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);
}
-
SimpleGraph()
-
-
addPoint(double, double)
- Add a point to the graph
-
debug(boolean)
-
-
paint(Graphics)
-
Paint the graph
-
range(double, double)
- Set the y range of the graph
-
sliding(boolean)
- If set to true, the graph will view a sliding window of data not
exceeding width set by windowWidth
-
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.
-
tickSeperation(double)
- This value specifies how far apart horizontal tick marks should be
-
update(Graphics)
- Update the graph.
-
windowWidth(double)
- If the window is sliding, the minimum x value displayed will be no
less than the maximum x value minus v
SimpleGraph
public SimpleGraph()
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
update
public void update(Graphics g)
- Update the graph. DoubleBuffer it.
- Overrides:
- update in class Component
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
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
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
debug
public void debug(boolean s)
- Parameters:
- s - true if debugging output should be displayed
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
tickSeperation
public void tickSeperation(double v)
- This value specifies how far apart horizontal tick marks should be
- Parameters:
- v - tick seperation
paint
public void paint(Graphics g)
- Paint the graph
- Overrides:
- paint in class Canvas
All Packages Class Hierarchy This Package Previous Next Index