rt-sim-training-client/src/jmapNew/shape/Switch/ESwLnversion.js
2019-11-29 12:51:58 +08:00

70 lines
1.3 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import Polygon from 'zrender/src/graphic/shape/Polygon';
class ESwLnversion extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model;
const style = this.model.style;
this.relocShelter = new Polygon({
zlevel: model.zlevel,
z: model.z,
shape: {
points: model.shelterPoints
},
style: {
fill: style.backgroundColor
},
cursor: model.cursor,
onmouseover: model.onmouseover,
onmouseout: model.onmouseout
});
const rpx = Math.abs(model.triangle.getCos(model.halfWidth)) + 0.2;
this.relocShelter.position = [-model.triangle.drictx * rpx, -model.triangle.dricty * 0.2];
this.section = new Polygon({
zlevel: model.zlevel,
z: model.z + 1,
shape: {
points: model.sectionPoints
},
style: {
fill: style.Section.line.spareColor
},
cursor: model.cursor,
onmouseover: model.onmouseover,
onmouseout: model.onmouseout
});
this.hide();
this.add(this.relocShelter);
this.add(this.section);
}
hide() {
this.relocShelter.hide();
this.section.hide();
}
show() {
this.relocShelter.show();
this.section.show();
}
stopAnimation(flag) {
this.section.stopAnimation(flag);
}
getSection() {
return this.section;
}
}
export default ESwLnversion;