我想将标签与draw2d一起使用(来自draw2d.org),但问题是它们将位于其他对象下,因此要拖动它们,它们必须是页面上的唯一对象。我尝试使用toFront()方法,但这会导致问题,并且不会显示任何连接。
draw2d.shape.bpmn.Connection = draw2d.Connection.extend({
NAME: "draw2d.shape.bpmn.Connection",
init: function (attr, setter, getter) {
this._super($.extend({
router: new draw2d.layout.connection.InteractiveManhattanConnectionRouter(),
stroke: 1,
}, attr), setter, getter);
this.setTargetDecorator(new draw2d.decoration.connection.ArrowDecorator(17, 8));
this.label = new draw2d.shape.basic.Label({
text: "Label",
fontColor: "#0d0d0d",
});
this.add(this.label, new draw2d.layout.locator.ConnectionLabelLocator());
//this.toFront(this.label);
// this.toFront(this.label)
//this.label.installEditor(new draw2d.ui.LabelInplaceEditor());
//this.toFront(this.getParent());
},
onInstall: function (conn) {
this._super();
}});
draw2d.layout.locator.TuiConnectionLabelLocator = draw2d.layout.locator.PolylineMidpointLocator.extend({
NAME: "draw2d.layout.locator.ConnectionLabelLocator",
init: function () {
this._super();
},
bind: function (parent, child) {
child.setSelectionAdapter(function () {
return child;
});
},
unbind: function (parent, child) {
child.setSelectionAdapter(null);
}
});