From 05e4fd73bb1fa8cfc8d8b6d9e52dde58ce8b9ce4 Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Thu, 8 Aug 2019 09:35:28 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=EF=BC=9A=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/jmap/config/skinStyle/chengdu_03.js | 8 +- .../shape/Train/{TrainBody => }/EMouse.js | 0 src/jmap/shape/Train/TrainBody.js | 243 ++++++++++++++++++ src/jmap/shape/Train/TrainBody/TextHSDA.js | 83 ------ .../shape/Train/TrainBody/TextTrainNumber.js | 37 --- .../shape/Train/TrainBody/TextTrainServer.js | 35 --- .../shape/Train/TrainBody/TextTrainTarget.js | 35 --- .../Train/TrainBody/TextTrainTargetNumber.js | 35 --- src/jmap/shape/Train/TrainBody/index.js | 197 -------------- .../{TrainBody/Train.js => TrainBodyBox.js} | 0 .../{TrainHead/index.js => TrainHead.js} | 0 src/jmap/shape/Train/index.js | 4 +- src/jmap/shape/element/ETextName.js | 1 + 13 files changed, 250 insertions(+), 428 deletions(-) rename src/jmap/shape/Train/{TrainBody => }/EMouse.js (100%) create mode 100644 src/jmap/shape/Train/TrainBody.js delete mode 100644 src/jmap/shape/Train/TrainBody/TextHSDA.js delete mode 100644 src/jmap/shape/Train/TrainBody/TextTrainNumber.js delete mode 100644 src/jmap/shape/Train/TrainBody/TextTrainServer.js delete mode 100644 src/jmap/shape/Train/TrainBody/TextTrainTarget.js delete mode 100644 src/jmap/shape/Train/TrainBody/TextTrainTargetNumber.js delete mode 100644 src/jmap/shape/Train/TrainBody/index.js rename src/jmap/shape/Train/{TrainBody/Train.js => TrainBodyBox.js} (100%) rename src/jmap/shape/Train/{TrainHead/index.js => TrainHead.js} (100%) diff --git a/src/jmap/config/skinStyle/chengdu_03.js b/src/jmap/config/skinStyle/chengdu_03.js index 3b2709cb0..e028ac4dc 100644 --- a/src/jmap/config/skinStyle/chengdu_03.js +++ b/src/jmap/config/skinStyle/chengdu_03.js @@ -509,13 +509,13 @@ class SkinStyle extends defaultStyle { }, { status: '04', - trainLColor: '#A0522D', - trainRColor: '#A0522D' + trainLColor: '#C2C2C2', + trainRColor: '#C2C2C2' }, { status: '05', - trainLColor: '#A0522D', - trainRColor: '#A0522D' + trainLColor: '#C2C2C2', + trainRColor: '#C2C2C2' } ], // 列车运行模式对应车头颜色 01未知 02 ATO自动驾驶模式AM 03 ATP监控下的人工驾驶模式CM 04 限制人工驾驶模式RM 05 非限制人工驾驶模式RM runControlStatus: [ diff --git a/src/jmap/shape/Train/TrainBody/EMouse.js b/src/jmap/shape/Train/EMouse.js similarity index 100% rename from src/jmap/shape/Train/TrainBody/EMouse.js rename to src/jmap/shape/Train/EMouse.js diff --git a/src/jmap/shape/Train/TrainBody.js b/src/jmap/shape/Train/TrainBody.js new file mode 100644 index 000000000..cd49141cf --- /dev/null +++ b/src/jmap/shape/Train/TrainBody.js @@ -0,0 +1,243 @@ +import Group from 'zrender/src/container/Group'; +import TrainBodyBox from './TrainBodyBox'; +import '../StationStand/EDetain'; +import ETextName from '../element/ETextName'; // 名称文字 (共有) +import EMouse from './EMouse'; +import store from '@/store'; + +/** 车身*/ +export default class TrainBody extends Group { + constructor(model) { + super(); + this.model = model; + this.deviceModel = model.model; + this.create(); + this.createMouse(); // 鼠标事件 + } + + createMouse() { + this.mouseEvent = new EMouse(this); + this.add(this.mouseEvent); + if (this.deviceModel.down) { + store.dispatch('map/setTrainDetails', this.deviceModel); + this.mouseEvent.mouseover(); + } + + this.on('mouseover', () => { + store.dispatch('map/setTrainDetails', this.deviceModel); + this.mouseEvent.mouseover(); + }); + this.on('mouseout', () => { + store.dispatch('map/setTrainDetails', null); + this.mouseEvent.mouseout(); + }); + } + + create() { + const model = this.model; + const style = this.model.style; + this.trainBodyBox = new TrainBodyBox({ + zlevel: model.zlevel, + z: model.z, + shape: { + x: model.point.x, + y: model.point.y, + width: style.Train.common.trainWidth, + height: style.Train.common.trainHeight + }, + style: { + lineWidth: style.Train.trainBody.trainBodyLineWidth, + stroke: style.trainSidelineColor, + fill: style.Train.trainBody.trainBodyFillColor + }, + cursor: 'pointer' + }); + + const beginX = (model.point.x + style.Train.trainBody.lrPadding); + const beginY = (model.point.y - style.Train.hsda.trainHSDATextFontSize - style.Train.hsda.upPaddingHSDA); + const margin = (style.Train.common.trainWidth - style.Train.hsda.lrPaddingHSDA * 2) / 4; + + this.textH = style.Train.common.haveTextHSDA ? new ETextName({ + zlevel: model.zlevel, + z: model.z, + x: parseInt(beginX + margin * 0), + y: parseInt(beginY), + text: style.Train.hsda.textHContent, + textFill: style.trainYellowColor, + fontSize: style.Train.hsda.trainHSDATextFontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'middle', + textVerticalAlign: 'top' + }) : ''; + this.textS = style.Train.common.haveTextHSDA ? new ETextName({ + zlevel: model.zlevel, + z: model.z, + x: parseInt(beginX + margin * 1), + y: parseInt(beginY), + text: style.Train.hsda.textSContent, + textFill: style.trainBlueColor, + fontSize: style.Train.hsda.trainHSDATextFontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'middle', + textVerticalAlign: 'top' + }) : ''; + this.textD = style.Train.common.haveTextHSDA ? new ETextName({ + zlevel: model.zlevel, + z: model.z, + x: parseInt(beginX + margin * 2), + y: parseInt(beginY), + text: style.Train.hsda.textDContent, + textFill: style.trainGreenColor, + fontSize: style.Train.hsda.trainHSDATextFontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'middle', + textVerticalAlign: 'top' + }) : ''; + this.textA = style.Train.common.haveTextHSDA ? new ETextName({ + zlevel: model.zlevel, + z: model.z, + x: parseInt(beginX + margin * 3), + y: parseInt(beginY), + text: style.Train.hsda.textAContent, + textFill: style.trainRedColor, + fontSize: style.Train.hsda.trainHSDATextFontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'middle', + textVerticalAlign: 'top' + }) : ''; + let serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号) + const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode + ?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber) + :model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号 + const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码 + const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号 + + this.textTrainServer = new ETextName({ + zlevel: model.zlevel, + z: model.z+1, + x: parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x), + y: parseInt(model.point.y + style.Train.trainServer.trainServerOffset.y), + text: serviceNumber.substring(serviceNumber.length - style.Train.trainServer.serviceNumberPrefix.length), + textFill: style.trainTextColor, + fontSize: model.fontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'left', + textVerticalAlign: 'top' + }); + this.textTrainTarget = new ETextName({ + zlevel: this.model.zlevel, + z: this.model.z+1, + x: parseInt(model.point.x + model.style.Train.trainTarget.trainTargetOffset.x), + y: parseInt(model.point.y + model.style.Train.trainTarget.trainTargetOffset.y), + text: tripNumber.substring(tripNumber.length - 3), + textFill: style.trainTextColor, + fontSize: model.fontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: style.Train.trainTarget.trainTargetTextAlign, + textVerticalAlign: 'top' + }); + this.textTrainNumber = new ETextName({ + zlevel: model.zlevel, + z: model.z+1, + x: parseInt(model.point.x + style.Train.trainBody.lrPadding), + y: parseInt(model.point.y + style.Train.trainBody.upPadding), + text: targetCode.substring(targetCode.length - 3), + textFill: style.trainTextColor, + textStroke: style.trainTextColor, + fontWeight: 400, + textStrokeWidth: 0, + fontSize: model.fontSize, + fontFamily: style.Train.common.fontFamily, + textAlign: 'left', + textVerticalAlign: 'top' + }); + this.textTrainTargetNumber = new ETextName({ + zlevel: model.zlevel, + z: model.z+1, + x: parseInt(model.point.x - style.Train.trainBody.lrPadding), + y: parseInt(model.point.y + style.Train.trainBody.upPadding), + text: groupNumber.substring(groupNumber.length - 3), + textFill: style.trainTextColor, + textStroke: style.trainTextColor, + textStrokeWidth: 0, + fontSize: model.fontSize, + textAlign: 'left', + textVerticalAlign: 'top' + }); + // 根据列车类型设置显示格式 + if ( style.Train.trainBody.specialTrainType.length > 0) { + style.Train.trainBody.specialTrainType.some((item) =>{ + if (model.type === item.type) { + serviceNumber = item.serviceNumber; + style.Train.trainBody.nameFormat = item.nameFormat; + return true; + } + }); + } + this.formatChangePosition(model, style); + this.add(this.trainBodyBox); + if (style.Train.common.haveTextHSDA) { + this.add(this.textH); + this.add(this.textS); + this.add(this.textD); + this.add(this.textA); + } + } + + removeTrainDetail() { + this.mouseEvent.mouseout(); + store.dispatch('map/setTrainDetails', null); + this.deviceModel.down = false; + } + setTrainColor(color) { + this.trainBodyBox && this.trainBodyBox.setStyle('fill', color); + } + setTextTrainServerColor(color) { + this.textTrainServer.setStyle('textFill', color); + this.textTrainServer.setStyle('textStroke', color); + } + setTextTrainTargetColor(color) { + this.textTrainTarget.setStyle('textFill', color); + this.textTrainTarget.setStyle('textStroke', color); + } + setHShow(isShow) { + if (this.textH) { + isShow ? this.textH.show() : this.textH.hide(); + } + } + setSShow(isShow) { + if (this.textS) { + isShow ? this.textS.show() : this.textS.hide(); + } + } + setDShow(isShow) { + if (this.textD) { + isShow ? this.textD.show() : this.textD.hide(); + } + } + setAShow(isShow) { + if (this.textA) { + isShow ? this.textA.show() : this.textA.hide(); + } + } + formatChangePosition(model, style) { + if (style.Train.trainBody.trainNameFormat) { + const arr = style.Train.trainBody.trainNameFormat.split(':'); + arr.forEach(ele => { + if (ele == 'targetCode') { + this.textTrainNumber.setStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x)); + this.add(this.textTrainNumber); + } else if (ele == 'serviceNumber') { + this.textTrainServer.setStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x)); + this.add(this.textTrainServer); + } else if (ele == 'tripNumber') { + this.textTrainTarget.setStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x)); + this.add(this.textTrainTarget); + } else if (ele == 'groupNumber') { + this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x)); + this.add(this.textTrainTargetNumber); + } + }); + } + } +} diff --git a/src/jmap/shape/Train/TrainBody/TextHSDA.js b/src/jmap/shape/Train/TrainBody/TextHSDA.js deleted file mode 100644 index aee827b01..000000000 --- a/src/jmap/shape/Train/TrainBody/TextHSDA.js +++ /dev/null @@ -1,83 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; - -export default class TextHSDA extends Group { - constructor(model) { - super(); - this.model = model; - this.create(); - } - create() { - const model = this.model; - this.textH = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: parseInt(model.beginX + model.margin * 0), - y: parseInt(model.beginY), - text: 'H', - textFill: model.trainYellowColor, - textFont: model.TextFontHSDA, - textAlign: model.textAlign, - textVerticalAlign: model.textVerticalAlign - } - }); - this.textS = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: parseInt(model.beginX + model.margin * 1), - y: parseInt(model.beginY), - text: 'S', - textFill: model.trainBlueColor, - textFont: model.TextFontHSDA, - textAlign: model.textAlign, - textVerticalAlign: model.textVerticalAlign - } - }); - - this.textD = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: parseInt(model.beginX + model.margin * 2), - y: parseInt(model.beginY), - text: 'D', - textFill: model.trainGreenColor, - textFont: model.TextFontHSDA, - textAlign: model.textAlign, - textVerticalAlign: model.textVerticalAlign - } - }); - - this.textA = new Text({ - zlevel: model.zlevel, - z: model.z, - style: { - x: parseInt(model.beginX + model.margin * 3), - y: parseInt(model.beginY), - text: 'A', - textFill: model.trainRedColor, - textFont: model.TextFontHSDA, - textAlign: model.textAlign, - textVerticalAlign: model.textVerticalAlign - } - }); - this.add(this.textH); - this.add(this.textS); - this.add(this.textD); - this.add(this.textA); - } - setHShow(isShow) { - isShow ? this.textH.show() : this.textH.hide(); - } - setSShow(isShow) { - isShow ? this.textS.show() : this.textS.hide(); - } - setDShow(isShow) { - isShow ? this.textD.show() : this.textD.hide(); - } - setAShow(isShow) { - isShow ? this.textA.show() : this.textA.hide(); - } -} diff --git a/src/jmap/shape/Train/TrainBody/TextTrainNumber.js b/src/jmap/shape/Train/TrainBody/TextTrainNumber.js deleted file mode 100644 index 546fe4444..000000000 --- a/src/jmap/shape/Train/TrainBody/TextTrainNumber.js +++ /dev/null @@ -1,37 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; -/** 目的码 */ -export default class TextTrainNumber extends Group { - constructor(model) { - super(); - this.model = model; - this.create(); - } - create() { - const model = this.model; - this.textTrainNumber = new Text({ - zlevel: model.zlevel, - z: model.z+1, - style: { - x: parseInt(model.point.x + model.lrPadding), - y: parseInt(model.point.y + model.upPadding), - text: model.targetCode.substring(model.targetCode.length - 3), - textFill: model.trainTextColor, - textStroke: model.trainTextColor, - fontWeight: 400, - textStrokeWidth: 0, - textFont: model.textFont, - textAlign: 'left', - textVerticalAlign: 'top', - onmouseover: model.onmouseover, - onmouseout: model.onmouseout - }, - cursor: 'pointer' - }); - this.add(this.textTrainNumber); - } - setShapeStyle(key, style) { - this.textTrainNumber.setStyle(key, style); - } - -} diff --git a/src/jmap/shape/Train/TrainBody/TextTrainServer.js b/src/jmap/shape/Train/TrainBody/TextTrainServer.js deleted file mode 100644 index 978d108f1..000000000 --- a/src/jmap/shape/Train/TrainBody/TextTrainServer.js +++ /dev/null @@ -1,35 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; -/** 服务号、表号 */ -export default class TextTrainServer extends Group { - constructor(model) { - super(); - this.model = model; - this.create(); - } - create() { - this.textTrainServer = new Text({ - zlevel: this.model.zlevel, - z: this.model.z+1, - style: { - x: parseInt(this.model.point.x + this.model.style.Train.trainServer.trainServerOffset.x), - y: parseInt(this.model.point.y + this.model.style.Train.trainServer.trainServerOffset.y), - text: this.model.serviceNumber.substring(this.model.serviceNumber.length - this.model.style.Train.trainServer.serviceNumberPrefix.length), - textFill: this.model.trainBrownColor, - textFont: this.model.textFont, - textAlign: 'left', - textVerticalAlign: 'top', - onmouseover: this.model.onmouseover, - onmouseout: this.model.onmouseout - }, - cursor: 'pointer' - }); - this.add(this.textTrainServer); - } - setColor(key, color) { - this.textTrainServer.setStyle(key, color); - } - setShapeStyle(key, style) { - this.textTrainServer.setStyle(key, style); - } -} diff --git a/src/jmap/shape/Train/TrainBody/TextTrainTarget.js b/src/jmap/shape/Train/TrainBody/TextTrainTarget.js deleted file mode 100644 index 55dcf31c2..000000000 --- a/src/jmap/shape/Train/TrainBody/TextTrainTarget.js +++ /dev/null @@ -1,35 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; - -export default class TextTrainTarget extends Group { - constructor(model) { - super(); - this.model = model; - this.create(); - } - create() { - this.textTrainTarget = new Text({ - zlevel: this.model.zlevel, - z: this.model.z+1, - style: { - x: parseInt(this.model.point.x + this.model.style.Train.trainTarget.trainTargetOffset.x), - y: parseInt(this.model.point.y + this.model.style.Train.trainTarget.trainTargetOffset.y), - text: this.model.tripNumber.substring(this.model.tripNumber.length - 3), - textFill: this.model.trainYellowColor, - textFont: this.model.textFont, - textAlign: this.model.style.Train.trainTarget.trainTargetTextAlign, - textVerticalAlign: 'top', - onmouseover: this.model.onmouseover, - onmouseout: this.model.onmouseout - }, - cursor: 'pointer' - }); - this.add(this.textTrainTarget); - } - setColor(key, color) { - this.textTrainTarget.setStyle(key, color); - } - setShapeStyle(key, style) { - this.textTrainTarget.setStyle(key, style); - } -} diff --git a/src/jmap/shape/Train/TrainBody/TextTrainTargetNumber.js b/src/jmap/shape/Train/TrainBody/TextTrainTargetNumber.js deleted file mode 100644 index ad1d06980..000000000 --- a/src/jmap/shape/Train/TrainBody/TextTrainTargetNumber.js +++ /dev/null @@ -1,35 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Text from 'zrender/src/graphic/Text'; -/** 车组号 */ -export default class TextTrainTargetNumber extends Group { - constructor(model) { - super(); - this.model = model; - this.create(); - } - create() { - const model = this.model; - this.textTrainTargetNumber = new Text({ - zlevel: model.zlevel, - z: model.z+1, - style: { - x: parseInt(model.point.x - model.lrPadding), - y: parseInt(model.point.y + model.upPadding), - text: model.groupNumber.substring(model.groupNumber.length - 3), - textFill: model.trainTextColor, - textStroke: model.trainTextColor, - textStrokeWidth: 0, - textFont: model.textFont, - textAlign: 'left', - textVerticalAlign: 'top', - onmouseover: model.onmouseover, - onmouseout: model.onmouseout - }, - cursor: 'pointer' - }); - this.add(this.textTrainTargetNumber); - } - setShapeStyle(key, style) { - this.textTrainTargetNumber.setStyle(key, style); - } -} diff --git a/src/jmap/shape/Train/TrainBody/index.js b/src/jmap/shape/Train/TrainBody/index.js deleted file mode 100644 index 03c58f204..000000000 --- a/src/jmap/shape/Train/TrainBody/index.js +++ /dev/null @@ -1,197 +0,0 @@ -import Group from 'zrender/src/container/Group'; -import Train from './Train'; -import '../../StationStand/EDetain'; -import TextHSDA from './TextHSDA'; -import TextTrainServer from './TextTrainServer'; -import TextTrainTarget from './TextTrainTarget'; -import TextTrainNumber from './TextTrainNumber'; -import TextTrainTargetNumber from './TextTrainTargetNumber'; -import EMouse from './EMouse'; -import store from '@/store'; - -/** 车身*/ -export default class TrainBody extends Group { - constructor(model) { - super(); - this.model = model; - this.deviceModel = model.model; - this.create(); - this.createMouse(); // 鼠标事件 - } - - createMouse() { - this.mouseEvent = new EMouse(this); - this.add(this.mouseEvent); - if (this.deviceModel.down) { - store.dispatch('map/setTrainDetails', this.deviceModel); - this.mouseEvent.mouseover(); - } - - this.on('mouseover', () => { - store.dispatch('map/setTrainDetails', this.deviceModel); - this.mouseEvent.mouseover(); - }); - this.on('mouseout', () => { - store.dispatch('map/setTrainDetails', null); - this.mouseEvent.mouseout(); - }); - } - - create() { - const model = this.model; - const style = this.model.style; - const textFont = model.fontSize + 'px ' + style.Train.common.fontFamily; - const TextFontHSDA = style.Train.hsda.trainHSDATextFontSize + 'px ' + style.Train.common.fontFamily; - - this.train = new Train({ - zlevel: model.zlevel, - z: model.z, - shape: { - x: model.point.x, - y: model.point.y, - width: style.Train.common.trainWidth, - height: style.Train.common.trainHeight - }, - style: { - lineWidth: style.Train.trainBody.trainBodyLineWidth, - stroke: style.trainSidelineColor, - fill: style.Train.trainBody.trainBodyFillColor - }, - cursor: 'pointer' - }); - - const beginX = (model.point.x + style.Train.trainBody.lrPadding); - const beginY = (model.point.y - style.Train.hsda.trainHSDATextFontSize - style.Train.hsda.upPaddingHSDA); - const margin = (style.Train.common.trainWidth - style.Train.hsda.lrPaddingHSDA * 2) / 4; - this.textHSDA = style.Train.common.haveTextHSDA ? new TextHSDA({ - zlevel: model.zlevel, - z: model.z, - beginX: beginX, - beginY: beginY, - margin: margin, - trainYellowColor: style.trainYellowColor, - trainBlueColor: style.trainBlueColor, - textFontHSDA: TextFontHSDA, - textAlign: 'middle', - textVerticalAlign: 'top' - }) : ''; - - let serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号) - const tripNumber = style.Train.trainTarget.tripNumberPrefix + (style.Train.trainTarget.defaultDirectionCode - ?(model.directionCode||style.Train.trainTarget.defaultDirectionCode) + (model.tripNumber || style.Train.trainTarget.defaultTripNumber) - :model.tripNumber || style.Train.trainTarget.defaultTripNumber) + ''; // 车次号 - const targetCode = style.Train.trainNumber.targetCodePrefix + (model.targetCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码 - const groupNumber = style.Train.trainTargetNumber.groupNumberPrefix + (model.groupNumber || style.Train.trainTargetNumber.defaultGroupNumber) + ''; // 车组号 - - this.textTrainServer = new TextTrainServer({ - zlevel: model.zlevel, - z: model.z, - point: model.point, - style: style, - serviceNumber: serviceNumber, - trainBrownColor: style.trainTextColor, - textFont: textFont - }); - - this.textTrainTarget = new TextTrainTarget({ - zlevel: model.zlevel, - z: model.z, - point: model.point, - trainWidth: model.style.Train.common.trainWidth, - style: style, - tripNumber: tripNumber, - trainYellowColor: style.trainTextColor, - textFont: textFont - }); - - this.textTrainNumber = new TextTrainNumber({ - zlevel: model.zlevel, - z: model.z, - point: model.point, - lrPadding: style.Train.trainBody.lrPadding, - upPadding: style.Train.trainBody.upPadding, - targetCode: targetCode, - trainTextColor: style.trainTextColor, - textFont: textFont - }); - - this.textTrainTargetNumber = new TextTrainTargetNumber({ - zlevel: model.zlevel, - z: model.z, - point: model.point, - lrPadding: style.Train.lrPadding, - upPadding: style.Train.upPadding, - groupNumber: groupNumber, - trainTextColor: style.trainTextColor, - textFont: textFont - }); - // 根据列车类型设置显示格式 - if ( style.Train.trainBody.specialTrainType.length > 0) { - style.Train.trainBody.specialTrainType.some((item) =>{ - if (model.type === item.type) { - serviceNumber = item.serviceNumber; - style.Train.trainBody.nameFormat = item.nameFormat; - return true; - } - }); - } - this.formatChangePosition(model, style); - this.add(this.train); - this.add(this.arrowText); - this.add(this.textHSDA); - } - - removeTrainDetail() { - this.mouseEvent.mouseout(); - store.dispatch('map/setTrainDetails', null); - this.deviceModel.down = false; - } - setTrainColor(color) { - this.train && this.train.setColor('fill', color); - } - setTextTrainServerColor(color) { - this.textTrainServer.setColor('textFill', color); - this.textTrainServer.setColor('textStroke', color); - } - setTextTrainTargetColor(color) { - this.textTrainTarget.setColor('textFill', color); - this.textTrainTarget.setColor('textStroke', color); - } - setHShow(isShow) { - this.textHSDA && this.textHSDA.setHShow(isShow); - } - setSShow(isShow) { - this.textHSDA && this.textHSDA.setSShow(isShow); - } - setDShow(isShow) { - this.textHSDA && this.textHSDA.setDShow(isShow); - } - setAShow(isShow) { - this.textHSDA && this.textHSDA.setAShow(isShow); - } - onMouseOver() { - this.arrowText.setShapeStyle('x', this.model.point.x+50); - this.arrowText.setShapeStyle('y', this.model.point.y+25); - this.arrowText.getArrowText().show(); - } - formatChangePosition(model, style) { - if (style.Train.trainBody.trainNameFormat) { - const arr = style.Train.trainBody.trainNameFormat.split(':'); - arr.forEach(ele => { - if (ele == 'targetCode') { - this.textTrainNumber.setShapeStyle('x', parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x)); - this.add(this.textTrainNumber); - } else if (ele == 'serviceNumber') { - this.textTrainServer.setShapeStyle('x', parseInt(model.point.x + style.Train.trainServer.trainServerOffset.x)); - this.add(this.textTrainServer); - } else if (ele == 'tripNumber') { - this.textTrainTarget.setShapeStyle('x', parseInt(model.point.x + style.Train.trainTarget.trainTargetOffset.x)); - this.add(this.textTrainTarget); - } else if (ele == 'groupNumber') { - this.textTrainTargetNumber.setShapeStyle('x', parseInt(model.point.x + style.Train.textTrainTargetNumber.trainTargetNumberOffset.x)); - this.add(this.textTrainTargetNumber); - } - }); - } - } -} diff --git a/src/jmap/shape/Train/TrainBody/Train.js b/src/jmap/shape/Train/TrainBodyBox.js similarity index 100% rename from src/jmap/shape/Train/TrainBody/Train.js rename to src/jmap/shape/Train/TrainBodyBox.js diff --git a/src/jmap/shape/Train/TrainHead/index.js b/src/jmap/shape/Train/TrainHead.js similarity index 100% rename from src/jmap/shape/Train/TrainHead/index.js rename to src/jmap/shape/Train/TrainHead.js diff --git a/src/jmap/shape/Train/index.js b/src/jmap/shape/Train/index.js index 85cf3af96..822953b63 100644 --- a/src/jmap/shape/Train/index.js +++ b/src/jmap/shape/Train/index.js @@ -1,6 +1,6 @@ import Group from 'zrender/src/container/Group'; -import TrainHead from './TrainHead/index'; -import TrainBody from './TrainBody/index'; +import TrainHead from './TrainHead'; +import TrainBody from './TrainBody'; import BoundingRect from 'zrender/src/core/BoundingRect'; import Rect from 'zrender/src/graphic/shape/Rect'; diff --git a/src/jmap/shape/element/ETextName.js b/src/jmap/shape/element/ETextName.js index 99043cf6f..50bcb9fdc 100644 --- a/src/jmap/shape/element/ETextName.js +++ b/src/jmap/shape/element/ETextName.js @@ -15,6 +15,7 @@ export default function ETextName(model) { fontSize: model.fontSize, fontFamily: model.fontFamily, text: model.text, + textStrokeWidth: model.textStrokeWidth, textFill: model.textFill, textAlign: model.textAlign, textPosition: model.textPosition || 'inside',