public class DatumRange
extends java.lang.Object
implements java.lang.Comparable, java.io.Serializable
| Constructor and Description |
|---|
DatumRange(Datum s1,
Datum s2)
Creates valid DatumRange from two Datums.
|
DatumRange(double s1,
double s2,
Units units)
create a datum range from two doubles in the context of units.
|
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(java.lang.Object o)
Compare this to another DatumRange, ordered by the lesser datum,
then the greater datum.
|
boolean |
contains(Datum d)
returns true if the Datum is in the range, inclusive of the
lesser point but exclusive of the greater point.
|
boolean |
contains(DatumRange dr)
returns true of param dr is contained by this, so that this.union(dr).equals(this).
|
DatumRange |
convertTo(Units u)
return this DatumRange in new units.
|
boolean |
equals(java.lang.Object o)
returns true if the two endpoints are equal.
|
Units |
getUnits()
return the units of the DatumRange.
|
int |
hashCode() |
DatumRange |
include(Datum d)
return a new DatumRange that includes the given Datum, extending the
range if necessary.
|
DatumRange |
intersection(DatumRange dr)
returns the intersection of the two intersecting ranges.
|
boolean |
intersects(DatumRange dr)
returns true of the DatumRange overlaps this.
|
Datum |
max()
returns the bigger value or stop of the range.
|
Datum |
middle()
returns the middle value of the range, often useful when
the most descriptive value is needed.
|
Datum |
min()
returns the smaller value or start of the range.
|
static DatumRange |
newDatumRange(double min,
double max,
Units units)
Deprecated.
|
static DatumRange |
newRange(Datum lower,
Datum upper)
create a new DatumRange.
|
static DatumRange |
newRange(double lower,
double upper)
create a new DatumRange.
|
static DatumRange |
newRange(double lower,
double upper,
Units units)
create a new DatumRange.
|
DatumRange |
next()
returns the next DatumRange covering the space defined by Units.
|
DatumRange |
previous()
returns the previous DatumRange covering the space defined by Units.
|
DatumRange |
rescale(double min,
double max)
returns DatumRange relative to this, where 0.0 is the minimum, and 1.0 is the maximum.
|
java.lang.String |
toString()
returns a human consumable representation of the string.
|
DatumRange |
union(DatumRange dr)
returns the union of the two intersecting or adjacent ranges.
|
Datum |
width()
returns the width of the range, which is simply the greater minus the lessor.
|
DatumRange |
zoomOut(double factor)
returns a scaled DatumRange, with a new width that is the this
datumRange's width multiplied by factor, and the same center.
|
public DatumRange(Datum s1, Datum s2)
s1 - the start or smaller value of the range.s2 - the stop or bigger value of the range.public DatumRange(double s1,
double s2,
Units units)
s1 - the start or smaller value of the range.s2 - the stop or bigger value of the range.units - the units in which to interpret s1 and s2.public boolean intersects(DatumRange dr)
dr - a valid datum rangeInconvertibleUnitsException - if the units can not be reconciled.public DatumRange intersection(DatumRange dr)
dr - a valid datum range.java.lang.IllegalArgumentException - if the two do not overlap.DatumRangeUtil.sloppyIntersection(org.das2.datum.DatumRange, org.das2.datum.DatumRange)public boolean contains(DatumRange dr)
dr - the datum range to test.public DatumRange union(DatumRange dr)
dr - the other range of consistent units.java.lang.IllegalArgumentException - if the two are disjoint.public boolean contains(Datum d)
d - the datumjava.lang.IllegalArgumentException - if the units cannot be converted.public Datum width()
public java.lang.String toString()
toString in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objecto - public int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - the DatumRange to compare this DatumRange to.public DatumRange zoomOut(double factor)
factor - double representing the new range's width divided by this range's width.public DatumRange rescale(double min, double max)
min - the new min normalized with respect to this range. 0.0 is this range's min, 1.0 is this range's max.max - the new max with normalized with respect to this range. 0.0 is this range's min, 1.0 is this range's max.DatumRangeUtil.rescale(org.das2.datum.DatumRange, double, double)public Datum min()
public Datum max()
public Datum middle()
public DatumRange next()
public DatumRange previous()
public DatumRange convertTo(Units u)
u - the new units.public DatumRange include(Datum d)
[0,1).include(2)→ [0,2) (note this is exclusive of 2 since it's the end). [0,1).include(-1)→ [-1,1). [0,1).include(0.5) → [0,1] (and returns the same DatumRange object)Also, including a fill Datum returns the same DatumRange as well.
d - the Datum to includepublic Units getUnits()
public static DatumRange newDatumRange(double min, double max, Units units)
min - the minimum valuemax - the maximum value which is greater than or equal to the min.units - the units of the two doubles.newRange(double, double)public static DatumRange newRange(Datum lower, Datum upper)
lower - the lower boundupper - the upper boundpublic static DatumRange newRange(double lower, double upper, Units units)
lower - the lower boundupper - the upper boundunits - the unitspublic static DatumRange newRange(double lower, double upper)
lower - upper -