public class TrueHexGridLayout
extends java.lang.Object
implements java.awt.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.
Modifier and Type | Field and Description |
---|---|
(package private) int |
cols |
(package private) boolean |
indentOddRows |
private boolean |
isometricShape |
(package private) int |
rows |
Constructor and Description |
---|
TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow) |
TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow,
boolean pIsometricShape) |
Modifier and Type | Method and Description |
---|---|
void |
addLayoutComponent(java.lang.String name,
java.awt.Component comp) |
void |
layoutContainer(java.awt.Container parent)
Lays out the specified container using this layout.
|
static void |
main(java.lang.String[] args) |
java.awt.Dimension |
minimumLayoutSize(java.awt.Container parent) |
java.awt.Dimension |
preferredLayoutSize(java.awt.Container parent) |
void |
removeLayoutComponent(java.awt.Component comp) |
int rows
int cols
boolean indentOddRows
private final boolean isometricShape
public TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow, boolean pIsometricShape)
public TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow)
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
addLayoutComponent
in interface java.awt.LayoutManager
public void removeLayoutComponent(java.awt.Component comp)
removeLayoutComponent
in interface java.awt.LayoutManager
public void layoutContainer(java.awt.Container parent)
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.
layoutContainer
in interface java.awt.LayoutManager
parent
- the container in which to do the layoutContainer
,
Container.doLayout()
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
minimumLayoutSize
in interface java.awt.LayoutManager
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
preferredLayoutSize
in interface java.awt.LayoutManager
public static void main(java.lang.String[] args)