/hg/gfx-test: * src/org/gfxtest/common/Configuration.java: Added...

ptisnovs at icedtea.classpath.org ptisnovs at icedtea.classpath.org
Wed Aug 17 03:59:26 PDT 2011


changeset db95c4ecbdfc in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=db95c4ecbdfc
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Wed Aug 17 13:01:08 2011 +0200

	* src/org/gfxtest/common/Configuration.java: Added JavaDoc.
	* src/org/gfxtest/framework/CommonRenderingStyles.java: Added new
	helper methods for rendering using transparent colors.
	* src/org/gfxtest/framework/CommonShapesRenrered.java: Fixed
	rendering of closed path
	* src/org/gfxtest/framework/ColorPaint.java: Added new test cases.


diffstat:

 ChangeLog                                            |   11 +
 src/org/gfxtest/common/Configuration.java            |   44 +-
 src/org/gfxtest/framework/CommonRenderingStyles.java |   71 ++
 src/org/gfxtest/framework/CommonShapesRenderer.java  |   11 +-
 src/org/gfxtest/testsuites/ColorPaint.java           |  575 ++++++++----------
 5 files changed, 401 insertions(+), 311 deletions(-)

diffs (truncated from 926 to 500 lines):

diff -r d09593767afc -r db95c4ecbdfc ChangeLog
--- a/ChangeLog	Tue Aug 16 12:00:43 2011 +0200
+++ b/ChangeLog	Wed Aug 17 13:01:08 2011 +0200
@@ -1,3 +1,14 @@
+2011-08-17  Pavel Tisnovsky  <ptisnovs at redhat.com>
+	* src/org/gfxtest/common/Configuration.java:
+	Added JavaDoc.
+	* src/org/gfxtest/framework/CommonRenderingStyles.java:
+	Added new helper methods for rendering using transparent colors.
+	* src/org/gfxtest/framework/CommonShapesRenrered.java:
+	Fixed rendering of closed path - the path now consists of line
+	segments, quadratic curves and cubic curves.
+	* src/org/gfxtest/framework/ColorPaint.java:
+	Added new test cases.
+
 2011-08-16  Pavel Tisnovsky  <ptisnovs at redhat.com>
 	* src/org/gfxtest/testsuites/BlankImage.java:
 	Added new test cases (rendering using transparency etc.), added
diff -r d09593767afc -r db95c4ecbdfc src/org/gfxtest/common/Configuration.java
--- a/src/org/gfxtest/common/Configuration.java	Tue Aug 16 12:00:43 2011 +0200
+++ b/src/org/gfxtest/common/Configuration.java	Wed Aug 17 13:01:08 2011 +0200
@@ -46,10 +46,12 @@
 import org.gfxtest.framework.Log;
 import org.gfxtest.framework.ParameterNotFoundException;
 
+
+
 /**
  * This class is used to store actual configuration of graphics test framework.
  * Configuration can be changed via command line switches.
- *
+ * 
  * @author Pavel Tisnovsky
  */
 public abstract class Configuration
@@ -59,6 +61,16 @@
      */
     protected Log log;
 
+    /**
+     * Constructor called with array containing command line arguments.
+     * 
+     * @param args
+     *            command line arguments
+     * @param log
+     *            instance of logger class
+     * @throws ConfigurationException
+     *             in case configuration is wrong
+     */
     public Configuration(String[] args, Log log) throws ConfigurationException
     {
         this.log = log;
@@ -71,6 +83,16 @@
     protected abstract void readCommandLineParameters(String[] args) throws ConfigurationException;
     protected abstract void printParameters();
 
+    /**
+     * Method for get value of parameter which has integer value.
+     * 
+     * @param options
+     *            map containing all parameters
+     * @param parameterName
+     *            parameter name
+     * @return integer value of selected parameter
+     * @throws ConfigurationException
+     */
     protected int getIntegerParameter(Map<String, String> options, String parameterName) throws ConfigurationException
     {
         if (!options.containsKey(parameterName))
@@ -88,7 +110,18 @@
         }
     }
 
-    protected String getStringParameter(Map<String, String> options, String parameterName) throws ConfigurationException
+    /**
+     * Method for get value of parameter which has string value.
+     * 
+     * @param options
+     *            map containing all parameters
+     * @param parameterName
+     *            parameter name
+     * @return string value of selected parameter
+     * @throws ConfigurationException
+     */
+    protected String getStringParameter(Map<String, String> options, String parameterName)
+                    throws ConfigurationException
     {
         if (!options.containsKey(parameterName))
         {
@@ -97,6 +130,13 @@
         return options.get(parameterName);
     }
 
+    /**
+     * Resolve all configuration options, ie. parse it and push it to a map.
+     * 
+     * @param args
+     *            command line parameters
+     * @return map containing all parameters
+     */
     @SuppressWarnings("nls")
     protected Map<String, String> resolveAllOptions(String[] args)
     {
diff -r d09593767afc -r db95c4ecbdfc src/org/gfxtest/framework/CommonRenderingStyles.java
--- a/src/org/gfxtest/framework/CommonRenderingStyles.java	Tue Aug 16 12:00:43 2011 +0200
+++ b/src/org/gfxtest/framework/CommonRenderingStyles.java	Wed Aug 17 13:01:08 2011 +0200
@@ -97,6 +97,77 @@
     }
 
     /**
+     * Make sure the transparency is within given bounds 0.0-1.0
+     * 
+     * @param transparency
+     *            color transparency
+     * @return transparency in bounds 0.0-1.0
+     */
+    private static float transparencyToBounds(float transparency)
+    {
+        return transparency < 0.f ? 0.f : transparency > 1.f ? 1.f : transparency;
+    }
+
+    /**
+     * Set transparent color.
+     * 
+     * @param graphics
+     *            graphics context for image
+     * @param color
+     *            color without transparency
+     * @param transparency
+     *            color transparency represented in percents (0..100)
+     */
+    public static void setTransparentFillColor(Graphics2D graphics, Color color, int transparency)
+    {
+        float[] rgb = color.getRGBColorComponents(null);
+        float value = transparencyToBounds(transparency / 100.0f);
+        graphics.setPaint(new Color(rgb[0], rgb[1], rgb[2], value));
+    }
+
+    /**
+     * Set transparent red color.
+     * 
+     * @param graphics
+     *            graphics context for image
+     * @param transparency
+     *            color transparency represented in percents (0..100)
+     */
+    public static void setTransparentFillRedColor(Graphics2D graphics, int transparency)
+    {
+        float value = transparencyToBounds(transparency / 100.0f);
+        graphics.setPaint(new Color(1.0f, 0.0f, 0.0f, value));
+    }
+
+    /**
+     * Set transparent green color.
+     * 
+     * @param graphics
+     *            graphics context for image
+     * @param transparency
+     *            color transparency represented in percents (0..100)
+     */
+    public static void setTransparentFillGreenColor(Graphics2D graphics, int transparency)
+    {
+        float value = transparencyToBounds(transparency / 100.0f);
+        graphics.setPaint(new Color(0.0f, 1.0f, 0.0f, value));
+    }
+
+    /**
+     * Set transparent blue color.
+     * 
+     * @param graphics
+     *            graphics context for image
+     * @param transparency
+     *            color transparency represented in percents (0..100)
+     */
+    public static void setTransparentFillBlueColor(Graphics2D graphics, int transparency)
+    {
+        float value = transparencyToBounds(transparency / 100.0f);
+        graphics.setPaint(new Color(0.0f, 0.0f, 1.0f, value));
+    }
+
+    /**
      * Set zero pixels wide stroke and default cap and join style.
      * 
      * @param graphics
diff -r d09593767afc -r db95c4ecbdfc src/org/gfxtest/framework/CommonShapesRenderer.java
--- a/src/org/gfxtest/framework/CommonShapesRenderer.java	Tue Aug 16 12:00:43 2011 +0200
+++ b/src/org/gfxtest/framework/CommonShapesRenderer.java	Wed Aug 17 13:01:08 2011 +0200
@@ -294,20 +294,23 @@
 
         // construct closed path
         Path2D path = new Path2D.Float();
-        path.moveTo(GfxTest.OFFSET, GfxTest.OFFSET);
+        path.moveTo(GfxTest.OFFSET, h - GfxTest.OFFSET);
+        path.quadTo(GfxTest.OFFSET, GfxTest.OFFSET, w >> 1, GfxTest.OFFSET);
         path.quadTo(w - GfxTest.OFFSET, GfxTest.OFFSET, w - GfxTest.OFFSET, h - GfxTest.OFFSET);
-        path.quadTo(GfxTest.OFFSET, h - GfxTest.OFFSET, w >> 1, h >> 1);
+        path.curveTo(w >> 1, GfxTest.OFFSET, w >> 1, h - GfxTest.OFFSET, GfxTest.OFFSET, h - GfxTest.OFFSET);
         path.closePath();
 
         // draw the closed path
         graphics.fill(path);
 
         // draw crosses at interesting points of image
+        drawCross(graphics, GfxTest.OFFSET, h - GfxTest.OFFSET);
         drawCross(graphics, GfxTest.OFFSET, GfxTest.OFFSET);
+        drawCross(graphics, w >> 1, GfxTest.OFFSET);
         drawCross(graphics, w - GfxTest.OFFSET, GfxTest.OFFSET);
         drawCross(graphics, w - GfxTest.OFFSET, h - GfxTest.OFFSET);
-        drawCross(graphics, GfxTest.OFFSET, h - GfxTest.OFFSET);
-        drawCross(graphics, w >> 1, h >> 1);
+        drawCross(graphics, w >> 1, GfxTest.OFFSET);
+        drawCross(graphics, w >> 1, h - GfxTest.OFFSET);
     }
  
 }
diff -r d09593767afc -r db95c4ecbdfc src/org/gfxtest/testsuites/ColorPaint.java
--- a/src/org/gfxtest/testsuites/ColorPaint.java	Tue Aug 16 12:00:43 2011 +0200
+++ b/src/org/gfxtest/testsuites/ColorPaint.java	Wed Aug 17 13:01:08 2011 +0200
@@ -40,10 +40,8 @@
 
 package org.gfxtest.testsuites;
 
-import java.awt.BasicStroke;
 import java.awt.Color;
 import java.awt.Graphics2D;
-import java.awt.geom.Path2D;
 
 
 
@@ -62,286 +60,28 @@
 public class ColorPaint extends GfxTest
 {
     /**
-     * Stroke width used for drawing "thick" curves.
-     */
-    private static final int STROKE_WIDTH_THICK = 10;
-
-    /**
-     * Stroke width used for drawing extra "thick" curves.
-     */
-    private static final int STROKE_WIDTH_EXTRA_THICK = 30;
-
-    /**
-     * Default stroke color.
-     */
-    private static final Color DEFAULT_STROKE_COLOR = Color.BLACK;
-
-    /**
-     * Default fill color.
-     */
-    private static final Color DEFAULT_FILL_COLOR = Color.GREEN.darker();
-
-    /**
-     * Radius of round rectangle.
-     */
-    private static final int ROUND_RECT_RADIUS = 80;
-
-    /**
-     * Draw circle onto the graphics canvas.
+     * This method renders transparent circle using given color and transparency
      * 
      * @param image
      *            image to which two dimensional shape is to be rendered
      * @param graphics
      *            graphics context for image
+     * @param color
+     *            circle fill color
+     * @param transparency
+     *            circle fill color transparency
+     * @return test result status - PASSED, FAILED or ERROR
      */
-    private void drawCircle(TestImage image, Graphics2D graphics)
+    private static TestResult renderTransparentCircle(TestImage image, Graphics2D graphics, Color color, int transparency)
     {
-        // calculate center of the image
-        int xc = image.getCenterX();
-        int yc = image.getCenterY();
-        
-        // calculate radius of circle
-        int radius = calculateRadius(image);
-        
+        // set stroke color
+        CommonRenderingStyles.setStrokeColor(graphics);
+        // set fill color
+        CommonRenderingStyles.setTransparentFillColor(graphics, color, transparency);
         // draw the circle
-        graphics.drawOval(xc - radius, yc - radius, radius << 1, radius << 1);
-
-        // draw crosses at interesting points of image
-        drawCrossesForBasicShapes(graphics, xc, yc, radius);
-    }
-
-    /**
-     * Calculate radius of circle/arc/rectangle based on image size.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @return radius
-     */
-    private int calculateRadius(TestImage image)
-    {
-        return Math.min(image.getWidth(), image.getHeight()) / 3;
-    }
-
-    /**
-     * Draw crosses at interesting points of image.
-     *
-     * @param graphics
-     *            graphics context for image
-     * @param xc center of image
-     * @param yc center of image
-     * @param radius radius of shape(s)
-     */
-    private void drawCrossesForBasicShapes(Graphics2D graphics, int xc, int yc, int radius)
-    {
-        // move in vertical direction
-        for (int y = yc - radius; y <= yc + radius; y += radius)
-        {
-            // move in horizontal direction
-            for (int x = xc - radius; x <= xc + radius; x += radius)
-            {
-                drawCross(graphics, x, y);
-            }
-        }
-    }
-
-    /**
-     * Draw filled circle onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledCircle(TestImage image, Graphics2D graphics)
-    {
-        // calculate center of the image
-        int xc = image.getCenterX();
-        int yc = image.getCenterY();
-        
-        // calculate radius of circle
-        int radius = calculateRadius(image);
-        
-        // draw the filled circle
-        graphics.fillOval(xc - radius, yc - radius, radius << 1, radius << 1);
-
-        // draw crosses at interesting points of image
-        drawCrossesForBasicShapes(graphics, xc, yc, radius);
-    }
-
-    /**
-     * Draw filled arc onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledArc(TestImage image, Graphics2D graphics)
-    {
-        // calculate center of the image
-        int xc = image.getCenterX();
-        int yc = image.getCenterY();
-        
-        // calculate radius of circle
-        int radius = calculateRadius(image);
-        
-        // draw the filled arc
-        graphics.fillArc(xc - radius, yc - radius, radius << 1, radius << 1, 0, 135 + 180);
-
-        // draw crosses at interesting points of image
-        drawCrossesForBasicShapes(graphics, xc, yc, radius);
-    }
-
-    /**
-     * Draw filled rectangle onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledRect(TestImage image, Graphics2D graphics)
-    {
-        // calculate center of the image
-        int xc = image.getCenterX();
-        int yc = image.getCenterY();
-
-        // calculate radius of circle
-        int radius = calculateRadius(image);
-
-        // draw the filled rectangle
-        graphics.fillRect(xc - radius, yc - radius, radius << 1, radius << 1);
-
-        // draw crosses at interesting points of image
-        drawCrossesForBasicShapes(graphics, xc, yc, radius);
-    }
-
-    /**
-     * Draw filled rounded rectangle onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledRoundRect(TestImage image, Graphics2D graphics)
-    {
-        // calculate center of the image
-        int xc = image.getCenterX();
-        int yc = image.getCenterY();
-
-        // calculate radius of circle
-        int radius = calculateRadius(image);
-
-        // draw the filled rectangle round rectangle
-        graphics.fillRoundRect(xc - radius, yc - radius, radius << 1, radius << 1, ROUND_RECT_RADIUS, ROUND_RECT_RADIUS);
-
-        // draw crosses at interesting points of image
-        drawCrossesForBasicShapes(graphics, xc, yc, radius);
-    }
-
-    /**
-     * Draw filled polygon onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledPolygon(TestImage image, Graphics2D graphics)
-    {
-        // calculate image size
-        int w = image.getWidth();
-        int h = image.getHeight();
-
-        // polygon vertexes
-        int xPoints[] = new int[] { OFFSET, w >> 1, w >> 1, w - OFFSET };
-        int yPoints[] = new int[] { h >> 1, OFFSET, h - OFFSET, h >> 1 };
-
-        // draw the polygon
-        graphics.fillPolygon(xPoints, yPoints, xPoints.length);
-
-        // draw crosses at interesting points of image
-        drawCross(graphics, OFFSET, h >> 1, CROSS_SIZE);
-        drawCross(graphics, w >> 1, OFFSET, CROSS_SIZE);
-        drawCross(graphics, w >> 1, h - OFFSET, CROSS_SIZE);
-        drawCross(graphics, w - OFFSET, h >> 1, CROSS_SIZE);
-    }
-
-    /**
-     * Draw filled closed path onto the graphics canvas.
-     * 
-     * @param image
-     *            image to which two dimensional shape is to be rendered
-     * @param graphics
-     *            graphics context for image
-     */
-    private void drawFilledClosedPath(TestImage image, Graphics2D graphics)
-    {
-        // calculate image size
-        int w = image.getWidth();
-        int h = image.getHeight();
-
-        // construct closed path
-        Path2D path = new Path2D.Float();
-        path.moveTo(OFFSET, OFFSET);
-        path.quadTo(w - OFFSET, OFFSET, w - OFFSET, h - OFFSET);
-        path.quadTo(OFFSET, h - OFFSET, w >> 1, h >> 1);
-        path.closePath();
-
-        // draw the closed path
-        graphics.fill(path);
-
-        // draw crosses at interesting points of image
-        drawCross(graphics, OFFSET, OFFSET);
-        drawCross(graphics, w - OFFSET, OFFSET);
-        drawCross(graphics, w - OFFSET, h - OFFSET);
-        drawCross(graphics, OFFSET, h - OFFSET);
-        drawCross(graphics, w >> 1, h >> 1);
-    }
-
-    /**
-     * Set default stroke color.
-     * 
-     * @param graphics
-     *            graphics context for image
-     */
-    private void setStrokeColor(Graphics2D graphics)
-    {
-        graphics.setColor(DEFAULT_STROKE_COLOR);
-    }
-
-    /**
-     * Set default fill color.
-     *
-     * @param graphics
-     *            graphics context for image
-     */
-    private void setFillColor(Graphics2D graphics)



More information about the distro-pkg-dev mailing list