rt-sim-training-client/src/jmap/shape/StationControl/ESingleControl.js

70 lines
1.7 KiB
JavaScript
Raw Normal View History

2019-07-17 09:08:23 +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 {
constructor(model) {
super();
this.model = model;
this.zlevel = model.zlevel;
this._subType = model._subType;
this.z = 20;
this._create(model);
}
_create(model) {
var _subType = 'ControlSignal';
var _val = '0';
if (model.pop) {
_subType = 'ControlButton';
_val = '1';
}
this.control = new Arc({
pop: model.pop,
_subType: _subType,
_val: _val,
zlevel: this.zlevel,
z: this.z,
shape: {
cx: model.point.x,
cy: model.point.y,
2019-07-17 18:18:28 +08:00
r: model.style.StationControl.stationControlmodeR
2019-07-17 09:08:23 +08:00
},
style: {
lineWidth: 0.5,
2019-07-17 18:18:28 +08:00
fill: model.style.StationControl.stationControlGrayColor,
stroke: model.style.StationControl.stationControlGrayColor
2019-07-17 09:08:23 +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,
2019-07-17 18:18:28 +08:00
y: model.point.y + model.style.StationControl.stationControlmodeR + model.style.nameDistance,
2019-07-25 10:30:30 +08:00
fontWeight: model.style.StationControl.text.fontWeight,
fontSize: model.style.StationControl.text.fontSize,
fontFamily: model.style.StationControl.text.fontFormat,
2019-07-17 09:08:23 +08:00
text: model.context,
2019-07-25 10:30:30 +08:00
textFill: model.style.StationControl.text.fontColor,
textAlign: model.style.StationControl.text.textAlign,
textVerticalAlign: model.style.StationControl.text.textVerticalAlign
2019-07-17 09:08:23 +08:00
}
});
this.add(this.control);
this.add(this.text);
}
setColor(color) {
if (color) {
this.control.setStyle('fill', color);
}
}
}