# Class Range

java.lang.Object
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

Constructors
Constructor
Description
`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

Modifier and Type
Method
Description
`void`
`clear()`
Unsets the lower and upper bounds for this range.
`boolean`
`equals(Object o)`
`void`
`extend(Range other)`
Extends this range by another one.
`double[]`
`getBounds()`
Returns the current bounds of this range.
`double[]`
`getFiniteBounds(boolean positive)`
Returns finite upper and lower bounds for this range.
`int`
`hashCode()`
`boolean`
`isClear()`
Returns true if no data about this range has been set.
`boolean`
`isFinite()`
Returns true if both ends of the range have values which are not NaN.
`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 Object

`clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

## Constructor Details

### 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 Details

### 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

### isFinite

public boolean isFinite()
Returns true if both ends of the range have values which are not NaN.

Returns:
  true iff low and high are numbers

### 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 infinite 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

### extend

public void extend(Range other)
Extends this range by another one. The effect is as if all the data that has been submitted to the other range has been submitted to this one.

Parameters:
  `other` - other range

### equals

public boolean equals(Object o)

Overrides:
  `equals` in class `Object`

### hashCode

public int hashCode()

Overrides:
  `hashCode` in class `Object`

### toString

public String toString()

Overrides:
  `toString` in class `Object`