You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2014/07/10 20:00:59 UTC

svn commit: r1609532 - in /xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop: render/ps/svg/ render/shading/ svg/

Author: vhennebert
Date: Thu Jul 10 18:00:58 2014
New Revision: 1609532

URL: http://svn.apache.org/r1609532
Log:
Removed createGradient abstract method, that was not having any specific implementation in sub-classes
Removed unnecessary GradientRegistrar interface

Removed:
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientRegistrar.java
Modified:
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientFactory.java
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PDFGradientFactory.java
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PSGradientFactory.java
    xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java?rev=1609532&r1=1609531&r2=1609532&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSSVGGraphics2D.java Thu Jul 10 18:00:58 2014
@@ -33,14 +33,11 @@ import org.apache.batik.ext.awt.RadialGr
 import org.apache.xmlgraphics.java2d.ps.PSGraphics2D;
 import org.apache.xmlgraphics.ps.PSGenerator;
 
-import org.apache.fop.render.shading.Function;
-import org.apache.fop.render.shading.GradientRegistrar;
 import org.apache.fop.render.shading.PSGradientFactory;
 import org.apache.fop.render.shading.Pattern;
-import org.apache.fop.render.shading.Shading;
 
 
-public class PSSVGGraphics2D extends PSGraphics2D implements GradientRegistrar {
+public class PSSVGGraphics2D extends PSGraphics2D {
 
     private static final Log LOG = LogFactory.getLog(PSSVGGraphics2D.class);
 
@@ -109,36 +106,4 @@ public class PSSVGGraphics2D extends PSG
         return new PSSVGGraphics2D(this);
     }
 
-    /**
-     * Registers a function object against the output format document
-     * @param function The function object to register
-     * @return Returns either the function which has already been registered
-     * or the current new registered object.
-     */
-    public Function registerFunction(Function function) {
-        //Objects aren't needed to be registered in Postscript
-        return function;
-    }
-
-    /**
-     * Registers a shading object against the otuput format document
-     * @param shading The shading object to register
-     * @return Returs either the shading which has already been registered
-     * or the current new registered object
-     */
-    public Shading registerShading(Shading shading) {
-        //Objects aren't needed to be registered in Postscript
-        return shading;
-    }
-
-    /**
-     * Registers a pattern object against the output format document
-     * @param pattern The pattern object to register
-     * @return Returns either the pattern which has already been registered
-     * or the current new registered object
-     */
-    public Pattern registerPattern(Pattern pattern) {
-        // TODO Auto-generated method stub
-        return pattern;
-    }
 }

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientFactory.java?rev=1609532&r1=1609531&r2=1609532&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientFactory.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/GradientFactory.java Thu Jul 10 18:00:58 2014
@@ -79,7 +79,7 @@ public abstract class GradientFactory<P 
         List<Double> bounds = createBounds(gradient);
         //Gradients are currently restricted to sRGB
         PDFDeviceColorSpace colSpace = new PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
-        return createGradient(gradient instanceof RadialGradientPaint, colSpace, colors, bounds, coords, matrix);
+        return makeGradient(gradient instanceof RadialGradientPaint, colSpace, colors, bounds, coords, matrix);
     }
 
     private List<Double> createTransform(MultipleGradientPaint gradient,
@@ -134,11 +134,7 @@ public abstract class GradientFactory<P 
      * @param theMatrix The matrix for any transformations
      * @return Returns the Pattern object of the gradient
      */
-    public abstract P createGradient(boolean radial,
-            PDFDeviceColorSpace theColorspace, List<Color> theColors, List<Double> theBounds,
-            List<Double> theCoords, List<Double> theMatrix);
-
-    protected Pattern makeGradient(boolean radial, PDFDeviceColorSpace theColorspace,
+    protected P makeGradient(boolean radial, PDFDeviceColorSpace theColorspace,
                                    List<Color> theColors, List<Double> theBounds,
                                    List<Double> theCoords, List<Double> theMatrix) {
         Shading myShad;
@@ -226,7 +222,7 @@ public abstract class GradientFactory<P 
             boolean theAntiAlias, List<Double> theCoords, List<Double> theDomain,
             Function theFunction, List<Integer> theExtend);
 
-    public abstract Pattern makePattern(int thePatternType, Shading theShading, List theXUID,
+    public abstract P makePattern(int thePatternType, Shading theShading, List theXUID,
             StringBuffer theExtGState, List<Double> theMatrix);
 
     private List<Double> toColorVector(Color nextColor) {

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PDFGradientFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PDFGradientFactory.java?rev=1609532&r1=1609531&r2=1609532&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PDFGradientFactory.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PDFGradientFactory.java Thu Jul 10 18:00:58 2014
@@ -17,7 +17,6 @@
 
 package org.apache.fop.render.shading;
 
-import java.awt.Color;
 import java.util.List;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
@@ -28,35 +27,28 @@ import org.apache.fop.svg.PDFGraphics2D;
 
 public class PDFGradientFactory extends GradientFactory<PDFPattern> {
 
-    private final GradientRegistrar registrar;
+    private final PDFGraphics2D graphics2D;
 
     public PDFGradientFactory(PDFGraphics2D pdfGraphics2D) {
-        this.registrar = pdfGraphics2D;
-    }
-
-    @Override
-    public PDFPattern createGradient(boolean radial, PDFDeviceColorSpace theColorspace, List<Color> theColors,
-            List<Double> theBounds, List<Double> theCoords, List<Double> theMatrix) {
-        return (PDFPattern)makeGradient(radial, theColorspace, theColors, theBounds,
-                theCoords, theMatrix);
+        this.graphics2D = pdfGraphics2D;
     }
 
     @Override
     public Function makeFunction(int functionType, List<Double> theDomain,
             List<Double> theRange, List<Function> theFunctions,
             List<Double> theBounds, List<Double> theEncode) {
-        Function newFunction = new PDFFunction(functionType, theDomain, theRange, theFunctions,
+        PDFFunction newFunction = new PDFFunction(functionType, theDomain, theRange, theFunctions,
                     theBounds, theEncode);
-        newFunction = registrar.registerFunction(newFunction);
+        newFunction = graphics2D.registerFunction(newFunction);
         return newFunction;
     }
 
     public Function makeFunction(int functionType, List<Double> theDomain,
             List<Double> theRange, List<Double> theCZero, List<Double> theCOne,
             double theInterpolationExponentN) {
-        Function newFunction = new PDFFunction(functionType, theDomain, theRange, theCZero,
+        PDFFunction newFunction = new PDFFunction(functionType, theDomain, theRange, theCZero,
                     theCOne, theInterpolationExponentN);
-        newFunction = registrar.registerFunction(newFunction);
+        newFunction = graphics2D.registerFunction(newFunction);
         return newFunction;
     }
 
@@ -65,18 +57,18 @@ public class PDFGradientFactory extends 
             PDFDeviceColorSpace theColorSpace, List<Double> theBackground, List<Double> theBBox,
             boolean theAntiAlias, List<Double> theCoords, List<Double> theDomain,
             Function theFunction, List<Integer> theExtend) {
-        Shading newShading = new PDFShading(theShadingType, theColorSpace, theBackground,
+        PDFShading newShading = new PDFShading(theShadingType, theColorSpace, theBackground,
                     theBBox, theAntiAlias, theCoords, theDomain, theFunction, theExtend);
-        newShading = registrar.registerShading(newShading);
+        newShading = graphics2D.registerShading(newShading);
         return newShading;
     }
 
     @Override
-    public Pattern makePattern(int thePatternType, Shading theShading, List theXUID,
+    public PDFPattern makePattern(int thePatternType, Shading theShading, List theXUID,
             StringBuffer theExtGState, List<Double> theMatrix) {
-        Pattern newPattern = new PDFPattern(thePatternType, theShading, theXUID, theExtGState,
+        PDFPattern newPattern = new PDFPattern(thePatternType, theShading, theXUID, theExtGState,
                     theMatrix);
-        newPattern = registrar.registerPattern(newPattern);
+        newPattern = graphics2D.registerPattern(newPattern);
         return newPattern;
     }
 

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PSGradientFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PSGradientFactory.java?rev=1609532&r1=1609531&r2=1609532&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PSGradientFactory.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/shading/PSGradientFactory.java Thu Jul 10 18:00:58 2014
@@ -17,7 +17,6 @@
 
 package org.apache.fop.render.shading;
 
-import java.awt.Color;
 import java.util.List;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
@@ -27,14 +26,6 @@ import org.apache.fop.render.ps.svg.PSSh
 
 public class PSGradientFactory extends GradientFactory<PSPattern> {
 
-    @Override
-    public PSPattern createGradient(boolean radial, PDFDeviceColorSpace theColorspace,
-            List<Color> theColors, List<Double> theBounds, List<Double> theCoords,
-            List<Double> theMatrix) {
-        return (PSPattern)makeGradient(radial, theColorspace, theColors, theBounds,
-                theCoords, theMatrix);
-    }
-
     public Function makeFunction(int functionType, List<Double> theDomain,
             List<Double> theRange, List<Function> theFunctions,
             List<Double> theBounds, List<Double> theEncode) {
@@ -63,7 +54,7 @@ public class PSGradientFactory extends G
     }
 
     @Override
-    public Pattern makePattern(int thePatternType, Shading theShading, List theXUID,
+    public PSPattern makePattern(int thePatternType, Shading theShading, List theXUID,
             StringBuffer theExtGState, List<Double> theMatrix) {
         return new PSPattern(thePatternType, theShading, theXUID, theExtGState, theMatrix);
     }

Modified: xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java?rev=1609532&r1=1609531&r2=1609532&view=diff
==============================================================================
--- xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java (original)
+++ xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/svg/PDFGraphics2D.java Thu Jul 10 18:00:58 2014
@@ -95,11 +95,7 @@ import org.apache.fop.pdf.PDFXObject;
 import org.apache.fop.render.pdf.ImageRawCCITTFaxAdapter;
 import org.apache.fop.render.pdf.ImageRawJPEGAdapter;
 import org.apache.fop.render.pdf.ImageRenderedAdapter;
-import org.apache.fop.render.shading.Function;
-import org.apache.fop.render.shading.GradientRegistrar;
 import org.apache.fop.render.shading.PDFGradientFactory;
-import org.apache.fop.render.shading.Pattern;
-import org.apache.fop.render.shading.Shading;
 
 /**
  * <p>PDF Graphics 2D.
@@ -110,7 +106,7 @@ import org.apache.fop.render.shading.Sha
  *
  * @see org.apache.batik.ext.awt.g2d.AbstractGraphics2D
  */
-public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler, GradientRegistrar {
+public class PDFGraphics2D extends AbstractGraphics2D implements NativeImageHandler {
     private static final AffineTransform IDENTITY_TRANSFORM = new AffineTransform();
 
     /** The number of decimal places. */
@@ -1764,8 +1760,8 @@ public class PDFGraphics2D extends Abstr
      * @return Returns either the function which has already been registered
      * or the current new registered object.
      */
-    public Function registerFunction(Function function) {
-        return pdfDoc.getFactory().registerFunction((PDFFunction)function);
+    public PDFFunction registerFunction(PDFFunction function) {
+        return pdfDoc.getFactory().registerFunction(function);
     }
 
     /**
@@ -1774,9 +1770,8 @@ public class PDFGraphics2D extends Abstr
      * @return Returs either the shading which has already been registered
      * or the current new registered object
      */
-    public Shading registerShading(Shading shading) {
-        assert shading instanceof PDFShading;
-        return pdfDoc.getFactory().registerShading(resourceContext, (PDFShading)shading);
+    public PDFShading registerShading(PDFShading shading) {
+        return pdfDoc.getFactory().registerShading(resourceContext, shading);
     }
 
     /**
@@ -1785,9 +1780,8 @@ public class PDFGraphics2D extends Abstr
      * @return Returns either the pattern which has already been registered
      * or the current new registered object
      */
-    public Pattern registerPattern(Pattern pattern) {
-        assert pattern instanceof PDFPattern;
-        return pdfDoc.getFactory().registerPattern(resourceContext, (PDFPattern)pattern);
+    public PDFPattern registerPattern(PDFPattern pattern) {
+        return pdfDoc.getFactory().registerPattern(resourceContext, pattern);
     }
 
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org