uk.co.ist.mwt
Class FormLayoutManager

java.lang.Object
  |
  +--uk.co.ist.mwt.MarginLayoutManager
        |
        +--uk.co.ist.mwt.FormLayoutManager

public class FormLayoutManager
extends MarginLayoutManager
implements FormConstants

FormLayoutManagers are used to mimic the Motif XmForm widget. A detailed description of the workings of this widget would require more space than is available here. Basically, you need to constrain each child of the Container whose LayoutManager this is, using the constrain method, and then the resize behaviour will be appropriate.

To find out what 'appropriate' means, consult a good book on Motif...

See Also:
Serialized Form

Field Summary
protected  uk.co.ist.mwt.FormLayoutGraphNode formBottom
          The FormLayoutGraphNode representing the bottom of the form
protected  uk.co.ist.mwt.FormLayoutGraphNode formLeft
          The FormLayoutGraphNode representing the left of the form
protected  uk.co.ist.mwt.FormLayoutGraphNode formRight
          The FormLayoutGraphNode representing the right of the form
protected  uk.co.ist.mwt.FormLayoutGraphNode formTop
          The FormLayoutGraphNode representing the top of the form
 
Fields inherited from class uk.co.ist.mwt.MarginLayoutManager
marginHeight, marginWidth
 
Fields inherited from interface uk.co.ist.mwt.FormConstants
kAttachComponent, kAttachForm, kAttachNone, kAttachOppositeComponent, kAttachOppositeForm, kAttachPosition, kAttachSelf, kUnknown
 
Constructor Summary
FormLayoutManager()
          Constructor - sets up appropriate defaults
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Add a component to the layout manager's records.
 void constrain(java.awt.Component child, FormLayoutConstraints constr)
          Method to set the constraints on a particular child component
protected  void convertSelfAttachments(java.awt.Rectangle bounds, FormLayoutConstraints constr, java.awt.Dimension parentSize)
          Converts self attachments to position attachments when they are found.
 int getFractionBase()
          Accessor for the fraction base (the denominator in the fraction for which position values are the numerator)
protected  java.awt.Dimension guessPreferredSize(java.util.Vector nodes)
          Method to guess the preferred size of the form; when calculating the preferred size we use this for a first guess, then try to get something better through successive approximation.
protected  java.util.Vector initialiseGraph(java.awt.Component[] children, java.awt.Dimension parentSize)
          Method to set up the graph of FormLayoutGraphNodes needed for laying out and calculating the preferred size of a container using this layout manager
 void layoutContainer(java.awt.Container parent)
          Lays out the container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Method to find the minimum size of the parent container with this layout
protected  void placeGraphNodes(java.util.Vector nodes)
          Set the graph nodes position settings so that they reflect the positions in which the components should go.
protected  void positionComponents(java.util.Vector nodes)
          Position the children of the container in the positions their graph nodes say they should be in.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Method to find the preferred size of the parent container with this layout.
 void removeLayoutComponent(java.awt.Component comp)
          Remove a component from the layout manager's records.
protected  void setFormNodes(java.awt.Dimension parentSize)
          Method to set up the graph nodes which represent the sides of the form
 void setFractionBase(int fb)
          Method to set the fraction base (the denominator in the fraction for which position values are the numerator)
 
Methods inherited from class uk.co.ist.mwt.MarginLayoutManager
getMarginHeight, getMarginWidth, setMarginHeight, setMarginWidth, sizeOfComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

formTop

protected uk.co.ist.mwt.FormLayoutGraphNode formTop
The FormLayoutGraphNode representing the top of the form

formBottom

protected uk.co.ist.mwt.FormLayoutGraphNode formBottom
The FormLayoutGraphNode representing the bottom of the form

formLeft

protected uk.co.ist.mwt.FormLayoutGraphNode formLeft
The FormLayoutGraphNode representing the left of the form

formRight

protected uk.co.ist.mwt.FormLayoutGraphNode formRight
The FormLayoutGraphNode representing the right of the form
Constructor Detail

FormLayoutManager

public FormLayoutManager()
Constructor - sets up appropriate defaults
Method Detail

setFractionBase

public void setFractionBase(int fb)
Method to set the fraction base (the denominator in the fraction for which position values are the numerator)
Parameters:
fb - the new fraction base

getFractionBase

public int getFractionBase()
Accessor for the fraction base (the denominator in the fraction for which position values are the numerator)

constrain

public void constrain(java.awt.Component child,
                      FormLayoutConstraints constr)
Method to set the constraints on a particular child component
Parameters:
child - the child component
constr - the constraints to give it, or null for default constraints

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container.
Overrides:
layoutContainer in class MarginLayoutManager
Parameters:
parent - the component which needs to be laid out

placeGraphNodes

protected void placeGraphNodes(java.util.Vector nodes)
Set the graph nodes position settings so that they reflect the positions in which the components should go.
Parameters:
nodes - a list of nodes to place

positionComponents

protected void positionComponents(java.util.Vector nodes)
Position the children of the container in the positions their graph nodes say they should be in.
Parameters:
nodes - a list of nodes to place

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Method to find the minimum size of the parent container with this layout
Overrides:
minimumLayoutSize in class MarginLayoutManager
Parameters:
parent - the component to be laid out
Returns:
the minimum size
See Also:
preferredLayoutSize(java.awt.Container)

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Method to find the preferred size of the parent container with this layout.
Overrides:
preferredLayoutSize in class MarginLayoutManager
Parameters:
parent - the component to be laid out
Returns:
the preferred size
See Also:
minimumLayoutSize(java.awt.Container)

guessPreferredSize

protected java.awt.Dimension guessPreferredSize(java.util.Vector nodes)
Method to guess the preferred size of the form; when calculating the preferred size we use this for a first guess, then try to get something better through successive approximation.
Parameters:
nodes - the nodes to use during this guessing

initialiseGraph

protected java.util.Vector initialiseGraph(java.awt.Component[] children,
                                           java.awt.Dimension parentSize)
Method to set up the graph of FormLayoutGraphNodes needed for laying out and calculating the preferred size of a container using this layout manager
Parameters:
children - the children of the container we're laying out
parentSize - the container's size
Returns:
the vector of FormLayoutGraphNodes

setFormNodes

protected void setFormNodes(java.awt.Dimension parentSize)
Method to set up the graph nodes which represent the sides of the form

convertSelfAttachments

protected void convertSelfAttachments(java.awt.Rectangle bounds,
                                      FormLayoutConstraints constr,
                                      java.awt.Dimension parentSize)
Converts self attachments to position attachments when they are found. Self attachments are really just a shorthand for allowing position attachments to be set up quickly and easily on layouts which began life as explicitly set non-dynamic layouts.
Parameters:
bounds - the bounds of the child whose constraints we're converting
constr - the constraints we're converting from using self attachments
parentSize - the size of the parent container

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove a component from the layout manager's records. This is used to keep the record of each Component's constraints from storing constraints for components which have been removed from the parent Container.
Overrides:
removeLayoutComponent in class MarginLayoutManager
Parameters:
comp - the component to remove.
See Also:
addLayoutComponent(java.lang.String, java.awt.Component)

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Add a component to the layout manager's records. Bot used for this layout manager.
Overrides:
addLayoutComponent in class MarginLayoutManager
Parameters:
comp - would be the component to add.
name - would be the name with which to add the component.
See Also:
removeLayoutComponent(java.awt.Component)