import Group from 'zrender/src/container/Group'; import Text from 'zrender/src/graphic/Text'; class ELevel extends Group { constructor(model) { super(); this.model = model; this.level = null; this.isNew = false; } create() { if (!this.isNew) { const model = this.model.modelData; const style = this.model.style; this.isNew = true; const levelDrict = model.right ? 1 : -1; const levelX = model.position.x - levelDrict * (style.StationStand.level.offset.x - model.width / 2); const levelY = model.position.y + levelDrict * (style.StationStand.level.offset.y); this.level = new Text({ zlevel: this.model.zlevel, z: this.model.z, style: { x: levelX, y: levelY, fontWeight: style.textStyle.fontWeight, fontSize: style.StationStand.level.textFontSize, fontFamily: style.fontFamily, text: model.runLevelTime || '5', textFill: style.StationStand.level.textColor, textAlign: style.textStyle.textAlign, textVerticalAlign: style.textStyle.textVerticalAlign } }); this.add(this.level); } } setName(val) { this.level.setStyle('text', val); } setColor(color) { this.create(); this.level.setStyle('textFill', color); } hideMode() { this.level && this.level.hide(); } showMode() { this.create(); this.level.show(); } recover() { this.hideMode(); } setState(model) { // 运行等级 if (Number(model.runLevelTime) > 0) { this.showMode(); this.setName(model.runLevelTime); } } } export default ELevel;