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

71 lines
2.4 KiB
JavaScript
Raw Normal View History

2021-01-19 09:20:37 +08:00
import Group from 'zrender/src/container/Group';
import Polygon from 'zrender/src/graphic/shape/Polygon';
// import Text from 'zrender/src/graphic/Text';
class EStationPlatform extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
create() {
const model = this.model.modelData;
const style = this.model.style;
const buttonD = model.right ? 1 : -1;
const platFormOffset = model.inside ? style.StationStand.stationPlatform.insideOffset : style.StationStand.stationPlatform.outsideOffset;
const buttonX = model.position.x - buttonD * (platFormOffset.x - model.width / 2);
const buttonY = model.position.y + buttonD * (platFormOffset.y + buttonD * model.height / 2);
this.stationPlatform = new Polygon({
zlevel: this.model.zlevel,
z: this.model.z,
_subType: 'trainSetButton',
position: [0, 0],
shape: {
points: [
[buttonX, buttonY],
[buttonX - buttonD * 20, buttonY],
[buttonX - buttonD * 20, buttonY - 10],
[buttonX - buttonD * 5, buttonY - 10],
[buttonX, buttonY - 5]
]
},
style: {
fill: style.StationStand.stationPlatform.defaultColor
}
});
this.add(this.stationPlatform);
}
hideMode() {
this.stationPlatform && this.stationPlatform.hide();
}
showMode() {
this.stationPlatform && this.stationPlatform.show();
}
setColor(color) {
this.stationPlatform && this.stationPlatform.setStyle({fill:color});
}
recover() {
2021-01-19 17:14:47 +08:00
console.log(this.model.modelData, 22222222222);
console.log(this.model.modelData.code, 111111111);
2021-01-19 09:20:37 +08:00
const style = this.model.style;
this.setColor(style.StationStand.stationPlatform.defaultColor);
}
setState(model) {
const style = this.model.style;
if (model.stationHoldTrain || model.centerHoldTrain) {
2021-01-19 17:14:47 +08:00
console.log(model.code, model.stationHoldTrain, model.centerHoldTrain);
2021-01-19 09:20:37 +08:00
this.setColor(style.StationStand.stationPlatform.detainColor);
}
if (model.assignSkip || model.allSkip) {
this.setColor(style.StationStand.stationPlatform.jumpColor);
}
}
}
export default EStationPlatform;