User 7b0ee04e66
13-08-2007 12:08:54
Good afternoon,
I am trying to display a Reaction Smarts on the fly listening to the Change Event from Marvin Sketch and displaying it into a Text Area in a JPanel.
I then try to draw the reaction attached. As soon as I draw the reaction arrow, I get the following exception.
c1ccccc1
[#6]-c1ccccc1
[#6]Cc1ccccc1
[#6]C([#6])c1ccccc1
[#6]C(O)c1ccccc1
Exception breakpoint occurred at line 144 of EventDispatchThread.java.
java.lang.ArrayIndexOutOfBoundsException: -1
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at chemaxon.marvin.modules.SSSR.fillRingIdx(Unknown Source)
at chemaxon.marvin.modules.SSSR.getRings(Unknown Source)
at chemaxon.marvin.modules.SSSR.callback(Unknown Source)
at chemaxon.struc.CGraph.getSSSR(Unknown Source)
at chemaxon.marvin.modules.Aromata.aromatize(Unknown Source)
at chemaxon.marvin.modules.Aromata.callback(Unknown Source)
at chemaxon.struc.MoleculeGraph.aromatize(Unknown Source)
at chemaxon.struc.Molecule.aromatize(Unknown Source)
at chemaxon.struc.RgMolecule.aromatize(Unknown Source)
at chemaxon.struc.MoleculeGraph.aromatize(Unknown Source)
at marvin.MSketchListenerExample.propertyChange(MSketchListenerExample.java:118)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7172)
at chemaxon.marvin.beans.MarvinPane.propertyChange(Unknown Source)
at chemaxon.marvin.beans.MSketchPane.propertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at chemaxon.marvin.sketch.swing.SketchCanvas.callback(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.historize(Unknown Source)
at chemaxon.marvin.sketch.modules.LineSM.buttonUp(Unknown Source)
at chemaxon.marvin.sketch.modules.ArrowSM$Reaction.buttonUp(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.command0(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.command(Unknown Source)
at chemaxon.marvin.sketch.swing.SketchCanvas.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5501)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5266)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
If I open the file from Marvin Sketch File > Open, this does not happen.
What am I doing wrong? Is there a way around the problem?
I have been tring to use the method "isReactionErrorVisible()" in MSketchPane, but there nearly always seems to be a Reaction error highlighted even when the Reaction is correct and can succesfully be used for Library Enumeration. What is it checking for exactly?
Regards
Catherine
I am trying to display a Reaction Smarts on the fly listening to the Change Event from Marvin Sketch and displaying it into a Text Area in a JPanel.
Code: |
package marvin; import chemaxon.marvin.beans.MSketchPane; import chemaxon.struc.Molecule; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTextArea; public class MSketchListenerExample extends JPanel implements PropertyChangeListener { private JLabel lblSmirks; private JScrollPane m_ScrollSmirks; private JTextArea txtSmirks; private MSketchPane m_MarvinSketch; public MSketchListenerExample() { initialize(); } public static void main(String[] args) { MSketchListenerExample mSketchListenerExample = new MSketchListenerExample(); JFrame test = new JFrame(); test.add(mSketchListenerExample); test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); test.pack(); test.setVisible(true); } private void initialize() { createSketchPanelLabels(); createSketchPanelTextAreas(); setUpLayout(); } /** * Method to create all the Labels on the form */ private void createSketchPanelLabels() { lblSmirks = new JLabel("SMIRKS", JLabel.RIGHT); } /** * Method to create all the text objects on the form */ private void createSketchPanelTextAreas() { txtSmirks = new JTextArea(3, 100); txtSmirks.setWrapStyleWord(true); m_ScrollSmirks = new JScrollPane(txtSmirks); m_MarvinSketch = new MSketchPane(); m_MarvinSketch.addPropertyChangeListener(this); } /** * This methods lays out all the form's components */ private void setUpLayout() { // set Layout to GridBagLayout GridBagConstraints c = new GridBagConstraints(); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); // first row // marvin c.fill = GridBagConstraints.BOTH; c.insets = new Insets(5, 5, 5, 5); c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.gridy = 0; c.weightx = 1; c.gridheight = 5; c.gridwidth = 4; gridbag.setConstraints(m_MarvinSketch, c); add(m_MarvinSketch); c.gridx = 0; c.gridy = 5; c.gridheight = 3; c.weightx = 1.0; c.gridwidth = GridBagConstraints.REMAINDER; gridbag.setConstraints(m_ScrollSmirks, c); add(m_ScrollSmirks); } public void propertyChange(PropertyChangeEvent evt) { String name = evt.getPropertyName(); if (name.equals("file") || name.equals("mol")) { Molecule mol = m_MarvinSketch.getMol(); mol.expandSgroups(); mol.aromatize(); System.out.println(mol.toFormat("smarts")); String smarts = mol.toFormat("smarts"); txtSmirks.setText(smarts); } } } |
I then try to draw the reaction attached. As soon as I draw the reaction arrow, I get the following exception.
c1ccccc1
[#6]-c1ccccc1
[#6]Cc1ccccc1
[#6]C([#6])c1ccccc1
[#6]C(O)c1ccccc1
Exception breakpoint occurred at line 144 of EventDispatchThread.java.
java.lang.ArrayIndexOutOfBoundsException: -1
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
at chemaxon.marvin.modules.SSSR.fillRingIdx(Unknown Source)
at chemaxon.marvin.modules.SSSR.getRings(Unknown Source)
at chemaxon.marvin.modules.SSSR.callback(Unknown Source)
at chemaxon.struc.CGraph.getSSSR(Unknown Source)
at chemaxon.marvin.modules.Aromata.aromatize(Unknown Source)
at chemaxon.marvin.modules.Aromata.callback(Unknown Source)
at chemaxon.struc.MoleculeGraph.aromatize(Unknown Source)
at chemaxon.struc.Molecule.aromatize(Unknown Source)
at chemaxon.struc.RgMolecule.aromatize(Unknown Source)
at chemaxon.struc.MoleculeGraph.aromatize(Unknown Source)
at marvin.MSketchListenerExample.propertyChange(MSketchListenerExample.java:118)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at java.awt.Component.firePropertyChange(Component.java:7172)
at chemaxon.marvin.beans.MarvinPane.propertyChange(Unknown Source)
at chemaxon.marvin.beans.MSketchPane.propertyChange(Unknown Source)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:333)
at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:270)
at chemaxon.marvin.sketch.swing.SketchCanvas.callback(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.historize(Unknown Source)
at chemaxon.marvin.sketch.modules.LineSM.buttonUp(Unknown Source)
at chemaxon.marvin.sketch.modules.ArrowSM$Reaction.buttonUp(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.command0(Unknown Source)
at chemaxon.marvin.sketch.MolEditor.command(Unknown Source)
at chemaxon.marvin.sketch.swing.SketchCanvas.mouseReleased(Unknown Source)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.AWTEventMulticaster.mouseReleased(AWTEventMulticaster.java:231)
at java.awt.Component.processMouseEvent(Component.java:5501)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3135)
at java.awt.Component.processEvent(Component.java:5266)
at java.awt.Container.processEvent(Container.java:1966)
at java.awt.Component.dispatchEventImpl(Component.java:3968)
at java.awt.Container.dispatchEventImpl(Container.java:2024)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
at java.awt.Container.dispatchEventImpl(Container.java:2010)
at java.awt.Window.dispatchEventImpl(Window.java:1778)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
If I open the file from Marvin Sketch File > Open, this does not happen.
What am I doing wrong? Is there a way around the problem?
I have been tring to use the method "isReactionErrorVisible()" in MSketchPane, but there nearly always seems to be a Reaction error highlighted even when the Reaction is correct and can succesfully be used for Library Enumeration. What is it checking for exactly?
Regards
Catherine