Represents a CSS length value in any supportable unit, including percentage
and unitless type. Values may be integer or float, negative, zero and
positive. Immutable structure.
Determines whether this instance is a unitless zero or not. Unitless zero
is default value of this type. Same as IsDefault property.
Returns:
boolean
isDefault()
public final boolean isDefault()
Indicates whether this Length instance has a default value \u2014 unitless
zero. Same as IsUnitlessZero property.
Returns:
boolean
getUnitType()
public final int getUnitType()
Returns a unit type of this Length instance.
Returns:
int
isInteger()
public final boolean isInteger()
Indicates whether the numeric value of this Length instance was
originally specified and stored as an integer (INT32) number
Returns:
boolean
isFloat()
public final boolean isFloat()
Indicates whether the numeric value of this Length instance was
originally specified and stored as a float (FP32) number
Returns:
boolean
getFloatValue()
public final float getFloatValue()
Returns a float numeric value of the Length instance. Never throws an
exception - converts Integer value to Float if necessary.
Returns:
float
getIntegerValue()
public final int getIntegerValue()
Returns an integer numeric value of this Length instance, if it is
internally stored as an integer, or throws an exception, if it was
originally stored as a float number.
Returns:
int
isAbsolute()
public final boolean isAbsolute()
Gets if the length is given in absolute units. Such a length may be
converted to pixels.
Returns:
boolean
isRelative()
public final boolean isRelative()
Gets if the length is given in relative units. Such a length cannot be
converted to pixels.
Returns:
boolean
isZero()
public final boolean isZero()
Determines whether the numeric value of this length is a zero number
Returns:
boolean
isNegative()
public final boolean isNegative()
Determines whether the numeric value of this length is a negative number
Returns:
boolean
isPositive()
public final boolean isPositive()
Determines whether the numeric value of this length is a positive number
Returns:
boolean
isUnitlessNonZero()
public final boolean isUnitlessNonZero()
The value has unitless type, but is not a zero - positive or negative
number
Returns:
boolean
toPixel()
public final float toPixel()
Converts the length to a number of pixels, if possible. If the current
unit is relative, then an exception will be thrown.
Returns:
float - The number of pixels represented by the current length.
to(int unit)
public final float to(int unit)
Converts the length to the given unit, if possible. If the current or
given unit is relative, then an exception will be thrown.
Parameters:
Parameter
Type
Description
unit
int
The unit to convert to.
Returns:
float - The value in the given unit of the current length.
toStringSpecified(int unit)
public final String toStringSpecified(int unit)
Returns a string representation of this length in specified unit type.
Numeric value will be converted in corresponding to unit type change.
Parameters:
Parameter
Type
Description
unit
int
Specified unit, to which this instance should be converted before serializing to the string. Should be valid. Cannot be unitless.
Returns:
java.lang.String - String representation
serializeDefault()
public final String serializeDefault()
Returns a string representation of this length in its original native
form (as it is stored), without converting length value to some other
unit type
Returns:
java.lang.String - String instance
equals(Length other)
public final boolean equals(Length other)
Defines whether this value is equal to the other specified length