com.java4less.rchart
Class Scale

java.lang.Object
  |
  +--com.java4less.rchart.Scale
Direct Known Subclasses:
logScale

public class Scale
extends java.lang.Object


The scale converts the data to screen coordinates. All charts have two scales (except Pies), one per axis.

Example:

// create axis
com.java4less.rchart.Axis XAxis=new Axis(Axis.HORIZONTAL,new Scale());
com.java4less.rchart.Axis YAxis=new Axis(Axis.VERTICAL,new Scale());
XAxis.scale.min=0;
XAxis.scale.max=7;
YAxis.scale.min=0;
YAxis.scale.max=7;

If the min and max properties are not specified, RChart will calculate them from the DataSeries.


Field Summary
 boolean exactMaxValue
          if true, RChart will calculate the max value of the scale using the preferred min/max values list
default value is true for Y axis and false for X axis.
 boolean exactMinValue
          if true, RChart will calculate the min value of the scale using the preferred max values list
default value is true for Y axis and false for X axis.
 double max
          maximum value of the scale.
 double min
          minimum value of the scale.
 double[] preferred_MaxMin_values
          sorted list of preferred values for minimum and maximum values.
 boolean reverse
          internal use.
 int screenMax
          maximum value of scale on the screen.
 int screenMaxMargin
          internal use.
 int screenMin
          minimum value of scale on the screen.
 
Constructor Summary
Scale()
           
Scale(int ma, int mi)
          creates a scale with the specifed max and min values.
 
Method Summary
 int getScreenCoord(double v)
          convert a value to the screen coordinate.
 double getValue(int c)
          converts a screen coordinate to the real value.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

exactMaxValue

public boolean exactMaxValue
if true, RChart will calculate the max value of the scale using the preferred min/max values list
default value is true for Y axis and false for X axis.

exactMinValue

public boolean exactMinValue
if true, RChart will calculate the min value of the scale using the preferred max values list
default value is true for Y axis and false for X axis.

preferred_MaxMin_values

public double[] preferred_MaxMin_values
sorted list of preferred values for minimum and maximum values. It is u sed together with exactMaxValue and exactMinValue to calculate the min max values of the scale

Default is:
new {-1000000,-500000,-100000,-50000,-10000,-5000,-1000,-500,-250,-100,-50,-25-10,-5,-1,-0.5,-0.1,0,0.1,0.5,1,5,10,25,50,100,250,500,1000,5000,10000,50000,100000,500000,1000000};

max

public double max
maximum value of the scale.

min

public double min
minimum value of the scale.

screenMax

public int screenMax
maximum value of scale on the screen.

screenMaxMargin

public int screenMaxMargin
internal use. Calculated by Chart.

screenMin

public int screenMin
minimum value of scale on the screen.

reverse

public boolean reverse
internal use. It is true if the scale corresponds to the vertical axis. In the vertical axis the screen coordinate of the min value is greater than the screen coordinate of the max value.
Constructor Detail

Scale

public Scale()

Scale

public Scale(int ma,
             int mi)
creates a scale with the specifed max and min values.
Method Detail

getScreenCoord

public int getScreenCoord(double v)
convert a value to the screen coordinate.

getValue

public double getValue(int c)
converts a screen coordinate to the real value.