import Group from 'zrender/src/container/Group'; import Text from 'zrender/src/graphic/Text'; class ETime extends Group { constructor(model) { super(); this.model = model; this.isNew = false; } create() { if (!this.isNew) { const model = this.model.modelData; const style = this.model.style; const timeDrict = model.right ? 1 : -1; const timeX = model.position.x + style.StationStand.stopTime.position * timeDrict * (style.StationStand.stopTime.offset.x - model.width / 2); const timeY = model.position.y + timeDrict * (style.StationStand.stopTime.offset.y - model.height / 2); this.isNew = true; this.time = new Text({ zlevel: this.model.zlevel, z: this.model.z, style: { x: timeX, y: timeY, fontWeight: style.textStyle.fontWeight, fontSize: style.StationStand.stopTime.textFontSize, fontFamily: style.fontFamily, text: model.parkingTime || '30', textFill: style.StationStand.stopTime.textColor, textAlign: style.textStyle.textAlign, textVerticalAlign: style.textStyle.textVerticalAlign } }); this.add(this.time); } } setName(val) { this.time.setStyle('text', val); } setColor(color) { this.create(); this.time.setStyle('textFill', color); } hideMode() { this.time && this.time.hide(); } showMode() { this.create(); this.time && this.time.show(); } recover() { this.hideMode(); } setState(model) { // 停站时间 if (Number(model.parkingTime) > 0) { this.showMode(); this.setName(model.parkingTime); } } } export default ETime;