- java.lang.Object
-
- net.miginfocom.layout.BoundSize
-
- All Implemented Interfaces:
java.io.Serializable
public class BoundSize extends java.lang.Object implements java.io.Serializable
A size that contains minimum, preferred and maximum size of typeUnitValue
.This class is a simple value container and it is immutable.
If a size is missing (i.e.,
null
) that boundary should be considered "not in use".You can create a BoundSize from a String with the use of
ConstraintParser.parseBoundSize(String, boolean, boolean)
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description BoundSize(UnitValue minMaxPref, java.lang.String createString)
Constructor that use the same value for min/preferred/max size.BoundSize(UnitValue min, UnitValue preferred, UnitValue max, boolean gapPush, java.lang.String createString)
Constructor.BoundSize(UnitValue min, UnitValue preferred, UnitValue max, java.lang.String createString)
Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
checkNotLinked()
int
constrain(int size, float refValue, ContainerWrapper parent)
Makes sure thatsize
is within min and max of this size.(package private) java.lang.String
getConstraintString()
Returns the a constraint string that can be re-parsed to be the exact same UnitValue.boolean
getGapPush()
If the size should be hinted as "pushing" and thus want to occupy free space if no one else is claiming it.UnitValue
getMax()
Returns the maximum size as sent into the constructor.UnitValue
getMin()
Returns the minimum size as sent into the constructor.(package private) int[]
getPixelSizes(float refSize, ContainerWrapper parent, ComponentWrapper comp)
Convert the bound sizes to pixels.UnitValue
getPreferred()
Returns the preferred size as sent into the constructor.(package private) UnitValue
getSize(int sizeType)
Returns the minimum, preferred or maximum size for this bounded size.(package private) boolean
isAbsolute()
(package private) boolean
isLinked()
boolean
isUnset()
Returns if this bound size has no min, preferred and maximum size set (they are allnull
)private void
readObject(java.io.ObjectInputStream in)
protected java.lang.Object
readResolve()
java.lang.String
toString()
private void
writeObject(java.io.ObjectOutputStream out)
-
-
-
Field Detail
-
NULL_SIZE
public static final BoundSize NULL_SIZE
-
ZERO_PIXEL
public static final BoundSize ZERO_PIXEL
-
min
private final transient UnitValue min
-
pref
private final transient UnitValue pref
-
max
private final transient UnitValue max
-
gapPush
private final transient boolean gapPush
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
BoundSize
public BoundSize(UnitValue minMaxPref, java.lang.String createString)
Constructor that use the same value for min/preferred/max size.- Parameters:
minMaxPref
- The value to use for min/preferred/max size.createString
- The string used to create the BoundsSize.
-
BoundSize
public BoundSize(UnitValue min, UnitValue preferred, UnitValue max, java.lang.String createString)
Constructor. This method is here for serialization only and should normally not be used. UseConstraintParser.parseBoundSize(String, boolean, boolean)
instead.- Parameters:
min
- The minimum size. May benull
.preferred
- The preferred size. May benull
.max
- The maximum size. May benull
.createString
- The string used to create the BoundsSize.
-
BoundSize
public BoundSize(UnitValue min, UnitValue preferred, UnitValue max, boolean gapPush, java.lang.String createString)
Constructor. This method is here for serialization only and should normally not be used. UseConstraintParser.parseBoundSize(String, boolean, boolean)
instead.- Parameters:
min
- The minimum size. May benull
.preferred
- The preferred size. May benull
.max
- The maximum size. May benull
.gapPush
- If the size should be hinted as "pushing" and thus want to occupy free space if no one else is claiming it.createString
- The string used to create the BoundsSize.
-
-
Method Detail
-
getMin
public final UnitValue getMin()
Returns the minimum size as sent into the constructor.- Returns:
- The minimum size as sent into the constructor. May be
null
.
-
getPreferred
public final UnitValue getPreferred()
Returns the preferred size as sent into the constructor.- Returns:
- The preferred size as sent into the constructor. May be
null
.
-
getMax
public final UnitValue getMax()
Returns the maximum size as sent into the constructor.- Returns:
- The maximum size as sent into the constructor. May be
null
.
-
getGapPush
public boolean getGapPush()
If the size should be hinted as "pushing" and thus want to occupy free space if no one else is claiming it.- Returns:
- The value.
-
isUnset
public boolean isUnset()
Returns if this bound size has no min, preferred and maximum size set (they are allnull
)- Returns:
- If unset.
-
constrain
public int constrain(int size, float refValue, ContainerWrapper parent)
Makes sure thatsize
is within min and max of this size.- Parameters:
size
- The size to constrain.refValue
- The reference to use for relative sizes.parent
- The parent container.- Returns:
- The size, constrained within min and max.
-
getSize
final UnitValue getSize(int sizeType)
Returns the minimum, preferred or maximum size for this bounded size.- Parameters:
sizeType
- The type.LayoutUtil.MIN
,LayoutUtil.PREF
orLayoutUtil.MAX
.- Returns:
-
getPixelSizes
final int[] getPixelSizes(float refSize, ContainerWrapper parent, ComponentWrapper comp)
Convert the bound sizes to pixels.null
bound sizes will be 0 for min and preferred andLayoutUtil.INF
for max.- Parameters:
refSize
- The reference size.parent
- The parent. Notnull
.comp
- The component, if applicable, can benull
.- Returns:
- An array of length three (min,pref,max).
-
getConstraintString
java.lang.String getConstraintString()
Returns the a constraint string that can be re-parsed to be the exact same UnitValue.- Returns:
- A String. Never
null
.
-
checkNotLinked
void checkNotLinked()
-
isLinked
boolean isLinked()
-
isAbsolute
boolean isAbsolute()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
readResolve
protected java.lang.Object readResolve() throws java.io.ObjectStreamException
- Throws:
java.io.ObjectStreamException
-
writeObject
private void writeObject(java.io.ObjectOutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
readObject
private void readObject(java.io.ObjectInputStream in) throws java.io.IOException, java.lang.ClassNotFoundException
- Throws:
java.io.IOException
java.lang.ClassNotFoundException
-
-