# Class BasicRanger

java.lang.Object
uk.ac.starlink.ttools.plot2.BasicRanger

All Implemented Interfaces:
  `Ranger`

public class BasicRanger extends Object implements Ranger
Ranger implementation that just keeps track of high and low values.

Since:
  14 Mar 2019
Author:
  Mark Taylor

## Constructor Summary

Constructors
Constructor
Description
`BasicRanger(boolean isBestEfforts)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`void`
`add(Ranger other)`
Merges the contents of the supplied ranger into this one.
`static double[]`
`calculateFiniteBounds(double lo, double hi, boolean isPositive)`
Returns a 2-element array giving definite lower and upper bounds based on known lower and upper values.
`Ranger`
`createCompatibleRanger()`
Returns a Ranger instance that is compatible with this one.
`static Scaler`
`createRangeScaler(Scaling.RangeScaling rscaling, Subrange dataclip, Span span)`
Returns a scaler based on a RangeScaling.
`Span`
`createSpan()`
Returns an object characterising the range of data submitted so far.
`void`
`submitDatum(double datum)`
Accepts a data value.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### BasicRanger

public BasicRanger(boolean isBestEfforts)
Constructor.

Parameters:
  `isBestEfforts` - whether best efforts ranging should be done without complaint for inappropriate scalings

## Method Details

### submitDatum

public void submitDatum(double datum)
Description copied from interface: `Ranger`
Accepts a data value.

Specified by:
  `submitDatum` in interface `Ranger`
Parameters:
  `datum` - datum

### add

public void add(Ranger other)
Description copied from interface: `Ranger`
Merges the contents of the supplied ranger into this one. The effect is as if all the results accumulated into other had been accumulated into this one. The effect on the supplied other is undefined.

The supplied ranger is assumed to be compatible with this one, which probably means created in the same way. If not, some RuntimeException such as a ClassCastException may result.

Specified by:
  `add` in interface `Ranger`
Parameters:
  `other` - compatible ranger instance

### createCompatibleRanger

public Ranger createCompatibleRanger()
Description copied from interface: `Ranger`
Returns a Ranger instance that is compatible with this one. It has no content (does not copy any data from this one), but the two may be merged using the `Ranger.add(Ranger)` method.

Specified by:
  `createCompatibleRanger` in interface `Ranger`
Returns:
  new compatible ranger instance

### createSpan

public Span createSpan()
Description copied from interface: `Ranger`
Returns an object characterising the range of data submitted so far. This should not be called while another thread might be calling `Ranger.submitDatum(double)`.

Specified by:
  `createSpan` in interface `Ranger`
Returns:
  span of accumulated data

### calculateFiniteBounds

public static double[] calculateFiniteBounds(double lo, double hi, boolean isPositive)
Returns a 2-element array giving definite lower and upper bounds based on known lower and upper values. The upper bound will be strictly greater than the lower bound. Optionally, both bounds can be required to be strictly greater than zero. If the input values are insufficient to determine such return values, some reasonable defaults will be made up.

Parameters:
  `lo` - input lower bound, may be NaN
  `hi` - input upper bound, may be NaN
  `isPositive` - if true, output bounds must be positive
Returns:
  2-element array giving (lo,hi)

### createRangeScaler

public static Scaler createRangeScaler(Scaling.RangeScaling rscaling, Subrange dataclip, Span span)
Returns a scaler based on a RangeScaling.

Parameters:
  `rscaling` - scaling of range type
  `dataclip` - input data range adjustment
  `span` - data range information
Returns:
  new scaler