org.zaval.lw
Class LwFlowLayout

java.lang.Object
  |
  +--org.zaval.lw.LwFlowLayout
All Implemented Interfaces:
LwLayout

public class LwFlowLayout
extends java.lang.Object
implements LwLayout

This class implements layout manager interface. The impementation layouts child components according three parameters : direction (can be LwToolkit.HORIZONTAL or LwToolkit.VERTICAL), vertical alignment (Alignment.TOP, Alignment.BOTTOM, Alignment.CENTER) and horizontal alignment (Alignment.LEFT, Alignment.RIGHT, Alignment.CENTER).

The first parameter defines direction, if the direction is LwToolkit.VERTICAL than every following component will be added under the previous, otherwise every following component will be added to the right of the previous.

The vertical and horizontal alignments define how the child components will be laidout relatively the parent container. The table below shows the samples of the layout manager usage:
Direction Horizontal alignment Vertical alignment Sample App
LwToolkit.HORIZONTAL Alignment.LEFT Alignment.TOP
LwToolkit.VERTICAL Alignment.LEFT Alignment.TOP
LwToolkit.VERTICAL Alignment.RIGHT Alignment.TOP
LwToolkit.HORIZONTAL Alignment.CENTER Alignment.CENTER
LwToolkit.HORIZONTAL Alignment.CENTER Alignment.BOTTOM


Constructor Summary
LwFlowLayout()
          Constructs a new flow layout manager with default parameters.
LwFlowLayout(int ax, int ay)
          Constructs a new flow layout manager with the specified horizontal and vertical alignments.
LwFlowLayout(int ax, int ay, int dir)
          Constructs a new flow layout manager with the specified horizontal, vertical alignments and the direction.
LwFlowLayout(int ax, int ay, int dir, int vg, int hg)
          Constructs a new flow layout manager with the specified horizontal, vertical alignments, the direction and the given gaps.
 
Method Summary
 java.awt.Dimension calcPreferredSize(LayoutContainer target)
          Calculates the preferred size dimensions for the layout container.
 void componentAdded(java.lang.Object id, Layoutable lw, int index)
          Invoked when the specified layoutable component is added to the layout container (that uses the layout manager).
 void componentRemoved(Layoutable lw, int index)
          Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
 int getHGap()
          Gets the horizontal gap.
 int getVGap()
          Gets the vertical gap.
 void layout(LayoutContainer c)
          Lays out the child layoutable components inside the layout container.
 void setGaps(int vg, int hg)
          Sets the vertical and horizontal gaps.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LwFlowLayout

public LwFlowLayout()
Constructs a new flow layout manager with default parameters. In this case the direction property is LwToolkit.HORIZONTAL, the horizontal alignment is Alignment.LEFT and the vertical alignment is Alignment.TOP.

LwFlowLayout

public LwFlowLayout(int ax,
                    int ay)
Constructs a new flow layout manager with the specified horizontal and vertical alignments. In this case the direction property is LwToolkit.HORIZONTAL.
Parameters:
ax - the specified horizontal alignment.
ay - the specified vertical alignment.

LwFlowLayout

public LwFlowLayout(int ax,
                    int ay,
                    int dir)
Constructs a new flow layout manager with the specified horizontal, vertical alignments and the direction.
Parameters:
ax - the specified horizontal alignment.
ay - the specified vertical alignment.
dir - the specified direction.

LwFlowLayout

public LwFlowLayout(int ax,
                    int ay,
                    int dir,
                    int vg,
                    int hg)
Constructs a new flow layout manager with the specified horizontal, vertical alignments, the direction and the given gaps.
Parameters:
ax - the specified horizontal alignment.
ay - the specified vertical alignment.
dir - the specified direction.
vg - the specified vertical gap.
hg - the specified horizontal gap.
Method Detail

calcPreferredSize

public java.awt.Dimension calcPreferredSize(LayoutContainer target)
Calculates the preferred size dimensions for the layout container. The method calculates "pure" preferred size, it means that an insets of the container is not considered.
Specified by:
calcPreferredSize in interface LwLayout
Parameters:
target - the layout container.

layout

public void layout(LayoutContainer c)
Lays out the child layoutable components inside the layout container.
Specified by:
layout in interface LwLayout
Parameters:
c - the layout container that needs to be laid out.

getVGap

public int getVGap()
Gets the vertical gap.
Returns:
a vertical gap.

getHGap

public int getHGap()
Gets the horizontal gap.
Returns:
a horizontal gap.

setGaps

public void setGaps(int vg,
                    int hg)
Sets the vertical and horizontal gaps.
Parameters:
vg - the specified vertical gap.
hg - the specified horizontal gap.

componentAdded

public void componentAdded(java.lang.Object id,
                           Layoutable lw,
                           int index)
Invoked when the specified layoutable component is added to the layout container (that uses the layout manager). The specified constraints, layoutable component and child index are passed as arguments into the method. The layout manager doesn't use any constraints, so the method is empty for the manager.
Specified by:
componentAdded in interface LwLayout
Parameters:
id - the layoutable component constraints.
lw - the layoutable component.
index - the child index.

componentRemoved

public void componentRemoved(Layoutable lw,
                             int index)
Invoked when the specified layoutable component is removed from the layout container, that uses the layout manager.
Specified by:
componentRemoved in interface LwLayout
Parameters:
lw - the layoutable component to be removed
index - the child index.


Copyright © Zaval Creative Engineering Group, 2000-2005.
http://www.zaval.org