From: Robert H. <ha...@st...> - 2012-08-07 15:57:55
|
On Tue, Aug 7, 2012 at 10:28 AM, Gusts Kaksis <gus...@gm...>wrote: > On 2012.08.07. 17:03, Robert Hanson wrote: > > syncScript is very special. It's for sending scripts to synchronized > applets. Not something a user would do themselves. See the documentation on > the SYNC command. > > So it's used in between Jmol applets themselves, and it should not be > exported in JavaScript library? > > Right. For example, it's in JmolApplet.js, but not JmolApi.js > 5. And last, but not least. register and registerApplet - are these for >> synchronization? Is the fullName argument in registerApplet the same >> syncId received by appletReadyCallback (2nd argument)? And what's the >> second argument for register? >> >> > Yes, these are for synchronization. Don't play with those. Just make sure > your syncID is effectively unique. > > OK, so I have to use a script command "sync" then with all it's options, > right? > > It's not that you have to do anything. the syncScript method is the method we use for communicating among applets. I'm pretty sure that works directly, without JavaScript, because the registered applets are addressed directly. > My new idea is to create an applet wrapper class, that gets created once > the applet becomes ready. It will be thrown around in all the > events/callbacks as the first argument. And it will export applet's methods > or store something in cache if applet (for some unknown reason) would not > be available. jQuery-Jmol plugin would be used only to initialize DOM node > of Jmol applet and update some basic things, like dimensions, visibility of > the applet, also destroying it and restoring placeholder to it's initial > state (this option kind of complies with jQuery UI widget guidelines). I'm > targetting this: > > Initialization: > $('#jmol').jmol({... options ...}); > Update options: > $('#jmol').jmol({... options ...}); > Update single option: > $('#jmol').jmol('option', 'width', 200); > > Some jQuery-Jmol internal commands: > $('#jmol').jmol('hide'); // Hide applet - set it to 2x2 px > $('#jmol').jmol('show'); // Restore to original dimensions (from options) > $('#jmol').jmol('destroy'); // Remove Jmol from DOM and destroy every > reference > $('#jmol').jmol('bind', 'pick', myPickListener); // This would be an event > binding wrapper - > $('#jmol').jmol('unbind', 'pick', myPickListener); // This would be an > unbind wrapper - > > Binding wrapper would do the trick (although still, not quite jQuery-way) > - it would set up an appropriate callback in Jmol and then bind an event > listener to itself, so that callback listener could trigger an event. And > when all the listeners are removed, callback should also be freed, so I'll > send "set [callback] NONE". Event listeners should always receive my > wrapper object (which wraps a single instance of an applet) and other > parameters sent to callback (except for the ID attirbute). For example a > hoverCallback would be translated into an event, that would receive these > arguments: > > function myHoverListener (jmol, label, index){ > // Now you can just do some scripting > jmol.script('... some script source ...'); > } > > Methods, that I currently have in my Jmol wrapper, are: > getProperty - underneath it would use getPropertyAsJSON and parse the JSON > string prior returning a result. > getId - an ID attribute value of Jmol applet > script - same as in applet > scriptNoWait - same > scriptCheck - same > scriptWait - same > scriptWaitOutput - same > And, if I understood you correctly - other methods should not be made > public for JavaScript developers, these are either deprecated or for Jmol > intercommunication, right? > > So, this is what I'm currently playing around with. > Not sure what you are aiming at there. Jmol already has an applet wrapper, right? Are you saying this wrapper would not extend Applet? In Jmol right now the AppleWrapper class is an extension of Applet, so it, like any applet, must become fully initialized before it can ever be called. The Viewer class is what is being used for the display, but it is not the "applet" itself. (It is accessed by the wrapped applet using the JmolViewer interface.) The applet interface is public interface JmolAppletInterface extends JmolScriptInterface { public String getPropertyAsString(String infoType); public String getPropertyAsString(String infoType, String paramInfo); public String getPropertyAsJSON(String infoType); public String getPropertyAsJSON(String infoType, String paramInfo); public Object getProperty(String infoType); public Object getProperty(String infoType, String paramInfo); public String loadInlineString(String strModel, String script, boolean isAppend); public String loadInlineArray(String[] strModels, String script, boolean isAppend); public String loadNodeId(String nodeId); public String loadDOMNode(JSObject DOMNode); } with public interface JmolScriptInterface extends JmolSyncInterface { public Object setStereoGraphics(boolean isStereo); public void script(String script); public String scriptCheck(String script); public String scriptWait(String script); public String scriptWaitOutput(String script); public String scriptWait(String script, String statusParams); public String scriptNoWait(String script); } and public interface JmolSyncInterface { public abstract void syncScript(String script); public abstract void register(String id, JmolSyncInterface jsi); public Object getProperty(String key); } Bob > -- > Gusts Kaksis > > > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Jmol-developers mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-developers > > -- Robert M. Hanson Larson-Anderson Professor of Chemistry Chair, Chemistry Department St. Olaf College Northfield, MN http://www.stolaf.edu/people/hansonr If nature does not answer first what we want, it is better to take what answer we get. -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900 |