修改:根据包围盒去计算识别号位置
This commit is contained in:
parent
84f388b2d8
commit
f5152e5807
@ -457,7 +457,6 @@ class SkinCode extends defaultStyle {
|
||||
haveTextHSDA: true, // 是否需创建textHSDA对象
|
||||
haveArrowText: true, // 是否需创建arrowText对象
|
||||
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||
aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置)
|
||||
textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
|
||||
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
|
||||
useSelfFormat: true, // 使用配置项的nameFormat
|
||||
|
@ -423,7 +423,6 @@ class SkinCode extends defaultStyle {
|
||||
haveTextHSDA: true, // 是否需创建textHSDA对象
|
||||
haveArrowText: true, // 是否需创建arrowText对象
|
||||
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||
aspectRatio: 4/7, // 字体宽高比例(用以拼接text是计算位置)
|
||||
textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
|
||||
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
|
||||
useSelfFormat: true, // 使用配置项的nameFormat
|
||||
|
@ -371,7 +371,6 @@ class SkinCode extends defaultStyle {
|
||||
haveTextHSDA: false, // 是否需创建textHSDA对象
|
||||
haveArrowText: true, // 是否需创建arrowText对象
|
||||
haveTrainBorder: false, // 是否需创建trainBorder对象
|
||||
aspectRatio: 8/15, // 字体宽高比例(用以拼接text是计算位置)
|
||||
textOffset: 1, // 字体偏移(用以控制字体据车头的距离)
|
||||
trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸
|
||||
},
|
||||
|
@ -217,23 +217,23 @@ export default class TrainBody extends Group {
|
||||
formatChangePosition(model, style) {
|
||||
if (this.nameFormat) {
|
||||
const arr = this.nameFormat.split(':');
|
||||
let fontNumber = 0;
|
||||
let widthText = 0;
|
||||
arr.forEach(ele => {
|
||||
if (ele == 'targetCode') {
|
||||
this.textTrainNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset) );
|
||||
fontNumber += (style.Train.trainNumber.targetCodePrefix || '').length;
|
||||
this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) );
|
||||
widthText += this.textTrainNumber.getBoundingRect().width;
|
||||
this.add(this.textTrainNumber);
|
||||
} else if (ele == 'serviceNumber') {
|
||||
this.textTrainServer.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||
fontNumber += (style.Train.trainServer.serviceNumberPrefix || '').length;
|
||||
this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
||||
widthText += this.textTrainServer.getBoundingRect().width;
|
||||
this.add(this.textTrainServer);
|
||||
} else if (ele == 'tripNumber') {
|
||||
this.textTrainTarget.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||
fontNumber += (style.Train.trainTarget.tripNumberPrefix || '').length;
|
||||
this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
||||
widthText += this.textTrainTarget.getBoundingRect().width;
|
||||
this.add(this.textTrainTarget);
|
||||
} else if (ele == 'groupNumber') {
|
||||
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset));
|
||||
fontNumber += (style.Train.trainTargetNumber.groupNumberPrefix || '').length;
|
||||
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
||||
widthText += this.textTrainTargetNumber.getBoundingRect().width;
|
||||
this.add(this.textTrainTargetNumber);
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user