Search in sources :

Example 1 with SelfLoopEdge

use of org.eclipse.elk.alg.layered.intermediate.loops.SelfLoopEdge in project elk by eclipse.

the class OrthogonalSelfLoopRouter method routeSelfLoops.

@Override
public void routeSelfLoops(final SelfLoopHolder slHolder) {
    LNode lNode = slHolder.getLNode();
    KVector nodeSize = lNode.getSize();
    LMargin nodeMargins = lNode.getMargin();
    double edgeEdgeDistance = LGraphUtil.getIndividualOrInherited(lNode, LayeredOptions.SPACING_EDGE_EDGE);
    double edgeLabelDistance = LGraphUtil.getIndividualOrInherited(lNode, LayeredOptions.SPACING_EDGE_LABEL);
    double nodeSLDistance = LGraphUtil.getIndividualOrInherited(lNode, LayeredOptions.SPACING_NODE_SELF_LOOP);
    LMargin newNodeMargins = new LMargin();
    newNodeMargins.set(nodeMargins);
    // Compute how far away from the node each routing slot on each side is (this takes labels into account)
    double[][] routingSlotPositions = computeRoutingSlotPositions(slHolder, edgeEdgeDistance, edgeLabelDistance, nodeSLDistance);
    for (SelfHyperLoop slLoop : slHolder.getSLHyperLoops()) {
        for (SelfLoopEdge slEdge : slLoop.getSLEdges()) {
            LEdge lEdge = slEdge.getLEdge();
            EdgeRoutingDirection routingDirection = computeEdgeRoutingDirection(slEdge);
            // Compute orthogonal bend points and give subclasses a chance to modify them to suit their particular
            // routing style. The default implementation in this class won't change the bend points.
            KVectorChain bendPoints = computeOrthogonalBendPoints(slEdge, routingDirection, routingSlotPositions);
            bendPoints = modifyBendPoints(slEdge, routingDirection, bendPoints);
            lEdge.getBendPoints().clear();
            lEdge.getBendPoints().addAll(bendPoints);
            bendPoints.stream().forEach(bp -> updateNewNodeMargins(nodeSize, newNodeMargins, bp));
        }
        // Place the self loop's labels (the edges were routed such that there is enough space available)
        SelfHyperLoopLabels slLabels = slLoop.getSLLabels();
        if (slLabels != null) {
            placeLabels(slLoop, slLabels, routingSlotPositions, edgeLabelDistance);
            updateNewNodeMargins(nodeSize, newNodeMargins, slLabels);
        }
    }
    // Update the node's margins to include the space required for self loops
    nodeMargins.set(newNodeMargins);
}
Also used : LMargin(org.eclipse.elk.alg.layered.graph.LMargin) LEdge(org.eclipse.elk.alg.layered.graph.LEdge) KVectorChain(org.eclipse.elk.core.math.KVectorChain) SelfLoopEdge(org.eclipse.elk.alg.layered.intermediate.loops.SelfLoopEdge) SelfHyperLoopLabels(org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoopLabels) LNode(org.eclipse.elk.alg.layered.graph.LNode) KVector(org.eclipse.elk.core.math.KVector) SelfHyperLoop(org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoop)

Aggregations

LEdge (org.eclipse.elk.alg.layered.graph.LEdge)1 LMargin (org.eclipse.elk.alg.layered.graph.LMargin)1 LNode (org.eclipse.elk.alg.layered.graph.LNode)1 SelfHyperLoop (org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoop)1 SelfHyperLoopLabels (org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoopLabels)1 SelfLoopEdge (org.eclipse.elk.alg.layered.intermediate.loops.SelfLoopEdge)1 KVector (org.eclipse.elk.core.math.KVector)1 KVectorChain (org.eclipse.elk.core.math.KVectorChain)1