All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ChaosDemos.superGraph2D

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----graph.Graph2D
                           |
                           +----ChaosDemos.superGraph2D

public class superGraph2D
extends Graph2D
Class to make and modify 2D graph
Subclass of Graph2D by Leigh Brookshaw
Maximum number of curves is 10

Version:
15 March 1997
Author:
Michael Cross

Variable Index

 o allowDrag
 o xaxis
The x-axis of the graph
 o yaxis
The y-axis of the graph

Constructor Index

 o superGraph2D()
Default Constructor
 o superGraph2D(double, double, double, double)
Constructor givin minimum and maximum coordinates (can be rescaled later)
 o superGraph2D(dynamicGraph)
Constructor given dynamicGraph parent

Method Index

 o addCurve(double[], int, Color)
Adds an additional curve to be plotted
Returns index number of curve.
 o addCurve(double[], int, Color, int, int, double)
Adds an additional curve to be plotted
Returns index number of curve.
 o appendToCurve(double[], int, int)
Adds npts from indata[] to curve n
 o deleteAllCurves()
Deletes all curves
 o deleteFromCurve(int)
 o deleteFromCurve(int, int)
Deletes points from BEGINNING of curve
 o getData(int, int)
Returns first np points in curve n
 o mouseDown(Event, int, int)
Respond to mouse click in graph
calls respondToMouse(xcoord, xcoordValid, ycoord, ycoordValid) with (xcoord,ycoord) the coordinates of the event (in units of the axes) and xcoordValid true if coordinate within range of axis etc.
 o mouseDrag(Event, int, int)
 o mouseUp(Event, int, int)
 o nPoints(int)
Returns number of points in curve n
 o paintBeforeData(Graphics, Rectangle)
Connects to addToGraph method in parent.
 o paintFirst(Graphics, Rectangle)
Interface to Graph2D that is called before cruves are drawn in paint
 o setTitle(String)
Sets title string
 o setXAxisTitle(String)
Sets x-axis title
 o setYAxisTitle(String)
Sets y-axis title
 o update(Graphics)
This method is called through the repaint() method.

Variables

 o xaxis
 public Axis xaxis
The x-axis of the graph

 o yaxis
 public Axis yaxis
The y-axis of the graph

 o allowDrag
 public boolean allowDrag

Constructors

 o superGraph2D
 public superGraph2D()
Default Constructor

 o superGraph2D
 public superGraph2D(dynamicGraph target)
Constructor given dynamicGraph parent

Parameters:
target - parent of type dynamicGraph
 o superGraph2D
 public superGraph2D(double xmin,
                     double ymin,
                     double xmax,
                     double ymax)
Constructor givin minimum and maximum coordinates (can be rescaled later)

Parameters:
xmin - minimum value of x
xmax - maximum value of x
ymin - minimum value of y
ymax - maximum value of y

Methods

 o addCurve
 public int addCurve(double indata[],
                     int n,
                     Color c)
Adds an additional curve to be plotted
Returns index number of curve.

Parameters:
indata - data to be plotted indata[0]-[2n-1]
n - data points used are indata[0]-[2n-1]
c - color of new curve
Returns:
index number of curves
 o addCurve
 public int addCurve(double indata[],
                     int n,
                     Color c,
                     int linestyle,
                     int marker,
                     double markerscale)
Adds an additional curve to be plotted
Returns index number of curve.

Parameters:
indata - data to be plotted indata[0]-[2n-1]
n - data points used are indata[0]-[2n-1]
c - color of new curve
linestyle - 0 for points, 1 for line
Returns:
index number of added curve
 o appendToCurve
 public void appendToCurve(double indata[],
                           int npt,
                           int n)
Adds npts from indata[] to curve n

Parameters:
indata[] - data to add from
npt - nunmer of points to add
n - index of curve to add to
 o deleteFromCurve
 public void deleteFromCurve(int npt,
                             int n)
Deletes points from BEGINNING of curve

Parameters:
npt - number of points to delete
n - curve to delete from
 o deleteFromCurve
 public void deleteFromCurve(int n)
 o nPoints
 public int nPoints(int n)
Returns number of points in curve n

Parameters:
n - index of curve
Returns:
number of points in curve
 o getData
 public double[] getData(int n,
                         int np)
Returns first np points in curve n

Parameters:
n - index of curve
np - number of points to return (must be less than number in curve)
Returns:
array of points in x,y pairs
 o deleteAllCurves
 public int deleteAllCurves()
Deletes all curves

Returns:
-1 (for number of curves)
 o paintFirst
 public void paintFirst(Graphics g,
                        Rectangle r)
Interface to Graph2D that is called before cruves are drawn in paint

Parameters:
g - reference to Graphics object
r - reference to Rectangle object
Overrides:
paintFirst in class Graph2D
 o setTitle
 public void setTitle(String intitle)
Sets title string

Parameters:
intitle - text for title
 o mouseDown
 public boolean mouseDown(Event evt,
                          int x,
                          int y)
Respond to mouse click in graph
calls respondToMouse(xcoord, xcoordValid, ycoord, ycoordValid) with (xcoord,ycoord) the coordinates of the event (in units of the axes) and xcoordValid true if coordinate within range of axis etc.

Overrides:
mouseDown in class Component
 o mouseUp
 public boolean mouseUp(Event e,
                        int x,
                        int y)
Overrides:
mouseUp in class Component
 o mouseDrag
 public boolean mouseDrag(Event e,
                          int x,
                          int y)
Overrides:
mouseDrag in class Component
 o paintBeforeData
 public void paintBeforeData(Graphics g,
                             Rectangle r)
Connects to addToGraph method in parent. Called by the paint method in Graph2D

Parameters:
g - graphics
r - data rectangle
Overrides:
paintBeforeData in class Graph2D
 o setXAxisTitle
 public void setXAxisTitle(String title)
Sets x-axis title

Parameters:
title - text for x-axis title
 o setYAxisTitle
 public void setYAxisTitle(String title)
Sets y-axis title

Parameters:
title - text for y-axis title
 o update
 public void update(Graphics g)
This method is called through the repaint() method.

Overrides:
update in class Graph2D

All Packages  Class Hierarchy  This Package  Previous  Next  Index