timothy driscoll wrote:
what happens if a function needs data from Jmol in the middle of the polling interval - would it have to wait for the poll to return? this might require salting your js code with lots of timeouts that wait on the polling timeout. this is my biggest concern, especially since js "time" is not independent of platform, computer, browser.
As far as I know, no function in JavaScript can "wait" for anything, due to the lack of a "doevents()"-like function. So any polling would have to respond by calling a preset function. One idea I could imagine is passing a JS function name to Jmol (as in the jmol.scriptButton() method) so that at least when the triggering event occurs there is something associated with it as to what to do next.
how would the polling function get the data from Jmol? the only mechanism I know is the callback mechanism :-(
Just execute an applet method that returns a value rather than a void, such as
document.jmol.getAppletInfo()
No callback required there.
javascript is not truly platform-independent like Java, so there are bound to be more problems like what we have with liveconnect in general.
The polling process only requires reading Java variables or calling simple Java methods. So I do think it is more reliable. It still uses the live connect mechanism, so there shouldn't be MORE problems. What I've seen with these callbacks is so strange I can't believe any polling would be worse.
what data would be returned to the polling function? a script is done, a structure is loaded, a selection is made, etc.?
I imagine something like:
public Boolean jmol.isScriptCompleted() public String jmol.getMessage() public String jmol.setMessage()
public Boolean jmol.isStructureLoaded() public Boolean jmol.isStructureDisplayed() public String jmol.getFileName() public String jmol.getFileContents()
public Boolean jmol.isAtomPicked() public String jmol.getSelectedAtomList() public String jmol.setSelectedAtomList() public String jmol.getMeasurement()
public Boolean jmol.isFrameChanged() public Integer jmol.getCurrentFrame() public Integer jmol.setCurrentFrame()
These last two -- atom picking and frame changing -- are such naturals for callbacks, I see them as difficult to poll correctly. One could really run into synchronization problems there.
and here's a complete duffer's question: isn't there some way for js to just "peek" inside a Java applet class
at any time after the applet is loaded? that could contain all of the relevant status info of the applet - selected set, script status, structure loaded, etc. then the js could simply go get the info whenever it wanted, instead of having to wait for Java to send it along.
(I'm sure you've explained this before, Miguel, but it's early on a sunday morning here ;-)
Sure. Try this:
javascript:alert(document.jmol.getAppletInfo())
I think this has to be a public function, that's all. See src/JavaApplet.java
Bob
-- Robert M. Hanson, [EMAIL PROTECTED], 507-646-3107 Professor of Chemistry, St. Olaf College 1520 St. Olaf Ave., Northfield, MN 55057 mailto:[EMAIL PROTECTED] http://www.stolaf.edu/people/hansonr
------------------------------------------------------- The SF.Net email is sponsored by: Beat the post-holiday blues Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt _______________________________________________ Jmol-developers mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jmol-developers
