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:34:28 UTC
svn commit: r1609515 -
/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
Author: vhennebert
Date: Thu Jul 10 17:34:27 2014
New Revision: 1609515
URL: http://svn.apache.org/r1609515
Log:
Factorized creation of gradient transform
Modified:
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1609515&r1=1609514&r2=1609515&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java Thu Jul 10 17:34:27 2014
@@ -844,19 +844,7 @@ public class PDFGraphics2D extends Abstr
return false;
}
- // Build proper transform from gradient space to page space
- // ('Patterns' don't get userspace transform).
- AffineTransform transform;
- transform = new AffineTransform(getBaseTransform());
- transform.concatenate(getTransform());
- transform.concatenate(gp.getTransform());
-
- List<Double> theMatrix = new java.util.ArrayList<Double>();
- double [] mat = new double[6];
- transform.getMatrix(mat);
- for (int idx = 0; idx < mat.length; idx++) {
- theMatrix.add(new Double(mat[idx]));
- }
+ List<Double> matrix = createGradientTransform(gp);
Point2D p1 = gp.getStartPoint();
Point2D p2 = gp.getEndPoint();
@@ -909,7 +897,7 @@ public class PDFGraphics2D extends Abstr
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
PDFPattern myPat = gradientFactory.createGradient(false, colSpace, someColors, theBounds,
- theCoords, theMatrix);
+ theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill));
return true;
@@ -930,19 +918,7 @@ public class PDFGraphics2D extends Abstr
return false;
}
- // Build proper transform from gradient space to page space
- // ('Patterns' don't get userspace transform).
- AffineTransform transform;
- transform = new AffineTransform(getBaseTransform());
- transform.concatenate(getTransform());
- transform.concatenate(gp.getTransform());
-
- List<Double> theMatrix = new java.util.ArrayList<Double>();
- double [] mat = new double[6];
- transform.getMatrix(mat);
- for (int idx = 0; idx < mat.length; idx++) {
- theMatrix.add(new Double(mat[idx]));
- }
+ List<Double> matrix = createGradientTransform(gp);
double ar = gp.getRadius();
Point2D ac = gp.getCenterPoint();
@@ -996,12 +972,27 @@ public class PDFGraphics2D extends Abstr
PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
PDFGradientFactory gradientFactory = new PDFGradientFactory(this);
PDFPattern myPat = gradientFactory.createGradient(true, colSpace, someColors, theBounds,
- theCoords, theMatrix);
+ theCoords, matrix);
currentStream.write(myPat.getColorSpaceOut(fill));
return true;
}
+ private List<Double> createGradientTransform(MultipleGradientPaint gp) {
+ // Build proper transform from gradient space to page space
+ // ('Patterns' don't get userspace transform).
+ AffineTransform transform = new AffineTransform(getBaseTransform());
+ transform.concatenate(getTransform());
+ transform.concatenate(gp.getTransform());
+ List<Double> matrix = new java.util.ArrayList<Double>(6);
+ double[] m = new double[6];
+ transform.getMatrix(m);
+ for (double d : m) {
+ matrix.add(Double.valueOf(d));
+ }
+ return matrix;
+ }
+
private boolean createPattern(PatternPaint pp, boolean fill) {
preparePainting();
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org