getMol method of MSketchPane is not working properly.

User a8852677c2

27-12-2010 09:19:04

Hi,


I am opening MSketchPane in JFrame. Then Go To "File" menu of MSketchPane and click on "Open" menu Item.


And Then select chemical  "abc.mrv" . (for example abc.mrv  you can select any molecule and open in MSketchPane ).


Now you will see abc chemical name in MSketchPane. Till now everyting is Ok. Now change the structure of  "abc" by adding  bond , ehtane or methane. Means now on canvas name of the chemical is "ChangeAbc" not "abc".


you can see chemical name using "IUPAC name" menu Item of "Insert " Menu.


Now I am calling ok button on JFrame. In that ok buttion action I have wriiten code to get the chemical name


from MSketchPane. code is Molecule sketchMol = sketchPane.getMol();


Now I should get "ChangeAbc" chemical name If I call sketchMol.getName(). But I am getting previous name "abc".


Please  let us know What is the probelm.


Regards


Yogesh Dhawale

ChemAxon e7b9408ca1

27-12-2010 09:36:14

Dear Yogesh,


When you call mol.getName(), what you get is a constant String, which was set using mol.setName(String). It could be anything. I think in your case it was set in the mrv file (or maybe it is derived from the filename?).


If you want to compute the IUPAC name based on the actual structure, you can call mol.toFormat("name"). This is the name that is displayed on the canvas. Also, mol.toFormat("name:t") will return the traditional name, when applicable.


Is this satisfactory?


Regards,


Daniel

User a8852677c2

27-12-2010 12:34:40










Daniel Bonniot wrote:

Dear Yogesh,


When you call mol.getName(), what you get is a constant String, which was set using mol.setName(String). It could be anything. I think in your case it was set in the mrv file (or maybe it is derived from the filename?).


If you want to compute the IUPAC name based on the actual structure, you can call mol.toFormat("name"). This is the name that is displayed on the canvas. Also, mol.toFormat("name:t") will return the traditional name, when applicable.


Is this satisfactory?


Regards,


Daniel



Hi, Daniel


Thanks I have solved my problem using mol.toFormat("name").


Thank you very much.


Thanks & Regards


Yogesh Dhawale