MViewPane.getM() returns new molecules?

User 7a902f260f

09-11-2013 13:31:54

Hello,


The following is returning false with JChem 6.1.  Is this by design?  mvPane here is an instance of MViewPane.


mvPane.getM(0).equals(mvPane.getM(0))

Doing mvPane.getM(0, "cxsmiles") twice returns the same String as expected.  Previously, we were relying on the fact that mvPane.getM(0) returns the same molecule reference, and we were storing application specific properties in the instance.  With this change, that functionality is gone.  


 

ChemAxon 2c555f5717

12-11-2013 16:08:42

Dear Kongar!


   MViewPane.getM(int) ,method only returns the clone of the visualized molecule to protect inner state. (If you have to compare two molecules you can find suitabel methods in the JChem API. equals() and == will not be very useful.) If you update any molecules you can set it back to MViewPane (with setM(int, Molecule...) method). Be ware it will store a cloned molecule as well.


Regards:
Balázs