You CAN export an image from the applet, but you have to have the right 
browser. (Does not work in MSIE.) That is, it is not a general solution 
for the general user, but any web page developer can certainly take 
"snapshots" of the model for use in other applications. This was 
discussed earlier on this list, but I can't access the list archives 
right now.

The command from the console or via JavaScript is

getproperty image

The result is a base-64 encoded JPEG image that looks like this:

/9j/4AAQSkZJRgABAAAAAQABAAD//gBBSl...

Pop that into an <img> tag using Firefox or Opera (not MSIE), and you 
have an image that you can copy into your clipboard and do anything you 
would do with a JPG. The JavaScript required to create the tag looks 
like this:


var image = jmolGetPropertyAsString("image")
document.getElementById("someDiv").innerHTML ='<img 
src="data:image/jpeg;base64,'+image+'">'

This is implemented in 
<http://www.stolaf.edu/academics/chemapps/jmol/docs/examples-11/new.htm>. 
Just under the applet, click on the word "image" or the word "stereo". 
The stereo image can be generated by:

var width = 350
var height = 350

var s = '<table cellpadding="0" cellspacing="0"><tr>'
    +'<td><img width="WIDTH" height="HEIGHT" 
src="data:image/jpeg;base64,IMAGE"></td>'
    +'<td><img width="WIDTH" height="HEIGHT" 
src="data:image/jpeg;base64,IMAGE"></td>'
    +'</tr></table>'
s.replace(/WIDTH/g,width)
s.replace(/HEIGHT/g,height)

var angle = 2.5

jmolScriptWait("rotate y " + (-angle))
s = s.replace(/IMAGE/,jmolGetPropertyAsString("image"))

jmolScriptWait("rotate y "+ (2 * angle))
s = s.replace(/IMAGE/,jmolGetPropertyAsString("image"))

jmolScriptWait("rotate y " + (-angle))
document.getElementById("someDiv").innerHTML =s

In that web page this sort of code is run within a pop-up window that is 
running the jmol.js commands on the applet in the opener page. So you 
will see "opener." in front of all the jmol commands. Those pop-ups are 
getimage.htm and getstereo.htm in that directory.


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-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to