/hg/gfx-test: Several helper methods for working with various sh...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jan 16 00:59:24 PST 2014
changeset 23845c2f1cbc in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=23845c2f1cbc
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jan 16 10:03:33 2014 +0100
Several helper methods for working with various shapes added into
the class CommonCAGOperations.
Added new test to the test suite CAGOperationsOnRoundRectangleAndRectangle.
diffstat:
ChangeLog | 8 +
src/org/gfxtest/framework/CommonCAGOperations.java | 64 +++++++++-
src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java | 34 +++++-
3 files changed, 104 insertions(+), 2 deletions(-)
diffs (183 lines):
diff -r 121696444efb -r 23845c2f1cbc ChangeLog
--- a/ChangeLog Wed Jan 15 13:13:09 2014 +0100
+++ b/ChangeLog Thu Jan 16 10:03:33 2014 +0100
@@ -1,3 +1,11 @@
+2014-01-16 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/framework/CommonCAGOperations.java:
+ Several helper methods for working with various shapes added into
+ the class CommonCAGOperations.
+ * src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java:
+ Added new test to the test suite CAGOperationsOnRoundRectangleAndRectangle.
+
2014-01-15 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/BitBltAffineIdentityTransformOp.java:
diff -r 121696444efb -r 23845c2f1cbc src/org/gfxtest/framework/CommonCAGOperations.java
--- a/src/org/gfxtest/framework/CommonCAGOperations.java Wed Jan 15 13:13:09 2014 +0100
+++ b/src/org/gfxtest/framework/CommonCAGOperations.java Thu Jan 16 10:03:33 2014 +0100
@@ -1,7 +1,7 @@
/*
Java gfx-test framework
- Copyright (C) 2010, 2011 Red Hat
+ Copyright (C) 2010, 2011, 2012, 2013, 2014 Red Hat
This file is part of IcedTea.
@@ -44,6 +44,7 @@
import java.awt.geom.Area;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
+import java.awt.geom.RoundRectangle2D;
/**
* This class contains static methods used by various CAG operations tests.
@@ -84,6 +85,11 @@
private final static int PIE_EXTEND_ANGLE = 270;
/**
+ * Radius of rounded
+ */
+ private final static int ROUND_RECTANGLE_RADIUS = 100;
+
+ /**
* Compute radius of circle from the position of its center point in an
* image size (width and height).
*
@@ -240,6 +246,23 @@
}
/**
+ * Create rounded rectangular area i.e. area consisting of just one rectangle.
+ *
+ * @param xc
+ * the X coordinate of the center of rectangle
+ * @param yc
+ * the Y coordinate of the center of rectangle
+ * @param size
+ * of rectangle
+ * @return newly created area containing one rectangle
+ */
+ private static Area createRoundedRectangularArea(int xc, int yc, int size)
+ {
+ RoundRectangle2D rectangle = new RoundRectangle2D.Double(xc - size, yc - size, size << 1, size << 1, ROUND_RECTANGLE_RADIUS, ROUND_RECTANGLE_RADIUS);
+ return new Area(rectangle);
+ }
+
+ /**
* Create area composed of only one circle. This circle is placed on the
* left side of the image.
*
@@ -370,6 +393,28 @@
}
/**
+ * Create area composed of only one rounded rectangle. This rectangle is placed on
+ * the upper left side of the image.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @return newly created area containing one rectangle
+ */
+ private static Area createFirstOverlappingRoundedRectangularArea(TestImage image)
+ {
+ // compute center of the image
+ int xc = image.getCenterX();
+ int yc = image.getCenterY();
+ // compute size of the rectangle
+ int size = computeSizeForOverlappingRectangle(xc, yc);
+ int x = xc - 3 * (size >> 2);
+ // it's better to align rectangle sides with the grid
+ x = x + (x % image.getGrid());
+ int y = yc - (size >> 1);
+ return createRoundedRectangularArea(x, y, size);
+ }
+
+ /**
* Create area composed of only one rectangle. This rectangle is placed on
* the lower right side of the image.
*
@@ -711,6 +756,23 @@
}
/**
+ * Create new area composed from rounded rectangle and rectangle using union operator.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @return new area composed of two rectangles
+ */
+ public static Area createAreaFromRoundRectangleAndRectangleUsingUnionOperator(TestImage image)
+ {
+ Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+ Area rectangle2Area = createSecondOverlappingRectangularArea(image);
+ Area area = new Area();
+ area.add(rectangle1Area);
+ area.add(rectangle2Area);
+ return area;
+ }
+
+ /**
* Create new area constructed from bigger circle and rectangle using union
* operation.
*
diff -r 121696444efb -r 23845c2f1cbc src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java
--- a/src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java Wed Jan 15 13:13:09 2014 +0100
+++ b/src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java Thu Jan 16 10:03:33 2014 +0100
@@ -1,7 +1,7 @@
/*
Java gfx-test framework
- Copyright (C) 2013 Red Hat
+ Copyright (C) 2013, 2014 Red Hat
This file is part of IcedTea.
@@ -40,7 +40,16 @@
package org.gfxtest.testsuites;
+import java.awt.Graphics2D;
+import java.awt.geom.Area;
+
+
+
+import org.gfxtest.framework.CommonCAGOperations;
+import org.gfxtest.framework.CommonRenderingStyles;
import org.gfxtest.framework.GfxTest;
+import org.gfxtest.framework.TestImage;
+import org.gfxtest.framework.TestResult;
import org.gfxtest.framework.annotations.GraphicsPrimitive;
import org.gfxtest.framework.annotations.GraphicsPrimitives;
import org.gfxtest.framework.annotations.RenderStyle;
@@ -70,6 +79,29 @@
{
/**
+ * Checks the process of creating and rendering new geometric shape
+ * constructed from two rectangles using union operator. The shape is
+ * rendered using stroke.
+ *
+ * @param image
+ * image to which area is to be drawn
+ * @param graphics2d
+ * graphics canvas
+ * @return test result status - PASSED, FAILED or ERROR
+ */
+ public TestResult testUnionStrokePaint(TestImage image, Graphics2D graphics2d)
+ {
+ // set stroke color
+ CommonRenderingStyles.setStrokeColor(graphics2d);
+ // create area using union operator
+ Area area = CommonCAGOperations.createAreaFromRoundRectangleAndRectangleUsingUnionOperator(image);
+ // draw the area
+ graphics2d.draw(area);
+ // test result
+ return TestResult.PASSED;
+ }
+
+ /**
* Entry point to the test suite.
*
* @param args not used in this case
More information about the distro-pkg-dev
mailing list