diff --git a/src/jmap/config/skinStyle/bejing_01.js b/src/jmap/config/skinStyle/bejing_01.js index e510ccd53..710a1a982 100644 --- a/src/jmap/config/skinStyle/bejing_01.js +++ b/src/jmap/config/skinStyle/bejing_01.js @@ -456,7 +456,12 @@ class SkinStyle extends defaultStyle { fontFamily: 'consolas', // 默认字体 族类 haveTextHSDA: true, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 - haveTrainBorder: false// 是否需创建trainBorder对象 + haveTrainBorder: false, // 是否需创建trainBorder对象 + aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置) + textOffset: 4, // 字体偏移(用以控制字体据车头的距离) + trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 + useSelfFormat: true, // 使用配置项的nameFormat + useSelfText: true // 使用配置项的字体大小 }, trainStatusStyle: { destinationStatus: [ diff --git a/src/jmap/config/skinStyle/chengdu_03.js b/src/jmap/config/skinStyle/chengdu_03.js index 462a2c286..796fd8bee 100644 --- a/src/jmap/config/skinStyle/chengdu_03.js +++ b/src/jmap/config/skinStyle/chengdu_03.js @@ -422,7 +422,12 @@ class SkinStyle extends defaultStyle { fontFamily: 'consolas', // 默认字体 族类 haveTextHSDA: true, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 - haveTrainBorder: false // 是否需创建trainBorder对象 + haveTrainBorder: false, // 是否需创建trainBorder对象 + aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置) + textOffset: 4, // 字体偏移(用以控制字体据车头的距离) + trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 + useSelfFormat: true, // 使用配置项的nameFormat + useSelfText: true // 使用配置项的字体大小 }, trainStatusStyle: { defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色 diff --git a/src/jmap/config/skinStyle/chengdu_04.js b/src/jmap/config/skinStyle/chengdu_04.js index 7ac93a2e0..1aa852dc3 100644 --- a/src/jmap/config/skinStyle/chengdu_04.js +++ b/src/jmap/config/skinStyle/chengdu_04.js @@ -419,7 +419,12 @@ class SkinStyle extends defaultStyle { fontFamily: 'consolas', // 默认字体 族类 haveTextHSDA: true, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 - haveTrainBorder: false // 是否需创建trainBorder对象 + haveTrainBorder: false, // 是否需创建trainBorder对象 + aspectRatio: 7/5, // 字体宽高比例(用以拼接text是计算位置) + textOffset: 4, // 字体偏移(用以控制字体据车头的距离) + trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 + useSelfFormat: true, // 使用配置项的nameFormat + useSelfText: true // 使用配置项的字体大小 }, trainStatusStyle: { defaultDestinationColor: '#FFFFFF', // 默认目的地状态显示颜色 diff --git a/src/jmap/config/skinStyle/fuzhou_01.js b/src/jmap/config/skinStyle/fuzhou_01.js index e0b005879..61e8bd6c9 100644 --- a/src/jmap/config/skinStyle/fuzhou_01.js +++ b/src/jmap/config/skinStyle/fuzhou_01.js @@ -370,7 +370,10 @@ class SkinStyle extends defaultStyle { nameFontSize: 15, // 字体大小 haveTextHSDA: false, // 是否需创建textHSDA对象 haveArrowText: true, // 是否需创建arrowText对象 - haveTrainBorder: false// 是否需创建trainBorder对象 + haveTrainBorder: false, // 是否需创建trainBorder对象 + aspectRatio: 8/15, // 字体宽高比例(用以拼接text是计算位置) + textOffset: 1, // 字体偏移(用以控制字体据车头的距离) + trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸 }, trainStatusStyle: { destinationStatus: [ diff --git a/src/jmap/shape/Train/TrainBody.js b/src/jmap/shape/Train/TrainBody.js index 3d47dc083..714099fda 100644 --- a/src/jmap/shape/Train/TrainBody.js +++ b/src/jmap/shape/Train/TrainBody.js @@ -11,6 +11,7 @@ export default class TrainBody extends Group { super(); this.model = model; this.deviceModel = model.model; + this.nameFormat = model.nameFormat; this.create(); this.createMouse(); // 鼠标事件 } @@ -158,7 +159,7 @@ export default class TrainBody extends Group { style.Train.trainBody.specialTrainType.some((item) =>{ if (model.type === item.type) { serviceNumber = item.serviceNumber; - style.Train.trainBody.nameFormat = item.nameFormat; + this.nameFormat = item.nameFormat; return true; } }); @@ -213,20 +214,25 @@ export default class TrainBody extends Group { this.trainBodyBox && this.trainBodyBox.setColor(key, color); } formatChangePosition(model, style) { - if (style.Train.trainBody.trainNameFormat) { - const arr = style.Train.trainBody.trainNameFormat.split(':'); + if (this.nameFormat) { + const arr = this.nameFormat.split(':'); + let fontNumber = 0; arr.forEach(ele => { if (ele == 'targetCode') { - this.textTrainNumber.setStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x)); + 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.add(this.textTrainNumber); } else if (ele == 'serviceNumber') { - this.textTrainServer.setStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x)); + 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.add(this.textTrainServer); } else if (ele == 'tripNumber') { - this.textTrainTarget.setStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x)); + 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.add(this.textTrainTarget); } else if (ele == 'groupNumber') { - this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x)); + 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.add(this.textTrainTargetNumber); } }); diff --git a/src/jmap/shape/Train/index.js b/src/jmap/shape/Train/index.js index d0f84ddba..5ee1e3417 100644 --- a/src/jmap/shape/Train/index.js +++ b/src/jmap/shape/Train/index.js @@ -16,8 +16,9 @@ export default class Train extends Group { this.z = 40; this.size = 0; this.section = null; - this.fontSize = style.Train.common.nameFontSize || style.Train.common.trainTextFontSize; + this.fontSize = style.Train.common.useSelfText?style.Train.common.nameFontSize || style.Train.common.trainTextFontSize:model.nameFontSize || style.Train.common.nameFontSize || style.Train.common.trainTextFontSize; this.newScale = this.fontSize / style.Train.common.trainTextFontSize; + this.nameFormat = style.Train.common.useSelfFormat?style.Train.trainBody.trainNameFormat:model.nameFormat || style.Train.trainBody.trainNameFormat; this.create(); this.setState(model); } @@ -68,6 +69,7 @@ export default class Train extends Group { runControlStatus: model.runControlStatus, runStatus: model.runStatus, fontSize: this.fontSize, + nameFormat: this.nameFormat, type: model.type, speed: model.speed, maLen: model.maLen, @@ -290,24 +292,24 @@ export default class Train extends Group { // 是否根据车身上车组号、服务号、车次号、目的地码显示情况改变列车长度 isChangeTrainWidth(model, style) { if (!style.Train.trainBody.changeTrainWidth) { return; } - if (style.Train.trainBody.trainNameFormat) { - const arr = style.Train.trainBody.trainNameFormat.split(':'); + if (this.nameFormat) { + const arr = this.nameFormat.split(':'); arr.forEach(ele => { switch (ele) { case 'targetCode': { - this.size += style.Train.trainNumber.targetCodePrefix.length || 0; + this.size += (style.Train.trainNumber.targetCodePrefix || '').length; break; } case 'serviceNumber': { - this.size += style.Train.trainServer.serviceNumberPrefix.length || 0; + this.size += (style.Train.trainServer.serviceNumberPrefix || '').length; break; } case 'tripNumber': { - this.size += style.Train.trainTarget.tripNumberPrefix.length || 0; + this.size += (style.Train.trainTarget.tripNumberPrefix || '').length; break; } case 'groupNumber': { - this.size += style.Train.trainTargetNumber.groupNumberPrefix.length || 0; + this.size += (style.Train.trainTargetNumber.groupNumberPrefix || '').length; break; } } @@ -315,7 +317,7 @@ export default class Train extends Group { } else { this.size = 9; } - this.style.Train.common.trainWidth = this.size * this.fontSize * (2 / 3) -16; + this.style.Train.common.trainWidth = this.size * this.fontSize * this.style.Train.common.aspectRatio + this.style.Train.common.trainWidthMoreText; } removeTrainDetail() { this.trainB && this.trainB.removeTrainDetail();