# Class GenericApplet

java.lang.Object
org.jmol.util.GenericApplet

All Implemented Interfaces:
  `JSInterface, JmolAppletInterface, JmolCallbackListener, JmolStatusListener, JmolSyncInterface`

Direct Known Subclasses:
  `Jmol`

public abstract class GenericApplet extends Object implements JSInterface, JmolAppletInterface, JmolStatusListener
A collection of all methods necessary for initialization of and communication with the applet. JavaScript and Java applet (which is still part of Jmol-SwingJS).

## Field Summary

Fields
Modifier and Type
Field
Description
`protected Object`
`appletObject`
`protected Map<CBK,String>`
`callbacks`
`protected String`
`codeBase`
`protected String`
`documentBase`
`protected boolean`
`doTranslate`
`protected String`
`fullName`
`protected Object`
`gRight`
`protected boolean`
`haveDocumentAccess`
`protected boolean`
`haveNotifiedError`
`protected String`
`htmlName`
`protected Map<String,Object>`
`htParams`
`protected static Map<String,Object>`
`htRegistry`
`protected static boolean`
`isJS`
`protected boolean`
`isSigned`
`protected boolean`
`isStereoSlave`
`protected String`
`language`
`protected boolean`
`mayScript`
`protected String`
`statusForm`
`protected String`
`statusText`
`protected String`
`statusTextarea`
`protected Viewer`
`viewer`
`protected Map<String,Object>`
`vwrOptions`

## Constructor Summary

Constructors
Constructor
Description
`GenericApplet()`

## Method Summary

Modifier and Type
Method
Description
`int`
`cacheFileByName(String fileName, boolean isAdd)`
`void`
`cachePut(String key, Object data)`
`String`
`createImage(String fileName, String type, Object text_or_bytes, int quality)`
Starting with Jmol 11.8.RC5, for a context where the Jmol application is embedded in another application simply to send the returned message to the application.
`void`
`destroy()`
`protected String`
`doEval(String strEval)`
return RAW JAVASCRIPT OBJECT, NOT A STRING
`protected String`
`doSendCallback(CBK type, Object callback, Object[] data, String strInfo)`
`protected void`
`doShowDocument(URL url)`
`protected void`
`doShowStatus(String message)`
`String`
`eval(String strEval)`
`float[][]`
`functionXY(String functionName, int nX, int nY)`
for isosurface FUNCTIONXY
`float[][][]`
`functionXYZ(String functionName, int nX, int nY, int nZ)`
for isosurface FUNCTIONXYZ
`String`
`getAppletInfo()`
`protected boolean`
`getBooleanValue(String propertyName, boolean defaultValue)`
`String`
`getFullName()`
`Object`
`getGLmolView()`
This method is only called by JmolGLmol applet._refresh();
`protected String`
`getJmolParameter(String paramName)`
`Map<String,Object>`
`getJSpecViewProperty(String key)`
JSpecView shares the JmolSyncInterface; used to get JSpecView
`int`
`getModelIndexFromId(String id)`
`Object`
`getProperty(String infoType)`
`Object`
`getProperty(String infoType, String paramInfo)`
@XXXj2sOverride
`String`
`getPropertyAsJSON(String infoType)`
`String`
`getPropertyAsJSON(String infoType, String paramInfo)`
@XXXj2sOverride
`String`
`getPropertyAsString(String infoType)`
`String`
`getPropertyAsString(String infoType, String paramInfo)`
@XXXj2sOverride
`Map<String,Object>`
`getRegistryInfo()`
`protected String`
`getValue(String propertyName, String defaultValue)`
`boolean`
`handleEvent(Event e)`
/////////// JmolAppletInterface //////////////
`protected void`
`init(Object applet)`
`protected void`
`initOptions()`
`String`
`loadDOMNode(Object DOMNode)`
`String`
`loadInline(String strModel)`
Deprecated.
`String`
`loadInline(String[] strModels)`
Deprecated.
`String`
`loadInline(String[] strModels, String script)`
Deprecated.
`String`
`loadInline(String strModel, String script)`
Deprecated.
`String`
`loadInlineArray(String[] strModels, String script, boolean isAppend)`
`String`
`loadInlineString(String strModel, String script, boolean isAppend)`
`void`
`notifyAudioEnded(Object htParams)`
`void`
`notifyCallback(CBK type, Object[] data)`
`boolean`
`notifyEnabled(CBK type)`
////////// JmolStatusListener ///////////
`String`
`openFile(String fileName)`
possibly called from JSmolApplet.js upon start up
`void`
`openFileAsyncSpecial(String fileName, int flags)`
`void`
`openFileAsyncSpecialType(String fileName, int flags, String type)`
`void`
`output(String s)`
called by mystatuslisteners
`void`
`processKeyEvent(Object event)`
`boolean`
`processMouseEvent(int id, int x, int y, int modifiers, long time)`
`void`
`processTwoPointGesture(float[][][] touches)`
`void`
`register(String id, JmolSyncInterface jsi)`
////// JmolSyncInterface //////////
`int[]`
`resizeInnerPanel(String data)`
`void`
`script(String script)`
`String`
`scriptCheck(String script)`
`String`
`scriptNoWait(String script)`
`String`
`scriptWait(String script)`
`String`
`scriptWait(String script, String statusParams)`
`String`
`scriptWaitOutput(String script)`
`void`
`setCallback(String name, Object callbackObject)`
set a callback either as a function or a function name from JavaScript
`void`
`setCallbackFunction(String callbackName, String callbackObject)`
From StatusManager
`void`
`setDisplay(Object canvas)`
`protected void`
`setJSOptions(Map<String,Object> vwrOptions)`
`void`
`setScreenDimension(int width, int height)`
`boolean`
`setStatusDragDropped(int mode, int x, int y, String fileName, String[] retType)`
`Object`
`setStereoGraphics(boolean isStereo)`
`void`
`showUrl(String urlString)`
`void`
`startHoverWatcher(boolean enable)`
`void`
`syncScript(String script)`
`void`
`update()`

### Methods inherited from class Object

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

## Field Details

### htRegistry

protected static Map<String,Object> htRegistry

### isJS

protected static boolean isJS

### codeBase

protected String codeBase

### documentBase

protected String documentBase

### isSigned

protected boolean isSigned

### language

protected String language

### doTranslate

protected boolean doTranslate

### haveDocumentAccess

protected boolean haveDocumentAccess

### isStereoSlave

protected boolean isStereoSlave

### mayScript

protected boolean mayScript

### htmlName

protected String htmlName

### fullName

protected String fullName

### statusForm

protected String statusForm

### statusText

protected String statusText

### statusTextarea

protected String statusTextarea

### gRight

protected Object gRight

### viewer

protected Viewer viewer

### callbacks

protected Map<CBK,String> callbacks

### vwrOptions

protected Map<String,Object> vwrOptions

### haveNotifiedError

protected boolean haveNotifiedError

### appletObject

protected Object appletObject

### htParams

protected Map<String,Object> htParams

## Constructor Details

### GenericApplet

public GenericApplet()

## Method Details

### setStereoGraphics

public Object setStereoGraphics(boolean isStereo)

Specified by:
  `setStereoGraphics` in interface `JmolAppletInterface`

### processMouseEvent

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

Specified by:
  `processMouseEvent` in interface `JSInterface`

### processKeyEvent

public void processKeyEvent(Object event)

Specified by:
  `processKeyEvent` in interface `JSInterface`

### setDisplay

public void setDisplay(Object canvas)

Specified by:
  `setDisplay` in interface `JSInterface`

### setStatusDragDropped

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

Specified by:
  `setStatusDragDropped` 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`

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

### init

protected void init(Object applet)

### destroy

public void destroy()

Specified by:
  `destroy` in interface `JmolAppletInterface`
Specified by:
  `destroy` in interface `JSInterface`

### getBooleanValue

protected boolean getBooleanValue(String propertyName, boolean defaultValue)

### getValue

protected String getValue(String propertyName, String defaultValue)

### register

public void register(String id, JmolSyncInterface jsi)
////// JmolSyncInterface //////////

Specified by:
  `register` in interface `JmolSyncInterface`

### getJSpecViewProperty

public Map<String,Object> getJSpecViewProperty(String key)
JSpecView shares the JmolSyncInterface; used to get JSpecView

Specified by:
  `getJSpecViewProperty` in interface `JmolStatusListener`
Specified by:
  `getJSpecViewProperty` in interface `JmolSyncInterface`

### syncScript

public void syncScript(String script)

Specified by:
  `syncScript` in interface `JmolSyncInterface`

### handleEvent

public boolean handleEvent(Event e)
/////////// JmolAppletInterface //////////////

Specified by:
  `handleEvent` in interface `JmolAppletInterface`

### getAppletInfo

public String getAppletInfo()

Specified by:
  `getAppletInfo` in interface `JmolAppletInterface`

### script

public void script(String script)

Specified by:
  `script` in interface `JmolAppletInterface`

### scriptCheck

public String scriptCheck(String script)

Specified by:
  `scriptCheck` in interface `JmolAppletInterface`

### scriptNoWait

public String scriptNoWait(String script)

Specified by:
  `scriptNoWait` in interface `JmolAppletInterface`

### scriptWait

public String scriptWait(String script)

Specified by:
  `scriptWait` in interface `JmolAppletInterface`

### scriptWait

public String scriptWait(String script, String statusParams)

Specified by:
  `scriptWait` in interface `JmolAppletInterface`

### scriptWaitOutput

public String scriptWaitOutput(String script)

Specified by:
  `scriptWaitOutput` in interface `JmolAppletInterface`

### getModelIndexFromId

public int getModelIndexFromId(String id)

Specified by:
  `getModelIndexFromId` in interface `JmolAppletInterface`
Parameters:
  `id` - some_id, filename#id, or ~fileNo.modelNo added ".basemodel" indicates to get the first model in a series from a JDX-MOL file.
Returns:
  model index if found; -2 if file found but model not found -2 if no file indicated and no model found -1 if no such file

### getProperty

public Object getProperty(String infoType)

Specified by:
  `getProperty` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
Returns:
  value

### getProperty

public Object getProperty(String infoType, String paramInfo)
@XXXj2sOverride

Specified by:
  `getProperty` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
  `paramInfo` -
Returns:
  value

### getPropertyAsString

public String getPropertyAsString(String infoType)

Specified by:
  `getPropertyAsString` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
Returns:
  value

### getPropertyAsString

public String getPropertyAsString(String infoType, String paramInfo)
@XXXj2sOverride

Specified by:
  `getPropertyAsString` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
  `paramInfo` -
Returns:
  value

### getPropertyAsJSON

public String getPropertyAsJSON(String infoType)

Specified by:
  `getPropertyAsJSON` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
Returns:
  value

### getPropertyAsJSON

public String getPropertyAsJSON(String infoType, String paramInfo)
@XXXj2sOverride

Specified by:
  `getPropertyAsJSON` in interface `JmolAppletInterface`
Parameters:
  `infoType` -
  `paramInfo` -
Returns:
  value

### loadInlineString

public String loadInlineString(String strModel, String script, boolean isAppend)

Specified by:
  `loadInlineString` in interface `JmolAppletInterface`

### loadInlineArray

public String loadInlineArray(String[] strModels, String script, boolean isAppend)

Specified by:
  `loadInlineArray` in interface `JmolAppletInterface`

### loadDOMNode

public String loadDOMNode(Object DOMNode)

Specified by:
  `loadDOMNode` in interface `JmolAppletInterface`

### loadInline

@Deprecated public String loadInline(String strModel)
Deprecated.

Specified by:
  `loadInline` in interface `JmolAppletInterface`
Parameters:
  `strModel` -
Returns:
  error or null

### loadInline

@Deprecated public String loadInline(String strModel, String script)
Deprecated.

Specified by:
  `loadInline` in interface `JmolAppletInterface`
Parameters:
  `strModel` -
  `script` -
Returns:
  error or null

### loadInline

@Deprecated public String loadInline(String[] strModels)
Deprecated.

Specified by:
  `loadInline` in interface `JmolAppletInterface`
Parameters:
  `strModels` -
Returns:
  error or null

### loadInline

@Deprecated public String loadInline(String[] strModels, String script)
Deprecated.

Specified by:
  `loadInline` in interface `JmolAppletInterface`
Parameters:
  `strModels` -
  `script` -
Returns:
  error or null

### output

public void output(String s)
called by mystatuslisteners

### setCallback

public void setCallback(String name, Object callbackObject)
set a callback either as a function or a function name from JavaScript

Specified by:
  `setCallback` in interface `JmolAppletInterface`

### setCallbackFunction

public void setCallbackFunction(String callbackName, String callbackObject)
From StatusManager

Specified by:
  `setCallbackFunction` in interface `JmolCallbackListener`

### notifyEnabled

public boolean notifyEnabled(CBK type)
////////// JmolStatusListener ///////////

Specified by:
  `notifyEnabled` in interface `JmolCallbackListener`

### notifyCallback

public void notifyCallback(CBK type, Object[] data)

Specified by:
  `notifyCallback` in interface `JmolCallbackListener`
Parameters:
  `type` - the callback type or null for getJsObjectInfo() -- Java applet only
  `data` - type-dependent

### eval

public String eval(String strEval)

Specified by:
  `eval` in interface `JmolStatusListener`

### createImage

public String createImage(String fileName, String type, Object text_or_bytes, int quality)
Description copied from interface: `JmolStatusListener`
Starting with Jmol 11.8.RC5, for a context where the Jmol application is embedded in another application simply to send the returned message to the application. In this way any application can have access to the WRITE command.

Specified by:
  `createImage` in interface `JmolStatusListener`
Parameters:
  `fileName` -
  `type` -
  `text_or_bytes` - information or null indicates message AFTER Jmol creates the image
  `quality` -
Returns:
  null (canceled) or a message starting with OK or an error message

### getRegistryInfo

public Map<String,Object> getRegistryInfo()

Specified by:
  `getRegistryInfo` in interface `JmolStatusListener`

### showUrl

public void showUrl(String urlString)

Specified by:
  `showUrl` in interface `JmolStatusListener`

### resizeInnerPanel

public int[] resizeInnerPanel(String data)

Specified by:
  `resizeInnerPanel` in interface `JmolStatusListener`

### notifyAudioEnded

public void notifyAudioEnded(Object htParams)

Specified by:
  `notifyAudioEnded` in interface `JmolAppletInterface`

### setJSOptions

protected void setJSOptions(Map<String,Object> vwrOptions)

### initOptions

protected void initOptions()

### getJmolParameter

protected String getJmolParameter(String paramName)

### functionXY

public float[][] functionXY(String functionName, int nX, int nY)
Description copied from interface: `JmolStatusListener`
for isosurface FUNCTIONXY

Specified by:
  `functionXY` in interface `JmolStatusListener`
Parameters:
  `functionName` -
  `nX` -
  `nY` -
Returns:
  2D array or null

### functionXYZ

public float[][][] functionXYZ(String functionName, int nX, int nY, int nZ)
Description copied from interface: `JmolStatusListener`
for isosurface FUNCTIONXYZ

Specified by:
  `functionXYZ` in interface `JmolStatusListener`
Parameters:
  `functionName` -
  `nX` -
  `nY` -
  `nZ` -
Returns:
  3D array or null

### doShowDocument

protected void doShowDocument(URL url)

### doSendCallback

protected String doSendCallback(CBK type, Object callback, Object[] data, String strInfo)

### doEval

protected String doEval(String strEval)
return RAW JAVASCRIPT OBJECT, NOT A STRING

Parameters:
  `strEval` -
Returns:
  result, not necessarily a String

### doShowStatus

protected void doShowStatus(String message)

### getGLmolView

public Object getGLmolView()
This method is only called by JmolGLmol applet._refresh();

Returns:
  enough data to update a WebGL view

### openFile

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

Parameters:
  `fileName` -
Returns:
  error or null

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