/hg/gfx-test: Added several helper methods for working with vari...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Mon Feb 3 04:21:04 PST 2014


changeset a8433c21d4e1 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=a8433c21d4e1
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Mon Feb 03 13:25:21 2014 +0100

	Added several helper methods for working with various shapes added into


diffstat:

 ChangeLog                                          |    5 +
 src/org/gfxtest/framework/CommonCAGOperations.java |  174 +++++++++++++++++++++
 2 files changed, 179 insertions(+), 0 deletions(-)

diffs (210 lines):

diff -r a91f8aca3ad3 -r a8433c21d4e1 ChangeLog
--- a/ChangeLog	Thu Jan 30 10:55:41 2014 +0100
+++ b/ChangeLog	Mon Feb 03 13:25:21 2014 +0100
@@ -1,3 +1,8 @@
+2014-02-03  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/CommonCAGOperations.java:
+	Added several helper methods for working with various shapes added into
+
 2014-01-30  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/testsuites/CAGOperationsOnRoundRectangleAndRectangle.java:
diff -r a91f8aca3ad3 -r a8433c21d4e1 src/org/gfxtest/framework/CommonCAGOperations.java
--- a/src/org/gfxtest/framework/CommonCAGOperations.java	Thu Jan 30 10:55:41 2014 +0100
+++ b/src/org/gfxtest/framework/CommonCAGOperations.java	Mon Feb 03 13:25:21 2014 +0100
@@ -436,6 +436,27 @@
     }
 
     /**
+     * Create area composed of only one round rectangle. This rectangle is placed on
+     * the lower right side of the image.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return newly created area containing one rectangle
+     */
+    private static Area createSecondOverlappingRoundedRectangularArea(TestImage 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 center of the image.
      * 
@@ -756,6 +777,91 @@
     }
 
     /**
+     * Create new area composed from two round rectangles using union operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromTwoOverlappingRoundRectanglesUsingUnionOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRoundedRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.add(rectangle2Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from two round rectangles using subtract operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromTwoOverlappingRoundRectanglesUsingSubtractOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRoundedRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.subtract(rectangle2Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from two round rectangles using subtract operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromTwoOverlappingRoundRectanglesUsingInverseSubtractOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRoundedRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle2Area);
+        area.subtract(rectangle1Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from two round rectangles using intersect operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromTwoOverlappingRoundRectanglesUsingIntersectOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRoundedRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.intersect(rectangle2Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from two round rectangles using XOR operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromTwoOverlappingRoundRectanglesUsingXorOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRoundedRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle2Area);
+        area.exclusiveOr(rectangle1Area);
+        return area;
+    }
+
+    /**
      * Create new area composed from rounded rectangle and rectangle using union operator.
      * 
      * @param image
@@ -773,6 +879,74 @@
     }
 
     /**
+     * Create new area composed from rounded rectangle and rectangle using subtract operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromRoundRectangleAndRectangleUsingSubtractOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.subtract(rectangle2Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from rounded rectangle and rectangle using inverse subtract operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromRoundRectangleAndRectangleUsingInverseSubtractOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle2Area);
+        area.subtract(rectangle1Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from rounded rectangle and rectangle using intersect operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromRoundRectangleAndRectangleUsingIntersectOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.intersect(rectangle2Area);
+        return area;
+    }
+
+    /**
+     * Create new area composed from rounded rectangle and rectangle using exclusive or operator.
+     * 
+     * @param image
+     *            image to which area is to be drawn
+     * @return new area composed of two rectangles
+     */
+    public static Area createAreaFromRoundRectangleAndRectangleUsingXorOperator(TestImage image)
+    {
+        Area rectangle1Area = createFirstOverlappingRoundedRectangularArea(image);
+        Area rectangle2Area = createSecondOverlappingRectangularArea(image);
+        Area area = new Area();
+        area.add(rectangle1Area);
+        area.exclusiveOr(rectangle2Area);
+        return area;
+    }
+
+    /**
      * Create new area constructed from bigger circle and rectangle using union
      * operation.
      * 


More information about the distro-pkg-dev mailing list