/hg/gfx-test: 2011-11-08 Pavel Tisnovsky <ptisnovs at redhat.com>
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Nov 8 03:49:12 PST 2011
changeset 843d131b0d88 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=843d131b0d88
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Nov 08 12:51:12 2011 +0100
2011-11-08 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/framework/CommonClippingOperations.java:
Created new class containing methods used by all clipping test
suites.
* src/org/gfxtest/testsuites/Clipping.java:
* src/org/gfxtest/testsuites/ClippingCircleByRectangleArea.java:
Moved tests to ClippingCircleByRectangleArea because I'm planning to
add more specialized test for this area.
diffstat:
ChangeLog | 9 +
src/org/gfxtest/framework/CommonClippingOperations.java | 304 +++++++
src/org/gfxtest/testsuites/Clipping.java | 224 +----
src/org/gfxtest/testsuites/ClippingCircleByRectangleArea.java | 420 ++++++++++
4 files changed, 765 insertions(+), 192 deletions(-)
diffs (truncated from 1018 to 500 lines):
diff -r 697bfde838ac -r 843d131b0d88 ChangeLog
--- a/ChangeLog Mon Nov 07 10:01:14 2011 +0100
+++ b/ChangeLog Tue Nov 08 12:51:12 2011 +0100
@@ -1,3 +1,12 @@
+2011-11-08 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/CommonClippingOperations.java:
+ Created new class containing methods used by all clipping test suites.
+ * src/org/gfxtest/testsuites/Clipping.java:
+ * src/org/gfxtest/testsuites/ClippingCircleByRectangleArea.java:
+ Moved tests to ClippingCircleByRectangleArea because I'm planning to
+ add more specialized test for this area.
+
2011-11-07 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/TexturePaint.java:
diff -r 697bfde838ac -r 843d131b0d88 src/org/gfxtest/framework/CommonClippingOperations.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/framework/CommonClippingOperations.java Tue Nov 08 12:51:12 2011 +0100
@@ -0,0 +1,304 @@
+/*
+ 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.framework;
+
+import java.awt.Color;
+import java.awt.Graphics2D;
+import java.awt.Polygon;
+import java.awt.Shape;
+import java.awt.geom.Ellipse2D;
+import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
+
+
+
+/**
+ * This class contains static method used by the various tests which checks if
+ * clipping is working correctly.
+ *
+ * @author Pavel Tisnovsky
+ */
+public class CommonClippingOperations
+{
+ /**
+ * Color used for rendering shape which is drawn along clip region.
+ */
+ public static final Color CLIP_SHAPE_COLOR = Color.MAGENTA.darker();
+
+ /**
+ * Radius of corners of the round rectangle.
+ */
+ public static final int ROUND_RECTANGLE_ARC_RADIUS = 300;
+
+ /**
+ * Compute width of the clip region.
+ *
+ * @param image
+ * work image
+ * @return width of the clip region
+ */
+ private static int computeClipRegionWidth(TestImage image)
+ {
+ // compute width first
+ int width = 2 * image.getWidth() / 3;
+ // it's best to align clip area with the grid
+ width = width - (width % image.getGrid());
+ return width - 1;
+ }
+
+ /**
+ * Compute height of the clip region.
+ *
+ * @param image
+ * work image
+ * @return height of the clip region
+ */
+ private static int computeClipRegionHeight(TestImage image)
+ {
+ // compute height first
+ int height = 2 * image.getHeight() / 3;
+ // it's best to align clip area with the grid
+ height = height - (height % image.getGrid());
+ return height - 1;
+ }
+
+ /**
+ * Render the rectangle around the clip area. Clip area could have different
+ * shape but it's area should lie inside this rectangle.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void renderClipRectangle(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image) + 1;
+ final int height = computeClipRegionHeight(image) + 1;
+ // color used for clipping areas
+ graphics2d.setColor(CLIP_SHAPE_COLOR);
+ // draw rectangle around the clip area
+ graphics2d.drawRect(0, 0, width, height);
+ }
+
+ /**
+ * Render the round rectangle around the clip area.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void renderClipRoundRectangle(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image) + 1;
+ final int height = computeClipRegionHeight(image) + 1;
+ // color used for clipping areas
+ graphics2d.setColor(CLIP_SHAPE_COLOR);
+ // draw rounded rectangle around the clip area
+ graphics2d.drawRoundRect(0, 0, width, height, ROUND_RECTANGLE_ARC_RADIUS, ROUND_RECTANGLE_ARC_RADIUS);
+ }
+
+ /**
+ * Render the ellipse around the clip area. Clip area could have different
+ * shape but should be inside this ellipse.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void renderClipEllipse(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image) + 1;
+ final int height = computeClipRegionHeight(image) + 1;
+ // color used for clipping areas
+ graphics2d.setColor(CLIP_SHAPE_COLOR);
+ // draw ellipse around the clip area
+ graphics2d.drawOval(0, 0, width, height);
+ }
+
+ /**
+ * Render the polygon around the clip area. Clip area could have different
+ * shape but should be inside this ellipse.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void renderClipPolygon(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image) + 1;
+ final int height = computeClipRegionHeight(image) + 1;
+ // color used for clipping areas
+ graphics2d.setColor(CLIP_SHAPE_COLOR);
+ // draw ellipse around the clip area
+ graphics2d.drawPolygon(createClippingPolygon(width, height));
+ }
+
+ /**
+ * Create clip region using rectangle area (not rectangular shape)
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void createClipUsingRectangleArea(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image);
+ final int height = computeClipRegionHeight(image);
+ // apply clip rectangle area
+ graphics2d.setClip(1, 1, width, height);
+ }
+
+ /**
+ * Create clip region using rectangular shape (not rectangle area).
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void createClipUsingRectangleShape(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image);
+ final int height = computeClipRegionHeight(image);
+ // create clip shape
+ Shape clipShape = new Rectangle2D.Float(1, 1, width, height);
+ // and apply the created shape as clipping region
+ graphics2d.setClip(clipShape);
+ }
+
+ /**
+ * Create clip region using rounded rectangular shape (not rectangle area).
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void createClipUsingRoundRectangleShape(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image);
+ final int height = computeClipRegionHeight(image);
+ // create clip shape
+ Shape clipShape = new RoundRectangle2D.Float(1, 1, width, height, ROUND_RECTANGLE_ARC_RADIUS, ROUND_RECTANGLE_ARC_RADIUS);
+ // and apply the created shape as clipping region
+ graphics2d.setClip(clipShape);
+ }
+
+ /**
+ * Create clip region using elliptic shape.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void createClipUsingEllipseShape(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image);
+ final int height = computeClipRegionHeight(image);
+ // create clip shape
+ Shape clipShape = new Ellipse2D.Float(1, 1, width, height);
+ // and apply the created shape as clipping region
+ graphics2d.setClip(clipShape);
+ }
+
+ /**
+ * Create clip region using polygonal shape.
+ *
+ * @param image
+ * work image
+ * @param graphics2d
+ * graphics canvas
+ */
+ public static void createClipUsingPolygonalShape(TestImage image, Graphics2D graphics2d)
+ {
+ // compute size of clip area
+ final int width = computeClipRegionWidth(image);
+ final int height = computeClipRegionHeight(image);
+ // create clip shape
+ Polygon polygon = createClippingPolygon(width, height);
+ // and apply the created shape as clipping region
+ graphics2d.setClip(polygon);
+ }
+
+ /**
+ * Create clipping polygon with given width and height. Please note that the
+ * polygon has the following shape:
+ *
+ * <pre>
+ * |\ /|
+ * | \ / |
+ * | >< |
+ * | / \ |
+ * |/ \|
+ * </pre>
+ *
+ * @param width
+ * image width
+ * @param height
+ * image height
+ * @return new clipping polygon
+ */
+ private static Polygon createClippingPolygon(final int width, final int height)
+ {
+ Polygon polygon = new Polygon();
+ // add four vertexes
+ polygon.addPoint(1, 1);
+ polygon.addPoint(width, height);
+ polygon.addPoint(width, 1);
+ polygon.addPoint(1, height);
+ return polygon;
+ }
+
+}
diff -r 697bfde838ac -r 843d131b0d88 src/org/gfxtest/testsuites/Clipping.java
--- a/src/org/gfxtest/testsuites/Clipping.java Mon Nov 07 10:01:14 2011 +0100
+++ b/src/org/gfxtest/testsuites/Clipping.java Tue Nov 08 12:51:12 2011 +0100
@@ -42,19 +42,7 @@
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.Shape;
-import java.awt.geom.Ellipse2D;
-import java.awt.geom.Rectangle2D;
-
-
-
-import org.gfxtest.framework.CommonRenderingStyles;
-import org.gfxtest.framework.CommonShapesRenderer;
import org.gfxtest.framework.GfxTest;
-import org.gfxtest.framework.TestImage;
-import org.gfxtest.framework.TestResult;
import org.gfxtest.framework.annotations.TestType;
import org.gfxtest.framework.annotations.TestTypes;
import org.gfxtest.framework.annotations.Transformation;
@@ -74,185 +62,6 @@
@Zoom(1)
public class Clipping extends GfxTest
{
- /**
- * Color used for rendering shape which is drawn along clip region.
- */
- private static final Color CLIP_SHAPE_COLOR = Color.MAGENTA.darker();
-
- /**
- * Computes width of the clip region.
- *
- * @param image
- * work image
- * @return width of the clip region
- */
- private static int computeClipRegionWidth(TestImage image)
- {
- // compute width first
- int width = 2 * image.getWidth() / 3;
- // we need to align clip area with the grid
- width = width - (width % image.getGrid());
- return width - 1;
- }
-
- /**
- * Compute height of the clip region.
- *
- * @param image
- * work image
- * @return height of the clip region
- */
- private static int computeClipRegionHeight(TestImage image)
- {
- // compute height first
- int height = 2 * image.getHeight() / 3;
- // we need to align clip area with the grid
- height = height - (height % image.getGrid());
- return height - 1;
- }
-
- /**
- * Render the rectangle around the clip area. Clip area could have different
- * shape but should be inside this rectangle.
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- */
- private void renderClipRectangle(TestImage image, Graphics2D graphics2d)
- {
- // compute size of clip area
- final int width = computeClipRegionWidth(image) + 1;
- final int height = computeClipRegionHeight(image) + 1;
- // draw rectangle around the clip area
- graphics2d.setColor(CLIP_SHAPE_COLOR);
- graphics2d.drawRect(0, 0, width, height);
- }
-
- /**
- * Render the ellipse around the clip area. Clip area could have different
- * shape but should be inside this ellipse.
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- */
- private void renderClipEllipse(TestImage image, Graphics2D graphics2d)
- {
- // compute size of clip area
- final int width = computeClipRegionWidth(image) + 1;
- final int height = computeClipRegionHeight(image) + 1;
- // draw rectangle around the clip area
- graphics2d.setColor(CLIP_SHAPE_COLOR);
- graphics2d.drawOval(0, 0, width, height);
- }
-
- /**
- * Create clip region using rectangle area (not rectangular shape)
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- */
- private static void createClipUsingRectangleArea(TestImage image, Graphics2D graphics2d)
- {
- // compute size of clip area
- final int width = computeClipRegionWidth(image);
- final int height = computeClipRegionHeight(image);
- // apply clip rectangle area
- graphics2d.setClip(1, 1, width, height);
- }
-
- /**
- * Create clip region using rectangular shape (not rectangle area).
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- */
- private static void createClipUsingRectangleShape(TestImage image, Graphics2D graphics2d)
- {
- // compute size of clip area
- final int width = computeClipRegionWidth(image);
- final int height = computeClipRegionHeight(image);
- // create clip shape
- Shape clipShape = new Rectangle2D.Float(1, 1, width, height);
- // and apply it
- graphics2d.setClip(clipShape);
- }
-
- /**
- * Create clip region using elliptic shape.
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- */
- private static void createClipUsingEllipseShape(TestImage image, Graphics2D graphics2d)
- {
- // compute size of clip area
- final int width = computeClipRegionWidth(image);
- final int height = computeClipRegionHeight(image);
- // create clip shape
- Shape clipShape = new Ellipse2D.Float(1, 1, width, height);
- // and apply it
- graphics2d.setClip(clipShape);
- }
-
- /**
- * Check if circle shape could be clipped by a rectangle area. Circle is
- * rendered using stroke paint.
- *
- * @param image
- * work image
- * @param graphics2d
- * graphics canvas
- * @return test result status - PASSED, FAILED or ERROR
- */
- public TestResult testClipCircleByRectangleAreaStrokePaint(TestImage image, Graphics2D graphics2d)
- {
- // render clip rectangle
- renderClipRectangle(image, graphics2d);
- // set stroke color
- CommonRenderingStyles.setStrokeColor(graphics2d);
- // create clip area
- createClipUsingRectangleArea(image, graphics2d);
- // draw the area
More information about the distro-pkg-dev
mailing list