Skip to content

Commit

Permalink
radial: Correctly use half of the node node spacing as padding. (#957)
Browse files Browse the repository at this point in the history
* radial: Correctly use half of the node node spacing as padding.

* radial: Correct recursive remvoe overlap.
  • Loading branch information
soerendomroes authored Oct 6, 2023
1 parent cfc8845 commit c5e9fc2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ public boolean overlap(final ElkNode node1, final ElkNode node2) {
double y1 = node1.getY() - spacing / 2;
double y2 = node2.getY() - spacing / 2;

double width1 = node1.getWidth() + spacing / 2;
double width2 = node2.getWidth() + spacing / 2;
double height1 = node1.getHeight() + spacing / 2;
double height2 = node2.getHeight() + spacing / 2;
double width1 = node1.getWidth() + spacing;
double width2 = node2.getWidth() + spacing;
double height1 = node1.getHeight() + spacing;
double height2 = node2.getHeight() + spacing;

if ((x1 < x2 + width2 && x2 < x1) && (y1 < y2 + height2 && y2 < y1)) {
// left upper and right lower corner overlap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,17 @@ public void extend(final ElkNode graph, final List<ElkNode> nodes, IElkProgressM
Set<ElkNode> nextLevelNodes = RadialUtil.getNextLevelNodeSet(nodes);
// Calculate the moved distance which is the amount all children and grandchildren have to be moved.
int index = 1;
while (!nextLevelNodes.isEmpty()) {
if (!nextLevelNodes.isEmpty()) {
for(ElkNode nextLevelNode : nextLevelNodes) {
moveNode(nextLevelNode, movedDistance);
}
progressMonitor.logGraph(graph, "Child movement " + index);
nextLevelNodes = RadialUtil.getNextLevelNodeSet(new ArrayList<>(nextLevelNodes));
index++;
}

if (sorter != null) {
sorter.sort(new ArrayList<>(nextLevelNodes));
}
progressMonitor.logGraph(graph, "After ancestor movement");
extend(graph, new ArrayList<>(nextLevelNodes), progressMonitor);
}
}
Expand Down

0 comments on commit c5e9fc2

Please sign in to comment.