import Group from 'zrender/src/container/Group'; import Polyline from 'zrender/src/graphic/shape/Polyline'; import Circle from 'zrender/src/graphic/shape/Circle'; /** 分隔符*/ export default class ESeparator extends Group { constructor(model) { super(); this.model = model; this.zlevel = model.zlevel; this.style = model.style; this.z = 6; this._create(model); } _create(model) { this.partition = new Polyline({ zlevel: this.zlevel, z: this.z, shape: { points: [] }, style: { lineWidth: this.style.Section.sectionSeparatorWidth, stroke: this.style.Section.sectionSeparatorColor } }); this.circle = new Circle({ zlevel: this.zlevel, z: this.z, shape: { cx: model.point.x, cy: model.point.y, r: this.style.Section.sectionWidth }, style: { stroke: this.style.Section.sectionInvadeColor, GBaseLineWidth: 0.5, fill: this.style.transparentColor } }); this.add(this.partition); this.setType(); } setType() { const type = this.model.sepType; const model = this.model; if (model && this.style && model.traingle) { this.remove(this.circle); if (type === '00') { this.partition.setShape('points', [ [model.point.x, model.point.y], [model.point.x, model.point.y] ]); } else if (type === '01') { this.partition.setShape('points', [ [model.point.x, model.point.y - (this.style.Section.sectionWidth)], [model.point.x, model.point.y + (this.style.Section.sectionWidth)] ]); this.add(this.partition); } else if (type === '02') { this.partition.setShape('points', [ [model.point.x + model.drict * (this.style.Section.sectionWidth), model.point.y - (this.style.Section.sectionWidth * 1.5)], [model.point.x, model.point.y - (this.style.Section.sectionWidth * 1.5)], [model.point.x, model.point.y + (this.style.Section.sectionWidth * 1.5)] ]); this.add(this.partition); } else if (type === '03') { this.partition.setShape('points', [ [model.point.x + model.drict * (this.style.Section.sectionWidth) * 1.2, model.point.y - (this.style.Section.sectionWidth * 1.2)], [model.point.x, model.point.y - (this.style.Section.sectionWidth * 1.2)], [model.point.x, model.point.y + (this.style.Section.sectionWidth * 1.2)], [model.point.x + model.drict * (this.style.Section.sectionWidth) * 1.2, model.point.y + (this.style.Section.sectionWidth * 1.2)] ]); this.add(this.partition); this.partition.setStyle({'lineWidth': this.style.Section.sectionEndSeparatorWidth, 'stroke': this.style.Section.sectionEndSeparatorStroke }); } else if (type === '04') { this.add(this.circle); } } if (model.traingle) { this.origin = [model.point.x, model.point.y]; this.rotation = Math.PI * 2 - Math.atan2(model.traingle.absy, model.traingle.absx) * model.traingle.drictx * model.traingle.dricty; this.dirty(); // 可以无需调用 } } }