All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ptplot.PlotLive

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----ptplot.PlotBox
                                   |
                                   +----ptplot.Plot
                                           |
                                           +----ptplot.PlotLive

public abstract class PlotLive
extends Plot
implements Runnable
Plot signals dynamically, where points can be added at any time and the the display will be updated. This should be normally used with some finite persistence so that old points are erased as new points are added. Unfortunately, the most efficient way to erase old points is to draw graphics using the "exclusive or" mode, which introduces quite a number of artifacts. When lines are drawn between points, where they overlap the points the line becomes white. Moreover, if two lines or points overlap completely, they disappear.

This class is abstract, so it must be used by creating a derived class. To use it, create a derived class with init() and addPoints() methods. The init() method can call methods in the Plot or PlotBox classes (both of which are base classes) to set the static properties of the graph, such as the title, axis ranges, and axis labels. The addPoints() method should call addPoint() of the Plot base class to dynamically add points to the plot. This method is called within a thread separate from the applet thread.

The init() method must call super.init() somewhere in its body; along with general initialization, this reads a file given by a URL if the dataurl applet parameter is specified. Thus, the initial configuration can be specified in a separate file rather than in Java code.

Version:
@(#)PlotLive.java 1.28 10/25/97
Author:
Edward A. Lee, Christopher Hylands

Constructor Index

 o PlotLive()

Method Index

 o action(Event, Object)
Handle button presses to enable or disable plotting. Deprecated.
 o addPoints()
Redefine in derived classes to add points to the plot.
 o makeButtons()
Create a start and stop buttons, by which the user can invoke enable() and disable.
 o run()
This is the body of a thread that monitors which of the start or stop buttons have been pushed most recently, or which of the enable() or disable() methods has been called most recently, to determine whether to patiently wait or to call the addPoints() method.
 o setPlotting(boolean)
If plotting is set to true, then we plot.
 o start()
Start the widget.
 o stop()
Stop the widget.

Constructors

 o PlotLive
 public PlotLive()

Methods

 o action
 public boolean action(Event evt,
                       Object arg)
Note: action() is deprecated. As of JDK1.1 in java.awt.component but we need to compile under 1.0.2 for netscape3.x compatibility.

Handle button presses to enable or disable plotting.

Overrides:
action in class PlotBox
 o addPoints
 public abstract synchronized void addPoints()
Redefine in derived classes to add points to the plot. Adding many points at once will make the plot somewhat faster because the thread yields between calls to this method. However, the plot will also be somewhat less responsive to user inputs such as zooming, filling, or stopping.

 o makeButtons
 public void makeButtons()
Create a start and stop buttons, by which the user can invoke enable() and disable. Alternatively, a derived class might invoke these directly and dispense with the buttons. This should be called within the init() method in derived classes.

 o run
 public void run()
This is the body of a thread that monitors which of the start or stop buttons have been pushed most recently, or which of the enable() or disable() methods has been called most recently, to determine whether to patiently wait or to call the addPoints() method. Between calls to addPoints(), it calls Thread.yield() so that the thread does not hog all the resources. This somewhat slows down execution, so derived classes may wish to plot quite a few points in their addPoints() method, if possible. However, plotting more points at once may also decrease the responsiveness of the user interface.

 o setPlotting
 public void setPlotting(boolean plotting)
If plotting is set to true, then we plot.

 o start
 public void start()
Start the widget. It creates a thread to plot live data, if this has not been already done. However, we don't actually start plotting until either the start button is called, or setPlotting(true) is called.

Overrides:
start in class Plot
 o stop
 public void stop()
Stop the widget.

Overrides:
stop in class Plot

All Packages  Class Hierarchy  This Package  Previous  Next  Index