45 lines
910 B
JavaScript
45 lines
910 B
JavaScript
import Text from 'zrender/src/graphic/Text';
|
|
import Group from 'zrender/src/container/Group';
|
|
|
|
export default class Text2 extends Group {
|
|
constructor(model, style) {
|
|
super();
|
|
this._code = model.code;
|
|
this._type = model._type;
|
|
this.name = model.code;
|
|
this.zlevel = model.zlevel;
|
|
this.model = model;
|
|
this.style = style;
|
|
this.z = 6;
|
|
this._create();
|
|
this.setState(model);
|
|
}
|
|
|
|
_create() {
|
|
var model = this.model;
|
|
var [direction, content] = model.content.split('::');
|
|
if (direction == 'V') {
|
|
content = content.split('').join('\n');
|
|
} else if (direction != 'H') {
|
|
content = model.content;
|
|
}
|
|
|
|
this.text = new Text({
|
|
zlevel: this.zlevel,
|
|
z: this.z,
|
|
style: {
|
|
x: model.position.x,
|
|
y: model.position.y,
|
|
text: content,
|
|
textFont: model.font,
|
|
textFill: model.fontColor,
|
|
textAlign: 'middle'
|
|
}
|
|
});
|
|
this.add(this.text);
|
|
}
|
|
|
|
setState(model) {
|
|
}
|
|
}
|