public class NFSnapshotApp extends Applet implements Observer, Runnable
The NFSnapshotApp provides the capability to make a snapshot of an HTML document that contains Java applets. When the snapshot is made, all NAMED applets are replaced by a GIF image representing the current image displayed by each applet. (Applets without a NAME defined in the applet tag will be completely ignored when generating the snapshot, as well as the NFSnapshotApp applet itself. Also, because of a bug in Netscape, only applets with "lowercase" names will be processed as well.)
After the snapshot is generated, it is displayed in a separate browser window. At that point, the user may save or print the entire document using the capabilities provided by the Web browser.
The NFSnapshotApp applet uses the NFSnapshotServer to temporarily store HTML and GIF files needed for each snapshot. The ServerName and ServerPort for the appropriate server must be specified as parameters to the NFSnapshotApp applet. Temporary snapshot files are available via the Web server for as long as the NFSnapshotApp is running. Whenenver the NFSnapshotApp applet is STOPPED, it will automatically delete all temporary files that is has generated since the last time it started. (See the FileName parameter for a method of creating permanent snapshot files.)
The following parameters may be defined:
ServerName = "name";
The name of the host on which the NFSnapshotServer is running. Note, Netscape only allows applets to connect to the server from which they were loaded. This parameter must be specified.
ServerPort = integer;
The port number assigned to the NFSnapshotServer. This parameter must be specified.
TargetWindow = "name";
The name of the browser window that should be used to display the snapshot. The default is "SnapshotWindow". If this parameter is set to "NONE", then the snapshot WILL NOT be displayed in a browser window. This allows users to generate a snapshot file (in conjunction with the FileName parameter) without viewing it.
FileName = "Web Server File Name";
The name of the file to be used by the NFSnapshotServer when saving the snapshot. This filename prefix will be used to generate each of the html and image files needed for the snapshot. Accordingly, the given file and its associated directory must be writable by the NFSnapshotServer. If the file already exists, it will be overwritten. When this parameter is specified, the resulting snapshot files ARE NOT deleted automatically. If this parameter is not specified, the NFSnapshotServer will create a temporary file in the directory specified on its command line.
ButtonLabel = "label";
The label to be displayed in the snapshot button. For evaluation copies, the given label is ignored.
ButtonImage = "image url";
Defines a GIF or JPEG URL to be used as the button image. If this parameter is defined, ButtonLabel is ignored. For evaluations copies, the given image is ignored.
FontName = "name";
The font name to be used for the button. The default font name is "TimesRoman".
FontSize = integer;
The font size to be used for the button. The default font size is 16.
Background = "color";
The color to be used for the applet background. See NFColor for a list of supported colornames.
Foreground = "color";
The color to be used for the applet foreground. See NFColor for a list of supported colornames.
StatusFrame = ("title", width, height, color, fontname, fontsize);
If this parameter is defined, a frame will be displayed showing processing status. Default values will be used for all attributes that are unspecified.
For example, the following HTML document displays a very simple piechart and a copy of the NFSnapshotApp that connects it to the NFSnapshotServer on host "webserver" at port 1234, displaying the resulting snapshot in the window or frame with name "SnapshotWindow":
<title>NetCharts Snapshot Example</title>
<center> <h1>NetCharts Snapshot Example</h1>
<applet name=piechart codebase=/NetCharts/classes code=NFPiechartApp.class width=300 height=300>
<param name=NFParamScript value=' Slices = (10), (20), (30); '> </applet> <br> <br> Press the button to generate a snapshot <br> <br> <applet name=snapshot codebase=/NetCharts/classes code=NFSnapshotApp.class width=200 height=100>
<param name=NFParamScript value=' ServerName = "webserver"; ServerPort = 1234; TargetWindow = "SnapshotWindow"; '> </applet> </center>
The following parameters generate a snapshot in the "/mysnapshots" directory of the given webserver, without displaying it in a browser window. The snapshot will not be deleted automatically.
<applet name=snapshot codebase=/NetCharts/classes code=NFSnapshotApp.class width=200 height=100>
<param name=NFParamScript value=' ServerName = "webserver"; ServerPort = 1234; TargetWindow = "NONE"; FileName = "/mysnapshots/Snapshot"; '> </applet>