2019-11-29 12:51:58 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import TrainBodyBox from './TrainBodyBox';
|
|
|
|
import '../StationStand/EDetain';
|
|
|
|
import ETextName from '../element/ETextName'; // 名称文字 (共有)
|
|
|
|
import EMouse from './EMouse';
|
2020-04-01 13:47:29 +08:00
|
|
|
import store from '@/store/index_APP_TARGET';
|
2020-03-02 14:46:59 +08:00
|
|
|
import Circle from 'zrender/src/graphic/shape/Circle';
|
2020-03-09 09:58:49 +08:00
|
|
|
import BoundingRect from 'zrender/src/core/BoundingRect';
|
2019-11-29 12:51:58 +08:00
|
|
|
|
|
|
|
/** 车身*/
|
|
|
|
export default class TrainBody extends Group {
|
2020-03-09 09:58:49 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.deviceModel = model.model;
|
2020-03-25 17:15:16 +08:00
|
|
|
this.style = model.style;
|
2020-03-09 09:58:49 +08:00
|
|
|
this.nameFormat = model.nameFormat;
|
|
|
|
this.create();
|
|
|
|
this.createMouse(); // 鼠标事件
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
createMouse() {
|
|
|
|
this.mouseEvent = new EMouse(this);
|
|
|
|
this.add(this.mouseEvent);
|
|
|
|
if (this.deviceModel.down) {
|
|
|
|
store.dispatch('map/setTrainDetails', this.deviceModel);
|
|
|
|
this.mouseEvent.mouseover();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
this.on('mouseover', () => {
|
|
|
|
store.dispatch('map/setTrainDetails', this.deviceModel);
|
|
|
|
this.mouseEvent.mouseover();
|
|
|
|
});
|
|
|
|
this.on('mouseout', () => {
|
|
|
|
store.dispatch('map/setTrainDetails', null);
|
|
|
|
this.mouseEvent.mouseout();
|
|
|
|
});
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
create() {
|
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
|
|
|
this.trainBodyBox = new TrainBodyBox({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
point: model.point,
|
|
|
|
style: style
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
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;
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
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,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
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,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
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,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
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,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'middle',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
}) : '';
|
2020-05-26 16:17:16 +08:00
|
|
|
const serviceNumber = style.Train.trainServer.serviceNumberPrefix + (model.serviceNumber || model.model.specialServiceNumber || style.Train.trainServer.defaultServiceNumber) + '';// 服务号(表号)
|
2020-03-09 09:58:49 +08:00
|
|
|
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) + ''; // 车次号
|
2020-03-12 14:41:53 +08:00
|
|
|
const targetCode = style.Train.trainNumber.targetCodePrefix + (model.destinationCode || style.Train.trainNumber.defaultTargetCode) + ''; // 目的地码
|
2020-03-09 09:58:49 +08:00
|
|
|
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: model.style.Train.trainServer.fontColor || style.trainTextColor,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
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 - style.Train.trainTarget.tripNumberPrefix.length),
|
|
|
|
textFill: model.style.Train.trainTarget.fontColor || style.trainTextColor,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-25 15:22:52 +08:00
|
|
|
textAlign: 'left',
|
2020-03-09 09:58:49 +08:00
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
|
|
|
this.textTrainNumber = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.trainNumber.trainNumberOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.trainNumber.trainNumberOffset.y),
|
2020-03-25 15:22:52 +08:00
|
|
|
text: targetCode.substring(targetCode.length - style.Train.trainNumber.targetCodePrefix.length),
|
2020-05-14 10:22:13 +08:00
|
|
|
textFill: model.style.Train.trainNumber.fontColor || style.trainTextColor,
|
2020-03-09 09:58:49 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
|
|
|
this.textTrainTargetNumber = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.trainTargetNumber.trainTargetNumberOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.trainTargetNumber.trainTargetNumberOffset.y),
|
2020-04-15 09:33:21 +08:00
|
|
|
text: groupNumber.substring(groupNumber.length - style.Train.trainTargetNumber.groupNumberPrefix.length),
|
2020-03-09 09:58:49 +08:00
|
|
|
textFill: style.trainTextColor,
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-03-09 09:58:49 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
|
|
|
});
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasAtrStatus) {
|
2020-03-02 14:46:59 +08:00
|
|
|
this.atrStatus = new Circle({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
shape: {
|
|
|
|
cx: parseInt(model.point.x + style.Train.trainAtrStatus.trainAtrStatusOffset.x),
|
|
|
|
cy: parseInt(model.point.y + style.Train.trainAtrStatus.trainAtrStatusOffset.y),
|
|
|
|
r: style.Train.trainAtrStatus.r
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
fill: '#ff0000'
|
|
|
|
}
|
|
|
|
});
|
2020-03-07 18:57:01 +08:00
|
|
|
// this.add(this.atrStatus);
|
2020-03-02 14:46:59 +08:00
|
|
|
}
|
|
|
|
if (style.Train.common.hasTravelSigns) {
|
2020-05-20 17:08:21 +08:00
|
|
|
const travelSignsOffsetX = this.deviceModel.right ? style.Train.travelSigns.trainTravelRightSignsOffset.x + 4 : style.Train.travelSigns.trainTravelLeftSignsOffset.x;
|
2020-03-09 18:25:25 +08:00
|
|
|
const travelSignsOffsetY = this.deviceModel.right ? style.Train.travelSigns.trainTravelRightSignsOffset.y : style.Train.travelSigns.trainTravelLeftSignsOffset.y;
|
2020-03-02 14:46:59 +08:00
|
|
|
this.travelSigns = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
2020-03-09 09:58:49 +08:00
|
|
|
x: parseInt(model.point.x + travelSignsOffsetX),
|
|
|
|
y: parseInt(model.point.y + travelSignsOffsetY),
|
2020-03-07 18:57:01 +08:00
|
|
|
text: this.deviceModel.right ? '>' : '<',
|
|
|
|
textFill: '#00C300',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.travelSigns);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasCrewNum) {
|
|
|
|
this.crewNum = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.crewNum.trainCrewNumOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.crewNum.trainCrewNumOffset.y),
|
|
|
|
text: 'BBB',
|
|
|
|
textFill: style.trainTextColor,
|
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.crewNum);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasTravelNum) {
|
|
|
|
this.travelNum = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.travelNum.trainTravelNumOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.travelNum.trainTravelNumOffset.y),
|
2020-05-20 17:08:21 +08:00
|
|
|
text: model.destinationCode,
|
2020-03-07 18:57:01 +08:00
|
|
|
textFill: '#00C300',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.travelNum);
|
|
|
|
}
|
|
|
|
if (style.Train.common.hasDelayTime) {
|
|
|
|
this.delayTime = new ETextName({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z + 1,
|
|
|
|
x: parseInt(model.point.x + style.Train.delayTime.trainDelayTimeOffset.x),
|
|
|
|
y: parseInt(model.point.y + style.Train.delayTime.trainDelayTimeOffset.y),
|
2020-05-20 17:08:21 +08:00
|
|
|
text: model.dt > 0 ? '+' + model.dt : model.dt,
|
2020-03-07 18:57:01 +08:00
|
|
|
textFill: '#DADA00',
|
2020-03-02 14:46:59 +08:00
|
|
|
textStroke: style.trainTextColor,
|
|
|
|
textStrokeWidth: 0,
|
|
|
|
fontSize: model.fontSize,
|
2020-05-26 09:21:48 +08:00
|
|
|
fontFamily: style.Train.common.fontFamily,
|
2020-06-02 17:50:56 +08:00
|
|
|
textAlign: 'left',
|
|
|
|
textVerticalAlign: 'top'
|
2020-03-02 14:46:59 +08:00
|
|
|
});
|
|
|
|
this.add(this.delayTime);
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 09:58:49 +08:00
|
|
|
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 && this.textTrainServer.setStyle('textFill', color);
|
|
|
|
this.textTrainServer && this.textTrainServer.setStyle('textStroke', color);
|
|
|
|
}
|
|
|
|
setTextTrainTargetColor(color) {
|
|
|
|
this.textTrainTarget && this.textTrainTarget.setStyle('textFill', color);
|
|
|
|
this.textTrainTarget && this.textTrainTarget.setStyle('textStroke', color);
|
|
|
|
}
|
|
|
|
setTextTrainNumberColor(color) {
|
|
|
|
this.textTrainNumber && this.textTrainNumber.setStyle('textFill', color);
|
|
|
|
this.textTrainNumber && this.textTrainNumber.setStyle('textStroke', color);
|
|
|
|
}
|
|
|
|
setTextTrainTargetNumberColor(color) {
|
|
|
|
this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle('textFill', color);
|
|
|
|
this.textTrainTargetNumber && this.textTrainTargetNumber.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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
setBodyBoxShape(key, color) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor(key, color);
|
|
|
|
}
|
2020-03-03 09:46:50 +08:00
|
|
|
getBoundingRect() {
|
2020-05-14 11:03:24 +08:00
|
|
|
if (this.trainBodyBox) {
|
|
|
|
const tempRect = this.trainBodyBox.getBoundingRect().clone();
|
2020-05-20 14:46:26 +08:00
|
|
|
return tempRect;
|
|
|
|
} else {
|
|
|
|
return new BoundingRect(0, 0, 0, 0);
|
2020-05-14 11:03:24 +08:00
|
|
|
}
|
2020-03-03 09:46:50 +08:00
|
|
|
}
|
2020-05-29 16:55:25 +08:00
|
|
|
getBoundingRectOfFont() { // 获取文字宽度
|
|
|
|
if (this.textTrainServer) {
|
|
|
|
const tempRect = this.textTrainServer.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
|
|
|
} else if (this.textTrainTarget) {
|
|
|
|
const tempRect = this.textTrainTarget.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
|
|
|
} else if (this.textTrainNumber) {
|
|
|
|
const tempRect = this.textTrainNumber.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
|
|
|
} else if (this.textTrainTargetNumber) {
|
|
|
|
const tempRect = this.textTrainTargetNumber.getBoundingRect().clone();
|
|
|
|
return tempRect;
|
|
|
|
} else {
|
|
|
|
return new BoundingRect(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
2020-05-22 13:05:08 +08:00
|
|
|
setPlanRoutingTypeColor(planRoutingTypes) {
|
|
|
|
if (planRoutingTypes === 'BIG') {
|
|
|
|
this.style.Train.trainTarget.bigColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainTarget.bigColor});
|
|
|
|
} else if (planRoutingTypes === 'SMALL') {
|
|
|
|
this.style.Train.trainTarget.smallColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainTarget.smallColor});
|
|
|
|
} else if (planRoutingTypes === 'INBOUND') {
|
|
|
|
this.style.Train.trainTarget.inboundColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainTarget.inboundColor});
|
|
|
|
}
|
|
|
|
}
|
2020-05-22 14:47:19 +08:00
|
|
|
setTrainTypeColor(type) {
|
|
|
|
if (type === 'PLAN') {
|
|
|
|
this.style.Train.trainTarget.planTypeColor && this.textTrainTarget && this.textTrainTarget.setStyle({textFill: this.style.Train.trainTarget.planTypeColor});
|
|
|
|
} else if (type === 'MANUAL') {
|
2020-05-25 11:00:10 +08:00
|
|
|
this.style.Train.trainTargetNumber.manualTypeColor && this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle({textFill: this.style.Train.trainTargetNumber.manualTypeColor});
|
2020-05-22 14:47:19 +08:00
|
|
|
} else if (type === 'HEAD') {
|
2020-05-25 11:00:10 +08:00
|
|
|
this.style.Train.trainTargetNumber.headTypeColor && this.textTrainTargetNumber && this.textTrainTargetNumber.setStyle({textFill: this.style.Train.trainTargetNumber.headTypeColor});
|
2020-05-22 14:47:19 +08:00
|
|
|
}
|
|
|
|
}
|
2020-05-20 17:08:21 +08:00
|
|
|
setSoonerOrLater(dt) {
|
2020-05-20 17:44:47 +08:00
|
|
|
if (this.style.Train.soonerOrLater && this.style.Train.soonerOrLater.level === 5) {
|
2020-05-20 17:08:21 +08:00
|
|
|
if (dt > 120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.severeEarlyColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.severeEarlyColor});
|
|
|
|
} else if (dt >= 15 && dt <= 120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.earlyColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.earlyColor});
|
|
|
|
} else if (dt <= -15 && dt >= -120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.lateColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.lateColor});
|
|
|
|
} else if (dt < -120) {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.severeLateColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.severeLateColor});
|
|
|
|
} else {
|
|
|
|
this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.normalColor});
|
|
|
|
this.delayTime && this.delayTime.setStyle({textFill: this.style.Train.soonerOrLater.normalColor});
|
|
|
|
}
|
2020-05-20 17:44:47 +08:00
|
|
|
} else if (this.style.Train.soonerOrLater && this.style.Train.soonerOrLater.level === 3) {
|
2020-05-22 18:41:23 +08:00
|
|
|
if (dt > 120) {
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.serviceNumber && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.soonerOrLater.earlyColor});
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.earlyColor});
|
2020-05-22 18:41:23 +08:00
|
|
|
} else if (dt < -120) {
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.serviceNumber && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.soonerOrLater.lateColor});
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.lateColor});
|
2020-05-20 17:44:47 +08:00
|
|
|
} else {
|
2020-05-21 09:31:16 +08:00
|
|
|
this.style.Train.soonerOrLater.serviceNumber && this.textTrainServer && this.textTrainServer.setStyle({textFill: this.style.Train.soonerOrLater.normalColor});
|
|
|
|
this.style.Train.soonerOrLater.trainBody && this.trainBodyBox && this.trainBodyBox.setColor({stroke: this.style.Train.soonerOrLater.normalColor});
|
2020-05-20 17:44:47 +08:00
|
|
|
}
|
2020-05-20 17:08:21 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-09 09:58:49 +08:00
|
|
|
formatChangePosition(model, style) {
|
|
|
|
if (this.nameFormat) {
|
|
|
|
const arr = this.nameFormat.split(':');
|
|
|
|
let widthText = 0;
|
|
|
|
arr.forEach(ele => {
|
|
|
|
if (ele == 'targetCode') {
|
2020-03-02 14:46:59 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) );
|
2020-03-09 09:58:49 +08:00
|
|
|
widthText += this.textTrainNumber.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainNumber);
|
|
|
|
} else if (ele == 'serviceNumber') {
|
2020-03-02 14:46:59 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
2020-03-09 09:58:49 +08:00
|
|
|
widthText += this.textTrainServer.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainServer);
|
|
|
|
} else if (ele == 'tripNumber') {
|
2020-03-02 14:46:59 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
2020-03-09 09:58:49 +08:00
|
|
|
widthText += this.textTrainTarget.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainTarget);
|
|
|
|
} else if (ele == 'groupNumber') {
|
2020-03-02 14:46:59 +08:00
|
|
|
!style.Train.common.fixedCoordinates && this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
|
2020-03-09 09:58:49 +08:00
|
|
|
widthText += this.textTrainTargetNumber.getBoundingRect().width;
|
|
|
|
this.add(this.textTrainTargetNumber);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|