get the selected atoms from MSketchPane

ChemAxon 7c2d26e5cf

04-06-2004 17:00:43

See the below example to get selected atoms from MSketchPane.


Code:



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


            }


        }


    }


User c23c5e9da4

20-01-2006 18:49:26

Is a property changed event fired when an atom is selected? If not can that be added?

ChemAxon 7c2d26e5cf

20-01-2006 22:51:39

In the current Marvin, there is not any property change event for atom selection but


we will implement it soon.

User c23c5e9da4

03-03-2007 20:28:18

has the property event been added yet when the atom selection changes?

ChemAxon 7c2d26e5cf

05-03-2007 11:28:22

Not yet. How urgent is this for you?

User c23c5e9da4

05-03-2007 17:12:20

Somewhat urgent - we have been putting off some development which depends on this for quite a while.

ChemAxon 7c2d26e5cf

05-03-2007 17:28:14

OK, I 've set the priority of this task to "high". Thus, it will be implemented really soon.

User c23c5e9da4

06-08-2007 17:21:48

The property selectionChanged is now being fired but it seems to be fired before the atoms themselves are updated so there is no way within a propertyListener to determine the 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");


}


}


}





doesn't print out anything within a sketchPane.addPropertyChangeListener("selectionChanged", new PropertyChangeListener()





block

ChemAxon 7c2d26e5cf

08-08-2007 15:00:12

Thanks for the bug report. We will fix it.

User 870ab5b546

08-02-2008 18:55:32

Is it possible to select one or more atoms in a Molecule in the API, deliver the Molecule to the applet, and display the structure with the atoms selected?

ChemAxon 7c2d26e5cf

13-02-2008 13:06:14

No, you can not do it.


Although there is a selection flag in MolAtom, you can not pass neither the MolAtom nor Molecule object to the applet.


JavaScript does not support complex Java objects. Via JavaScript you can pass only simple data types (like String, integer, boolean etc.) to an applet.





Why do you need selection? If you would like just highlight a few atoms or bonds, you can do it by setting colors for the proper atoms/bonds. MRV can store these info.


Please see the documentation of Marvin Documents format.


When you edit the structure in MarvinSketch, you can define color for any atom/bond by the Edit/Formats... menu.

User 870ab5b546

13-02-2008 13:46:32

On the Web page where users can set a dihedral angle or rotate about a bond, I've now made it possible for the user to select the bond about which he wants to rotate, rather than writing the atom numbers of the atoms making up the bond. The problem is, after we do the rotation, we would like to display the result with the originally selected bond still selected, so that the user can again press the button to rotate some more about the bond without having to reselect the bond.





Yes, there are various workarounds we could employ, but none are as desirable as merely displaying a structure with the atoms/bonds already selected.





The MRV standard could be extended to include atom-selection data.

ChemAxon 7c2d26e5cf

15-02-2008 15:09:33

OK, we will consider your request.

ChemAxon f052bdfe3c

02-01-2014 13:07:23

The feature that selection can be saved in MRV was developed in 5.8. I am closing this topic.


Efi