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
-
applet
- the Applet that created this Project.
-
myThread
- The thread that runs this Project's run() method
-
projNum
- This ensures each project's thread's name has a unique number
-
watchManager
- keeps track of all variables being watched, and all displays watching them
-
wmName
- the prefix of the name of every watchable variable in this project
-
Project()
- constructor ensures that the background is white
-
action(Event, Object)
- respond to the menu choices
-
addMenus(MenuBar)
- Override this to give a GWin menus.
-
BNF(int)
-
-
destroy()
- When the window is closed or the applet dies,
this is called to kill the Project's thread
-
getName()
- Return the variable "name" that was passed into setWatchManager
-
getParameters(int)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
-
getWatchManager()
- Return the WatchManager set by setWatchManager().
-
initialize(int)
- Initialize, either partially or completely.
-
parse(Parser, int)
- Parse the input file to get the parameters for this object.
-
run()
- Start the project running.
-
setWatchManager()
- Set the watchManager and name to be the default values for this Project
-
setWatchManager(WatchManager, String)
- Register all variables with this WatchManager.
-
startThread()
- Create a new thread and start it running this.run()
-
unparse(Unparser, int)
- Output a description of this object that can be parsed with parse().
applet
public WebSim applet
- the Applet that created this Project. This is set by ProjWin.
projNum
protected static int projNum
- This ensures each project's thread's name has a unique number
myThread
protected Thread myThread
- The thread that runs this Project's run() method
watchManager
protected WatchManager watchManager
- keeps track of all variables being watched, and all displays watching them
wmName
protected String wmName
- the prefix of the name of every watchable variable in this project
Project
public Project()
- constructor ensures that the background is white
getParameters
public Object[][] getParameters(int lang)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
- See Also:
- getParameters
BNF
public String BNF(int lang)
unparse
public void unparse(Unparser u,
int lang)
- Output a description of this object that can be parsed with parse().
- See Also:
- Parsable
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
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.
startThread
public void startThread()
- Create a new thread and start it running this.run()
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
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
action
public boolean action(Event e,
Object w)
- respond to the menu choices
- Overrides:
- action in class Component
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.
setWatchManager
public void setWatchManager()
- Set the watchManager and name to be the default values for this Project
getWatchManager
public WatchManager getWatchManager()
- Return the WatchManager set by setWatchManager().
getName
public String getName()
- Return the variable "name" that was passed into setWatchManager
- Overrides:
- getName in class Component
initialize
public void initialize(int level)
- Initialize, either partially or completely.
- See Also:
- initialize