Enum Class UniformGridLayout.OverflowGrowth

java.lang.Object
java.lang.Enum<UniformGridLayout.OverflowGrowth>
swingtree.layout.UniformGridLayout.OverflowGrowth
All Implemented Interfaces:
Serializable, Comparable<UniformGridLayout.OverflowGrowth>, Constable
Enclosing class:
UniformGridLayout

public static enum UniformGridLayout.OverflowGrowth extends Enum<UniformGridLayout.OverflowGrowth>
Decides how the grid of a UniformGridLayout grows when a container holds more components than the declared number of rows times the declared number of columns, so that every component still gets a cell of its own.

A grid can overflow whenever its declared number of rows and its declared number of columns are both greater than 0, in either UniformGridLayout.Mode: both modes then have a fixed number of cells to run out of. A number of rows or columns of 0 means "as many as the components need", which leaves that axis free to grow on its own, so such a grid never overflows and this setting never changes it.

The UniformGridLayout.Mode shapes the grid up to that point and this setting shapes it from there on, so two grids which differ only in their mode are laid out alike once both have overflowed. This is how a grid declared with 2 rows and 5 columns, which has 10 cells, grows for 13 components, as rows × columns: ADD_ROWS 3 × 5, ADD_COLUMNS 2 × 7 and ADD_ROWS_AND_COLUMNS 3 × 6. The grid grows before the UniformGridLayout.CollapseEmpty setting leaves out the rows and columns which no component occupies.

See Also:
  • Enum Constant Details

    • ADD_ROWS

      public static final UniformGridLayout.OverflowGrowth ADD_ROWS
      Rows are added at the bottom until every component has a cell, and the grid keeps its declared number of columns. A grid of 2 rows and 5 columns lays out 13 components in 3 rows of 5 columns, and 30 components in 6 rows of 5 columns. This is the default.

      In the mode UniformGridLayout.Mode.WRAP_AFTER_COLUMNS, this is the only setting under which the component at index i stays in row i / columns and column i % columns however many components there are, so it is the only one under which adding a component never moves one of the components before it into another row or column.

    • ADD_COLUMNS

      public static final UniformGridLayout.OverflowGrowth ADD_COLUMNS
      Columns are added at the right until every component has a cell, and the grid keeps its declared number of rows. A grid of 2 rows and 5 columns lays out 13 components in 2 rows of 7 columns, and 30 components in 2 rows of 15 columns.

      This is the one policy which keeps making room the way a GridLayout makes room, so it is the growth policy the mode UniformGridLayout.Mode.SPREAD_OVER_ROWS needs, alongside UniformGridLayout.CollapseEmpty.NONE, to lay out components exactly like one. The mode still decides the grid below the declared number of cells: with UniformGridLayout.Mode.WRAP_AFTER_COLUMNS a grid of 2 rows and 5 columns lays out 3 components in 5 columns, and with UniformGridLayout.Mode.SPREAD_OVER_ROWS it lays them out in 2.

    • ADD_ROWS_AND_COLUMNS

      public static final UniformGridLayout.OverflowGrowth ADD_ROWS_AND_COLUMNS
      Rows and columns are added one at a time, each time the one which keeps the ratio of rows to columns closest to the declared ratio, until every component has a cell. The grid therefore keeps its shape as closely as whole rows and columns allow, and so do its cells: the container does not change size while the grid grows, so a cell of a grid of r rows and c columns is width / c by height / r large, and holding r / c at the declared ratio holds the shape of every cell as well.

      A grid of 2 rows and 5 columns lays out 13 components in 3 rows of 6 columns, and 30 components in 4 rows of 9 columns. When the declared numbers scale up evenly, the ratio is kept exactly and no cell is left over: a grid of 1 row and 4 columns lays out 400 components, 100 times its 4 cells, in exactly 10 rows of 40 columns.

      Growing both numbers can leave more empty cells behind than ADD_ROWS or ADD_COLUMNS do, because the last row of the grid is the one which absorbs the difference: 13 components in 3 rows of 6 columns leave 5 cells of the last row empty.

  • Method Details

    • values

      public static UniformGridLayout.OverflowGrowth[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static UniformGridLayout.OverflowGrowth valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null