public class Range extends java.lang.Object implements java.io.Serializable
| Constructor and Description |
|---|
Range(double min,
double max)
Creates a new range instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(double value)
Returns
true if the range includes the specified value,
and false otherwise. |
boolean |
equals(java.lang.Object obj)
Tests this instance for equality with an arbitrary object.
|
double |
getLength()
Returns the length of the range.
|
double |
getMax()
Returns the upper bound of the range.
|
double |
getMin()
Returns the lower bound of the range.
|
int |
hashCode()
Returns a hash code for this instance.
|
boolean |
intersects(double bound1,
double bound2)
Returns
true if the range intersects the interval defined
by the two bounds (the order of the bounds is not important), and
false otherwise. |
boolean |
intersects(Range range)
Returns
true if this range intersects with
the specified range, and false otherwise. |
double |
peggedValue(double value)
Returns either (a) the supplied value, if it falls within the range, or
(b) the range minimum or maximum value, whichever is closest to value.
|
double |
percent(double value)
Returns the value as a percentage along the range.
|
double |
percent(double value,
boolean inverted)
Returns the value as a percentage along the range, with optionally the
result inverted (that is, p becomes 1.0 - p).
|
java.lang.String |
toString()
Returns a string representation of this instance, primarily for
debugging purposes.
|
double |
value(double percent)
Returns the value corresponding to the specified percentage.
|
public Range(double min, double max)
min - the lower bound of the range.max - the upper bound of the range.public double getMin()
public double getMax()
public double getLength()
public boolean contains(double value)
true if the range includes the specified value,
and false otherwise.value - the value.public double peggedValue(double value)
value - the value.public boolean intersects(double bound1, double bound2)
true if the range intersects the interval defined
by the two bounds (the order of the bounds is not important), and
false otherwise.bound1 - the first boundary value.bound2 - the second boundary value.public boolean intersects(Range range)
true if this range intersects with
the specified range, and false otherwise.range - the range (null not permitted).public double percent(double value)
value - the value.public double percent(double value, boolean inverted)
value - the value.inverted - invert the result?public double value(double percent)
percent - the percentage along the range.public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectobj - the object (null permitted).public int hashCode()
hashCode in class java.lang.Objectpublic java.lang.String toString()
toString in class java.lang.Object