net.xoetrope.optional.layout
Class ColumnLayout

java.lang.Object
  extended by net.xoetrope.optional.layout.ColumnLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public class ColumnLayout
extends java.lang.Object
implements java.awt.LayoutManager2

A layout manager for forms. Components flow along rows till a break element is encountered abd then they flow to the next row along the page length

Copyright (c) Xoetrope Ltd., 2002-2006

$Revision: 1.2 $

License: see License.txt


Constructor Summary
ColumnLayout(int cols, int padding)
          Creates a layout manager that will lay out components along the y axis.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.
 void addRowSpacer()
          Fill the next slot with a spacer, or advance a column before adding the next component
 void addSpacer()
          Fill the next slot with a spacer, or advance a column before adding the next component
 void addSpacer(int numSpacers)
          Fill the next N slots with a spacer, or advance a column before adding the next component
 void endRow()
          End the row, so that the next component begins on the left
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Calculates the maximum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified container, given the components it contains.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified container, given the components it contains.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setIndentX(int x)
          Set the X indent
 void setIndentY(int y)
          Set the Y indent
 void setMaxRowWidth(double maxWidth)
          Set the maximum row width, or the amount of horizontal space that the layout consumes
 void setMaxRowWidth(java.lang.String s)
          Set the maximum row width, or the amount of horizontal space that the layout consumes
 void setNumCols(int cols)
          Set the number of columns
 void setNumCols(java.lang.String s)
          Set the number of columns
 void setPadding(int pad)
          Set the padding amount
 void setPadding(java.lang.String s)
          Set the padding amount
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColumnLayout

public ColumnLayout(int cols,
                    int padding)
Creates a layout manager that will lay out components along the y axis.

Parameters:
target - the container that needs to be laid out
Method Detail

setMaxRowWidth

public void setMaxRowWidth(double maxWidth)
Set the maximum row width, or the amount of horizontal space that the layout consumes

Parameters:
maxWidth - the maximum width in pixels or as a percentage if less than 1.0

setMaxRowWidth

public void setMaxRowWidth(java.lang.String s)
Set the maximum row width, or the amount of horizontal space that the layout consumes

Parameters:
s - a string representing the double value for the maximum width

setPadding

public void setPadding(java.lang.String s)
Set the padding amount

Parameters:
s - the amount of padding

setPadding

public void setPadding(int pad)
Set the padding amount

Parameters:
pad - the amount of padding

setNumCols

public void setNumCols(java.lang.String s)
Set the number of columns

Parameters:
s - the amount of padding

setNumCols

public void setNumCols(int cols)
Set the number of columns

Parameters:
pad - the amount of padding

setIndentX

public void setIndentX(int x)
Set the X indent

Parameters:
x - the indent for the left hand side in pixels

setIndentY

public void setIndentY(int y)
Set the Y indent

Parameters:
y - the indent for the top edge in pixels

endRow

public void endRow()
End the row, so that the next component begins on the left


addRowSpacer

public void addRowSpacer()
Fill the next slot with a spacer, or advance a column before adding the next component


addSpacer

public void addSpacer()
Fill the next slot with a spacer, or advance a column before adding the next component


addSpacer

public void addSpacer(int numSpacers)
Fill the next N slots with a spacer, or advance a column before adding the next component

Parameters:
numSpacers - the number of spacers to add

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Calculates the maximum size dimensions for the specified container, given the components it contains.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
See Also:
Component.getMaximumSize(), LayoutManager

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
If the layout manager uses a per-component string, adds the component comp to the layout, associating it with the string specified by name.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the string to be associated with the component
comp - the component to be added

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to be removed

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified container, given the components it contains.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the container to be laid out
See Also:
minimumLayoutSize(java.awt.Container)

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified container, given the components it contains.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the component to be laid out
See Also:
preferredLayoutSize(java.awt.Container)

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the container to be laid out