From 66d92bd2251bb7ab8ecb78cd1afa50d62584a762 Mon Sep 17 00:00:00 2001 From: Soeren Domroes Date: Mon, 11 Apr 2022 16:54:41 +0200 Subject: [PATCH] Rectpacking: Fixed bug that padding describes the minimum size. Signed-off-by: Soeren Domroes --- .../elk/alg/rectpacking/RectPackingLayoutProvider.java | 2 +- .../seconditeration/RowFillingAndCompaction.java | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) 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 2ade54311f..939780722e 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 @@ -138,7 +138,7 @@ public void layout(final ElkNode layoutGraph, final IElkProgressMonitor progress maxWidth = Math.max(minSize.x, drawing.getDrawingWidth()); // Run placement, compaction, and expansion (if enabled). - drawing = secondIt.start(rectangles, maxWidth, minSize, progressMonitor, layoutGraph); + drawing = secondIt.start(rectangles, maxWidth, minSize, progressMonitor, layoutGraph, padding); } // Final touch. diff --git a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/seconditeration/RowFillingAndCompaction.java b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/seconditeration/RowFillingAndCompaction.java index b7efc87760..5d013254c4 100644 --- a/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/seconditeration/RowFillingAndCompaction.java +++ b/plugins/org.eclipse.elk.alg.rectpacking/src/org/eclipse/elk/alg/rectpacking/seconditeration/RowFillingAndCompaction.java @@ -16,6 +16,7 @@ import org.eclipse.elk.alg.rectpacking.util.DrawingData; import org.eclipse.elk.alg.rectpacking.util.DrawingDataDescriptor; import org.eclipse.elk.alg.rectpacking.util.RectRow; +import org.eclipse.elk.core.math.ElkPadding; import org.eclipse.elk.core.math.KVector; import org.eclipse.elk.core.util.IElkProgressMonitor; import org.eclipse.elk.graph.ElkNode; @@ -69,7 +70,7 @@ public RowFillingAndCompaction(final double aspectRatio, final boolean expandNod * @return Drawing data for a produced drawing. */ public DrawingData start(final List rectangles, final double maxWidth, final KVector minParentSize, - final IElkProgressMonitor progressMonitor, final ElkNode layoutGraph) { + final IElkProgressMonitor progressMonitor, final ElkNode layoutGraph, final ElkPadding padding) { // Initial placement for rectangles in blocks in each row. List rows = InitialPlacement.place(rectangles, maxWidth, nodeNodeSpacing); @@ -107,8 +108,8 @@ public DrawingData start(final List rectangles, final double maxWidth, progressMonitor.logGraph(layoutGraph, "After compaction"); } - double totalWidth = Math.max(this.drawingWidth, minParentSize.x); - double minHeight = Math.max(this.drawingHeight, minParentSize.y); + double totalWidth = Math.max(this.drawingWidth, minParentSize.x - padding.getHorizontal()); + double minHeight = Math.max(this.drawingHeight, minParentSize.y - padding.getVertical()); double additionalHeight = minHeight - this.drawingHeight; if (expandNodes && expandToAspectRatio) { double aspectRatio = totalWidth / minHeight;