rt-sim-training-client/src/jmapNew/shape/LimitControl/index.js

85 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-11-29 12:51:58 +08:00
/*
* 权限临时限速
*/
import Group from 'zrender/src/container/Group';
import EControl from '../element/EControl';
import EMouse from './EMouse';
export default class LimitControl extends Group {
constructor(model, style) {
super();
this.selected = false;
this._code = model.code;
this._type = model._type;
this.zlevel = model.zlevel;
this.model = model;
this.style = style;
this.z = 20;
this.create(model);
this.createMouseEvent();
this.setState(model);
}
2019-11-29 12:51:58 +08:00
create(model) {
this.control = new EControl({
zlevel: this.zlevel,
z: this.z,
arc: {
shape: {
cx: model.position.x,
cy: model.position.y,
r: this.style.LimitControl.lamp.radiusR
},
subType: 'Control',
lineWidth: 0,
fill: this.style.LimitControl.lamp.controlColor,
mouseover: this.mouseoverArc,
mouseout: this.mouseoutArc
},
text: {
position: [0, 0],
x: model.position.x,
y: model.position.y + this.style.LimitControl.lamp.radiusR + this.style.LimitControl.text.distance,
fontWeight: this.style.LimitControl.text.fontWeight,
fontSize: this.style.LimitControl.text.fontSize,
fontFamily: this.style.fontFamily,
text: model.name,
textFill: '#fff',
textAlign: 'middle',
textVerticalAlign: 'top',
mouseover: this.mouseoverText,
mouseout: this.mouseoutText
},
style: this.style
});
2019-11-29 12:51:58 +08:00
this.add(this.control);
}
2019-11-29 12:51:58 +08:00
// 设置状态
setState(model) {
}
2019-11-29 12:51:58 +08:00
createMouseEvent() {
if (this.style.LimitControl.mouseOverStyle) {
this.mouseEvent = new EMouse(this);
this.add(this.mouseEvent);
this.on('mouseout', (e) => { this.mouseEvent.mouseout(e); });
this.on('mouseover', (e) => { this.mouseEvent.mouseover(e); });
}
}
2019-11-29 12:51:58 +08:00
getShapeTipPoint() {
if (this.control) {
var distance = 2;
var rect = this.control.getBoundingRect();
return {
x: rect.x + rect.width / 2,
y: rect.y - distance
};
}
return null;
}
2020-03-11 15:10:08 +08:00
setShowMode() {}
2019-11-29 12:51:58 +08:00
}