import Line from 'zrender/src/graphic/shape/Line'; import Group from 'zrender/src/container/Group'; // import { stat } from 'fs'; class Link extends Group { constructor({ _code, _type, zlevel, model, state }, style, styleGlobal) { super(); this._code = _code; this._type = _type; this.zlevel = zlevel; this.model = model; this.state = state; this.style = style; this.styleGlobal = styleGlobal; this.create(); } create() { const model = this.model; const style = this.style; const styleGlobal = this.styleGlobal; this.link = new Line({ zlevel: this.zlevel, shape: { x1: model.lp.x, y1: model.lp.y, x2: model.rp.x, y2: model.rp.y }, style: { lineWidth: style.linkWidth, stroke: style.linkColor, text: model.code, textDistance: style.linkWidth * 2, textPosition: 'inside', textAlign: 'middle', fontSize: styleGlobal.textFontSize, textFill: style.linkTextColor, textStroke: styleGlobal.backgroundColor } }); this.add(this.link); } setState({ _code, _type, zlevel, model, state }) { switch (state.status) { case '01': this.link.setStyle('stroke', 'green'); break; case '02': this.link.setStyle('stroke', 'yellow'); break; } } tipBasePoint() { return { x: (this.link.shape.x1 + this.link.shape.x2) / 2, y: (this.link.shape.y1 + this.link.shape.y2) / 2 }; } } export default Link;