# Class JSVApplet

java.lang.Object
jspecview.appletjs.JSVApplet

All Implemented Interfaces:
  `JSInterface, AppletFrame, JSVAppletInterface`

Direct Known Subclasses:
  `JSVAppletPro`

public class JSVApplet extends Object implements JSVAppletInterface, AppletFrame, JSInterface
Entry point for the web. JSpecView Applet class. For a list of parameters and scripting functionality see the file JSpecView_Applet_Specification.html.

Author:
  Bob Hanson, Debbie-Ann Facey, Khari A. Bryan, Craig A. D. Walters, Prof Robert J. Lancashire http://blog.gorges.us/2009/03/how-to-enable-keywords-in-eclipse-and- subversion-svn/ $LastChangedRevision: 1097 $ $LastChangedDate: 2012-07-23 11:10:30 -0500 (Mon, 23 Jul 2012) $

## Field Summary

Fields
Modifier and Type
Field
Description
`protected JSVApp`
`app`
`JSViewer`
`viewer`
`protected Map<String,Object>`
`viewerOptions`

## Constructor Summary

Constructors
Constructor
Description
`JSVApplet(Map<String,Object> viewerOptions)`

## Method Summary

Modifier and Type
Method
Description
`void`
`addHighlight(double x1, double x2, int r, int g, int b, int a)`
Method that can be called from another applet or from javascript that adds a highlight to a portion of the plot area of a `JSVPanel`
`int`
`cacheFileByName(String fileName, boolean isAdd)`
`void`
`cachePut(String key, Object data)`
`void`
`callToJavaScript(String callback, Object[] data)`
Calls a javascript function given by the function name passing to it the string parameters as arguments
`String`
`checkScript(String script)`
`void`
`createMainPanel(JSViewer viewer)`
`void`
`destroy()`
`void`
`doExitJmol()`
`String`
`export(String type, int n)`
Deprecated.
`String`
`exportSpectrum(String type, int n)`
Delivers spectrum coded as desired: XY, SQZ, PAC, DIF, DIFDUP, FIX, AML, CML, PDF(base64-encoded)
`JSVApp`
`getApp()`
`String`
`getAppletInfo()`
Get Applet information
`String`
`getCoordinate()`
Method that can be called from another applet or from javascript to return the coordinate of clicked point in the plot area of the `JSVPanel`
`URL`
`getDocumentBase()`
`String`
`getFullName()`
`JSVPanel`
`getJSVPanel(JSViewer viewer, Lst<Spectrum> specs)`
`String`
`getParameter(String paramName)`
`String`
`getParameter(String key, String def)`
`Map<String,Object>`
`getPropertyAsJavaObject(String key)`
`String`
`getPropertyAsJSON(String key)`
`String`
`getSolnColour()`
Returns the calculated colour of a visible spectrum (Transmittance)
`void`
`init()`
Initializes applet with parameters and load the `JDXSource` called by the browser
`protected void`
`initViewer()`
`boolean`
`isPro()`
`boolean`
`isSigned()`
`void`
`loadInline(String data)`
Loads in-line JCAMP-DX data into the existing applet window
`void`
`newWindow(boolean isSelected)`
`String`
`openFile(String fileName)`
possibly called from JSmolJSV.js upon start up
`void`
`openFileAsyncSpecial(String fileName, int flags)`
`void`
`openFileAsyncSpecialType(String fileName, int flags, String type)`
`String`
`print(String fileName)`
`void`
`processKeyEvent(Object event)`
`boolean`
`processMouseEvent(int id, int x, int y, int modifiers, long time)`
`void`
`processTwoPointGesture(float[][][] touches)`
`void`
`removeAllHighlights()`
Method that can be called from another applet or from javascript that removes all highlights from the plot area of a `JSVPanel`
`void`
`removeHighlight(double x1, double x2)`
Method that can be called from another applet or from javascript that removes a highlight from the plot area of a `JSVPanel`
`void`
`repaint()`
`void`
`reversePlot()`
Method that can be called from another applet or from javascript that toggles reversing the plot on a `JSVPanel`
`void`
`runScript(String script)`
runs a script in proper order as listed
`boolean`
`runScriptNow(String script)`
`void`
`script(String script)`
Deprecated.
`void`
`setDisplay(Object canvas)`
`void`
`setDropTargetListener(boolean isSigned, JSViewer viewer)`
`void`
`setFilePath(String tmpFilePath)`
`void`
`setPanelVisible(boolean b)`
`void`
`setScreenDimension(int width, int height)`
`void`
`setSpectrumNumber(int i)`
Sets the spectrum to the specified block number
`boolean`
`setStatusDragDropped(int mode, int x, int y, String fileName, String[] retType)`
`void`
`startHoverWatcher(boolean enable)`
`void`
`syncScript(String peakScript)`
precede invalid input: '<'Peaks here with full name of Jmol applet (including syncID)
`void`
`toggleCoordinate()`
Method that can be called from another applet or from javascript that toggles the coordinate on a `JSVPanel`
`void`
`toggleGrid()`
Method that can be called from another applet or from javascript that toggles the grid on a `JSVPanel`
`void`
`toggleIntegration()`
Method that can be called from another applet or from javascript that toggles the integration graph of a `JSVPanel`.
`void`
`togglePointsOnly()`
Method that can be called from another applet or from javascript that toggles the flag for points only on a `JSVPanel`
`void`
`update()`
`void`
`validate()`
`void`
`validateContent(int mode)`
`void`
`writeStatus(String msg)`
Writes a message to the status label

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### app

protected JSVApp app

### viewer

public JSViewer viewer

### viewerOptions

protected Map<String,Object> viewerOptions

## Constructor Details

### JSVApplet

public JSVApplet(Map<String,Object> viewerOptions)

## Method Details

### init

public void init()
Initializes applet with parameters and load the `JDXSource` called by the browser

### initViewer

protected void initViewer()

### getParameter

public String getParameter(String paramName)

Specified by:
  `getParameter` in interface `AppletFrame`

### isPro

public boolean isPro()

Specified by:
  `isPro` in interface `JSVAppletInterface`

### isSigned

public boolean isSigned()

Specified by:
  `isSigned` in interface `JSVAppletInterface`

### destroy

public void destroy()

Specified by:
  `destroy` in interface `JSInterface`

### getParameter

public String getParameter(String key, String def)

### getAppletInfo

public String getAppletInfo()
Get Applet information

Specified by:
  `getAppletInfo` in interface `AppletFrame`
Returns:
  the String "JSpecView Applet"

### getSolnColour

public String getSolnColour()
Description copied from interface: `JSVAppletInterface`
Returns the calculated colour of a visible spectrum (Transmittance)

Specified by:
  `getSolnColour` in interface `JSVAppletInterface`
Returns:
  Color

### getCoordinate

public String getCoordinate()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript to return the coordinate of clicked point in the plot area of the `JSVPanel`

Specified by:
  `getCoordinate` in interface `JSVAppletInterface`
Returns:
  A String representation of the coordinate

### loadInline

public void loadInline(String data)
Description copied from interface: `JSVAppletInterface`
Loads in-line JCAMP-DX data into the existing applet window

Specified by:
  `loadInline` in interface `JSVAppletInterface`
Parameters:
  `data` - String

### export

@Deprecated public String export(String type, int n)
Deprecated.

### exportSpectrum

public String exportSpectrum(String type, int n)
Description copied from interface: `JSVAppletInterface`
Delivers spectrum coded as desired: XY, SQZ, PAC, DIF, DIFDUP, FIX, AML, CML, PDF(base64-encoded)

Specified by:
  `exportSpectrum` in interface `JSVAppletInterface`
Parameters:
  `type` -
  `n` -
Returns:
  data

### setFilePath

public void setFilePath(String tmpFilePath)

Specified by:
  `setFilePath` in interface `JSVAppletInterface`

### setSpectrumNumber

public void setSpectrumNumber(int i)
Description copied from interface: `JSVAppletInterface`
Sets the spectrum to the specified block number

Specified by:
  `setSpectrumNumber` in interface `JSVAppletInterface`
Parameters:
  `i` -

### toggleGrid

public void toggleGrid()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that toggles the grid on a `JSVPanel`

Specified by:
  `toggleGrid` in interface `JSVAppletInterface`

### toggleCoordinate

public void toggleCoordinate()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that toggles the coordinate on a `JSVPanel`

Specified by:
  `toggleCoordinate` in interface `JSVAppletInterface`

### togglePointsOnly

public void togglePointsOnly()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that toggles the flag for points only on a `JSVPanel`

Specified by:
  `togglePointsOnly` in interface `JSVAppletInterface`

### toggleIntegration

public void toggleIntegration()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that toggles the integration graph of a `JSVPanel`.

Specified by:
  `toggleIntegration` in interface `JSVAppletInterface`

### addHighlight

public void addHighlight(double x1, double x2, int r, int g, int b, int a)
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that adds a highlight to a portion of the plot area of a `JSVPanel`

Specified by:
  `addHighlight` in interface `JSVAppletInterface`
Parameters:
  `x1` - the starting x value
  `x2` - the ending x value
  `r` - the red portion of the highlight color
  `g` - the green portion of the highlight color
  `b` - the blue portion of the highlight color
  `a` - the alpha portion of the highlight color

### removeAllHighlights

public void removeAllHighlights()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that removes all highlights from the plot area of a `JSVPanel`

Specified by:
  `removeAllHighlights` in interface `JSVAppletInterface`

### removeHighlight

public void removeHighlight(double x1, double x2)
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that removes a highlight from the plot area of a `JSVPanel`

Specified by:
  `removeHighlight` in interface `JSVAppletInterface`
Parameters:
  `x1` - the starting x value
  `x2` - the ending x value

### reversePlot

public void reversePlot()
Description copied from interface: `JSVAppletInterface`
Method that can be called from another applet or from javascript that toggles reversing the plot on a `JSVPanel`

Specified by:
  `reversePlot` in interface `JSVAppletInterface`

### script

@Deprecated public void script(String script)
Deprecated.

### runScript

public void runScript(String script)
Description copied from interface: `JSVAppletInterface`
runs a script in proper order as listed

Specified by:
  `runScript` in interface `JSVAppletInterface`
Parameters:
  `script` -

### syncScript

public void syncScript(String peakScript)
Description copied from interface: `JSVAppletInterface`
precede invalid input: '<'Peaks here with full name of Jmol applet (including syncID)

Specified by:
  `syncScript` in interface `JSVAppletInterface`
Parameters:
  `peakScript` -

### writeStatus

public void writeStatus(String msg)
Description copied from interface: `JSVAppletInterface`
Writes a message to the status label

Specified by:
  `writeStatus` in interface `JSVAppletInterface`
Parameters:
  `msg` - the message

### getPropertyAsJavaObject

public Map<String,Object> getPropertyAsJavaObject(String key)

Specified by:
  `getPropertyAsJavaObject` in interface `JSVAppletInterface`

### getPropertyAsJSON

public String getPropertyAsJSON(String key)

Specified by:
  `getPropertyAsJSON` in interface `JSVAppletInterface`

### runScriptNow

public boolean runScriptNow(String script)

Specified by:
  `runScriptNow` in interface `JSVAppletInterface`

### print

public String print(String fileName)

Specified by:
  `print` in interface `JSVAppletInterface`

### setDropTargetListener

public void setDropTargetListener(boolean isSigned, JSViewer viewer)

Specified by:
  `setDropTargetListener` in interface `AppletFrame`

### validateContent

public void validateContent(int mode)

Specified by:
  `validateContent` in interface `AppletFrame`

### createMainPanel

public void createMainPanel(JSViewer viewer)

Specified by:
  `createMainPanel` in interface `AppletFrame`

### newWindow

public void newWindow(boolean isSelected)

Specified by:
  `newWindow` in interface `AppletFrame`

### callToJavaScript

public void callToJavaScript(String callback, Object[] data)
Calls a javascript function given by the function name passing to it the string parameters as arguments

Specified by:
  `callToJavaScript` in interface `AppletFrame`
Parameters:
  `callback` -
  `data` -

### setPanelVisible

public void setPanelVisible(boolean b)

Specified by:
  `setPanelVisible` in interface `AppletFrame`

### getJSVPanel

public JSVPanel getJSVPanel(JSViewer viewer, Lst<Spectrum> specs)

Specified by:
  `getJSVPanel` in interface `AppletFrame`

### getDocumentBase

public URL getDocumentBase()

Specified by:
  `getDocumentBase` in interface `AppletFrame`

### repaint

public void repaint()

Specified by:
  `repaint` in interface `AppletFrame`

### validate

public void validate()

Specified by:
  `validate` in interface `AppletFrame`

### doExitJmol

public void doExitJmol()

Specified by:
  `doExitJmol` in interface `AppletFrame`

### getApp

public JSVApp getApp()

Specified by:
  `getApp` in interface `AppletFrame`

### setStatusDragDropped

public boolean setStatusDragDropped(int mode, int x, int y, String fileName, String[] retType)

Specified by:
  `setStatusDragDropped` in interface `JSInterface`

### cacheFileByName

public int cacheFileByName(String fileName, boolean isAdd)

Specified by:
  `cacheFileByName` in interface `JSInterface`

### cachePut

public void cachePut(String key, Object data)

Specified by:
  `cachePut` in interface `JSInterface`

### getFullName

public String getFullName()

Specified by:
  `getFullName` in interface `JSInterface`

### processMouseEvent

public boolean processMouseEvent(int id, int x, int y, int modifiers, long time)

Specified by:
  `processMouseEvent` in interface `JSInterface`

### setDisplay

public void setDisplay(Object canvas)

Specified by:
  `setDisplay` in interface `JSInterface`

### startHoverWatcher

public void startHoverWatcher(boolean enable)

Specified by:
  `startHoverWatcher` in interface `JSInterface`

### update

public void update()

Specified by:
  `update` in interface `JSInterface`

### openFile

public String openFile(String fileName)
possibly called from JSmolJSV.js upon start up

Parameters:
  `fileName` -
Returns:
  error or null

### openFileAsyncSpecial

public void openFileAsyncSpecial(String fileName, int flags)

Specified by:
  `openFileAsyncSpecial` in interface `JSInterface`

### openFileAsyncSpecialType

public void openFileAsyncSpecialType(String fileName, int flags, String type)

Specified by:
  `openFileAsyncSpecialType` in interface `JSInterface`

### processTwoPointGesture

public void processTwoPointGesture(float[][][] touches)

Specified by:
  `processTwoPointGesture` in interface `JSInterface`

### setScreenDimension

public void setScreenDimension(int width, int height)

Specified by:
  `setScreenDimension` in interface `JSInterface`

### checkScript

public String checkScript(String script)

Specified by:
  `checkScript` in interface `JSVAppletInterface`

### processKeyEvent

public void processKeyEvent(Object event)

Specified by:
  `processKeyEvent` in interface `JSInterface`