Use as Applet

From jV
Jump to navigation Jump to search

Introduction

In order to use jV as an applet, your browser must support the Java Plug-in technology. The applet is called from OBJECT tags in HTML, where class name that should be called is "org.pdbj.viewer.gui.ViewerApplet". The program has following features.

  • whether to use the command line interface or not can be specified
  • whether to use the file control panel or not can be specified
  • whether to use the popup menu or not can be specified
  • witihin applets in the same web page, mouse events can be shared
  • applet can receive a command string from JaveScript
  • applet can send information about mouse-picked atoms to JavaScript.

Parameters

To initialize the applet, the following parameters can be specified in HTML.

parameter value
pdbid PDB ID to be loaded from the PDBj FTP site (delimited by comma for more than one files). This parameter works only in a signed applet.
mmcifURL URL of the mmCIF files to be loaded (delimited by comma for more than one files).
pdbmlURL URL of the PDBML files to be loaded (delimited by comma for more than one files).
pdbURL URL of the PDB files to be loaded (delimited by comma for more than one files).
polygonURL URL of the polygon files to be loaded (delimited by comma for more than one files).
animURL URL of the animation files to be loaded (delimited by comma for more than one files).
command_area whether to use the command line interface or not (true or false).
file_control whether to use the file control panel or not (true or false).
popup_menu whether to use the popup menu or not (true or false).
mouse_send_to name property of applets with which mouse events are shared (delimited by comma for more than one applets).
commands initial commands that are executed when the applet starts (delimited by semicolon for more than one commands).
report_picking whether to send information about mouse-picked atoms to JavaScript or not (true or false).
picking_receiver JavaScript function name that receives mouse-picking data.
file_load_message whether to show a message dialog while loading a file (true or false).
call_on_start whether to call a JavaScript function when the applet started (true or false).
newt whether to use JOGL's native windowing toolkit (true or false). At the current version, applets on Mac need this parameter set to true. On other platforms, however, this parameter must be set to fasle. Therefore the parameter should be dynamically determined in applet tags in HTML based on the platform. When set to true, two other parameters, command_area and file_control, are automatically set to false and the stereo command becomes unavailable.

JavaScript-to-Applet Communication

The ViewerApplet class has some public methods, which can be called from JavaScript.

void executeCommand(String commands)

Through this method, the applet can receive some arbitrary commands (delimited by semicolon).

void loadMmcif(String fileLocation)
void loadPDB(String fileLocation)
void loadPDBML(String fileLocation)
void loadFTP(String pdbId)
void loadPolygon(String fileLocation)
void loadPolygonCGO(String fileLocation)
void loadAnim(String fileLocation)

Using these methods, mmCIF file, PDB file, PDBML file, polygon file, and animation file specified by URL can be loaded respectively. The loadFTP method receives a PDB ID and retrieves a PDBML file from the PDBj FTP site, which works only in a signed applet.

void loadMmcif(String fileLocation, int fitTo)
void loadPDB(String fileLocation, int fitTo)
void loadPDBML(String fileLocation, int fitTo)
void loadFTP(String pdbId, int fitTo)
void loadPolygon(String fileLocation, int fitTo)
void loadPolygonCGO(String fileLocation, int fitTo)
void loadAnim(String fileLocation, int fitTo)

When these methods are used, the transform matrix of the loaded file is set identical to that of the specified file.

void loadMmcif(String fileLocation, int fitTo, String biomolecule, String filter)
void loadPDB(String fileLocation, int fitTo, String filter)
void loadPDBML(String fileLocation, int fitTo, String biomolecule, String filter)
void loadFTP(String pdbId, int fitTo, String biomolecule, String filter)
void loadAnim(String fileLocation, int fitTo, String filter)

When these methods are used, biomolecule structure and filter can also be specified. The arguments fitTo, biomolecule and filter can be set as -1, null and null, respectively, if you do not need to use some of them.

Applet-to-JavaScript Communication

In order to send the result of mouse-picking to JavaScript, the following function must be defined in JavaScript.

function receiveMousePick(file, model, chain, res, atom, altloc, resName, atomName, x, y, z)

The function name 'receiveMousePick' is a default name. It can be changed by specifying the 'picking_receiver' parameter in the OBJECT tag.

When the applet started, it invokes the following JavScript function

function jvOnStart(name)

if it is configured to do so by the applet parameter 'call_on_start'. Here the function receives the name of the applet as its argument.

Available applet code for each environment

Which type of applet code works or not in each environment is described here.