public final class UnitValue
- Object
- UnitValue
Fields
public static final int STATIC = 100 | An operation indicating a static value. |
public static final int ADD = 101 | An operation indicating a addition of two sub units. |
public static final int SUB = 102 | An operation indicating a subtraction of two sub units |
public static final int MUL = 103 | An operation indicating a multiplication of two sub units. |
public static final int DIV = 104 | An operation indicating a division of two sub units. |
public static final int MIN = 105 | An operation indicating the minimum of two sub units |
public static final int MAX = 106 | An operation indicating the maximum of two sub units |
public static final int MID = 107 | An operation indicating the middle value of two sub units |
public static final int PIXEL = 0 | A unit indicating pixels. |
public static final int LPX = 1 | A unit indicating logical horizontal pixels. |
public static final int LPY = 2 | A unit indicating logical vertical pixels. |
public static final int MM = 3 | A unit indicating millimeters. |
public static final int CM = 4 | A unit indicating centimeters. |
public static final int INCH = 5 | A unit indicating inches. |
public static final int PERCENT = 6 | A unit indicating percent. |
public static final int PT = 7 | A unit indicating points. |
public static final int SPX = 8 | A unit indicating screen percentage width. |
public static final int SPY = 9 | A unit indicating screen percentage height. |
public static final int ALIGN = 12 | A unit indicating alignment. |
public static final int MIN_SIZE = 13 | A unit indicating minimum size. |
public static final int PREF_SIZE = 14 | A unit indicating preferred size. |
public static final int MAX_SIZE = 15 | A unit indicating maximum size. |
public static final int BUTTON = 16 | A unit indicating botton size. |
public static final int LINK_X = 18 | A unit indicating linking to x. |
public static final int LINK_Y = 19 | A unit indicating linking to y. |
public static final int LINK_W = 20 | A unit indicating linking to width. |
public static final int LINK_H = 21 | A unit indicating linking to height. |
public static final int LINK_X2 = 22 | A unit indicating linking to x2. |
public static final int LINK_Y2 = 23 | A unit indicating linking to y2. |
public static final int LINK_XPOS = 24 | A unit indicating linking to x position on screen. |
public static final int LINK_YPOS = 25 | A unit indicating linking to y position on screen. |
public static final int LOOKUP = 26 | A unit indicating a lookup. |
public static final int LABEL_ALIGN = 27 | A unit indicating label alignment. |
Constructors
public UnitValue(float value) | |
public UnitValue(float value, int unit, String createString) |
Methods
Inherited methods
Field details
STATIC
public static final int STATIC = 100An operation indicating a static value.
ADD
public static final int ADD = 101An operation indicating a addition of two sub units.
SUB
public static final int SUB = 102An operation indicating a subtraction of two sub units
MUL
public static final int MUL = 103An operation indicating a multiplication of two sub units.
DIV
public static final int DIV = 104An operation indicating a division of two sub units.
MIN
public static final int MIN = 105An operation indicating the minimum of two sub units
MAX
public static final int MAX = 106An operation indicating the maximum of two sub units
MID
public static final int MID = 107An operation indicating the middle value of two sub units
PIXEL
public static final int PIXEL = 0A unit indicating pixels.
LPX
public static final int LPX = 1A unit indicating logical horizontal pixels.
LPY
public static final int LPY = 2A unit indicating logical vertical pixels.
MM
public static final int MM = 3A unit indicating millimeters.
CM
public static final int CM = 4A unit indicating centimeters.
INCH
public static final int INCH = 5A unit indicating inches.
PERCENT
public static final int PERCENT = 6A unit indicating percent.
PT
public static final int PT = 7A unit indicating points.
SPX
public static final int SPX = 8A unit indicating screen percentage width.
SPY
public static final int SPY = 9A unit indicating screen percentage height.
ALIGN
public static final int ALIGN = 12A unit indicating alignment.
MIN_SIZE
public static final int MIN_SIZE = 13A unit indicating minimum size.
PREF_SIZE
public static final int PREF_SIZE = 14A unit indicating preferred size.
MAX_SIZE
public static final int MAX_SIZE = 15A unit indicating maximum size.
BUTTON
public static final int BUTTON = 16A unit indicating botton size.
LINK_X
public static final int LINK_X = 18A unit indicating linking to x.
LINK_Y
public static final int LINK_Y = 19A unit indicating linking to y.
LINK_W
public static final int LINK_W = 20A unit indicating linking to width.
LINK_H
public static final int LINK_H = 21A unit indicating linking to height.
LINK_X2
public static final int LINK_X2 = 22A unit indicating linking to x2.
LINK_Y2
public static final int LINK_Y2 = 23A unit indicating linking to y2.
LINK_XPOS
public static final int LINK_XPOS = 24A unit indicating linking to x position on screen.
LINK_YPOS
public static final int LINK_YPOS = 25A unit indicating linking to y position on screen.
LOOKUP
public static final int LOOKUP = 26A unit indicating a lookup.
LABEL_ALIGN
public static final int LABEL_ALIGN = 27A unit indicating label alignment.
Constructor details
UnitValue
public UnitValue(float value)UnitValue
public UnitValue(float value, int unit, String createString)Method details
addGlobalUnitConverter
public static synchronized 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
convUnitConverter- The converter. Not
null.
removeGlobalUnitConverter
public static synchronized boolean removeGlobalUnitConverter(UnitConverter unit)Removed the converter.
Parameters
unitUnitConverter- The converter.
Returns
If there was a converter found and thus removed.
getGlobalUnitConverters
public static synchronized 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. Use
PlatformDefaults#getDefaultHorizontalUnit() and PlatformDefaults#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.
setDefaultUnit
public static void setDefaultUnit(int unit)Deprecated. Use
PlatformDefaults#setDefaultHorizontalUnit(int) and PlatformDefaults#setDefaultVerticalUnit(int) instead.Sets the default unit. The default unit is the unit used if no unit is set. E.g. “width 10”.
Parameters
unitint- The new default unit.
getPixels
public int getPixels(float refValue, ContainerWrapper parent, ComponentWrapper comp)Returns the size in pixels rounded.
Parameters
refValuefloat- The reference value. Normally the size of the parent. For unit
#ALIGNthe current size of the component should be sent in. parentContainerWrapper- The parent. May be
nullfor testing the validity of the value, but should normally not and are not required to return any usable value ifnull. compComponentWrapper- The component, if any, that the value is for. Might be
nullif the value is not connected to any component.
Returns
The size in pixels.
getPixelsExact
public float getPixelsExact(float refValue, ContainerWrapper parent, ComponentWrapper comp)Returns the size in pixels.
Parameters
refValuefloat- The reference value. Normally the size of the parent. For unit
#ALIGNthe current size of the component should be sent in. parentContainerWrapper- The parent. May be
nullfor testing the validity of the value, but should normally not and are not required to return any usable value ifnull. compComponentWrapper- The component, if any, that the value is for. Might be
nullif the value is not connected to any component.
Returns
The size in pixels.
getSubUnits
public UnitValue[] getSubUnits()getUnit
public int getUnit()getUnitString
public String getUnitString()getOperation
public int getOperation()getValue
public float getValue()isHorizontal
public boolean isHorizontal()toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())
getConstraintString
public String getConstraintString()Returns the creation string for this object. Note that
boolean) must be
set to true for the creation strings to be stored.Returns
The constraint string or
null if none is registered.hashCode
public int hashCode()Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.
The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables.
As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
equals
public boolean equals(Object obj)Indicates whether some other object is “equal to” this one.
The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false.
The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true).