Frequently Asked Questions

  • Which Java versions are supported by Marvin Beans?

    Marvin Beans requires at least Java 1.6.

  • If I put MViewPane objects in JTable cells then I can display only about 200 molecules. These huge objects cause out of memory exceptions. Do you provide a simple and "thin" viewer component, which just displays a molecule without any rotation and linkage to the sketcher?

    The rotation and the linkage to the sketcher have negligible contribution to the memory footprint. The largest contributions are from

    1. double buffering of Swing components

    2. size of Molecule objects

    3. large color arrays that store the shades for 3D rendering modes

    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.

  • MViewPane.getM(int) returns with null.

    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);

  • I called MViewPane.setParams() to change only one parameter in MarvinView but it changed all of them.

    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.

  • Is there a way to generate image without opening a display?

    Add the -Djava.awt.headless=true option to your Java command. E.g.:

    java -classpath lib/MarvinBeans.jar -Djava.awt.headless=true chemaxon.formats.MolConverter

  • How can I get the selected atoms from MSketchPane?

    123456789101112

    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"); } } }