All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class mkgray.gui.SimpleGraph

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----mkgray.gui.SimpleGraph

public class SimpleGraph
extends Canvas
SimpleGraph is a basic graphing component, useful for graphing time series data. You might use it something like this:
Frame f = new Frame();
SimpleGraph sg = new SimpleGraph();
sg.sliding(true);
sg.windowWidth(100.0);
sg.tickSeperation(10.0);
// More GUI setup here
while(true){
double x = getX();
double y = getY();
sg.addPoint(x, y);
}


Constructor Index

 o SimpleGraph()

Method Index

 o addPoint(double, double)
Add a point to the graph
 o debug(boolean)
 o paint(Graphics)
Paint the graph
 o range(double, double)
Set the y range of the graph
 o sliding(boolean)
If set to true, the graph will view a sliding window of data not exceeding width set by windowWidth
 o tickless(boolean)
Drawing tick marks is "slow" (for some reason it sometimes takes over 200ms to draw them) so if you are adding points faster than 5 per second, you may want to disable ticks.
 o tickSeperation(double)
This value specifies how far apart horizontal tick marks should be
 o update(Graphics)
Update the graph.
 o windowWidth(double)
If the window is sliding, the minimum x value displayed will be no less than the maximum x value minus v

Constructors

 o SimpleGraph
 public SimpleGraph()

Methods

 o addPoint
 public void addPoint(double x,
                      double y)
Add a point to the graph

Parameters:
x - X coordinate of the data point
y - Y coordinate of the data point
 o update
 public void update(Graphics g)
Update the graph. DoubleBuffer it.

Overrides:
update in class Component
 o range
 public void range(double low,
                   double high)
Set the y range of the graph

Parameters:
low - Lowest y value to display
high - Highest y value to display
 o sliding
 public void sliding(boolean s)
If set to true, the graph will view a sliding window of data not exceeding width set by windowWidth

Parameters:
s - true if the graph should be sliding
 o tickless
 public void tickless(boolean s)
Drawing tick marks is "slow" (for some reason it sometimes takes over 200ms to draw them) so if you are adding points faster than 5 per second, you may want to disable ticks. This bug will be fixed eventually.

Parameters:
s - true if the graph should not be labeled with tick marks
 o debug
 public void debug(boolean s)
Parameters:
s - true if debugging output should be displayed
 o windowWidth
 public void windowWidth(double v)
If the window is sliding, the minimum x value displayed will be no less than the maximum x value minus v

Parameters:
v - width of the window to be displayed
 o tickSeperation
 public void tickSeperation(double v)
This value specifies how far apart horizontal tick marks should be

Parameters:
v - tick seperation
 o paint
 public void paint(Graphics g)
Paint the graph

Overrides:
paint in class Canvas

All Packages  Class Hierarchy  This Package  Previous  Next  Index