Class WebSim
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
|
+----WebSim
- public class WebSim
- extends Applet
- implements Parsable
Parse a string (from the Web page, a file, or a URL), and build and
run the objects that it describes. It should describe one or more
objects of type Project. The first will
be embedded on the Web page, and each of the others will be
placed 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.05, 11 May 97
- Author:
- Leemon Baird
-
allThreadsSuspended
- Have all threads created by WebSim (and the applet thread itself) been suspended?
-
bnf
- If nonnull, the string containing the BNF code
-
myThreadGroup
- The thread group containing this thread (and all other WebSim threads)
-
restartNumber
- All projects check this occasionally, and restart when it changes
-
unparseAtEnd
-
-
watchManager
- This static variable allows any thread in memory (such as another Applet like VRMLInterface)
to communicate with WebSim's WatchManager.
-
watchManagerGuard
- Synchronize on watchManagerGuard before attempting to read or write watchManager.
-
wins
- array of all the Projects
-
WebSim()
- constructor that does nothing
-
WebSim(String, int, int, int, int)
- Instantiate a WebSim manually rather than with a browser or applet viewer.
-
BNF(int)
-
-
destroy()
- The browser calls this when quitting.
-
destroyAll()
- close all windows, kill all threads, dispose of all Graphics contexts
-
getAppletInfo()
- Information about the applet that a browser
or Java interpretor can give the user
-
getParameterInfo()
- Parameter info that a browser or Java
interpretor can give the user
-
getParameters(int)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
-
init()
- Initialize the applet with a white background
-
initialize(int)
- Initialize, either partially or completely.
-
parse(Parser, int)
- Parse the input file to get the parameters for this object.
-
parseAndRun()
- parses the BNF string and runs a set of projects.
-
resumeAllThreads()
- resume all threads created by WebSim that have been suspended
-
saveFile()
-
-
start()
- Parse projects and start them running in separate threads
-
stop()
- The browser calls this when the document is no longer on
the screen.
-
stopAllThreads()
- stop all threads created by WebSim
-
suspendAllThreads()
- suspend all threads created by WebSim
-
unparse(Unparser, int)
- Output a description of this object that can be parsed with parse().
-
unparseAll()
- Unparse everything into a file.
watchManager
public static WatchManager watchManager
- This static variable allows any thread in memory (such as another Applet like VRMLInterface)
to communicate with WebSim's WatchManager. If there are several WatchManagers,
then it gives the one belonging to the last WebSim Project that finished
initializing. To wait for the WatchManager to become available then put it
into a new local variable called watchManager, run the following code:
WatchManager watchManager;
synchronized(WebSim.watchManagerGuard) {
if (WebSim.watchManager==null)
try {
WebSim.watchManagerGuard.wait();
} catch(InterruptedException e) {
}
watchManager=WebSim.watchManager;
}
watchManagerGuard
public static Double watchManagerGuard
- Synchronize on watchManagerGuard before attempting to read or write watchManager.
Why is there a separate variable just for the guard? This is a workaround for a BUG:
it's needed in Netscape 3.0 for SunOs 4, but not in Netscape for Win95/NT.
restartNumber
public static int restartNumber
- All projects check this occasionally, and restart when it changes
wins
protected ProjWin wins[]
- array of all the Projects
unparseAtEnd
protected boolean unparseAtEnd
myThreadGroup
protected ThreadGroup myThreadGroup
- The thread group containing this thread (and all other WebSim threads)
bnf
protected String bnf
- If nonnull, the string containing the BNF code
allThreadsSuspended
protected PBoolean allThreadsSuspended
- Have all threads created by WebSim (and the applet thread itself) been suspended?
WebSim
public WebSim()
- constructor that does nothing
WebSim
public WebSim(String bnfString,
int x,
int y,
int width,
int height)
- Instantiate a WebSim manually rather than with a browser or applet viewer.
The BNF code is in bnfString, and the window has upper-left corner (x,y) and
dimensions (width,height).
getAppletInfo
public String getAppletInfo()
- Information about the applet that a browser
or Java interpretor can give the user
- Overrides:
- getAppletInfo in class Applet
getParameterInfo
public String[][] getParameterInfo()
- Parameter info that a browser or Java
interpretor can give the user
- Overrides:
- getParameterInfo in class Applet
init
public void init()
- Initialize the applet with a white background
- Overrides:
- init in class Applet
start
public void start()
- Parse projects and start them running in separate threads
- Overrides:
- start in class Applet
parseAndRun
public void parseAndRun()
- parses the BNF string and runs a set of projects.
stop
public void stop()
- The browser calls this when the document is no longer on
the screen. It should kill all threads and release all
graphics contexts.
- Overrides:
- stop in class Applet
destroyAll
public void destroyAll()
- close all windows, kill all threads, dispose of all Graphics contexts
destroy
public void destroy()
- The browser calls this when quitting.
It should kill all threads and release all
graphics contexts.
- Overrides:
- destroy in class Applet
stopAllThreads
public void stopAllThreads()
- stop all threads created by WebSim
suspendAllThreads
public void suspendAllThreads()
- suspend all threads created by WebSim
resumeAllThreads
public void resumeAllThreads()
- resume all threads created by WebSim that have been suspended
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
unparseAll
public void unparseAll()
- Unparse everything into a file.
saveFile
public void saveFile()
initialize
public void initialize(int level)
- Initialize, either partially or completely.
- See Also:
- initialize