use of org.eclipse.elk.alg.layered.graph.LPort in project elk by eclipse.
the class SwitchDecider method notifyOfSwitch.
/**
* Notifies in-layer counter of node switch for efficiency reasons.
*
* @param upperNode
* a node
* @param lowerNode
* a node
*/
public void notifyOfSwitch(final LNode upperNode, final LNode lowerNode) {
leftInLayerCounter.switchNodes(upperNode, lowerNode, PortSide.WEST);
rightInLayerCounter.switchNodes(upperNode, lowerNode, PortSide.EAST);
if (countCrossingsCausedByPortSwitch) {
LPort upperPort = (LPort) upperNode.getProperty(InternalProperties.ORIGIN);
LPort lowerPort = (LPort) lowerNode.getProperty(InternalProperties.ORIGIN);
parentCrossCounter.switchPorts(upperPort, lowerPort);
}
}
use of org.eclipse.elk.alg.layered.graph.LPort in project elk by eclipse.
the class AbstractBarycenterPortDistributorTest method distributePortsOfGraph_GivenCrossOnBothSides_ShouldRemoveCrossin.
/**
* <pre>
* * ___ *
* \/| |\/
* /\| |/\
* * |_| *
* </pre>
*/
@Test
public void distributePortsOfGraph_GivenCrossOnBothSides_ShouldRemoveCrossin() {
LNode[] leftNodes = addNodesToLayer(2, makeLayer(getGraph()));
LNode middleNode = addNodeToLayer(makeLayer(getGraph()));
LNode[] rightNodes = addNodesToLayer(2, makeLayer(getGraph()));
eastWestEdgeFromTo(middleNode, rightNodes[1]);
eastWestEdgeFromTo(middleNode, rightNodes[0]);
eastWestEdgeFromTo(leftNodes[0], middleNode);
eastWestEdgeFromTo(leftNodes[1], middleNode);
setUpIds();
List<LPort> expectedPortOrderMiddleNode = copyPortsInIndexOrder(middleNode, 1, 0, 3, 2);
distributePortsInCompleteGraph(8);
assertThat(middleNode.getPorts(), is(expectedPortOrderMiddleNode));
}
use of org.eclipse.elk.alg.layered.graph.LPort in project elk by eclipse.
the class AbstractBarycenterPortDistributorTest method distributePortsOnSide_GivenCrossOnWesternSide_ShouldRemoveCrossing.
// CHECKSTYLEOFF javadoc
// CHECKSTYLEOFF MagicNumber
// CHECKSTYLEOFF MethodName
/**
* <pre>
* * ___
* \/| |
* /\| |
* * |_|
* </pre>
*/
@Test
public void distributePortsOnSide_GivenCrossOnWesternSide_ShouldRemoveCrossing() {
LNode[] leftNodes = addNodesToLayer(2, makeLayer(getGraph()));
LNode rightNode = addNodeToLayer(makeLayer(getGraph()));
eastWestEdgeFromTo(leftNodes[0], rightNode);
eastWestEdgeFromTo(leftNodes[1], rightNode);
List<LPort> expectedPortOrderRightNode = Lists.newArrayList(rightNode.getPorts().get(1), rightNode.getPorts().get(0));
distributePortsInCompleteGraph(4);
assertThat(rightNode.getPorts(), is(expectedPortOrderRightNode));
}
use of org.eclipse.elk.alg.layered.graph.LPort in project elk by eclipse.
the class AbstractBarycenterPortDistributorTest method distributePortsOnSide_partlyCrossHierarchicalEdges_CrossHierarchyStaysOuterChanges.
/**
* <pre>
* ____
* | *+-- *
* | | \/
* | |\ /\
* | *+-x *
* |__| \
* -*
* </pre>
*/
// TODO this is a problem which currently cannot be solved by our algorithm :-(
@Ignore
public void distributePortsOnSide_partlyCrossHierarchicalEdges_CrossHierarchyStaysOuterChanges() {
LNode leftOuterNode = addNodeToLayer(makeLayer());
LNode[] rightNodes = addNodesToLayer(3, makeLayer());
LPort[] leftOuterPorts = addPortsOnSide(3, leftOuterNode, PortSide.EAST);
LGraph leftInnerGraph = nestedGraph(leftOuterNode);
LNode[] leftInnerNodes = addNodesToLayer(2, makeLayer(leftInnerGraph));
LNode[] leftInnerDummyNodes = new LNode[2];
Layer dummyLayer = makeLayer();
leftInnerDummyNodes[0] = addExternalPortDummyNodeToLayer(dummyLayer, leftOuterPorts[0]);
leftInnerDummyNodes[1] = addExternalPortDummyNodeToLayer(dummyLayer, leftOuterPorts[2]);
eastWestEdgeFromTo(leftInnerNodes[0], leftInnerDummyNodes[0]);
eastWestEdgeFromTo(leftInnerNodes[1], leftInnerDummyNodes[1]);
eastWestEdgeFromTo(leftOuterPorts[0], rightNodes[1]);
eastWestEdgeFromTo(leftOuterPorts[1], rightNodes[2]);
eastWestEdgeFromTo(leftOuterPorts[2], rightNodes[0]);
// leftOuterNode.setProperty(InternalProperties.HAS_HIERARCHICAL_AND_NORMAL_PORTS, true);
setPortOrderFixed(leftOuterNode);
setUpIds();
List<LPort> expectedOrder = Lists.newArrayList(switchOrderInArray(1, 2, leftOuterPorts));
distributePortsInCompleteGraph(8);
assertThat(leftOuterNode.getPorts(), is(expectedOrder));
}
use of org.eclipse.elk.alg.layered.graph.LPort in project elk by eclipse.
the class AbstractBarycenterPortDistributorTest method distributePortsWhileSweeping_givenSimpleCross_ShouldRemoveCrossing.
/**
* <pre>
* ___ ____
* | |\/| |
* |_|/\| |
* |--|
* </pre>
*/
@Test
public void distributePortsWhileSweeping_givenSimpleCross_ShouldRemoveCrossing() {
LNode leftNode = addNodeToLayer(makeLayer(getGraph()));
LNode rightNode = addNodeToLayer(makeLayer(getGraph()));
eastWestEdgeFromTo(leftNode, rightNode);
eastWestEdgeFromTo(leftNode, rightNode);
List<LPort> expectedPortRightNode = copyPortsInIndexOrder(rightNode, 1, 0);
setUpIds();
LNode[][] nodeArray = graph.toNodeArray();
ISweepPortDistributor portDist = new LayerTotalPortDistributor(nodeArray.length);
IInitializable.init(Arrays.asList(portDist), nodeArray);
portDist.distributePortsWhileSweeping(nodeArray, 1, true);
assertThat(rightNode.getPorts(), is(expectedPortRightNode));
}
Aggregations