83 lines
2.5 KiB
JavaScript
83 lines
2.5 KiB
JavaScript
/*
|
|
* ZC区域控制模式
|
|
*/
|
|
import Group from 'zrender/src/container/Group';
|
|
import EControl from '../element/EControl';
|
|
import EMouse from './EMouse';
|
|
|
|
export default class ZcControl extends Group {
|
|
constructor(model, style) {
|
|
super();
|
|
this.z = 20;
|
|
this._code = model.code;
|
|
this._type = model._type;
|
|
this.zlevel = model.zlevel;
|
|
this.model = model;
|
|
this.style = style;
|
|
this.create(model);
|
|
this.createMouseEvent();
|
|
this.setState(model);
|
|
|
|
}
|
|
|
|
create(model) {
|
|
if (this.style.ZcControl.visible) {
|
|
this.control = new EControl({
|
|
zlevel: this.zlevel,
|
|
z: this.z,
|
|
arc: {
|
|
shape: {
|
|
cx: model.position.x,
|
|
cy: model.position.y,
|
|
r: this.style.ZcControl.lamp.radiusR
|
|
},
|
|
lineWidth: 0,
|
|
fill: this.style.ZcControl.lamp.controlColor,
|
|
mouseover: this.mouseoverArc,
|
|
mouseout: this.mouseoutArc
|
|
},
|
|
text: {
|
|
position: [0, 0],
|
|
x: model.position.x,
|
|
y: model.position.y + this.style.ZcControl.lamp.radiusR + this.style.ZcControl.text.distance,
|
|
fontWeight: this.style.ZcControl.text.fontWeight,
|
|
fontSize: this.style.ZcControl.text.fontSize,
|
|
fontFamily: this.style.fontFamily,
|
|
text: model.name,
|
|
textFill: '#fff',
|
|
textAlign: 'middle',
|
|
textVerticalAlign: 'top',
|
|
mouseover: this.mouseoverText,
|
|
mouseout: this.mouseoutText
|
|
},
|
|
style: this.style
|
|
});
|
|
this.add(this.control);
|
|
}
|
|
|
|
}
|
|
|
|
// 设置状态
|
|
setState(model) {
|
|
}
|
|
createMouseEvent() {
|
|
if (this.style.ZcControl.mouseOverStyle) {
|
|
this.mouseEvent = new EMouse(this);
|
|
this.add(this.mouseEvent);
|
|
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
|
|
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
|
|
}
|
|
}
|
|
getShapeTipPoint() {
|
|
if (this.control) {
|
|
var distance = 2;
|
|
var rect = this.control.getBoundingRect();
|
|
return {
|
|
x: rect.x + rect.width / 2,
|
|
y: rect.y - distance
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
}
|