Bringing up Marvin Sketch with selection mode preselected

User 6e867c1849

07-02-2005 21:29:47

Hello,


We are planning to use Marvin Sketch / View as a tool for entering structures for our Physical / Chemical properties calculator SPARC. I know how to use Marvin to get SMILES of drawn structures. I am interested in using Marvin as a interface to get the user to select a ionization site in a molecule. I kinda figured out how to do all this except bring marvin sketch preselected in selection mode instead of draw mode. It would be very helpful if someone can point me in the right direction. Can I do this single atom selection using Marvin View or is Marvin Sketch necessary.


Thank You


-Raj

ChemAxon 7c2d26e5cf

08-02-2005 15:33:16

It's not clear for me what do you use (applets or beans)?


Do you want to get the selected atoms?

User 6e867c1849

08-02-2005 16:53:45

I am using marvin beans for displaying the molecule. What I really need is to programatically make Marvin Sketch go into select mode (as if I clicked on the select button in the tool bar) as by default marvin comes up in draw mode.

ChemAxon 7c2d26e5cf

09-02-2005 14:01:06

Programatically, you can not invoke Selection button pushing event but you can select atoms in the structure on the canvas.


Code:
Molecule mol = sketchPane.getMol();


if(mol != null) {


    MolAtom atom = mol.getAtom(0);


    atom.setSelected(true);


    sketchPane.setMol(mol);


}





Is it a good solution for you?

User 6e867c1849

09-02-2005 16:22:42

Hi Tamas,


Thanks for you reply. Your solution would work if I wanted to preselect the atoms. But I want to get the user to select the atoms. I am going to try to send a keyevent "Escape Key" to the SketchPane to see if I can make it come up in select mode. What key event do you guys use to process the Escape key, is it key_presses, key_released or key_types ?


It would be of great help if you can tell me the event I need to send.


Thanks


-Raj

ChemAxon 7c2d26e5cf

09-02-2005 18:14:57

In Marvin, ESCAPE key event is processed by the keyReleased method.


Try to simulate it with a KEY_RELEASED event.


I suggest to add a keylistener to the parent component of MSketchPane (which is a dialog or a frame) and check generated key events when a ESCAPE button is typed.


If you manage to simulate the same events, it may solve the problem.


SketchEventTest example in the Marvin Beans package demonstrates event handling.


If you add a new KeyListener to this frame. You can check key events.





I have checked quickly which key event are generated in SketchEvenTest:


Code:
java.awt.event.KeyEvent[KEY_PRESSED,keyCode=27,keyText=Escape,keyChar=Escape,keyLocation=KEY_LOCATION_STANDARD] on frame0


java.awt.event.KeyEvent[KEY_TYPED,keyCode=0,keyText=Unknown keyCode: 0x0,keyChar=Escape,keyLocation=KEY_LOCATION_UNKNOWN] on frame0


java.awt.event.KeyEvent[KEY_RELEASED,keyCode=27,keyText=Escape,keyChar=Escape,keyLocation=KEY_LOCATION_STANDARD] on frame0


User 6e867c1849

09-02-2005 19:20:46

Thanks a lot Tamas, I managed to generate a key released event and that did exactly what I wanted it to do.


Thanks


-Raj