uk.co.ist.mwt
Class DrawingAreaLayout

java.lang.Object
  |
  +--uk.co.ist.mwt.MarginLayoutManager
        |
        +--uk.co.ist.mwt.DrawingAreaLayout
Direct Known Subclasses:
BulletinBoardLayout

public class DrawingAreaLayout
extends MarginLayoutManager

The DrawingAreaLayout is a very simple layout manager - it leaves all child components where they want to be (that is, it doesn't move them), unless their position would put them inside the margin space.

If a child is added with no set size, then it will always be resized to its preferred size, even if the size is set later

It gives a minimum size of (2 * marginWidth, 2 * marginHeight) and a preferred size which makes all child components visible.

See Also:
Serialized Form

Fields inherited from class uk.co.ist.mwt.MarginLayoutManager
marginHeight, marginWidth
 
Constructor Summary
DrawingAreaLayout()
           
 
Method Summary
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Add a component to the layout manager's records.
 void layoutContainer(java.awt.Container parent)
          Lays out the container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Find the minimum size for a paretn container with this layout.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Work out how large the parent Container should be to hold everthing comfortably.
 void removeLayoutComponent(java.awt.Component comp)
          Remove a component from the layout manager's records.
protected  void updateUnsized(java.awt.Component[] children)
          A method to add a component to the list of components which did not have an explicit size set when they were added; called from layoutContainer() and preferred/minimumLayoutSize().
 
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
 

Constructor Detail

DrawingAreaLayout

public DrawingAreaLayout()
Method Detail

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the container. We need do nothing with any Components which have been moved and resized appropriately, but any which are sized to (0, 0) must be resized, as this is the default size for unlaid-out components.
Overrides:
layoutContainer in class MarginLayoutManager
Parameters:
parent - the component which needs to be laid out

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Find the minimum size for a paretn container with this layout. The DrawingAreaLayout has no problem with being resized to just enough size to hold its margins.
Overrides:
minimumLayoutSize in class MarginLayoutManager
Parameters:
parent - the parent container
See Also:
preferredLayoutSize(java.awt.Container)

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Work out how large the parent Container should be to hold everthing comfortably. This is the size we need to be to be able to show everything, with margins.
Overrides:
preferredLayoutSize in class MarginLayoutManager
Parameters:
parent - the parent container
See Also:
minimumLayoutSize(java.awt.Container)

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Remove a component from the layout manager's records. This is used to keep a record of components which were added with no explicit size setting made up-to-date.
Overrides:
removeLayoutComponent in class MarginLayoutManager
Parameters:
comp - would be 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. This would be used to keep a record of components which were added with no explicit size setting made up-to-date, but of course it's only called when a component is added with a name. So, the code to add unsized components to the list of such is in the updateUnsized() method, called from the layoutContainer() and preferred/minimumLayoutSize() methods.
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)

updateUnsized

protected void updateUnsized(java.awt.Component[] children)
A method to add a component to the list of components which did not have an explicit size set when they were added; called from layoutContainer() and preferred/minimumLayoutSize().