The rotation and the linkage to the sketcher have negligible contribution to the memory footprint. The largest contributions are from
Even if we provided a "thin" panel without 3D support, it would only enable you to use about twice as many molecules. Then you would run out of memory again because of the double buffering.
The solution is to use only one n-molecule scrollable MViewPane instead of a JTable with n MViewPanes. Then the common data will be stored in only one place (instead of n) and the number of Swing components will be equal to the number of visible molecules which is usually much smaller than n.
You should use an n-molecule scrollable MView table instead of n applets, see explanation to the previous question.
I have this problem when I want to get a Molecule from MViewPane:
viewPane.getM(0)
returns null although I put a molecule in 0.
Here is my code:
viewPane.setM(0, "mols-2d/caffeine.mol"); Molecule m = viewPane.getM(0);The problem is that you called
getM(0)
too early. The molecule was not loaded yet, since
viewPane.getM(0)
. MViewPane.setM(int,String)
launches a new thread for
loading a molecule and the getM(0)
method does not wait until this thread is finished.
Thus, there is no guaranty that the molecule loading process is finished until the method returns.
This method is generally used in case of loading a huge set of molecules in the same time.
If you use debug option: viewPane.setDebug(2)
, you can see when the molecule is loaded.
Instead of setM(int, java.lang.String)
use setM(int, java.io.File, java.lang.String)
method. Using this method will cause setM
to wait until molecule loading is finished.
This example shows a similar problem:
viewPane.setM(0, "CN1C=NC2=C1C(=O)N(C)C(=O)N2C"); Molecule m = viewPane.getM(0);In this case, there are several ways to avoid this problem. For example, you can use
MViewPane.setM(int, Molecule)
method:
String smiles="CN1C=NC2=C1C(=O)N(C)C(=O)N2C"; byte[] buf=smiles.getBytes(); MolImporter mi = new MolImporter(new ByteArrayInputStream(buf)); try{ Molecule mol = mi.importMol(buf); viewPane.setM(0,mol); }catch(Exception e) {System.err.println(e);} Molecule m = viewPane.getM(0);
The MarvinPanel.setParams(String) method is used to set parameters when MarvinPane is initialized (before loading the molecule). You should avoid calling this method after setMol(..) or any other property-setting method. You can find more details about it at here.
The difference between a parameter and a property that you can modify a property's value after initialization, while a parameter can only be set once.
It is possible with the Xvfb virtual X11 server. Documentation can be found on the xfree86 site and in the Linux manual (man Xvfb
).
Xvfb :2 -screen 0 649x480x24 2>>logfile & export DISPLAY=:2
Your molecule string may contain consecutive space characters in applet parameters which are converted to only one space. This bug applies to Mozilla 0.9.7-1.0 and probably some earlier versions too.
Please see the below example to get selected atoms.
Molecule mol = sketchPane.getMol(); if(mol != null) { int size = mol.getAtomCount(); for(int i = 0;i < size;i++) { MolAtom atom = mol.getAtom(i); if(atom.isSelected()) { System.err.println(i+". atom is selected"); } } }