diff --git a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/intermediate/compaction/LGraphToCGraphTransformer.java b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/intermediate/compaction/LGraphToCGraphTransformer.java index 4ce09c4006..5b3076edfe 100644 --- a/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/intermediate/compaction/LGraphToCGraphTransformer.java +++ b/plugins/org.eclipse.elk.alg.layered/src/org/eclipse/elk/alg/layered/intermediate/compaction/LGraphToCGraphTransformer.java @@ -479,6 +479,19 @@ public void applyLayout() { } + // offset selfloop labels + nodesMap.keySet().stream() + .flatMap(n -> StreamSupport.stream(n.getOutgoingEdges().spliterator(), false)) + .filter(e -> e.isSelfLoop()) + .forEach(sl -> { + LNode lNode = sl.getSource().getNode(); + CNode cNode = nodesMap.get(lNode); + double deltaX = cNode.hitbox.x - cNode.hitboxPreCompaction.x; + sl.getLabels().forEach(l -> { + l.getPosition().x += deltaX; + }); + }); + // calculating new graph size and offset KVector topLeft = new KVector(Double.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); KVector bottomRight = new KVector(Double.NEGATIVE_INFINITY, Double.NEGATIVE_INFINITY);