buoy.widget
Class LayoutInfo
- 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.
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.
|
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.
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.
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.
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.
widget
- the Widget to positionrect
- the rectangle within which the Widget should be positioned. This is typically the
region a WidgetContainer has set aside for this particular Widget.
- 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.