I have a problem when reparenting links in and out of subgraphs.
When calling: getSelection().addCollection(deflayer.addCollection(getSelection(), true, deflayer));
It seems to reparent the link correctly so its parent is null and the labels’ parent is null. (when dragging to the top level).
However when I then drag two nodes back into the subgraph and call:
subgraph.addCollection(getSelection(), true, deflayer);
It correctly makes the links’ parent the subgraph however the labels’ parent stays as null which then causes it to not be drawn correctly.
I have found this is also an issue with the BoxApp example.
By overriding the method in BoxView.java
public void newLink(JGoPort from, JGoPort to) {
JGoDocument doc = getDocument();
if (doc == null) return;
JGoLabeledLink link = new JGoLabeledLink(from, to);
JGoLinkLabel label = new JGoLinkLabel("Hello");
label.setTransparent(false);
link.setMidLabel(label);
JGoSubGraphBase.reparentToCommonSubGraph(link, from, to, true, doc.getLinksLayer());
fireUpdate(JGoViewEvent.LINK_CREATED, 0, link);
doc.endTransaction(getEditPresentationName(4));
}
Put two nodes in the subgraph, make a link between them. Works fine.
Drag both nodes out of the subgraph. Works fine.
Drag both nodes back in the subgraph. Works fine. (However the labels parent is incorrect but it draws it correctly).
Move the subgraph (this causes it to get reinserted into the document) and you now notice that the link line goes over the top of the text (this is because the order it is drawing the objects).
I’ve tried a few things to circumvent this problem but no luck.
Any ideas?
Thanks.