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
TheTrueHexGridLayout
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
Fields Modifier and Type Field Description (package private) int
cols
(package private) boolean
indentOddRows
private boolean
isometricShape
(package private) int
rows
-
Constructor Summary
Constructors Constructor Description TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow)
TrueHexGridLayout(int pRows, int pColumns, boolean pIndentFirstRow, boolean pIsometricShape)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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)
-
-
-
Method Detail
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)
- Specified by:
addLayoutComponent
in interfacejava.awt.LayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponent
in interfacejava.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 interfacejava.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 interfacejava.awt.LayoutManager
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSize
in interfacejava.awt.LayoutManager
-
main
public static void main(java.lang.String[] args)
-
-