edu.hawaii.ics.yucheng
Class AnchorLayoutManager

java.lang.Object
  extended by edu.hawaii.ics.yucheng.AnchorLayoutManager
All Implemented Interfaces:
java.awt.LayoutManager

 class AnchorLayoutManager
extends java.lang.Object
implements java.awt.LayoutManager

A layout manager that supports anchored components. Each component added can be anchored to the left, top, right, bottom, or a combination of these locations. When the container is resized, the components will stretch or move accordingly.


Nested Class Summary
(package private)  class AnchorLayoutManager.Anchor
          An anchor associated with a component.
 
Field Summary
static java.lang.String ANCHOR_BOTTOM
          An anchor flag that indicates the component should anchor to the bottom of the container.
static java.lang.String ANCHOR_LEFT
          An anchor flag that indicates the component should anchor to the left of the container.
static java.lang.String ANCHOR_RIGHT
          An anchor flag that indicates the component should anchor to the right of the container.
static java.lang.String ANCHOR_TOP
          An anchor flag that indicates the component should anchor to the top of the container.
private  java.util.Collection<AnchorLayoutManager.Anchor> myAnchors
           
(package private)  int myMinimumCX
          The minimum width of the container.
(package private)  int myMinimumCY
          The minimum height of the container.
 
Constructor Summary
AnchorLayoutManager(int minimumCX, int minimumCY)
          Initializes a new instance of the class.
 
Method Summary
 void addLayoutComponent(java.lang.String flags, java.awt.Component component)
          Adds a component to the layout manager.
 void layoutContainer(java.awt.Container container)
          Positions each component added to the layout based on the size of the specified container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container container)
          Returns the minimum layout size.
 java.awt.Dimension preferredLayoutSize(java.awt.Container container)
          Returns the preferred layout size.
 void removeLayoutComponent(java.awt.Component component)
          Removes a component from the layout.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ANCHOR_BOTTOM

public static final java.lang.String ANCHOR_BOTTOM
An anchor flag that indicates the component should anchor to the bottom of the container.

See Also:
Constant Field Values

ANCHOR_LEFT

public static final java.lang.String ANCHOR_LEFT
An anchor flag that indicates the component should anchor to the left of the container.

See Also:
Constant Field Values

ANCHOR_RIGHT

public static final java.lang.String ANCHOR_RIGHT
An anchor flag that indicates the component should anchor to the right of the container.

See Also:
Constant Field Values

ANCHOR_TOP

public static final java.lang.String ANCHOR_TOP
An anchor flag that indicates the component should anchor to the top of the container.

See Also:
Constant Field Values

myAnchors

private final java.util.Collection<AnchorLayoutManager.Anchor> myAnchors

myMinimumCX

final int myMinimumCX
The minimum width of the container.


myMinimumCY

final int myMinimumCY
The minimum height of the container.

Constructor Detail

AnchorLayoutManager

public AnchorLayoutManager(int minimumCX,
                           int minimumCY)
Initializes a new instance of the class. The minimum width and height must be at least one.

Parameters:
minimumCX - The minimum and initial width of the container.
minimumCY - The minimum and initial height of the container.
Throws:
java.lang.IllegalArgumentException - Thrown if either of the minimum sizes are less than one.
Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String flags,
                               java.awt.Component component)
Adds a component to the layout manager.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
flags - The layout flags.
component - The component to add.
Throws:
java.lang.NullPointerException - Thrown if either of the arguments are null.

layoutContainer

public void layoutContainer(java.awt.Container container)
Positions each component added to the layout based on the size of the specified container.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
container - The container.
Throws:
java.lang.NullPointerException - Thrown if the container is null.

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container container)
Returns the minimum layout size. This is the size specified in the constructor.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
container - The container (not used).
Returns:
The minimum size.
Throws:
java.lang.NullPointerException - Thrown if the container is null.

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container container)
Returns the preferred layout size. This is the maximum of the minimum size and the current size of the container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
container - The container.
Returns:
The preferred size.
Throws:
java.lang.NullPointerException - Thrown if the container is null.

removeLayoutComponent

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

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
component - The component to remove.
Throws:
java.lang.NullPointerException - Thrown if the component is null.