RiverLayout Class Reference

List of all members.

Public Member Functions

 RiverLayout ()
 RiverLayout (int hgap, int vgap)
void addLayoutComponent (String name, Component comp)
Insets getExtraInsets ()
int getHgap ()
 Gets the horizontal gap between components.
int getVgap ()
 Gets the vertical gap between components.
void layoutContainer (Container target)
 Lays out the container.
Dimension minimumLayoutSize (Container target)
 Returns the minimum dimensions needed to layout the visible components contained in the specified target container.
Dimension preferredLayoutSize (Container target)
 Returns the preferred dimensions for this layout given the visible components in the specified target container.
void removeLayoutComponent (Component comp)
 Removes the specified component from the layout.
void setExtraInsets (Insets newExtraInsets)
void setHgap (int hgap)
 Sets the horizontal gap between components.
void setVgap (int vgap)
 Sets the vertical gap between components.

Static Public Attributes

static final String CENTER_ALIGN = "center"
static final String HFILL = "hfill"
static final String LEFT_ALIGN = "left"
static final String LINE_BREAK = "br"
static final String PARAGRAPH_BREAK = "p"
static final String RIGHT_ALIGN = "right"
static final String TAB_STOP = "tab"
static final String VCENTER = "vcenter"
static final String VFILL = "vfill"
static final String VTOP = "vtop"

Protected Member Functions

void adjustAlignment (Component m)
Ruler calcTabs (Container target)
 Figure out tab stop x-positions.
Insets getInsets (Container target)
void moveComponents (Container target, int x, int y, int width, int height, int rowStart, int rowEnd, boolean ltr, Ruler ruler)
 Centers the elements in the specified row, if there is any slack.
void relMove (Container target, int dx, int dy, int rowStart, int rowEnd)

Package Functions

boolean hasConstraint (Component comp, String test)
boolean hasHfill (Component comp)
boolean hasVfill (Component comp)
boolean isFirstInRow (Component comp)

Package Attributes

final Map< Component, String > constraints = new HashMap<Component, String>()
Insets extraInsets
int hgap
final Insets totalInsets = new Insets(0, 0, 0, 0)
String valign = VCENTER
int vgap

Detailed Description

RiverLayout makes it very simple to construct user interfaces as components are laid out similar to how text is added to a word processor (Components flow like a "river". RiverLayout is however much more powerful than FlowLayout: Components added with the add() method generally gets laid out horizontally, but one may add a string before the component being added to specify "constraints" like this: add("br hfill", new JTextField("Your name here"); The code above forces a "line break" and extends the added component horizontally. Without the "hfill" constraint, the component would take on its preferred size.

List of constraints:

RiverLayout is LGPL licensed - use it freely in free and commercial programs

Author:
David Ekholm
Version:
1.1 (2005-05-23) -Bugfix: JScrollPanes were oversized (sized to their containing component) if the container containing the JScrollPane was resized.

Definition at line 37 of file RiverLayout.java.


Member Function Documentation

void addLayoutComponent ( String  name,
Component  comp 
)

Parameters:
name the name of the component
comp the component to be added

Definition at line 87 of file RiverLayout.java.

References RiverLayout.constraints.

void layoutContainer ( Container  target  ) 

Lays out the container.

This method lets each component take its preferred size by reshaping the components in the target container in order to satisfy the constraints of this FlowLayout object.

Parameters:
target the specified component being laid out
See also:
Container

java.awt.Container.doLayout

Definition at line 196 of file RiverLayout.java.

References RiverLayout.adjustAlignment(), RiverLayout.calcTabs(), RiverLayout.getInsets(), Ruler.getTab(), RiverLayout.hasConstraint(), RiverLayout.hasHfill(), RiverLayout.hasVfill(), RiverLayout.hgap, RiverLayout.isFirstInRow(), RiverLayout.moveComponents(), RiverLayout.PARAGRAPH_BREAK, RiverLayout.relMove(), RiverLayout.TAB_STOP, and RiverLayout.vgap.

Dimension minimumLayoutSize ( Container  target  ) 

Returns the minimum dimensions needed to layout the visible components contained in the specified target container.

Parameters:
target the component which needs to be laid out
Returns:
the minimum dimensions to lay out the subcomponents of the specified container
See also:
preferredLayoutSize

java.awt.Container

java.awt.Container.doLayout

Definition at line 284 of file RiverLayout.java.

References RiverLayout.calcTabs(), RiverLayout.getInsets(), Ruler.getTab(), RiverLayout.hasConstraint(), RiverLayout.hgap, RiverLayout.isFirstInRow(), RiverLayout.PARAGRAPH_BREAK, RiverLayout.TAB_STOP, and RiverLayout.vgap.

void moveComponents ( Container  target,
int  x,
int  y,
int  width,
int  height,
int  rowStart,
int  rowEnd,
boolean  ltr,
Ruler  ruler 
) [protected]

Centers the elements in the specified row, if there is any slack.

Parameters:
target the component which needs to be moved
x the x coordinate
y the y coordinate
width the width dimensions
height the height dimensions
rowStart the beginning of the row
rowEnd the the ending of the row

Definition at line 344 of file RiverLayout.java.

References RiverLayout.getInsets(), Ruler.getTab(), RiverLayout.hasConstraint(), RiverLayout.hgap, RiverLayout.TAB_STOP, RiverLayout.valign, and RiverLayout.VTOP.

Referenced by RiverLayout.layoutContainer().

Dimension preferredLayoutSize ( Container  target  ) 

Returns the preferred dimensions for this layout given the visible components in the specified target container.

Parameters:
target the component which needs to be laid out
Returns:
the preferred dimensions to lay out the subcomponents of the specified container
See also:
Container

minimumLayoutSize

java.awt.Container.getPreferredSize

Definition at line 392 of file RiverLayout.java.

References RiverLayout.calcTabs(), RiverLayout.getInsets(), Ruler.getTab(), RiverLayout.hasConstraint(), RiverLayout.hgap, RiverLayout.isFirstInRow(), RiverLayout.PARAGRAPH_BREAK, RiverLayout.TAB_STOP, and RiverLayout.vgap.

void removeLayoutComponent ( Component  comp  ) 

Removes the specified component from the layout.

Not used by this class.

Parameters:
comp the component to remove
See also:
java.awt.Container.removeAll

Definition at line 453 of file RiverLayout.java.

References RiverLayout.constraints.


The documentation for this class was generated from the following file:
Generated on Sat Apr 14 18:21:46 2007 for R3 Paper Toolkit by  doxygen 1.4.7