Skip to content

Commit

Permalink
Fixes Self-loop label bug when using compaction (#1081)
Browse files Browse the repository at this point in the history
Self-loop labels were previously omitted during compaction. This PR
moves them together with everything else.
  • Loading branch information
Eddykasp authored Nov 6, 2024
1 parent c85c8b6 commit 099fd0d
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 099fd0d

Please sign in to comment.