add support for drawing and filling a polygon

Signed-off-by: Florian Thienel <florian@thienel.org>
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
index 8dc494a..379802e 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/FakeGraphics.java
@@ -145,6 +145,10 @@
 	}
 
 	@Override
+	public void drawPolygon(final int... coordinates) {
+	}
+
+	@Override
 	public void drawImage(final Image image, final int x, final int y, final int width, final int height) {
 		Assert.isTrue(image instanceof FakeImage);
 		lastDrawnImageUrl = ((FakeImage) image).url;
@@ -167,6 +171,10 @@
 	}
 
 	@Override
+	public void fillPolygon(final int... coordinates) {
+	}
+
+	@Override
 	public Rectangle getClipBounds() {
 		return new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
 	}
diff --git a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/endtoend/TracingGraphics.java b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/endtoend/TracingGraphics.java
index 80c3bd4..45668f0 100644
--- a/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/endtoend/TracingGraphics.java
+++ b/org.eclipse.vex.core.tests/src/org/eclipse/vex/core/internal/layout/endtoend/TracingGraphics.java
@@ -143,6 +143,11 @@
 	}
 
 	@Override
+	public void drawPolygon(final int... coordinates) {
+		tracer.trace("Graphics.drawPolygon(int[{0}])", coordinates.length);
+	}
+
+	@Override
 	public void drawImage(final Image image, final int x, final int y, final int width, final int height) {
 		tracer.trace("Graphics.drawImage({0}, {1,number,#}, {2,number,#}, {3,number,#}, {4,number,#})", image, x, y, width, height);
 	}
@@ -163,6 +168,11 @@
 	}
 
 	@Override
+	public void fillPolygon(final int... coordinates) {
+		tracer.trace("Graphics.fillPolygon(int[{0}])", coordinates.length);
+	}
+
+	@Override
 	public Rectangle getClipBounds() {
 		return new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE);
 	}
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
index f004d3e..4dd6e5b 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/core/Graphics.java
@@ -50,6 +50,8 @@
 
 	public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
 
+	public void drawPolygon(int... coordinates);
+
 	public void drawImage(Image image, int x, int y, int width, int height);
 
 	public void fillOval(int x, int y, int width, int height);
@@ -58,6 +60,8 @@
 
 	public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight);
 
+	public void fillPolygon(int... coordinates);
+
 	public Rectangle getClipBounds();
 
 	public FontResource getCurrentFont();
diff --git a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/SwtGraphics.java b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/SwtGraphics.java
index 8fe81e5..ed3c7c6 100644
--- a/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/SwtGraphics.java
+++ b/org.eclipse.vex.core/src/org/eclipse/vex/core/internal/widget/swt/SwtGraphics.java
@@ -131,6 +131,23 @@
 	}
 
 	@Override
+	public void drawPolygon(final int... coordinates) {
+		gc.drawPolygon(translateCoordinates(coordinates));
+	}
+
+	private int[] translateCoordinates(final int... coordinates) {
+		final int[] transformedCoordinates = new int[coordinates.length];
+		for (int i = 0; i < coordinates.length; i += 1) {
+			if (i % 2 == 0) {
+				transformedCoordinates[i] = coordinates[i] + offsetX;
+			} else {
+				transformedCoordinates[i] = coordinates[i] + offsetY;
+			}
+		}
+		return transformedCoordinates;
+	}
+
+	@Override
 	public void drawString(final String s, final int x, final int y) {
 		gc.drawString(s, x + offsetX, y + offsetY, true);
 	}
@@ -170,6 +187,11 @@
 	}
 
 	@Override
+	public void fillPolygon(final int... coordinates) {
+		gc.fillPolygon(translateCoordinates(coordinates));
+	}
+
+	@Override
 	public Rectangle getClipBounds() {
 		final org.eclipse.swt.graphics.Rectangle r = gc.getClipping();
 		return new Rectangle(r.x - offsetX, r.y - offsetY, r.width, r.height);