public final class UnitValue extends Object
Modifier and Type | Field and Description |
---|---|
static int |
ADD
An operation indicating a addition of two sub units.
|
static int |
ALIGN
A unit indicating alignment.
|
static int |
BUTTON
A unit indicating botton size.
|
static int |
CM
A unit indicating centimeters.
|
static int |
DIV
An operation indicating a division of two sub units.
|
static int |
INCH
A unit indicating inches.
|
static int |
LABEL_ALIGN
A unit indicating label alignment.
|
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.
|
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 units
|
static int |
MAX_SIZE
A unit indicating maximum size.
|
static int |
MID
An operation indicating the middle value of two sub units
|
static int |
MIN
An operation indicating the minimum of two sub units
|
static 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.
|
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.
|
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 units
|
Constructor and Description |
---|
UnitValue(float value) |
UnitValue(float value,
int unit,
String createString) |
Modifier and Type | Method and Description |
---|---|
static void |
addGlobalUnitConverter(UnitConverter conv)
Adds a global unit converter that can convert from some
unit to pixels. |
String |
getConstraintString()
Returns the creation string for this object.
|
static int |
getDefaultUnit()
Deprecated.
|
static UnitConverter[] |
getGlobalUnitConverters()
Returns the global converters currently registered.
|
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.
|
UnitValue[] |
getSubUnits() |
int |
getUnit() |
String |
getUnitString() |
float |
getValue() |
int |
hashCode()
Returns a hash code value for the object.
|
boolean |
isHorizontal() |
static boolean |
removeGlobalUnitConverter(UnitConverter unit)
Removed the converter.
|
static void |
setDefaultUnit(int unit)
Deprecated.
|
String |
toString()
Returns a string representation of the object.
|
public static final int STATIC
public static final int ADD
public static final int SUB
public static final int MUL
public static final int DIV
public static final int MIN
public static final int MAX
public static final int MID
public static final int PIXEL
public static final int LPX
public static final int LPY
public static final int MM
public static final int CM
public static final int INCH
public static final int PERCENT
public static final int PT
public static final int SPX
public static final int SPY
public static final int ALIGN
public static final int MIN_SIZE
public static final int PREF_SIZE
public static final int MAX_SIZE
public static final int BUTTON
public static final int LINK_X
public static final int LINK_Y
public static final int LINK_W
public static final int LINK_H
public static final int LINK_X2
public static final int LINK_Y2
public static final int LINK_XPOS
public static final int LINK_YPOS
public static final int LOOKUP
public static final int LABEL_ALIGN
public UnitValue(float value)
public UnitValue(float value, int unit, String createString)
public final int getPixels(float refValue, ContainerWrapper parent, ComponentWrapper comp)
refValue
- The reference value. Normally the size of the parent. For unit ALIGN
the current size of the component should be sent in.parent
- The parent. May be null
for testing the validity of the value, but should normally not and are not
required to return any usable value if null
.comp
- The component, if any, that the value is for. Might be null
if the value is not
connected to any component.public final float getPixelsExact(float refValue, ContainerWrapper parent, ComponentWrapper comp)
refValue
- The reference value. Normally the size of the parent. For unit ALIGN
the current size of the component should be sent in.parent
- The parent. May be null
for testing the validity of the value, but should normally not and are not
required to return any usable value if null
.comp
- The component, if any, that the value is for. Might be null
if the value is not
connected to any component.public final UnitValue[] getSubUnits()
public final int getUnit()
public final String getUnitString()
public final int getOperation()
public final float getValue()
public final boolean isHorizontal()
public final String toString()
Object
public final String getConstraintString()
LayoutUtil.setDesignTime(ContainerWrapper, boolean)
must be
set to true
for the creation strings to be stored.null
if none is registered.public final int hashCode()
Object
public static void addGlobalUnitConverter(UnitConverter conv)
unit
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").
conv
- The converter. Not null
.public static boolean removeGlobalUnitConverter(UnitConverter unit)
unit
- The converter.public static UnitConverter[] getGlobalUnitConverters()
null
.public static int getDefaultUnit()
PlatformDefaults.getDefaultHorizontalUnit()
and PlatformDefaults.getDefaultVerticalUnit()
instead.public static void setDefaultUnit(int unit)
PlatformDefaults.setDefaultHorizontalUnit(int)
and PlatformDefaults.setDefaultVerticalUnit(int)
instead.