Class GRAph

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--GRAph

public class GRAph
extends java.awt.Canvas

This class implements a 2D graph capable of graphing several data sets

See Also:
Serialized Form

Inner Class Summary
 class GRAph.monthDay
          Inner class providing calendar functions.
 
Field Summary
 java.awt.Color[] graph_colors
           
 double[][][] graph_data
          Three dimensional array of data points to be plotted.
 java.lang.String graph_title
          Graph title
 boolean gridOn
          Boolean variable setting grid on or off.
 int margin_bottom
          Pixels between bottom of graph and bottom of window.
 int margin_left
          Pixels between left side of graph and left side of window.
 int margin_right
          Pixels between right side of graph and right side of window.
 int margin_top
          Pixels between top of graph and top of window.
static int[] MONTH_DAYS
          Array giving the starting day number in the year for the first day of each of the 12 months.
static int NORMAL
          Used to specify X axis mode (alternatively, TIME).
 int ticSize
          Size of the tic marks on the X and Y axes, in pixels.
static int TIME
          Used to specify X axis mode (alternatively, NORMAL).
 int xAxisMode
          Defines the mode of the X axis display, NORMAL or TIME.
 double xGridInterval
          Interval between grid lines in X direction.
 double xGridOrigin
          Position of grid origin.
 double xmax
          Defines right boundary of the graph.
 double xmin
          Defines left boundary of the graph.
 double yGridInterval
          Interval between grid lines in Y direction.
 double yGridOrigin
          Position of grid origin.
 double ymax
          Defines top boundary of the graph.
 double ymin
          Defines bottom boundary of the graph.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
GRAph(java.awt.Color[] graph_colors)
          Constructor for GRAph data object.
 
Method Summary
 void autoscale(double[][][] graph_data)
           
 void autoscaleX(double[][][] graph_data)
           
 void autoscaleY(double[][][] graph_data)
           
 void drawTimeTics(java.awt.Graphics g)
          Draw a set of tics for time-marked axis.
 void graphit(double[][][] graph_data)
          If invoked without the bounds being specified, autoscale() is first invoked to set plotting bounds.
 void graphit(double xmin, double xmax, double ymin, double ymax, double[][][] graph_data)
          Used to draw a graph.
 void paint(java.awt.Graphics g)
          This routine is called whenever something changes, to render the graph.
 
Methods inherited from class java.awt.Canvas
addNotify
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TIME

public static final int TIME
Used to specify X axis mode (alternatively, NORMAL).

NORMAL

public static final int NORMAL
Used to specify X axis mode (alternatively, TIME).

MONTH_DAYS

public static final int[] MONTH_DAYS
Array giving the starting day number in the year for the first day of each of the 12 months.

xAxisMode

public int xAxisMode
Defines the mode of the X axis display, NORMAL or TIME.

xmin

public double xmin
Defines left boundary of the graph. Uses the same units as the data being plotted.

xmax

public double xmax
Defines right boundary of the graph. Uses the same units as the data being plotted.

ymin

public double ymin
Defines bottom boundary of the graph. Uses the same units as the data being plotted.

ymax

public double ymax
Defines top boundary of the graph. Uses the same units as the data being plotted.

margin_top

public int margin_top
Pixels between top of graph and top of window.

margin_bottom

public int margin_bottom
Pixels between bottom of graph and bottom of window.

margin_left

public int margin_left
Pixels between left side of graph and left side of window.

margin_right

public int margin_right
Pixels between right side of graph and right side of window.

graph_title

public java.lang.String graph_title
Graph title

xGridInterval

public double xGridInterval
Interval between grid lines in X direction. Units are the same as X data.

yGridInterval

public double yGridInterval
Interval between grid lines in Y direction. Units are the same as Y data.

xGridOrigin

public double xGridOrigin
Position of grid origin. Units are the same as X data.

yGridOrigin

public double yGridOrigin
Position of grid origin. Units are the same as Y data.

ticSize

public int ticSize
Size of the tic marks on the X and Y axes, in pixels.

gridOn

public boolean gridOn
Boolean variable setting grid on or off.

graph_data

public double[][][] graph_data
Three dimensional array of data points to be plotted. Holds an arbitrary number of sets of x-y data. first index selects the data set number. Second index selects x (0) or y (1) Third index selects the data value. There must be 1-1 correspondence between x and y values, but the number of data points may vary across data sets.

graph_colors

public java.awt.Color[] graph_colors
Constructor Detail

GRAph

public GRAph(java.awt.Color[] graph_colors)
Constructor for GRAph data object. Sets up a blank canvas, with colors initialized for plotting. Nothing is actually plotted.
Method Detail

graphit

public void graphit(double xmin,
                    double xmax,
                    double ymin,
                    double ymax,
                    double[][][] graph_data)
Used to draw a graph. xmin, xmax, ymin, ymax define the bounds of the graph area, in units of plotted data. Data is a 3 dimensional array containing arbitrary number of sets of x-y points: first dimension selects data set, second specifies x (0)or y (1), and third is an array of x or y data. For each set of data being graphed, both x and y values must exist and be of the same size. Different data sets may be of different size.

graphit

public void graphit(double[][][] graph_data)
If invoked without the bounds being specified, autoscale() is first invoked to set plotting bounds.

paint

public void paint(java.awt.Graphics g)
This routine is called whenever something changes, to render the graph.
Overrides:
paint in class java.awt.Canvas

drawTimeTics

public void drawTimeTics(java.awt.Graphics g)
Draw a set of tics for time-marked axis.

autoscaleX

public void autoscaleX(double[][][] graph_data)

autoscaleY

public void autoscaleY(double[][][] graph_data)

autoscale

public void autoscale(double[][][] graph_data)