___version=13.1.2_dev http://chemapps.stolaf.edu/jmol/Jmol-13.zip
new feature: (JmolViewer) public void cacheFile(String fileName, byte[] bytes) -- allows a mechanism for applets or embedding apps to deliver file content as bytes -- for applets, first getPropertyAsJavaObject("Viewer") So this should be a general way to deliver a byte array to Jmol. Basically what it does is to cache the bytes in memory. Then any later script reference to fileName will instead get those bytes. If you use null for fileName, then the cache will be cleared. Or, better, the cache will be cleared with the script command reset cache or cache remove all Basically, then, if you need to load binary data: 1) find a way to get that data using AJAX. 2) use Jmol.getPropertyAsJavaObject(jmol, "JmolViewer").cacheFile("url_of_your_data", data) 3) then just send a script to Jmol -- LOAD "url_of_your_data;cache remove all" Example is attached. On Fri, Aug 31, 2012 at 1:43 AM, Mikko Rantalainen < mikko.rantalai...@peda.net> wrote: > 2012-08-30 16:16 Europe/Helsinki: Robert Hanson: > > You won't be able to load binary data into Jmol using any script > command. > > Sorry. This won't work with .jmol files. > > > > So basically you have the problem that Java itself can't load the file > as a > > script, and the file is binary. Right? > > This is correct. I need the browser to download the file instead of Java > applet trying to do that by itself. > > > I can probably do something about that. As long as the binary data is > > mappable to Java byte[] > > I'll get back to you with a test tonight or tomorrow. I think it should > be > > possible, but it's going to be rather tricky. > > OK. In the demo "demo-ajax-load-jmol.html" you can change start of the > function httpGet(url, vars, callbackFunction) to read > > var request = getXmlHttpRequest(); > request.open("GET", url, true); // async > request.responseType = "text"; > request.overrideMimeType("application/octet-stream"); > request.onreadystatechange = function() > { > > Where responseType is set to "text", "blob", "document" or "arraybuffer" > (see documentation at > https://developer.mozilla.org/en-US/docs/DOM/XMLHttpRequest for more > details) to see if it gets the data in more appropriate format. > Currently anything else but "text" (default) causes "Error: Error > calling method on NPObject." in Google Chrome and in Firefox, I get > following error (with "arraybuffer"): > > java.lang.IllegalArgumentException: No method found matching name > loadInlineArray and arguments > [sun.plugin2.main.client.MessagePassingJSObject, java.lang.String, > java.lang.Boolean] > > It would be great if you can get binary loading to work. If this ends up > being unsupported, I just need to know it for sure before I start > working with some kind of workaround. > > -- > Mikko > > > > > ------------------------------------------------------------------------------ > 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-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users > > -- 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
<<attachment: testbinary.png>>
------------------------------------------------------------------------------ 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-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users