Package uk.ac.starlink.ttools.plot
Class Range
java.lang.Object
uk.ac.starlink.ttools.plot.Range
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
clear()
Unsets the lower and upper bounds for this range.boolean
void
Extends this range by another one.double[]
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
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.toString()
-
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 boundhi
- upper bound
-
Range
public Range(double[] bounds) Constructs a range with given lower and upper bounds. The first two elements of thebounds
array are taken as the initial lower and upper bounds. Either may be NaN.- Parameters:
bounds
- 2-element array giving lower, upper bounds
-
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 includevalue
- 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 thebounds
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 boundhi
- 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 thepositive
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 NaNhi
- 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
Limits this range by another one. If either of the bounds ofboundRange
is finite, it will replace the corresponding bound of this one.- Parameters:
boundRange
- range giving new bounds
-
extend
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
-
hashCode
public int hashCode() -
toString
-