From 2144d91514d4f79dc194d8f394193d7b1e544399 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Mon, 12 Feb 2024 17:16:47 +0100 Subject: [PATCH] rectpacking: Do node micro layout before and after layout. Previously it was only done after because whitespace elimination might change node sizes. However, if the node size cannot fit the label, we need to do this before the layout too. --- .../elk/alg/rectpacking/RectPackingLayoutProvider.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java index 831b867a0..8f1a2df14 100644 --- a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java +++ b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/RectPackingLayoutProvider.java @@ -58,6 +58,11 @@ public void layout(final ElkNode layoutGraph, final IElkProgressMonitor progress boolean tryBox = layoutGraph.getProperty(RectPackingOptions.TRYBOX); List rectangles = layoutGraph.getChildren(); + // if requested, compute nodes's dimensions, place node labels, ports, port labels, etc. + if (!layoutGraph.getProperty(RectPackingOptions.OMIT_NODE_MICRO_LAYOUT)) { + NodeMicroLayout.forGraph(layoutGraph).execute(); + } + // Check whether regions are stackable and do box layout instead. boolean stackable = false; if (tryBox && rectangles.size() >= 3) { @@ -129,7 +134,7 @@ public void layout(final ElkNode layoutGraph, final IElkProgressMonitor progress layoutGraph.getProperty(InternalProperties.DRAWING_HEIGHT) + padding.getVertical(), false, true); } - // if requested, compute nodes's dimensions, place node labels, ports, port labels, etc. + // Do micro layout again since the whitspace elimination and other things might have changed node sizes. if (!layoutGraph.getProperty(RectPackingOptions.OMIT_NODE_MICRO_LAYOUT)) { NodeMicroLayout.forGraph(layoutGraph).execute(); }