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);
}
Aggregations