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

60 lines
1.4 KiB
JavaScript
Raw Normal View History

import Group from 'zrender/src/container/Group';
2019-07-31 14:59:38 +08:00
import Rect from 'zrender/src/graphic/shape/Rect';
export default class EMouse extends Group {
constructor(device) {
super();
this.device = device;
2019-07-31 14:59:38 +08:00
this.zlevel = device.zlevel;
this.style = device.style;
this.down = true;
2019-07-31 14:59:38 +08:00
this.create();
}
create() {
this.lampRect = new Rect({
silent: true,
zlevel: this.zlevel,
z: 6,
shape: this.device.getBoundingRect(),
style: {
2019-08-02 14:17:43 +08:00
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
2019-07-31 14:59:38 +08:00
fill: this.style.transparentColor
}
});
this.nameRect = new Rect({
silent: true,
zlevel: this.zlevel,
z: 5,
shape: this.device.sigName.getBoundingRect(),
style: {
2019-08-02 14:17:43 +08:00
lineDash: this.style.Signal.mouseOverStyle.borderLineDash,
stroke: this.style.Signal.mouseOverStyle.borderLineColor,
fill: this.style.Signal.mouseOverStyle.nameBackgroundColor
2019-07-31 14:59:38 +08:00
}
});
this.lampRect.hide();
this.nameRect.hide();
this.add(this.lampRect);
this.add(this.nameRect);
}
mouseover(e) {
2019-07-31 14:59:38 +08:00
this.nameRect.show();
this.lampRect.show();
this.device.lamps.forEach(elem => {
2019-08-02 14:17:43 +08:00
elem.setBorderColor(this.style.Signal.mouseOverStyle.lampBorderLineColor);
2019-07-31 14:59:38 +08:00
});
this.device.sigName.setColor(this.style.backgroundColor);
}
mouseout(e) {
2019-07-31 14:59:38 +08:00
this.nameRect.hide();
this.lampRect.hide();
this.device.setState(this.device.model);
}
}