Hi, here is the "trick" I have employed to retrieve variable content from the jmol environment to the parent java application.
Thanks to Bob ! Sincerely. Eric Solution found: use the first atom of the model to "transport" the wanted data: --------------------------------------------------------------------------------------------------------------- Consider one corner of my box: pt6X, pt6Y, pt6Z, defined in the jmol environment. In order to get back these 3 coordinates into my java application environment: ... JmolPanel jmolPanel = new JmolPanel(); jmolPanel.viewer.script("script userJmolFunctions.spt"); ... pt6X =...........; (Mathematical expression to compute the X coordinate for corner 6) pt6Y=...; pt6Z=...; // move atom 1 (atom numbering begins at 1 here) to corner 6 // (considering that the model is no longer used) jmolPanel.viewer.script("{atomno=1}.x=pt6X"); jmolPanel.viewer.script("{atomno=1}.y=pt6Y"); jmolPanel.viewer.script("{atomno=1}.z=pt6Z"); ... P3 corner; double[][] boxCorners = new double[8][3]; corner = jmolPanel.viewer.getAtomPoint3f(0); // take care ! atom numbering begins at 0 here boxCorners[0][0]= corner.x; boxCorners[0][1]= corner.y; boxCorners[0][2]= corner.z; ... static class JmolPanel extends JPanel { JmolViewer viewer; private final Dimension currentSize = new Dimension(); private final Rectangle rectClip = new Rectangle(); // ignored by Jmol JmolPanel() { viewer = JmolViewer.allocateViewer(this, new SmarterJmolAdapter(), null, null, null, null, null); } @Override public void paint(Graphics g) { getSize(currentSize); g.getClipBounds(rectClip); viewer.renderScreenImage(g, currentSize, rectClip); } } --------------------------------------------------------------------------------------------------------------- ~ ~ > > Today's Topics: > > 1. Re: Retrieving variable content, pb with getAtomPoint3f > (Robert Hanson) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 16 May 2014 16:35:46 -0500 > From: Robert Hanson <hans...@stolaf.edu> > Subject: Re: [Jmol-developers] Retrieving variable content, pb with > getAtomPoint3f > To: Jmol Developers <jmol-developers@lists.sourceforge.net> > Message-ID: > <CAF_YUvVjAH2qX05D51pA_mSOMHf7dPf-aXm_mRGh=a_x8uk...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Note that Jmol does not use javax.vecmath. I decided to just write my own > package, which would be then be way more efficient when translated to > JavaScript. > > > On Fri, May 16, 2014 at 12:49 PM, eric henon <eric.he...@univ-reims.fr>wrote: > >> Dear Bob, >> >> As you suggested it, I tried using (pseudo)atom information to pass >> my variable content, then: >> >> ------------------------------------------------------------------------- >> >> import org.jmol.api.JmolViewer; >> import org.jmol.util.Logger; >> import javax.vecmath.*; >> >> ... >> >> JmolPanel jmolPanel; >> ... >> >> Point3f corner; >> corner = jmolPanel.viewer.getAtomPoint3f(10); >> >> ... >> static class JmolPanel extends JPanel { >> >> JmolViewer viewer; >> >> private final Dimension currentSize = new Dimension(); >> private final Rectangle rectClip = new Rectangle(); // ignored by Jmol >> >> JmolPanel() { >> viewer = JmolViewer.allocateViewer(this, new SmarterJmolAdapter(), >> null, null, null, null, null); >> } >> >> ------------------------------------------------------------------------- >> >> However, I get the following compilation error: >> >> >> ******* >> MyJmol.java:473: incompatible types >> found : javajs.util.P3 >> required: javax.vecmath.Point3f >> corner = jmolPanel.viewer.getAtomPoint3f(2); >> >> ^ >> 1 error >> ******* >> >> as if getAtomPoint3f would return a P3 type ?? >> >> However, according to the class JmolViewer the getAtomPoint3f >> method should return a javax.vecmath.Point3f result ? >> >> >> Please, can you tell me what is wrong in what I do ? >> >> Thanks. >> Eric >> >> >> >> Today's Topics: >> >> 1. Re: jMol variable access (Robert Hanson) >> >> >> ---------------------------------------------------------------------- >> >> Message: 1 >> Date: Wed, 14 May 2014 12:04:17 -0500 >> From: Robert Hanson <hans...@stolaf.edu> >> Subject: Re: [Jmol-developers] jMol variable access >> To: Jmol Developers <jmol-developers@lists.sourceforge.net> >> Message-ID: >> <CAF_YUvXF8M3zuLyO0Bb-v=s1Bo1=smttzmn938pys6brkaz...@mail.gmail.com> >> Content-Type: text/plain; charset="utf-8" >> >> I would suggest implementing Atom, Bond, etc. The getProperty() method is >> also very powerful. >> >> >> >> >> On Wed, May 14, 2014 at 2:08 AM, eric henon <eric.he...@univ-reims.fr >>> wrote: >> >> Dear all, >> >> >> In my last email, I was wondering how to >> >> retrieve variable content of the Jmol environment, >> >> from a standalone java application. >> >> >> It seems that methods like *getAtomNumber >> >> < >> https://www.cellmicrocosmos.org/download/cm2/doc/org/jmol/api/JmolViewer.html#getAtomNumber(int) >>> * >> >> or *getAtomPoint3f >> >> < >> https://www.cellmicrocosmos.org/download/cm2/doc/org/jmol/api/JmolViewer.html#getAtomPoint3f(int)> >> of >> >> the class * >> >> JmolViewer are able to return some data. But these >> >> data are specific to objects like atoms, or bonds. However, >> >> what I need is something slightly different. >> >> >> In my Jmol application, I display a bound box >> >> that can be rotated, scaled, translated, and >> >> I want to get back the final volume, corner >> >> coordinates ... These data are encapsulated in >> >> some variables of my Jmol application. >> >> But how can I get back them ? >> >> >> Any help will be appreciated. >> >> Thanks. >> >> >> Eric >> >> >> >> >> >> Le 10 mai 2014 ? 19:41, eric henon a ?crit : >> >> >> Dear Bob, >> >> >> >> Thank you for your reply, that works fine ! >> >> >> Just a last question: how to get back jMol variable values into >> >> the parent java application ? >> >> >> Thanks in advance for your help. >> >> Eric >> >> >> >> Message: 2 >> >> >> Date: Mon, 5 May 2014 17:56:59 -0500 >> >> >> From: Robert Hanson <hans...@stolaf.edu> >> >> >> Subject: Re: [Jmol-developers] Running Script commands directly from a >> >> >> Java application >> >> >> To: Jmol Developers <jmol-developers@lists.sourceforge.net> >> >> >> Message-ID: >> >> >> <CAF_YUvU3xKpVN4SSx=vNPLc2_cp=wb-jbq-hxuze0sutjao...@mail.gmail.com> >> >> >> Content-Type: text/plain; charset="utf-8" >> >> >> >> Sure. All the menus do this. The toolbar buttons in the Java application, >> >> >> the surface tool dialog does this. File...Export...Gaussian has buttons. So >> >> >> check out org.openscience.jmol.app and included classes. The template is >> >> >> something like this: >> >> >> >> JButton goButton; >> >> >> JmolViewer viewer; >> >> >> ... >> >> >> goButton = new JButton("Turn the background to red"); >> >> >> goButton.setActionCommand("background red"); >> >> >> goButton.addActionListener(this); >> >> >> ... >> >> >> >> @Override >> >> >> public void actionPerformed(ActionEvent e) { >> >> >> Object source = e.getSource(); >> >> >> if (source == goButton) { >> >> >> viewer.script(((JButton)goButton).getActionCommand()); >> >> >> } >> >> >> } >> >> >> >> >> Various ways to embellish upon that. >> >> >> >> Bob >> >> >> >> >> >> >> >> >> On Mon, May 5, 2014 at 9:21 AM, eric henon <eric.he...@univ-reims.fr> >> >> wrote: >> >> >> >> Dear all, >> >> >> >> Last year, I built an web application using the jmolApplet. >> >> >> This applet (JBox) allows for embedding a protein in a boundbox, >> >> >> which can interactively be translated, zoomed in, or >> >> >> even individually rotated about three axis. >> >> >> >> I would like now to built my own java application >> >> >> embedding jmol that would allow for the same possibilities >> >> >> (rotating, ... boundBox). >> >> >> >> >> I have already used the Integration.java example >> >> >> to create a JmolPanel. It works fine. However, instead of using the >> >> >> "text" AppConsole possibilities, I would like to add buttons >> >> >> in my own application that would automatically pass script commands >> >> >> (functions) >> >> >> directly to jmol. Is this possible ? Are there any example for something >> >> >> like that ? >> >> >> >> Thanks in advance. >> >> >> Eric >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> >> Is your legacy SCM system holding you back? Join Perforce May 7 to find >> >> >> out: >> >> >> • 3 signs your SCM is hindering your productivity >> >> >> • Requirements for releasing software faster >> >> >> • Expert tips and advice for migrating your SCM now >> >> >> http://p.sf.net/sfu/perforce >> >> >> _______________________________________________ >> >> >> Jmol-developers mailing list >> >> >> Jmol-developers@lists.sourceforge.net >> >> >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> >> >> >> >> >> -- >> >> >> Robert M. Hanson >> >> >> Larson-Anderson Professor of Chemistry >> >> >> 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 >> >> >> -------------- next part -------------- >> >> >> An HTML attachment was scrubbed... >> >> >> >> ------------------------------ >> >> >> >> Message: 3 >> >> >> Date: Thu, 8 May 2014 11:50:50 +0200 >> >> >> From: Angel Herr?ez <angel.herr...@uah.es> >> >> >> Subject: Re: [Jmol-developers] What is the second Canvas2d for that >> >> >> shows up below the active one when using JSmol? >> >> >> To: <jmol-developers@lists.sourceforge.net> >> >> >> Message-ID: <536b537a.7561.2d99d...@angel.herraez.uah.es> >> >> >> Content-Type: text/plain; charset="US-ASCII" >> >> >> >> I'm having a similar problem as Jonathan's. Two canvas2d objects are >> >> >> created. >> >> >> >> I believe there is something wrong with Jmol.getAppletHtml() >> >> >> The problem does not happen when I use Jmol.getApplet() directly in the >> >> div. >> >> >> >> Note: I am using jquery-1.10.2.min.js plus JSmol.min.nojq.js >> >> >> >> Symptoms: >> >> >> >> - The page is taller (scroolbar) than its intended contents. >> >> >> >> - A square area below the actual JSmol square is sensitive to right-click >> >> >> opening of the popup menu and also to zoom by mouse wheel. >> >> >> >> - Firefox Inspector gives this source code: >> >> >> <div id="JmolOb_appletdiv" style="z-index: 15; width: 100%; height: 100%; >> >> >> position: absolute; top: 0px; left: 0px; display: block;"> >> >> >> <script type="text/javascript"></script> >> >> >> <canvas id="JmolOb_canvas2d" style="width: 100%; height: 100%; >> >> >> z-index: 17;" width="400" height="400"></canvas> >> >> >> <canvas id="JmolOb_canvas2d" style="width: 100%; height: 100%;" >> >> >> width="400" height="400"></canvas> >> >> >> </div> >> >> >> >> >> This is my code in the page: >> >> >> >> <head> >> >> >> <script> >> >> >> /* viewerMolec is a global object-variable defined before, that holds >> >> many >> >> >> parameters for the page. >> >> >> */ >> >> >> viewerMolec.infoJmol = { >> >> >> color: '#'+viewerCfg.bkg, >> >> >> height: '100%', >> >> >> width: '100%', >> >> >> j2sPath: viewerMolec.pathJmol + 'j2s', >> >> >> jarPath: viewerMolec.pathJmol + 'java', >> >> >> jarFile: 'JmolAppletSigned0.jar', >> >> >> isSigned: true, >> >> >> serverURL: viewerMolec.pathJmol + 'php/jsmol.php', >> >> >> loadstructcallback: 'viewer_OnModelLoad', >> >> >> pickcallback: 'viewer_OnAtomOrBondPicked', >> >> >> measureCallback: 'viewer_OnMeasures', >> >> >> script: 'set frank off; /*etc*/ ', >> >> >> zIndexBase: 15, >> >> >> z: 15, >> >> >> deferUncover:true, >> >> >> coverImage:'cover.png', >> >> >> use: 'html5' >> >> >> }; >> >> >> >> $(document).ready( function() { >> >> >> >> $('#viewerViewer').html(Jmol.getAppletHtml('JmolOb',viewerMolec.infoJmol)) >> >> >> ; >> >> >> }); >> >> >> </script> >> >> >> >> <style> >> >> >> #viewer { width:800px; height:400px; position:relative; } >> >> >> #viewerTools { width:49%; height:100%; position:absolute; left:0; top:0; >> >> >> overflow:hidden; } >> >> >> #viewerViewer { width:50%; height:100%; position:absolute; left:50%; >> >> top:0; } >> >> >> </style> >> >> >> </head> >> >> >> >> <body> >> >> >> <div id="viewer"> >> >> >> <div id="viewerTools"> >> >> >> // etc. >> >> >> </div> >> >> >> <div id="viewerViewer"><img src="cover.png"> >> >> >> </div> >> >> >> </div> >> >> >> </body> >> >> >> >> >> >> >> >> >> ------------------------------ >> >> >> >> Message: 4 >> >> >> Date: Thu, 8 May 2014 10:06:54 -0500 >> >> >> From: Robert Hanson <hans...@stolaf.edu> >> >> >> Subject: Re: [Jmol-developers] What is the second Canvas2d for that >> >> >> shows up below the active one when using JSmol? >> >> >> To: Jmol Developers <jmol-developers@lists.sourceforge.net> >> >> >> Message-ID: >> >> >> <caf_yuvw+uylr_1egwz601342cj3dd3wakff_8swoaj85hnd...@mail.gmail.com> >> >> >> Content-Type: text/plain; charset="utf-8" >> >> >> >> That's not enough to go on. Yes, the applet is creating itself twice. As >> >> >> described above, we need to check what is happening with >> >> >> >> proto._createCanvas2d >> >> >> >> You must determine why it is running twice. >> >> >> >> Also, correct your <img> tag. It is not closed. >> >> >> >> >> >> >> On Thu, May 8, 2014 at 4:50 AM, Angel Herr?ez <angel.herr...@uah.es> >> >> wrote: >> >> >> >> I'm having a similar problem as Jonathan's. Two canvas2d objects are >> >> >> created. >> >> >> >> I believe there is something wrong with Jmol.getAppletHtml() >> >> >> The problem does not happen when I use Jmol.getApplet() directly in the >> >> >> div. >> >> >> >> Note: I am using jquery-1.10.2.min.js plus JSmol.min.nojq.js >> >> >> >> Symptoms: >> >> >> >> - The page is taller (scroolbar) than its intended contents. >> >> >> >> - A square area below the actual JSmol square is sensitive to right-click >> >> >> opening of the popup menu and also to zoom by mouse wheel. >> >> >> >> - Firefox Inspector gives this source code: >> >> >> <div id="JmolOb_appletdiv" style="z-index: 15; width: 100%; height: 100%; >> >> >> position: absolute; top: 0px; left: 0px; display: block;"> >> >> >> <script type="text/javascript"></script> >> >> >> <canvas id="JmolOb_canvas2d" style="width: 100%; height: 100%; >> >> >> z-index: 17;" width="400" height="400"></canvas> >> >> >> <canvas id="JmolOb_canvas2d" style="width: 100%; height: 100%;" >> >> >> width="400" height="400"></canvas> >> >> >> </div> >> >> >> >> >> This is my code in the page: >> >> >> >> <head> >> >> >> <script> >> >> >> /* viewerMolec is a global object-variable defined before, that holds many >> >> >> parameters for the page. >> >> >> */ >> >> >> viewerMolec.infoJmol = { >> >> >> color: '#'+viewerCfg.bkg, >> >> >> height: '100%', >> >> >> width: '100%', >> >> >> j2sPath: viewerMolec.pathJmol + 'j2s', >> >> >> jarPath: viewerMolec.pathJmol + 'java', >> >> >> jarFile: 'JmolAppletSigned0.jar', >> >> >> isSigned: true, >> >> >> serverURL: viewerMolec.pathJmol + 'php/jsmol.php', >> >> >> loadstructcallback: 'viewer_OnModelLoad', >> >> >> pickcallback: 'viewer_OnAtomOrBondPicked', >> >> >> measureCallback: 'viewer_OnMeasures', >> >> >> script: 'set frank off; /*etc*/ ', >> >> >> zIndexBase: 15, >> >> >> z: 15, >> >> >> deferUncover:true, >> >> >> coverImage:'cover.png', >> >> >> use: 'html5' >> >> >> }; >> >> >> >> $(document).ready( function() { >> >> >> >> $('#viewerViewer').html(Jmol.getAppletHtml('JmolOb',viewerMolec.infoJmol)) >> >> >> ; >> >> >> }); >> >> >> </script> >> >> >> >> <style> >> >> >> #viewer { width:800px; height:400px; position:relative; } >> >> >> #viewerTools { width:49%; height:100%; position:absolute; left:0; top:0; >> >> >> overflow:hidden; } >> >> >> #viewerViewer { width:50%; height:100%; position:absolute; left:50%; >> >> >> top:0; } >> >> >> </style> >> >> >> </head> >> >> >> >> <body> >> >> >> <div id="viewer"> >> >> >> <div id="viewerTools"> >> >> >> // etc. >> >> >> </div> >> >> >> <div id="viewerViewer"><img src="cover.png"> >> >> >> </div> >> >> >> </div> >> >> >> </body> >> >> >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> >> Is your legacy SCM system holding you back? Join Perforce May 7 to find >> >> >> out: >> >> >> • 3 signs your SCM is hindering your productivity >> >> >> • Requirements for releasing software faster >> >> >> • Expert tips and advice for migrating your SCM now >> >> >> http://p.sf.net/sfu/perforce >> >> >> _______________________________________________ >> >> >> Jmol-developers mailing list >> >> >> Jmol-developers@lists.sourceforge.net >> >> >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> >> >> >> >> >> -- >> >> >> Robert M. Hanson >> >> >> Larson-Anderson Professor of Chemistry >> >> >> 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 >> >> >> -------------- next part -------------- >> >> >> An HTML attachment was scrubbed... >> >> >> >> ------------------------------ >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> >> Is your legacy SCM system holding you back? Join Perforce May 7 to find >> >> out: >> >> >> • 3 signs your SCM is hindering your productivity >> >> >> • Requirements for releasing software faster >> >> >> • Expert tips and advice for migrating your SCM now >> >> >> http://p.sf.net/sfu/perforce >> >> >> >> ------------------------------ >> >> >> >> _______________________________________________ >> >> >> Jmol-developers mailing list >> >> >> Jmol-developers@lists.sourceforge.net >> >> >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> >> >> >> End of Jmol-developers Digest, Vol 96, Issue 1 >> >> >> ********************************************** >> >> >> >> >> >> >> >> ------------------------------------------------------------------------------ >> >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> >> Instantly run your Selenium tests across 300+ browser/OS combos. >> >> Get unparalleled scalability from the best Selenium testing platform >> >> available >> >> Simple to use. Nothing to install. Get started now for free." >> >> http://p.sf.net/sfu/SauceLabs >> >> _______________________________________________ >> >> Jmol-developers mailing list >> >> Jmol-developers@lists.sourceforge.net >> >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> >> >> >> >> -- >> Robert M. Hanson >> Larson-Anderson Professor of Chemistry >> 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 >> -------------- next part -------------- >> An HTML attachment was scrubbed... >> >> ------------------------------ >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> >> ------------------------------ >> >> _______________________________________________ >> Jmol-developers mailing list >> Jmol-developers@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> >> End of Jmol-developers Digest, Vol 96, Issue 5 >> ********************************************** >> >> >> >> >> ------------------------------------------------------------------------------ >> "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE >> Instantly run your Selenium tests across 300+ browser/OS combos. >> Get unparalleled scalability from the best Selenium testing platform >> available >> Simple to use. Nothing to install. Get started now for free." >> http://p.sf.net/sfu/SauceLabs >> _______________________________________________ >> Jmol-developers mailing list >> Jmol-developers@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/jmol-developers >> >> > > > -- > Robert M. Hanson > Larson-Anderson Professor of Chemistry > 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 > -------------- next part -------------- > An HTML attachment was scrubbed... > > ------------------------------ > > ------------------------------------------------------------------------------ > "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE > Instantly run your Selenium tests across 300+ browser/OS combos. > Get unparalleled scalability from the best Selenium testing platform available > Simple to use. Nothing to install. Get started now for free." > http://p.sf.net/sfu/SauceLabs > > ------------------------------ > > _______________________________________________ > Jmol-developers mailing list > Jmol-developers@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-developers > > > End of Jmol-developers Digest, Vol 96, Issue 7 > ********************************************** ------------------------------------------------------------------------------ "Accelerate Dev Cycles with Automated Cross-Browser Testing - For FREE Instantly run your Selenium tests across 300+ browser/OS combos. Get unparalleled scalability from the best Selenium testing platform available Simple to use. Nothing to install. Get started now for free." http://p.sf.net/sfu/SauceLabs _______________________________________________ Jmol-developers mailing list Jmol-developers@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-developers