HTML How To

Introduction

JAS now includes the capability to display HTML pages and the ability to follow hyperlinks to other pages. Plots may be embedded within these pages using the HTML <OBJECT> tag described below. In addition user-written objects can be displayed, and objects within a page can be set up to interact with each other. Uses for this feature include displaying pages of plots for use within an online monitoring application, or for displaying  tutorial information to new users. In addition JAS incorporates a "Full Screen" mode which, in combination with the HTML display capability, can be used for making  presentations incorporating "active" plots.

JAS uses the swing JEditorPane component to display web pages. This component supports most features of HTML 3.2. We have found it to work quite well with simple HTML pages, but not to do a great job with pages containing frames or nested tables. The viewer includes limited support for cascading style sheets. There is currently no support for the <APPLET> tag, although the <OBJECT> tag described below can provide similar functionality.

Security

It is important to note that the JAS HTML feature is designed for browsing pages which are "trusted" by the viewer. Objects loaded by these pages are run with the same security as JAS itself, and thus have full access to the file system of the local machine. Browsing the web in general using the built in HTML display capability is not recommended.

Navigating within Web Pages and Hyperlinks

Hyperlinks can be embedded within HTML pages and are interpreted in the normal way. Currently the target attribute within a hyperlink is not supported. Links may contain relative or absolute URL's, and may read local files or remote files using the http: or ftp: protocols.

The View menu contains the normal browser "Home", "Forward", "Backward" and "Refresh" items, as well as a "Web Page" item for opening an arbitrary page using a URL. You can also open a local HTML file using the "Open" item in the "File" menu. The same navigation controls are available from the HTML page's popup menu and from the "Web" toolbar.

Embedding Objects using the Object Tag

Java objects can be embedded within a page using the <OBJECT> tag. The tag allows one to specify the class to be embedded, as well as parameters for controlling how the object looks. Here is an example of an object tag:

<OBJECT classid="jas.bean.XMLPlot" id="Plot1">
    <PARAM name="xmlURL" value="plot1.xml">
    <PARAM name="opaque" value="true">
</OBJECT>

The <OBJECT> tag is most useful when used with an Java class them conforms to the Java  beans specification. In this case the jas.bean.XMLPlot class referred to is a bean supplied with JAS which extends the Swing JPanel, and thus accepts all of the standard Swing properties in addition to the one property it defines itself, xmlURL, which is used to specify the URL of an XML file which defines the plot. The xmlURL is interpreted relative the URL of the document containing the XMLPlot. The XML file may either contain the data for the plot, or reference to some "live" data source. See the XML HowTo for more information on specifying plots in XML.

Embedding Custom Objects

The example above showed how to use a built-in bean,  but you can also embed your own beans within an HTML page. The example below shows a simple bean which extends the Swing JSlider, and which accepts a single parameter, the name of a Plot to attach itself to. Once the slider has attached itself to a plot it can be used to change the number of bins in the plot.

This bean can be included in the HTML page using the following code:

<OBJECT classid="RebinSlider" id="Slider">
    <PARAM name="target" value="Plot1">
    <PARAM name="opaque" value="true">
</OBJECT>

Note that the RebinSlider specifies the object to connect to using the id specified on the plot's <OBJECT> tag.

The RebinSlider is able to communicate with the other sliders objects on the page because it implements jas.bean.PageContextHook. When a bean implements this interface JAS will call its init method when the bean is first created, and the destroy method when the page containing the object is closed. The init method is called with a jas.bean.PageContext object which can be used by the bean to locate other beans on the page, and to interact with its container.

Currently classes are loaded using the system CLASSPATH specified when JAS was started, but we plan to support more flexible loading of classes, including loading from the same location as the HTML page which contains the <OBJECT> tag, in future releases.

Using Full Screen Mode

The JAS Window menu now includes a "Full Screen" item which can be used to display any JAS window so that it fills the entire screen. To exit full screen mode use the escape key, or right click on the window to bring up a popup window and select "Close".

Full screen mode when used in combination with an HTML page and a style sheet that selects suitably large fonts, can be used for making presentations. Since you can include active plots and objects within your presentation you can show the effects of varying cuts "live" in your presentation.

The Full Screen mode is a new addition to JAS in release 2.0 Alpha 3. Your comments and suggestions for improving this feature are particularly welcome.

Future Plans

Future releases of JAS will probably support embedding some scripting language within the HTML page to simplify the task of writing "glue" code to interconnect beams on a page. We also plan to add support for editing HTML pages within JAS, either directly on the HTML page, or by editing the HTML source code. Finally some improved support for presentations, for example easier navigation between pages without having to embed links in each page. Support for printing Web Pages is currently very limited, we are working on proper multi page printing of HTML pages and expect this to be in the next alpha release of JAS.


Page last updated: Wednesday, January 14, 2004 by SLAC\tonyj