Package org.jmol.util

Class GenericApplet

java.lang.Object
org.jmol.util.GenericApplet
All Implemented Interfaces:
javajs.api.JSInterface, JmolAppletInterface, JmolCallbackListener, JmolStatusListener, JmolSyncInterface
Direct Known Subclasses:
Jmol

public abstract class GenericApplet extends Object implements javajs.api.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 Details

    • htRegistry

      protected static Map<String,Object> htRegistry
    • isJS

      protected static boolean isJS
    • SCRIPT_CHECK

      private static final int SCRIPT_CHECK
      See Also:
    • SCRIPT_WAIT

      private static final int SCRIPT_WAIT
      See Also:
    • SCRIPT_NOWAIT

      private static final int SCRIPT_NOWAIT
      See Also:
    • 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
    • loading

      private boolean loading
    • syncId

      private String syncId
    • outputBuffer

      private javajs.util.SB outputBuffer
    • 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 javajs.api.JSInterface
    • processKeyEvent

      public void processKeyEvent(Object event)
      Specified by:
      processKeyEvent in interface javajs.api.JSInterface
    • setDisplay

      public void setDisplay(Object canvas)
      Specified by:
      setDisplay in interface javajs.api.JSInterface
    • setStatusDragDropped

      public boolean setStatusDragDropped(int mode, int x, int y, String fileName, String[] retType)
      Specified by:
      setStatusDragDropped in interface javajs.api.JSInterface
    • startHoverWatcher

      public void startHoverWatcher(boolean enable)
      Specified by:
      startHoverWatcher in interface javajs.api.JSInterface
    • update

      public void update()
      Specified by:
      update in interface javajs.api.JSInterface
    • openFileAsyncSpecial

      public void openFileAsyncSpecial(String fileName, int flags)
      Specified by:
      openFileAsyncSpecial in interface javajs.api.JSInterface
    • openFileAsyncSpecialType

      public void openFileAsyncSpecialType(String fileName, int flags, String type)
      Specified by:
      openFileAsyncSpecialType in interface javajs.api.JSInterface
    • processTwoPointGesture

      public void processTwoPointGesture(float[][][] touches)
      Specified by:
      processTwoPointGesture in interface javajs.api.JSInterface
    • setScreenDimension

      public void setScreenDimension(int width, int height)
      Specified by:
      setScreenDimension in interface javajs.api.JSInterface
    • resizeDisplay

      void resizeDisplay(int width, int height)
    • init

      protected void init(Object applet)
    • initApplication

      private void initApplication()
    • destroy

      public void destroy()
      Specified by:
      destroy in interface JmolAppletInterface
      Specified by:
      destroy in interface javajs.api.JSInterface
    • getBooleanValue

      protected boolean getBooleanValue(String propertyName, boolean defaultValue)
    • getValue

      protected String getValue(String propertyName, String defaultValue)
    • getValueLowerCase

      private String getValueLowerCase(String paramName, String defaultValue)
    • setStringProperty

      private void setStringProperty(String name, String value)
    • scriptProcessor

      private String scriptProcessor(String script, String statusParams, int processType)
    • register

      public void register(String id, JmolSyncInterface jsi)
      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)
      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)
    • 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
    • consoleMessage

      private void consoleMessage(String message)
    • notifyEnabled

      public boolean notifyEnabled(CBK type)
      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
    • sendScript

      private String sendScript(String script, String appletName, boolean isSync, boolean doCallback)
    • notifySync

      private String notifySync(String info, String appletName)
    • 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
    • checkIn

      static void checkIn(String name, Object applet)
    • checkOut

      static void checkOut(String name)
    • findApplets

      static void findApplets(String appletName, String mySyncId, String excludeName, javajs.util.Lst<String> apps)
    • 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 javajs.api.JSInterface
    • cachePut

      public void cachePut(String key, Object data)
      Specified by:
      cachePut in interface javajs.api.JSInterface
    • getFullName

      public String getFullName()
      Specified by:
      getFullName in interface javajs.api.JSInterface