|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectlt.monarch.chart.mapper.NormalizedMathRange
public class NormalizedMathRange extends java.lang.Object implements Range<java.lang.Double>, java.io.Serializable
Manages a range of double values. Range minimum and maximum values are adjusted to the nearest round values in a
decimal system.
For example: [-4, 19] will be adjusted to [-5,20]
Then reasonable division mark spacings are calculated.
| Modifier and Type | Field and Description |
|---|---|
protected double |
firstMark
|
protected static double |
log10
|
protected double |
max
|
protected double |
min
|
protected int |
minSteps
|
protected int |
neededPrecision
|
protected double |
precision
|
protected int |
precisionPlaces
|
protected double |
requestedMax
|
protected double |
requestedMin
|
protected double |
step
|
protected int |
steps
|
| Constructor and Description |
|---|
NormalizedMathRange(double min,
double max)
Constructs a new NormalizedMathRange with the specified start and end of the
range. |
NormalizedMathRange(Range<java.lang.Double> r)
Constructs a new NormalizedMathRange. |
| Modifier and Type | Method and Description |
|---|---|
void |
adjustRange()
Adjusts the range. |
void |
adjustSteps()
Adjusts step size. |
protected void |
determineStepCount()
Determines step count in the range. |
protected int |
findNeededPrecision()
|
java.lang.String |
format(double val)
Returns a string representation of the specified double value. |
java.lang.String |
formatPrecise(double val)
Returns a string representation of the specified double value. |
double |
getFirstMark()
Gets a value of the first mark in the range. |
java.lang.Double |
getMaximum()
Gets the end (maximum value) of the range. |
java.lang.Double |
getMinimum()
Gets the start (minimum value) of the range. |
int |
getPrecisionPlaces()
Gets the precision places. |
double |
getRange()
Gets an extent of the range. |
double |
getStep()
Gets a size of step in the range. |
int |
getStepCount()
Gets a number of steps in the range. |
boolean |
inRange(double v)
Checks whether the specified double value is in this range. |
double |
map(double value)
Finds a position of the specified double value in this range. |
double |
mapBack(double pos)
Finds a number corresponding to the specified position in this range. |
void |
setMinimumSteps(int minSteps)
Sets a minimum number of steps for this range. |
void |
setPrecisionPlaces(int places)
Sets precision places for this range. |
void |
setRange(double min,
double max)
Sets the bounds of this range to the specified values. |
void |
setRange(Range<java.lang.Double> r)
Sets bounds of this range equal to the bounds of the specified range. |
void |
setRangeMinimum(double m)
Sets minimum of the range to the specified value. |
void |
setStep(double step)
Sets a step size for this range. |
java.lang.String |
toString()
Returns string representation of this range. |
void |
updateRange(double d)
Updates this range so that the specified value will be in the range. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final double log10
protected double requestedMin
protected double requestedMax
protected double min
protected double max
protected double firstMark
protected double step
protected int minSteps
protected int steps
protected int precisionPlaces
protected double precision
protected int neededPrecision
| Constructor Detail |
|---|
public NormalizedMathRange(double min,
double max)
NormalizedMathRange with the specified start and end of the
range.
min - start of the rangemax - end of the rangepublic NormalizedMathRange(Range<java.lang.Double> r)
NormalizedMathRange. The range bounds are taken from the
specified range.
r - the range to take bounds from| Method Detail |
|---|
public void setRange(Range<java.lang.Double> r)
r - the range to take bounds from
public void setRange(double min,
double max)
min - start of the rangemax - end of the rangepublic void setRangeMinimum(double m)
m - the new range minimumpublic void updateRange(double d)
d - the double valuepublic final double getRange()
getMaximum() - getMinimum().
public final double getFirstMark()
public final java.lang.Double getMinimum()
getMinimum in interface Range<java.lang.Double>public final java.lang.Double getMaximum()
getMaximum in interface Range<java.lang.Double>public final double getStep()
public final int getStepCount()
public final boolean inRange(double v)
v - the double valuetrue if ( v>=getMinimum() && v<=getMaximum() );
false otherwisepublic void setStep(double step)
step - the step size; a number greater than 0.0.public void setPrecisionPlaces(int places)
places - the number of precision placespublic void setMinimumSteps(int minSteps)
minSteps - the minimum number of stepspublic void adjustSteps()
setMinimumSteps(int)public void adjustRange()
(getMaximum() - getMinimum()) / getStep() is equal to mathematical integer.
First step is set to range minimum. Number of steps after adjustment is updated.
protected void determineStepCount()
public java.lang.String format(double val)
val - the double value to formatsetPrecisionPlaces(int)public java.lang.String formatPrecise(double val)
format
method. If step size of the range is greater than 10 the double value is rounded to
mathematical integer and converted to String.
val - the double value to formatsetPrecisionPlaces(int)public double map(double value)
(value-getMinimum()) / getRange() If getRange() returns 0, then
Double.NaN is returned.
value - double value to mapgetMinimum(),
getRange()public double mapBack(double pos)
pos*getRange() + getMinimum() If getRange()
returns 0, then Double.NaN is returned.
pos - position in the range; should be a value in range [0,1]getMinimum(),
getRange()public java.lang.String toString()
toString in class java.lang.Objectprotected int findNeededPrecision()
public int getPrecisionPlaces()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||