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

52 lines
1.4 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
class EDetain extends Group {
constructor(model) {
super();
this.model = model;
this.detain = null;
2020-03-27 10:17:24 +08:00
this.isNew = false;
}
2020-03-26 15:04:52 +08:00
create() {
2020-03-27 11:35:46 +08:00
if (!this.isNew) {
2020-03-27 10:17:24 +08:00
const model = this.model;
const style = this.model.style;
this.isNew = true;
this.detain = new Text({
zlevel: model.zlevel,
z: model.z,
position: [0, 0],
style: {
x: model.x,
y: model.y,
text: style.StationStand.detainCar.text,
fontSize: `${style.StationStand.detainCar.fontSize} px ${style.fontFamily}`,
textFill: style.StationStand.detainCar.centerTrainColor,
textStroke: style.backgroundColor,
textAlign: style.textStyle.textAlign,
textVerticalAlign: style.textStyle.textVerticalAlign
}
});
this.add(this.detain);
}
}
setColor(color) {
2020-03-27 10:17:24 +08:00
this.create();
this.detain.setStyle('textFill', color);
}
hide() {
2020-03-27 10:17:24 +08:00
this.detain && this.detain.hide();
}
2020-03-26 15:04:52 +08:00
show() {
2020-03-27 10:17:24 +08:00
this.create();
2020-03-07 19:12:19 +08:00
this.detain.show();
}
2019-11-29 12:51:58 +08:00
}
export default EDetain;