2019-11-29 12:51:58 +08:00
|
|
|
import Text from 'zrender/src/graphic/Text';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
2020-03-10 10:21:33 +08:00
|
|
|
import {getPrdType, isShowThePrdType} from '../utils/handlePath';
|
2019-11-29 12:51:58 +08:00
|
|
|
|
|
|
|
export default class Text2 extends Group {
|
2020-03-09 17:38:15 +08:00
|
|
|
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;
|
2020-03-10 09:49:05 +08:00
|
|
|
this.prdType = getPrdType();
|
2020-03-10 10:21:33 +08:00
|
|
|
if (isShowThePrdType(this.prdType, model.showConditions)) {
|
2020-03-10 09:49:05 +08:00
|
|
|
this.create();
|
|
|
|
this.setState(model);
|
|
|
|
}
|
2020-03-09 17:38:15 +08:00
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
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;
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
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);
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
|
2020-03-09 17:38:15 +08:00
|
|
|
setState(model) {
|
|
|
|
}
|
2019-11-29 12:51:58 +08:00
|
|
|
}
|