/hg/gfx-test: * src/org/gfxtest/framework/CommonRenderingStyles....

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Aug 19 07:05:23 PDT 2011


changeset a70769863697 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=a70769863697
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Aug 19 16:06:59 2011 +0200

	* src/org/gfxtest/framework/CommonRenderingStyles.java: Added
	methods supporting rendering shapes filled by radial gradient paint.
	* src/org/gfxtest/testsuites/GradientPaint.java: Removed unused
	import.
	* src/org/gfxtest/testsuites/RadialGradientPaint.java: Created new
	test suite containing 12 new gfx.tests.


diffstat:

 ChangeLog                                            |    9 +
 src/org/gfxtest/framework/CommonRenderingStyles.java |  115 ++++++-
 src/org/gfxtest/testsuites/GradientPaint.java        |    3 +-
 src/org/gfxtest/testsuites/RadialGradientPaint.java  |  336 +++++++++++++++++++
 4 files changed, 460 insertions(+), 3 deletions(-)

diffs (truncated from 522 to 500 lines):

diff -r 086679317267 -r a70769863697 ChangeLog
--- a/ChangeLog	Thu Aug 18 12:35:19 2011 +0200
+++ b/ChangeLog	Fri Aug 19 16:06:59 2011 +0200
@@ -1,3 +1,12 @@
+2011-08-19  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/framework/CommonRenderingStyles.java:
+	Added methods supporting rendering shapes filled by radial gradient
+	paint.
+	* src/org/gfxtest/testsuites/GradientPaint.java:
+	Removed unused import.
+	* src/org/gfxtest/testsuites/RadialGradientPaint.java:
+	Created new test suite containing 12 new gfx.tests.
+
 2011-08-18  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/testsuites/GradientPaint.java:
 	Created new test suite containing 16 new gfx.tests.
diff -r 086679317267 -r a70769863697 src/org/gfxtest/framework/CommonRenderingStyles.java
--- a/src/org/gfxtest/framework/CommonRenderingStyles.java	Thu Aug 18 12:35:19 2011 +0200
+++ b/src/org/gfxtest/framework/CommonRenderingStyles.java	Fri Aug 19 16:06:59 2011 +0200
@@ -44,6 +44,8 @@
 import java.awt.Color;
 import java.awt.GradientPaint;
 import java.awt.Graphics2D;
+import java.awt.RadialGradientPaint;
+import java.awt.MultipleGradientPaint.CycleMethod;
 
 
 
@@ -78,7 +80,7 @@
     /**
      * Default gradient paint first color.
      */
-    private static final Color DEFAULT_GRADIENT_PAINT_FIRST_COLOR = Color.RED;
+    private static final Color DEFAULT_GRADIENT_PAINT_FIRST_COLOR = Color.BLUE;
 
     /**
      * Default gradient paint second color.
@@ -86,6 +88,21 @@
     private static final Color DEFAULT_GRADIENT_PAINT_SECOND_COLOR = Color.YELLOW;
 
     /**
+     * Default radial gradient paint first color.
+     */
+    private static final Color DEFAULT_RADIAL_GRADIENT_PAINT_FIRST_COLOR = Color.RED;
+
+    /**
+     * Default radial gradient paint second color.
+     */
+    private static final Color DEFAULT_RADIAL_GRADIENT_PAINT_SECOND_COLOR = Color.WHITE;
+
+    /**
+     * Default radial gradient paint third color.
+     */
+    private static final Color DEFAULT_RADIAL_GRADIENT_PAINT_THIRD_COLOR = Color.BLUE;
+
+    /**
      * Set default stroke color.
      * 
      * @param graphics
@@ -412,6 +429,102 @@
     }
 
     /**
+     * Set radial gradient fill for given graphics context.
+     *
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @param cycleMethod
+     *            the method to use when painting outside gradient bounds
+     * @param radiusScale
+     *            scale used while calculating radius
+     */
+    public static void setRadialGradientFill(TestImage image, Graphics2D graphics, CycleMethod cycleMethod, float radiusScale)
+    {
+        setRadialGradientFill(image, graphics, DEFAULT_RADIAL_GRADIENT_PAINT_FIRST_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_SECOND_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_THIRD_COLOR, cycleMethod, radiusScale);
+    }
+
+    /**
+     * Set radial gradient fill for given graphics context.
+     *
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     */
+    public static void setRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        setRadialGradientFill(image, graphics, DEFAULT_RADIAL_GRADIENT_PAINT_FIRST_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_SECOND_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_THIRD_COLOR);
+    }
+
+    /**
+     * Set radial gradient fill for given graphics context.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @param cycleMethod
+     *            the method to use when painting outside gradient bounds
+     */
+    public static void setRadialGradientFill(TestImage image, Graphics2D graphics, CycleMethod cycleMethod)
+    {
+        setRadialGradientFill(image, graphics, DEFAULT_RADIAL_GRADIENT_PAINT_FIRST_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_SECOND_COLOR, DEFAULT_RADIAL_GRADIENT_PAINT_THIRD_COLOR, cycleMethod, 1.0f);
+    }
+
+    /**
+     * Set radial gradient fill for given graphics context.
+     *
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @param color1
+     *            color used in the gradient
+     * @param color2
+     *            color used in the gradient
+     * @param color3
+     *            color used in the gradient
+     */
+    private static void setRadialGradientFill(TestImage image, Graphics2D graphics, Color color1, Color color2, Color color3)
+    {
+        setRadialGradientFill(image, graphics, color1, color2, color3, CycleMethod.NO_CYCLE, 1.0f);
+    }
+
+    /**
+     * Set radial gradient fill for given graphics context.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @param color1
+     *            color used in the gradient
+     * @param color2
+     *            color used in the gradient
+     * @param color3
+     *            color used in the gradient
+     * @param cycleMethod
+     *            the method to use when painting outside gradient bounds
+     * @param radiusScale
+     *            scale used while calculating radius
+     */
+    private static void setRadialGradientFill(TestImage image, Graphics2D graphics, Color color1, Color color2, Color color3, CycleMethod cycleMethod, float radiusScale)
+    {
+        // calculate center of the image
+        int xc = image.getCenterX();
+        int yc = image.getCenterY();
+
+        // calculate radius of circle
+        int radius = (int) (CommonShapesRenderer.calculateRadius(image) * radiusScale);
+        float[] dist = { 0.0f, 0.2f, 1.0f };
+        Color[] colors = { color1, color2, color3 };
+        RadialGradientPaint gradientPaint = new RadialGradientPaint(xc, yc, radius, dist, colors, cycleMethod);
+        graphics.setPaint(gradientPaint);
+    }
+
+    /**
      * Set zero pixels wide stroke and default cap and join style.
      * 
      * @param graphics
diff -r 086679317267 -r a70769863697 src/org/gfxtest/testsuites/GradientPaint.java
--- a/src/org/gfxtest/testsuites/GradientPaint.java	Thu Aug 18 12:35:19 2011 +0200
+++ b/src/org/gfxtest/testsuites/GradientPaint.java	Fri Aug 19 16:06:59 2011 +0200
@@ -42,7 +42,6 @@
 
 
 
-import java.awt.Color;
 import java.awt.Graphics2D;
 
 
@@ -51,7 +50,7 @@
 import org.gfxtest.framework.annotations.*;
 
 /**
- * This test renders filled shapes using simple ColorPaint.
+ * This test renders filled shapes using gradient paint.
  *
  * @author Pavel Tisnovsky
  */
diff -r 086679317267 -r a70769863697 src/org/gfxtest/testsuites/RadialGradientPaint.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/testsuites/RadialGradientPaint.java	Fri Aug 19 16:06:59 2011 +0200
@@ -0,0 +1,336 @@
+/*
+  Java gfx-test framework
+
+   Copyright (C) 2010, 2011  Red Hat
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version.
+*/
+
+package org.gfxtest.testsuites;
+
+import java.awt.Graphics2D;
+import java.awt.MultipleGradientPaint.CycleMethod;
+
+
+
+import org.gfxtest.framework.*;
+import org.gfxtest.framework.annotations.*;
+
+/**
+ * This test renders filled shapes using radial gradient paint.
+ *
+ * @author Pavel Tisnovsky
+ */
+ at TestType(TestTypes.RENDER_TEST)
+ at RenderStyle(RenderStyles.FILL)
+ at Transformation(Transformations.NONE)
+ at Zoom(1)
+public class RadialGradientPaint extends GfxTest
+{
+  
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillSmallerRadiusNoCycle(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.NO_CYCLE, 0.5f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillSmallerRadiusRepeat(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.REPEAT, 0.5f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillSmallerRadiusReflect(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.REFLECT, 0.5f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillLargerRadiusNoCycle(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.NO_CYCLE, 2.0f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillLargerRadiusRepeat(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.REPEAT, 2.0f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled circle drawn by graphics.fillOval() is rendered correctly.
+     * Radial Gradient paint is used for filling this circle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testCircleRadialGradientFillLargerRadiusReflect(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics, CycleMethod.REFLECT, 2.0f);
+        // draw the circle
+        CommonShapesRenderer.drawFilledCircle(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled rectangle is rendered correctly.
+     * Radial gradient paint is used for filling this rectangle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testRectangleRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics);
+        // draw the circle
+        CommonShapesRenderer.drawFilledRect(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled round rectangle is rendered correctly.
+     * Radial gradient paint is used for filling this round rectangle.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testRoundRectangleRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics);
+        // draw the circle
+        CommonShapesRenderer.drawFilledRoundRect(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled arc is rendered correctly.
+     * Radial gradient paint is used for filling this arc.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testArcRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics);
+        // draw the circle
+        CommonShapesRenderer.drawFilledArc(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled polygon is rendered correctly.
+     * Radial gradient paint is used for filling this polygon.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */
+    public TestResult testPolygonRadialGradientFill(TestImage image, Graphics2D graphics)
+    {
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setRadialGradientFill(image, graphics);
+        // draw the circle
+        CommonShapesRenderer.drawFilledPolygon(image, graphics);
+        // test return value
+        return TestResult.PASSED;
+    }
+
+    /**
+     * Test if filled closed path is rendered correctly.
+     * Radial gradient paint is used for filling this path.
+     * 
+     * @param image
+     *            image to which two dimensional shape is to be rendered
+     * @param graphics
+     *            graphics context for image
+     * @return test result status - PASSED, FAILED or ERROR
+     */



More information about the distro-pkg-dev mailing list