rt-sim-training-client/src/jmap/shape/Signal/EMouse.js
sunzhenyu d7efef41e4 pull
2019-08-29 17:16:33 +08:00

64 lines
1.5 KiB
JavaScript

import Group from 'zrender/src/container/Group';
import Rect from 'zrender/src/graphic/shape/Rect';
export default class EMouse extends Group {
constructor(device) {
super();
this.device = device;
this.zlevel = device.zlevel;
this.style = device.style;
this.create();
}
create() {
this.lampRect = new Rect({
silent: true,
zlevel: this.zlevel,
z: 6,
shape: this.device.getBoundingRect(),
style: {
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
fill: this.style.transparentColor
}
});
this.nameRect = new Rect({
silent: true,
zlevel: this.zlevel,
z: 5,
shape: this.device.sigName.getBoundingRect(),
style: {
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
fill: this.style.Signal.mouseOverStyle.nameBackgroundColor
}
});
this.lampRect.hide();
this.nameRect.hide();
this.add(this.lampRect);
this.add(this.nameRect);
}
mouseover(e) {
this.nameRect.show();
this.lampRect.show();
this.device.lamps.forEach(elem => {
elem.setBorderColor(this.style.Signal.mouseOverStyle.lampBorderLineColor);
});
this.device.sigName && this.device.sigName.setColor(this.style.backgroundColor);
}
mouseout(e) {
if (!this.device.model.down) {
this.nameRect.hide();
this.lampRect.hide();
this.device.lamps.forEach(elem => {
elem.setBorderColor(this.style.Signal.lamp.borderColor);
});
this.device.setState(this.device.model);
}
}
}