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

58 lines
1.6 KiB
JavaScript
Raw Normal View History

import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
export default class EMouse extends Group {
constructor(device) {
super();
this.device = device;
this.down = true;
this._create();
}
_create() {
this.text = new Text({
_subType: 'Text',
zlevel: this.device.zlevel,
z: this.device.z+1,
position: [0, 0],
style: {
x: this.device.model.position.x - this.device.style.StationControl.stationControlDistance / 2 + this.device.style.StationControl.stationOffset.x,
y: this.device.model.position.y + this.device.style.StationControl.stationOffset.y + this.device.style.StationControl.stationControlmodeR + this.device.style.nameDistance-30,
fontWeight: this.device.style.StationControl.mouseOverStyle.fontWeight,
fontSize: this.device.style.StationControl.mouseOverStyle.fontSize,
fontFamily: this.device.style.StationControl.mouseOverStyle.fontFormat,
text: '填充',
textFill: this.device.style.StationControl.mouseOverStyle.fontColor,
textAlign: this.device.style.StationControl.mouseOverStyle.textAlign,
textVerticalAlign: this.device.style.StationControl.mouseOverStyle.textVerticalAlign
}
});
this.add(this.text);
this.hide();
}
setTextContext(text) {
if (text) {
this.text.setStyle('text', text);
}
}
mouseover(e) {
let name = '';
switch (e.target.parent._subType) {
case 'emergency':
name = '紧急站控';
break;
case 'center':
name = '中控';
break;
case 'substation':
name = '站控';
break;
}
this.setTextContext(name);
this.show();
}
mouseout(e) {
this.hide();
}
}