Recursive Connection [message #1807906] |
Wed, 12 June 2019 07:48 |
Servan Kilec Messages: 7 Registered: October 2018 |
Junior Member |
|
|
I want a recursive relationship with a node. I have created a connection (this connection uses the "OrthogonalRouter").
For example:
MindMapNode node = new MindMapNode();
MindMapConnection conn = new MindMapConnection();
conn.connect(node, node);
In the "MinMapConnection" class I rewrote the "connect" method so that it doesn't throw exceptions if the target and the source node are the same. However, no connection is displayed anyway.
Is there a way to create a recursive relationship? Do I have to write my own router? If so, what is the best way to do this?
My goal is a connection like in this picture:
[Updated on: Wed, 12 June 2019 07:49] Report message to a moderator
|
|
|
Re: Recursive Connection [message #1808686 is a reply to message #1807906] |
Fri, 28 June 2019 14:20 |
|
Hi Servan,
in order to implement reflexive relations, you may contribute an implementation for this special case within the corresponding part's doRefreshVisual() method by testing if source and target are identical and supplying the relation visual with control points manually routed around the source/target so that it is fully visible.
Hence, it could look similar to this pseudocode:
public class RelationPart extends AbstractContentPart<RelationVisual> {
protected void doRefreshVisual(RelationVisual visual) {
...
// update control points
if (sourcePart == targetPart) {
// reflexive relation
relationVisual.setControlPoints(determineReflexiveControlPoints(sourcePart));
} else {
// normal control points
}
}
protected List<Point> determineReflexiveControlPoints(NodePart target) {
Bounds bounds = target.getVisual().getBoundsInParent();
// TODO: return list of control points, e.g. Arrays.asLists(bounds.x + 5, bounds.y, ...);
}
...
}
Best regards,
Matthias
|
|
|
Powered by
FUDForum. Page generated in 0.02903 seconds