javax.swing
Class SizeRequirements

java.lang.Object
  |
  +--javax.swing.SizeRequirements
All Implemented Interfaces:
Serializable

public class SizeRequirements
extends Object
implements Serializable

Safe:

See Also:
Serialized Form

Field Summary
 float alignment
          Suppressed: The alignment, specified as a value between 0.0 and 1.0, inclusive.
 int maximum
          Suppressed: The maximum size allowed.
 int minimum
          Suppressed: The minimum size required.
 int preferred
          Suppressed: The preferred (natural) size.
 
Constructor Summary
SizeRequirements()
          Enabled: Creates a SizeRequirements object with the minimum, preferred, and maximum sizes set to zero and an alignment value of 0.5 (centered).
SizeRequirements(int min, int pref, int max, float a)
          Enabled: Creates a SizeRequirements object with the specified minimum, preferred, and maximum sizes and the specified alignment.
 
Method Summary
static int[] adjustSizes(int delta, SizeRequirements[] children)
          Enabled: Adjust a specified array of sizes by a given amount.
static void calculateAlignedPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans)
          Enabled: Creates a bunch of offset/span pairs specifying how to lay out a set of components with the specified alignments.
static void calculateAlignedPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans, boolean normal)
          Enabled: Creates a set of offset/span pairs specifying how to lay out a set of components with the specified alignments.
static void calculateTiledPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans)
          Enabled: Creates a set of offset/span pairs representing how to lay out a set of components end-to-end.
static void calculateTiledPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans, boolean forward)
          Enabled: Creates a set of offset/span pairs representing how to lay out a set of components end-to-end.
private static void compressedTile(int allocated, long min, long pref, long max, SizeRequirements[] request, int[] offsets, int[] spans, boolean forward)
           
private static void expandedTile(int allocated, long min, long pref, long max, SizeRequirements[] request, int[] offsets, int[] spans, boolean forward)
           
static SizeRequirements getAlignedSizeRequirements(SizeRequirements[] children)
          Enabled: Determines the total space necessary to align a set of components.
static SizeRequirements getTiledSizeRequirements(SizeRequirements[] children)
          Enabled: Determines the total space necessary to place a set of components end-to-end.
 String toString()
          Suppressed: Returns a string describing the minimum, preferred, and maximum size requirements, along with the alignment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

minimum

public int minimum
Suppressed: The minimum size required. For a component comp, this should be equal to either comp.getMinimumSize().width or comp.getMinimumSize().height.


preferred

public int preferred
Suppressed: The preferred (natural) size. For a component comp, this should be equal to either comp.getPreferredSize().width or comp.getPreferredSize().height.


maximum

public int maximum
Suppressed: The maximum size allowed. For a component comp, this should be equal to either comp.getMaximumSize().width or comp.getMaximumSize().height.


alignment

public float alignment
Suppressed: The alignment, specified as a value between 0.0 and 1.0, inclusive. To specify centering, the alignment should be 0.5.

Constructor Detail

SizeRequirements

public SizeRequirements()
Enabled: Creates a SizeRequirements object with the minimum, preferred, and maximum sizes set to zero and an alignment value of 0.5 (centered).


SizeRequirements

public SizeRequirements(int min,
                        int pref,
                        int max,
                        float a)
Enabled: Creates a SizeRequirements object with the specified minimum, preferred, and maximum sizes and the specified alignment.

Parameters:
min - the minimum size >= 0
pref - the preferred size >= 0
max - the maximum size >= 0
a - the alignment >= 0.0f && <= 1.0f
Method Detail

toString

public String toString()
Suppressed: Returns a string describing the minimum, preferred, and maximum size requirements, along with the alignment.

Overrides:
toString in class Object
Returns:
the string

getTiledSizeRequirements

public static SizeRequirements getTiledSizeRequirements(SizeRequirements[] children)
Enabled: Determines the total space necessary to place a set of components end-to-end. The needs of each component in the set are represented by an entry in the passed-in SizeRequirements array. The returned SizeRequirements object has an alignment of 0.5 (centered). The space requirement is never more than Integer.MAX_VALUE.

Parameters:
children - the space requirements for a set of components. The vector may be of zero length, which will result in a default SizeRequirements object instance being passed back.
Returns:
the total space requirements.

getAlignedSizeRequirements

public static SizeRequirements getAlignedSizeRequirements(SizeRequirements[] children)
Enabled: Determines the total space necessary to align a set of components. The needs of each component in the set are represented by an entry in the passed-in SizeRequirements array. The total space required will never be more than Integer.MAX_VALUE.

Parameters:
children - the set of child requirements. If of zero length, the returns result will be a default instance of SizeRequirements.
Returns:
the total space requirements.

calculateTiledPositions

public static void calculateTiledPositions(int allocated,
                                           SizeRequirements total,
                                           SizeRequirements[] children,
                                           int[] offsets,
                                           int[] spans)
Enabled: Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. This method requires that you specify the total amount of space to be allocated, the size requirements for each component to be placed (specified as an array of SizeRequirements), and the total size requirement of the set of components. You can get the total size requirement by invoking the getTiledSizeRequirements method. The components will be tiled in the forward direction with offsets increasing from 0.

Parameters:
allocated - the total span to be allocated >= 0.
total - the total of the children requests. This argument is optional and may be null.
children - the size requirements for each component.
offsets - the offset from 0 for each child where the spans were allocated (determines placement of the span).
spans - the span allocated for each child to make the total target span.

calculateTiledPositions

public static void calculateTiledPositions(int allocated,
                                           SizeRequirements total,
                                           SizeRequirements[] children,
                                           int[] offsets,
                                           int[] spans,
                                           boolean forward)
Enabled: Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. This method requires that you specify the total amount of space to be allocated, the size requirements for each component to be placed (specified as an array of SizeRequirements), and the total size requirement of the set of components. You can get the total size requirement by invoking the getTiledSizeRequirements method. This method also requires a flag indicating whether components should be tiled in the forward direction (offsets increasing from 0) or reverse direction (offsets decreasing from the end of the allocated space). The forward direction represents components tiled from left to right or top to bottom. The reverse direction represents components tiled from right to left or bottom to top.

Parameters:
allocated - the total span to be allocated >= 0.
total - the total of the children requests. This argument is optional and may be null.
children - the size requirements for each component.
offsets - the offset from 0 for each child where the spans were allocated (determines placement of the span).
spans - the span allocated for each child to make the total target span.
forward - tile with offsets increasing from 0 if true and with offsets decreasing from the end of the allocated space if false.

compressedTile

private static void compressedTile(int allocated,
                                   long min,
                                   long pref,
                                   long max,
                                   SizeRequirements[] request,
                                   int[] offsets,
                                   int[] spans,
                                   boolean forward)

expandedTile

private static void expandedTile(int allocated,
                                 long min,
                                 long pref,
                                 long max,
                                 SizeRequirements[] request,
                                 int[] offsets,
                                 int[] spans,
                                 boolean forward)

calculateAlignedPositions

public static void calculateAlignedPositions(int allocated,
                                             SizeRequirements total,
                                             SizeRequirements[] children,
                                             int[] offsets,
                                             int[] spans)
Enabled: Creates a bunch of offset/span pairs specifying how to lay out a set of components with the specified alignments. The resulting span allocations will overlap, with each one fitting as well as possible into the given total allocation. This method requires that you specify the total amount of space to be allocated, the size requirements for each component to be placed (specified as an array of SizeRequirements), and the total size requirements of the set of components (only the alignment field of which is actually used). You can get the total size requirement by invoking getAlignedSizeRequirements. Normal alignment will be done with an alignment value of 0.0f representing the left/top edge of a component.

Parameters:
allocated - the total span to be allocated >= 0.
total - the total of the children requests.
children - the size requirements for each component.
offsets - the offset from 0 for each child where the spans were allocated (determines placement of the span).
spans - the span allocated for each child to make the total target span.

calculateAlignedPositions

public static void calculateAlignedPositions(int allocated,
                                             SizeRequirements total,
                                             SizeRequirements[] children,
                                             int[] offsets,
                                             int[] spans,
                                             boolean normal)
Enabled: Creates a set of offset/span pairs specifying how to lay out a set of components with the specified alignments. The resulting span allocations will overlap, with each one fitting as well as possible into the given total allocation. This method requires that you specify the total amount of space to be allocated, the size requirements for each component to be placed (specified as an array of SizeRequirements), and the total size requirements of the set of components (only the alignment field of which is actually used) You can get the total size requirement by invoking getAlignedSizeRequirements. This method also requires a flag indicating whether normal or reverse alignment should be performed. With normal alignment the value 0.0f represents the left/top edge of the component to be aligned. With reverse alignment, 0.0f represents the right/bottom edge.

Parameters:
allocated - the total span to be allocated >= 0.
total - the total of the children requests.
children - the size requirements for each component.
offsets - the offset from 0 for each child where the spans were allocated (determines placement of the span).
spans - the span allocated for each child to make the total target span.
normal - when true, the alignment value 0.0f means left/top; when false, it means right/bottom.

adjustSizes

public static int[] adjustSizes(int delta,
                                SizeRequirements[] children)
Enabled: Adjust a specified array of sizes by a given amount.

Parameters:
delta - an int specifying the size difference
children - an array of SizeRequirements objects
Returns:
an array of ints containing the final size for each item


comments?