Browse Source

Factorized creation of gradient transform


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609515 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Vincent Hennebert 9 years ago
parent
commit
291a0f7840
1 changed files with 19 additions and 28 deletions
  1. 19
    28
      src/java/org/apache/fop/svg/PDFGraphics2D.java

+ 19
- 28
src/java/org/apache/fop/svg/PDFGraphics2D.java View File

@@ -844,19 +844,7 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand
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 AbstractGraphics2D implements NativeImageHand
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 AbstractGraphics2D implements NativeImageHand
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 AbstractGraphics2D implements NativeImageHand
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();


Loading…
Cancel
Save