public class SizeWithUnit
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
protected float |
size |
protected static java.util.regex.Pattern |
SIZE_PATTERN |
static java.lang.String |
SIZE_PATTERN_STRING |
protected SizeUnit |
unit |
Constructor and Description |
---|
SizeWithUnit(float size,
SizeUnit unit)
Constructs a new SizeWithUnit object representing the pair (size, unit).
|
Modifier and Type | Method and Description |
---|---|
float |
getSize()
Returns the numeric value stored in this object.
|
SizeUnit |
getUnit()
Returns the size unit stored in this object.
|
static SizeWithUnit |
parseStringSize(java.lang.String size)
Returns an object whose numeric value and unit are taken from the string
size.
|
static SizeWithUnit |
parseStringSize(java.lang.String sizeString,
SizeUnit defaultUnit)
Returns an object whose numeric value and unit are taken from the string
sizeString . |
public static final java.lang.String SIZE_PATTERN_STRING
protected float size
protected SizeUnit unit
protected static final java.util.regex.Pattern SIZE_PATTERN
public SizeWithUnit(float size, SizeUnit unit)
size
- a numeric valueunit
- a unitpublic float getSize()
public SizeUnit getUnit()
public static SizeWithUnit parseStringSize(java.lang.String sizeString, SizeUnit defaultUnit)
sizeString
. If sizeString
does not specify a unit and defaultUnit
is not null,
defaultUnit
is used as the unit. Null, empty or 'AUTO' string will produce {-1, SizeUnit#PIXELS}.sizeString
- the string to be parseddefaultUnit
- The unit to be used if sizeString
does not contain any unit.
Use null
for no default unit.public static SizeWithUnit parseStringSize(java.lang.String size)
size
- the string to be parsed