|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.das2.datum.DatumRange
public class DatumRange
A DatumRange is provided as a means to carry an ordered pair of Datums representing an interval. This sort of data structure comes up often in processing, and it's useful to define once and get the operators implemented correctly. Consider using this object whenever you see pairs of Datums in interfaces and codes (e.g. tbegin,tend), they are probably a DatumRange!
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
int |
compareTo(java.lang.Object o)
Ordered by the lesser point, then the greater point. |
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). |
boolean |
equals(java.lang.Object o)
returns true if the two endpoints are equal. |
Units |
getUnits()
return the units of the DatumRange. |
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 |
min()
returns the smaller value or start of the range. |
static DatumRange |
newDatumRange(double min,
double max,
Units units)
creates a new DatumRange object with the range specified in the space identified by units. |
DatumRange |
next()
returns the next DatumRange covering the space defined by Units. |
double |
normalize(Datum d)
returns the position within this, where 0. |
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. |
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. |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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.Method Detail |
---|
public boolean intersects(DatumRange dr)
dr
- a valid datum range
InconvertableUnitsException
- 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
public boolean contains(DatumRange dr)
dr
- public DatumRange union(DatumRange dr)
dr
-
java.lang.IllegalArgumentException
- if the two are disjoint.public boolean contains(Datum d)
d
-
public Datum width()
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
-
public int compareTo(java.lang.Object o)
compareTo
in interface java.lang.Comparable
o
-
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. is this range's min, 1 is this range's max, 0 is
min-width.max
- the new max with normalized wrt this range. 0. is this range's min, 1 is this range's max, 0 is
min-width.
public double normalize(Datum d)
d
- a datum to normalize with respect to the range.
public Datum min()
public Datum max()
public DatumRange next()
public DatumRange previous()
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.
public Units getUnits()
public static DatumRange newDatumRange(double min, double max, Units units)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |