com.sas.visuals.adapters
Class MinMaxSpacePartitioner

com.sas.visuals.adapters.MinMaxSpacePartitioner
All Implemented Interfaces:
SpacePartitionerInterface, java.io.Serializable
Direct Known Subclasses:
ProportionalSpacePartitioner

public class MinMaxSpacePartitioner
implements SpacePartitionerInterface, java.io.Serializable

The MinMaxSpacePartitioner class is a helper class for the AutoSizingGridLayout. It partitions the total space specified using the preferredSizes passed in to getPartitionedSpace. If the preferred size for an element is less than the minimum for that column, the minimum size is used. If the preferred size for an element is greater than the maximum for that column, the maximum size is used.

Once all the space is given out, no more space will be allocated to elements.

An instance of MinMaxSpacePartitioner can be set on columnSpacePartitioner and/or the rowSpacePartitioner properties of the AutoSizingGridLayout.

See Also:
SpacePartitionerInterface, AutoSizingGridLayout, Serialized Form

Field Summary
protected  boolean giveMoreSpaceThanSpecified
           
protected  int[] maximums
           
protected  int[] minimums
           
 
Constructor Summary
MinMaxSpacePartitioner()
          Constructor.
MinMaxSpacePartitioner(boolean giveMoreSpaceThanSpecified)
          Constructor which allows specifying whether more that the totalSize space may be allocated using in getPartitionedSpace.
MinMaxSpacePartitioner(int[] minimums, int[] maximums)
          Constructor which allows specifying the minimum and maximum sizes of the elements.
MinMaxSpacePartitioner(int[] minimums, int[] maximums, boolean giveMoreSpaceThanSpecified)
          Constructor which allows specifying the minimum and maximum sizes of the elements.
 
Method Summary
protected  int getConstrainedSize(int i, int size, int totalSize, int sizeUsed)
          getConstrainedSize is a helper method which subclasses may use if they do not wish to call super in their getParitionedSpace method.
 int getPartitionedSpace(int[] sizes, int totalSize, int[] preferredSizes)
          getPartitionedSpace partitions the totalSize space between a number of "elements" and returns the sizes of those elements in the sizes array.
 

Field Detail

minimums

protected int[] minimums

maximums

protected int[] maximums

giveMoreSpaceThanSpecified

protected boolean giveMoreSpaceThanSpecified
Constructor Detail

MinMaxSpacePartitioner

public MinMaxSpacePartitioner()
Constructor.


MinMaxSpacePartitioner

public MinMaxSpacePartitioner(boolean giveMoreSpaceThanSpecified)
Constructor which allows specifying whether more that the totalSize space may be allocated using in getPartitionedSpace.

Parameters:
giveMoreSpaceThanSpecified - whether more that the totalSize space may be allocated using in getPartitionedSpace.

MinMaxSpacePartitioner

public MinMaxSpacePartitioner(int[] minimums,
                              int[] maximums)
Constructor which allows specifying the minimum and maximum sizes of the elements.

Parameters:
minimums - Array of minimum sizes for elements. Usually a positive int. If negative, there is no minimum for that element. If minimums is null, there are no minimums for any element.
maximums - Array of maximum sizes for elements. Usually a positive int. If negative, there is no maximum for that element. If maximums is null, there are no maximums for any element.

MinMaxSpacePartitioner

public MinMaxSpacePartitioner(int[] minimums,
                              int[] maximums,
                              boolean giveMoreSpaceThanSpecified)
Constructor which allows specifying the minimum and maximum sizes of the elements.

Parameters:
minimums - Array of minimum sizes for elements. Usually a positive int. If negative, there is no minimum for that element. If minimums is null, there are no minimums for any element.
maximums - Array of maximum sizes for elements. Usually a positive int. If negative, there is no maximum for that element. If maximums is null, there are no maximums for any element.
giveMoreSpaceThanSpecified - whether more that the totalSize space may be allocated using in getPartitionedSpace.
Method Detail

getConstrainedSize

protected int getConstrainedSize(int i,
                                 int size,
                                 int totalSize,
                                 int sizeUsed)
getConstrainedSize is a helper method which subclasses may use if they do not wish to call super in their getParitionedSpace method.

Parameters:
i - The zero based index of the element to determine the size of
size - The preferred size for this element
totalSize - The total amount of space to allocate to the elements
sizeUsed - The amount of totalSize used already
Returns:
The size of the specified element
See Also:
getPartitionedSpace(int[], int, int[])

getPartitionedSpace

public int getPartitionedSpace(int[] sizes,
                               int totalSize,
                               int[] preferredSizes)
getPartitionedSpace partitions the totalSize space between a number of "elements" and returns the sizes of those elements in the sizes array. An array of preferred sizes for the elements is passed in the preferredSizes array. These sizes are used as the base sizes for the elements and then the sizes are adjusted based on the minimum and maximum sizes set earlier.

Specified by:
getPartitionedSpace in interface SpacePartitionerInterface
Parameters:
sizes - An array allocated by the caller for getPartitionedSpace to return the element sizes in.
totalSize - The total available size to partition between the elements.
preferredSizes - The preferred sizes of the elements
Returns:
The amount of space left after allocating space to the elements.
See Also:
SpacePartitionerInterface



Copyright © 2009 SAS Institute Inc. All Rights Reserved.