public final class SizeD
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static SizeD |
EMPTY
An empty read-only
SizeD. |
double |
height
The vertical dimension of the
SizeD. |
double |
width
The horizontal dimension of the
SizeD. |
| Constructor and Description |
|---|
SizeD()
Creates a
SizeD with zero extension. |
SizeD(double width,
double height)
Creates a
SizeD with the specified extension. |
| Modifier and Type | Method and Description |
|---|---|
SizeD |
add(SizeD size)
Adds the extension of the specified
SizeD to this instance. |
boolean |
equals(java.lang.Object obj)
Compares the specified
Object to this SizeD instance. |
static boolean |
equals(SizeD a,
SizeD b,
double epsilon)
Compares two
SizeD instances for equality, given the specified epsilon. |
static SizeD[] |
fromDoubles(double... sizes)
Converts the specified
Double array to a SizeD array. |
int |
hashCode()
Returns a hash code for the
SizeD. |
boolean |
isEmpty()
Determines whether the
SizeD is empty. |
SizeD |
restrict(double minWidth,
double minHeight,
double maxWidth,
double maxHeight)
Restricts the
SizeD to the specified extension range. |
SizeI |
round()
|
SizeD |
subtract(SizeD size)
Subtracts the extension of the specified
SizeD from this instance. |
static double[] |
toDoubles(SizeD... sizes)
Converts the specified
SizeD array to a Double array. |
SizeI |
toSizeI()
|
java.lang.String |
toString()
Returns a
String representation of the SizeD. |
public final double width
SizeD. Never negative.public final double height
SizeD. Never negative.public static final SizeD EMPTY
public SizeD add(SizeD size)
SizeD to this instance.
Returns Double.POSITIVE_INFINITY in any dimension that overflows Double.public static boolean equals(SizeD a, SizeD b, double epsilon)
SizeD instances for equality, given the specified epsilon.a - the first SizeD to compareb - the second SizeD to compareepsilon - the maximum absolute difference where the corresponding dimensions
of a and b are considered equaltrue if the absolute difference between both corresponding dimensions
of a and b is no greater than epsilon, else falsejava.lang.IllegalArgumentException - if epsilon is less than zerojava.lang.NullPointerException - if a or b is nullpublic static SizeD[] fromDoubles(double... sizes)
Double array to a SizeD array.
The returned array has half as many elements as the specified sizes
and retains the same dimension sequence.sizes - an array containing the width and height components
of SizeD instances, stored in alternating index positionsSizeD array created from sizesjava.lang.IllegalArgumentException - if sizes has an odd number of elements,
or if any width or height is less than zerojava.lang.NullPointerException - if sizes is nullpublic boolean isEmpty()
SizeD is empty.public SizeD restrict(double minWidth, double minHeight, double maxWidth, double maxHeight)
SizeD to the specified extension range.minWidth - the smallest permissible widthminHeight - the smallest permissible heightmaxWidth - the greatest permissible widthmaxHeight - the greatest permissible heightSizeD whose width and height equal those
of this instance, restricted to the specified extension rangejava.lang.IllegalArgumentException - if maxWidth or maxHeight is less than zeropublic SizeI round()
SizeD to a SizeI by rounding dimensions to the
nearest Integer values. Uses Fortran.nint(double) for rounding.SizeI whose SizeI.width and SizeI.height
equal the corresponding dimensions of the SizeD,
rounded to the nearest Integer valuesjava.lang.ArithmeticException - if any dimension overflows Integerpublic SizeD subtract(SizeD size)
SizeD from this instance.size - the SizeD extension to subtract from this instanceSizeD whose width and height equal the subtraction
of the corresponding dimensions of the specified size from this instancejava.lang.IllegalArgumentException - if the difference in any dimension is less than zerojava.lang.NullPointerException - if size is nullpublic static double[] toDoubles(SizeD... sizes)
SizeD array to a Double array.
The returned array has twice as many elements as the specified sizes
and retains the same dimension sequence.public SizeI toSizeI()
SizeD to a SizeI by truncating dimensions to the
nearest Integer values. Uses Integer casts for truncation.SizeI whose SizeI.width and SizeI.height
equal the corresponding dimensions of the SizeD,
truncated to the nearest Integer valuesjava.lang.ArithmeticException - if any dimension overflows Integerpublic boolean equals(java.lang.Object obj)
Object to this SizeD instance.public int hashCode()
SizeD.hashCode in class java.lang.ObjectInteger hash code for the SizeD