MDocument draw() feature request

User c23c5e9da4

26-01-2007 00:33:52

Can you add a





public void draw(java.awt.Graphics g, java.lang.String opts)





method to MDocument like you have in Molecule? We rely on this feature and would like to be able to take advantage of the features of documents.





Trevor

ChemAxon 7c2d26e5cf

26-01-2007 22:58:36

Hi Trevor,


We do not plan to implement MDocument.draw(java.awt.Graphics g, java.lang.String opts).


To draw the document on a graphics, we recommend the following way:


Code:
int x, y


Graphics g;


MDocument doc;


...


Image img = (Image)doc.exportToObject("image:w"+Integer.toString(Math.round(d.width))+


                    ",h"+Integer.toString(Math.round(d.height)));


g.drawImage(img, x,y,null);



(You can also use Molecule.toObject(String) by the same way.)


Is this solution suitable for you?

User c23c5e9da4

12-02-2007 05:11:13

No - Using images does not preserve the information we need. This is an important issue for us.

User f359e526a1

12-02-2007 14:24:36

Hi, we are quite reluctant to make an MDocument.draw() as MDocument is about storing object and not about drawing. We are happy to deprecate Molecule.draw() as well since were not happy to include that either ;) But seriously: could you please send a more elaborate example why you need this method?

User c23c5e9da4

12-02-2007 15:56:57

We are using iText to generate pdfs - when using Molecule.draw to insert a molecule in the pdf the molecules come out clear with the atom labels identified as text. When using the Image method suggested earlier the molecule in the resulting pdf is fuzzy and the atom labels are not text.

ChemAxon 7c2d26e5cf

12-02-2007 20:42:03

Have you tried to insert SVG into PDF? Marvin can export scalable vector graphics like SVG.


Would it be a suitable solution for you?


If not, we are considering how to provide a painting method for you to draw the MDocument to the specified graphics.

User c23c5e9da4

12-02-2007 22:25:51

I tried using SVG as an intermediate but the result looks different than it does in Marvin.

ChemAxon 7c2d26e5cf

13-02-2007 15:19:04

We will implement a draw(Graphics g,MDocument doc,String opts) method. Instead of the MDocument, we will place it into a new utility class.

ChemAxon 7c2d26e5cf

13-02-2007 23:23:38

I have implemented draw(Molecule,Graphics,String) and draw(MDocument,Graphics,String) methods in chemaxon.marvin.util.MPainterUtil class. It will be available in next release (4.1.6).


Since Marvin 4.1.6, Molecule.draw(Graphics,String) is deprecated. Instead of that, chemaxon.marvin.util.MolPainterUtil.draw(Molecule,Graphics,String) should be used.

User c23c5e9da4

14-02-2007 16:04:03

Great! Thank you very much.





Trevor