net.sf.colossus.gui
Class TrueHexGridLayout
java.lang.Object
net.sf.colossus.gui.TrueHexGridLayout
- All Implemented Interfaces:
- java.awt.LayoutManager
public class TrueHexGridLayout
- extends java.lang.Object
- implements java.awt.LayoutManager
The 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.
Constructor Summary |
TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow)
|
TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow,
boolean pIsometricShape)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
rows
int rows
cols
int cols
indentOddRows
boolean indentOddRows
isometricShape
private final boolean isometricShape
TrueHexGridLayout
public TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow,
boolean pIsometricShape)
TrueHexGridLayout
public TrueHexGridLayout(int pRows,
int pColumns,
boolean pIndentFirstRow)
addLayoutComponent
public void addLayoutComponent(java.lang.String name,
java.awt.Component comp)
- Specified by:
addLayoutComponent
in interface java.awt.LayoutManager
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponent
in interface java.awt.LayoutManager
layoutContainer
public void layoutContainer(java.awt.Container parent)
- 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 interface java.awt.LayoutManager
- Parameters:
parent
- the container in which to do the layout- See Also:
Container
,
Container.doLayout()
minimumLayoutSize
public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
- Specified by:
minimumLayoutSize
in interface java.awt.LayoutManager
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSize
in interface java.awt.LayoutManager
main
public static void main(java.lang.String[] args)