52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
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;
|
|
this.isNew = false;
|
|
}
|
|
|
|
create() {
|
|
if (!this.isNew) {
|
|
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) {
|
|
this.create();
|
|
this.detain.setStyle('textFill', color);
|
|
}
|
|
|
|
hideMode() {
|
|
this.detain && this.detain.hide();
|
|
}
|
|
|
|
showMode() {
|
|
this.create();
|
|
this.detain && this.detain.show();
|
|
}
|
|
}
|
|
|
|
export default EDetain;
|