com.objectwave.viewUtility
Class FlexGridLayout

java.lang.Object
  |
  +--com.objectwave.viewUtility.FlexGridLayout
All Implemented Interfaces:
java.awt.LayoutManager

public class FlexGridLayout
extends java.lang.Object
implements java.awt.LayoutManager

This is a new layout manager which targets the problem of laying out columns of components. This is currently accomplished by using a GridBagLayout, which is cumbersome to use if the components are to be laid out in a similar fashion on a per-column basis. The FlexGridLayout manager uses an array of column constraints (FlexGridColumn) to determine both how many columns there are and how each component is to presented in each of them. See the main() method of FlexGridLayout for a simple example.


Constructor Summary
FlexGridLayout()
          Empty constructor for FlexGridLayout.
FlexGridLayout(FlexGridColumn[] columns)
          Constructor for FlexGridLayout which defines the column constraints.
FlexGridLayout(int numColumns)
          This constructor will initialize numColumns column constraints, using FlexGridColumn's default values.
 
Method Summary
 void addColumn(FlexGridColumn column)
          Add a column constraint to the layout manager.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Add a componenth to the layout.
protected  java.awt.Rectangle adjustPosition(java.awt.Component component, FlexGridColumn columnLayout, int x, int y, int width, int height)
          Determine the bounds of "component" within a given cell (x,y,width,height) using it's current bounds and "columnLayout".
 FlexGridColumn getColumn(int index)
          Access the index'th column's constraints.
 FlexGridColumn[] getColumns()
          Return a reference to the column constraints.
protected  java.awt.Component[] getComponents()
          Get the components.
 DebugOutput getDebug()
          Get the debuggin out put object.
 int getXgap()
          Get the inter-column spacing value.
 int getYgap()
          Get the vertical spacing between components.
 void layoutContainer(java.awt.Container parent)
          Layout the given parent's components according to the array of column constraints.
static void main(java.lang.String[] args)
          Test method.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          get the minimumLayoutSize
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          get the preferredLayoutSize
 void removeLayoutComponent(java.awt.Component comp)
          Remove a layout component.
 void setColumnAt(FlexGridColumn column, int index)
          Replace the index'th column with "column".
protected  void setColumns(FlexGridColumn[] newValue)
          Set the columns array.
 void setComponents(java.awt.Component[] array)
          Set the components array.
protected  void setDebug(DebugOutput newValue)
          Set the debugging object.
 void setMinimumLayoutSize(java.awt.Dimension newValue)
          Set the minimum layout size.
 void setNumberOfColumns(int num)
          Set the number of columns, creating default-value columns if "num" is greater that the old number of columns.
 void setPreferredLayoutSize(java.awt.Dimension newValue)
          Set the prederred layout size
 void setXgap(int newValue)
          Set the intercolumn spacing value.
 void setYgap(int newValue)
          Set the vertical spacing between components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlexGridLayout

public FlexGridLayout()
Empty constructor for FlexGridLayout. No columns are defined.


FlexGridLayout

public FlexGridLayout(FlexGridColumn[] columns)
Constructor for FlexGridLayout which defines the column constraints.

Parameters:
columns - com.objectwave.viewUtility.FlexGridColumn[]

FlexGridLayout

public FlexGridLayout(int numColumns)
This constructor will initialize numColumns column constraints, using FlexGridColumn's default values.

Parameters:
numColumns - int
Method Detail

addColumn

public void addColumn(FlexGridColumn column)
Add a column constraint to the layout manager. Please note that this method is not all that efficient. A better approach would be to build the array of FlexGridColumns and then call addColumns().

Parameters:
column - com.objectwave.viewUtility.FlexGridColumn

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Add a componenth to the layout. This method is part of the LayoutManager interface, but is never called by the framework.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager

adjustPosition

protected java.awt.Rectangle adjustPosition(java.awt.Component component,
                                            FlexGridColumn columnLayout,
                                            int x,
                                            int y,
                                            int width,
                                            int height)
Determine the bounds of "component" within a given cell (x,y,width,height) using it's current bounds and "columnLayout".

Parameters:
component - java.awt.Component
columnLayout - com.objectwave.viewUtility.FlexGridColumn
x - int
y - int
width - int
height - int

getColumn

public FlexGridColumn getColumn(int index)
Access the index'th column's constraints. index is from 0 ... #columns

Parameters:
index - int
Returns:
com.objectwave.viewUtility.FlexGridColumn

getColumns

public FlexGridColumn[] getColumns()
Return a reference to the column constraints.

Returns:
FlexGridColumn[]

getComponents

protected java.awt.Component[] getComponents()
Get the components.

Returns:
java.awt.Component[]

getDebug

public DebugOutput getDebug()
Get the debuggin out put object.

Returns:
com.objectwave.utility.DebugOutput

getXgap

public int getXgap()
Get the inter-column spacing value.

Returns:
int

getYgap

public int getYgap()
Get the vertical spacing between components.

Returns:
int

layoutContainer

public void layoutContainer(java.awt.Container parent)
Layout the given parent's components according to the array of column constraints.

Specified by:
layoutContainer in interface java.awt.LayoutManager

main

public static void main(java.lang.String[] args)
Test method.

Parameters:
args - java.lang.String[]

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
get the minimumLayoutSize

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
get the preferredLayoutSize

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove a layout component. This method is required by the LayoutManager interface, but is never called by the framework.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager

setColumnAt

public void setColumnAt(FlexGridColumn column,
                        int index)
Replace the index'th column with "column".

Parameters:
column - com.objectwave.viewUtility.FlexGridColumn
index - int

setColumns

protected void setColumns(FlexGridColumn[] newValue)
Set the columns array.

Parameters:
newValue - FlexGridColumn[]

setComponents

public void setComponents(java.awt.Component[] array)
Set the components array.

Parameters:
array - java.awt.Component[]

setDebug

protected void setDebug(DebugOutput newValue)
Set the debugging object.

Parameters:
newValue - com.objectwave.utility.DebugOutput

setMinimumLayoutSize

public void setMinimumLayoutSize(java.awt.Dimension newValue)
Set the minimum layout size.

Parameters:
newValue - java.awt.Dimension

setNumberOfColumns

public void setNumberOfColumns(int num)
Set the number of columns, creating default-value columns if "num" is greater that the old number of columns.

Parameters:
num - int

setPreferredLayoutSize

public void setPreferredLayoutSize(java.awt.Dimension newValue)
Set the prederred layout size

Parameters:
newValue - java.awt.Dimension

setXgap

public void setXgap(int newValue)
Set the intercolumn spacing value.

Parameters:
newValue - int

setYgap

public void setYgap(int newValue)
Set the vertical spacing between components.

Parameters:
newValue - int