- java.lang.Object
-
- net.miginfocom.layout.UnitValue
-
- All Implemented Interfaces:
java.io.Serializable
public final class UnitValue extends java.lang.Object implements java.io.Serializable
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static int
ADD
An operation indicating a addition of two sub units.static int
ALIGN
A unit indicating alignment.(package private) static UnitValue
BASELINE_IDENTITY
(package private) static UnitValue
BOTTOM
static int
BUTTON
A unit indicating button size.(package private) static UnitValue
CENTER
static int
CM
A unit indicating centimeters.private static java.util.ArrayList<UnitConverter>
CONVERTERS
static int
DIV
An operation indicating a division of two sub units.private static int
IDENTITY
static int
INCH
A unit indicating inches.(package private) static UnitValue
INF
private boolean
isHor
(package private) static UnitValue
LABEL
static int
LABEL_ALIGN
A unit indicating label alignment.(package private) static UnitValue
LEADING
(package private) static UnitValue
LEFT
static int
LINK_H
A unit indicating linking to height.static int
LINK_W
A unit indicating linking to width.static int
LINK_X
A unit indicating linking to x.static int
LINK_X2
A unit indicating linking to x2.static int
LINK_XPOS
A unit indicating linking to x position on screen.static int
LINK_Y
A unit indicating linking to y.static int
LINK_Y2
A unit indicating linking to y2.static int
LINK_YPOS
A unit indicating linking to y position on screen.private java.lang.String
linkId
static int
LOOKUP
A unit indicating a lookup.static int
LPX
A unit indicating logical horizontal pixels.static int
LPY
A unit indicating logical vertical pixels.static int
MAX
An operation indicating the maximum of two sub unitsstatic int
MAX_SIZE
A unit indicating maximum size.static int
MID
An operation indicating the middle value of two sub unitsstatic int
MIN
An operation indicating the minimum of two sub unitsstatic int
MIN_SIZE
A unit indicating minimum size.static int
MM
A unit indicating millimeters.static int
MUL
An operation indicating a multiplication of two sub units.private int
oper
static int
PERCENT
A unit indicating percent.static int
PIXEL
A unit indicating pixels.static int
PREF_SIZE
A unit indicating preferred size.static int
PT
A unit indicating points.(package private) static UnitValue
RIGHT
private static float[]
SCALE
private static long
serialVersionUID
static int
SPX
A unit indicating screen percentage width.static int
SPY
A unit indicating screen percentage height.static int
STATIC
An operation indicating a static value.static int
SUB
An operation indicating a subtraction of two sub unitsprivate UnitValue[]
subUnits
(package private) static UnitValue
TOP
(package private) static UnitValue
TRAILING
private int
unit
private static java.util.HashMap<java.lang.String,java.lang.Integer>
UNIT_MAP
private java.lang.String
unitStr
private float
value
(package private) static UnitValue
ZERO
-
Constructor Summary
Constructors Modifier Constructor Description (package private)
UnitValue(boolean isHor, int oper, UnitValue sub1, UnitValue sub2, java.lang.String createString)
UnitValue(float value)
UnitValue(float value, int unit, java.lang.String createString)
UnitValue(float value, java.lang.String unitStr, boolean isHor, int oper, java.lang.String createString)
private
UnitValue(float value, java.lang.String unitStr, int unit, boolean isHor, int oper, UnitValue sub1, UnitValue sub2, java.lang.String createString)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
addGlobalUnitConverter(UnitConverter conv)
Adds a global unit converter that can convert from someunit
to pixels.java.lang.String
getConstraintString()
Returns the creation string for this object.static int
getDefaultUnit()
Deprecated.static UnitConverter[]
getGlobalUnitConverters()
Returns the global converters currently registered.(package private) java.lang.String
getLinkTargetId()
int
getOperation()
int
getPixels(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels rounded.float
getPixelsExact(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels.(package private) int
getSubUnitCount()
UnitValue[]
getSubUnits()
(package private) UnitValue
getSubUnitValue(int i)
int
getUnit()
java.lang.String
getUnitString()
float
getValue()
int
hashCode()
(package private) boolean
isAbsolute()
(package private) boolean
isAbsoluteDeep()
boolean
isHorizontal()
(package private) boolean
isLinked()
(package private) boolean
isLinkedDeep()
private float
lookup(float refValue, ContainerWrapper parent, ComponentWrapper comp)
private int
parseUnitString()
private void
readObject(java.io.ObjectInputStream in)
private java.lang.Object
readResolve()
static boolean
removeGlobalUnitConverter(UnitConverter unit)
Removed the converter.static void
setDefaultUnit(int unit)
Deprecated.java.lang.String
toString()
private void
writeObject(java.io.ObjectOutputStream out)
-
-
-
Field Detail
-
UNIT_MAP
private static final java.util.HashMap<java.lang.String,java.lang.Integer> UNIT_MAP
-
CONVERTERS
private static final java.util.ArrayList<UnitConverter> CONVERTERS
-
STATIC
public static final int STATIC
An operation indicating a static value.- See Also:
- Constant Field Values
-
ADD
public static final int ADD
An operation indicating a addition of two sub units.- See Also:
- Constant Field Values
-
SUB
public static final int SUB
An operation indicating a subtraction of two sub units- See Also:
- Constant Field Values
-
MUL
public static final int MUL
An operation indicating a multiplication of two sub units.- See Also:
- Constant Field Values
-
DIV
public static final int DIV
An operation indicating a division of two sub units.- See Also:
- Constant Field Values
-
MIN
public static final int MIN
An operation indicating the minimum of two sub units- See Also:
- Constant Field Values
-
MAX
public static final int MAX
An operation indicating the maximum of two sub units- See Also:
- Constant Field Values
-
MID
public static final int MID
An operation indicating the middle value of two sub units- See Also:
- Constant Field Values
-
PIXEL
public static final int PIXEL
A unit indicating pixels.- See Also:
- Constant Field Values
-
LPX
public static final int LPX
A unit indicating logical horizontal pixels.- See Also:
- Constant Field Values
-
LPY
public static final int LPY
A unit indicating logical vertical pixels.- See Also:
- Constant Field Values
-
MM
public static final int MM
A unit indicating millimeters.- See Also:
- Constant Field Values
-
CM
public static final int CM
A unit indicating centimeters.- See Also:
- Constant Field Values
-
INCH
public static final int INCH
A unit indicating inches.- See Also:
- Constant Field Values
-
PERCENT
public static final int PERCENT
A unit indicating percent.- See Also:
- Constant Field Values
-
PT
public static final int PT
A unit indicating points.- See Also:
- Constant Field Values
-
SPX
public static final int SPX
A unit indicating screen percentage width.- See Also:
- Constant Field Values
-
SPY
public static final int SPY
A unit indicating screen percentage height.- See Also:
- Constant Field Values
-
ALIGN
public static final int ALIGN
A unit indicating alignment.- See Also:
- Constant Field Values
-
MIN_SIZE
public static final int MIN_SIZE
A unit indicating minimum size.- See Also:
- Constant Field Values
-
PREF_SIZE
public static final int PREF_SIZE
A unit indicating preferred size.- See Also:
- Constant Field Values
-
MAX_SIZE
public static final int MAX_SIZE
A unit indicating maximum size.- See Also:
- Constant Field Values
-
BUTTON
public static final int BUTTON
A unit indicating button size.- See Also:
- Constant Field Values
-
LINK_X
public static final int LINK_X
A unit indicating linking to x.- See Also:
- Constant Field Values
-
LINK_Y
public static final int LINK_Y
A unit indicating linking to y.- See Also:
- Constant Field Values
-
LINK_W
public static final int LINK_W
A unit indicating linking to width.- See Also:
- Constant Field Values
-
LINK_H
public static final int LINK_H
A unit indicating linking to height.- See Also:
- Constant Field Values
-
LINK_X2
public static final int LINK_X2
A unit indicating linking to x2.- See Also:
- Constant Field Values
-
LINK_Y2
public static final int LINK_Y2
A unit indicating linking to y2.- See Also:
- Constant Field Values
-
LINK_XPOS
public static final int LINK_XPOS
A unit indicating linking to x position on screen.- See Also:
- Constant Field Values
-
LINK_YPOS
public static final int LINK_YPOS
A unit indicating linking to y position on screen.- See Also:
- Constant Field Values
-
LOOKUP
public static final int LOOKUP
A unit indicating a lookup.- See Also:
- Constant Field Values
-
LABEL_ALIGN
public static final int LABEL_ALIGN
A unit indicating label alignment.- See Also:
- Constant Field Values
-
IDENTITY
private static final int IDENTITY
- See Also:
- Constant Field Values
-
ZERO
static final UnitValue ZERO
-
TOP
static final UnitValue TOP
-
LEADING
static final UnitValue LEADING
-
LEFT
static final UnitValue LEFT
-
CENTER
static final UnitValue CENTER
-
TRAILING
static final UnitValue TRAILING
-
RIGHT
static final UnitValue RIGHT
-
BOTTOM
static final UnitValue BOTTOM
-
LABEL
static final UnitValue LABEL
-
INF
static final UnitValue INF
-
BASELINE_IDENTITY
static final UnitValue BASELINE_IDENTITY
-
value
private final transient float value
-
unit
private final transient int unit
-
oper
private final transient int oper
-
unitStr
private final transient java.lang.String unitStr
-
linkId
private transient java.lang.String linkId
-
isHor
private final transient boolean isHor
-
subUnits
private final transient UnitValue[] subUnits
-
SCALE
private static final float[] SCALE
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
UnitValue
public UnitValue(float value)
-
UnitValue
public UnitValue(float value, int unit, java.lang.String createString)
-
UnitValue
public UnitValue(float value, java.lang.String unitStr, boolean isHor, int oper, java.lang.String createString)
-
UnitValue
UnitValue(boolean isHor, int oper, UnitValue sub1, UnitValue sub2, java.lang.String createString)
-
-
Method Detail
-
getPixels
public final int getPixels(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels rounded.- Parameters:
refValue
- The reference value. Normally the size of the parent. For unitALIGN
the current size of the component should be sent in.parent
- The parent. May benull
for testing the validity of the value, but should normally not and are not required to return any usable value ifnull
.comp
- The component, if any, that the value is for. Might benull
if the value is not connected to any component.- Returns:
- The size in pixels.
-
getPixelsExact
public final float getPixelsExact(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels.- Parameters:
refValue
- The reference value. Normally the size of the parent. For unitALIGN
the current size of the component should be sent in.parent
- The parent. May benull
for testing the validity of the value, but should normally not and are not required to return any usable value ifnull
.comp
- The component, if any, that the value is for. Might benull
if the value is not connected to any component.- Returns:
- The size in pixels.
-
lookup
private float lookup(float refValue, ContainerWrapper parent, ComponentWrapper comp)
-
parseUnitString
private int parseUnitString()
-
isAbsolute
final boolean isAbsolute()
-
isAbsoluteDeep
final boolean isAbsoluteDeep()
-
isLinked
final boolean isLinked()
-
isLinkedDeep
final boolean isLinkedDeep()
-
getLinkTargetId
final java.lang.String getLinkTargetId()
-
getSubUnitValue
final UnitValue getSubUnitValue(int i)
-
getSubUnitCount
final int getSubUnitCount()
-
getSubUnits
public final UnitValue[] getSubUnits()
-
getUnit
public final int getUnit()
-
getUnitString
public final java.lang.String getUnitString()
-
getOperation
public final int getOperation()
-
getValue
public final float getValue()
-
isHorizontal
public final boolean isHorizontal()
-
toString
public final java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
getConstraintString
public final java.lang.String getConstraintString()
Returns the creation string for this object. Note thatLayoutUtil.setDesignTime(ContainerWrapper, boolean)
must be set totrue
for the creation strings to be stored.- Returns:
- The constraint string or
null
if none is registered.
-
hashCode
public final int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
addGlobalUnitConverter
public static void addGlobalUnitConverter(UnitConverter conv)
Adds a global unit converter that can convert from someunit
to pixels.This converter will be asked before the platform converter so the values for it (e.g. "related" and "unrelated") can be overridden. It is however not possible to override the built in ones (e.g. "mm", "pixel" or "lp").
- Parameters:
conv
- The converter. Notnull
.
-
removeGlobalUnitConverter
public static boolean removeGlobalUnitConverter(UnitConverter unit)
Removed the converter.- Parameters:
unit
- The converter.- Returns:
- If there was a converter found and thus removed.
-
getGlobalUnitConverters
public static UnitConverter[] getGlobalUnitConverters()
Returns the global converters currently registered. The platform converter will not be in this list.- Returns:
- The converters. Never
null
.
-
getDefaultUnit
public static int getDefaultUnit()
Deprecated.Returns the current default unit. The default unit is the unit used if no unit is set. E.g. "width 10".
-
setDefaultUnit
public static void setDefaultUnit(int unit)
Deprecated.Sets the default unit. The default unit is the unit used if no unit is set. E.g. "width 10".
-
readResolve
private 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
-
-