48 lines
1.4 KiB
JavaScript
48 lines
1.4 KiB
JavaScript
|
import Group from 'zrender/src/container/Group';
|
||
|
import Polyline from 'zrender/src/graphic/shape/Polyline';
|
||
|
|
||
|
/** 分隔符*/
|
||
|
export default class ESeparator extends Group {
|
||
|
constructor(model) {
|
||
|
super();
|
||
|
this.model = model;
|
||
|
this.zlevel = model.zlevel;
|
||
|
this.z = model.z || 6;
|
||
|
this.style = model.style;
|
||
|
this.setType();
|
||
|
}
|
||
|
|
||
|
createModel(points) {
|
||
|
const model = this.model;
|
||
|
this.partition = new Polyline({
|
||
|
zlevel: this.zlevel,
|
||
|
progressive: model.progressive,
|
||
|
z: this.z,
|
||
|
shape: {
|
||
|
points: points
|
||
|
},
|
||
|
style: {
|
||
|
lineWidth: model.width,
|
||
|
stroke: model.stroke
|
||
|
}
|
||
|
});
|
||
|
this.add(this.partition);
|
||
|
}
|
||
|
|
||
|
setType() {
|
||
|
const model = this.model;
|
||
|
if (model && model.traingle) {
|
||
|
const points = [
|
||
|
[model.point.x, model.point.y - (this.style.Power.extendLength)],
|
||
|
[model.point.x, model.point.y + (this.style.Power.extendLength)]
|
||
|
];
|
||
|
this.createModel(points);
|
||
|
}
|
||
|
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(); // 可以无需调用
|
||
|
}
|
||
|
}
|
||
|
}
|