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

83 lines
2.2 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
import Arc from 'zrender/src/graphic/shape/Arc';
class EJump extends Group {
constructor(model) {
super();
this.model = model;
this.isNew = false;
this.create();
this.setStatus(model.allSkip, model.assignSkip);
}
create() {
if (!this.isNew) {
const model = this.model;
const style = this.model.style;
this.isNew = true;
this.jump = new Text({
zlevel: model.zlevel,
z: model.z,
style: {
x: model.x,
y: model.y,
fontWeight: 'normal',
fontSize: style.StationStand.common.textFontSize,
fontFamily: style.fontFamily,
text: style.StationStand.jump.text,
textFill: style.StationStand.jump.textColor,
textAlign: model.textAlign,
textVerticalAlign: model.textVerticalAlign
}
});
this.jumpArc = new Arc({
zlevel: model.zlevel,
z: model.z,
shape: {
cx: model.cx,
cy: model.cy,
r: style.StationStand.jump.r
},
style: {
stroke: style.StationStand.jump.arcColor,
fill: style.StationStand.jump.fillColor
}
});
this.add(this.jumpArc);
this.add(this.jump);
this.jumpArc.hide();
}
}
setName(val) {
this.create();
this.jump.setStyle('text', val);
}
setStatus(allSkip, assignSkip) {
this.jumpArc.hide();
if (assignSkip) {
this.jumpArc.hide(); // 指定站台跳停
} else if (allSkip) {
this.jumpArc.show(); // 站台全部跳停
}
}
setColor(color) {
this.create();
this.jump.setStyle('textFill', color);
}
hide() {
this.create();
this.jump.hide();
}
show() {
this.create();
this.jump.show();
}
}
export default EJump;