de.pxclass.gui
Class PXElasticLayout

java.lang.Object
  extended by de.pxclass.gui.PXElasticLayout
All Implemented Interfaces:
java.awt.LayoutManager, java.awt.LayoutManager2, java.io.Serializable

public class PXElasticLayout
extends java.lang.Object
implements java.awt.LayoutManager2, java.io.Serializable

A layout manager.

Since:
0.9
Version:
$Revision: 72 $
Author:
D. Starke
See Also:
Serialized Form

Field Summary
protected  de.pxclass.gui.PXElasticLayout.CellArea cellArea
          the layout information
protected  java.util.Map constraintsMap
          This Map maintains the association between a component and its constraints.
 
Constructor Summary
PXElasticLayout()
          Creates a new PXElasticLayout layout manager.
PXElasticLayout(int columnGap, int rowGap)
          Creates a new PXElasticLayout layout manager.
PXElasticLayout(int columnGap, int rowGap, int outerHorizontalGap, int outerVerticalGap)
          Creates a new PXElasticLayout layout manager.
PXElasticLayout(int columnGap, int rowGap, int outerTopGap, int outerLeftGap, int outerBottomGap, int outerRightGap)
          Creates a new PXElasticLayout layout manager.
 
Method Summary
 void addLayoutComponent(java.awt.Component comp, java.lang.Object constraints)
          Adds the specified component to the layout, using the specified constraints object.
 void addLayoutComponent(java.lang.String name, java.awt.Component comp)
          Has no effect, since this layout manager does not use a per-component string.
 int getColumnGap()
          Gets the horizontal gap between columns.
 PXElasticConstraints getConstraints(java.awt.Component comp)
          Gets the constraints for the specified component.
protected  PXElasticConstraints getConstraintsImpl(java.awt.Component comp)
          Retrieves the constraints for the specified component.
 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 getOuterBottomGap()
          Gets the vertical gap between the bottom-most component to the edge of the container.
 int getOuterLeftGap()
          Gets the horizontal gap between the left-most component and the edge of the container.
 int getOuterRightGap()
          Gets the horizontal gap between the right-most component and the edge of the container.
 int getOuterTopGap()
          Gets the vertical gap between the top-most component and the edge of the container.
 int getRowGap()
          Gets the vertical gap between rows.
 void invalidateLayout(java.awt.Container target)
          Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
protected  void invalidateLayoutInfo()
          Invalidates the layout, cached information of this layout manager is discarded.
 boolean isHeedingInvisibleComponents()
          Gets whether or not invisible components are heeded in layout calculations.
protected  boolean isLayoutInfoValid()
          Gets whether or not the layout information of this layout manager is valid.
 void layoutContainer(java.awt.Container parent)
          Lays out the specified container using this grid bag layout.
 java.awt.Dimension maximumLayoutSize(java.awt.Container parent)
          Returns the maximum dimensions for this layout given the components in the specified target container.
 java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
          Determines the minimum size of the parent container using this PXElasticLayout.
 java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
          Determines the preferred size of the parent container using this PXElasticLayout.
 void removeLayoutComponent(java.awt.Component comp)
          Removes the specified component from this layout.
 void setColumnGap(int columnGap)
          Sets the horizontal gap between columns.
 void setConstraints(java.awt.Component comp, PXElasticConstraints constraints)
          Sets the constraints for the specified component in this layout.
protected  void setConstraintsImpl(java.awt.Component comp, PXElasticConstraints constraints)
          Sets the constraints for the specified component in this layout.
 void setDebugMode(boolean enabled)
          Sets the debug mode of this PXElasticLayout object.
 void setHeedingInvisibleComponents(boolean heedingInvisibleComp)
          Sets whether or not invisible components are heeded in layout calculations.
 void setOuterBottomGap(int outerBottomGap)
          Sets the vertical gap between the bottom-most component to the edge of the container.
 void setOuterLeftGap(int outerLeftGap)
          Sets the horizontal gap between the left-most component and the edge of the container.
 void setOuterRightGap(int outerRightGap)
          Sets the horizontal gap between the right-most component and the edge of the container.
 void setOuterTopGap(int outerTopGap)
          Sets the vertical gap between the top-most component and the edge of the container.
 void setRowGap(int rowGap)
          Sets the vertical gap between rows.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

constraintsMap

protected final java.util.Map constraintsMap
This Map maintains the association between a component and its constraints. The Keys in the map are the components and the values are the instances of PXElasticConstraints.


cellArea

protected de.pxclass.gui.PXElasticLayout.CellArea cellArea
the layout information

Constructor Detail

PXElasticLayout

public PXElasticLayout()
Creates a new PXElasticLayout layout manager.


PXElasticLayout

public PXElasticLayout(int columnGap,
                       int rowGap)
Creates a new PXElasticLayout layout manager.

Parameters:
columnGap - the gap between columns
rowGap - the gap between rows

PXElasticLayout

public PXElasticLayout(int columnGap,
                       int rowGap,
                       int outerHorizontalGap,
                       int outerVerticalGap)
Creates a new PXElasticLayout layout manager.

Parameters:
columnGap - the gap between columns
rowGap - the gap between rows
outerHorizontalGap - the gap between the parent container and the first and the last row
outerVerticalGap - the gap between the parent container and the first and the last column

PXElasticLayout

public PXElasticLayout(int columnGap,
                       int rowGap,
                       int outerTopGap,
                       int outerLeftGap,
                       int outerBottomGap,
                       int outerRightGap)
Creates a new PXElasticLayout layout manager.

Parameters:
columnGap - the gap between columns
rowGap - the gap between rows
outerTopGap - the gap between the parent container and the first row
outerLeftGap - the gap between the parent container and the first column
outerBottomGap - the gap between the parent container and the last row
outerRightGap - the gap between the parent container and the last column
Method Detail

getColumnGap

public int getColumnGap()
Gets the horizontal gap between columns.

Returns:
the column gap to set
See Also:
setColumnGap(int)

setColumnGap

public void setColumnGap(int columnGap)
Sets the horizontal gap between columns.

Parameters:
columnGap - the column gap
See Also:
getColumnGap()

getRowGap

public int getRowGap()
Gets the vertical gap between rows.

Returns:
the row gap
See Also:
setRowGap(int)

setRowGap

public void setRowGap(int rowGap)
Sets the vertical gap between rows.

Parameters:
rowGap - the row gap
See Also:
getRowGap()

getOuterTopGap

public int getOuterTopGap()
Gets the vertical gap between the top-most component and the edge of the container.

Returns:
the outer top gap
See Also:
setOuterTopGap(int)

setOuterTopGap

public void setOuterTopGap(int outerTopGap)
Sets the vertical gap between the top-most component and the edge of the container.

Parameters:
outerTopGap - the outer top gap to set
See Also:
getOuterTopGap()

getOuterLeftGap

public int getOuterLeftGap()
Gets the horizontal gap between the left-most component and the edge of the container.

Returns:
the outer left gap
See Also:
setOuterLeftGap(int)

setOuterLeftGap

public void setOuterLeftGap(int outerLeftGap)
Sets the horizontal gap between the left-most component and the edge of the container.

Parameters:
outerLeftGap - the outer left gap to set
See Also:
getOuterLeftGap()

getOuterBottomGap

public int getOuterBottomGap()
Gets the vertical gap between the bottom-most component to the edge of the container.

Returns:
the outer bottom gap
See Also:
setOuterBottomGap(int)

setOuterBottomGap

public void setOuterBottomGap(int outerBottomGap)
Sets the vertical gap between the bottom-most component to the edge of the container.

Parameters:
outerBottomGap - the outer bottom gap to set
See Also:
getOuterBottomGap()

getOuterRightGap

public int getOuterRightGap()
Gets the horizontal gap between the right-most component and the edge of the container.

Returns:
the outer right gap
See Also:
setOuterRightGap(int)

setOuterRightGap

public void setOuterRightGap(int outerRightGap)
Sets the horizontal gap between the right-most component and the edge of the container.

Parameters:
outerRightGap - the outer right gap to set
See Also:
getOuterRightGap()

setConstraints

public void setConstraints(java.awt.Component comp,
                           PXElasticConstraints constraints)
Sets the constraints for the specified component in this layout.

Parameters:
comp - the component to be modified
constraints - the constraints to be applied

setConstraintsImpl

protected void setConstraintsImpl(java.awt.Component comp,
                                  PXElasticConstraints constraints)
Sets the constraints for the specified component in this layout.

Parameters:
comp - the component to be modified
constraints - the constraints to be applied

setDebugMode

public void setDebugMode(boolean enabled)
Sets the debug mode of this PXElasticLayout object.

Parameters:
enabled - true enables the debug mode, false disables it

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
Returns:
0.5f

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
Returns:
0.5f

getConstraints

public PXElasticConstraints getConstraints(java.awt.Component comp)
Gets the constraints for the specified component. A copy of the actual PXElasticConstraints object is returned.

Parameters:
comp - the component to be queried
Returns:
the constraint for the specified component in this PXElasticLayout; a copy of the actual constraint object is returned.

addLayoutComponent

public void addLayoutComponent(java.lang.String name,
                               java.awt.Component comp)
Has no effect, since this layout manager does not use a per-component string.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager
Parameters:
name - the string to be associated with 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 constraints object.

Please note:
Constraints are mutable and are, therefore, cloned when cached.

Specified by:
addLayoutComponent in interface java.awt.LayoutManager2
Parameters:
comp - the component to be added
constraints - an object that determines how the component is added to the layout
Throws:
java.lang.IllegalArgumentException - if constraints is not a PXElasticConstraints

removeLayoutComponent

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

Most applications do not call this method directly.

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

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

minimumLayoutSize

public java.awt.Dimension minimumLayoutSize(java.awt.Container parent)
Determines the minimum size of the parent container using this PXElasticLayout.

Most applications do not call this method directly.

Specified by:
minimumLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the container in which to do the layout
Returns:
the minimum size of the parent container

preferredLayoutSize

public java.awt.Dimension preferredLayoutSize(java.awt.Container parent)
Determines the preferred size of the parent container using this PXElasticLayout.

Most applications do not call this method directly.

Specified by:
preferredLayoutSize in interface java.awt.LayoutManager
Parameters:
parent - the container in which to do the layout
Returns:
the preferred size of the parent container

maximumLayoutSize

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

Specified by:
maximumLayoutSize in interface java.awt.LayoutManager2
Parameters:
parent - the container in which to do the layout
Returns:
the maximum size of the parent container

layoutContainer

public void layoutContainer(java.awt.Container parent)
Lays out the specified container using this grid bag layout. This method reshapes components in the specified container in order to satisfy the contraints of this PXElasticLayout.

Most applications do not call this method directly.

Specified by:
layoutContainer in interface java.awt.LayoutManager
Parameters:
parent - the container in which to do the layout

isLayoutInfoValid

protected boolean isLayoutInfoValid()
Gets whether or not the layout information of this layout manager is valid.

Returns:
true if the layout information of this layout manager is valid, else false

getConstraintsImpl

protected PXElasticConstraints getConstraintsImpl(java.awt.Component comp)
Retrieves the constraints for the specified component. The return value is not a copy, but is the actual GridBagConstraints object used by the layout mechanism.

Parameters:
comp - the component to be queried
Returns:
the contraints for the specified component

invalidateLayoutInfo

protected void invalidateLayoutInfo()
Invalidates the layout, cached information of this layout manager is discarded.


setHeedingInvisibleComponents

public void setHeedingInvisibleComponents(boolean heedingInvisibleComp)
Sets whether or not invisible components are heeded in layout calculations.

Parameters:
heedingInvisibleComp - true, if invisible components should be heeded when calculating the layout, else false
See Also:
isHeedingInvisibleComponents()

isHeedingInvisibleComponents

public boolean isHeedingInvisibleComponents()
Gets whether or not invisible components are heeded in layout calculations.

Returns:
true, if invisible components are heeded when calculating the layout, else false
See Also:
setHeedingInvisibleComponents(boolean)


Copyright © 2008. All Rights Reserved.