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

60 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;
2019-08-02 14:17:43 +08:00
this.create();
}
2019-08-02 14:17:43 +08:00
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,
2019-08-02 10:39:59 +08:00
y: this.device.model.position.y + this.device.style.StationControl.stationOffset.y + this.device.style.StationControl.stationControlmodeR + this.device.style.nameDistance-40,
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
}
});
2019-08-02 14:17:43 +08:00
this.add(this.text);
2019-08-02 10:39:59 +08:00
this.text.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;
}
2019-08-02 10:39:59 +08:00
// debugger;
this.setTextContext(name);
2019-08-02 10:39:59 +08:00
this.text.show();
}
mouseout(e) {
2019-08-02 10:39:59 +08:00
this.text.hide();
}
}