com.sas.visuals.adapters
Class EqualSpacePartitioner

com.sas.visuals.adapters.EqualSpacePartitioner
All Implemented Interfaces:
SpacePartitionerInterface, java.io.Serializable

public class EqualSpacePartitioner
implements SpacePartitionerInterface, java.io.Serializable

The EqualSpacePartitioner class is a helper class for the AutoSizingGridLayout. The EqualSpacePartitioner operates in two modes. Either it will divide the total available space between the number of available parts, or it will determine the preferred size of the largest part and give that much space to each part. The default is to use the preferred size of the largest part for each part.

The minimumSize and maximumSize properties constrain the sizes returned by getPartitionedSpace. Once the size of each part is determined based on the mode of operation, the minimum size and maximum size are used to adjust the size of each part. If minimumSize or maximumSize is zero, that constraint is ignored.

An instance of EqualSpacePartitioner can be set on the columnSpacePartitioner and/or rowSpacePartitioner property of the AutoSizingGridLayout.

See Also:
SpacePartitionerInterface, AutoSizingGridLayout, Serialized Form

Field Summary
protected  boolean divideTotalSpace
           
protected  int maximumSize
           
protected  int minimumSize
           
protected  boolean[] partitionsToDivide
           
 
Constructor Summary
EqualSpacePartitioner()
          Default contructor.
EqualSpacePartitioner(boolean divideTotalSpace)
          Contructor.
 
Method Summary
protected  int constrainSize(int size)
          Helper method used to constrain the passed in size based on the minimumSize and maximumSize properties.
 int getMaximumSize()
          Returns the maximum size of the parts.
 int getMinimumSize()
          Returns the minimum size of the parts.
 int getPartitionedSpace(int[] sizes, int totalSize, int[] preferredSizes)
          Partition the space represented by totalSize into parts and store the resulting size in the sizes array.
 boolean isDivideTotalSpace()
           
 void setDivideTotalSpace(boolean divideTotalSpace)
           
 void setMaximumSize(int maximumSize)
          Sets the maximum size of the parts.
 void setMinimumSize(int minimumSize)
          Sets the minimum size of the parts.
 

Field Detail

divideTotalSpace

protected boolean divideTotalSpace

minimumSize

protected int minimumSize

maximumSize

protected int maximumSize

partitionsToDivide

protected boolean[] partitionsToDivide
Constructor Detail

EqualSpacePartitioner

public EqualSpacePartitioner()
Default contructor. Calls this( false ).


EqualSpacePartitioner

public EqualSpacePartitioner(boolean divideTotalSpace)
Contructor. Sets the divideTotalSpace property.

Parameters:
divideTotalSpace - Whether to divide the total available space between the number of available parts or to determine the preferred size of the largest part and give that much space to each part, if there is extra space left over, it is distributed equally amongst the parts.
Method Detail

constrainSize

protected int constrainSize(int size)
Helper method used to constrain the passed in size based on the minimumSize and maximumSize properties.

Parameters:
size - The size to constrain.

getPartitionedSpace

public int getPartitionedSpace(int[] sizes,
                               int totalSize,
                               int[] preferredSizes)
Description copied from interface: SpacePartitionerInterface
Partition the space represented by totalSize into parts and store the resulting size in the sizes array. preferredSizes may also be passed in to specify a preferred size for each of the parts.

Note that the length of the sizes array and the preferredSizes array should be equal if the preferredSizes array is specified.

Specified by:
getPartitionedSpace in interface SpacePartitionerInterface
Parameters:
sizes - The array to return the sizes of the parts in.
totalSize - The amount of space to split up between the parts.
preferredSizes - The preferred size of the parts. This may be null to indicate that no preferred size is available.
Returns:
The amount of totalSize left over after the space has been allocated. Note that for some implementations, this value may be negative.
See Also:
SpacePartitionerInterface.getPartitionedSpace(int[], int, int[])

getMinimumSize

public int getMinimumSize()
Returns the minimum size of the parts. Once the size is determined based on the mode of operation, the minimum and maximum size restrictions are applied.

Returns:
the minimum size of the parts
See Also:
setMinimumSize(int), getMaximumSize(), setMaximumSize(int)

setMinimumSize

public void setMinimumSize(int minimumSize)
Sets the minimum size of the parts. Once the size is determined based on the mode of operation, the minimum and maximum size restrictions are applied.

Parameters:
minimumSize - the minimum size of the parts
See Also:
getMinimumSize(), getMaximumSize(), setMaximumSize(int)

getMaximumSize

public int getMaximumSize()
Returns the maximum size of the parts. Once the size is determined based on the mode of operation, the minimum and maximum size restrictions are applied.

Returns:
the minimum size of the parts
See Also:
setMaximumSize(int), getMinimumSize(), setMinimumSize(int)

setMaximumSize

public void setMaximumSize(int maximumSize)
Sets the maximum size of the parts. Once the size is determined based on the mode of operation, the minimum and maximum size restrictions are applied.

Parameters:
maximumSize - the maximum size of the parts
See Also:
getMaximumSize(), getMinimumSize(), setMinimumSize(int)

isDivideTotalSpace

public boolean isDivideTotalSpace()

setDivideTotalSpace

public void setDivideTotalSpace(boolean divideTotalSpace)



Copyright © 2009 SAS Institute Inc. All Rights Reserved.