/hg/gfx-test: Changed generation of various rendering styles for...
ptisnovs at icedtea.classpath.org
ptisnovs at icedtea.classpath.org
Thu Jul 22 07:27:04 PDT 2010
changeset e6167048456f in /hg/gfx-test
details: http://icedtea.classpath.org/hg/gfx-test?cmd=changeset;node=e6167048456f
author: Pavel Tisnovsky <ptisnovs at redhat.com>
date: Thu Jul 22 16:27:18 2010 +0200
Changed generation of various rendering styles for common graphics
entities.
diffstat:
12 files changed, 136 insertions(+), 204 deletions(-)
TODO | 5 -
src/org/gfxtest/framework/EntityRenderingStyle.java | 51 +++++++++++++
src/org/gfxtest/framework/GfxTest.java | 65 ++++++++++++-----
src/org/gfxtest/testsuites/FilledCircles.java | 6 -
src/org/gfxtest/testsuites/FilledPolygons.java | 6 -
src/org/gfxtest/testsuites/FilledRectangles.java | 39 +---------
src/org/gfxtest/testsuites/FilledRoundRectangles.java | 39 +---------
src/org/gfxtest/testsuites/NormalArcs.java | 39 +---------
src/org/gfxtest/testsuites/NormalCircles.java | 6 -
src/org/gfxtest/testsuites/NormalPolygons.java | 6 -
src/org/gfxtest/testsuites/NormalRectangles.java | 39 +---------
src/org/gfxtest/testsuites/NormalRoundRectangles.java | 39 +---------
diffs (truncated from 595 to 500 lines):
diff -r ec0b1d456477 -r e6167048456f TODO
--- a/TODO Wed Jul 21 16:28:07 2010 +0200
+++ b/TODO Thu Jul 22 16:27:18 2010 +0200
@@ -3,15 +3,10 @@ DashedPolylines.java
DashedPolylines.java
DashedRectangles.java
FilledEllipses.java
-FilledRectangles.java
-FilledRoundRectangles.java
Normal3DRectangles.java
-NormalArcs.java
NormalEllipses.java
NormalLines.java
NormalPolylines.java
-NormalRectangles.java
-NormalRoundRectangles.java
ScaledLines.java
ScaledPolylines.java
ScaledRectangles.java
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/framework/EntityRenderingStyle.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/org/gfxtest/framework/EntityRenderingStyle.java Thu Jul 22 16:27:18 2010 +0200
@@ -0,0 +1,51 @@
+package org.gfxtest.framework;
+
+public class EntityRenderingStyle
+{
+ private int cap;
+ private int join;
+ private float width;
+ private float scale;
+ private int arcWidth;
+ private int arcHeight;
+
+ public EntityRenderingStyle(int cap, int join, float width, int arcWidth, int arcHeight)
+ {
+ this.cap = cap;
+ this.join = join;
+ this.width = width;
+ this.arcWidth = arcWidth;
+ this.arcHeight = arcHeight;
+ }
+
+ public int getCap()
+ {
+ return this.cap;
+ }
+
+ public int getJoin()
+ {
+ return this.join;
+ }
+
+ public float getWidth()
+ {
+ return this.width;
+ }
+
+ public float getScale()
+ {
+ return this.scale;
+ }
+
+ public int getArcWidth()
+ {
+ return this.arcWidth;
+ }
+
+ public int getArcHeight()
+ {
+ return this.arcHeight;
+ }
+
+}
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/framework/GfxTest.java
--- a/src/org/gfxtest/framework/GfxTest.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/framework/GfxTest.java Thu Jul 22 16:27:18 2010 +0200
@@ -63,6 +63,8 @@ public abstract class GfxTest
*/
protected static final int MAJOR_RADIUS = 100;
+ protected static final int RADIUS_STEP = 30;
+
/**
* Offset from image borders used for rendering various graphics entities, for example rectangles.
*/
@@ -108,6 +110,8 @@ public abstract class GfxTest
* All line or curve widths.
*/
protected static final float[] ALL_WIDTHS = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
+
+ private static final int ARC_STEP = 10;
/**
* Construct test suite name using full class name.
@@ -183,12 +187,17 @@ public abstract class GfxTest
*
* @param configuration configuration of current test case.
*/
- protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, float scale, float width, int cap, int join, float[] dash)
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
// to be overrided by test cases
}
protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash)
+ {
+ this.drawEntityWithVariousStyles(configuration, changeCap, changeJoin, changeWidth, changeScale, changeDash, 0, 0, 0, 0);
+ }
+
+ protected void drawEntityWithVariousStyles(Configuration configuration, boolean changeCap, boolean changeJoin, boolean changeWidth, boolean changeScale, boolean changeDash, int minArcWidth, int maxArcWidth, int minArcHeight, int maxArcHeight)
{
int[] caps = changeCap ? ALL_CAP_STYLES : DEFAULT_CAP_STYLE;
int[] joins = changeJoin ? ALL_JOIN_STYLES : DEFAULT_JOIN_STYLE;
@@ -200,26 +209,50 @@ public abstract class GfxTest
{
for (float width : widths)
{
- String testName = "test" + testNumber; //$NON-NLS-1$
- this.log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = image.getGraphics();
- /* TODO: add support to various scales and dashes */
- drawEntity(image, graphics, testNumber, 1.0f, width, cap, join, null);
- graphics.dispose();
- try
+ for (int arcHeight = minArcHeight; arcHeight <= maxArcHeight; arcHeight += ARC_STEP)
{
- image.writeImage(configuration, this.suiteName, testName);
+ for (int arcWidth = minArcWidth; arcWidth <= maxArcWidth; arcWidth += ARC_STEP)
+ {
+ performOneTest(configuration, testNumber, cap, join, width, arcHeight, arcWidth);
+ testNumber++;
+ }
}
- catch (IOException e)
- {
- e.printStackTrace();
- }
- this.log.logEnd(testName);
- testNumber++;
}
}
}
+ }
+
+ private void performOneTest(Configuration configuration, int testNumber, int cap, int join, float width,
+ int arcHeight, int arcWidth)
+ {
+ String testName = "test" + testNumber; //$NON-NLS-1$
+ this.log.logBegin(testName);
+ TestImage image = new TestImage(configuration);
+ Graphics2D graphics = image.getGraphics();
+ /* TODO: add support to various scales and dashes */
+ EntityRenderingStyle entityRenderingStyle = new EntityRenderingStyle(cap, join, width, arcHeight, arcWidth);
+ logCurrentRenderingStyle(entityRenderingStyle);
+ drawEntity(image, graphics, testNumber, entityRenderingStyle);
+ graphics.dispose();
+ try
+ {
+ image.writeImage(configuration, this.suiteName, testName);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace();
+ }
+ this.log.logEnd(testName);
+ }
+
+ @SuppressWarnings({ "nls", "boxing" })
+ private void logCurrentRenderingStyle(EntityRenderingStyle entityRenderingStyle)
+ {
+ this.log.logSet("cap", entityRenderingStyle.getCap());
+ this.log.logSet("join", entityRenderingStyle.getJoin());
+ this.log.logSet("width", entityRenderingStyle.getWidth());
+ this.log.logSet("arc width", entityRenderingStyle.getArcWidth());
+ this.log.logSet("arc height", entityRenderingStyle.getArcHeight());
}
private void tryToInvokeTestMethod(Configuration configuration, Method method)
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/FilledCircles.java
--- a/src/org/gfxtest/testsuites/FilledCircles.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/FilledCircles.java Thu Jul 22 16:27:18 2010 +0200
@@ -58,12 +58,10 @@ public class FilledCircles extends GfxTe
{
@Override
- protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, float scale, float width, int cap, int join, float[] dash)
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
graphics.setColor(Color.BLACK);
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- join)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/FilledPolygons.java
--- a/src/org/gfxtest/testsuites/FilledPolygons.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/FilledPolygons.java Thu Jul 22 16:27:18 2010 +0200
@@ -58,12 +58,10 @@ public class FilledPolygons extends GfxT
{
@Override
- protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, float scale, float width, int cap, int join, float[] dash)
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
graphics.setColor(Color.BLACK);
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- join)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int w = image.getWidth();
int h = image.getHeight();
int xPoints[] = new int[] { OFFSET, w >> 1, w >> 1, w - OFFSET };
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/FilledRectangles.java
--- a/src/org/gfxtest/testsuites/FilledRectangles.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/FilledRectangles.java Thu Jul 22 16:27:18 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -57,9 +56,10 @@ import org.gfxtest.framework.annotations
@Transformation(Transformations.NONE)
public class FilledRectangles extends GfxTest
{
- private void drawFilledRectangle(TestImage image, Graphics2D graphics, float width, int cap, int join)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, cap, join));
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
@@ -77,39 +77,10 @@ public class FilledRectangles extends Gf
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- /* TODO: transfer caps and joins to GfxTest for ALL test cases */
- int[] caps = { BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, BasicStroke.CAP_SQUARE };
- int[] joins = { BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_MITER, BasicStroke.CAP_ROUND };
- // TODO: transfer widths to GfxTest for ALL test cases
- float[] widths = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- int testNumber = 0;
- for (int cap : caps)
- {
- for (int join : joins)
- {
- for (float width : widths)
- {
- String testName = "test" + testNumber;
- log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = (Graphics2D) image.getGraphics();
- drawFilledRectangle(image, graphics, width, cap, join);
- graphics.dispose();
- try
- {
- image.writeImage(configuration, suiteName, testName);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- log.logEnd(testName);
- testNumber++;
- }
- }
- }
+ drawEntityWithVariousStyles(configuration, true, true, true, false, false);
}
public static void main(String[] args)
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/FilledRoundRectangles.java
--- a/src/org/gfxtest/testsuites/FilledRoundRectangles.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/FilledRoundRectangles.java Thu Jul 22 16:27:18 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -57,11 +56,10 @@ import org.gfxtest.framework.annotations
@Transformation(Transformations.NONE)
public class FilledRoundRectangles extends GfxTest
{
- private void drawFilledRoundRectangle(TestImage image, Graphics2D graphics, float width, int arcWidth, int arcHeight)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, // width
- BasicStroke.CAP_BUTT, // cap
- BasicStroke.JOIN_BEVEL)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
@@ -74,40 +72,15 @@ public class FilledRoundRectangles exten
int x = (int) (xc + rmaj * Math.cos(angle));
int y = (int) (yc + rmaj * Math.sin(angle));
int radius = (int)(MINOR_RADIUS + m * (MAJOR_RADIUS - MINOR_RADIUS));
- graphics.fillRoundRect(x - radius, y - radius, radius << 1, radius << 1, arcWidth, arcHeight);
+ graphics.fillRoundRect(x - radius, y - radius, radius << 1, radius << 1, entityRenderingStyle.getArcWidth(), entityRenderingStyle.getArcHeight());
}
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- float[] widths = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- int testNumber = 0;
- for (float width : widths)
- {
- for (int arcHeight = 0; arcHeight < 40; arcHeight += 10)
- {
- for (int arcWidth = 0; arcWidth < 40; arcWidth += 10)
- {
- String testName = "test" + testNumber;
- log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = (Graphics2D) image.getGraphics();
- drawFilledRoundRectangle(image, graphics, width, arcWidth, arcHeight);
- graphics.dispose();
- try
- {
- image.writeImage(configuration, suiteName, testName);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- log.logEnd(testName);
- testNumber++;
- }
- }
- }
+ drawEntityWithVariousStyles(configuration, true, true, true, false, false, 0, 40, 0, 40);
}
public static void main(String[] args)
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/NormalArcs.java
--- a/src/org/gfxtest/testsuites/NormalArcs.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalArcs.java Thu Jul 22 16:27:18 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -57,19 +56,16 @@ import org.gfxtest.framework.annotations
@Transformation(Transformations.NONE)
public class NormalArcs extends GfxTest
{
- private static final int MINOR_RADIUS = 50;
- private static final int RADIUS_STEP = 30;
- private void drawArc(TestImage image, Graphics2D graphics, float width, int cap)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- BasicStroke.JOIN_BEVEL)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
int majorRadius = (xc > yc ? yc : xc) - 20;
- for (int radius = MINOR_RADIUS; radius < majorRadius; radius += RADIUS_STEP)
+ for (int radius = majorRadius; radius >= MINOR_RADIUS; radius -= RADIUS_STEP)
{
double r = ((double) radius - MINOR_RADIUS) / (majorRadius - MINOR_RADIUS);
Color color = new Color(Color.HSBtoRGB((float)r, 1.0f, 1.0f));
@@ -79,33 +75,10 @@ public class NormalArcs extends GfxTest
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- float[] widths = { 1.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- int[] caps = { BasicStroke.CAP_SQUARE, BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND };
- int testNumber = 0;
- for (int cap : caps)
- {
- for (float width : widths)
- {
- String testName = "test" + testNumber;
- log.logBegin(testName);
- TestImage image = new TestImage(configuration);
- Graphics2D graphics = (Graphics2D) image.getGraphics();
- drawArc(image, graphics, width, cap);
- graphics.dispose();
- try
- {
- image.writeImage(configuration, suiteName, testName);
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- log.logEnd(testName);
- testNumber++;
- }
- }
+ drawEntityWithVariousStyles(configuration, true, true, true, false, false);
}
public static void main(String[] args)
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/NormalCircles.java
--- a/src/org/gfxtest/testsuites/NormalCircles.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalCircles.java Thu Jul 22 16:27:18 2010 +0200
@@ -58,12 +58,10 @@ public class NormalCircles extends GfxTe
{
@Override
- protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, float scale, float width, int cap, int join, float[] dash)
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
graphics.setColor(Color.BLACK);
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- join)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/NormalPolygons.java
--- a/src/org/gfxtest/testsuites/NormalPolygons.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalPolygons.java Thu Jul 22 16:27:18 2010 +0200
@@ -58,12 +58,10 @@ public class NormalPolygons extends GfxT
{
@Override
- protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, float scale, float width, int cap, int join, float[] dash)
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
graphics.setColor(Color.BLACK);
- graphics.setStroke(new BasicStroke(width, // width
- cap, // cap
- join)); // join
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int w = image.getWidth();
int h = image.getHeight();
int xPoints[] = new int[] { OFFSET, w >> 1, w >> 1, w - OFFSET };
diff -r ec0b1d456477 -r e6167048456f src/org/gfxtest/testsuites/NormalRectangles.java
--- a/src/org/gfxtest/testsuites/NormalRectangles.java Wed Jul 21 16:28:07 2010 +0200
+++ b/src/org/gfxtest/testsuites/NormalRectangles.java Thu Jul 22 16:27:18 2010 +0200
@@ -41,7 +41,6 @@ package org.gfxtest.testsuites;
package org.gfxtest.testsuites;
import java.awt.*;
-import java.io.IOException;
import org.gfxtest.framework.*;
import org.gfxtest.framework.annotations.*;
@@ -57,9 +56,10 @@ import org.gfxtest.framework.annotations
@Transformation(Transformations.NONE)
public class NormalRectangles extends GfxTest
{
- private void drawRectangle(TestImage image, Graphics2D graphics, float width, int cap, int join)
+ @Override
+ protected void drawEntity(TestImage image, Graphics2D graphics, int testNumber, EntityRenderingStyle entityRenderingStyle)
{
- graphics.setStroke(new BasicStroke(width, cap, join));
+ graphics.setStroke(new BasicStroke(entityRenderingStyle.getWidth(), entityRenderingStyle.getCap(), entityRenderingStyle.getJoin()));
int xc = image.getCenterX();
int yc = image.getCenterY();
double rmaj = (xc > yc ? yc : xc) - (MAJOR_RADIUS - MINOR_RADIUS);
@@ -77,39 +77,10 @@ public class NormalRectangles extends Gf
drawCross(graphics, xc, yc, CROSS_SIZE);
}
+ @Override
protected void runOtherTests(Configuration configuration)
{
- /* TODO: transfer caps and joins to GfxTest for ALL test cases */
- int[] caps = { BasicStroke.CAP_BUTT, BasicStroke.CAP_ROUND, BasicStroke.CAP_SQUARE };
- int[] joins = { BasicStroke.JOIN_BEVEL, BasicStroke.JOIN_MITER, BasicStroke.CAP_ROUND };
- // TODO: transfer widths to GfxTest for ALL test cases
- float[] widths = { 1.0f, 2.0f, 5.0f, 10.0f, 20.0f, 40.0f };
- int testNumber = 0;
- for (int cap : caps)
- {
- for (int join : joins)
- {
More information about the distro-pkg-dev
mailing list