Added: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java?rev=1541551&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java
 (added)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java
 Wed Nov 13 15:24:26 2013
@@ -0,0 +1,70 @@
+ /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.render.ps.svg;
+
+import java.awt.Color;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.Rectangle2D.Float;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+
+import org.junit.Test;
+
+import org.apache.commons.io.FileUtils;
+
+import org.apache.batik.ext.awt.LinearGradientPaint;
+
+import org.apache.xmlgraphics.java2d.GraphicContext;
+import org.apache.xmlgraphics.ps.PSGenerator;
+
+import static org.junit.Assert.assertEquals;
+
+public class PSSVGLinearGraphics2DTestCase {
+    float startX = 115f;
+    float endX = 15f;
+    float startY = 285f;
+    float endY=15f;
+    float[] fractions = {0.0f, 1.0f};
+
+    /**
+     * Tests a linear gradient generated pattern with certain inputs against
+     * an expected output.
+     * @throws IOException
+     */
+    @Test
+    public void testApplyPaint() throws IOException {
+        ByteArrayOutputStream os = new ByteArrayOutputStream();
+        PSGenerator gen = new PSGenerator(os);
+        PSSVGGraphics2D svgGraphics2D = new PSSVGGraphics2D(false, gen);
+        svgGraphics2D.setGraphicContext(new GraphicContext());
+        svgGraphics2D.setTransform(new AffineTransform());
+        Color[] colors = {new Color(255, 255, 0), new Color(255, 0, 0)};
+        LinearGradientPaint paint = new LinearGradientPaint(startX, startY, 
endX, endY, fractions, colors);
+        Float s = new Rectangle2D.Float(115.0f, 15.0f, 170f, 110f);
+        svgGraphics2D.applyPaint(paint, true);
+        byte[] test = os.toByteArray();
+
+        byte[] expected = FileUtils.readFileToByteArray(
+                new 
File("test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat"));
+        assertEquals(new String(test), new String(expected));
+    }
+}

Propchange: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/PSSVGLinearGraphics2DTestCase.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat?rev=1541551&view=auto
==============================================================================
--- 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat
 (added)
+++ 
xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/axial-shading-expected.dat
 Wed Nov 13 15:24:26 2013
@@ -0,0 +1,26 @@
+/Pattern setcolorspace
+<< 
+/Type /Pattern 
+/PatternType 2 
+/Shading <<
+/ShadingType 2 
+/ColorSpace /DeviceRGB 
+       /Coords [ 115 285 15 15 ] 
+       /Domain [ 0 1 ] 
+       /Extend [ true true ] 
+       /Function << 
+/FunctionType 3 
+/Domain [ 0 1 ] 
+/Functions [ << 
+/FunctionType 2 
+/Domain [ 0 1 ] 
+/C0 [ 1 1 0 ] 
+/C1 [ 1 0 0 ] 
+/N 1 
+>> ] 
+/Encode [ 0 1 ] 
+/Bounds [ ]
+>> 
+>> 
+>> 
+matrix makepattern setcolor

Added: xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected.ps
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected.ps?rev=1541551&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected.ps 
(added)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/render/ps/svg/expected.ps 
Wed Nov 13 15:24:26 2013
@@ -0,0 +1,38 @@
+/Pattern setcolorspace
+<< 
+/Type /Pattern 
+/PatternType 2 
+/Shading <<
+/ShadingType 3 
+/ColorSpace /DeviceRGB 
+       /Coords [ 841.890991 178.582993 3.28662 841.890991 178.582993 16.4331 ] 
+       /Domain [ 0 1 ] 
+       /Extend [ true true ] 
+       /Function << 
+/FunctionType 3 
+/Domain [ 0 1 ] 
+/Functions [ << 
+/FunctionType 2 
+/Domain [ 0 1 ] 
+/C0 [ 1 1 1 ] 
+/C1 [ 0.784314 0.784314 0.784314 ] 
+/N 1 
+>> << 
+/FunctionType 2 
+/Domain [ 0 1 ] 
+/C0 [ 0.784314 0.784314 0.784314 ] 
+/C1 [ 0.666667 0.666667 0.666667 ] 
+/N 1 
+>> << 
+/FunctionType 2 
+/Domain [ 0 1 ] 
+/C0 [ 0.666667 0.666667 0.666667 ] 
+/C1 [ 0.54902 0.54902 0.54902 ] 
+/N 1 
+>> ] 
+/Encode [ 0 1 0 1 0 1 ] 
+/Bounds [ 0.6012 0.8094 ]
+>> 
+>> 
+>> 
+matrix makepattern setcolor



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

Reply via email to