org.PingOO.DLAI.lib.PWidget
Class FormLayout

java.lang.Object
  |
  +--org.PingOO.DLAI.lib.PWidget.FormLayout

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

A layout manager modeled after the HTML <TABLE> tag.
Components are added to a specified row and column, and can span multiple rows.
Column widths are calculated in layoutComponents(), and adjustments for compacting forms can be made with mode parameters.

Basic Design:
Separate interleaved objects called FormRowLayout and FormColumnLayout manage the horizontal and vertical layout settings, respectively.
The objects do not speak to each other.
RowLeader and ColumnLeader sit here in FormLayout and have access to all Rows and all Columns, respectively ; they are responsible for coordinating addition of new Rows and Columns, which are organized as linked lists.
A floating point scheme is used to deal with extra space.
See the HTML documentation for details about the interface and behavior.

Since:
PingOO 2.0
Version:
2.0
Author:
Byron Hawkins (bhawkins@oz.net), Fabrice Bouyé (bouye@cur-archamps.fr)

Inner Class Summary
private  class FormLayout.ColumnLeader
          oversees and coordinates FormColumnLayout`s
protected static class FormLayout.ExtendedVector
           
private  class FormLayout.RowLeader
          Oversees and coordinates FormRowLayouts.
 
Field Summary
static int DEFAULT
          Specifies default alignment for the associated component (used in the FormLayout.add() methods).
static int FREE_FIELD
          Special alignment: the associated field will not align with other fields in this column (used in certain FormLayout.add() methods).
static int FREE_LABEL
          Special alignment: the associated label will not align with other labels in this column (used in certain FormLayout.add() methods).
static int LABEL_ON_TOP
          Special alignment: the label and field will appear in subsequent columns, starting with the one specified (used in certain FormLayout.add() methods).
private  FormLayout.ColumnLeader m_ColumnLeader
           
private  FormLayout.ExtendedVector m_Columns
           
private  java.awt.Container m_container
           
private  int m_externalHGap
           
private  int m_externalVGap
           
private  int m_hgap
           
private  double m_pct
           
private  FormLayout.RowLeader m_RowLeader
           
private  int m_vgap
           
 
Constructor Summary
FormLayout()
          Creates a new layout.
FormLayout(int internalHGap, int internalVGap, int externalHGap, int externalVGap)
          Creates a layout with most specific gap access available.
 
Method Summary
 void add(java.awt.Component label, java.awt.Component field, int row, int column)
          Adds label and field with alignment respective to the other labels and fields in column.
 void add(java.awt.Component label, java.awt.Component field, int row, int column, double fillRightPct)
          Addq label and field with alignment respective to the other labels and fields in column, and will stretch as far as preferredSize.width * fillRightPct to right justify.
 void add(java.awt.Component label, java.awt.Component field, int row, int column, int mode)
          Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode.
 void add(java.awt.Component label, java.awt.Component field, int row, int column, int mode, double fillRightPct)
          Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, and will stretch as far as preferredSize.width * fillRightPct to right justify.
 void add(java.awt.Component component, int row, int column)
          Adds a component that will align with the labels in column.
 void add(java.awt.Component component, int row, int column, double fillRightPct)
          Adds a component that will align with the labels in column, and will stretch as far as preferredSize.width * fillRightPct to right justify.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Terminated ancestor method.
 void addMultiRow(java.awt.Component label, java.awt.Component field, int startRow, int endRow, int column)
          Adds label and field with alignment respective to the other labels and fields in column. and span from startRow to endRow.
 void addMultiRow(java.awt.Component label, java.awt.Component field, int startRow, int endRow, int column, double fillRightPct)
          Adds label and field with alignment respective to the other labels and fields in column, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
 void addMultiRow(java.awt.Component label, java.awt.Component field, int startRow, int endRow, int column, int mode)
          Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, and span from startRow to endRow.
 void addMultiRow(java.awt.Component label, java.awt.Component field, int startRow, int endRow, int column, int mode, double fillRightPct)
          Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
 void addMultiRow(java.awt.Component component, int startRow, int endRow, int column)
          Adds a component that will align with the labels in column, and span from startRow to endRow.
 void addMultiRow(java.awt.Component component, int startRow, int endRow, int column, double fillRightPct)
          Adds a component that will align with the labels in column, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
protected  int getBottomInset()
          Returns the bottom inset.
protected  FormColumnLayout getColumn(int column)
          Returns the FormColumnLayout for "column"; create it if it doesn't exist
 double getDefaultFillRightPct()
          Returns the default value.
 int getExternalHGap()
          Returns the external horizontal gap.
 int getExternalVGap()
          Returns the external vertical gap.
 int getInternalHGap()
          Returns the internal horizontal gap.
 int getInternalVGap()
          Returns the internal vertical gap.
protected  int getLeftInset()
          Returns the left inset.
protected  int getRightInset()
          Returns the right inset.
protected  int getTopInset()
          Returns the top inset.
private  void init()
          Initializes datas.
 void layoutContainer(java.awt.Container parent)
          Lays out the container in the specified panel.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
 void removeLayoutComponent(java.awt.Component component)
          Removes the specified component from the layout.
 void setDefaultFillRightPct(double fillRightPct)
          All subsequent add() calls that do not specify fillRightPct will use this fillRightPct.
 void setExternalHGap(int gap)
          Sets the external horizontal gap.
 void setExternalVGap(int gap)
          Sets the external vertical gap.
 void setInternalHGap(int gap)
          Sets the internal horizontal gap.
 void setInternalVGap(int gap)
          Sets the internal vertical gap.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_hgap

private int m_hgap

m_vgap

private int m_vgap

m_externalHGap

private int m_externalHGap

m_externalVGap

private int m_externalVGap

m_pct

private double m_pct

m_Columns

private FormLayout.ExtendedVector m_Columns

m_ColumnLeader

private FormLayout.ColumnLeader m_ColumnLeader

m_RowLeader

private FormLayout.RowLeader m_RowLeader

m_container

private java.awt.Container m_container

DEFAULT

public static final int DEFAULT
Specifies default alignment for the associated component (used in the FormLayout.add() methods).

FREE_LABEL

public static final int FREE_LABEL
Special alignment: the associated label will not align with other labels in this column (used in certain FormLayout.add() methods).

FREE_FIELD

public static final int FREE_FIELD
Special alignment: the associated field will not align with other fields in this column (used in certain FormLayout.add() methods).

LABEL_ON_TOP

public static final int LABEL_ON_TOP
Special alignment: the label and field will appear in subsequent columns, starting with the one specified (used in certain FormLayout.add() methods).
Constructor Detail

FormLayout

public FormLayout()
Creates a new layout.

FormLayout

public FormLayout(int internalHGap,
                  int internalVGap,
                  int externalHGap,
                  int externalVGap)
Creates a layout with most specific gap access available.
Parameters:
internalHGap -  
internalVGap -  
externalHGap -  
externalVGap -  
Method Detail

getLeftInset

protected int getLeftInset()
Returns the left inset.
Returns:
externalHGap + left inset of the container.

getRightInset

protected int getRightInset()
Returns the right inset.
Returns:
externalHGap+right inset of the container.

getTopInset

protected int getTopInset()
Returns the top inset.
Returns:
externalVGap + top inset of the container.

getBottomInset

protected int getBottomInset()
Returns the bottom inset.
Returns:
externalVGap + bottom inset of the container.

getInternalHGap

public int getInternalHGap()
Returns the internal horizontal gap.
Returns:
The internal horizontal gap.

getInternalVGap

public int getInternalVGap()
Returns the internal vertical gap.
Returns:
The internal vertical gap.

getExternalHGap

public int getExternalHGap()
Returns the external horizontal gap.
Returns:
The external horizontal gap.

getExternalVGap

public int getExternalVGap()
Returns the external vertical gap.
Returns:
The external verticla gap.

setInternalVGap

public void setInternalVGap(int gap)
Sets the internal vertical gap.
Parameters:
gap - The internal vertical gap.

setInternalHGap

public void setInternalHGap(int gap)
Sets the internal horizontal gap.
Parameters:
gap - The internal horizontal gap.

setExternalVGap

public void setExternalVGap(int gap)
Sets the external vertical gap.
Parameters:
gap - The external vertical gap.

setExternalHGap

public void setExternalHGap(int gap)
Sets the external horizontal gap.
Parameters:
gap - The external horizontal gap.

init

private void init()
Initializes datas.

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container in the specified panel.
Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - The component which needs to be laid out.

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Calculates the minimum size dimensions for the specified panel given the components in the specified parent container.
Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The component to be laid out

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Calculates the preferred size dimensions for the specified panel given the components in the specified parent container.
Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - The component to be laid out.

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component component)
Removes the specified component from the layout.
Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - The component ot be removed.

add

public void add(java.awt.Component component,
                int row,
                int column)
Adds a component that will align with the labels in column.
Parameters:
component - The component to be added.
row - The row where to put the component.
column - The column where to put the component.

add

public void add(java.awt.Component label,
                java.awt.Component field,
                int row,
                int column)
Adds label and field with alignment respective to the other labels and fields in column.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
row - The row where to put the components.
colum - The column where to put the components.

add

public void add(java.awt.Component label,
                java.awt.Component field,
                int row,
                int column,
                int mode)
Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
row - The row where to put the components.
colum - The column where to put the components.
mode - The mode used.

addMultiRow

public void addMultiRow(java.awt.Component component,
                        int startRow,
                        int endRow,
                        int column)
Adds a component that will align with the labels in column, and span from startRow to endRow.
Parameters:
component - The component to be added.
startRow - The first row where to add the component.
endRow - The last row where to add the component.
column - The column where to add the component.

addMultiRow

public void addMultiRow(java.awt.Component label,
                        java.awt.Component field,
                        int startRow,
                        int endRow,
                        int column)
Adds label and field with alignment respective to the other labels and fields in column. and span from startRow to endRow.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
startRow - The first row where to add the components.
endRow - The last row where to add the components.
column - The column where to add the components.

addMultiRow

public void addMultiRow(java.awt.Component label,
                        java.awt.Component field,
                        int startRow,
                        int endRow,
                        int column,
                        int mode)
Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, and span from startRow to endRow.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
startRow - The first row where to add the components.
endRow - The last row where to add the components.
column - The column where to add the components.
mode - The mode to use.

add

public void add(java.awt.Component component,
                int row,
                int column,
                double fillRightPct)
Adds a component that will align with the labels in column, and will stretch as far as preferredSize.width * fillRightPct to right justify.
Parameters:
component - The component to be added.
row - The row where to insert this component.
column - The column where to insert this component.
fillRightPct -  

add

public void add(java.awt.Component label,
                java.awt.Component field,
                int row,
                int column,
                double fillRightPct)
Addq label and field with alignment respective to the other labels and fields in column, and will stretch as far as preferredSize.width * fillRightPct to right justify.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
row - The row where to insert this component.
column - The column where to insert this component.
fillRightPct -  

add

public void add(java.awt.Component label,
                java.awt.Component field,
                int row,
                int column,
                int mode,
                double fillRightPct)
Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, and will stretch as far as preferredSize.width * fillRightPct to right justify.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
row - The row where to insert this component.
column - The column where to insert this component.
mode - The mode to use.
fillRightPct -  

addMultiRow

public void addMultiRow(java.awt.Component component,
                        int startRow,
                        int endRow,
                        int column,
                        double fillRightPct)
Adds a component that will align with the labels in column, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
Parameters:
component - The component to be added.
startRow - The first row where to add the components.
endRow - The last row where to add the components.
column - The column where to insert this component.
fillRightPct -  

addMultiRow

public void addMultiRow(java.awt.Component label,
                        java.awt.Component field,
                        int startRow,
                        int endRow,
                        int column,
                        double fillRightPct)
Adds label and field with alignment respective to the other labels and fields in column, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
startRow - The first row where to add the components.
endRow - The last row where to add the components.
column - The column where to insert this component.
fillRightPct -  

addMultiRow

public void addMultiRow(java.awt.Component label,
                        java.awt.Component field,
                        int startRow,
                        int endRow,
                        int column,
                        int mode,
                        double fillRightPct)
Adds label and field with alignment respective to the other labels and fields in column, subject to the specified mode, will span from startRow to endRow, and will stretch as far as preferredSize.width * fillRightPct to reach the right side.
Parameters:
label - The label to be associated with the field.
field - The field to be associated with the label.
startRow - The first row where to add the components.
endRow - The last row where to add the components.
column - The column where to insert this component.
mode - the mode to use.
fillRightPct -  

setDefaultFillRightPct

public void setDefaultFillRightPct(double fillRightPct)
All subsequent add() calls that do not specify fillRightPct will use this fillRightPct.
Parameters:
fillRightPct -  

getDefaultFillRightPct

public double getDefaultFillRightPct()
Returns the default value.
Returns:
The default value.

getColumn

protected FormColumnLayout getColumn(int column)
Returns the FormColumnLayout for "column"; create it if it doesn't exist
Returns:
The FormColumnLayout.

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Terminated ancestor method.
Specified by:
addLayoutComponent in interface java.awt.LayoutManager