org.omegahat.Graphics.Primitives
Class Scale

java.lang.Object
  |
  +--org.omegahat.Graphics.Primitives.Scale
All Implemented Interfaces:
ScaleInt

public class Scale
extends java.lang.Object
implements ScaleInt

A scale (e.g., for an axis), defined by a minimum and maximum value.

Scales can be constructed from an array of numbers or specified directly. Scale objects are typically used to control the plotting limits of a graphical element.

The pretty method converts a scale into an axis, having a lower and upper bound and a number of intervals. The computed axis will be within the range defined by the scale.


Field Summary
protected  double max
           
protected  double min
           
 
Constructor Summary
Scale()
           
Scale(double[] data)
          use the range of the data.
Scale(double min, double max)
          use the supplied minimum and maximum.
 
Method Summary
 double log10(double x)
           
 double max()
          Retrieve the maximum of this scale.
 double max(double v)
          Set the maximum of this scale.
 double min()
          Retrieve the minimum of this scale.
 double min(double v)
          Set the minimum of this scale.
 AxisRangeInt pretty(int n)
           
 ScaleInt reScale(double[] data)
          extend the scale by the range of the data.
 java.lang.String toString()
           
 double transformDimension(double dim)
          transform dimension (scale) in native units to normalized parent co-ordinates.
 double transformLocation(double locn)
          transform location in native units to normalized parent co-ordinates.
 double transformToNative(double value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

min

protected double min

max

protected double max
Constructor Detail

Scale

public Scale()

Scale

public Scale(double min,
             double max)
use the supplied minimum and maximum.

Scale

public Scale(double[] data)
use the range of the data.

Values of NaN in the data are allowed, and ignored.

Method Detail

min

public double min()
Description copied from interface: ScaleInt
Retrieve the minimum of this scale.
Specified by:
min in interface ScaleInt

min

public double min(double v)
Description copied from interface: ScaleInt
Set the minimum of this scale.
Specified by:
min in interface ScaleInt

max

public double max()
Description copied from interface: ScaleInt
Retrieve the maximum of this scale.
Specified by:
max in interface ScaleInt

max

public double max(double v)
Description copied from interface: ScaleInt
Set the maximum of this scale.
Specified by:
max in interface ScaleInt

reScale

public ScaleInt reScale(double[] data)
extend the scale by the range of the data.

NaN values in the data are allowed and ignored.

Specified by:
reScale in interface ScaleInt

transformLocation

public double transformLocation(double locn)
transform location in native units to normalized parent co-ordinates.
Specified by:
transformLocation in interface ScaleInt

transformDimension

public double transformDimension(double dim)
transform dimension (scale) in native units to normalized parent co-ordinates.
Specified by:
transformDimension in interface ScaleInt

log10

public double log10(double x)

transformToNative

public double transformToNative(double value)
Specified by:
transformToNative in interface ScaleInt

pretty

public AxisRangeInt pretty(int n)
Specified by:
pretty in interface ScaleInt

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object