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 {
|
2020-01-13 16:52:00 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.isNew = false;
|
2020-02-03 17:17:56 +08:00
|
|
|
this.detain = null;
|
|
|
|
if (this.model.style.StationStand.common.special) {
|
|
|
|
this.create('E');
|
|
|
|
}
|
2020-01-13 16:52:00 +08:00
|
|
|
}
|
|
|
|
|
2020-02-03 17:17:56 +08:00
|
|
|
create(textName) {
|
2020-01-13 16:52:00 +08:00
|
|
|
if (!this.isNew) {
|
2020-02-03 17:17:56 +08:00
|
|
|
|
2020-01-13 16:52:00 +08:00
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
|
|
|
|
|
|
|
this.isNew = true;
|
2020-02-03 17:17:56 +08:00
|
|
|
if (style.StationStand.common.special) {
|
|
|
|
const height = model.right ? 30 : -30;
|
|
|
|
const position = model.right ? model.width / 4 : -model.width / 4;
|
|
|
|
this.detain = new Text({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
position: [0, 0],
|
|
|
|
style: {
|
|
|
|
x: model.x + position,
|
|
|
|
y: model.y + height,
|
|
|
|
text: textName,
|
|
|
|
textAlign: model.right ? 'left' : 'right',
|
|
|
|
fontWeight: 'blod',
|
|
|
|
fontSize: `${style.StationStand.detainCar.fontSize} px ${style.fontFamily}`,
|
|
|
|
textFill: textName == 'E' ? '#fff' : 'red',
|
|
|
|
textVerticalAlign: 'middle'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.detain);
|
|
|
|
} else {
|
|
|
|
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,
|
|
|
|
textAlign: model.textAlign,
|
|
|
|
textVerticalAlign: model.textVerticalAlign,
|
|
|
|
fontSize: `${style.StationStand.stand.headFontSize} px ${style.fontFamily}`,
|
|
|
|
textFill: style.StationStand.detainCar.centerTrainColor,
|
|
|
|
textStroke: style.backgroundColor
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.detain);
|
|
|
|
}
|
2020-01-13 16:52:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setColor(color) {
|
|
|
|
this.create();
|
|
|
|
this.detain.setStyle('textFill', color);
|
|
|
|
}
|
|
|
|
|
|
|
|
hide() {
|
|
|
|
this.create();
|
|
|
|
this.detain.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
show() {
|
2020-02-03 17:17:56 +08:00
|
|
|
this.create('H');
|
2020-01-13 16:52:00 +08:00
|
|
|
this.detain.show();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default EDetain;
|