com.alee.extended.layout
Class AlignLayout

java.lang.Object
  extended by com.alee.extended.layout.AbstractLayoutManager
      extended by com.alee.extended.layout.AlignLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, javax.swing.SwingConstants

public class AlignLayout
extends AbstractLayoutManager
implements javax.swing.SwingConstants

This layout allows you to align components inside the container using the standart Swing constants.

Author:
Mikle Garin

Field Summary
protected  java.util.Map<java.awt.Component,java.lang.String> constraints
          Constraints cache for added components.
protected  boolean hfill
          Whether components should fill all available horizontal space or not.
protected  int hgap
          Horizontal gap between components.
static java.util.List<java.lang.Integer> horizontals
          Horizontal alignment constraints.
static java.lang.String SEPARATOR
          Layout constraints separator.
static java.util.List<java.lang.Integer> verticals
          Vertical alignment constraints.
protected  boolean vfill
          Whether components should fill all available vertical space or not.
protected  int vgap
          Vertical gap between components.
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
AlignLayout()
          Constructs new align layout.
 
Method Summary
 void addComponent(java.awt.Component component, java.lang.Object constraints)
          Caled when component added into container with this layout.
protected  int getHalign(java.lang.String name)
          Returns horizontal alignment for the specified constraint.
 int getHgap()
          Returns horizontal gap between components.
protected  java.awt.Dimension getSideSize(java.awt.Container parent, int halign, int valign)
          Returns size for the side specified by horizontal and vertical alignments.
protected  int getValign(java.lang.String name)
          Returns vertical alignment for the specified constraint.
 int getVgap()
          Returns vertical gap between components.
protected  void illegalArgument()
          Throws illegal argument (constraint) exception.
 boolean isHfill()
          Returns whether components should fill all available horizontal space or not.
 boolean isVfill()
          Returns whether components should fill all available vertical space or not.
 void layoutContainer(java.awt.Container parent)
          
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          
 void removeComponent(java.awt.Component component)
          Called when component removed from container with this layout.
 void setHfill(boolean hfill)
          Sets whether components should fill all available horizontal space or not.
 void setHgap(int hgap)
          Sets horizontal gap between components.
 void setVfill(boolean vfill)
          Sets whether components should fill all available vertical space or not.
 void setVgap(int vgap)
          Sets vertical gap between components.
 
Methods inherited from class com.alee.extended.layout.AbstractLayoutManager
addLayoutComponent, addLayoutComponent, getLayoutAlignmentX, getLayoutAlignmentY, invalidateLayout, maximumLayoutSize, minimumLayoutSize, removeLayoutComponent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEPARATOR

public static final java.lang.String SEPARATOR
Layout constraints separator.

See Also:
Constant Field Values

horizontals

public static final java.util.List<java.lang.Integer> horizontals
Horizontal alignment constraints.


verticals

public static final java.util.List<java.lang.Integer> verticals
Vertical alignment constraints.


constraints

protected final java.util.Map<java.awt.Component,java.lang.String> constraints
Constraints cache for added components.


hgap

protected int hgap
Horizontal gap between components.


vgap

protected int vgap
Vertical gap between components.


hfill

protected boolean hfill
Whether components should fill all available horizontal space or not.


vfill

protected boolean vfill
Whether components should fill all available vertical space or not.

Constructor Detail

AlignLayout

public AlignLayout()
Constructs new align layout.

Method Detail

getHgap

public int getHgap()
Returns horizontal gap between components.

Returns:
horizontal gap between components

setHgap

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

Parameters:
hgap - new horizontal gap between components

getVgap

public int getVgap()
Returns vertical gap between components.

Returns:
vertical gap between components

setVgap

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

Parameters:
vgap - new vertical gap between components

isHfill

public boolean isHfill()
Returns whether components should fill all available horizontal space or not.

Returns:
true if components should fill all available horizontal space, false otherwise

setHfill

public void setHfill(boolean hfill)
Sets whether components should fill all available horizontal space or not.

Parameters:
hfill - whether components should fill all available horizontal space or not

isVfill

public boolean isVfill()
Returns whether components should fill all available vertical space or not.

Returns:
true if components should fill all available vertical space, false otherwise

setVfill

public void setVfill(boolean vfill)
Sets whether components should fill all available vertical space or not.

Parameters:
vfill - whether components should fill all available vertical space or not

addComponent

public void addComponent(java.awt.Component component,
                         java.lang.Object constraints)
Caled when component added into container with this layout.

Overrides:
addComponent in class AbstractLayoutManager
Parameters:
component - added component
constraints - component constraints

illegalArgument

protected void illegalArgument()
Throws illegal argument (constraint) exception.


getHalign

protected int getHalign(java.lang.String name)
Returns horizontal alignment for the specified constraint.

Parameters:
name - constraint
Returns:
horizontal alignment

getValign

protected int getValign(java.lang.String name)
Returns vertical alignment for the specified constraint.

Parameters:
name - constraint
Returns:
vertical alignment

removeComponent

public void removeComponent(java.awt.Component component)
Called when component removed from container with this layout.

Overrides:
removeComponent in class AbstractLayoutManager
Parameters:
component - removed component

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager

getSideSize

protected java.awt.Dimension getSideSize(java.awt.Container parent,
                                         int halign,
                                         int valign)
Returns size for the side specified by horizontal and vertical alignments.

Parameters:
parent - container
halign - horizontal alignment
valign - vertical alignment
Returns:
size for the side specified by horizontal and vertical alignments

layoutContainer

public void layoutContainer(java.awt.Container parent)

Specified by:
layoutContainer in interface java.awt.LayoutManager