58 lines
988 B
JavaScript
58 lines
988 B
JavaScript
|
import Group from 'zrender/src/container/Group';
|
||
|
import Text from 'zrender/src/graphic/Text';
|
||
|
|
||
|
class ELevel extends Group {
|
||
|
constructor(model) {
|
||
|
super();
|
||
|
this.model = model;
|
||
|
this.isNew = false;
|
||
|
}
|
||
|
|
||
|
create() {
|
||
|
if (!this.isNew) {
|
||
|
const model = this.model;
|
||
|
const style = this.model.style;
|
||
|
|
||
|
this.isNew = true;
|
||
|
this.level = new Text({
|
||
|
zlevel: model.zlevel,
|
||
|
z: model.z,
|
||
|
style: {
|
||
|
x: model.x,
|
||
|
y: model.y,
|
||
|
fontWeight: 'normal',
|
||
|
fontSize: style.StationStand.common.textFontSize,
|
||
|
fontFamily: style.fontFamily,
|
||
|
text: model.name,
|
||
|
textFill: style.StationStand.level.textColor,
|
||
|
textAlign: 'middle'
|
||
|
}
|
||
|
});
|
||
|
|
||
|
this.add(this.level);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
setName(val) {
|
||
|
this.create();
|
||
|
this.level.setStyle('text', val);
|
||
|
}
|
||
|
|
||
|
setColor(color) {
|
||
|
this.create();
|
||
|
this.level.setStyle('textFill', color);
|
||
|
}
|
||
|
|
||
|
hide() {
|
||
|
this.create();
|
||
|
this.level.hide();
|
||
|
}
|
||
|
|
||
|
show() {
|
||
|
this.create();
|
||
|
this.level.show();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
export default ELevel;
|