Package org.jfree.data
Class Range
java.lang.Object
org.jfree.data.Range
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DateRange
public class Range extends Object implements Serializable
Represents an immutable range of values.
- See Also:
- Serialized Form
-
Constructor Summary
Constructors Constructor Description Range(double lower, double upper)Creates a new range. -
Method Summary
Modifier and Type Method Description static Rangecombine(Range range1, Range range2)Creates a new range by combining two existing ranges.doubleconstrain(double value)Returns the value within the range that is closest to the specified value.booleancontains(double value)Returnstrueif the range contains the specified value andfalseotherwise.booleanequals(Object object)Tests this object for equality with an arbitrary object.static Rangeexpand(Range range, double lowerMargin, double upperMargin)Creates a new range by adding margins to an existing range.doublegetCentralValue()Returns the central value for the range.doublegetLength()Returns the length of the range.doublegetLowerBound()Returns the lower bound for the range.doublegetUpperBound()Returns the upper bound for the range.inthashCode()Returns a hash code.booleanintersects(double b0, double b1)Returnstrueif the range intersects with the specified range, andfalseotherwise.StringtoString()Returns a string representation of this Range.
-
Constructor Details
-
Range
public Range(double lower, double upper)Creates a new range.- Parameters:
lower- the lower bound (must be <= upper bound).upper- the upper bound (must be >= lower bound).
-
-
Method Details
-
getLowerBound
public double getLowerBound()Returns the lower bound for the range.- Returns:
- The lower bound.
-
getUpperBound
public double getUpperBound()Returns the upper bound for the range.- Returns:
- The upper bound.
-
getLength
public double getLength()Returns the length of the range.- Returns:
- The length.
-
getCentralValue
public double getCentralValue()Returns the central value for the range.- Returns:
- The central value.
-
contains
public boolean contains(double value)Returnstrueif the range contains the specified value andfalseotherwise.- Parameters:
value- the value to lookup.- Returns:
trueif the range contains the specified value.
-
intersects
public boolean intersects(double b0, double b1)Returnstrueif the range intersects with the specified range, andfalseotherwise.- Parameters:
b0- the lower bound.b1- the upper bound.- Returns:
- A boolean.
-
constrain
public double constrain(double value)Returns the value within the range that is closest to the specified value.- Parameters:
value- the value.- Returns:
- The constrained value.
-
combine
Creates a new range by combining two existing ranges.Note that:
- either range can be
null, in which case the other range is returned; - if both ranges are
nullthe return value isnull.
- Parameters:
range1- the first range (nullpermitted).range2- the second range (nullpermitted).- Returns:
- A new range (possibly
null).
- either range can be
-
expand
Creates a new range by adding margins to an existing range.- Parameters:
range- the range (nullnot permitted).lowerMargin- the lower margin (expressed as a percentage of the range length).upperMargin- the upper margin (expressed as a percentage of the range length).- Returns:
- The expanded range.
-
equals
Tests this object for equality with an arbitrary object. -
hashCode
public int hashCode()Returns a hash code. -
toString
Returns a string representation of this Range.
-