Modifier and Type | Field and Description |
---|---|
static Percent |
HUNDRED
Convenience value representing 100%.
|
static Percent |
ZERO
Convenience value representing 0%.
|
Modifier and Type | Method and Description |
---|---|
Percent |
clamp()
Returns a new instance clamped between 0% and 100%.
|
static Percent |
fromDouble_clamped(double value)
Returns a new instance clamped between 0% and 100%, regardless of input value.
|
static Percent |
fromDouble(double value)
Returns a new instance using the given
double value. |
static Percent |
fromInt_clamped(int value)
Returns a new instance clamped between 0% and 100%, regardless of input value.
|
static Percent |
fromInt(int value)
Returns a new instance using the given
int value. |
protected double |
getRawValue()
Subclasses must implement this to return their raw
double value. |
protected Unit<Percent> |
newInstance(double rawValue)
Subclasses must override this so that arithmetic "operators" can create new instances.
|
double |
toDouble()
Returns the
double value of this instance. |
double |
toFraction()
Returns .5 for 50%, for example.
|
int |
toInt_ceil()
int from Math.ceil(double) . |
int |
toInt_floor()
int from Math.floor(double) . |
int |
toInt_round()
int from Math.round(double) . |
java.lang.String |
toString() |
public static final Percent ZERO
public static final Percent HUNDRED
public Percent clamp()
public double toFraction()
public double toDouble()
double
value of this instance.public int toInt_round()
int
from Math.round(double)
.public int toInt_ceil()
int
from Math.ceil(double)
.public int toInt_floor()
int
from Math.floor(double)
.public static Percent fromDouble(double value)
double
value.public static Percent fromDouble_clamped(double value)
public static Percent fromInt(int value)
int
value.public static Percent fromInt_clamped(int value)
public java.lang.String toString()
toString
in class java.lang.Object
protected double getRawValue()
Unit
double
value.getRawValue
in class Unit<Percent>