MolPrinter question

User f5e6ccf034

26-05-2008 04:07:44

Is the former a shortcut for the latter?


Code:
new MolPrinter(mol)



Code:
new MolPrinter(new MDocument(mol))



Same question for setMol and setDoc.

ChemAxon 7c2d26e5cf

26-05-2008 11:14:19

Yes, the two methods are compatible with each others.


The setDoc method is also compatible with setMol.

User f5e6ccf034

26-05-2008 12:45:08

This is a bit confusing, though, because MDocument has a Molecule constructor and a getPrimaryMolecule() method but Molecule also has a getDocument() method. So, does a document hold a molecule or vice-versa?

User f5e6ccf034

26-05-2008 14:21:59

It looks like Molecule.getDocument() will sometimes return null. This is really confusing. I can't get a good mental picture of how this is working.


1) when is there a document?


2) if I have a MolPrinter object that was constructed with a specific


document object, to which I keep a handle around, and then I call


setMol on the printer, does that change the underlying document


and invalidate my handle?





Thanks for clarifying.-

ChemAxon 7c2d26e5cf

26-05-2008 20:44:59

Molecule class includes reference to MDocument and vice-versa.


MDocument is a more descriptive format than Molecule. It can store also graphical objects (like text box or polyline) and it is capable to preserve display settings for a structure. Of course the primary (main) molecule is also stored there. You can imagine MDocument as a container.


Of course, the "document" field of Molecule can be null. MDocument is required when there is some data that is not described by the Molecule class (like graphical objects).





The "setMol" method changes the Molecule object for MolPrinter.


The MolPrinter works with a clone of the given molecule. The MDocument property of the given molecule is not preserved in this case.


The "setDoc" method creates a copy about the given document.


Neither "setMol" nor "setDoc" preserves earlier Molecule / MDocument object inside MolPrinter.


So, if you work only with the core chemical structure, use Molecule. If additional data (like display settings or graphical objects) are also important for you, works with "setDoc".

User f5e6ccf034

26-05-2008 20:52:06

So, if you work only with the core chemical structure, use Molecule. If additional data (like display settings or graphical objects) are also important for you, works with "setDoc".





Got it. Thanks.

User f5e6ccf034

26-05-2008 20:54:10

I think I was waylaid by an analogy with Swing text widgets, in which there is always a document.

ChemAxon 7c2d26e5cf

26-05-2008 21:33:16

Yes, you can find some analogy.

User 870ab5b546

27-05-2008 12:23:04

We were also at one time confused about the relationship between a Molecule and an MDocument. It would be useful to include descriptions of the relationships between these classes (and other classes with a similar relationship, like the SgroupAtoms and SuperatomSgroups) in the API. The API shows subclasses and superclasses, but that doesn't help in the case of an MDocument and a Molecule, which are not parent and child but cousins.

ChemAxon 7c2d26e5cf

30-05-2008 08:23:53

Thanks for the feedback.


We are working on improving / completing the API documentation.