Class Display

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----GWin
                                   |
                                   +----Display

public abstract class Display
extends GWin
implements Parsable, Watcher, Watchable
A display object can display simulation variables in a separate window.

This code is (c) 1996 Leemon Baird <leemon@cs.cmu.edu>, http://www.cs.cmu.edu/~baird
The source and object code may be redistributed freely. If the code is modified, please state so in the comments.

Version:
1.01, 24 July 96
Author:
Leemon Baird

Variable Index

 o buffBounds
bounds of buffer
 o buffer
offscreen buffer used for double buffering
 o disableDisplays
Should all the displays be disabled (still record data, but don't display it)?
 o flicker
Should drawing to the screen not be double buffered (use offscreen buffer for no flicker)?
 o image
image corresponding to buffer
 o plotBuffer
smaller region within offscreen buffer used for double buffering
 o repaintInProgress
is a repaint currently queued (and so there's no need to call repaint() again)?
 o watchManager
The WatchManager that this Watcher watches
 o wmName
the prefix string for the name of every watched variable (passed in to setWatchManager)

Constructor Index

 o Display()

Method Index

 o BNF(int)
 o destroy()
This is called when the user closes the window.
 o drawAll(Graphics)
Override this to draw directly to the display.
 o getName()
Return the variable "name" that was passed into setWatchManager
 o getParameters(int)
Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
 o getWatchManager()
Get the WatchManager being used
 o initialize(int)
Initialize, either partially or completely.
 o paint(Graphics)
Redraw the display.
 o parse(Parser, int)
Parse the input file to get the parameters for this object.
 o repaint()
Repaint the screen if a repaint isn't already queued.
 o setWatchManager(WatchManager, String)
Remember the WatchManager for this object and create the window.
 o unparse(Unparser, int)
Output a description of this object that can be parsed with parse().
 o unregister(String)
One of the watched variables has been unregistered.
 o update(Graphics)
Redraw the display without flicker.
 o update(String, Pointer, Watchable)
One of the watched variables has changed, so look at it and others.

Variables

 o disableDisplays
 public static boolean disableDisplays
Should all the displays be disabled (still record data, but don't display it)?

 o watchManager
 public WatchManager watchManager
The WatchManager that this Watcher watches

 o wmName
 public String wmName
the prefix string for the name of every watched variable (passed in to setWatchManager)

 o flicker
 public PBoolean flicker
Should drawing to the screen not be double buffered (use offscreen buffer for no flicker)?

 o buffer
 public Graphics buffer
offscreen buffer used for double buffering

 o plotBuffer
 public Graphics plotBuffer
smaller region within offscreen buffer used for double buffering

 o image
 public Image image
image corresponding to buffer

 o buffBounds
 public Dimension buffBounds
bounds of buffer

 o repaintInProgress
 public PBoolean repaintInProgress
is a repaint currently queued (and so there's no need to call repaint() again)?

Constructors

 o Display
 public Display()

Methods

 o setWatchManager
 public void setWatchManager(WatchManager wm,
                             String name)
Remember the WatchManager for this object and create the window. After everything is parsed and windows are created, all experiments are given a watchManager by Simulator, then it starts giving each Display a watchManager. This is where the Display should register each variable it wants to watch.

 o getName
 public String getName()
Return the variable "name" that was passed into setWatchManager

Overrides:
getName in class Component
 o getWatchManager
 public WatchManager getWatchManager()
Get the WatchManager being used

 o getParameters
 public Object[][] getParameters(int lang)
Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.

See Also:
getParameters
 o BNF
 public String BNF(int lang)
 o unparse
 public void unparse(Unparser u,
                     int lang)
Output a description of this object that can be parsed with parse().

 o parse
 public Object parse(Parser p,
                     int lang) throws ParserException
Parse the input file to get the parameters for this object.

Throws: ParserException
parser didn't find the required token
 o unregister
 public void unregister(String watchedVar)
One of the watched variables has been unregistered. The watcher doesn't have to do anything, but might remove this variable from some internal data structure.

 o update
 public void update(String changedName,
                    Pointer changedVar,
                    Watchable obj)
One of the watched variables has changed, so look at it and others. It should call checkMoved() to make sure the window is a legal size.

 o update
 public void update(Graphics g)
Redraw the display without flicker. Normally update() first erases the screen, then calls paint(), but it's overridden here so it won't erase. Don't override update() or paint(). Override drawAll() instead. When it is time to redraw the display, call repaint();

Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Redraw the display. Do not override update(Graphics) or paint(Graphics). Override drawAll() instead. When it is time to redraw the display, call repaint().

Overrides:
paint in class GWin
 o repaint
 public void repaint()
Repaint the screen if a repaint isn't already queued. Do not override repaint().

Overrides:
repaint in class Component
 o drawAll
 public void drawAll(Graphics g)
Override this to draw directly to the display. It should clear the entire window and redraw everything. It is called by paint() which is called when a window is created, uncovered, or saved to the disk as a GIF or Postscript file.

 o destroy
 public void destroy()
This is called when the user closes the window. Override it to react to that event (e.g. kill threads, dispose of Graphics)

Overrides:
destroy in class GWin
 o initialize
 public void initialize(int level)
Initialize, either partially or completely.

See Also:
initialize