org.jfree.data

Class Range

public strictfp class Range extends Object implements Serializable

Represents an immutable range of values.
Constructor Summary
Range(double lower, double upper)
Creates a new range.
Method Summary
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)
Returns true if the range contains the specified value and false otherwise.
booleanequals(Object obj)
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.
static RangeexpandToInclude(Range range, double value)
Returns a range that includes all the values in the specified range AND the specified value.
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)
Returns true if the range intersects with the specified range, and false otherwise.
booleanintersects(Range range)
Returns true if the range intersects with the specified range, and false otherwise.
static Rangescale(Range base, double factor)
Scales the range by the specified factor.
static Rangeshift(Range base, double delta)
Shifts the range by the specified amount.
static Rangeshift(Range base, double delta, boolean allowZeroCrossing)
Shifts the range by the specified amount.
StringtoString()
Returns a string representation of this Range.

Constructor Detail

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 Detail

combine

public static Range combine(Range range1, Range range2)
Creates a new range by combining two existing ranges.

Note that:

Parameters: range1 the first range (null permitted). range2 the second range (null permitted).

Returns: A new range (possibly null).

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.

contains

public boolean contains(double value)
Returns true if the range contains the specified value and false otherwise.

Parameters: value the value to lookup.

Returns: true if the range contains the specified value.

equals

public boolean equals(Object obj)
Tests this object for equality with an arbitrary object.

Parameters: obj the object to test against (null permitted).

Returns: A boolean.

expand

public static Range expand(Range range, double lowerMargin, double upperMargin)
Creates a new range by adding margins to an existing range.

Parameters: range the range (null not 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.

expandToInclude

public static Range expandToInclude(Range range, double value)
Returns a range that includes all the values in the specified range AND the specified value.

Parameters: range the range (null permitted). value the value that must be included.

Returns: A range.

Since: 1.0.1

getCentralValue

public double getCentralValue()
Returns the central value for the range.

Returns: The central value.

getLength

public double getLength()
Returns the length of the range.

Returns: The length.

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.

hashCode

public int hashCode()
Returns a hash code.

Returns: A hash code.

intersects

public boolean intersects(double b0, double b1)
Returns true if the range intersects with the specified range, and false otherwise.

Parameters: b0 the lower bound (should be <= b1). b1 the upper bound (should be >= b0).

Returns: A boolean.

intersects

public boolean intersects(Range range)
Returns true if the range intersects with the specified range, and false otherwise.

Parameters: range another range (null not permitted).

Returns: A boolean.

Since: 1.0.9

scale

public static Range scale(Range base, double factor)
Scales the range by the specified factor.

Parameters: base the base range (null not permitted). factor the scaling factor (must be non-negative).

Returns: A new range.

Since: 1.0.9

shift

public static Range shift(Range base, double delta)
Shifts the range by the specified amount.

Parameters: base the base range (null not permitted). delta the shift amount.

Returns: A new range.

shift

public static Range shift(Range base, double delta, boolean allowZeroCrossing)
Shifts the range by the specified amount.

Parameters: base the base range (null not 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.

toString

public String toString()
Returns a string representation of this Range.

Returns: A String "Range[lower,upper]" where lower=lower range and upper=upper range.