java.lang.NullPointerException - PluginDisplay

User b6c0b36627

18-04-2013 22:05:52

Dear all,


I've been trying to generate the window that show the tautomers without any success.


I cannot understand what I'm doing wrong... I keep obtaining a nullpointer exception, and using the debugger seems that the field resultmolecules of the display is empty;


I honestly cannot find a way to load the molecules and finally obtain a display;


here's the code I'm using:


 


private void spawnTautomerSelection(){
    
    
    TautomerizationPluginDisplay dsp=new TautomerizationPluginDisplay();
    TautomerizationPlugin tauplugin=new TautomerizationPlugin();
    dsp.setPlugin(tauplugin);
    JSplitPane tautdisplay = new JSplitPane();
    try {
        tauplugin.setMolecule(jcpPanel.getMol());
    } catch (PluginException e1) {
        e1.printStackTrace();
    }
    int count = tauplugin.getStructureCount();
    Molecule[] mollist={};
    tauplugin.setDominantTautomerDistributionCalculation(true);
    try {
        tauplugin.run();
    } catch (PluginException e) {
        e.printStackTrace();
    }
    for (int i=0; i < count; ++i) {
        Molecule tautomer = tauplugin.getStructure(i);
        double distribution = tauplugin.getDominantTautomerDistribution(i);
        System.out.println(tautomer.toFormat("smiles") + "  " + distribution);
    }
    dsp.setTitle("Conformers");
 
    Component comp = null;
    Component comp1 = null;
    try {
        dsp.setCellIndex(0);
        dsp.setParent(tautdisplay);
        ParameterPanelHandler pn = dsp.getParameterPanel();
        comp= pn.getComponent();//dsp.getResultComponent();
        comp1=dsp.getResultComponent();
        System.out.println ("done");
    } catch (PluginException e2) {
        e2.printStackTrace();
    }
    tautdisplay.setTopComponent(comp);
    tautdisplay.setBottomComponent(comp1);
    tautdisplay.setVisible(true);
    }

ChemAxon d9100dae53

22-04-2013 09:17:57

 


Dear Andrea,


the TautomerizationPluginDisplay class is not part of our public API, you should use chemaxon.marvin.beans.MViewPane or chemaxon.marvin.beans.MSketchPane instead.


Anyway, if you want to use the PluginDisplay you can do it something like this:


 


private static void spawnTautomerSelection(Molecule molecule) throws PluginException {



TautomerizationPlugin tauplugin = new TautomerizationPlugin();

tauplugin.setParameters(new Properties());

tauplugin.setMolecule(molecule);

tauplugin.setDominantTautomerDistributionCalculation(true);

tauplugin.run();



TautomerizationPluginDisplay dsp = new TautomerizationPluginDisplay();

dsp.setPlugin(tauplugin);

dsp.setCellIndex(0);

dsp.setParent(new MSketchPane().getMolPanel());

dsp.getResultComponent().setVisible(true);

}