/hg/gfx-test: 2011-12-09 Pavel Tisnovsky <ptisnovs at redhat.com>

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Fri Dec 9 05:20:32 PST 2011


changeset b8eeeed237a2 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=b8eeeed237a2
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Fri Dec 09 14:21:10 2011 +0100

	2011-12-09 Pavel Tisnovsky <ptisnovs at redhat.com>

	 * src/org/gfxtest/framework/CommonPathsGenerator.java:
	Added methods for tests which use cubic paths.
	        * src/org/gfxtest/framework/CubicCurvePointSet.java: New
	static method used by tests.


diffstat:

 ChangeLog                                           |    7 +
 src/org/gfxtest/framework/CommonPathsGenerator.java |  346 +++++++++++++++++++-
 src/org/gfxtest/framework/CubicCurvePointSet.java   |   15 +-
 3 files changed, 364 insertions(+), 4 deletions(-)

diffs (407 lines):

diff -r f1181d8e0365 -r b8eeeed237a2 ChangeLog
--- a/ChangeLog	Thu Dec 08 11:57:09 2011 +0100
+++ b/ChangeLog	Fri Dec 09 14:21:10 2011 +0100
@@ -1,3 +1,10 @@
+2011-12-09  Pavel Tisnovsky  <ptisnovs at redhat.com>
+
+	* src/org/gfxtest/framework/CommonPathsGenerator.java:
+	Added methods for tests which use cubic paths.
+	* src/org/gfxtest/framework/CubicCurvePointSet.java:
+	New static method used by tests.
+
 2011-12-08  Pavel Tisnovsky  <ptisnovs at redhat.com>
 
 	* src/org/gfxtest/framework/CommonPathsGenerator.java:
diff -r f1181d8e0365 -r b8eeeed237a2 src/org/gfxtest/framework/CommonPathsGenerator.java
--- a/src/org/gfxtest/framework/CommonPathsGenerator.java	Thu Dec 08 11:57:09 2011 +0100
+++ b/src/org/gfxtest/framework/CommonPathsGenerator.java	Fri Dec 09 14:21:10 2011 +0100
@@ -52,7 +52,7 @@
 public class CommonPathsGenerator
 {
     /**
-     * Default Y offset of curve end points.
+     * Default Y offset of quadratic curve end points.
      */
     private static final int DEFAULT_Y_OFFSET_FOR_QUADRATIC_CURVES = 40;
 
@@ -145,6 +145,350 @@
     }
 
     /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            test image
+     * @return created path
+     */
+    public static Path2D createCubicPathFloat(TestImage image)
+    {
+        // compute image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // construct path containing cubic curve
+        return createCubicPathFloat(width, height);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @return created path
+     */
+    public static Path2D createCubicPathFloat(int width, int height)
+    {
+        // construct path containing cubic curve
+        return createCubicPathFloat(width, height, new int[] {1,2,3,4});
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param pointIndexes 
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return created path
+     */
+    public static Path2D createCubicPathFloat(int width, int height, int[] pointIndexes)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(width, height);
+
+        // fill in arrays containing coordinates for all cubic curve control points
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        // construct path containing cubic curve
+        return createCubicPathFloat(width, height, x, y, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            test image
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    public static Path2D createCubicPathFloat(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        // compute image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // construct path containing cubic curve
+        return createCubicPathFloat(width, height, xarray, yarray, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    public static Path2D createCubicPathFloat(int width, int height, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        // construct path containing cubic curve
+        return createCubicPathFloat(width, height, xarray, yarray, pointIndexes, 0);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    public static Path2D createCubicPathFloat(int width, int height, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // construct path containing cubic curve
+        Path2D path = new Path2D.Float();
+        path.moveTo(xarray[pointIndexes[0]-1], yarray[pointIndexes[0]-1] + yoffset);
+        path.curveTo(xarray[pointIndexes[1]-1], yarray[pointIndexes[1]-1] + yoffset,
+                     xarray[pointIndexes[2]-1], yarray[pointIndexes[2]-1] + yoffset,
+                     xarray[pointIndexes[3]-1], yarray[pointIndexes[3]-1] + yoffset);
+        return path;
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic curve.
+     * 
+     * @param image
+     *            test image
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    public static Path2D createCubicPathFloat(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // create and return the path
+        return createCubicPathFloat(width, height, xarray, yarray, pointIndexes, yoffset);
+    }
+
+    /**
+     * Create new path using Path2D.Float() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            test image
+     * @return created path
+     */
+    public static Path2D createCubicPathDouble(TestImage image)
+    {
+        // compute image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // construct path containing cubic curve
+        return createCubicPathDouble(width, height);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @return created path
+     */
+    public static Path2D createCubicPathDouble(int width, int height)
+    {
+        // construct path containing cubic curve
+        return createCubicPathDouble(width, height, new int[] {1,2,3,4});
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param pointIndexes 
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return created path
+     */
+    public static Path2D createCubicPathDouble(int width, int height, int[] pointIndexes)
+    {
+        // construct point set which consists of all four curve control points
+        CubicCurvePointSet pointSet = new CubicCurvePointSet(width, height);
+
+        // fill in arrays containing coordinates for all cubic curve control points
+        int[] x = pointSet.getXPointArray();
+        int[] y = pointSet.getYPointArray();
+
+        // construct path containing cubic curve
+        return createCubicPathDouble(width, height, x, y, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param image
+     *            test image
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    public static Path2D createCubicPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        // compute image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // construct path containing cubic curve
+        return createCubicPathDouble(width, height, xarray, yarray, pointIndexes);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @return
+     */
+    public static Path2D createCubicPathDouble(int width, int height, int[] xarray, int[] yarray, int[] pointIndexes)
+    {
+        return createCubicPathDouble(width, height, xarray, yarray, pointIndexes, 0);
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic
+     * curve.
+     * 
+     * @param width
+     *            canvas width
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    public static Path2D createCubicPathDouble(int width, int height, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // construct path containing cubic curve
+        Path2D path = new Path2D.Double();
+        path.moveTo(xarray[pointIndexes[0]-1], yarray[pointIndexes[0]-1] + yoffset);
+        path.curveTo(xarray[pointIndexes[1]-1], yarray[pointIndexes[1]-1] + yoffset,
+                     xarray[pointIndexes[2]-1], yarray[pointIndexes[2]-1] + yoffset,
+                     xarray[pointIndexes[3]-1], yarray[pointIndexes[3]-1] + yoffset);
+        return path;
+    }
+
+    /**
+     * Create new path using Path2D.Double() which contains just one cubic curve.
+     * 
+     * @param image
+     *            test image
+     * @param height
+     *            canvas height
+     * @param xarray
+     *            array containing x coordinates of all four control points of
+     *            cubic curve
+     * @param yarray
+     *            array containing y coordinates of all four control points of
+     *            cubic curve
+     * @param pointIndexes
+     *            indexes of control point to use to draw the curve (default
+     *            value should be {1,2,3,4})
+     * @param yoffset
+     *            offset for all y-coordinates
+     * @return
+     */
+    public static Path2D createCubicPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+    {
+        // image dimensions
+        int width = image.getWidth();
+        int height = image.getHeight();
+        // create and return the path
+        return createCubicPathDouble(width, height, xarray, yarray, pointIndexes, yoffset);
+    }
+
+    /**
      * Compute X coordinate of first curve end point.
      * 
      * @param width
diff -r f1181d8e0365 -r b8eeeed237a2 src/org/gfxtest/framework/CubicCurvePointSet.java
--- a/src/org/gfxtest/framework/CubicCurvePointSet.java	Thu Dec 08 11:57:09 2011 +0100
+++ b/src/org/gfxtest/framework/CubicCurvePointSet.java	Fri Dec 09 14:21:10 2011 +0100
@@ -69,14 +69,23 @@
      * Constructor which computes all four control points from the dimensions of
      * test image.
      *
-     * @param image
+     * @param image test image
      */
     public CubicCurvePointSet(TestImage image)
     {
         // compute width and height of test image
-        int width = image.getWidth();
-        int height = image.getHeight();
+        this(image.getWidth(), image.getHeight());
+    }
 
+    /**
+     * Constructor which computes all four control points from the dimensions of
+     * test image.
+     *
+     * @param width image width
+     * @param height image height
+     */
+    public CubicCurvePointSet(int width, int height)
+    {
         // compute control points coordinates
         this.x[0] = computeX1(width);
         this.y[0] = computeY1();



More information about the distro-pkg-dev mailing list