Molecule-dependent way to setPreferredSize?

User d5d3760021

18-04-2016 16:10:24

Hello,


I'm working on a GUI tool using MarvinBeans for one of its panels. In the panel, I want to show different reactions (i.e., 2 dimensional sketches) corresponding to a user's selection. I'd like to be able to set the size of the panel to depend on the reaction itself since some take up significantly more space than others. E.g., something like this:


myMolecule = MolImporter.importMol(myData, myDataFormat);
structurePane = new MViewPane();
structurePane.setM(0, myMolecule);
structurePane.setPreferredSize(someAPI(myMolecule));

 


where someAPI takes into account font size, bond lengths, etc and tells me how much space the reaction needs. Is this possible?


Thanks!


 


I'm using:





































Product Version: MarvinSketch 6.0.1
Build Date: 2013-06-21
Internal build id: 6.0.1_b94
Operating System: x86_64 Mac OS X 10.11.4
Java: Oracle Corporation Java 1.7.0_79
Memory: 3641.0M maximum, 245.5M total, 192.4M free
Environment: Application
Browser: -

 

User d5d3760021

06-05-2016 17:19:44

Is the feature I described unavailable?

ChemAxon cbb451ac1e

09-05-2016 09:35:31

Dear Amos,


It is in our backlog. We'll keep you posted when fixed. 


Best regards,

ChemAxon 7936325a45

07-06-2016 12:18:33

Dear Amos,


The API won't be extended in the near future, but there is a similar API method.

https://marvin-demo.chemaxon.com/marvin/help/developer/beans/api/index.html


The MolImporter is part of the public API, and has a  getBoundingRectangle(MoleculeGraph[] mols) method. In the apidoc there is an example, but you only need the these two lines:


molPrinter.setScale(28);
Rectangle r = molPrinter.getBoundingRectangle(mols);

The resulting rectangle has the dimensions of the molecule at default scale.


I hope this helps, best regards,
István