buoy.widget

Class LayoutInfo

Implemented Interfaces:
Cloneable

public class LayoutInfo
extends java.lang.Object
implements 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, Insets insets, Dimension padding)
Create a LayoutInfo object.

Method Summary

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.
Insets
getInsets()
Get the extra space (in pixels) that should be added around the Widget.
Dimension
getMaximumSize(Widget widget)
Get the maximum size of a Widget, taking into account the insets and padding specified by this object.
Dimension
getPadding()
Get the extra padding, in pixels, that should be added to the preferred size of the Widget.
Dimension
getPreferredSize(Widget widget)
Get the preferred size of a Widget, taking into account the insets and padding specified by this object.
Rectangle
getWidgetLayout(Widget widget, 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(Insets insets)
Set the extra space (in pixels) that should be added around the Widget.
void
setPadding(Dimension padding)
Set the extra padding, in pixels, that should be added to the preferred size of the Widget.

Field Details

BOTH

public static final LayoutInfo.FillType BOTH

CENTER

public static final LayoutInfo.Alignment CENTER

EAST

public static final LayoutInfo.Alignment EAST

HORIZONTAL

public static final LayoutInfo.FillType HORIZONTAL

NONE

public static final LayoutInfo.FillType NONE

NORTH

public static final LayoutInfo.Alignment NORTH

NORTHEAST

public static final LayoutInfo.Alignment NORTHEAST

NORTHWEST

public static final LayoutInfo.Alignment NORTHWEST

SOUTH

public static final LayoutInfo.Alignment SOUTH

SOUTHEAST

public static final LayoutInfo.Alignment SOUTHEAST

SOUTHWEST

public static final LayoutInfo.Alignment SOUTHWEST

VERTICAL

public static final LayoutInfo.FillType VERTICAL

WEST

public static final LayoutInfo.Alignment WEST

Constructor Details

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,
                  Insets insets,
                  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 Details

clone

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

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.

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.

getInsets

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

getMaximumSize

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

getPadding

public 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.

getPreferredSize

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

getWidgetLayout

public Rectangle getWidgetLayout(Widget widget,
                                 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

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.

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.

setInsets

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

setPadding

public void setPadding(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.

Written by Peter Eastman.