buoy.widget
Class LayoutInfo

java.lang.Object
  extended by buoy.widget.LayoutInfo
All Implemented Interfaces:
java.lang.Cloneable

public class LayoutInfo
extends java.lang.Object
implements java.lang.Cloneable

A LayoutInfo object contains information about how a Widget should be layed out within the space provided by its WidgetContainer. Most containers allow you to specify a default LayoutInfo for all Widgets, and also to specify a different one for each Widget.

It is permitted to reuse a single LayoutInfo object for multiple Widgets. In that case, any change made to the LayoutInfo will affect all Widgets for which it is used.

Author:
Peter Eastman

Nested Class Summary
static class LayoutInfo.Alignment
          This inner class represents a value for the alignment.
static class LayoutInfo.FillType
          This inner class represents a value for the fill.
 
Field Summary
static LayoutInfo.FillType BOTH
           
static LayoutInfo.Alignment CENTER
           
static LayoutInfo.Alignment EAST
           
static LayoutInfo.FillType HORIZONTAL
           
static LayoutInfo.FillType NONE
           
static LayoutInfo.Alignment NORTH
           
static LayoutInfo.Alignment NORTHEAST
           
static LayoutInfo.Alignment NORTHWEST
           
static LayoutInfo.Alignment SOUTH
           
static LayoutInfo.Alignment SOUTHEAST
           
static LayoutInfo.Alignment SOUTHWEST
           
static LayoutInfo.FillType VERTICAL
           
static LayoutInfo.Alignment WEST
           
 
Constructor Summary
LayoutInfo()
          Create a LayoutInfo object with the following default values: no padding, no insets, center alignment, and no fill.
LayoutInfo(LayoutInfo.Alignment align, LayoutInfo.FillType fill)
          Create a LayoutInfo object with no padding or insets.
LayoutInfo(LayoutInfo.Alignment align, LayoutInfo.FillType fill, java.awt.Insets insets, java.awt.Dimension padding)
          Create a LayoutInfo object.
 
Method Summary
 java.lang.Object clone()
          Create a duplicate of this object.
 LayoutInfo.Alignment getAlignment()
          Get the alignment of the Widget within its available space.
 LayoutInfo.FillType getFill()
          Get whether the Widget should grow to fill the available space.
 java.awt.Insets getInsets()
          Get the extra space (in pixels) that should be added around the Widget.
 java.awt.Dimension getMaximumSize(Widget widget)
          Get the maximum size of a Widget, taking into account the insets and padding specified by this object.
 java.awt.Dimension getPadding()
          Get the extra padding, in pixels, that should be added to the preferred size of the Widget.
 java.awt.Dimension getPreferredSize(Widget widget)
          Get the preferred size of a Widget, taking into account the insets and padding specified by this object.
 java.awt.Rectangle getWidgetLayout(Widget widget, java.awt.Rectangle rect)
          Given a Widget, and a Rectangle in which to position it, return the desired bounds of the Widget.
 void setAlignment(LayoutInfo.Alignment align)
          Set the alignment of the Widget within its available space.
 void setFill(LayoutInfo.FillType fill)
          Set whether the Widget should grow to fill the available space.
 void setInsets(java.awt.Insets insets)
          Set the extra space (in pixels) that should be added around the Widget.
 void setPadding(java.awt.Dimension padding)
          Set the extra padding, in pixels, that should be added to the preferred size of the Widget.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CENTER

public static final LayoutInfo.Alignment CENTER

NORTH

public static final LayoutInfo.Alignment NORTH

SOUTH

public static final LayoutInfo.Alignment SOUTH

WEST

public static final LayoutInfo.Alignment WEST

EAST

public static final LayoutInfo.Alignment EAST

NORTHEAST

public static final LayoutInfo.Alignment NORTHEAST

SOUTHEAST

public static final LayoutInfo.Alignment SOUTHEAST

NORTHWEST

public static final LayoutInfo.Alignment NORTHWEST

SOUTHWEST

public static final LayoutInfo.Alignment SOUTHWEST

NONE

public static final LayoutInfo.FillType NONE

HORIZONTAL

public static final LayoutInfo.FillType HORIZONTAL

VERTICAL

public static final LayoutInfo.FillType VERTICAL

BOTH

public static final LayoutInfo.FillType BOTH
Constructor Detail

LayoutInfo

public LayoutInfo()
Create a LayoutInfo object with the following default values: no padding, no insets, center alignment, and no fill.


LayoutInfo

public LayoutInfo(LayoutInfo.Alignment align,
                  LayoutInfo.FillType fill)
Create a LayoutInfo object with no padding or insets.

Parameters:
align - the alignment of the Widget. This should be equal to one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.
fill - specifies whether the Widget should grow to fill the available space. This should be equal to NONE, HORIZONTAL, VERTICAL, BOTH.

LayoutInfo

public LayoutInfo(LayoutInfo.Alignment align,
                  LayoutInfo.FillType fill,
                  java.awt.Insets insets,
                  java.awt.Dimension padding)
Create a LayoutInfo object.

Parameters:
align - the alignment of the Widget. This should be equal to one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.
fill - specifies whether the Widget should grow to fill the available space. This should be equal to NONE, HORIZONTAL, VERTICAL, BOTH.
insets - specifies extra space (in pixels) that should be added around the Widget. If this is null, no insets will be used.
padding - extra padding, in pixels. This requests that the Widget be made larger than its preferred size. If this is null, no padding will be used.
Method Detail

getAlignment

public LayoutInfo.Alignment getAlignment()
Get the alignment of the Widget within its available space. This should be equal to one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.


setAlignment

public void setAlignment(LayoutInfo.Alignment align)
Set the alignment of the Widget within its available space. This should be equal to one of the alignment constants defined by this class: CENTER, NORTH, NORTHEAST, EAST, etc.


getFill

public LayoutInfo.FillType getFill()
Get whether the Widget should grow to fill the available space. This should be equal to NONE, HORIZONTAL, VERTICAL, BOTH.


setFill

public void setFill(LayoutInfo.FillType fill)
Set whether the Widget should grow to fill the available space. This should be equal to NONE, HORIZONTAL, VERTICAL, BOTH.


getInsets

public java.awt.Insets getInsets()
Get the extra space (in pixels) that should be added around the Widget. If this is null, no insets will be used.


setInsets

public void setInsets(java.awt.Insets insets)
Set the extra space (in pixels) that should be added around the Widget. If this is null, no insets will be used.


getPadding

public java.awt.Dimension getPadding()
Get the extra padding, in pixels, that should be added to the preferred size of the Widget. If this is null, no padding will be used.


setPadding

public void setPadding(java.awt.Dimension padding)
Set the extra padding, in pixels, that should be added to the preferred size of the Widget. If this is null, no padding will be used.


clone

public java.lang.Object clone()
Create a duplicate of this object.

Overrides:
clone in class java.lang.Object

getPreferredSize

public java.awt.Dimension getPreferredSize(Widget widget)
Get the preferred size of a Widget, taking into account the insets and padding specified by this object.


getMaximumSize

public java.awt.Dimension getMaximumSize(Widget widget)
Get the maximum size of a Widget, taking into account the insets and padding specified by this object.


getWidgetLayout

public java.awt.Rectangle getWidgetLayout(Widget widget,
                                          java.awt.Rectangle rect)
Given a Widget, and a Rectangle in which to position it, return the desired bounds of the Widget.

Parameters:
widget - the Widget to position
rect - the rectangle within which the Widget should be positioned. This is typically the region a WidgetContainer has set aside for this particular Widget.
Returns:
the bounds which should be set for the Widget


Written by Peter Eastman.