2019-11-29 12:51:58 +08:00
|
|
|
import Arc from 'zrender/src/graphic/shape/Arc';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
|
|
|
|
/** 单个控制灯*/
|
|
|
|
export default class ESingleControl extends Group {
|
2019-12-05 10:52:45 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
|
|
|
this.zlevel = model.zlevel;
|
|
|
|
this._subType = model._subType;
|
|
|
|
this.z = 20;
|
|
|
|
this.onmouseover = model.mouseover;
|
|
|
|
this.onmouseout = model.mouseout;
|
|
|
|
this.create(model);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-05 10:52:45 +08:00
|
|
|
create(model) {
|
|
|
|
var _subType = 'ControlSignal';
|
|
|
|
var _val = '0';
|
|
|
|
if (model.pop) {
|
|
|
|
_subType = 'ControlButton';
|
|
|
|
_val = '1';
|
|
|
|
}
|
|
|
|
var _nameType = this._subType;
|
|
|
|
this.control = new Arc({
|
|
|
|
pop: model.pop,
|
|
|
|
_subType: _subType,
|
|
|
|
_nameType: _nameType,
|
|
|
|
_val: _val,
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
shape: {
|
|
|
|
cx: model.point.x,
|
|
|
|
cy: model.point.y,
|
|
|
|
r: model.style.Station.StationControl.lamp.radiusR
|
|
|
|
},
|
|
|
|
style: {
|
2020-03-05 14:33:08 +08:00
|
|
|
lineWidth: 0,
|
2019-12-05 10:52:45 +08:00
|
|
|
fill: model.style.Station.StationControl.lamp.grayColor,
|
|
|
|
stroke: model.style.Station.StationControl.lamp.grayColor
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-05 10:52:45 +08:00
|
|
|
this.text = new Text({
|
|
|
|
pop: model.pop,
|
|
|
|
_subType: _subType,
|
|
|
|
zlevel: this.zlevel,
|
|
|
|
z: this.z,
|
|
|
|
position: [0, 0],
|
|
|
|
style: {
|
|
|
|
x: model.point.x,
|
|
|
|
y: model.point.y + model.style.Station.StationControl.lamp.radiusR + model.style.Station.StationControl.text.distance,
|
|
|
|
fontWeight: model.style.Station.StationControl.text.fontWeight,
|
|
|
|
fontSize: model.style.Station.StationControl.text.fontSize,
|
2020-05-25 15:06:34 +08:00
|
|
|
fontFamily: model.style.fontFamily,
|
2019-12-05 10:52:45 +08:00
|
|
|
text: model.context,
|
|
|
|
textFill: model.style.Station.StationControl.text.fontColor,
|
|
|
|
textAlign: model.style.Station.StationControl.text.textAlign,
|
|
|
|
textVerticalAlign: model.style.Station.StationControl.text.textVerticalAlign
|
|
|
|
}
|
|
|
|
});
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-05 10:52:45 +08:00
|
|
|
this.add(this.control);
|
|
|
|
this.add(this.text);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2019-12-05 10:52:45 +08:00
|
|
|
setColor(color) {
|
|
|
|
if (color) {
|
|
|
|
this.control.setStyle('fill', color);
|
|
|
|
}
|
|
|
|
}
|
2020-05-28 14:39:06 +08:00
|
|
|
|
|
|
|
setTextColor(color) {
|
2020-10-22 13:40:56 +08:00
|
|
|
if (color && !this.model.style.Station.StationControl.lamp.textColorNoChange) {
|
2020-05-28 14:39:06 +08:00
|
|
|
this.text.setStyle('textFill', color);
|
|
|
|
}
|
|
|
|
}
|
2020-03-05 14:33:08 +08:00
|
|
|
getArcBoundingRect() {
|
|
|
|
const rect = this.control.getBoundingRect().clone();
|
|
|
|
const scale = this.control.scale[0];
|
|
|
|
const offsetX = this.control.position[0];
|
|
|
|
const offsetY = this.control.position[1];
|
|
|
|
rect.x = rect.x * scale + offsetX - 2;
|
|
|
|
rect.y = rect.y * scale + offsetY - 2;
|
|
|
|
rect.width = rect.width * scale + 4;
|
|
|
|
rect.height = rect.height * scale + 4;
|
|
|
|
return rect;
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|