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 vh...@apache.org on 2014/07/10 19:44:41 UTC

svn commit: r1609522 - /xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java

Author: vhennebert
Date: Thu Jul 10 17:44:40 2014
New Revision: 1609522

URL: http://svn.apache.org/r1609522
Log:
Factorized creation of gradient transform

Modified:
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java?rev=1609522&r1=1609521&r2=1609522&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java Thu Jul 10 17:44:40 2014
@@ -102,16 +102,7 @@ public class PSSVGGraphics2D extends PSG
             return;
         }
 
-        AffineTransform transform = new AffineTransform(getBaseTransform());
-        transform.concatenate(getTransform());
-        transform.concatenate(gp.getTransform());
-
-        List<Double> theMatrix = new ArrayList<Double>();
-        double [] mat = new double[6];
-        transform.getMatrix(mat);
-        for (int idx = 0; idx < mat.length; idx++) {
-            theMatrix.add(Double.valueOf(mat[idx]));
-        }
+        List<Double> matrix = createGradientTransform(gp);
 
         List<Double> theCoords = new java.util.ArrayList<Double>();
         theCoords.add(gp.getStartPoint().getX());
@@ -146,30 +137,19 @@ public class PSSVGGraphics2D extends PSG
 
         PSGradientFactory gradientFactory = new PSGradientFactory();
         PSPattern myPattern = gradientFactory.createGradient(false, colSpace,
-                someColors, theBounds, theCoords, theMatrix);
+                someColors, theBounds, theCoords, matrix);
 
         gen.write(myPattern.toString());
 
     }
 
-
-
     private void handleRadialGradient(RadialGradientPaint gp, PSGenerator gen) throws IOException {
         MultipleGradientPaint.CycleMethodEnum cycle = gp.getCycleMethod();
         if (cycle != MultipleGradientPaint.NO_CYCLE) {
             return;
         }
 
-        AffineTransform transform = new AffineTransform(getBaseTransform());
-        transform.concatenate(getTransform());
-        transform.concatenate(gp.getTransform());
-
-        List<Double> theMatrix = new ArrayList<Double>();
-        double [] mat = new double[6];
-        transform.getMatrix(mat);
-        for (int idx = 0; idx < mat.length; idx++) {
-            theMatrix.add(Double.valueOf(mat[idx]));
-        }
+        List<Double> matrix = createGradientTransform(gp);
 
         double ar = gp.getRadius();
         Point2D ac = gp.getCenterPoint();
@@ -219,11 +199,24 @@ public class PSSVGGraphics2D extends PSG
 
         PSGradientFactory gradientFactory = new PSGradientFactory();
         PSPattern myPattern = gradientFactory.createGradient(true, colSpace,
-                someColors, theBounds, theCoords, theMatrix);
+                someColors, theBounds, theCoords, matrix);
 
         gen.write(myPattern.toString());
     }
 
+    private List<Double> createGradientTransform(MultipleGradientPaint gradient) {
+        AffineTransform transform = new AffineTransform(getBaseTransform());
+        transform.concatenate(getTransform());
+        transform.concatenate(gradient.getTransform());
+        List<Double> matrix = new ArrayList<Double>(6);
+        double[] m = new double[6];
+        transform.getMatrix(m);
+        for (double d : m) {
+            matrix.add(Double.valueOf(d));
+        }
+        return matrix;
+    }
+
     private AffineTransform applyTransform(AffineTransform base, double posX, double posY) {
         AffineTransform result = AffineTransform.getTranslateInstance(posX, posY);
         AffineTransform orig = base;



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