Search in sources :

Example 16 with Layer

use of org.eclipse.elk.alg.layered.graph.Layer in project elk by eclipse.

the class TestGraphCreator method getOneNodeGraph.

/**
 * Creates graph with only one node.
 *
 * @return graph with only one node.
 */
public LGraph getOneNodeGraph() {
    Layer layer = makeLayer();
    addNodeToLayer(layer);
    setUpIds();
    return graph;
}
Also used : Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 17 with Layer

use of org.eclipse.elk.alg.layered.graph.Layer 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;
}
Also used : LPort(org.eclipse.elk.alg.layered.graph.LPort) LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 18 with Layer

use of org.eclipse.elk.alg.layered.graph.Layer 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;
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 19 with Layer

use of org.eclipse.elk.alg.layered.graph.Layer in project elk by eclipse.

the class TestGraphCreator method getInLayerEdgesGraph.

/**
 * <pre>
 *   --*
 *   |
 * *-+-*-*
 *   |
 *   --*
 * .
 * </pre>
 *
 * @return graph of the form above
 */
public LGraph getInLayerEdgesGraph() {
    Layer leftLayer = makeLayer();
    Layer middleLayer = makeLayer();
    Layer rightLayer = makeLayer();
    LNode leftNode = addNodeToLayer(leftLayer);
    LNode[] middleNodes = addNodesToLayer(3, middleLayer);
    LNode rightNode = addNodeToLayer(rightLayer);
    // add east side ports first to get expected port ordering
    eastWestEdgeFromTo(middleNodes[1], rightNode);
    eastWestEdgeFromTo(leftNode, middleNodes[1]);
    addInLayerEdge(middleNodes[0], middleNodes[2], PortSide.WEST);
    setUpIds();
    return graph;
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Example 20 with Layer

use of org.eclipse.elk.alg.layered.graph.Layer in project elk by eclipse.

the class TestGraphCreator method getCrossFormedGraphConstraintsPreventAnySwitch.

/**
 * <pre>
 * this node must be.. -> *  *  <- and this node must be ...
 *                         \/
 *                         /\
 *    before this node -> *  *  <- before this node.
 * .
 * </pre>
 *
 * @return Graph of the form above.
 */
public LGraph getCrossFormedGraphConstraintsPreventAnySwitch() {
    Layer leftLayer = makeLayer();
    Layer rightLayer = makeLayer();
    LNode topLeft = addNodeToLayer(leftLayer);
    LNode bottomLeft = addNodeToLayer(leftLayer);
    LNode topRight = addNodeToLayer(rightLayer);
    LNode bottomRight = addNodeToLayer(rightLayer);
    eastWestEdgeFromTo(topLeft, bottomRight);
    eastWestEdgeFromTo(bottomLeft, topRight);
    setInLayerOrderConstraint(topRight, bottomRight);
    setInLayerOrderConstraint(topLeft, bottomLeft);
    setUpIds();
    return graph;
}
Also used : LNode(org.eclipse.elk.alg.layered.graph.LNode) Layer(org.eclipse.elk.alg.layered.graph.Layer)

Aggregations

Layer (org.eclipse.elk.alg.layered.graph.Layer)209 LNode (org.eclipse.elk.alg.layered.graph.LNode)185 LPort (org.eclipse.elk.alg.layered.graph.LPort)64 LEdge (org.eclipse.elk.alg.layered.graph.LEdge)40 LGraph (org.eclipse.elk.alg.layered.graph.LGraph)36 Test (org.junit.Test)25 TestAfterProcessor (org.eclipse.elk.alg.test.framework.annotations.TestAfterProcessor)13 KVector (org.eclipse.elk.core.math.KVector)12 List (java.util.List)9 NodeType (org.eclipse.elk.alg.layered.graph.LNode.NodeType)6 InternalProperties (org.eclipse.elk.alg.layered.options.InternalProperties)6 LLabel (org.eclipse.elk.alg.layered.graph.LLabel)5 LayeredOptions (org.eclipse.elk.alg.layered.options.LayeredOptions)5 IElkProgressMonitor (org.eclipse.elk.core.util.IElkProgressMonitor)5 BPInfo (org.eclipse.elk.alg.layered.intermediate.wrapping.BreakingPointInserter.BPInfo)4 GraphInfoHolder (org.eclipse.elk.alg.layered.p3order.GraphInfoHolder)4 ILayoutProcessor (org.eclipse.elk.core.alg.ILayoutProcessor)4 PortSide (org.eclipse.elk.core.options.PortSide)4 Pair (org.eclipse.elk.core.util.Pair)4 ArrayList (java.util.ArrayList)3