Package uk.ac.starlink.ttools.plot
Class Range
- java.lang.Object
-
- uk.ac.starlink.ttools.plot.Range
-
public class Range extends java.lang.ObjectDescribes 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclear()Unsets the lower and upper bounds for this range.booleanequals(java.lang.Object o)voidextend(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.inthashCode()booleanisClear()Returns true if no data about this range has been set.booleanisFinite()Returns true if both ends of the range have values which are not NaN.voidlimit(double[] bounds)Limits the bounds of this range.voidlimit(double lo, double hi)Limits the bounds of this range.voidlimit(Range boundRange)Limits this range by another one.voidpad(double ratio)Adds padding to either end of this range.voidsetBounds(double[] bounds)Resets the bounds of this range.voidsetBounds(double lo, double hi)Resets the bounds of this range.voidsubmit(double datum)Submits a value to this range.java.lang.StringtoString()
-
-
-
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 boundhi- upper bound
-
Range
public Range(double[] bounds)
Constructs a range with given lower and upper bounds. The first two elements of theboundsarray 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 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 theboundsarray 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 thepositiveparameter 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
public void limit(Range boundRange)
Limits this range by another one. If either of the bounds ofboundRangeis 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(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-