All Packages Class Hierarchy This Package Previous Next Index
Class ptolemy.plot.PlotLive
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----ptolemy.plot.PlotBox
|
+----ptolemy.plot.Plot
|
+----ptolemy.plot.PlotLive
- public abstract class PlotLive
- extends Plot
- implements Runnable
Plot signals dynamically, where points can be added at any time
and 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 an
addPoints() method. Your class may also set graph parameters like
titles and axis labels in the constructor by calling
methods in the Plot or PlotBox classes (both of which are base classes).
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, so the zooming
mechanism and buttons remain live.
- Version:
- $Id: PlotLive.java,v 1.40 1998/11/18 07:43:20 cxh Exp $
- Author:
- Edward A. Lee, Christopher Hylands
-
PlotLive()
-
-
addPoints()
- Redefine in derived classes to add points to the plot.
-
makeButtons()
- Make start and stop buttons.
Deprecated.
-
pause()
- Pause the plot.
-
run()
- This is the body of a thread that repeatedly calls addPoints()
if the plot is active.
-
setButtons(boolean)
- If the argument is true, make a start, stop, and fill button
visible at the upper right.
-
start()
- Make the plot active.
-
stop()
- Stop the plot.
PlotLive
public PlotLive()
addPoints
public abstract 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. In the derived-class
implementation, this method should probably be synchronized.
makeButtons
public void makeButtons()
- Note: makeButtons() is deprecated.
- Make start and stop buttons.
This method is deprecated. Use setButtons() instead.
pause
public void pause()
- Pause the plot. To resume, call start().
run
public void run()
- This is the body of a thread that repeatedly calls addPoints()
if the plot is active. To make the plot active, call start().
To pause the plot, call pause(). To stop the plot and destroy
the thread, call stop(). The next time start() is called, a new
thread will be started. Between calls to addPoints(), this method 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.
setButtons
public void setButtons(boolean visible)
- If the argument is true, make a start, stop, and fill button
visible at the upper right. Otherwise, make the buttons invisible.
NOTE: The buttons may infringe on the title space,
if the title is long. In an application, it is preferable to provide
a menu with the commands. This way, when printing the plot,
the printed plot will not have spurious buttons. Thus, this method
should be used only by applets, which normally do not have menus.
- Overrides:
- setButtons in class PlotBox
start
public synchronized void start()
- Make the plot active. Start a new thread if necessary.
stop
public void stop()
- Stop the plot. The plot thread exits. This should be called by
an applet's stop() method.
All Packages Class Hierarchy This Package Previous Next Index