Enum Class UniformGridLayout.Mode
- All Implemented Interfaces:
Serializable,Comparable<UniformGridLayout.Mode>,Constable
- Enclosing class:
UniformGridLayout
UniformGridLayout is built from the declared number of
rows, the declared number of columns and the number of components in the container.
In both modes, the grid is filled row by row, and a number of rows or columns of 0 means
"as many as the components need". The mode only shapes a grid which still has a cell for
every component; once there are more components than the declared numbers multiply to, the
UniformGridLayout.OverflowGrowth setting decides the shape instead. The UniformGridLayout.CollapseEmpty setting
then decides which of the rows and columns that no component occupies are left out.
This is how each mode builds a grid declared with 2 rows and 5 columns, as rows × columns, before any empty rows or columns are left out:
- 3 components:
WRAP_AFTER_COLUMNS2 × 5,SPREAD_OVER_ROWS2 × 2 - 8 components:
WRAP_AFTER_COLUMNS2 × 5,SPREAD_OVER_ROWS2 × 4 - 11 components: both modes 3 × 5, because 11 components overflow the declared 10
cells and the default
UniformGridLayout.OverflowGrowth.ADD_ROWStakes the decision
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe components are spread over the declared number of rows in as many columns as they need, so the declared number of columns does not shape the grid.A new row starts after every declared number of columns, so the grid has the declared number of columns and at least the declared number of rows. -
Method Summary
Modifier and TypeMethodDescriptionstatic UniformGridLayout.ModeReturns the enum constant of this class with the specified name.static UniformGridLayout.Mode[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
WRAP_AFTER_COLUMNS
A new row starts after every declared number of columns, so the grid has the declared number of columns and at least the declared number of rows. When there are more components than cells, theUniformGridLayout.OverflowGrowthsetting decides whether the grid grows by rows, by columns or by both. This is the default mode.A grid of 2 rows and 5 columns builds 2 rows of 5 columns for 8 components, and, with the default
UniformGridLayout.OverflowGrowth.ADD_ROWS, 3 rows of 5 columns for 11 components. While the grid keeps its declared number of columns, the component at indexiis always in rowi / columnsand columni % columns, so adding a component never moves one of the components before it into another row or column.If the declared number of columns is 0, the grid gets as many columns as it takes to fit the components into the declared number of rows, and can never overflow.
-
SPREAD_OVER_ROWS
The components are spread over the declared number of rows in as many columns as they need, so the declared number of columns does not shape the grid. It still counts the cells: once there are more components than the declared rows times the declared columns, theUniformGridLayout.OverflowGrowthsetting decides whether the grid makes room by rows, by columns or by both, exactly as it does inWRAP_AFTER_COLUMNS.A grid of 2 rows and 5 columns builds 2 columns for 3 components and 4 columns for 8 components. Its 11th component overflows the declared 10 cells, and from there the growth policy answers: 6 columns under
UniformGridLayout.OverflowGrowth.ADD_COLUMNS, a third row under the defaultUniformGridLayout.OverflowGrowth.ADD_ROWS. A grid of 0 rows builds its declared number of columns, and as many rows as its components need.UniformGridLayout.OverflowGrowth.ADD_COLUMNSis the policy which keeps widening the grid the way theGridLayoutof the JDK does, so aUniformGridLayoutin this mode, withUniformGridLayout.CollapseEmpty.NONEand that growth policy, can replace aGridLayoutwithout changing where any component ends up.
-
-
Method Details
-
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
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 nameNullPointerException- if the argument is null
-