Class Project

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

public abstract class Project
extends GWin
implements Runnable, Parsable, Watchable
This defines a project. The WebSim applet parses a string consisting of descriptions of one or more Projects. They are created, the first is embedded in the Web page, and the others are placed in separate windows.

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 applet
the Applet that created this Project.
 o myThread
The thread that runs this Project's run() method
 o projNum
This ensures each project's thread's name has a unique number
 o watchManager
keeps track of all variables being watched, and all displays watching them
 o wmName
the prefix of the name of every watchable variable in this project

Constructor Index

 o Project()
constructor ensures that the background is white

Method Index

 o action(Event, Object)
respond to the menu choices
 o addMenus(MenuBar)
Override this to give a GWin menus.
 o BNF(int)
 o destroy()
When the window is closed or the applet dies, this is called to kill the Project's thread
 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()
Return the WatchManager set by setWatchManager().
 o initialize(int)
Initialize, either partially or completely.
 o parse(Parser, int)
Parse the input file to get the parameters for this object.
 o run()
Start the project running.
 o setWatchManager()
Set the watchManager and name to be the default values for this Project
 o setWatchManager(WatchManager, String)
Register all variables with this WatchManager.
 o startThread()
Create a new thread and start it running this.run()
 o unparse(Unparser, int)
Output a description of this object that can be parsed with parse().

Variables

 o applet
 public WebSim applet
the Applet that created this Project. This is set by ProjWin.

 o projNum
 protected static int projNum
This ensures each project's thread's name has a unique number

 o myThread
 protected Thread myThread
The thread that runs this Project's run() method

 o watchManager
 protected WatchManager watchManager
keeps track of all variables being watched, and all displays watching them

 o wmName
 protected String wmName
the prefix of the name of every watchable variable in this project

Constructors

 o Project
 public Project()
constructor ensures that the background is white

Methods

 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().

See Also:
Parsable
 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 run
 public abstract void run()
Start the project running. This is called after parse(). Make it do something if the project should run in a separate thread. Otherwise, just put code in functions like paint() or mouseDown(), and then the project will not get a separate thread.

 o startThread
 public void startThread()
Create a new thread and start it running this.run()

 o destroy
 public void destroy()
When the window is closed or the applet dies, this is called to kill the Project's thread

Overrides:
destroy in class GWin
 o addMenus
 public void addMenus(MenuBar mb)
Override this to give a GWin menus. Menus are only visible when it's a separate window, not when embedded in the Web page. The menus should be added to mb. Make sure that any child overriding addMenus makes a call to super.addMenus(ab) too.

Overrides:
addMenus in class GWin
 o action
 public boolean action(Event e,
                       Object w)
respond to the menu choices

Overrides:
action in class Component
 o setWatchManager
 public void setWatchManager(WatchManager wm,
                             String name)
Register all variables with this WatchManager. This method should register all the variables in this object and in those it links to. The name of each variable should be appended to the end of the String name.

 o setWatchManager
 public void setWatchManager()
Set the watchManager and name to be the default values for this Project

 o getWatchManager
 public WatchManager getWatchManager()
Return the WatchManager set by setWatchManager().

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

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

See Also:
initialize