rt-sim-training-client/src/jmap/shape/element/ESigPost.js

64 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-07-16 16:29:31 +08:00
import Polyline from 'zrender/src/graphic/shape/Polyline';
import Group from 'zrender/src/container/Group';
class ESigPost extends Group {
constructor({position, drict, type, zlevel, z, style}) {
super();
this.drict = drict;
this.position = position;
this.style = style;
this.ver = new Polyline({
zlevel: zlevel,
z: z,
shape: {
points: [
[position.x, position.y + style.Signal.signalR * 1.2],
[position.x, position.y - style.Signal.signalR * 1.2]
]
},
style: {
lineWidth: style.Signal.signalLampStandardWidth,
stroke: style.Signal.signalLampStandardColor
}
});
this.hor = new Polyline({
zlevel: zlevel,
z: z,
shape: {
points: [
[position.x, position.y],
[position.x + drict * style.Signal.signalR * 1.2, position.y]
]
},
style: {
lineWidth: style.Signal.signalLampStandardWidth,
stroke: style.Signal.signalLampStandardColor
}
});
this.add(this.ver);
this.add(this.hor);
type === '01' ? this.hor.hide() : this.hor.show();
}
getLampPosition(type) {
if (type === '01') {
return {
x: this.position.x + this.drict * this.style.Signal.signalR * 3 / 2,
y: this.position.y
};
} else {
return {
x: this.hor.shape.points[1][0] + this.drict * this.style.Signal.signalR,
y: this.hor.shape.points[1][1]
};
}
}
}
export default ESigPost;