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-1998 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
-
myThreadGroup
- The thread group containing this thread (and all other WebSim threads)
-
restartNumber
- All projects check this occasionally, and restart when it changes
-
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.
-
WebSim()
- constructor for WebSim includes setting the background color and layout manager
-
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.
-
initialize(int)
- Initialize, either partially or completely.
-
parse(Parser, int)
-
-
parseAndRun()
- parses the BNF string and runs a set of projects.
-
resumeAllThreads()
- resume all threads created by WebSim that have been suspended
-
saveFile()
- save everything as a WebSim HTML file.
-
setWatchManager(WatchManager, String)
- Register all variables with this WatchManager.
-
start()
- Parse projects and start them running in separate threads
-
stop()
- The browser calls this when the document is no longer on
the screen, either because another Web page has been loaded,
or because the current window was minimized.
-
stopAllThreads()
- stop all threads created by WebSim
-
suspendAllThreads()
- suspend all threads created by WebSim
-
unparse(Unparser, int)
-
-
unparseAll()
- Unparse everything into a file, asking the user for the filename and
whether to overwrite it if it exists.
-
unparseAll(String, boolean)
- Unparse everything into the given file, and if it is overwriting an existing
file, and makeBackup, then rename the old file *.BAK, and delete any
existing .BAK with that same name
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
myThreadGroup
public ThreadGroup myThreadGroup
- The thread group containing this thread (and all other WebSim threads)
WebSim
public WebSim()
- constructor for WebSim includes setting the background color and layout manager
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).
getParameters
public Object[][] getParameters(int lang)
- Return a parameter array if BNF(), parse(), and unparse() are to be automated, null otherwise.
- See Also:
- getParameters
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
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, either because another Web page has been loaded,
or because the current window was minimized. 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
unparseAll
public void unparseAll()
- Unparse everything into a file, asking the user for the filename and
whether to overwrite it if it exists.
unparseAll
public void unparseAll(String filename,
boolean makeBackup)
- Unparse everything into the given file, and if it is overwriting an existing
file, and makeBackup, then rename the old file *.BAK, and delete any
existing .BAK with that same name
saveFile
public void saveFile()
- save everything as a WebSim HTML file.
initialize
public void initialize(int level)
- Initialize, either partially or completely.
- See Also:
- initialize
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.
BNF
public String BNF(int lang)
unparse
public void unparse(Unparser u,
int lang)
parse
public Object parse(Parser p,
int lang) throws ParserException