Previous Up Next

Because Java applets have limitations that stand-alone applications do not have, there are differences between using the two.

Opening and Saving Files :
Security provisions prevent Java applets from reading from or writing to the hard disk on the client machine (i.e., the local machine where the web browser was launched). As a result, some I/O functions associated with the standalone application are not available in the Notung applet. It is not possible to open new trees, save trees, or export images or annotations from the Notung applet. To save trees in text format from a Notung applet, the user can select an option from “File View Tree in Text Format”, and then copy and paste the tree into a text file. To perform other operations not allowed in an applet, such as saving a PNG image of a tree, the user can download the stand-alone Notung program from http://www.cs.cmu.edu/~durand/Notung and use it to process trees on the local machine.
Clipboard Access :
Applets cannot access the clipboard directly. The stand-alone version of Notung allows the user to click a button to copy the contents of a dialog box to the clipboard. In the applet, a button selects the text in the dialog box. The user can then type ‘Ctrl - c’ to copy the text to the clipboard.
Startup Window :
When Notung is run as an applet, a small html window opens before the main Notung window opens. This window contains information about the version of Notung that is being run, and a button that allows the user to quit Notung. A short description of the trees being viewed is sometimes included in this window. The small window must remain open while Notung is running - closing the window will cause Notung to quit.

G.2  Setting up the Notung applet

In this section, we describe how to construct a web page with an embedded Notung applet. The following files are required:

HTML to Embed the Notung Applet in a Web Page

The HTML required to embed the Notung applet in a web page must include a definition of notung.js. This is typically of the form

<head>
<script src='notung.js'></script>
</head>

<body>
<a href="javascript:openNotung(
...
)"
  title="Notung JavaApplet">
Informative title goes here</a>
</body>

The main work is carried out by the function openNotung, which takes four parameters:

First argument :
An array of gene tree URLs to load. This can have 0, 1, or more than 1 URL.
Second argument :
An array of species tree URLs to load. This can have 0, 1, or more than 1 URL.
Third argument :
A string with all the command line arguments to pass Notung. The following options are a subset of the flags discussed in Chapter 12 which are particularly relevant to using Notung as an applet.
--show-species-tree :
If Notung is given a previously reconciled gene tree in Notung format, this option will cause Notung to also open the species tree embedded in the gene tree file.
--homologgui :
This option starts Notung in Ortholog/Paralog mode.
--annotationfile <annotationfile> :
This option gives Notung an annotation file to use.
Fourth argument :
A string which describes the trees being loaded. This string will be displayed in the browser window that pops up.

Here are two examples of HTML code that defines javascript that calls openNotung(), creating a link to launch the Notung applet.

Example 1:

<head>
<script src='notung.js'></script>
</head>

<body>
<a href="javascript:openNotung(
 ['GENE_TREE_001'],
 ['SPECIES_TREE_001'],
 '',
 'Example Trees One')"
  title="Notung JavaApplet">
  Open GENE_TREE_001 and SPECIES_TREE_001 in Notung</a>
</body>

In this example, the web page, jar file, notung.js, and trees are all located in the same directory.

Example 2:

<head>
<script src='http://www.yourdomain.com/applet_files/notung.js'></script>
</head>

<body>
<a href="javascript:openNotung(
 ['http://www.yourdomain.com/tree_files/GENE_TREE_001',    'http://www.yourdomain.com/tree_files/GENE_TREE_002'],
 [],
 '',
 'Example Trees Two')"
  title="Notung JavaApplet">
  Open GENE_TREE_001 and GENE_TREE_002 in Notung</a>
</body>

In this example the Notung jar file and notung.js are both located in the directory
http://www.yourdomain.com/applet_files. The gene trees are located in the directory
http://www.yourdomain.com/tree_files. The web page can be located anywhere on the webserver http://www.yourdomain.com/

This example displays two gene trees, and no species trees.

File Locations

Because of restrictions on the actions of Java applets, all of the files used for the Notung applet (the jar file, notung.js, and the tree files) must be located on the same webserver as the web page.

Location of notung.js :
If notung.js is not in the same directory as the web page, the text src=’notung.js’ in the example above must be replaced with the URL specifying the location of notung.js. For example, if the URL to the notung.js file is
http://www.yourdomain.com/path/to/files/notung.js,
the html should look like this:
<script
src=`http://www.yourdomain.com/path/to/files/notung.js'>
</script>
Location of Notung jar file
By default, notung.js expects the Notung jar file to be in the same directory as notung.js. If the Notung jar is located somewhere else, the following line in notung.js will have to be modified to point to the correct location.
// url for jar file 
var jar = "Notung-2.6.jar"

Previous Up Next