org.browsecode.helpers.layouts
Class SmartFlowLayout

java.lang.Object
  extended by org.browsecode.helpers.layouts.SmartFlowLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2

public class SmartFlowLayout
extends java.lang.Object
implements java.awt.LayoutManager2


Constructor Summary
SmartFlowLayout()
           
SmartFlowLayout(int horizontalGapBetweenComponents, int verticalGapBetweenComponents)
           
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraint object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Adds the specified component to the layout.
protected  void debug(java.lang.String out)
           
 boolean getDebug()
           
 java.lang.String getDebugPretext()
           
 int getHgap()
          Gets the horizontal gap between components.
 float getLayoutAlignmentX(java.awt.Container target)
          Returns the alignment along the x axis.
 float getLayoutAlignmentY(java.awt.Container target)
          Returns the alignment along the y axis.
 int getVgap()
          Gets the vertical gap between components.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
 void layoutContainer(java.awt.Container target)
          Lays out the container.
 java.awt.Dimension maximumLayoutSize(java.awt.Container target)
          Returns the maximum size of this component.
 java.awt.Dimension minimumLayoutSize(java.awt.Container target)
          Returns the minimum dimensions needed to layout the components contained in the specified target container.
 java.awt.Dimension preferredLayoutSize(java.awt.Container target)
          Returns the preferred dimensions for this layout given the components in the specified target container.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from the layout.
 void setDebug(boolean b)
           
 void setDebugPretext(java.lang.String string)
           
 void setHgap(int hgap)
          Sets the horizontal gap between components.
 void setVgap(int vgap)
          Sets the vertical gap between components.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SmartFlowLayout

public SmartFlowLayout()

SmartFlowLayout

public SmartFlowLayout(int horizontalGapBetweenComponents,
                       int verticalGapBetweenComponents)
Method Detail

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Adds the specified component to the layout. Not used by this class.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the name of the component
comp - the component to be added

addLayoutComponent

public void addLayoutComponent(java.awt.Component comp,
                               java.lang.Object constraints)
Adds the specified component to the layout, using the specified constraint object.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - where/how the component is added to the layout.

removeLayoutComponent

public void removeLayoutComponent(java.awt.Component comp)
Removes the specified component from the layout. Not used by this class.

Specified by:
removeLayoutComponent in interface java.awt.LayoutManager
Parameters:
comp - the component to remove
See Also:
Container.removeAll()

getHgap

public int getHgap()
Gets the horizontal gap between components.

Returns:
the horizontal gap between components.
See Also:
setHgap

setHgap

public void setHgap(int hgap)
Sets the horizontal gap between components.

Parameters:
hgap - the horizontal gap between components
See Also:
getHgap

getVgap

public int getVgap()
Gets the vertical gap between components.

Returns:
the vertical gap between components.
See Also:
setVgap

setVgap

public void setVgap(int vgap)
Sets the vertical gap between components.

Parameters:
vgap - the vertical gap between components
See Also:
getVgap

getLayoutAlignmentX

public float getLayoutAlignmentX(java.awt.Container target)
Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentX in interface java.awt.LayoutManager2

getLayoutAlignmentY

public float getLayoutAlignmentY(java.awt.Container target)
Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.

Specified by:
getLayoutAlignmentY in interface java.awt.LayoutManager2

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container target)
Returns the preferred dimensions for this layout given the components in the specified target container.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
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), Container.getPreferredSize()

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container target)
Returns the minimum dimensions needed to layout the components contained in the specified target container.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
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), Container, Container.doLayout()

maximumLayoutSize

public java.awt.Dimension maximumLayoutSize(java.awt.Container target)
Returns the maximum size of this component.

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
See Also:
Component.getMinimumSize(), Component.getPreferredSize(), LayoutManager

invalidateLayout

public void invalidateLayout(java.awt.Container target)
Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.

Specified by:
invalidateLayout in interface java.awt.LayoutManager2

layoutContainer

public void layoutContainer(java.awt.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 SmartFlowLayout object. This code bears a surprising similarity to FlowLayout

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
target - the specified component being laid out.
See Also:
Container, Container.doLayout()

getDebug

public boolean getDebug()
Returns:

setDebug

public void setDebug(boolean b)
Parameters:
b -

debug

protected void debug(java.lang.String out)

getDebugPretext

public java.lang.String getDebugPretext()
Returns:

setDebugPretext

public void setDebugPretext(java.lang.String string)
Parameters:
string -