Rectangle Packing

Property Value
Identifier: org.eclipse.elk.rectpacking.rectPacking
Meta Data Provider: options.RectPackingMetaDataProvider

Description

Algorithm for packing of unconnected boxes, i.e. graphs without edges. The given order of the boxes is always preserved and the main reading direction of the boxes is left to right. The algorithm is divided into two phases. One phase approximates the width in which the rectangles can be placed. The next phase places the rectangles in rows using the previously calculated width as bounding width and bundles rectangles with a similar height in blocks. A compaction step reduces the size of the drawing. Finally, the rectangles are expanded to fill their bounding box and eliminate empty unused spaces.

Additional Documentation

The different phases of the algorithm are illustrated below on an example:

First the drawing width is approximated. Such a drawing can look like this:

Preview Image

After this the initial drawing is created:

Preview Image

This drawing is then compacted to use less space:

Preview Image

Now the nodes can be either expanded to fill the bounding box:

Preview Image

Or, the nodes can be expanded to fit the aspect ratio.

Preview Image

Supported Options

Option Default Value
Aspect Ratio 1.3
Compact Rows true
Current position of a node in the order of nodes -1
Desired index of node -1
Expand Nodes false
Fit Aspect Ratio false
Interactive false
interactive Layout false
Node Spacing 15
Only Area Approximation false
Optimization Goal OptimizationGoal.MAX_SCALE_DRIVEN
Padding new ElkPadding(15)
Shift Last Placed. true