rt-sim-training-client/src/jmapNew/shape/StationStand/EEarlyStart.js

77 lines
2.4 KiB
JavaScript
Raw Normal View History

2020-10-22 13:40:56 +08:00
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
class EEarlyStart extends Group {
constructor(model) {
super();
this.model = model;
this.detain = null;
this.isNew = false;
}
create(deviceParam) {
if (!this.isNew) {
const model = this.model.modelData;
const style = this.model.style;
this.isNew = true;
/** 提前发车*/
const startD = model.right ? 1 : -1;
const startX = model.position.x - startD * (deviceParam.offset.x - model.width / 2);
const startY = model.position.y + startD * (deviceParam.offset.y - model.height / 2);
this.earlyStart = new Text({
zlevel: this.model.zlevel,
z: this.model.z,
position: [0, 0],
style: {
x: startX,
y: startY,
text: deviceParam.text,
fontSize: deviceParam.fontSize,
fontFamily: style.fontFamily,
fontWeight: deviceParam.fontWeight,
textFill: deviceParam.centerTrainColor,
textStroke: style.backgroundColor,
textAlign: style.textStyle.textAlign,
textVerticalAlign: deviceParam.textVerticalAlign || style.textStyle.textVerticalAlign
}
});
2020-10-22 14:07:18 +08:00
this.add(this.earlyStart);
2020-10-22 13:40:56 +08:00
}
}
setColor(color) {
2020-10-22 14:07:18 +08:00
this.earlyStart.setStyle('textFill', color);
2020-10-22 13:40:56 +08:00
}
recover() {
this.hideMode();
}
hideMode() {
2020-10-22 14:07:18 +08:00
this.earlyStart && this.earlyStart.hide();
2020-10-22 13:40:56 +08:00
}
showMode(deviceParam) {
this.create(deviceParam);
2020-10-22 14:07:18 +08:00
this.earlyStart && this.earlyStart.show();
2020-10-22 13:40:56 +08:00
}
setState(model, deviceParam = this.model.style.StationStand.detainNormal) {
2020-10-22 14:07:18 +08:00
// /** 设置扣车*/
// if (model.stationHoldTrain && model.centerHoldTrain) {
// this.showMode(deviceParam);
// this.setColor(deviceParam.andCenterTrainColor);
// } else if (model.stationHoldTrain) {
// this.showMode(deviceParam);
// this.setColor(deviceParam.detainTrainTextColor);
// } else if (model.centerHoldTrain) {
// this.showMode(deviceParam);
// this.setColor(deviceParam.centerTrainColor);
// }
2020-10-22 13:40:56 +08:00
}
}
2020-10-22 14:07:18 +08:00
export default EEarlyStart;