Browse Source

Factorized creation of gradient transform


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609522 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-2_0
Vincent Hennebert 9 years ago
parent
commit
73b9837624
1 changed files with 17 additions and 24 deletions
  1. 17
    24
      src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java

+ 17
- 24
src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java View File

@@ -102,16 +102,7 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
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 PSGraphics2D implements GradientRegistrar {

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 PSGraphics2D implements GradientRegistrar {

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;

Loading…
Cancel
Save