net.miginfocom.layout

Class UnitValue

public final class UnitValue extends Object implements Serializable

Field Summary
static intADD
An operation indicating a addition of two sub units.
static intALIGN
A unit indicating alignment.
static intBUTTON
A unit indicating botton size.
static intCM
A unit indicating centimeters.
static intDIV
An operation indicating a division of two sub units.
static intINCH
A unit indicating inches.
static intLABEL_ALIGN
A unit indicating label alignment.
static intLINK_H
A unit indicating linking to height.
static intLINK_W
A unit indicating linking to width.
static intLINK_X
A unit indicating linking to x.
static intLINK_X2
A unit indicating linking to x2.
static intLINK_XPOS
A unit indicating linking to x position on screen.
static intLINK_Y
A unit indicating linking to y.
static intLINK_Y2
A unit indicating linking to y2.
static intLINK_YPOS
A unit indicating linking to y position on screen.
static intLOOKUP
A unit indicating a lookup.
static intLPX
A unit indicating logical horizontal pixels.
static intLPY
A unit indicating logical vertical pixels.
static intMAX
An operation indicating the maximum of two sub units
static intMAX_SIZE
A unit indicating maximum size.
static intMID
An operation indicating the middle value of two sub units
static intMIN
An operation indicating the minimum of two sub units
static intMIN_SIZE
A unit indicating minimum size.
static intMM
A unit indicating millimeters.
static intMUL
An operation indicating a multiplication of two sub units.
static intPERCENT
A unit indicating percent.
static intPIXEL
A unit indicating pixels.
static intPREF_SIZE
A unit indicating preferred size.
static intPT
A unit indicating points.
static intSPX
A unit indicating screen percentage width.
static intSPY
A unit indicating screen percentage height.
static intSTATIC
An operation indicating a static value.
static intSUB
An operation indicating a subtraction of two sub units
Constructor Summary
UnitValue(float value)
UnitValue(float value, int unit, String createString)
Method Summary
static voidaddGlobalUnitConverter(UnitConverter conv)
Adds a global unit converter that can convert from some unit to pixels.
StringgetConstraintString()
Returns the creation string for this object.
static intgetDefaultUnit()
Returns the current default unit.
static UnitConverter[]getGlobalUnitConverters()
Returns the global converters currently registered.
intgetOperation()
intgetPixels(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels rounded.
floatgetPixelsExact(float refValue, ContainerWrapper parent, ComponentWrapper comp)
Returns the size in pixels.
UnitValue[]getSubUnits()
intgetUnit()
StringgetUnitString()
floatgetValue()
inthashCode()
booleanisHorizontal()
static booleanremoveGlobalUnitConverter(String unit)
Removed the converter.
static voidsetDefaultUnit(int unit)
Sets the default unit.
StringtoString()

Field Detail

ADD

public static final int ADD
An operation indicating a addition of two sub units.

ALIGN

public static final int ALIGN
A unit indicating alignment.

BUTTON

public static final int BUTTON
A unit indicating botton size.

CM

public static final int CM
A unit indicating centimeters.

DIV

public static final int DIV
An operation indicating a division of two sub units.

INCH

public static final int INCH
A unit indicating inches.

LABEL_ALIGN

public static final int LABEL_ALIGN
A unit indicating label alignment.

LINK_H

public static final int LINK_H
A unit indicating linking to height.

LINK_W

public static final int LINK_W
A unit indicating linking to width.

LINK_X

public static final int LINK_X
A unit indicating linking to x.

LINK_X2

public static final int LINK_X2
A unit indicating linking to x2.

LINK_XPOS

public static final int LINK_XPOS
A unit indicating linking to x position on screen.

LINK_Y

public static final int LINK_Y
A unit indicating linking to y.

LINK_Y2

public static final int LINK_Y2
A unit indicating linking to y2.

LINK_YPOS

public static final int LINK_YPOS
A unit indicating linking to y position on screen.

LOOKUP

public static final int LOOKUP
A unit indicating a lookup.

LPX

public static final int LPX
A unit indicating logical horizontal pixels.

LPY

public static final int LPY
A unit indicating logical vertical pixels.

MAX

public static final int MAX
An operation indicating the maximum of two sub units

MAX_SIZE

public static final int MAX_SIZE
A unit indicating maximum size.

MID

public static final int MID
An operation indicating the middle value of two sub units

MIN

public static final int MIN
An operation indicating the minimum of two sub units

MIN_SIZE

public static final int MIN_SIZE
A unit indicating minimum size.

MM

public static final int MM
A unit indicating millimeters.

MUL

public static final int MUL
An operation indicating a multiplication of two sub units.

PERCENT

public static final int PERCENT
A unit indicating percent.

PIXEL

public static final int PIXEL
A unit indicating pixels.

PREF_SIZE

public static final int PREF_SIZE
A unit indicating preferred size.

PT

public static final int PT
A unit indicating points.

SPX

public static final int SPX
A unit indicating screen percentage width.

SPY

public static final int SPY
A unit indicating screen percentage height.

STATIC

public static final int STATIC
An operation indicating a static value.

SUB

public static final int SUB
An operation indicating a subtraction of two sub units

Constructor Detail

UnitValue

public UnitValue(float value)

UnitValue

public UnitValue(float value, int unit, String createString)

Method Detail

addGlobalUnitConverter

public static final void addGlobalUnitConverter(UnitConverter conv)
Adds a global unit converter that can convert from some 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").

Parameters: conv The converter. Not null.

getConstraintString

public final String getConstraintString()
Returns the creation string for this object. Note that LayoutUtil must be set to true for the creation strings to be stored.

Returns: The constraint string or null if none is registered.

getDefaultUnit

public static final int getDefaultUnit()

Deprecated: Use getDefaultHorizontalUnit and getDefaultVerticalUnit instead.

Returns the current default unit. The default unit is the unit used if no unit is set. E.g. "width 10".

Returns: The current default unit.

See Also: PIXEL LPX

getGlobalUnitConverters

public static final UnitConverter[] getGlobalUnitConverters()
Returns the global converters currently registered. The platform converter will not be in this list.

Returns: The converters. Never null.

getOperation

public final int getOperation()

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 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.

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 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.

Returns: The size in pixels.

getSubUnits

public final UnitValue[] getSubUnits()

getUnit

public final int getUnit()

getUnitString

public final String getUnitString()

getValue

public final float getValue()

hashCode

public final int hashCode()

isHorizontal

public final boolean isHorizontal()

removeGlobalUnitConverter

public static final boolean removeGlobalUnitConverter(String unit)
Removed the converter.

Parameters: unit The converter.

Returns: If there was a converter found and thus removed.

setDefaultUnit

public static final void setDefaultUnit(int unit)

Deprecated: Use PlatformDefaults and PlatformDefaults instead.

Sets the default unit. The default unit is the unit used if no unit is set. E.g. "width 10".

Parameters: unit The new default unit.

See Also: PIXEL LPX

toString

public final String toString()