Package org.eclipse.draw2d

# Class FlowLayout

java.lang.Object
org.eclipse.draw2d.AbstractLayout
org.eclipse.draw2d.AbstractHintLayout
org.eclipse.draw2d.OrderedLayout
org.eclipse.draw2d.FlowLayout

All Implemented Interfaces:
  `LayoutManager`

public class FlowLayout extends OrderedLayout
Lays out children in rows or columns, wrapping when the current row/column is filled. The aligment and spacing of rows in the parent can be configured. The aligment and spacing of children within a row can be configured.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected class`
`FlowLayout.WorkingData`
Holds the necessary information for layout calculations.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ALIGN_LEFTTOP`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.ALIGN_TOPLEFT` instead.
`static final int`
`ALIGN_RIGHTBOTTOM`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.ALIGN_BOTTOMRIGHT` instead.
`protected FlowLayout.WorkingData`
`data`
`protected boolean`
`fill`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.setStretchMinorAxis(boolean)` and `OrderedLayout.isStretchMinorAxis()` instead.
`protected int`
`majorAlignment`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMajorAlignment()` and `setMajorAlignment(int)` instead.
`protected int`
`majorSpacing`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMajorSpacing()` and `setMajorSpacing(int)` instead.
`protected int`
`minorSpacing`
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMinorSpacing()` and `setMinorSpacing(int)` instead.

### Fields inherited from class org.eclipse.draw2d.OrderedLayout

`ALIGN_BOTTOMRIGHT, ALIGN_CENTER, ALIGN_TOPLEFT, horizontal, HORIZONTAL, minorAlignment, transposer, VERTICAL`

### Fields inherited from class org.eclipse.draw2d.AbstractLayout

`isObservingVisibility, preferredSize`

## Constructor Summary

Constructors
Constructor
Description
`FlowLayout()`
Constructs a FlowLayout with horizontal orientation.
`FlowLayout(boolean isHorizontal)`
Constructs a FlowLayout whose orientation is given in the input.

## Method Summary

Modifier and Type
Method
Description
`protected Dimension`
`calculatePreferredSize(IFigure container, int wHint, int hHint)`
Calculates the preferred size of the given figure, using width and height hints.
`protected Dimension`
`getChildSize(IFigure child, int wHint, int hHint)`
Provides the given child's preferred size.
`protected int`
`getDefaultOrientation()`
Returns `PositionConstants.HORIZONTAL` by default.
`int`
`getMajorAlignment()`
Returns the alignment used for an entire row/column.
`int`
`getMajorSpacing()`
Returns the spacing in pixels to be used between children in the direction parallel to the layout's orientation.
`int`
`getMinorSpacing()`
Returns the spacing to be used between children within a row/column.
`protected void`
`initRow()`
Initializes the state of row data, which is internal to the layout process.
`protected void`
`initVariables(IFigure parent)`
Initializes state data for laying out children, based on the Figure given as input.
`protected boolean`
`isSensitiveHorizontally(IFigure parent)`
Returns whether this layout manager is sensitive to changes in the horizontal hint.
`protected boolean`
`isSensitiveVertically(IFigure parent)`
Returns whether this layout manager is sensitive to changes in the vertical hint.
`boolean`
`isStretchMinorAxis()`
Overwritten to guarantee backwards compatibility with `fill` field.
`void`
`layout(IFigure parent)`
Lays out the given figure.
`protected void`
`layoutRow(IFigure parent)`
Layouts one row of components.
`protected void`
`setBoundsOfChild(IFigure parent, IFigure child, Rectangle bounds)`
Sets the given bounds for the child figure input.
`void`
`setMajorAlignment(int align)`
Sets the alignment for an entire row/column within the parent figure.
`void`
`setMajorSpacing(int n)`
Sets the spacing in pixels to be used between children in the direction parallel to the layout's orientation.
`void`
`setMinorSpacing(int n)`
Sets the spacing to be used between children within a row/column.
`void`
`setStretchMinorAxis(boolean value)`
Overwritten to guarantee backwards compatibility with `fill` field.

### Methods inherited from class org.eclipse.draw2d.OrderedLayout

`getMinorAlignment, isHorizontal, setHorizontal, setMinorAlignment`

### Methods inherited from class org.eclipse.draw2d.AbstractHintLayout

`calculateMinimumSize, getMinimumSize, getPreferredSize, invalidate`

### Methods inherited from class org.eclipse.draw2d.AbstractLayout

`calculatePreferredSize, getBorderPreferredSize, getConstraint, getMinimumSize, getPreferredSize, invalidate, isObservingVisibility, remove, setConstraint, setObserveVisibility`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### ALIGN_LEFTTOP

@Deprecated(forRemoval=true, since="2025-09") public static final int ALIGN_LEFTTOP
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.ALIGN_TOPLEFT` instead. This field will be removed after the 2027-09 release.
Constant to specify components to be aligned on the left/top

See Also:
  - Constant Field Values

### ALIGN_RIGHTBOTTOM

@Deprecated(forRemoval=true, since="2025-09") public static final int ALIGN_RIGHTBOTTOM
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.ALIGN_BOTTOMRIGHT` instead. This field will be removed after the 2027-09 release.
Constant to specify components to be aligned on the right/bottom

See Also:
  - Constant Field Values

### data

protected FlowLayout.WorkingData data

### fill

@Deprecated(forRemoval=true, since="2025-09") protected boolean fill
Deprecated, for removal: This API element is subject to removal in a future version.
Use `OrderedLayout.setStretchMinorAxis(boolean)` and `OrderedLayout.isStretchMinorAxis()` instead. This field will be made private after the 2027-09 release.
The property that determines whether leftover space at the end of a row/column should be filled by the last item in that row/column.

### majorAlignment

@Deprecated(forRemoval=true, since="2025-09") protected int majorAlignment
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMajorAlignment()` and `setMajorAlignment(int)` instead. This field will be made private after the 2027-09 release.
The alignment along the major axis.

### majorSpacing

@Deprecated(forRemoval=true, since="2025-09") protected int majorSpacing
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMajorSpacing()` and `setMajorSpacing(int)` instead. This field will be made private after the 2027-09 release.
The spacing along the major axis.

### minorSpacing

@Deprecated(forRemoval=true, since="2025-09") protected int minorSpacing
Deprecated, for removal: This API element is subject to removal in a future version.
Use `getMinorSpacing()` and `setMinorSpacing(int)` instead. This field will be made private after the 2027-09 release.
The spacing along the minor axis.

## Constructor Details

### FlowLayout

public FlowLayout()
Constructs a FlowLayout with horizontal orientation.

Since:
  2.0

### FlowLayout

public FlowLayout(boolean isHorizontal)
Constructs a FlowLayout whose orientation is given in the input.

Parameters:
  `isHorizontal` - `true` if the layout should be horizontal
Since:
  2.0

## Method Details

### calculatePreferredSize

protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint)
Description copied from class: `AbstractLayout`
Calculates the preferred size of the given figure, using width and height hints.

Specified by:
  `calculatePreferredSize` in class `AbstractLayout`
Parameters:
  `container` - The figure
  `wHint` - The width hint
  `hHint` - The height hint
Returns:
  The preferred size
See Also:
  - `AbstractLayout.calculatePreferredSize(IFigure, int, int)`

### getChildSize

protected Dimension getChildSize(IFigure child, int wHint, int hHint)
Provides the given child's preferred size.

Parameters:
  `child` - the Figure whose preferred size needs to be calculated
  `wHint` - the width hint
  `hHint` - the height hint
Returns:
  the child's preferred size

### getDefaultOrientation

protected int getDefaultOrientation()
Returns `PositionConstants.HORIZONTAL` by default.

Specified by:
  `getDefaultOrientation` in class `OrderedLayout`
Returns:
  one of `PositionConstants.HORIZONTAL` or `PositionConstants.VERTICAL`
See Also:
  - `OrderedLayout.getDefaultOrientation()`

### getMajorAlignment

public int getMajorAlignment()
Returns the alignment used for an entire row/column.

Possible values are :

- `OrderedLayout.ALIGN_CENTER`
- `ALIGN_LEFTTOP`
- `ALIGN_RIGHTBOTTOM`

Returns:
  the major alignment
Since:
  2.0

### getMajorSpacing

public int getMajorSpacing()
Returns the spacing in pixels to be used between children in the direction parallel to the layout's orientation.

Returns:
  the major spacing

### getMinorSpacing

public int getMinorSpacing()
Returns the spacing to be used between children within a row/column.

Returns:
  the minor spacing

### initRow

protected void initRow()
Initializes the state of row data, which is internal to the layout process.

### initVariables

protected void initVariables(IFigure parent)
Initializes state data for laying out children, based on the Figure given as input.

Parameters:
  `parent` - the parent figure
Since:
  2.0

### isSensitiveHorizontally

protected boolean isSensitiveHorizontally(IFigure parent)
Description copied from class: `AbstractHintLayout`
Returns whether this layout manager is sensitive to changes in the horizontal hint. By default, this method returns `true`.

Overrides:
  `isSensitiveHorizontally` in class `AbstractHintLayout`
Parameters:
  `parent` - the layout's container
Returns:
  `true` if this layout is sensite to horizontal hint changes
See Also:
  - `AbstractHintLayout.isSensitiveHorizontally(IFigure)`

### isSensitiveVertically

protected boolean isSensitiveVertically(IFigure parent)
Description copied from class: `AbstractHintLayout`
Returns whether this layout manager is sensitive to changes in the vertical hint. By default, this method returns `true`.

Overrides:
  `isSensitiveVertically` in class `AbstractHintLayout`
Parameters:
  `parent` - the layout's container
Returns:
  `true` if this layout is sensite to vertical hint changes
See Also:
  - `AbstractHintLayout.isSensitiveVertically(IFigure)`

### isStretchMinorAxis

public boolean isStretchMinorAxis()
Overwritten to guarantee backwards compatibility with `fill` field.

Specified by:
  `isStretchMinorAxis` in class `OrderedLayout`
Returns:
  whether children are to be stretched in the minor axis.
See Also:
  - `OrderedLayout.isStretchMinorAxis()`

### layout

public void layout(IFigure parent)
Description copied from interface: `LayoutManager`
Lays out the given figure.

Parameters:
  `parent` - The figure
See Also:
  - `LayoutManager.layout(IFigure)`

### layoutRow

protected void layoutRow(IFigure parent)
Layouts one row of components. This is done based on the layout's orientation, minor alignment and major alignment.

Parameters:
  `parent` - the parent figure
Since:
  2.0

### setBoundsOfChild

protected void setBoundsOfChild(IFigure parent, IFigure child, Rectangle bounds)
Sets the given bounds for the child figure input.

Parameters:
  `parent` - the parent figure
  `child` - the child figure
  `bounds` - the size of the child to be set
Since:
  2.0

### setMajorAlignment

public void setMajorAlignment(int align)
Sets the alignment for an entire row/column within the parent figure.

Possible values are :

- `OrderedLayout.ALIGN_CENTER`
- `ALIGN_LEFTTOP`
- `ALIGN_RIGHTBOTTOM`

Parameters:
  `align` - the major alignment
Since:
  2.0

### setMajorSpacing

public void setMajorSpacing(int n)
Sets the spacing in pixels to be used between children in the direction parallel to the layout's orientation.

Parameters:
  `n` - the major spacing
Since:
  2.0

### setMinorSpacing

public void setMinorSpacing(int n)
Sets the spacing to be used between children within a row/column.

Parameters:
  `n` - the minor spacing
Since:
  2.0

### setStretchMinorAxis

public void setStretchMinorAxis(boolean value)
Overwritten to guarantee backwards compatibility with `fill` field.

Specified by:
  `setStretchMinorAxis` in class `OrderedLayout`
Parameters:
  `value` - whether children should be stretched in the minor axis.
See Also:
  - `OrderedLayout.setStretchMinorAxis(boolean)`