rt-sim-training-client/src/jmapNew/shape/StationStand/EEarlyStart.js
2020-10-22 14:07:18 +08:00

77 lines
2.4 KiB
JavaScript

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
}
});
this.add(this.earlyStart);
}
}
setColor(color) {
this.earlyStart.setStyle('textFill', color);
}
recover() {
this.hideMode();
}
hideMode() {
this.earlyStart && this.earlyStart.hide();
}
showMode(deviceParam) {
this.create(deviceParam);
this.earlyStart && this.earlyStart.show();
}
setState(model, deviceParam = this.model.style.StationStand.detainNormal) {
// /** 设置扣车*/
// 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);
// }
}
}
export default EEarlyStart;