Class GridLayout
java.lang.Object
xyz.gmitch215.socketmc.screen.layout.AbstractLayout
xyz.gmitch215.socketmc.screen.layout.GridLayout
- All Implemented Interfaces:
Serializable
,Layout
,LayoutElement
Represents a layout with elements in a grid format. The Grid Layout starts with a size of 0, and is expanded as elements are added.
- See Also:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic final class
A Child Container inside of a GridLayout.final class
Utility class for adding elements in rows.Nested classes/interfaces inherited from class xyz.gmitch215.socketmc.screen.layout.AbstractLayout
AbstractLayout.AbstractChildContainer
-
Field Summary
Fields inherited from class xyz.gmitch215.socketmc.screen.layout.AbstractLayout
height, width, x, y
-
Constructor Summary
ConstructorDescriptionCreates a new GridLayout at the origin.GridLayout
(int x, int y) Creates a new GridLayout with the specified position. -
Method Summary
Modifier and TypeMethodDescription<T extends LayoutElement>
TaddCell
(T element, int row, int column) Adds a cell to the GridLayout using the default layout settings.<T extends LayoutElement>
TaddCell
(T element, int row, int column, int occupiedRows, int occupiedColumns) Adds a cell to the GridLayout using the default layout settings.<T extends LayoutElement>
TaddCell
(T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull Consumer<LayoutSettings> settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddCell
(T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull Supplier<LayoutSettings> settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddCell
(T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull LayoutSettings settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddCell
(T element, int row, int column, @NotNull Consumer<LayoutSettings> settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddCell
(T element, int row, int column, @NotNull Supplier<LayoutSettings> settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddCell
(T element, int row, int column, @NotNull LayoutSettings settings) Adds a cell to the GridLayout.<T extends LayoutElement>
TaddElement
(T element, @NotNull LayoutSettings settings) Deprecated.void
Arranges the elements inside this Layout.Generates the default layout settings for this layout.getCells()
Gets an immutable copy of the cells in the GridLayout.Gets an immutable copy of the children in the GridLayout.int
Gets the column spacing between cells.int
Gets the row spacing between cells.newRow()
Creates a new RowHelper with one column.newRow
(int columns) Creates a new RowHelper with the specified number of columns.setColumnSpacing
(int columnSpacing) Sets the column spacing between cells.setRowSpacing
(int rowSpacing) Sets the row spacing between cells.setSpacing
(int spacing) Sets the row and column spacing between cells.setSpacing
(int row, int column) Sets the row and column spacing between cells.void
visitChildren
(@NotNull Consumer<LayoutElement> visitor) Visits this layout and all of its children.Methods inherited from class xyz.gmitch215.socketmc.screen.layout.AbstractLayout
getHeight, getWidth, getX, getY, isFullscreen, setFullscreen, setHeight, setWidth, setX, setY
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface xyz.gmitch215.socketmc.screen.layout.Layout
addElement, addElement, addElement, visitWidgets
Methods inherited from interface xyz.gmitch215.socketmc.screen.layout.LayoutElement
setPosition, setSize, setSize, setSize
-
Constructor Details
-
GridLayout
public GridLayout()Creates a new GridLayout at the origin. -
GridLayout
public GridLayout(int x, int y) Creates a new GridLayout with the specified position.- Parameters:
x
- The X positiony
- The Y position
-
-
Method Details
-
getChildren
Gets an immutable copy of the children in the GridLayout.- Returns:
- GridLayout Children
-
getCells
Gets an immutable copy of the cells in the GridLayout.- Returns:
- GridLayout Cells
-
getRowSpacing
public int getRowSpacing()Gets the row spacing between cells.- Returns:
- Row Spacing
-
setRowSpacing
Sets the row spacing between cells.- Parameters:
rowSpacing
- Row Spacing- Returns:
- this class, for chaining
-
getColumnSpacing
public int getColumnSpacing()Gets the column spacing between cells.- Returns:
- Column Spacing
-
setColumnSpacing
Sets the column spacing between cells.- Parameters:
columnSpacing
- Column Spacing- Returns:
- this class, for chaining
-
setSpacing
Sets the row and column spacing between cells.- Parameters:
spacing
- The spacing- Returns:
- this class, for chaining
-
setSpacing
Sets the row and column spacing between cells.- Parameters:
row
- The row spacingcolumn
- The column spacing- Returns:
- this class, for chaining
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column) throws IllegalArgumentException Adds a cell to the GridLayout using the default layout settings.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the cell- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null or the row/column coordinates are negative
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, int occupiedRows, int occupiedColumns) throws IllegalArgumentException Adds a cell to the GridLayout using the default layout settings.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the celloccupiedRows
- The number of rows the cell occupiesoccupiedColumns
- The number of columns the cell occupies- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null, the row/column coordinates are negative, or the occupied size is less than 1
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, @NotNull @NotNull LayoutSettings settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the cellsettings
- The layout settings for the cell- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null or the row/column coordinates are negative
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull @NotNull LayoutSettings settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the celloccupiedRows
- The number of rows the cell occupiesoccupiedColumns
- The number of columns the cell occupiessettings
- The layout settings for the cell- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null, the row/column coordinates are negative, or the occupied size is less than 1
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, @NotNull @NotNull Supplier<LayoutSettings> settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the cellsettings
- The generator for the cell settings- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null or the row/column coordinates are negative
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull @NotNull Supplier<LayoutSettings> settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the celloccupiedRows
- The number of rows the cell occupiesoccupiedColumns
- The number of columns the cell occupiessettings
- The generator for the cell settings- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null, the row/column coordinates are negative, or the occupied size is less than 1
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, @NotNull @NotNull Consumer<LayoutSettings> settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the cellsettings
- The function to apply tocreateDefaultSettings()
- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null or the row/column coordinates are negative
-
addCell
@NotNull public <T extends LayoutElement> T addCell(@NotNull T element, int row, int column, int occupiedRows, int occupiedColumns, @NotNull @NotNull Consumer<LayoutSettings> settings) throws IllegalArgumentException Adds a cell to the GridLayout.- Type Parameters:
T
- The type of the element- Parameters:
element
- The element to addrow
- The row of the cellcolumn
- The column of the celloccupiedRows
- The number of rows the cell occupiesoccupiedColumns
- The number of columns the cell occupiessettings
- The function to apply tocreateDefaultSettings()
- Returns:
- The element that was added
- Throws:
IllegalArgumentException
- if the element or size is null, the row/column coordinates are negative, or the occupied size is less than 1
-
createDefaultSettings
Description copied from interface:Layout
Generates the default layout settings for this layout.- Returns:
- Default Layout Settings
-
visitChildren
Description copied from interface:Layout
Visits this layout and all of its children.- Parameters:
visitor
- Element Visitor
-
arrangeElements
public void arrangeElements()Description copied from interface:Layout
Arranges the elements inside this Layout. -
addElement
@Deprecated public <T extends LayoutElement> T addElement(@NotNull T element, @NotNull @NotNull LayoutSettings settings) throws IllegalArgumentException Deprecated.Description copied from interface:Layout
Adds an element to this layout.- Type Parameters:
T
- the type of the element- Parameters:
element
- the element to addsettings
- the settings for the element- Returns:
- the added element
- Throws:
IllegalArgumentException
- if the element or settings are null
-
newRow
Creates a new RowHelper with one column.- Returns:
- RowHelper
-
newRow
Creates a new RowHelper with the specified number of columns.- Parameters:
columns
- The number of columns- Returns:
- RowHelper
-
addCell(LayoutElement, int, int, int, int, LayoutSettings)
instead