Class TrueHexGridLayout
- All Implemented Interfaces:
LayoutManager
TrueHexGridLayout
class is a layout manager that
lays out a container's components in a grid with alternate rows
offset by a partial grid component. The vertical gap is automatically
sized so that the Hex components can draw the non base-rectangle portions
of the hexes in the gap. This results in a hexagonal tesselation.
When constructed, the layout can start with an indented row or not.
The sizing can be done Isometrically or not.
TODO: implement the containers ComponentOrientation
property
If either the Number of Rows or the Number of Columns is set to Zero either
by constructor or the set rows or set columns method, then the grid will be
assumed to be square and layed out as such. This class is used for battle
Hexes.
- Author:
- Edward Dranathi based loosely on Sun's GridLayout class.
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) int
(package private) boolean
private final boolean
(package private) int
-
Constructor Summary
ConstructorsConstructorDescriptionTrueHexGridLayout
(int pRows, int pColumns, boolean pIndentFirstRow) TrueHexGridLayout
(int pRows, int pColumns, boolean pIndentFirstRow, boolean pIsometricShape) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLayoutComponent
(String name, Component comp) void
layoutContainer
(Container parent) Lays out the specified container using this layout.static void
minimumLayoutSize
(Container parent) preferredLayoutSize
(Container parent) void
-
Field Details
-
rows
int rows -
cols
int cols -
indentOddRows
boolean indentOddRows -
isometricShape
private final boolean isometricShape
-
-
Constructor Details
-
TrueHexGridLayout
public TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow, boolean pIsometricShape) -
TrueHexGridLayout
public TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow)
-
-
Method Details
-
addLayoutComponent
- Specified by:
addLayoutComponent
in interfaceLayoutManager
-
removeLayoutComponent
- Specified by:
removeLayoutComponent
in interfaceLayoutManager
-
layoutContainer
Lays out the specified container using this layout.This method resizes the components in the specified target container in order to satisfy the constraints of the
BattleHexGridLayout
object.This layout manager determines the size of individual components by dividing the free space in the container into equal-sized portions according to the number of rows and columns in the layout. The container's free space equals the container's size minus any insets and vertical gap needed. All components in the layout are given the same size.
- Specified by:
layoutContainer
in interfaceLayoutManager
- Parameters:
parent
- the container in which to do the layout- See Also:
-
minimumLayoutSize
- Specified by:
minimumLayoutSize
in interfaceLayoutManager
-
preferredLayoutSize
- Specified by:
preferredLayoutSize
in interfaceLayoutManager
-
main
-