112 lines
3.6 KiB
JavaScript
112 lines
3.6 KiB
JavaScript
import Group from 'zrender/src/container/Group';
|
|
import Rect from 'zrender/src/graphic/shape/Rect';
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
class ESafeStand extends Group {
|
|
constructor(model) {
|
|
super();
|
|
this.model = model;
|
|
this.create();
|
|
}
|
|
|
|
create() {
|
|
const model = this.model;
|
|
const style = this.model.style;
|
|
// 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
|
|
}
|
|
});
|
|
let height = model.inside ? 7 : -12;
|
|
if (model.right) {
|
|
if (model.inside) {
|
|
height = -12;
|
|
} else {
|
|
height = 7;
|
|
}
|
|
} else {
|
|
if (model.inside) {
|
|
height = 7;
|
|
} else {
|
|
height = -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
|
|
}
|
|
});
|
|
if (style.StationStand.common.standType && style.StationStand.common.standType == 'notFill') {
|
|
this.stand && this.stand.setStyle('lineWidth', 2);
|
|
} else {
|
|
this.stand && this.stand.setStyle('fill', style.StationStand.stand.spareColor);
|
|
}
|
|
this.add(this.stand);
|
|
}
|
|
}
|
|
|
|
setColor(color) {
|
|
const style = this.model.style;
|
|
if (style.StationStand.common.standType && style.StationStand.common.standType == 'notFill') {
|
|
this.stand && this.stand.setStyle('stroke', color);
|
|
} else {
|
|
this.stand && this.stand.setStyle('fill', color);
|
|
}
|
|
}
|
|
}
|
|
|
|
export default ESafeStand;
|