Author: vhennebert
Date: Fri Jul 11 17:07:29 2014
New Revision: 1609746

URL: http://svn.apache.org/r1609746
Log:
Removed makeFunction methods, whose implementations are the same for both PDF 
and PS

Removed:
    
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSFunction.java
Modified:
    
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSShading.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

Modified: 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSShading.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSShading.java?rev=1609746&r1=1609745&r2=1609746&view=diff
==============================================================================
--- 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSShading.java
 (original)
+++ 
xmlgraphics/fop/branches/FOP-2393_gradient-rendering/src/java/org/apache/fop/render/ps/svg/PSShading.java
 Fri Jul 11 17:07:29 2014
@@ -19,12 +19,13 @@
 
 package org.apache.fop.render.ps.svg;
 
-import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
 import org.apache.fop.pdf.PDFNumber;
 import org.apache.fop.render.shading.Function;
+import org.apache.fop.render.shading.FunctionPattern;
 import org.apache.fop.render.shading.Shading;
 import org.apache.fop.render.shading.ShadingPattern;
 
@@ -72,7 +73,7 @@ public class PSShading implements Shadin
      * The object of the color mapping function (usually type 2 or 3).
      * Optional for Type 4,5,6, and 7: When it's nearly the same thing.
      */
-    protected PSFunction function = null;
+    protected Function function;
 
     /**
      * Required for Type 2: An Array of four numbers specifying
@@ -125,8 +126,7 @@ public class PSShading implements Shadin
 
         this.coords = theCoords;
         this.domain = theDomain;
-        assert theFunction instanceof PSFunction;
-        this.function = (PSFunction)theFunction;
+        this.function = theFunction;
         this.extend = theExtend;
     }
 
@@ -187,15 +187,20 @@ public class PSShading implements Shadin
 
         if (this.function != null) {
             p.append("\t/Function ");
-            try {
-                p.append(new String(this.function.toByteString(), "UTF-8") + " 
\n");
-            } catch (UnsupportedEncodingException ex) {
-                //This should have been made an enum type to avoid throwing 
exceptions.
-            }
+            p.append(functionToString(function) + " \n");
         }
         return p;
     }
 
+    private String functionToString(Function function) {
+        FunctionPattern pattern = new FunctionPattern(function);
+        List<String> functionsStrings = new 
ArrayList<String>(function.getFunctions().size());
+        for (Function f : function.getFunctions()) {
+            functionsStrings.add(functionToString(f));
+        }
+        return pattern.toWriteableString(functionsStrings);
+    }
+
     /**
      * A method to write a type 1 shading object
      * @param p The StringBuffer to write the shading object

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=1609746&r1=1609745&r2=1609746&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
 Fri Jul 11 17:07:29 2014
@@ -79,7 +79,7 @@ public abstract class GradientFactory<P 
         List<Function> functions = createFunctions(gradient);
         //Gradients are currently restricted to sRGB
         PDFDeviceColorSpace colSpace = new 
PDFDeviceColorSpace(PDFDeviceColorSpace.DEVICE_RGB);
-        Function function = makeFunction(3, null, null, functions, bounds, 
null);
+        Function function = new Function(3, null, null, functions, bounds, 
null);
         Shading shading = makeShading(gradient instanceof LinearGradientPaint 
? 2 : 3,
                 colSpace, null, null, false, coords, null, function, null);
         return makePattern(2, shading, null, null, matrix);
@@ -127,7 +127,7 @@ public abstract class GradientFactory<P 
             Color nextColor = colors.get(currentPosition + 1);
             List<Double> c0 = toColorVector(currentColor);
             List<Double> c1 = toColorVector(nextColor);
-            Function function = makeFunction(2, null, null, c0, c1, 1.0);
+            Function function = new Function(2, null, null, c0, c1, 1.0);
             functions.add(function);
         }
         return functions;
@@ -149,14 +149,6 @@ public abstract class GradientFactory<P 
         return gradientColors;
     }
 
-    public abstract Function makeFunction(int functionType, List<Double> 
theDomain,
-            List<Double> theRange, List<Function> theFunctions,
-            List<Double> theBounds, List<Double> theEncode);
-
-    public abstract Function makeFunction(int functionType, List<Double> 
theDomain,
-            List<Double> theRange, List<Double> theCZero, List<Double> theCOne,
-            double theInterpolationExponentN);
-
     public abstract Shading makeShading(int theShadingType,
             PDFDeviceColorSpace theColorSpace, List<Double> theBackground, 
List<Double> theBBox,
             boolean theAntiAlias, List<Double> theCoords, List<Double> 
theDomain,

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=1609746&r1=1609745&r2=1609746&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
 Fri Jul 11 17:07:29 2014
@@ -35,21 +35,6 @@ public class PDFGradientFactory extends 
     }
 
     @Override
-    public Function makeFunction(int functionType, List<Double> theDomain,
-            List<Double> theRange, List<Function> theFunctions,
-            List<Double> theBounds, List<Double> theEncode) {
-        return new Function(functionType, theDomain, theRange, theFunctions, 
theBounds, theEncode);
-    }
-
-    public Function makeFunction(int functionType, List<Double> theDomain,
-            List<Double> theRange, List<Double> theCZero, List<Double> theCOne,
-            double theInterpolationExponentN) {
-        Function newFunction = new Function(functionType, theDomain, theRange, 
theCZero,
-                    theCOne, theInterpolationExponentN);
-        return newFunction;
-    }
-
-    @Override
     public Shading makeShading(int theShadingType,
             PDFDeviceColorSpace theColorSpace, List<Double> theBackground, 
List<Double> theBBox,
             boolean theAntiAlias, List<Double> theCoords, List<Double> 
theDomain,

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=1609746&r1=1609745&r2=1609746&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
 Fri Jul 11 17:07:29 2014
@@ -20,29 +20,11 @@ package org.apache.fop.render.shading;
 import java.util.List;
 
 import org.apache.fop.pdf.PDFDeviceColorSpace;
-import org.apache.fop.render.ps.svg.PSFunction;
 import org.apache.fop.render.ps.svg.PSPattern;
 import org.apache.fop.render.ps.svg.PSShading;
 
 public class PSGradientFactory extends GradientFactory<PSPattern> {
 
-    public Function makeFunction(int functionType, List<Double> theDomain,
-            List<Double> theRange, List<Function> theFunctions,
-            List<Double> theBounds, List<Double> theEncode) {
-        Function newFunction = new PSFunction(functionType, theDomain, 
theRange, theFunctions,
-                    theBounds, theEncode);
-        return newFunction;
-    }
-
-    @Override
-    public Function makeFunction(int functionType, List<Double> theDomain,
-            List<Double> theRange, List<Double> theCZero, List<Double> theCOne,
-            double theInterpolationExponentN) {
-        Function newFunction = new PSFunction(functionType, theDomain, 
theRange, theCZero,
-                    theCOne, theInterpolationExponentN);
-        return newFunction;
-    }
-
     @Override
     public Shading makeShading(int theShadingType,
             PDFDeviceColorSpace theColorSpace, List<Double> theBackground, 
List<Double> theBBox,



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to