Getting the shape of edges using the ELK Java API? [message #1796898] |
Sun, 21 October 2018 19:08 |
vlq . Messages: 2 Registered: October 2018 |
Junior Member |
|
|
I am trying to use the Java API to make a simple command-line tool and I can't figure out how to get the path (i.e. the bending points) of the edges. ElkEdge.getSections() seems to give me only the starting and end points. I have also tried ElkEdge.getProperty(LayeredOptions.JUNCTION_POINTS) and LEdge.getBendPoints() with an LGraph, but they both always return an empty list for me.
Below is a pretty simple test graph that I tried to replicate in Java.
algorithm: layered
node n1 {
layout [ size: 100, 100 ]
portConstraints: FIXED_POS
port p1 {
layout [ position: 100, 0 size: 10, 10 ]
}
}
node n2 {
layout [ size: 100, 100 ]
portConstraints: FIXED_POS
port p2 {
layout [ position: 80, 100 size: 20, 20 ]
}
}
edge n1.p1 -> n2.p2
My Java code:
LayoutMetaDataService.getInstance(); // Forces initialization of ELK reflective classes.
ElkNode rootNode = ElkGraphUtil.createGraph();
rootNode.setProperty(LayeredOptions.EDGE_ROUTING, EdgeRouting.ORTHOGONAL);
ElkNode elkNode1 = ElkGraphUtil.createNode(rootNode);
elkNode1.setDimensions(100.0, 100.0);
elkNode1.setProperty(CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_POS);
ElkPort elkPort1 = ElkGraphUtil.createPort(elkNode1);
elkPort1.setDimensions(10.0, 10.0);
elkPort1.setLocation(100.0, 0.0);
ElkNode elkNode2 = ElkGraphUtil.createNode(rootNode);
elkNode2.setDimensions(100.0, 100.0);
elkNode2.setProperty(CoreOptions.PORT_CONSTRAINTS, PortConstraints.FIXED_POS);
ElkPort elkPort2 = ElkGraphUtil.createPort(elkNode2);
elkPort2.setDimensions(20.0, 20.0);
elkPort2.setLocation(80.0, 100.0);
ElkEdge edge = ElkGraphUtil.createEdge(rootNode);
edge.getSources().add(elkPort1);
edge.getTargets().add(elkPort2);
LayeredLayoutProvider layeredLayoutProvider = new LayeredLayoutProvider();
layeredLayoutProvider.initialize(null);
try {
BasicProgressMonitor progressMonitor = new BasicProgressMonitor();
layeredLayoutProvider.layout(rootNode, progressMonitor);
} finally {
layeredLayoutProvider.dispose();
}
System.out.println(elkNode1);
System.out.println(elkNode2);
System.out.println(edge.getSections());
System.out.println(edge.getProperty(LayeredOptions.JUNCTION_POINTS));
Which outputs:
ElkNode (12.0,137.0 | 100.0,100.0)
ElkNode (142.0,12.0 | 100.0,100.0)
[org.eclipse.elk.graph.impl.ElkEdgeSectionImpl@d4342c2 (startX: 122.0, startY: 142.0, endX: 232.0, endY: 132.0, identifier: null)]
()
So the edge seems to go diagonally from (122, 142) to (232, 132), which is fine, but there are no junctions even though I was hoping for an orthogonal graph.
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04006 seconds