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 } }); 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); } } setColor(color) { this.stand && this.stand.setStyle('fill', color); } } export default ESafeStand;