randsburg
Class GraphMethods

java.lang.Object
  |
  +--randsburg.GraphMethods

public class GraphMethods
extends java.lang.Object

static methods for graph classes


Field Summary
static int HIGH
           
static int HORIZONTAL
           
static int LOW
           
static int VERTICAL
           
 
Constructor Summary
GraphMethods()
           
 
Method Summary
static float[] findGrid(double lowValue, double highValue, int graphPixels)
          Find good grid values for scales and grid lines
static void paintScale(java.awt.Graphics g, GraphInfo gi, int direction, boolean labelAxes)
          static method to paint a reasonable scale on a graph grid should be found be a call to findGrid above
static void paintVerticalGrid(java.awt.Graphics g, double[] scaledVGrid, int offsetLeft, int graphWidth, java.awt.Color gridColor)
          Before using the grid to paint a vertical grid, need to scale locally
protected static int scale(double value, double lowValue, double highValue, int direction, int offset, int graphSize)
           
static int setMaxFractionDigits(double max, double min)
          try to determine a reasonable number of decimal places to show in labels
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HORIZONTAL

public static final int HORIZONTAL
See Also:
Constant Field Values

VERTICAL

public static final int VERTICAL
See Also:
Constant Field Values

LOW

public static final int LOW
See Also:
Constant Field Values

HIGH

public static final int HIGH
See Also:
Constant Field Values
Constructor Detail

GraphMethods

public GraphMethods()
Method Detail

setMaxFractionDigits

public static int setMaxFractionDigits(double max,
                                       double min)
try to determine a reasonable number of decimal places to show in labels


findGrid

public static float[] findGrid(double lowValue,
                               double highValue,
                               int graphPixels)
Find good grid values for scales and grid lines

Parameters:
lowValue - The lower endpoint of the scale
highValue - iThe upper endpoint of the scale
graphPixels - The dimension of the scale in pixel space
Returns:
an array of floats to draw the grid at

paintVerticalGrid

public static void paintVerticalGrid(java.awt.Graphics g,
                                     double[] scaledVGrid,
                                     int offsetLeft,
                                     int graphWidth,
                                     java.awt.Color gridColor)
Before using the grid to paint a vertical grid, need to scale locally


paintScale

public static void paintScale(java.awt.Graphics g,
                              GraphInfo gi,
                              int direction,
                              boolean labelAxes)
static method to paint a reasonable scale on a graph grid should be found be a call to findGrid above

Parameters:
g - the Graphics object of the graph
gi - GraphInfo object
direction - one of VERTICAL or HORIZONTAL
labelAxes - whether to label axes

scale

protected static int scale(double value,
                           double lowValue,
                           double highValue,
                           int direction,
                           int offset,
                           int graphSize)