Skip to content

Commit

Permalink
Rectpacking orderbysize patch (#1100)
Browse files Browse the repository at this point in the history
* the rectpacking size reorderer now compares node height rather than area

Co-authored-by: Sören Domrös <[email protected]>
  • Loading branch information
Eddykasp and soerendomroes authored Dec 13, 2024
1 parent 37c7ded commit 765676d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ option inNewRow: boolean {
}

option orderBySize: boolean {
label "Order nodes by size"
label "Order nodes by height"
description
"If set to true the nodes will be sorted by the size of their area before computing the layout. The largest
"If set to true the nodes will be sorted by their height before computing the layout. The highest
node will be in the first position."
default = false
targets parents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import org.eclipse.elk.graph.ElkNode;

/**
* Node size comparator to compare nodes by their size
* Node size comparator to compare nodes by their height
*
*/
public class NodeSizeComparator implements Comparator<ElkNode> {
Expand All @@ -24,10 +24,7 @@ public class NodeSizeComparator implements Comparator<ElkNode> {
*/
@Override
public int compare(ElkNode node0, ElkNode node1) {
double area0 = node0.getWidth() * node0.getHeight();
double area1 = node1.getWidth() * node1.getHeight();

return Double.compare(area1, area0);
return Double.compare(node1.getHeight(), node0.getHeight());
}

}

0 comments on commit 765676d

Please sign in to comment.