com.miginfocom.ashape.layout
Class RowAShapeLayout

java.lang.Object
  extended by com.miginfocom.ashape.layout.AbstractAShapeLayout
      extended by com.miginfocom.ashape.layout.RowAShapeLayout
All Implemented Interfaces:
AShapeLayout, java.io.Serializable

public class RowAShapeLayout
extends AbstractAShapeLayout

A container that lays out it's sub components in a row/column, quite like BoxLayout but the min/preferred/max sizes, in the laid out dimension, are here optionally specified in the constuctor of this layout.
Size in the non-layed out dimension (width for dim == SwingUtilities.VERTICAL and vice versa) is always set to span the parent's shape bounds.

To evenly force a distribution use:
new RowAShapeLayoutt(SwingConstants.HORIZONTAL, RowAShapeLayoutt.EVEN_DISTR)

See Also:
Serialized Form

Field Summary
protected  int dim
           
static AtRefNumber[] EVEN_DISTR
          Evenly ditributes the sub shapes giving then all the same space within the bounds.
protected  AtRefNumber[] maxSizes
           
protected  AtRefNumber[] minSizes
           
protected  AtRefNumber[] prefSizes
           
 
Constructor Summary
RowAShapeLayout(int dim)
          Constructor where no size are imposed from this layout.
RowAShapeLayout(int dim, AtRefNumber[] prefSizes)
          Constructor.
RowAShapeLayout(int dim, AtRefNumber[] prefSizes, AtRefNumber[] minSizes, AtRefNumber[] maxSizes)
          Constructor.
RowAShapeLayout(int dim, int staticPreferredShapeSize)
          Constructor.
 
Method Summary
 int getDimension()
          Returns the dimension to layout in.
 java.lang.Integer getLayoutSize(AShape parent, int type, int dim, java.lang.Integer otherDimSizeHint)
          Overridden to, in the laid out dimension, add up the sizes rather than to take the smallest/biggest as the default implmentation does.
 AtRefNumber[] getMaximumSizes()
          Returns the maximum sizes.
 AtRefNumber[] getMinimumSizes()
          Returns the minimum sizes.
 AtRefNumber[] getPreferredSizes()
          Return he preferred sizes.
 void layoutShapes(AShape parent)
          Layout the first level sub shapes of the parent and call AShape.layout() on them
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EVEN_DISTR

public static final AtRefNumber[] EVEN_DISTR
Evenly ditributes the sub shapes giving then all the same space within the bounds. Trans into new AtRefNumber[] {new AtFraction(1.0f)}.


dim

protected final transient int dim

minSizes

protected final transient AtRefNumber[] minSizes

prefSizes

protected final transient AtRefNumber[] prefSizes

maxSizes

protected final transient AtRefNumber[] maxSizes
Constructor Detail

RowAShapeLayout

public RowAShapeLayout(int dim)
Constructor where no size are imposed from this layout. All sized are gotten from the shapes.

Parameters:
dim - SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL

RowAShapeLayout

public RowAShapeLayout(int dim,
                       int staticPreferredShapeSize)
Constructor.

Parameters:
dim - SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL
staticPreferredShapeSize - The preferred size that all sub shapes will get. Min/max not set though. Transformed into: new AtRefNumber[] {new AtFixed(staticShapeSize)}.

RowAShapeLayout

public RowAShapeLayout(int dim,
                       AtRefNumber[] prefSizes)
Constructor.

Parameters:
dim - SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL
prefSizes - The preferred sizes. The elements corresponds to the subcomponents.
If null or a shape's corresponding element are null the preferred size of that com.miginfocom.ashape is used.
If elements count is less that the number of sub shapes the last element is used as a substitue.
Distributor.distribute(com.miginfocom.util.gfx.geometry.numbers.AtRefNumber[][], float, boolean) will be used to distribute the shapes (with true set for the last argument) in the laid out dimension.

RowAShapeLayout

public RowAShapeLayout(int dim,
                       AtRefNumber[] prefSizes,
                       AtRefNumber[] minSizes,
                       AtRefNumber[] maxSizes)
Constructor.

Parameters:
dim - SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL
prefSizes - The preferred sizes. The elements corresponds to the subcomponents.
If null or a shape's corresponding element are null the preferred size of that com.miginfocom.ashape is used.
If elements count is less that the number of sub shapes the last element is used as a substitue.
Distributor.distribute(com.miginfocom.util.gfx.geometry.numbers.AtRefNumber[][], float, boolean) will be used to distribute the shapes (with true set for the last argument) in the laid out dimension.
minSizes - Same as prefSizes but denotes the minimum sizes.
maxSizes - Same as prefSizes but denotes the maximum sizes.
Method Detail

getLayoutSize

public java.lang.Integer getLayoutSize(AShape parent,
                                       int type,
                                       int dim,
                                       java.lang.Integer otherDimSizeHint)
Overridden to, in the laid out dimension, add up the sizes rather than to take the smallest/biggest as the default implmentation does.

Specified by:
getLayoutSize in interface AShapeLayout
Overrides:
getLayoutSize in class AbstractAShapeLayout
Parameters:
parent - The shape to return the size for.
type - The type of size to return. E.g. Distributor.MIN.
dim - The dimension for which to return the size. E.g SwingConstants.HORIZONTAL
otherDimSizeHint - On optional size in the not-asked-for dimension. Useful for text shapes that wraps for instance.
Returns:
The size or null there are no answer that makes sense or it isn't set.

layoutShapes

public void layoutShapes(AShape parent)
Description copied from interface: AShapeLayout
Layout the first level sub shapes of the parent and call AShape.layout() on them

Parameters:
parent - The parent which sub shapes should be laid out.

getDimension

public int getDimension()
Returns the dimension to layout in.

Returns:
SwingUtilities.HORIZONTAL or SwingUtilities.VERTICAL

getPreferredSizes

public AtRefNumber[] getPreferredSizes()
Return he preferred sizes. The elements corresponds to the subcomponents.
If null or a shape's corresponding element are null the preferred size of that com.miginfocom.ashape is used.
If elements count is less that the number of sub shapes the last element is used as a substitue.
Distributor.distribute(com.miginfocom.util.gfx.geometry.numbers.AtRefNumber[][], float, boolean) will be used to distribute the shapes (with true set for the last argument) in the laid out dimension.

Returns:
The preferred sizes. May be null and elements may be null.

getMaximumSizes

public AtRefNumber[] getMaximumSizes()
Returns the maximum sizes. See getPreferredSizes() for eplanation.

Returns:
The maximum sizes. May be null and elements may be null.

getMinimumSizes

public AtRefNumber[] getMinimumSizes()
Returns the minimum sizes. See getPreferredSizes() for eplanation.

Returns:
The minimum sizes. May be null and elements may be null.


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.