/hg/gfx-test: 2011-12-13 Pavel Tisnovsky <ptisnovs at redhat.com>
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Tue Dec 13 02:20:05 PST 2011
changeset d55fc8062bd9 in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=d55fc8062bd9
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Tue Dec 13 11:22:19 2011 +0100
2011-12-13 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java:
Added about twenty new tests to this test case.
diffstat:
ChangeLog | 5 +
src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java | 958 +++++++++++---
2 files changed, 730 insertions(+), 233 deletions(-)
diffs (truncated from 1288 to 500 lines):
diff -r 2b1aa77d67de -r d55fc8062bd9 ChangeLog
--- a/ChangeLog Mon Dec 12 12:31:21 2011 +0100
+++ b/ChangeLog Tue Dec 13 11:22:19 2011 +0100
@@ -1,3 +1,8 @@
+2011-12-13 Pavel Tisnovsky <ptisnovs at redhat.com>
+
+ * src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java:
+ Added about twenty new tests to this test case.
+
2011-12-12 Pavel Tisnovsky <ptisnovs at redhat.com>
* src/org/gfxtest/testsuites/ClippingPathByRectangleArea.java:
diff -r 2b1aa77d67de -r d55fc8062bd9 src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java
--- a/src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java Mon Dec 12 12:31:21 2011 +0100
+++ b/src/org/gfxtest/testsuites/NormalCubicCurvesAsPaths.java Tue Dec 13 11:22:19 2011 +0100
@@ -63,10 +63,11 @@
@Zoom(1)
public class NormalCubicCurvesAsPaths extends GfxTest
{
+
/**
- * Default Y offset of curve end points.
+ * Default Y offset of cubic curve end points.
*/
- private static final int DEFAULT_Y_OFFSET = -20;
+ private static final int DEFAULT_Y_OFFSET_FOR_CUBIC_CURVES = -20;
/**
* Step between curves drawn by different colors onto the same image.
@@ -179,7 +180,7 @@
* @param graphics
* graphics canvas
*/
- private void drawCurveWithVariousColors(TestImage image, Graphics2D graphics)
+ private void drawCurveWithVariousColorsFloat(TestImage image, Graphics2D graphics)
{
// construct point set which consists of all four curve control points
CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
@@ -192,13 +193,54 @@
Color[] colors = ColorPalette.getColors();
// offset counter
- int offset = DEFAULT_Y_OFFSET;
+ int offset = DEFAULT_Y_OFFSET_FOR_CUBIC_CURVES;
// Draw each curve with different color.
for (Color color : colors)
{
// create new path
- Path2D path = createPathFloat(image, xarray, yarray, new int[] {1,2,3,4}, offset);
+ Path2D path = CommonPathsGenerator.createCubicPathFloat(image, xarray, yarray, new int[] {1,2,3,4}, offset);
+
+ // set the specified color
+ graphics.setColor(color);
+
+ // draw QuadCurve2D
+ graphics.draw(path);
+
+ // move next curve down
+ offset += OFFSET_STEP;
+ }
+ }
+
+ /**
+ * Draw set of cubic curves onto canvas specified by Graphics2D class.
+ * Curves are drawn using various colors.
+ *
+ * @param image
+ * image to which two dimensional shape is to be rendered
+ * @param graphics
+ * graphics canvas
+ */
+ private void drawCurveWithVariousColorsDouble(TestImage image, Graphics2D graphics)
+ {
+ // construct point set which consists of all four curve control points
+ CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
+
+ // fill in arrays containing coordinates for all cubic curve control points
+ int[] xarray = pointSet.getXPointArray();
+ int[] yarray = pointSet.getYPointArray();
+
+ // curve colors
+ Color[] colors = ColorPalette.getColors();
+
+ // offset counter
+ int offset = DEFAULT_Y_OFFSET_FOR_CUBIC_CURVES;
+
+ // Draw each curve with different color.
+ for (Color color : colors)
+ {
+ // create new path
+ Path2D path = CommonPathsGenerator.createCubicPathDouble(image, xarray, yarray, new int[] {1,2,3,4}, offset);
// set the specified color
graphics.setColor(color);
@@ -220,7 +262,7 @@
* @param graphics
* graphics canvas
*/
- private void drawCurveWithVariousTransparency(TestImage image, Graphics2D graphics)
+ private void drawCurveWithVariousTransparencyFloat(TestImage image, Graphics2D graphics)
{
// construct point set which consists of all four curve control points
CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
@@ -230,13 +272,13 @@
int[] yarray = pointSet.getYPointArray();
// offset counter
- int offset = DEFAULT_Y_OFFSET;
+ int offset = DEFAULT_Y_OFFSET_FOR_CUBIC_CURVES;
// Draw each curve with transparency
for (int transparency = 0; transparency < 16; transparency++)
{
// create new path
- Path2D path = createPathFloat(image, xarray, yarray, new int[] {1,2,3,4}, offset);
+ Path2D path = CommonPathsGenerator.createCubicPathFloat(image, xarray, yarray, new int[] {1,2,3,4}, offset);
// set the specified color
graphics.setColor(new Color(0f, 0f, 0f, transparency / 16f));
@@ -250,183 +292,77 @@
}
/**
- * Create new path using Path2D.Float() which contains just one cubic curve.
+ * Draw set of cubic curves onto canvas specified by Graphics2D class.
+ * Curves are drawn using various transparency.
*
* @param image
* image to which two dimensional shape is to be rendered
- * @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
+ * @param graphics
+ * graphics canvas
*/
- private Path2D createPathFloat(TestImage image, 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
- * image to which two dimensional shape is to be rendered
- * @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
- */
- private Path2D createPathFloat(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
- {
- // construct path containing cubic curve
- return createPathFloat(image, xarray, yarray, pointIndexes, 0);
- }
-
- /**
- * Create new path using Path2D.Float() which contains just one cubic
- * curve.
- *
- * @param image
- * image to which two dimensional shape is to be rendered
- * @param pointIndexes
- * indexes of control point to use to draw the curve (default
- * value should be {1,2,3,4})
- * @return created path
- */
- private Path2D createPathFloat(TestImage image, int[] pointIndexes)
+ private void drawCurveWithVariousTransparencyDouble(TestImage image, Graphics2D graphics)
{
// construct point set which consists of all four curve control points
CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
// fill in arrays containing coordinates for all cubic curve control points
- int[] x = pointSet.getXPointArray();
- int[] y = pointSet.getYPointArray();
+ int[] xarray = pointSet.getXPointArray();
+ int[] yarray = pointSet.getYPointArray();
- // construct path containing cubic curve
- return createPathFloat(image, x, y, pointIndexes);
+ // offset counter
+ int offset = DEFAULT_Y_OFFSET_FOR_CUBIC_CURVES;
+
+ // Draw each curve with transparency
+ for (int transparency = 0; transparency < 16; transparency++)
+ {
+ // create new path
+ Path2D path = CommonPathsGenerator.createCubicPathDouble(image, xarray, yarray, new int[] {1,2,3,4}, offset);
+
+ // set the specified color
+ graphics.setColor(new Color(0f, 0f, 0f, transparency / 16f));
+
+ // draw QuadCurve2D
+ graphics.draw(path);
+
+ // move next curve down
+ offset += OFFSET_STEP;
+ }
}
/**
- * Create new path using Path2D.Float() which contains just one cubic
- * curve.
+ * Create cubic cube and draw it.
*
* @param image
* image to which two dimensional shape is to be rendered
- * @return created path
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
*/
- private Path2D createPathFloat(TestImage image)
+ private TestResult createAndDrawPathFloat(TestImage image, Graphics2D graphics)
{
- // construct path containing cubic curve
- return createPathFloat(image, new int[] {1,2,3,4});
+ // create new path
+ Path2D path = CommonPathsGenerator.createCubicPathFloat(image);
+
+ // draw path
+ return drawPath(image, graphics, path);
}
/**
- * Create new path using Path2D.Double() which contains just one cubic
- * curve.
+ * Create cubic cube and draw it.
*
* @param image
* image to which two dimensional shape is to be rendered
- * @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
+ * @param graphics
+ * graphics context for image
+ * @return test result status - PASSED, FAILED or ERROR
*/
- private Path2D createPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes, int yoffset)
+ private TestResult createAndDrawPathDouble(TestImage image, Graphics2D graphics)
{
- // 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
+ Path2D path = CommonPathsGenerator.createCubicPathDouble(image);
- /**
- * Create new path using Path2D.Double() which contains just one cubic
- * curve.
- *
- * @param image
- * image to which two dimensional shape is to be rendered
- * @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
- */
- private Path2D createPathDouble(TestImage image, int[] xarray, int[] yarray, int[] pointIndexes)
- {
- return createPathDouble(image, xarray, yarray, pointIndexes, 0);
- }
-
- /**
- * Create new path using Path2D.Double() which contains just one cubic
- * curve.
- *
- * @param image
- * image to which two dimensional shape is to be rendered
- * @param pointIndexes
- * indexes of control point to use to draw the curve (default
- * value should be {1,2,3,4})
- * @return created path
- */
- private Path2D createPathDouble(TestImage image, int[] pointIndexes)
- {
- // construct point set which consists of all four curve control points
- CubicCurvePointSet pointSet = new CubicCurvePointSet(image);
-
- // 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 createPathDouble(image, x, y, pointIndexes);
- }
-
- /**
- * Create new path using Path2D.Double() which contains just one cubic
- * curve.
- *
- * @param image
- * image to which two dimensional shape is to be rendered
- * @return created path
- */
- private Path2D createPathDouble(TestImage image)
- {
- // construct path containing cubic curve
- return createPathDouble(image, new int[] {1,2,3,4});
+ // draw path
+ return drawPath(image, graphics, path);
}
/**
@@ -441,7 +377,7 @@
public TestResult testBasicCubicCurveFloat(TestImage image, Graphics2D graphics)
{
// create cubic curve and draw it
- Path2D path = createPathFloat(image);
+ Path2D path = CommonPathsGenerator.createCubicPathFloat(image);
return drawPath(image, graphics, path);
}
@@ -457,7 +393,7 @@
public TestResult testBasicCubicCurveDouble(TestImage image, Graphics2D graphics)
{
// create cubic curve and draw it
- Path2D path = createPathDouble(image);
+ Path2D path = CommonPathsGenerator.createCubicPathDouble(image);
return drawPath(image, graphics, path);
}
@@ -472,14 +408,153 @@
* graphics context for image
* @return test result status - PASSED, FAILED or ERROR
*/
- public TestResult testZeroStroke(TestImage image, Graphics2D graphics)
+ public TestResult testZeroStrokeFloat(TestImage image, Graphics2D graphics)
{
// set zero pixels wide stroke
CommonRenderingStyles.setStrokeZeroThick(graphics);
// create cubic curve and draw it
- Path2D path = createPathFloat(image);
- return drawPath(image, graphics, path);
+ return createAndDrawPathFloat(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Float() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and default
+ * caps.
+ *
+ * @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 testZeroStrokeDouble(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics);
+
+ // create cubic curve and draw it
+ return createAndDrawPathDouble(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Float() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and butt
+ * caps.
+ *
+ * @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 testZeroStrokeCapsButtFloat(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics, BasicStroke.CAP_BUTT);
+
+ // create cubic path and draw it
+ return createAndDrawPathFloat(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Double() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and butt
+ * caps.
+ *
+ * @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 testZeroStrokeCapsButtDouble(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics, BasicStroke.CAP_BUTT);
+
+ // create cubic path and draw it
+ return createAndDrawPathDouble(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Float() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and round
+ * caps.
+ *
+ * @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 testZeroStrokeCapsRoundFloat(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics, BasicStroke.CAP_ROUND);
+
+ // create cubic path and draw it
+ return createAndDrawPathFloat(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Double() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and default
+ * caps.
+ *
+ * @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 testZeroStrokeCapsRoundDouble(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics, BasicStroke.CAP_ROUND);
+
+ // create cubic path and draw it
+ return createAndDrawPathDouble(image, graphics);
+ }
+
+ /**
+ * Test if cubic curve created by Path2D.Float() is rendered
+ * correctly. Curve is to be drawn with zero pixels wide stroke and square
+ * caps.
+ *
+ * @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 testZeroStrokeCapsSquareFloat(TestImage image, Graphics2D graphics)
+ {
+ // set zero pixels wide stroke
+ CommonRenderingStyles.setStrokeZeroThick(graphics, BasicStroke.CAP_SQUARE);
+
+ // create cubic path and draw it
+ return createAndDrawPathFloat(image, graphics);
More information about the distro-pkg-dev
mailing list