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

57 lines
1.3 KiB
JavaScript
Raw Normal View History

2019-07-23 18:49:54 +08:00
import Group from 'zrender/src/container/Group';
import Text from 'zrender/src/graphic/Text';
class ESigName extends Group {
2020-03-31 15:34:55 +08:00
constructor(model) {
super();
this.model = model;
this.create();
}
2019-07-23 18:49:54 +08:00
2020-03-31 15:34:55 +08:00
create() {
const model = this.model;
this.name = new Text({
_subType: 'SignalLamp',
_val: '3',
zlevel: model.zlevel,
z: model.z,
silent: model.silent,
style: {
textBorderColor: 'red',
textBorderWidth: 0,
x: model.x,
y: model.y,
fontWeight: model.fontWeight,
fontSize: model.fontSize,
fontFamily: model.fontFamily,
text: model.text,
textFill: model.textFill,
textAlign: model.textAlign,
textPosition: model.textPosition || 'inside',
textVerticalAlign: model.textVerticalAlign || null
}
});
this.add(this.name);
}
2019-07-23 18:49:54 +08:00
2020-03-31 15:34:55 +08:00
setStyle(model) {
this.name.setStyle(model);
}
2019-07-23 18:49:54 +08:00
2020-03-31 15:34:55 +08:00
setColor(color) {
this.name.setStyle('textFill', color);
}
2019-07-23 18:49:54 +08:00
2020-03-31 15:34:55 +08:00
// 隐藏
hide() {
this.name.hide();
}
2019-07-23 18:49:54 +08:00
2020-03-31 15:34:55 +08:00
// 显示
show() {
this.name.show();
}
2019-07-23 18:49:54 +08:00
}
export default ESigName;