rt-sim-training-client/src/jmap/shape/StationControl/ESingleControl.js
2019-08-05 08:42:45 +08:00

74 lines
1.8 KiB
JavaScript

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 {
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);
}
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.StationControl.lamp.radiusR
},
style: {
lineWidth: 0.5,
fill: model.style.StationControl.lamp.grayColor,
stroke: model.style.StationControl.lamp.grayColor
}
});
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.StationControl.lamp.radiusR + model.style.StationControl.text.distance,
fontWeight: model.style.StationControl.text.fontWeight,
fontSize: model.style.StationControl.text.fontSize,
fontFamily: model.style.StationControl.text.fontFormat,
text: model.context,
textFill: model.style.StationControl.text.fontColor,
textAlign: model.style.StationControl.text.textAlign,
textVerticalAlign: model.style.StationControl.text.textVerticalAlign
}
});
this.add(this.control);
this.add(this.text);
}
setColor(color) {
if (color) {
this.control.setStyle('fill', color);
}
}
}