com.ijchart.xychart.range
Class NumberRange

java.lang.Object
  extended by com.ijchart.xychart.range.NumberRange
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable
Direct Known Subclasses:
DateRange

public class NumberRange
extends java.lang.Object
implements java.io.Serializable, java.lang.Cloneable

Title: IJChart

Description: a chart library for the Java(tm) platform.

Represents an immutable range of values.

Copyright: Copyright (c) 2013

Company:

Version:
1.0
Author:
zhang feng min,shanghai china. Contract me by email.
See Also:
Serialized Form

Field Summary
static NumberRange RANGE_ZERO
           The NumberRange object with lower and upper value both 0.
 
Constructor Summary
NumberRange(double lower, double upper)
           Creates a new range.
 
Method Summary
protected  java.lang.Object clone()
           Creates and returns a copy of this object.
 boolean contains(double value)
           Returns true if the range contains the specified value and false otherwise.
 boolean equals(java.lang.Object obj)
           Tests this object for equality with an arbitrary object.
 double getCentralValue()
           Returns the central value for the range.
 double getLength()
           Returns the length of the range.
 double getLowerBound()
           Returns the lower bound for the range.
 double getUpperBound()
           Returns the upper bound for the range.
 int hashCode()
           Returns a hash code.
 NumberRange resizeRange(double percent)
           Increases or decreases the range by the specified percentage about the specified anchor value.
 NumberRange resizeRange(double percent, double anchorValue)
           Increases or decreases the range by the specified percentage about the specified anchor value.
 NumberRange resizeRange2(double percent, double anchorValue)
           Increases or decreases the range by the specified percentage about the specified anchor value.
 java.lang.String toString()
           Returns a string representation of this Range.
 NumberRange zoomRange(double lowerPercent, double upperPercent, boolean invert)
           Zooms in on the current range.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

RANGE_ZERO

public static final NumberRange RANGE_ZERO
The NumberRange object with lower and upper value both 0.

Constructor Detail

NumberRange

public NumberRange(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

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)
Returns true if the range contains the specified value and false otherwise.

Parameters:
value - double The value.
Returns:
boolean A boolean.

resizeRange

public NumberRange resizeRange(double percent)
Increases or decreases the range by the specified percentage about the specified anchor value.

To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).

Parameters:
percent - double The resize factor.
Returns:
NumberRange Returns the new NumberRange,if percent<=0 return null.

resizeRange

public NumberRange resizeRange(double percent,
                               double anchorValue)
Increases or decreases the range by the specified percentage about the specified anchor value.

To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).

Parameters:
percent - double The resize factor.
anchorValue - double the new central value after the resize.
Returns:
NumberRange Returns the new NumberRange,if percent<=0 return null.

resizeRange2

public NumberRange resizeRange2(double percent,
                                double anchorValue)
Increases or decreases the range by the specified percentage about the specified anchor value.

To double the length of the axis range, use 200% (2.0). To halve the length of the axis range, use 50% (0.5).

Parameters:
percent - double The resize factor.
anchorValue - double the new central value after the resize.
Returns:
NumberRange The new NumberRange,if percent<=0 return null.

zoomRange

public NumberRange zoomRange(double lowerPercent,
                             double upperPercent,
                             boolean invert)
Zooms in on the current range.

Parameters:
lowerPercent - double The new lower bound.
upperPercent - double The new upper bound.
invert - boolean Whether or not the axis is invert.
Returns:
NumberRange The new NumberRange,if percent<=0 return null.

equals

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

Overrides:
equals in class java.lang.Object
Parameters:
obj - The object to test against (null permitted).
Returns:
A boolean.

hashCode

public int hashCode()
Returns a hash code.

Overrides:
hashCode in class java.lang.Object
Returns:
A hash code.

clone

protected java.lang.Object clone()
                          throws java.lang.CloneNotSupportedException
Creates and returns a copy of this object.

Overrides:
clone in class java.lang.Object
Returns:
Object
Throws:
java.lang.CloneNotSupportedException

toString

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

Overrides:
toString in class java.lang.Object
Returns:
A String.