MolPrinter clipping issues

User 700a43e5ff

31-03-2015 13:00:07

Hello, I am new to Marvin and try to draw a molfile to an image.  I followed the example closely and everything is fine as long as  almost all of the image is used for printing. See the attached Java source and the the resulting image for a margin of 10.


It was my understanding, that the rect argument to  chemaxon.marvin.MolPrinter.paint defines the drawing area. The  Javadoc says "Paints the molecule into the center of the specified rectangle."


However if I use a larger margin (70px), the molecule image get clipped (See mol70.png).  It looks like exactly  those 70 pixel are missing.


Any help would be appreciated.

ChemAxon 5433b8e56b

31-03-2015 15:45:16

Hi,


for the first sight I would say you are doing it right, and something goes wrong in the background, and I was able to reproduce the issue.


Currently we are actively developing in the related area and there is a possibility that we made some changes that ruins the scale for bound calculation, or somewhere else in the painting code.


I have to check it a bit deeper, If you need an instant solution I would suggest to use an earlier version of the library until we fix the issue, or if it is not important to solve this today, then I am sure we will fix this soon.


Tomorrow I will be able to dig a bit deeper into the code, and check what could have happened, after I have more info I will get back to you.


Regards,
Istvan 

User 700a43e5ff

31-03-2015 17:02:33

Hi Istvan,  


I found the problem with  the most recent marvinbeans-15.3.23.0, but I found the same problem  with 5.2.6 from 2009. 


Regards 


Martin

ChemAxon 5433b8e56b

01-04-2015 14:13:52

Hi Martin,


I was checking the code today, and found out the cause of the problem, it seems there is an old and not recognized issue with the MolPrinter.paint(Graphics2D, Rectangle) method that translates the clipping area with the margin twice, that is why the top and left part of the sturcture is not on the resulting image.


I was able to fix it, the next version (15.4.6) will contain the fix.


In the mean time, I have modified your code and attached, with the attached code you can achieve your original intent with any version of the library, altough it is not the expected way I think.


Regards,
Istvan 

User 700a43e5ff

01-04-2015 21:13:12

Hi Istvan,


your solution was very helpful. There is one more thing missing. Restore the clip:


Shape saveClip = g.getClip();
molPrinter.paint(g, rect);
g.setClip(saveClip);

... do more drawing

Now my program is working


Best wishes


   Martin


 


 

ChemAxon 5433b8e56b

03-04-2015 10:39:32

Hi Martin,


without playing this around, I would say that the missing of the clip handling could not cause problems in your code, since this is handled in the old and the new solution also in MolPrinter.


But better to do it twice than not even once. Or the lack of these few lines have caused problems on your side, since when I had tested it, it worked properly without it, as I noticed.


Regards,
Istvan 

User 700a43e5ff

03-04-2015 16:36:52

Hi Istvan, 


your are right, it's not a problem  in the small test program, because i draw the rectangle inside the clipping area. But it some slightly more complicated stuff. However, I  did it with an ancient version of MarvinBeans (5.2,if I remember correctly). I will check, if the problem is solved in more recent versions, after Easter holidays. 

User 700a43e5ff

13-04-2015 12:20:41

I tested the clipping issue again. You are right. It is fixed in MarvinBeans 15.3.23.0. The very old 5.2 was broken.

ChemAxon d26931946c

17-04-2015 12:39:38

Hi Martin,


Thank you for the feedback,


Cheers,


Peter