From 2cf4301b4fae392b6d904457974092f3634902c0 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Thu, 10 Jul 2014 17:51:53 +0000 Subject: 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 --- .../apache/fop/render/ps/svg/PSSVGGraphics2D.java | 31 +++++++++++----------- src/java/org/apache/fop/svg/PDFGraphics2D.java | 25 ++++++++--------- 2 files changed, 26 insertions(+), 30 deletions(-) (limited to 'src') 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 matrix = createGradientTransform(gp); - List theCoords = new java.util.ArrayList(); - 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 coords = new java.util.ArrayList(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 colors = createGradientColors(gp); List 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 colors = createGradientColors(gp); List 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 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 matrix = createGradientTransform(gp); - Point2D p1 = gp.getStartPoint(); - Point2D p2 = gp.getEndPoint(); - List theCoords = new java.util.ArrayList(); - 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 coords = new java.util.ArrayList(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 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 theCoords = new java.util.ArrayList(); 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; } -- cgit v1.2.3