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.LayoutManagerTheTrueHexGridLayoutclass 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
ComponentOrientationproperty 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) intcols(package private) booleanindentOddRowsprivate booleanisometricShape(package private) introws
-
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 voidaddLayoutComponent(java.lang.String name, java.awt.Component comp)voidlayoutContainer(java.awt.Container parent)Lays out the specified container using this layout.static voidmain(java.lang.String[] args)java.awt.DimensionminimumLayoutSize(java.awt.Container parent)java.awt.DimensionpreferredLayoutSize(java.awt.Container parent)voidremoveLayoutComponent(java.awt.Component comp)
-
-
-
Method Detail
-
addLayoutComponent
public void addLayoutComponent(java.lang.String name, java.awt.Component comp)- Specified by:
addLayoutComponentin interfacejava.awt.LayoutManager
-
removeLayoutComponent
public void removeLayoutComponent(java.awt.Component comp)
- Specified by:
removeLayoutComponentin 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
BattleHexGridLayoutobject.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:
layoutContainerin 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:
minimumLayoutSizein interfacejava.awt.LayoutManager
-
preferredLayoutSize
public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
- Specified by:
preferredLayoutSizein interfacejava.awt.LayoutManager
-
main
public static void main(java.lang.String[] args)
-
-