From 47b6aab658b32a63bce57d230ea13d3c2d155401 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Thu, 10 Jul 2014 17:40:50 +0000 Subject: [PATCH] Small adjustments to make duplication in linear and radial gradients more apparent git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/FOP-2393_gradient-rendering@1609521 13f79535-47bb-0310-9956-ffa450edef68 --- .../fop/render/ps/svg/PSSVGGraphics2D.java | 67 +++++++------------ 1 file changed, 25 insertions(+), 42 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 7bb230323..87e9e384f 100644 --- a/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java +++ b/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java @@ -96,47 +96,44 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { } } - private void handleLinearGradient(LinearGradientPaint lgp, PSGenerator gen) throws IOException { - MultipleGradientPaint.CycleMethodEnum cycle = lgp.getCycleMethod(); + private void handleLinearGradient(LinearGradientPaint gp, PSGenerator gen) throws IOException { + MultipleGradientPaint.CycleMethodEnum cycle = gp.getCycleMethod(); if (cycle != MultipleGradientPaint.NO_CYCLE) { return; } - float[] fractions = lgp.getFractions(); - Color[] cols = lgp.getColors(); AffineTransform transform = new AffineTransform(getBaseTransform()); transform.concatenate(getTransform()); - transform.concatenate(lgp.getTransform()); + transform.concatenate(gp.getTransform()); - List theMatrix = new ArrayList(); + List theMatrix = new ArrayList(); double [] mat = new double[6]; transform.getMatrix(mat); for (int idx = 0; idx < mat.length; idx++) { theMatrix.add(Double.valueOf(mat[idx])); } - List theCoords = new java.util.ArrayList(); - theCoords.add(lgp.getStartPoint().getX()); - theCoords.add(lgp.getStartPoint().getX()); - theCoords.add(lgp.getEndPoint().getX()); - theCoords.add(lgp.getEndPoint().getY()); + theCoords.add(gp.getStartPoint().getX()); + theCoords.add(gp.getStartPoint().getX()); + theCoords.add(gp.getEndPoint().getX()); + theCoords.add(gp.getEndPoint().getY()); + Color[] cols = gp.getColors(); List someColors = new java.util.ArrayList(); + float[] fractions = gp.getFractions(); if (fractions[0] > 0f) { someColors.add(cols[0]); } for (int count = 0; count < cols.length; count++) { - Color c1 = cols[count]; - if (c1.getAlpha() != 255) { - LOG.warn("Opacity is not currently supported for Postscript output"); - } - someColors.add(c1); + Color c = cols[count]; + someColors.add(c); } if (fractions[fractions.length - 1] < 1f) { someColors.add(cols[cols.length - 1]); } + List theBounds = new java.util.ArrayList(); for (int count = 0; count < fractions.length; count++) { float offset = fractions[count]; @@ -157,34 +154,26 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { - private void handleRadialGradient(RadialGradientPaint rgp, PSGenerator gen) throws IOException { - MultipleGradientPaint.CycleMethodEnum cycle = rgp.getCycleMethod(); + private void handleRadialGradient(RadialGradientPaint gp, PSGenerator gen) throws IOException { + MultipleGradientPaint.CycleMethodEnum cycle = gp.getCycleMethod(); if (cycle != MultipleGradientPaint.NO_CYCLE) { return; } - AffineTransform transform; - transform = new AffineTransform(getBaseTransform()); + AffineTransform transform = new AffineTransform(getBaseTransform()); transform.concatenate(getTransform()); - transform.concatenate(rgp.getTransform()); + transform.concatenate(gp.getTransform()); - AffineTransform resultCentre = applyTransform(rgp.getTransform(), - rgp.getCenterPoint().getX(), rgp.getCenterPoint().getY()); - AffineTransform resultFocus = applyTransform(rgp.getTransform(), - rgp.getFocusPoint().getX(), rgp.getFocusPoint().getY()); - - List theMatrix = new java.util.ArrayList(); + List theMatrix = new ArrayList(); double [] mat = new double[6]; transform.getMatrix(mat); for (int idx = 0; idx < mat.length; idx++) { theMatrix.add(Double.valueOf(mat[idx])); } - float[] fractions = rgp.getFractions(); - - double ar = rgp.getRadius(); - Point2D ac = rgp.getCenterPoint(); - Point2D af = rgp.getFocusPoint(); + 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(); @@ -204,21 +193,15 @@ public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar { theCoords.add(new Double(ac.getY())); theCoords.add(new Double(ar)); - Color[] cols = rgp.getColors(); + Color[] cols = gp.getColors(); List someColors = new java.util.ArrayList(); + float[] fractions = gp.getFractions(); if (fractions[0] > 0f) { someColors.add(cols[0]); } for (int count = 0; count < cols.length; count++) { - Color cc = cols[count]; - if (cc.getAlpha() != 255) { - /* This should never happen because radial gradients with opacity should now - * be rasterized in the PSImageHandlerSVG class. Please see the shouldRaster() - * method for more information. */ - LOG.warn("Opacity is not currently supported for Postscript output"); - } - - someColors.add(cc); + Color c = cols[count]; + someColors.add(c); } if (fractions[fractions.length - 1] < 1f) { someColors.add(cols[cols.length - 1]); -- 2.39.5