com.sas.visuals.adapters
Class ProportionalSpacePartitioner

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

public class ProportionalSpacePartitioner

The ProportionalSpacePartitioner class is a helper class for the AutoSizingGridLayout. It partitions the total space specified in the proportions specified between the elements (rows/columns) of the passed in array. If the PREFERRED_SIZE param is used in the percentages array, that element should receive its preferred size while the rest of the percentages should still add up to equal 1.

If minumum and maximum sizes are specified, the ProportionalSpacePartitioner may run out of space when distributing between elements. In this case, elements will be given space in ascending order. Once all the space is given out, no more space will be allocated to elements.

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

See Also:
SpacePartitionerInterface, AutoSizingGridLayout, Serialized Form

Field Summary
protected  double[] percentages
           
static double PREFERRED_SIZE
          Used as a value to indicate to set the size as the preferred size instead of usign a percentage
 
Fields inherited from class com.sas.visuals.adapters.MinMaxSpacePartitioner
giveMoreSpaceThanSpecified, maximums, minimums
 
Constructor Summary
ProportionalSpacePartitioner()
          Constructor.
ProportionalSpacePartitioner(double[] percentages)
          Constructor which allows specifying the percentages given to each element (row/column).
ProportionalSpacePartitioner(double[] percentages, int[] minimums, int[] maximums)
          Constructor which allows specifying the percentages given to each element (row/column) as well as the minimum and maximum sizes of the elements.
ProportionalSpacePartitioner(double[] percentages, int[] minimums, int[] maximums, boolean giveMoreSpaceThanSpecified)
          Constructor which allows specifying the percentages given to each element (row/column) as well as the minimum and maximum sizes of the elements.
 
Method Summary
 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.
 double[] getPercentages()
          Returns the percentages determining how much of totalSize to allocate to each element.
 void setPercentages(double[] percentages)
          Set the percentages determining how much of totalSize to allocate to each element.
 
Methods inherited from class com.sas.visuals.adapters.MinMaxSpacePartitioner
getConstrainedSize
 

Field Detail

PREFERRED_SIZE

public static final double PREFERRED_SIZE
Used as a value to indicate to set the size as the preferred size instead of usign a percentage

See Also:
Constant Field Values

percentages

protected double[] percentages
Constructor Detail

ProportionalSpacePartitioner

public ProportionalSpacePartitioner()
Constructor. Calls ProportionalSpacePartitioner( null, null, null );


ProportionalSpacePartitioner

public ProportionalSpacePartitioner(double[] percentages)
Constructor which allows specifying the percentages given to each element (row/column). Calls ProportionalSpacePartitioner( percentages, null, null );

Parameters:
percentages - Fractional percentages determining how much of totalSize to allocate to each element. If PREFERRED_SIZE is used as a param, then that element should receive its preferred sizes and should have no bearing on the other percentages.

ProportionalSpacePartitioner

public ProportionalSpacePartitioner(double[] percentages,
                                    int[] minimums,
                                    int[] maximums)
Constructor which allows specifying the percentages given to each element (row/column) as well as the minimum and maximum sizes of the elements. Calls ProportionalSpacePartitioner( percentages, minimums, maximums, true );

Parameters:
percentages - Fractional percentages determining how much of totalSize to allocate to each element. If PREFERRED_SIZE is used as a param, then that element should receive its preferred sizes and should have no bearing on the other percentages.
minimums - Array of minimum sizes for the elements.
maximums - Array of maximum sizes for the elements.

ProportionalSpacePartitioner

public ProportionalSpacePartitioner(double[] percentages,
                                    int[] minimums,
                                    int[] maximums,
                                    boolean giveMoreSpaceThanSpecified)
Constructor which allows specifying the percentages given to each element (row/column) as well as the minimum and maximum sizes of the elements.

Parameters:
percentages - Fractional percentages determining how much of totalSize to allocate to each element. If PREFERRED_SIZE is used as a param, then that element should receive its preferred sizes and should have no bearing on the other percentages.
minimums - Array of minimum sizes for the elements.
maximums - Array of maximum sizes for the elements.
giveMoreSpaceThanSpecified - Whether to allocate more than totalSize to the elements is necessary to meet minimum and maximum requirements.
Method Detail

getPartitionedSpace

public int getPartitionedSpace(int[] sizes,
                               int totalSize,
                               int[] preferredSizes)
Description copied from class: MinMaxSpacePartitioner
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
Overrides:
getPartitionedSpace in class MinMaxSpacePartitioner
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.getPartitionedSpace(int[], int, int[])

getPercentages

public double[] getPercentages()
Returns the percentages determining how much of totalSize to allocate to each element.

Parameters:
percentages - Fractional percentages determining how much of totalSize to allocate to each element.
See Also:
setPercentages(double[])

setPercentages

public void setPercentages(double[] percentages)
Set the percentages determining how much of totalSize to allocate to each element.

See Also:
getPercentages()



Copyright © 2009 SAS Institute Inc. All Rights Reserved.