Class SizeRequirements
- All Implemented Interfaces:
Serializable
public class SizeRequirements extends Object implements Serializable
- tiled
- The components are placed end-to-end, starting either at coordinate 0 (the leftmost or topmost position) or at the coordinate representing the end of the allocated span (the rightmost or bottommost position).
- aligned
- The components are aligned as specified by each component's X or Y alignment value.
Each SizeRequirements object contains information about either the width (and X alignment) or height (and Y alignment) of a single component or a group of components:
minimum
- The smallest reasonable width/height of the component or component group, in pixels.
preferred
- The natural width/height of the component or component group, in pixels.
maximum
- The largest reasonable width/height of the component or component group, in pixels.
alignment
- The X/Y alignment of the component or component group.
Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. As of 1.4, support for long term storage of all JavaBeans has been added to the java.beans
package. Please see XMLEncoder
.
Field Summary
Modifier and Type | Field | Description |
---|---|---|
float |
alignment |
The alignment, specified as a value between 0.0 and 1.0, inclusive. |
int |
maximum |
The maximum size allowed. |
int |
minimum |
The minimum size required. |
int |
preferred |
The preferred (natural) size. |
Constructor Summary
Constructor | Description |
---|---|
SizeRequirements() |
Creates a SizeRequirements object with the minimum, preferred, and maximum sizes set to zero and an alignment value of 0.5 (centered). |
SizeRequirements |
Creates a SizeRequirements object with the specified minimum, preferred, and maximum sizes and the specified alignment. |
Method Summary
Modifier and Type | Method | Description |
---|---|---|
static int[] |
adjustSizes |
Adjust a specified array of sizes by a given amount. |
static void |
calculateAlignedPositions |
Creates a bunch of offset/span pairs specifying how to lay out a set of components with the specified alignments. |
static void |
calculateAlignedPositions |
Creates a set of offset/span pairs specifying how to lay out a set of components with the specified alignments. |
static void |
calculateTiledPositions |
Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. |
static void |
calculateTiledPositions |
Creates a set of offset/span pairs representing how to lay out a set of components end-to-end. |
static SizeRequirements |
getAlignedSizeRequirements |
Determines the total space necessary to align a set of components. |
static SizeRequirements |
getTiledSizeRequirements |
Determines the total space necessary to place a set of components end-to-end. |
String |
toString() |
Returns a string describing the minimum, preferred, and maximum size requirements, along with the alignment. |
Field Details
minimum
public int minimum
comp
, this should be equal to either comp.getMinimumSize().width
or comp.getMinimumSize().height
.preferred
public int preferred
comp
, this should be equal to either comp.getPreferredSize().width
or comp.getPreferredSize().height
.maximum
public int maximum
comp
, this should be equal to either comp.getMaximumSize().width
or comp.getMaximumSize().height
.alignment
public float alignment
Constructor Details
SizeRequirements
public SizeRequirements()
SizeRequirements
public SizeRequirements(int min, int pref, int max, float a)
- Parameters:
-
min
- the minimum size >= 0 -
pref
- the preferred size >= 0 -
max
- the maximum size >= 0 -
a
- the alignment >= 0.0f && <= 1.0f
Method Details
toString
public String toString()
getTiledSizeRequirements
public static SizeRequirements getTiledSizeRequirements(SizeRequirements[] children)
- 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)
- 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)
- 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)
- 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. - Since:
- 1.4
calculateAlignedPositions
public static void calculateAlignedPositions(int allocated, SizeRequirements total, SizeRequirements[] children, int[] offsets, int[] spans)
- 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)
- 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. - Since:
- 1.4
adjustSizes
public static int[] adjustSizes(int delta, SizeRequirements[] children)
- 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
© 1993, 2021, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/17/docs/api/java.desktop/javax/swing/SizeRequirements.html