uk.ac.starlink.ttools.plot
Class Range

java.lang.Object
  extended by uk.ac.starlink.ttools.plot.Range

public class Range
extends Object

Describes a one-dimensional range. This is effectively a lower and upper bound, but either of these may be absent.

Since:
28 Mar 2006
Author:
Mark Taylor

Constructor Summary
Range()
          Constructs an unbounded range.
Range(double[] bounds)
          Constructs a range with given lower and upper bounds.
Range(double lo, double hi)
          Constructs a range with given lower and upper bounds.
Range(Range range)
          Constructs a new range which is a copy of an existing one.
 
Method Summary
 void clear()
          Unsets the lower and upper bounds for this range.
 double[] getBounds()
          Returns the current bounds of this range.
 double[] getFiniteBounds(boolean positive)
          Returns finite upper and lower bounds for this range.
 boolean isClear()
          Returns true if no data about this range has been set.
 void limit(double[] bounds)
          Limits the bounds of this range.
 void limit(double lo, double hi)
          Limits the bounds of this range.
 void limit(Range boundRange)
          Limits this range by another one.
 void pad(double ratio)
          Adds padding to either end of this range.
 void setBounds(double[] bounds)
          Resets the bounds of this range.
 void setBounds(double lo, double hi)
          Resets the bounds of this range.
 void submit(double datum)
          Submits a value to this range.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Range

public Range()
Constructs an unbounded range.


Range

public Range(double lo,
             double hi)
Constructs a range with given lower and upper bounds. Either or both may be NaN.

Parameters:
lo - lower bound
hi - upper bound

Range

public Range(double[] bounds)
Constructs a range with given lower and upper bounds. The first two elements of the bounds array are taken as the initial lower and upper bounds. Either may be NaN.

Parameters:
bounds - 2-element array giving lower, upper bounds

Range

public Range(Range range)
Constructs a new range which is a copy of an existing one.

Parameters:
range - range to copy
Method Detail

submit

public void submit(double datum)
Submits a value to this range. The range will be expanded as required to include value

Parameters:
datum - value to accommodate in this range

setBounds

public void setBounds(double[] bounds)
Resets the bounds of this range. The first two elements of the bounds array are taken as the initial lower and upper bounds. Either may be NaN.

Parameters:
bounds - 2-element array giving lower, upper bounds

setBounds

public void setBounds(double lo,
                      double hi)
Resets the bounds of this range. Either or both may be NaN.

Parameters:
lo - lower bound
hi - upper bound

getBounds

public double[] getBounds()
Returns the current bounds of this range. Either or both may be null.

Returns:
2-element array giving lower, upper bound values

getFiniteBounds

public double[] getFiniteBounds(boolean positive)
Returns finite upper and lower bounds for this range. Both are guaranteed to be non-infinite and non-NaN. If no finite lower and upper bounds have ever been set for this range, they will have to be made up to some extent. If the positive parameter is set true, then both returned bounds are guaranteed to be greater than zero.

Parameters:
positive - true iff strictly positive bounds are required
Returns:
2-element array giving finite lower, upper bounds

isClear

public boolean isClear()
Returns true if no data about this range has been set.

Returns:
true for clear range

pad

public void pad(double ratio)
Adds padding to either end of this range.

Parameters:
ratio - padding ratio (should normally be greater than 0)

clear

public void clear()
Unsets the lower and upper bounds for this range.


limit

public void limit(double lo,
                  double hi)
Limits the bounds of this range. If either of the submitted bounds is finite (not inifinite and not NaN) then the corresponding bound of this range will be replaced by it.

Parameters:
lo - new lower bound, or NaN
hi - new upper bound, or NaN

limit

public void limit(double[] bounds)
Limits the bounds of this range. If either of the submitted bounds is finite (not inifinite and not NaN) then the corresponding bound of this range will be replaced by it.

Parameters:
bounds - 2-element array giving new lower, upper bounds; either may be NaN

limit

public void limit(Range boundRange)
Limits this range by another one. If either of the bounds of boundRange is finite, it will replace the corresponding bound of this one.

Parameters:
boundRange - range giving new bounds

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2009 Central Laboratory of the Research Councils. All Rights Reserved.