public class Length extends AbstractSimpleDatatypeBase<String>
Datatype for a Length. It typically represents a width
or height of a UI-object. Therefore it consists of two parts:
Examples:
getValue() |
getAmount() |
getUnit() |
|---|---|---|
| 12px | 12.0 | LengthUnit.PIXEL |
| 100% | 100.0 | LengthUnit.PERCENT |
| 0.8em | 0.8 | LengthUnit.EM |
LengthUnit.newLength(double),
Serialized Form| Modifier and Type | Field and Description |
|---|---|
private double |
amount |
static Length |
FULL
The full
Length as "100%". |
static Length |
MAX
The maximum
Length. |
private static long |
serialVersionUID
UID for serialization.
|
private LengthUnit |
unit |
static Length |
ZERO
The empty
Length. |
| Modifier | Constructor and Description |
|---|---|
protected |
Length()
The constructor.
|
|
Length(double value,
LengthUnit unit)
The constructor.
|
|
Length(String size)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
double |
convertToPixel(double basePixelLength,
LengthProperty property)
|
double |
getAmount()
This method gets the value (amount) of this size.
|
LengthUnit |
getUnit()
|
String |
getValue()
This method returns the raw value of this datatype.
|
static Length |
valueOfPercent(double amount)
|
static Length |
valueOfPixel(double amount)
|
equals, getValue, hashCode, toStringprivate static final long serialVersionUID
private double amount
getAmount()private LengthUnit unit
getUnit()protected Length()
public Length(double value,
LengthUnit unit)
public String getValue()
String
, Character, Boolean, any type of Number, any type of java.time.LocalDate, etc.).public double getAmount()
unit.Length.public LengthUnit getUnit()
LengthUnit.public double convertToPixel(double basePixelLength,
LengthProperty property)
amount in pixels. basePixelLength - is the base length in pixel used to convert from percent. Use 0 if unknown (what will result in 0 in case of
percent length values).property - is the LengthProperty or null if not available.length in pixels.public static Length valueOfPercent(double amount)
Copyright © 2001–2016 mmm-Team. All rights reserved.