You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2006/04/10 12:43:02 UTC

svn commit: r392917 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java

Author: jeremias
Date: Mon Apr 10 03:42:58 2006
New Revision: 392917

URL: http://svn.apache.org/viewcvs?rev=392917&view=rev
Log:
Bugzilla #39033:
Enancement: convert java.awt.GradientPaint to Batik's LinearGradientPaint to avoid rasterization when painting. This is useful when someone uses PDFGraphics2D outside FOP.
Submitted by: Michal Sevcenko <sevcenko.at.vc.cvut.cz>

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=392917&r1=392916&r2=392917&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/svg/PDFGraphics2D.java Mon Apr 10 03:42:58 2006
@@ -60,6 +60,7 @@
 import java.awt.GraphicsConfiguration;
 /*  java.awt.Font is not imported to avoid confusion with
     org.apache.fop.fonts.Font */
+import java.awt.GradientPaint;
 import java.awt.Image;
 import java.awt.Shape;
 import java.awt.Stroke;
@@ -852,12 +853,25 @@
      *
      * @param paint the paint to convert to PDF
      * @param fill true if the paint should be set for filling
+     * @return true if the paint is handled natively, false if the paint should be rasterized
      */
     protected boolean applyPaint(Paint paint, boolean fill) {
         preparePainting();
 
         if (paint instanceof Color) {
             return true;
+        }
+        // convert java.awt.GradientPaint to LinearGradientPaint to avoid rasterization
+        if (paint instanceof GradientPaint) {
+            GradientPaint gpaint = (GradientPaint) paint;
+            paint = new LinearGradientPaint(
+                    (float) gpaint.getPoint1().getX(),
+                    (float) gpaint.getPoint1().getY(),
+                    (float) gpaint.getPoint2().getX(),
+                    (float) gpaint.getPoint2().getY(), 
+                    new float[] {0, 1}, 
+                    new Color[] {gpaint.getColor1(), gpaint.getColor2()},
+                    gpaint.isCyclic() ? LinearGradientPaint.REPEAT : LinearGradientPaint.NO_CYCLE);
         }
         if (paint instanceof LinearGradientPaint) {
             LinearGradientPaint gp = (LinearGradientPaint)paint;



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org