org.das2.datum.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!


include

include( Datum d ) → DatumRange

return a new DatumRange that includes the given Datum, extending the range if necessary. For example,

 [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.

Parameters

d - the Datum to include

Returns:

the new range.

search for examples view on GitHub view source


intersection

intersection( DatumRange dr ) → DatumRange

returns the intersection of the two intersecting ranges. This is a range that contains(d) if and only if this.contains(d) and dr.contains(d).

Parameters

dr - a valid datum range.

Returns:

the intersection of the two intersecting ranges.

See Also:

DatumRangeUtil#sloppyIntersection(org.das2.datum.DatumRange, org.das2.datum.DatumRange)


search for examples view on GitHub view source


intersects

intersects( DatumRange dr ) → boolean

returns true of the DatumRange overlaps this. Note that the endpoints are not included in the comparison, so that Tuesday.intersects(Wednesday)==false.

Parameters

dr - a valid datum range

Returns:

true of the DatumRange overlaps this

search for examples view on GitHub view source


middle

middle( ) → Datum

returns the middle value of the range, often useful when the most descriptive value is needed.

Returns:

the middle value of the range.

search for examples view on GitHub view source


previous

previous( ) → DatumRange

returns the previous DatumRange covering the space defined by Units. See next().

Returns:

the previous DatumRange covering the space defined by Units

search for examples view on GitHub view source


union

union( DatumRange dr ) → DatumRange

returns the union of the two intersecting or adjacent ranges.

Parameters

dr - the other range of consistent units.

Returns:

DatumRange union of the two DatumRanges

search for examples view on GitHub view source


width

width( ) → Datum

returns the width of the range, which is simply the greater minus the lessor. Note that the units of the result will not necessarily be the same as the endpoints, for example with LocationDatums.

Returns:

Datum that is the width of the range (max.subtract(min)).

search for examples view on GitHub view source


zoomOut

zoomOut( double factor ) → DatumRange

returns a scaled DatumRange, with a new width that is the this datumRange's width multiplied by factor, and the same center. 1.0 is the same range, 2.0 has twice the width, etc.

Parameters

factor - double representing the new range's width divided by this range's width.

Returns:

a scaled DatumRange, with a new width that is the this datumRange's width multiplied by factor, and the same center.

search for examples view on GitHub view source