87 lines
2.5 KiB
JavaScript
87 lines
2.5 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Polygon from 'zrender/src/graphic/shape/Polygon';
|
|
import { flashlight } from '../utils/ShapePoints.js';
|
|
|
|
class EReentry extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.isNew = false;
|
|
}
|
|
|
|
create() {
|
|
if (!this.isNew) {
|
|
const model = this.model.modelData;
|
|
const style = this.model.style;
|
|
this.isNew = true;
|
|
|
|
const reentryH = style.StationStand.reentry.mergentR;
|
|
const isRight = model.right ? -1 : 1;
|
|
const reentryX = model.position.x - (style.StationStand.reentry.position || isRight) * (style.StationStand.reentry.offset.x - model.width / 2);
|
|
const reentryY = model.position.y + (style.StationStand.reentry.position || isRight) * (style.StationStand.reentry.offset.y) + isRight * reentryH;
|
|
|
|
this.reentry = new Polygon({
|
|
zlevel: this.model.zlevel,
|
|
z: this.model.z,
|
|
shape: {
|
|
points: flashlight(reentryX, reentryY, isRight, 10, 5, 0, 0, 4)
|
|
},
|
|
style: {
|
|
lineWidth: 0,
|
|
fill: style.StationStand.reentry.noHumanColor
|
|
}
|
|
});
|
|
|
|
this.add(this.reentry);
|
|
}
|
|
}
|
|
|
|
setColor(color) {
|
|
this.create();
|
|
this.reentry.setStyle('textFill', color);
|
|
}
|
|
|
|
hideMode() {
|
|
this.reentry && this.reentry.hide();
|
|
}
|
|
|
|
showMode() {
|
|
this.create();
|
|
this.reentry.show();
|
|
}
|
|
|
|
recover() {
|
|
this.hideMode();
|
|
}
|
|
|
|
setState(model) {
|
|
const style = this.model.style;
|
|
let reentryStrategy = '';
|
|
if (model.reentryStrategy !== '04') {
|
|
reentryStrategy = model.reentryStrategy;
|
|
} else {
|
|
reentryStrategy = model.defaultReentryStrategy;
|
|
}
|
|
switch (reentryStrategy) {
|
|
case '04': /** 默认*/
|
|
case '01': {
|
|
this.reentry && this.reentry.hideMode(); /** 无折返策略*/
|
|
break;
|
|
}
|
|
case '02': {
|
|
this.showMode(); /** 无人折返*/
|
|
this.setColor(style.StationStand.reentry.noHumanColor);
|
|
break;
|
|
}
|
|
case '03':/** 自动换端*/ {
|
|
this.showMode();
|
|
this.setColor(style.StationStand.reentry.autoChangeEndsColor);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
export default EReentry;
|