2019-07-31 18:24:28 +08:00
|
|
|
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;
|
2019-08-06 09:32:55 +08:00
|
|
|
this.down = false;
|
2019-08-02 14:17:43 +08:00
|
|
|
this.create();
|
2019-07-31 18:24:28 +08:00
|
|
|
}
|
2019-08-02 14:17:43 +08:00
|
|
|
create() {
|
2019-07-31 18:24:28 +08:00
|
|
|
this.text = new Text({
|
|
|
|
_subType: 'Text',
|
|
|
|
zlevel: this.device.zlevel,
|
|
|
|
z: this.device.z+1,
|
|
|
|
position: [0, 0],
|
|
|
|
style: {
|
2019-08-02 17:02:43 +08:00
|
|
|
x: this.device.model.position.x - this.device.style.StationControl.lamp.distance / 2 + this.device.style.StationControl.lamp.offset.x,
|
2019-08-02 18:05:08 +08:00
|
|
|
y: this.device.model.position.y + this.device.style.StationControl.lamp.offset.y + this.device.style.StationControl.lamp.radiusR + this.device.style.StationControl.text.distance-40,
|
2019-07-31 18:24:28 +08:00
|
|
|
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
|
|
|
|
2019-07-31 18:24:28 +08:00
|
|
|
this.add(this.text);
|
2019-08-02 10:39:59 +08:00
|
|
|
this.text.hide();
|
2019-07-31 18:24:28 +08:00
|
|
|
}
|
|
|
|
setTextContext(text) {
|
|
|
|
if (text) {
|
|
|
|
this.text.setStyle('text', text);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mouseover(e) {
|
2019-08-07 09:16:55 +08:00
|
|
|
if (e.target) {
|
|
|
|
let name = '';
|
|
|
|
switch (e.target.parent._subType) {
|
|
|
|
case 'emergency':
|
|
|
|
name = '紧急站控';
|
|
|
|
break;
|
|
|
|
case 'center':
|
|
|
|
name = '中控';
|
|
|
|
break;
|
|
|
|
case 'substation':
|
|
|
|
name = '站控';
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// debugger;
|
|
|
|
this.setTextContext(name);
|
|
|
|
this.text.show();
|
2019-07-31 18:24:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mouseout(e) {
|
2019-08-05 18:42:37 +08:00
|
|
|
if (!this.down) {
|
|
|
|
this.text.hide();
|
|
|
|
}
|
2019-07-31 18:24:28 +08:00
|
|
|
}
|
|
|
|
}
|