Skip to content

Commit 765676d

Browse files
Rectpacking orderbysize patch (#1100)
* the rectpacking size reorderer now compares node height rather than area Co-authored-by: Sören Domrös <[email protected]>
1 parent 37c7ded commit 765676d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPacking.melk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@ option inNewRow: boolean {
206206
}
207207

208208
option orderBySize: boolean {
209-
label "Order nodes by size"
209+
label "Order nodes by height"
210210
description
211-
"If set to true the nodes will be sorted by the size of their area before computing the layout. The largest
211+
"If set to true the nodes will be sorted by their height before computing the layout. The highest
212212
node will be in the first position."
213213
default = false
214214
targets parents

plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/intermediate/NodeSizeComparator.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import org.eclipse.elk.graph.ElkNode;
1515

1616
/**
17-
* Node size comparator to compare nodes by their size
17+
* Node size comparator to compare nodes by their height
1818
*
1919
*/
2020
public class NodeSizeComparator implements Comparator<ElkNode> {
@@ -24,10 +24,7 @@ public class NodeSizeComparator implements Comparator<ElkNode> {
2424
*/
2525
@Override
2626
public int compare(ElkNode node0, ElkNode node1) {
27-
double area0 = node0.getWidth() * node0.getHeight();
28-
double area1 = node1.getWidth() * node1.getHeight();
29-
30-
return Double.compare(area1, area0);
27+
return Double.compare(node1.getHeight(), node0.getHeight());
3128
}
3229

3330
}

0 commit comments

Comments
 (0)