2019-11-29 12:51:58 +08:00
|
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
|
|
|
|
class ELevel extends Group {
|
2020-01-13 16:52:00 +08:00
|
|
|
constructor(model) {
|
|
|
|
super();
|
|
|
|
this.model = model;
|
2020-03-27 10:17:24 +08:00
|
|
|
this.level = null;
|
2020-01-13 16:52:00 +08:00
|
|
|
this.isNew = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
create() {
|
|
|
|
if (!this.isNew) {
|
2020-09-09 13:55:42 +08:00
|
|
|
const model = this.model.modelData;
|
2020-01-13 16:52:00 +08:00
|
|
|
const style = this.model.style;
|
|
|
|
|
|
|
|
this.isNew = true;
|
2020-09-09 13:55:42 +08:00
|
|
|
|
|
|
|
const levelDrict = model.right ? 1 : -1;
|
|
|
|
const levelX = model.position.x - levelDrict * (style.StationStand.level.offset.x - model.width / 2);
|
|
|
|
const levelY = model.position.y + levelDrict * (style.StationStand.level.offset.y);
|
|
|
|
|
2020-01-13 16:52:00 +08:00
|
|
|
this.level = new Text({
|
2020-09-09 13:55:42 +08:00
|
|
|
zlevel: this.model.zlevel,
|
|
|
|
z: this.model.z,
|
2020-01-13 16:52:00 +08:00
|
|
|
style: {
|
2020-09-09 13:55:42 +08:00
|
|
|
x: levelX,
|
|
|
|
y: levelY,
|
2020-03-27 10:17:24 +08:00
|
|
|
fontWeight: style.textStyle.fontWeight,
|
2020-09-09 13:55:42 +08:00
|
|
|
fontSize: style.StationStand.level.textFontSize,
|
2020-01-13 16:52:00 +08:00
|
|
|
fontFamily: style.fontFamily,
|
2020-09-09 13:55:42 +08:00
|
|
|
text: model.runLevelTime || '5',
|
2020-01-13 16:52:00 +08:00
|
|
|
textFill: style.StationStand.level.textColor,
|
2020-03-27 10:17:24 +08:00
|
|
|
textAlign: style.textStyle.textAlign,
|
|
|
|
textVerticalAlign: style.textStyle.textVerticalAlign
|
2020-01-13 16:52:00 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
this.add(this.level);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setName(val) {
|
|
|
|
this.level.setStyle('text', val);
|
|
|
|
}
|
|
|
|
|
|
|
|
setColor(color) {
|
|
|
|
this.create();
|
|
|
|
this.level.setStyle('textFill', color);
|
|
|
|
}
|
|
|
|
|
2020-03-27 17:26:17 +08:00
|
|
|
hideMode() {
|
2020-03-27 10:17:24 +08:00
|
|
|
this.level && this.level.hide();
|
2020-01-13 16:52:00 +08:00
|
|
|
}
|
|
|
|
|
2020-03-27 17:26:17 +08:00
|
|
|
showMode() {
|
2020-01-13 16:52:00 +08:00
|
|
|
this.create();
|
|
|
|
this.level.show();
|
|
|
|
}
|
2020-09-09 13:55:42 +08:00
|
|
|
|
|
|
|
recover() {
|
|
|
|
this.hideMode();
|
|
|
|
}
|
2020-09-15 17:08:28 +08:00
|
|
|
setState(model) {
|
2020-09-15 18:28:32 +08:00
|
|
|
// 运行等级
|
2020-09-15 17:08:28 +08:00
|
|
|
if (Number(model.runLevelTime) > 0) {
|
|
|
|
this.showMode();
|
|
|
|
this.setName(model.runLevelTime);
|
|
|
|
}
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ELevel;
|