Skip to content

Commit

Permalink
Rectpacking: Fixed bug that padding describes the minimum size.
Browse files Browse the repository at this point in the history
Signed-off-by: Soeren Domroes <sdo@informatik.uni-kiel.de>
  • Loading branch information
soerendomroes committed Apr 11, 2022
1 parent 2bb24cf commit 66d92bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,7 +70,7 @@ public RowFillingAndCompaction(final double aspectRatio, final boolean expandNod
* @return Drawing data for a produced drawing.
*/
public DrawingData start(final List<ElkNode> 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<RectRow> rows = InitialPlacement.place(rectangles, maxWidth, nodeNodeSpacing);

Expand Down Expand Up @@ -107,8 +108,8 @@ public DrawingData start(final List<ElkNode> 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;
Expand Down

0 comments on commit 66d92bd

Please sign in to comment.