102 lines
3.0 KiB
JavaScript
102 lines
3.0 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 y1;
|
|
let y2;
|
|
if (model.right && model.inside) {
|
|
y1 = standY + model.height / 2;
|
|
y2 = standY;
|
|
} else if (model.right && !model.inside) {
|
|
y1 = standY;
|
|
y2 = standY + model.height / 2;
|
|
} else if (!model.right && model.inside) {
|
|
y1 = standY;
|
|
y2 = standY + model.height / 2;
|
|
} else if (!model.right && !model.inside) {
|
|
y1 = standY + model.height / 2;
|
|
y2 = standY;
|
|
}
|
|
this.detainRectTop = new Rect({
|
|
zlevel: this.model.zlevel,
|
|
z: this.model.z + 1,
|
|
shape: {
|
|
x: standX,
|
|
y: y1,
|
|
width: model.width,
|
|
height: model.height / 2
|
|
},
|
|
style: {
|
|
lineWidth: style.StationStand.detainRect.lineWidth || 0,
|
|
stroke: style.StationStand.detainRect.spareStrokeColor,
|
|
fill: '#000'
|
|
}
|
|
});
|
|
this.detainRectBottom = new Rect({
|
|
zlevel: this.model.zlevel,
|
|
z: this.model.z + 1,
|
|
shape: {
|
|
x: standX,
|
|
y: y2,
|
|
width: model.width,
|
|
height: model.height / 2
|
|
},
|
|
style: {
|
|
lineWidth: style.StationStand.detainRect.lineWidth || 0,
|
|
stroke: style.StationStand.detainRect.spareStrokeColor,
|
|
fill: '#000'
|
|
}
|
|
});
|
|
this.add(this.detainRectTop);
|
|
this.add(this.detainRectBottom);
|
|
this.detainRectTop.hide();
|
|
this.detainRectBottom.hide();
|
|
}
|
|
|
|
setColor(color1, color2) {
|
|
this.detainRectTop.setStyle('fill', color1);
|
|
this.detainRectBottom.setStyle('fill', color2);
|
|
}
|
|
setShow() {
|
|
this.detainRectTop.show();
|
|
this.detainRectBottom.show();
|
|
}
|
|
setHide() {
|
|
this.detainRectTop.hide();
|
|
this.detainRectBottom.hide();
|
|
}
|
|
recover() {
|
|
this.setHide();
|
|
}
|
|
|
|
setState(model) {
|
|
const style = this.model.style;
|
|
/** 设置扣车*/
|
|
if (model.stationHoldTrain && model.centerHoldTrain) {
|
|
this.setShow();
|
|
this.setColor(...style.StationStand.detainRect.centerTrainColor);
|
|
} else if (model.stationHoldTrain) {
|
|
this.setShow();
|
|
this.setColor(...style.StationStand.detainRect.localTrainColor);
|
|
} else if (model.centerHoldTrain) {
|
|
this.setShow();
|
|
this.setColor(...style.StationStand.detainRect.centerTrainColor);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default EDetainCircle;
|