# Class JSVApp

java.lang.Object
jspecview.app.JSVApp

All Implemented Interfaces:
  `JSVAppInterface, JSVAppletInterface, PanelListener, ScriptInterface`

Direct Known Subclasses:
  `JSVAppPro`

public class JSVApp extends Object implements PanelListener, JSVAppInterface, ScriptInterface
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

## Field Summary

Fields
Modifier and Type
Field
Description
`protected AppletFrame`
`appletFrame`
`String`
`appletReadyCallbackFunctionName`
`static final String`
`CREDITS`
`JSViewer`
`vwr`

## Constructor Summary

Constructors
Constructor
Description
`JSVApp(AppletFrame appletFrame, boolean isJS)`

## 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`
`String`
`checkScript(String script)`
`void`
`dispose()`
`void`
`doAdvanced(String filePath)`
called by Pro's popup window Advanced...
`String`
`exportSpectrum(String type, int n)`
Delivers spectrum coded as desired: XY, SQZ, PAC, DIF, DIFDUP, FIX, AML, CML
`AppletFrame`
`getAppletFrame()`
`static String`
`getAppletInfo()`
`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`
`Map<String,Object>`
`getPropertyAsJavaObject(String key)`
`String`
`getPropertyAsJSON(String key)`
`Lst<String>`
`getScriptQueue()`
`String`
`getSolnColour()`
Returns the calculated colour of a visible spectrum (Transmittance)
`void`
`initParams(String params)`
starts or restarts applet display from scratch or from a JSVApplet.script() JavaScript command Involves a two-pass sequence through parsing the parameters, because order is not important in this sort of call.
`boolean`
`isPro()`
`boolean`
`isSigned()`
`void`
`loadInline(String data)`
Loads in-line JCAMP-DX data into the existing applet window
`void`
`panelEvent(Object eventObj)`
called by notifyPeakPickedListeners in JSVPanel
`String`
`print(String fileName)`
`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 params)`
`void`
`setCursor(int id)`
`void`
`setFilePath(String tmpFilePath)`
`void`
`setSpectrumNumber(int n)`
Sets the spectrum to the specified block number
`void`
`setVisible(boolean b)`
`void`
`siCheckCallbacks(String title)`
`void`
`siExecHidden(boolean b)`
`void`
`siExecScriptComplete(String msg, boolean isOK)`
`void`
`siExecSetCallback(ScriptToken st, String value)`
`void`
`siExecTest(String value)`
`JSVPanel`
`siGetNewJSVPanel(Spectrum spec)`
`JSVPanel`
`siGetNewJSVPanel2(Lst<Spectrum> specs)`
`String`
`siLoaded(String value)`
`void`
`siNewWindow(boolean isSelected, boolean fromFrame)`
Shows the applet in a Frame
`void`
`siNodeSet(PanelNode panelNode)`
`void`
`siOpenDataOrFile(Object data, String name, Lst<Spectrum> specs, String url, int firstSpec, int lastSpec, boolean isAppend, String script, String id)`
`void`
`siProcessCommand(String scriptItem)`
overloaded in JSVAppletPro
`void`
`siSendPanelChange()`
`void`
`siSetCurrentSource(JDXSource source)`
`void`
`siSetLoaded(String fileName, String filePath)`
`void`
`siSetMenuEnables(PanelNode node, boolean isSplit)`
`void`
`siSetPropertiesFromPreferences(JSVPanel jsvp, boolean includeMeasures)`
`void`
`siSetSelectedPanel(JSVPanel jsvp)`
`void`
`siSourceClosed(JDXSource source)`
`void`
`siSyncLoad(String filePath)`
Loads a new file into the existing applet window
`void`
`siUpdateBoolean(ScriptToken st, boolean TF)`
`void`
`siUpdateRecentMenus(String filePath)`
`void`
`siValidateAndRepaint(boolean isAll)`
`void`
`syncScript(String peakScript)`
precede invalid input: '<'Peaks here with full name of Jmol applet (including syncID)
`void`
`syncToJmol(String msg)`
`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 coordinate on a `JSVPanel`
`void`
`updateJS(int width, int height)`
`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

### CREDITS

public static final String CREDITS

See Also:
  - Constant Field Values

### appletFrame

protected AppletFrame appletFrame

### appletReadyCallbackFunctionName

public String appletReadyCallbackFunctionName

### vwr

public JSViewer vwr

## Constructor Details

### JSVApp

public JSVApp(AppletFrame appletFrame, boolean isJS)

## Method Details

### isPro

public boolean isPro()

Specified by:
  `isPro` in interface `JSVAppletInterface`

### isSigned

public boolean isSigned()

Specified by:
  `isSigned` in interface `JSVAppletInterface`
Specified by:
  `isSigned` in interface `ScriptInterface`

### getAppletFrame

public AppletFrame getAppletFrame()

### dispose

public void dispose()

### 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`

### getCoordinate

public 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`

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

### loadInline

public void loadInline(String data)
Loads in-line JCAMP-DX data into the existing applet window

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

### exportSpectrum

public String exportSpectrum(String type, int n)
Delivers spectrum coded as desired: XY, SQZ, PAC, DIF, DIFDUP, FIX, AML, CML

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 n)
Sets the spectrum to the specified block number

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

### reversePlot

public void reversePlot()
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`

### toggleGrid

public void toggleGrid()
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()
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()
Method that can be called from another applet or from javascript that toggles the coordinate on a `JSVPanel`

Specified by:
  `togglePointsOnly` in interface `JSVAppletInterface`

### toggleIntegration

public void toggleIntegration()
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)
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

### removeHighlight

public 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`

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

### removeAllHighlights

public void removeAllHighlights()
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`

### 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)
Writes a message to the status label

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

### initParams

public void initParams(String params)
starts or restarts applet display from scratch or from a JSVApplet.script() JavaScript command Involves a two-pass sequence through parsing the parameters, because order is not important in this sort of call. To call a script and have commands execute in order, use JSVApplet.runScript(script) instead

Parameters:
  `params` -

### repaint

public void repaint()

Specified by:
  `repaint` in interface `ScriptInterface`

### updateJS

public void updateJS(int width, int height)

Parameters:
  `width` -
  `height` -

### runScriptNow

public boolean runScriptNow(String params)

Specified by:
  `runScriptNow` in interface `JSVAppletInterface`
Specified by:
  `runScriptNow` in interface `ScriptInterface`

### doAdvanced

public void doAdvanced(String filePath)
called by Pro's popup window Advanced...

Parameters:
  `filePath` -

### panelEvent

public void panelEvent(Object eventObj)
called by notifyPeakPickedListeners in JSVPanel

Specified by:
  `panelEvent` in interface `PanelListener`

### getSolnColour

public String getSolnColour()
Returns the calculated colour of a visible spectrum (Transmittance)

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

### syncToJmol

public void syncToJmol(String msg)

Specified by:
  `syncToJmol` in interface `ScriptInterface`
Parameters:
  `msg` -

### setVisible

public void setVisible(boolean b)

Specified by:
  `setVisible` in interface `JSVAppInterface`

### setCursor

public void setCursor(int id)

Specified by:
  `setCursor` in interface `ScriptInterface`

### 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`
Specified by:
  `runScript` in interface `ScriptInterface`
Parameters:
  `script` -

### getScriptQueue

public Lst<String> getScriptQueue()

Specified by:
  `getScriptQueue` in interface `JSVAppInterface`

### siSetCurrentSource

public void siSetCurrentSource(JDXSource source)

Specified by:
  `siSetCurrentSource` in interface `ScriptInterface`

### siSendPanelChange

public void siSendPanelChange()

Specified by:
  `siSendPanelChange` in interface `ScriptInterface`

### siNewWindow

public void siNewWindow(boolean isSelected, boolean fromFrame)
Shows the applet in a Frame

Specified by:
  `siNewWindow` in interface `ScriptInterface`
Parameters:
  `isSelected` -

### siValidateAndRepaint

public void siValidateAndRepaint(boolean isAll)

Specified by:
  `siValidateAndRepaint` in interface `ScriptInterface`

### siSyncLoad

public void siSyncLoad(String filePath)
Loads a new file into the existing applet window

Specified by:
  `siSyncLoad` in interface `ScriptInterface`
Parameters:
  `filePath` -

### siOpenDataOrFile

public void siOpenDataOrFile(Object data, String name, Lst<Spectrum> specs, String url, int firstSpec, int lastSpec, boolean isAppend, String script, String id)

Specified by:
  `siOpenDataOrFile` in interface `ScriptInterface`

### siProcessCommand

public void siProcessCommand(String scriptItem)
overloaded in JSVAppletPro

Specified by:
  `siProcessCommand` in interface `ScriptInterface`
Parameters:
  `scriptItem` -

### siSetSelectedPanel

public void siSetSelectedPanel(JSVPanel jsvp)

Specified by:
  `siSetSelectedPanel` in interface `ScriptInterface`

### siExecSetCallback

public void siExecSetCallback(ScriptToken st, String value)

Specified by:
  `siExecSetCallback` in interface `ScriptInterface`

### siLoaded

public String siLoaded(String value)

Specified by:
  `siLoaded` in interface `ScriptInterface`

### siExecHidden

public void siExecHidden(boolean b)

Specified by:
  `siExecHidden` in interface `ScriptInterface`

### siExecScriptComplete

public void siExecScriptComplete(String msg, boolean isOK)

Specified by:
  `siExecScriptComplete` in interface `ScriptInterface`

### siUpdateBoolean

public void siUpdateBoolean(ScriptToken st, boolean TF)

Specified by:
  `siUpdateBoolean` in interface `ScriptInterface`

### siCheckCallbacks

public void siCheckCallbacks(String title)

Specified by:
  `siCheckCallbacks` in interface `ScriptInterface`

### siNodeSet

public void siNodeSet(PanelNode panelNode)

Specified by:
  `siNodeSet` in interface `ScriptInterface`

### siSourceClosed

public void siSourceClosed(JDXSource source)

Specified by:
  `siSourceClosed` in interface `ScriptInterface`

### siGetNewJSVPanel

public JSVPanel siGetNewJSVPanel(Spectrum spec)

Specified by:
  `siGetNewJSVPanel` in interface `ScriptInterface`

### siGetNewJSVPanel2

public JSVPanel siGetNewJSVPanel2(Lst<Spectrum> specs)

Specified by:
  `siGetNewJSVPanel2` in interface `ScriptInterface`

### siSetPropertiesFromPreferences

public void siSetPropertiesFromPreferences(JSVPanel jsvp, boolean includeMeasures)

Specified by:
  `siSetPropertiesFromPreferences` in interface `ScriptInterface`

### siSetLoaded

public void siSetLoaded(String fileName, String filePath)

Specified by:
  `siSetLoaded` in interface `ScriptInterface`

### siSetMenuEnables

public void siSetMenuEnables(PanelNode node, boolean isSplit)

Specified by:
  `siSetMenuEnables` in interface `ScriptInterface`

### siUpdateRecentMenus

public void siUpdateRecentMenus(String filePath)

Specified by:
  `siUpdateRecentMenus` in interface `ScriptInterface`

### siExecTest

public void siExecTest(String value)

Specified by:
  `siExecTest` in interface `ScriptInterface`

### print

public String print(String fileName)

Specified by:
  `print` in interface `JSVAppletInterface`

### checkScript

public String checkScript(String script)

Specified by:
  `checkScript` in interface `JSVAppletInterface`

### getAppletInfo

public static String getAppletInfo()