use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class TestGraphCreator method getCurrentOrder.
/**
* Returns the nodes in the graph as two-dimensional array of LNodes.
*
* @return graph as LNode[][].
*/
public LNode[][] getCurrentOrder() {
LNode[][] nodeOrder = new LNode[graph.getLayers().size()][];
List<Layer> layers = graph.getLayers();
for (int i = 0; i < layers.size(); i++) {
Layer layer = layers.get(i);
List<LNode> nodes = layer.getNodes();
nodeOrder[i] = new LNode[nodes.size()];
for (int j = 0; j < nodes.size(); j++) {
nodeOrder[i][j] = nodes.get(j);
}
}
return nodeOrder;
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class TestGraphCreator method getFixedPortOrderInLayerEdgesDontCrossEachOther.
/**
* <pre>
* ____
* | |----
* |__|\ |
* ____ | |
* | |/ |
* |__|---|
* .
* </pre>
*
* Port order fixed.
*
* @return Graph of the form above.
*/
public LGraph getFixedPortOrderInLayerEdgesDontCrossEachOther() {
Layer layer = makeLayer();
LNode[] nodes = addNodesToLayer(2, layer);
setFixedOrderConstraint(nodes[0]);
setFixedOrderConstraint(nodes[1]);
// must add ports and edges manually, due to clockwise port ordering
LPort upperPortUpperNode = addPortOnSide(nodes[0], PortSide.EAST);
LPort lowerPortUpperNode = addPortOnSide(nodes[0], PortSide.EAST);
LPort upperPortLowerNode = addPortOnSide(nodes[1], PortSide.EAST);
LPort lowerPortLowerNode = addPortOnSide(nodes[1], PortSide.EAST);
addEdgeBetweenPorts(upperPortUpperNode, lowerPortLowerNode);
addEdgeBetweenPorts(lowerPortUpperNode, upperPortLowerNode);
setUpIds();
return graph;
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class TestGraphCreator method addNorthSouthEdge.
protected void addNorthSouthEdge(final PortSide side, final LNode nodeWithNSPorts, final LNode northSouthDummy, final LNode nodeWithEastWestPorts, final boolean nodeWithEastWestPortsIsOrigin) {
boolean normalNodeEastOfNsPortNode = nodeWithEastWestPorts.getLayer().getIndex() < nodeWithNSPorts.getLayer().getIndex();
PortSide direction = normalNodeEastOfNsPortNode ? PortSide.WEST : PortSide.EAST;
PortSide targetNodePortSide = direction == PortSide.WEST ? PortSide.EAST : PortSide.WEST;
LPort normalNodePort = addPortOnSide(nodeWithEastWestPorts, targetNodePortSide);
LPort dummyNodePort = addPortOnSide(northSouthDummy, direction);
if (nodeWithEastWestPortsIsOrigin) {
addEdgeBetweenPorts(normalNodePort, dummyNodePort);
} else {
addEdgeBetweenPorts(dummyNodePort, normalNodePort);
}
northSouthDummy.setProperty(InternalProperties.IN_LAYER_LAYOUT_UNIT, nodeWithNSPorts);
northSouthDummy.setProperty(InternalProperties.ORIGIN, nodeWithNSPorts);
setAsNorthSouthNode(northSouthDummy);
LPort originPort = addPortOnSide(nodeWithNSPorts, side);
dummyNodePort.setProperty(InternalProperties.ORIGIN, originPort);
originPort.setProperty(InternalProperties.PORT_DUMMY, northSouthDummy);
List<LNode> baryAssoc = Lists.newArrayList(northSouthDummy);
List<LNode> otherBaryAssocs = nodeWithNSPorts.getProperty(InternalProperties.BARYCENTER_ASSOCIATES);
if (otherBaryAssocs == null) {
nodeWithNSPorts.setProperty(InternalProperties.BARYCENTER_ASSOCIATES, baryAssoc);
} else {
otherBaryAssocs.addAll(baryAssoc);
}
if (side == PortSide.NORTH) {
northSouthDummy.getProperty(InternalProperties.IN_LAYER_SUCCESSOR_CONSTRAINTS).add(nodeWithNSPorts);
} else {
nodeWithNSPorts.getProperty(InternalProperties.IN_LAYER_SUCCESSOR_CONSTRAINTS).add(northSouthDummy);
}
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class TestGraphCreator method multipleInBetweenLayerEdgesIntoNodeWithNoFixedPortOrder.
/**
* <pre>
* ---*
* |
* | ____
* *+-| |
* *+-| |
* \|__|
* Port order not fixed.
* .
* </pre>
*
* @return Graph of the form above.
*/
public LGraph multipleInBetweenLayerEdgesIntoNodeWithNoFixedPortOrder() {
Layer leftLayer = makeLayer();
LNode[] leftNodes = addNodesToLayer(2, leftLayer);
Layer rightLayer = makeLayer();
LNode[] rightNodes = addNodesToLayer(2, rightLayer);
addInLayerEdge(rightNodes[0], rightNodes[1], PortSide.WEST);
eastWestEdgeFromTo(leftNodes[0], rightNodes[1]);
eastWestEdgeFromTo(leftNodes[0], rightNodes[1]);
setUpIds();
return graph;
}
use of org.eclipse.elk.alg.layered.graph.LNode in project elk by eclipse.
the class TestGraphCreator method addNodeToLayer.
protected LNode addNodeToLayer(final Layer layer) {
LNode node = new LNode(graph);
node.setType(NodeType.NORMAL);
node.setProperty(InternalProperties.IN_LAYER_LAYOUT_UNIT, node);
node.setLayer(layer);
node.id = nodeId++;
return node;
}
Aggregations