Search in sources :

Example 6 with SelfHyperLoopLabels

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

the class OrthogonalSelfLoopRouter method initializeWithMaxLabelHeight.

/**
 * Initializes the entry for each routing slot on the north or south sides with the maximum height of labels it
 * houses.
 */
private void initializeWithMaxLabelHeight(final double[][] positions, final SelfLoopHolder slHolder, final PortSide portSide) {
    assert portSide == PortSide.NORTH || portSide == PortSide.SOUTH;
    double[] sidePositions = positions[portSide.ordinal()];
    for (SelfHyperLoop slLoop : slHolder.getSLHyperLoops()) {
        SelfHyperLoopLabels slLabels = slLoop.getSLLabels();
        if (slLabels != null && slLabels.getSide() == portSide) {
            int routingSlot = slLoop.getRoutingSlot(portSide);
            sidePositions[routingSlot] = Math.max(sidePositions[routingSlot], slLabels.getSize().y);
        }
    }
}
Also used : SelfHyperLoopLabels(org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoopLabels) SelfHyperLoop(org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoop)

Example 7 with SelfHyperLoopLabels

use of org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoopLabels 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

SelfHyperLoopLabels (org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoopLabels)7 SelfHyperLoop (org.eclipse.elk.alg.layered.intermediate.loops.SelfHyperLoop)3 KVector (org.eclipse.elk.core.math.KVector)3 LMargin (org.eclipse.elk.alg.layered.graph.LMargin)2 LNode (org.eclipse.elk.alg.layered.graph.LNode)2 SelfLoopPort (org.eclipse.elk.alg.layered.intermediate.loops.SelfLoopPort)2 LEdge (org.eclipse.elk.alg.layered.graph.LEdge)1 SelfLoopEdge (org.eclipse.elk.alg.layered.intermediate.loops.SelfLoopEdge)1 SelfLoopOrderingStrategy (org.eclipse.elk.alg.layered.options.SelfLoopOrderingStrategy)1 KVectorChain (org.eclipse.elk.core.math.KVectorChain)1 PortSide (org.eclipse.elk.core.options.PortSide)1