2019-07-03 14:29:09 +08:00
|
|
|
import Line from 'zrender/src/graphic/shape/Line';
|
|
|
|
import Group from 'zrender/src/container/Group';
|
2019-07-03 18:41:00 +08:00
|
|
|
import { stat } from 'fs';
|
2019-07-03 14:29:09 +08:00
|
|
|
|
|
|
|
class Link extends Group {
|
2019-07-03 18:41:00 +08:00
|
|
|
constructor({ _code, _type, zlevel, model, state }, style) {
|
2019-07-03 14:29:09 +08:00
|
|
|
super();
|
2019-07-03 18:41:00 +08:00
|
|
|
this._code = _code;
|
|
|
|
this._type = _type;
|
|
|
|
this.zlevel = zlevel;
|
2019-07-03 14:29:09 +08:00
|
|
|
this.model = model;
|
|
|
|
this.state = state;
|
2019-07-03 18:41:00 +08:00
|
|
|
this.style = style;
|
2019-07-03 14:29:09 +08:00
|
|
|
this.create();
|
|
|
|
}
|
|
|
|
|
|
|
|
create() {
|
|
|
|
let model = this.model;
|
|
|
|
let style = this.style;
|
|
|
|
let textPosition = 'insideBottom';
|
|
|
|
|
|
|
|
if (model.beg.x !== model.end.x && model.beg.y !== model.end.y) {
|
|
|
|
textPosition = model.beg.y > model.end.y ? 'insideLeft' : 'insideRight';
|
|
|
|
}
|
|
|
|
|
|
|
|
this.link = new Line({
|
2019-07-03 18:41:00 +08:00
|
|
|
zlevel: this.zlevel,
|
2019-07-03 14:29:09 +08:00
|
|
|
shape: {
|
|
|
|
x1: model.beg.x,
|
|
|
|
y1: model.beg.y,
|
|
|
|
x2: model.end.x,
|
|
|
|
y2: model.end.y,
|
|
|
|
},
|
|
|
|
style: {
|
2019-07-03 18:41:00 +08:00
|
|
|
lineWidth: style.Link.linkWidth,
|
|
|
|
stroke: style.Link.linkColor,
|
|
|
|
text: model.code,
|
|
|
|
textDistance: style.Link.linkWidth * 2,
|
2019-07-03 14:29:09 +08:00
|
|
|
textPosition: textPosition,
|
|
|
|
textAlign: 'middle',
|
2019-07-03 18:41:00 +08:00
|
|
|
fontSize: style.Global.textFontSize,
|
|
|
|
textFill: style.Link.linkTextColor,
|
|
|
|
textStroke: style.Global.backgroundColor,
|
2019-07-03 14:29:09 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
this.add(this.link);
|
|
|
|
}
|
|
|
|
|
|
|
|
setStatus() {
|
|
|
|
}
|
|
|
|
|
|
|
|
tipBasePoint() {
|
|
|
|
return {
|
|
|
|
x: (this.link.shape.x1 + this.link.shape.x2) / 2,
|
|
|
|
y: (this.link.shape.y1 + this.link.shape.y2) / 2
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default Link;
|