77 lines
2.2 KiB
JavaScript
77 lines
2.2 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
|
|
|
class EDetainCircle extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.create();
|
|
}
|
|
|
|
create() {
|
|
const model = this.model.modelData;
|
|
const style = this.model.style;
|
|
|
|
const standX = model.position.x - model.width / 2;
|
|
const standY = model.position.y - model.height / 2;
|
|
|
|
let y;
|
|
if (model.right && model.inside) {
|
|
y = standY + model.height / 2;
|
|
} else if (model.right && !model.inside) {
|
|
y = standY;
|
|
} else if (!model.right && model.inside) {
|
|
y = standY;
|
|
} else if (!model.right && !model.inside) {
|
|
y = standY + model.height / 2;
|
|
}
|
|
this.detainRect = new Rect({
|
|
zlevel: this.model.zlevel,
|
|
z: this.model.z + 1,
|
|
shape: {
|
|
x: standX,
|
|
y: y,
|
|
width: model.width,
|
|
height: model.height / 2
|
|
},
|
|
style: {
|
|
lineWidth: style.StationStand.detainRect.lineWidth || 0,
|
|
stroke: style.StationStand.detainRect.spareStrokeColor,
|
|
fill: '#000'
|
|
}
|
|
});
|
|
this.add(this.detainRect);
|
|
this.detainRect.hide();
|
|
}
|
|
|
|
setColor(color) {
|
|
this.detainRect.setStyle('stroke', color);
|
|
}
|
|
setShow() {
|
|
this.detainRect.show();
|
|
}
|
|
setHide() {
|
|
this.detainRect.hide();
|
|
}
|
|
recover() {
|
|
this.setHide();
|
|
}
|
|
|
|
setState(model) {
|
|
const style = this.model.style;
|
|
/** 设置扣车*/
|
|
if (model.stationHoldTrain && model.centerHoldTrain) {
|
|
this.showMode();
|
|
this.setColor(style.StationStand.detainRect.centerTrainColor);
|
|
} else if (model.stationHoldTrain) {
|
|
this.showMode();
|
|
this.setColor(style.StationStand.detainRect.detainTrainTextColor);
|
|
} else if (model.centerHoldTrain) {
|
|
this.showMode();
|
|
this.setColor(style.StationStand.detainRect.centerTrainColor);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default EDetainCircle;
|