2019-11-29 12:51:58 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
2020-02-03 17:17:56 +08:00
|
|
|
import Text from 'zrender/src/graphic/Text';
|
2019-11-29 12:51:58 +08:00
|
|
|
|
|
|
|
class ESafeStand extends Group {
|
2019-12-11 17:07:29 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.create();
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-11 17:07:29 +08:00
|
|
|
create() {
|
|
|
|
const model = this.model;
|
|
|
|
const style = this.model.style;
|
2020-02-03 17:17:56 +08:00
|
|
|
// model.x /y 是整个坐标左上角起点
|
|
|
|
if (style.StationStand.common.special) {
|
|
|
|
this.stand1 = new Rect({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
shape: {
|
|
|
|
x: model.x,
|
|
|
|
y: model.y,
|
|
|
|
width: model.width / 4 - 2,
|
|
|
|
height: model.height
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
lineWidth: 0,
|
|
|
|
stroke: style.sidelineColor,
|
|
|
|
fill: style.StationStand.stand.spareColor
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.stand2 = new Rect({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
shape: {
|
|
|
|
x: model.x + model.width * 3 / 4,
|
|
|
|
y: model.y,
|
|
|
|
width: model.width / 4 - 2,
|
|
|
|
height: model.height
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
lineWidth: 0,
|
|
|
|
stroke: style.sidelineColor,
|
|
|
|
fill: style.StationStand.stand.spareColor
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const height = model.right ? 7 : -12;
|
|
|
|
this.standText = new Text({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
style: {
|
|
|
|
x: model.x + model.width / 2,
|
|
|
|
y: model.y + height,
|
|
|
|
fontSize: style.StationStand.stand.headFontSize,
|
|
|
|
text: model.name,
|
|
|
|
textFill: style.StationStand.stand.textFill,
|
|
|
|
textPosition: 'inside',
|
|
|
|
textAlign: 'center'
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.stand1);
|
|
|
|
this.add(this.stand2);
|
|
|
|
this.add(this.standText);
|
|
|
|
} else {
|
|
|
|
this.stand = new Rect({
|
|
|
|
zlevel: model.zlevel,
|
|
|
|
z: model.z,
|
|
|
|
shape: {
|
|
|
|
x: model.x,
|
|
|
|
y: model.y,
|
|
|
|
width: model.width,
|
|
|
|
height: model.height
|
|
|
|
},
|
|
|
|
style: {
|
|
|
|
lineWidth: 0,
|
|
|
|
stroke: style.sidelineColor,
|
|
|
|
fill: style.StationStand.stand.spareColor
|
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.stand);
|
|
|
|
}
|
2019-12-11 17:07:29 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-11 17:07:29 +08:00
|
|
|
setColor(color) {
|
2020-02-03 17:17:56 +08:00
|
|
|
this.stand && this.stand.setStyle('fill', color);
|
2019-12-11 17:07:29 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ESafeStand;
|