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
|
|
|
|
}
|
|
|
|
});
|
2020-02-04 11:25:21 +08:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2020-02-03 17:17:56 +08:00
|
|
|
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,
|
2020-04-09 13:01:48 +08:00
|
|
|
stroke: style.sidelineColor
|
2020-02-03 17:17:56 +08:00
|
|
|
}
|
|
|
|
});
|
2020-04-09 13:01:48 +08:00
|
|
|
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);
|
|
|
|
}
|
2020-02-03 17:17:56 +08:00
|
|
|
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-04-09 13:01:48 +08:00
|
|
|
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);
|
|
|
|
}
|
2019-12-11 17:07:29 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ESafeStand;
|