diff options
author | Vincent Hennebert <vhennebert@apache.org> | 2014-07-10 17:51:53 +0000 |
---|---|---|
committer | Vincent Hennebert <vhennebert@apache.org> | 2014-07-10 17:51:53 +0000 |
commit | 2cf4301b4fae392b6d904457974092f3634902c0 (patch) | |
tree | f86859711020f058008bda74fc6a1475088543f1 /src | |
parent | b1e0d1b19f5bd04f2cdb5715bc04506b34a8183b (diff) | |
download | xmlgraphics-fop-2cf4301b4fae392b6d904457974092f3634902c0.tar.gz xmlgraphics-fop-2cf4301b4fae392b6d904457974092f3634902c0.zip |
Small adjustments to make duplication in PDF and PostScript gradients more apparent
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609526 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java | 31 | ||||
-rw-r--r-- | src/java/org/apache/fop/svg/PDFGraphics2D.java | 25 |
2 files changed, 26 insertions, 30 deletions
diff --git a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java index abfbdd859..12a482c94 100644 --- a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java @@ -104,24 +104,24 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { List<Double> matrix = createGradientTransform(gp); - List<Double> theCoords = new java.util.ArrayList<Double>(); - theCoords.add(gp.getStartPoint().getX()); - theCoords.add(gp.getStartPoint().getX()); - theCoords.add(gp.getEndPoint().getX()); - theCoords.add(gp.getEndPoint().getY()); + Point2D startPoint = gp.getStartPoint(); + Point2D endPoint = gp.getEndPoint(); + List<Double> coords = new java.util.ArrayList<Double>(4); + coords.add(new Double(startPoint.getX())); + coords.add(new Double(startPoint.getY())); + coords.add(new Double(endPoint.getX())); + coords.add(new Double(endPoint.getY())); List<Color> colors = createGradientColors(gp); List<Double> bounds = createGradientBounds(gp); - PDFDeviceColorSpace colSpace; - colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); + //Gradients are currently restricted to sRGB + PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PSGradientFactory gradientFactory = new PSGradientFactory(); - PSPattern myPattern = gradientFactory.createGradient(false, colSpace, - colors, bounds, theCoords, matrix); - - gen.write(myPattern.toString()); + PSPattern pattern = gradientFactory.createGradient(false, colSpace, colors, bounds, coords, matrix); + gen.write(pattern.toString()); } private void handleRadialGradient(RadialGradientPaint gp, PSGenerator gen) throws IOException { @@ -157,14 +157,13 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { List<Color> colors = createGradientColors(gp); List<Double> bounds = createGradientBounds(gp); - PDFDeviceColorSpace colSpace; - colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); + //Gradients are currently restricted to sRGB + PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PSGradientFactory gradientFactory = new PSGradientFactory(); - PSPattern myPattern = gradientFactory.createGradient(true, colSpace, - colors, bounds, theCoords, matrix); + PSPattern pattern = gradientFactory.createGradient(true, colSpace, colors, bounds, theCoords, matrix); - gen.write(myPattern.toString()); + gen.write(pattern.toString()); } private List<Double> createGradientTransform(MultipleGradientPaint gradient) { diff --git a/src/java/org/apache/fop/svg/PDFGraphics2D.java b/src/java/org/apache/fop/svg/PDFGraphics2D.java index a373178d0..d3c72f76e 100644 --- a/src/java/org/apache/fop/svg/PDFGraphics2D.java +++ b/src/java/org/apache/fop/svg/PDFGraphics2D.java @@ -856,13 +856,13 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand List<Double> matrix = createGradientTransform(gp); - Point2D p1 = gp.getStartPoint(); - Point2D p2 = gp.getEndPoint(); - List<Double> theCoords = new java.util.ArrayList<Double>(); - theCoords.add(new Double(p1.getX())); - theCoords.add(new Double(p1.getY())); - theCoords.add(new Double(p2.getX())); - theCoords.add(new Double(p2.getY())); + Point2D startPoint = gp.getStartPoint(); + Point2D endPoint = gp.getEndPoint(); + List<Double> coords = new java.util.ArrayList<Double>(4); + coords.add(new Double(startPoint.getX())); + coords.add(new Double(startPoint.getY())); + coords.add(new Double(endPoint.getX())); + coords.add(new Double(endPoint.getY())); List<Color> colors = createGradientColors(gp); @@ -871,10 +871,9 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand //Gradients are currently restricted to sRGB PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PDFGradientFactory gradientFactory = new PDFGradientFactory(this); - PDFPattern myPat = gradientFactory.createGradient(false, colSpace, colors, bounds, - theCoords, matrix); - currentStream.write(myPat.getColorSpaceOut(fill)); + PDFPattern pattern = gradientFactory.createGradient(false, colSpace, colors, bounds, coords, matrix); + currentStream.write(pattern.getColorSpaceOut(fill)); return true; } @@ -898,7 +897,6 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand double ar = gp.getRadius(); Point2D ac = gp.getCenterPoint(); Point2D af = gp.getFocusPoint(); - List<Double> theCoords = new java.util.ArrayList<Double>(); double dx = af.getX() - ac.getX(); double dy = af.getY() - ac.getY(); @@ -925,10 +923,9 @@ public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHand //Gradients are currently restricted to sRGB PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB); PDFGradientFactory gradientFactory = new PDFGradientFactory(this); - PDFPattern myPat = gradientFactory.createGradient(true, colSpace, colors, bounds, - theCoords, matrix); - currentStream.write(myPat.getColorSpaceOut(fill)); + PDFPattern pattern = gradientFactory.createGradient(true, colSpace, colors, bounds, theCoords, matrix); + currentStream.write(pattern.getColorSpaceOut(fill)); return true; } |