Package com.jidesoft.range
Class NumericRange
- java.lang.Object
-
- com.jidesoft.range.AbstractRange<T>
-
- com.jidesoft.range.AbstractNumericRange<java.lang.Double>
-
- com.jidesoft.range.NumericRange
-
public class NumericRange extends AbstractNumericRange<java.lang.Double>
Specifies upper and lower bounds for a range of values- Author:
- Simon
-
-
Field Summary
Fields Modifier and Type Field Description protected double
_max
protected double
_min
-
Fields inherited from interface com.jidesoft.range.Range
PROPERTY_MAX, PROPERTY_MIN
-
-
Constructor Summary
Constructors Constructor Description NumericRange()
Creates a numeric range with minimum 0.0 and maximum of 1.0NumericRange(double min, double max)
Create a numeric range by supplying minimum and maximum valuesNumericRange(NumericRange numericRange)
Creates a copy of the supplied NumericRange
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adjust(java.lang.Double lower, java.lang.Double upper)
Sets the minimum and maximum values of the range in a single callboolean
contains(java.lang.Double x)
Determines whether the range contains the supplied valueRange<java.lang.Double>
copy()
Range<java.lang.Double>
createIntermediate(Range<java.lang.Double> target, double position)
boolean
equals(java.lang.Object other)
Test for equality based on the values of min and maxdouble
getMax()
double
getMin()
int
hashCode()
java.lang.Double
lower()
double
maximum()
This may be the numeric representation of upper() or it may be rounded up.double
minimum()
This may be the numeric representation of lower() or it may be rounded down.void
setMax(double max)
Sets the maximum valuevoid
setMin(double min)
Sets the minimum valuedouble
size()
Compute the size of the rangeNumericRange
stretch(double stretchFactor)
Creates a new NumericRange by enlarging this numeric range about its mid-point.NumericRange
stretch(double stretchFactorForLower, double stretchFactorForUpper)
Creates a new NumericRange by enlarging this numeric range about its mid-point.java.lang.String
toString()
static NumericRange
union(NumericRange r1, NumericRange r2)
Creates a new NumericRange as the union of two existing NumericRanges.java.lang.Double
upper()
-
Methods inherited from class com.jidesoft.range.AbstractRange
addPropertyChangeListener, compareTo, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, removePropertyChangeListener
-
-
-
-
Constructor Detail
-
NumericRange
public NumericRange()
Creates a numeric range with minimum 0.0 and maximum of 1.0
-
NumericRange
public NumericRange(double min, double max)
Create a numeric range by supplying minimum and maximum values- Parameters:
min
- the minumummax
- the maximum
-
NumericRange
public NumericRange(NumericRange numericRange)
Creates a copy of the supplied NumericRange- Parameters:
numericRange
- the NumericRange instance to copy
-
-
Method Detail
-
copy
public Range<java.lang.Double> copy()
- Overrides:
copy
in classAbstractRange<java.lang.Double>
-
minimum
public double minimum()
Description copied from interface:Range
This may be the numeric representation of lower() or it may be rounded down.- Returns:
- the minimum value
-
maximum
public double maximum()
Description copied from interface:Range
This may be the numeric representation of upper() or it may be rounded up.- Returns:
- the maximum value
-
getMin
public double getMin()
- Returns:
- the minimum value
-
setMin
public void setMin(double min)
Sets the minimum value- Parameters:
min
- the new minimum value.
-
getMax
public double getMax()
- Returns:
- the maximum value
-
setMax
public void setMax(double max)
Sets the maximum value- Parameters:
max
- the new maximum value.
-
size
public double size()
Description copied from interface:Range
Compute the size of the range- Returns:
- the size of the range
-
lower
public java.lang.Double lower()
- Returns:
- the minimum() value for the range
-
adjust
public void adjust(java.lang.Double lower, java.lang.Double upper)
Sets the minimum and maximum values of the range in a single call- Parameters:
lower
- the new smallest value of the rangeupper
- the new largest value of the range
-
upper
public java.lang.Double upper()
- Returns:
- the maximum() value for the range
-
contains
public boolean contains(java.lang.Double x)
Determines whether the range contains the supplied value- Returns:
- a boolean to indicate whether the supplied point lies within the range
-
stretch
public NumericRange stretch(double stretchFactor)
Creates a new NumericRange by enlarging this numeric range about its mid-point. For example to make it 10% bigger, use a stretch factor of 1.1. Note that this method can also be used to shrink a NumericRange.- Parameters:
stretchFactor
- the multiplication factor for the enlargement- Returns:
- a new NumericRange
-
stretch
public NumericRange stretch(double stretchFactorForLower, double stretchFactorForUpper)
Creates a new NumericRange by enlarging this numeric range about its mid-point. For example to make it 10% bigger, use a stretch factor of 1.1. Note that this method can also be used to shrink a NumericRange.- Parameters:
stretchFactorForLower
- the multiplication factor for the enlargement for the lower rangestretchFactorForUpper
- the multiplication factor for the enlargement for the upper range- Returns:
- a new NumericRange
-
createIntermediate
public Range<java.lang.Double> createIntermediate(Range<java.lang.Double> target, double position)
- Specified by:
createIntermediate
in classAbstractRange<java.lang.Double>
-
equals
public boolean equals(java.lang.Object other)
Test for equality based on the values of min and max- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
union
public static NumericRange union(NumericRange r1, NumericRange r2)
Creates a new NumericRange as the union of two existing NumericRanges. The date format of the first time range is retained in the returned result.- Parameters:
r1
- the first NumericRanger2
- the second NumericRange- Returns:
- the union of the supplied NumericRanges
-
-