OK, I've just about tracked down this Mac freezing business, but I don't
think I can do this myself. Tim, you have a Mac, right? will you please
report what you observe at http://fusion.stolaf.edu/chemistry/jmol/xtalx ?
I spent much of the afternoon going from one Mac to another in the lobby
of the Science Center stopping them in their tracks. I finally set up a
"javascript console" and tracked it all down to one statement near the
end of Eval.run():
clearMyThread();
terminationNotification = true;
viewer.popHoldRepaint();
}
Someone who knows the intricacies of Mac threading will have to look at
that, I guess, but apparently the fact that the scriptWait() method is
running Eval.run() even though NOT a separate thread is causing some
problem here.
Mind you, we have had loads of student reports of losing work due to
Macs freezing, so I think it's really more of a fundamental issue with
their threading model (or how difficult it is to program properly around
it). Still, I would like to see this page working on Macs.
I've added two features to 10.x that I think are pretty nice. Three
additional <object> parameters:
param name=statusForm
param name=statusText
param name=statusTextarea
This IS working on the Macs, and it's pretty neat. It's what is allowing
the pick "callback" at that page. Not a callback at all, just the applet
using
JSObject jsoForm = (JSObject) jsoDocument.getMember(statusForm);
if (statusText != null) {
JSObject jsoText = (JSObject) jsoForm.getMember(statusText);
jsoText.setMember("value", message);
The two methods -- text and textarea -- provide two ways of tracking the
status. The text one is overwritten and represents anything that would
normally go just to the status line. The textarea is equivalent to the
"console" (although System.outs don't go to it).
All you have to do is set a little looping function that incorporates
your needs. In this case we are testing for atom picking and measurements:
laststatus=""
function domonitor(){
var s=document.getElementById("statusText").value
if(s!=laststatus){
laststatus=s
if(s.indexOf("#")>=0){
var i=parseInt(s.split("#")[1])
if(!isNaN(i) && i > 0) {
var atom="atomno="+i
var ret=jmolGetJSONPropertyDecoded("atominfo",atom)
textoutput(s+"\n"+ret)
}
}
if(s.indexOf("measureCompleted")>=0){
textoutput(s)
}
}
setTimeout("domonitor()",10)
}
In association with this work, I found several additions to Jmol.js
(http://fusion.stolaf.edu/chemistry/jmol/xtalx/Jmol-new.js) handy:
//allows for custom jar file as second parameter of jmolInitialize():
function _jmolUseSignedApplet(useSignedApplet) {
_jmol.archivePath =
(typeof(useSignedApplet) == "string" ? useSignedApplet :
(useSignedApplet ? "JmolAppletSigned" : "JmolApplet") + "0.jar");
}
//slick as can be save/restore orientation:
function jmolSaveOrientation(id, targetSuffix) {
if(!targetSuffix)targetSufix="0"
return _jmol["savedOrientation"+id]
= jmolScriptWait("show orientation",targetSuffix).split(";")[0]
}
function jmolRestoreOrientation(id, targetSuffix) {
if(!targetSuffix)targetSufix="0"
var s=_jmol["savedOrientation"+id]
if (!s || s == "")return
return jmolScriptWait(s,targetSuffix)
}
//this is nice --- just gets a JSON property straight into a JavaScript
array:
function jmolGetJSONPropertyAsArray(key, param, targetSuffix) {
if(!param)param=""
if(!targetSuffix)targetSufix="0"
if(param!="")param=' "'+param+'"'
var ret = jmolScriptWait("getproperty "+key+param, targetSuffix)
ret = _jmolEvalJSON(ret,key)
return ret
}
//this is handy --- for development so you can see what the array
members look like:
function jmolGetJSONPropertyDecoded(key, param, targetSuffix) {
if(!param)param=""
if(!targetSuffix)targetSufix="0"
return _jmolEnumerateObject(jmolGetJSONPropertyAsArray(key, param,
targetSuffix),key)
}
//a simple way to add parameters to applet code returned using
jmolSetDocument(0):
function jmolAppletAddParam(appletCode,name,value){
if(value == "")return appletCode
return appletCode.replace(/\<param/,
"\n<param name='"+name+"' value='"+value+"' />\n<param")
}
All-in-all, I think XTALX demonstrates the power of jmolScriptWait() in
conjunction with
the script command "getproperty":
getproperty atominfo "atomno < 10"
getproperty orientationinfo
getproperty measurementinfo
etc.
Lots and lots of possibilities here.
By the way, the way the data are feeding into XTALX is sort of interesting:
For PDB, mmCIF, and user URL data, I'm just using a simple page on
fusion.stolaf.edu as a relay, delivering data from some other machine.
For the American Mineralogical Society Crystal Database structures
(multi-CIF), right now that same ColdFusion page transfers the database
output (which is in HTML) to JavaScript, which is requested through a
dynamic DOM script node. I haven't seen a lot of use of this, but it's
quite neat -- even at home I can get any of these formats. In fact, with
this method and a simple HTML file on your local machine, you could
still get all four forms of data. No jar files, not js files, nothing.
Just a bit of HTML and this DOM script node business. I'll set that up
as a demo.
I know Eric was complaining that it didn't seem to work consistently,
but I thnk that was a fluke -- I had changed some code on the server
page, and it wrecked it until just this last week.
Bob
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers