rt-sim-training-client/src/jmapNew/shape/StationStand/ESafeStand.js

103 lines
3.1 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
import Text from 'zrender/src/graphic/Text';
2019-11-29 12:51:58 +08:00
class ESafeStand extends Group {
constructor(model) {
super();
this.model = model;
this.create();
}
2019-11-29 12:51:58 +08:00
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
}
});
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;
}
}
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-11-29 12:51:58 +08:00
setColor(color) {
this.stand && this.stand.setStyle('fill', color);
}
2019-11-29 12:51:58 +08:00
}
export default ESafeStand;