Package org.jfree.data
Class Range
java.lang.Object
org.jfree.data.Range
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
DateRange
Represents an immutable range of values.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RangeCreates a new range by combining two existing ranges.static RangecombineIgnoringNaN(Range range1, Range range2) Returns a new range that spans bothrange1andrange2.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.booleanTests this object for equality with an arbitrary object.static RangeCreates a new range by adding margins to an existing range.static RangeexpandToInclude(Range range, double value) Returns a range that includes all the values in the specifiedrangeAND the specifiedvalue.doubleReturns the central value for the range.doubleReturns the length of the range.doubleReturns the lower bound for the range.doubleReturns 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.booleanintersects(Range range) Returnstrueif the range intersects with the specified range, andfalseotherwise.booleanReturnstrueif both the lower and upper bounds areDouble.NaN, andfalseotherwise.static RangeScales the range by the specified factor.static RangeShifts the range by the specified amount.static RangeShifts the range by the specified amount.toString()Returns a string representation of this Range.
-
Constructor Details
-
Range
Creates a new range.- Parameters:
lower- the lower bound (must be <= upper bound).upper- the upper bound (must be >= lower bound).
-
-
Method Details
-
getLowerBound
Returns the lower bound for the range.- Returns:
- The lower bound.
-
getUpperBound
Returns the upper bound for the range.- Returns:
- The upper bound.
-
getLength
Returns the length of the range.- Returns:
- The length.
-
getCentralValue
Returns the central value for the range.- Returns:
- The central value.
-
contains
Returnstrueif the range contains the specified value andfalseotherwise.- Parameters:
value- the value to lookup.- Returns:
trueif the range contains the specified value.
-
intersects
Returnstrueif the range intersects with the specified range, andfalseotherwise.- Parameters:
b0- the lower bound (should be <= b1).b1- the upper bound (should be >= b0).- Returns:
- A boolean.
-
intersects
Returnstrueif the range intersects with the specified range, andfalseotherwise.- Parameters:
range- another range (nullnot permitted).- Returns:
- A boolean.
-
constrain
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
-
combineIgnoringNaN
Returns a new range that spans bothrange1andrange2. This method has a special handling to ignore Double.NaN values.- Parameters:
range1- the first range (nullpermitted).range2- the second range (nullpermitted).- Returns:
- A new range (possibly
null).
-
expandToInclude
Returns a range that includes all the values in the specifiedrangeAND the specifiedvalue.- Parameters:
range- the range (nullpermitted).value- the value that must be included.- Returns:
- A range.
-
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.
-
shift
Shifts the range by the specified amount.- Parameters:
base- the base range (nullnot permitted).delta- the shift amount.- Returns:
- A new range.
-
shift
Shifts the range by the specified amount.- Parameters:
base- the base range (nullnot permitted).delta- the shift amount.allowZeroCrossing- a flag that determines whether or not the bounds of the range are allowed to cross zero after adjustment.- Returns:
- A new range.
-
scale
Scales the range by the specified factor.- Parameters:
base- the base range (nullnot permitted).factor- the scaling factor (must be non-negative).- Returns:
- A new range.
-
equals
Tests this object for equality with an arbitrary object. -
isNaNRange
Returnstrueif both the lower and upper bounds areDouble.NaN, andfalseotherwise.- Returns:
- A boolean.
-
hashCode
Returns a hash code. -
toString
Returns a string representation of this Range.
-