org.das2.datum
Class DatumRangeUtil

java.lang.Object
  extended by org.das2.datum.DatumRangeUtil

public class DatumRangeUtil
extends java.lang.Object


Nested Class Summary
static class DatumRangeUtil.DateDescriptor
           
 
Constructor Summary
DatumRangeUtil()
           
 
Method Summary
static java.lang.String formatTimeRange(DatumRange self)
           
static java.util.List generateList(DatumRange bounds, DatumRange element)
          return a list of DatumRanges that together cover the space identified by bounds.
static DatumRange newDimensionless(double lower, double upper)
           
static double normalize(DatumRange dr, Datum d)
          returns the position within dr, where 0.
static double normalizeLog(DatumRange dr, Datum d)
          returns the position within dr, where 0.
static DatumRange parseDatumRange(java.lang.String str, DatumRange orig)
           
static DatumRange parseDatumRange(java.lang.String str, Units units)
           
static DatumRange parseTimeRange(java.lang.String string)
           
static DatumRange parseTimeRangeValid(java.lang.String s)
           
static DatumRange rescale(DatumRange dr, double min, double max)
          returns DatumRange relative to this, where 0.
static DatumRange rescaleLog(DatumRange dr, double min, double max)
          returns DatumRange relative to this, where 0.
static boolean sloppyContains(DatumRange context, Datum datum)
          Like DatumRange.contains, but includes the end point.
static DatumRange sloppyIntersection(DatumRange range, DatumRange include)
          Like DatumRange.intesects, but returns a zero-width range when the two do not intersect.
static DatumRange union(DatumRange range, DatumRange include)
          return the union of two DatumRanges.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatumRangeUtil

public DatumRangeUtil()
Method Detail

parseTimeRange

public static DatumRange parseTimeRange(java.lang.String string)
                                 throws java.text.ParseException
Throws:
java.text.ParseException

parseTimeRangeValid

public static DatumRange parseTimeRangeValid(java.lang.String s)

formatTimeRange

public static java.lang.String formatTimeRange(DatumRange self)

generateList

public static java.util.List generateList(DatumRange bounds,
                                          DatumRange element)
return a list of DatumRanges that together cover the space identified by bounds. The list should contain one DatumRange that is equal to element, which should define the phase and period of the list elements. For example,
 DatumRange bounds= DatumRangeUtil.parseTimeRangeValid( '2006' );
 DatumRange first= DatumRangeUtil.parseTimeRangeValid( 'Jan 2006' );
 List list= generateList( bounds, first );
Note the procedure calls element.previous until bound.min() is contained, then calls bound.max until bound.max() is contained.

Parameters:
bounds - range to be covered.
element - range defining the width and phase of each list DatumRange.

newDimensionless

public static DatumRange newDimensionless(double lower,
                                          double upper)

parseDatumRange

public static DatumRange parseDatumRange(java.lang.String str,
                                         Units units)
                                  throws java.text.ParseException
Throws:
java.text.ParseException

parseDatumRange

public static DatumRange parseDatumRange(java.lang.String str,
                                         DatumRange orig)
                                  throws java.text.ParseException
Throws:
java.text.ParseException

rescale

public static DatumRange rescale(DatumRange dr,
                                 double min,
                                 double max)
returns DatumRange relative to this, where 0. is the minimum, and 1. is the maximum. For example rescale(1,2) is scanNext, rescale(0.5,1.5) is zoomOut.

Parameters:
dr - a DatumRange with nonzero width.
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.
Returns:
new DatumRange.

rescaleLog

public static DatumRange rescaleLog(DatumRange dr,
                                    double min,
                                    double max)
returns DatumRange relative to this, where 0. is the minimum, and 1. is the maximum, but the scaling is done in the log space. For example, rescaleLog( [0.1,1.0], -1, 2 )-> [ 0.01, 10.0 ]

Parameters:
dr - a DatumRange with nonzero width.
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.
Returns:
new DatumRange.

normalize

public static double normalize(DatumRange dr,
                               Datum d)
returns the position within dr, where 0. is the dr.min(), and 1. is dr.max()

Parameters:
dr - a datum range with non-zero width.
d - a datum to normalize with respect to the range.
Returns:
a double indicating the normalized datum.

normalizeLog

public static double normalizeLog(DatumRange dr,
                                  Datum d)
returns the position within dr, where 0. is the dr.min(), and 1. is dr.max()

Parameters:
dr - a datum range with non-zero width.
d - a datum to normalize with respect to the range.
Returns:
a double indicating the normalized datum.

sloppyIntersection

public static DatumRange sloppyIntersection(DatumRange range,
                                            DatumRange include)
Like DatumRange.intesects, but returns a zero-width range when the two do not intersect. When they do not intersect, the min or max of the first range is returned, depending on whether or not the second range is above or below the first range. Often this allows for simpler code.

See Also:
DatumRange.intersection.

sloppyContains

public static boolean sloppyContains(DatumRange context,
                                     Datum datum)
Like DatumRange.contains, but includes the end point. Often this allows for simpler code.

See Also:
DatumRange.contains.

union

public static DatumRange union(DatumRange range,
                               DatumRange include)
return the union of two DatumRanges. If they do not intersect, the range between the two is included as well.

Parameters:
range -
include -
Returns: