org.virion.jam.layouts
Class CompassLayout

java.lang.Object
  extended by org.virion.jam.layouts.CompassLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2

public class CompassLayout
extends Object
implements LayoutManager2

A layout manager similar to BorderLayout but with 8 compass directions. It will layout a container using members named "North", "NorthEast", "East", etc. and "Center".

The "North", "South", "East" and "West" components get layed out according to their preferred sizes and the constraints of the container's size. The "Center" component will get any space left over. The corner components are layed out accordingly

Author:
Andrew Rambaut

Constructor Summary
CompassLayout()
          Constructs a new CompassLayout.
CompassLayout(int hgap, int vgap)
          Constructs a CompassLayout with the specified gaps.
 
Method Summary
 void addLayoutComponent(Component comp, Object constraints)
          Adds the specified named component to the layout.
 void addLayoutComponent(String name, Component comp)
          Deprecated. replaced by addLayoutComponent(Component, Object).
 int getHgap()
          Returns the horizontal gap between components.
 float getLayoutAlignmentX(Container parent)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(Container parent)
          Returns the alignment along the y axis.
 int getVgap()
          Returns the vertical gap between components.
 void invalidateLayout(Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(Container target)
          Lays out the specified container.
 Dimension maximumLayoutSize(Container target)
          Returns the maximum dimensions for this layout given the components in the specified target container.
 Dimension minimumLayoutSize(Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
 Dimension preferredLayoutSize(Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 void removeLayoutComponent(Component comp)
          Removes the specified component from the layout.
 void setHgap(int hgap)
          Sets the horizontal gap between components.
 void setVgap(int vgap)
          Sets the vertical gap between components.
 String toString()
          Returns the String representation of this CompassLayout's values.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CompassLayout

public CompassLayout()
Constructs a new CompassLayout.


CompassLayout

public CompassLayout(int hgap,
                     int vgap)
Constructs a CompassLayout with the specified gaps.

Parameters:
hgap - the horizontal gap
vgap - the vertical gap
Method Detail

getHgap

public int getHgap()
Returns the horizontal gap between components.


setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components.

Parameters:
hgap - the horizontal gap between components

getVgap

public int getVgap()
Returns the vertical gap between components.


setVgap

public void setVgap(int vgap)
Sets the vertical gap between components.

Parameters:
vgap - the vertical gap between components

addLayoutComponent

public void addLayoutComponent(Component comp,
                               Object constraints)
Adds the specified named component to the layout.

Specified by:
addLayoutComponent in interface LayoutManager2

addLayoutComponent

public void addLayoutComponent(String name,
                               Component comp)
Deprecated. replaced by addLayoutComponent(Component, Object).

Specified by:
addLayoutComponent in interface LayoutManager

removeLayoutComponent

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

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

minimumLayoutSize

public Dimension minimumLayoutSize(Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.

Specified by:
minimumLayoutSize in interface LayoutManager
Parameters:
target - the Container on which to do the layout
See Also:
Container, preferredLayoutSize(java.awt.Container)

preferredLayoutSize

public Dimension preferredLayoutSize(Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

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

maximumLayoutSize

public Dimension maximumLayoutSize(Container target)
Returns the maximum dimensions for this layout given the components in the specified target container.

Specified by:
maximumLayoutSize in interface LayoutManager2
Parameters:
target - the component which needs to be laid out

getLayoutAlignmentX

public float getLayoutAlignmentX(Container parent)
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 LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(Container parent)
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 LayoutManager2

invalidateLayout

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

Specified by:
invalidateLayout in interface LayoutManager2

layoutContainer

public void layoutContainer(Container target)
Lays out the specified container. This method will actually reshape the components in the specified target container in order to satisfy the constraints of the CompassLayout object.

Specified by:
layoutContainer in interface LayoutManager
Parameters:
target - the component being laid out
See Also:
Container

toString

public String toString()
Returns the String representation of this CompassLayout's values.

Overrides:
toString in class Object