Community
Participate
Working Groups
Created attachment 127021 [details] proposed patch 1. Create a geoshape diagram 2. Create a note on it 3. Save diagram as either JPEG or PNG, or SVG, or PDF. 4. Operation fails with exception from GraphicstoGraphics2DAdapter that #fillPath(Path) method is not implemented. NoteFigure uses SWT Path to paint itself (gradient is supported for Path) P.S. Alex Fitzpatrick was about to raise a bug on that.
Created attachment 127028 [details] JUnit support for painting Path with Graphics2D JUnit addition that adds a note to the diagram beside the circuit. The diagram is exported to images of various formats.
Created attachment 127031 [details] final patch Final patch for code review. Cleaned up and merged with JUnit support.
I verify that this patch fixes the failure in GMF that I observed.
Marc, could you code review this patch please?
Just two things, otherwise looks good. 1. On the last line of drawPath(), path2D isn't used (compiler misses it because of the path2D.transform() call), so it's missing the transform. 2. I'd factor out these lines from fillPath and drawPath Path2D path2D = createPathAWT(path); AffineTransform transform = new AffineTransform(); transform.translate(transX, transY); path2D.transform(transform); and roll them into createPathAWT(), making drawPath for example into just 3 lines: checkState(); getGraphics2D().setPaint(getColor(swtGraphics.getForegroundColor())); getGraphics2D().draw(createPathAWT(path));
Sounds good - I'll do that.
Corrected as Marc suggested (Thanks, Marc!) Committed the fix for 2.2
Nice work... I guess that's another lunch I owe you.
Need to use GeneralPath instead of Path2D.Float, because Path2D is introduced in Java 6.
Hi Alex, it also needs to implement setFillRule(), can be tested with GeoShapeCylinderFigure. It is also used when gradient is applied.
Ok, will add that too. Thanks, Lidija.
Regarding the setFillRule()... is that something obvious about Cylinder figure that I should notice when export it to image? Or perhaps gradient etc should be set on it to notice the problem? I just need to know what is the problem with the cylinder, so I can test the fix...
It is the same use case you described when raising this defect. Just add cylinder on a diagram. Or add any other geoshape or note and apply gradient. Then, do File->Save As Image, PNG.
Created attachment 127587 [details] patch to fix #setFillRule(int) Proposed patch to implement #setFillRule(int) 1. Use GeneralPath supported in Java 5 instead of Java 6 Path2D.Float 2. Implementation of #setFillRule(int), #getFillRule() is essentially ported from SWTGraphics in draw2D. The fill rule cannot be set on Graphics2D, but instead it can be set on GeneralPath, so I set it from the applied state. 3. #setClip(Path) fixes... before I had no idea when this gets called, because with plain GMF examples gradient cannot be set. 4. Clean up for the creation of the AWT path. Can translate points during conversion. Lidija, am I missing anything now? Anything else we're missing in GraphicstoGraphics2DAdapter? If everything looks in order, could you code review the patch please? Yhanks in advance.
Created attachment 127612 [details] JUnit support for Cylinder with gradient Added cylinder with gradient on the diagram that is used in image export JUnits
(In reply to comment #14) > Lidija, am I missing anything now? Anything else we're missing in > GraphicstoGraphics2DAdapter? If everything looks in order, could you code > review the patch please? > Yhanks in advance. Alex, we are good to commit this now, since the existing code in CVS has build errors.
I just looked at the patch, works well, don't think there is anything else.
Committed the fix + JUnit for 2.2. Anthony and Lidija hanks for the feedback on this one.
[target cleanup] 2.2 M6 was the original target milestone for this bug
[GMF Restructure] Bug 319140 : product GMF and component Runtime Diagram was the original product and component for this bug