<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<!-- MHonArc v2.6.10 -->
	<channel>
		<title>gef3d-commits</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/maillist.html</link>
		<description>gef3d-commits</description>
		<language>en-us</language>
		<pubDate>Sun, 22 Nov 2009 13:50:14 GMT</pubDate>
		<lastBuildDate>Sun, 22 Nov 2009 13:50:14 GMT</lastBuildDate>
		<docs>http://blogs.law.harvard.edu/tech/rss</docs>
		<generator>MHonArc RSS 2.0 RCFile</generator>
		<managingEditor>webmaster@eclipse.org (Webmaster)</managingEditor>
		<webMaster>webmaster@eclipse.org (Webmaster)</webMaster>
		<image>
			<title>gef3d-commits</title>
			<url>http://www.eclipse.org/eclipse.org-common/themes/Phoenix/images/eclipse_home_header.jpg</url>
			<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/maillist.html</link>
		</image>
 

	<item>
		<title>[gef3d-commits] r394 - in branches/experimental_direct_2D_rendering:	org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics	org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer	org.eclipse.draw3d.geometry/META-INF	org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry	org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection	org.eclipse.draw3d.graphics3d/META-INF	org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture	org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry	org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00239.html</link>
		<description>Author: kduske Date: 2009-11-22 08:46:12 -0500 (Sun, 22 Nov 2009) New Revision: 394 Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math2D.java branches/experimental_direct_2D_rendering/org....</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-22 08:46:12 -0500 (Sun, 22 Nov 2009)
New Revision: 394

Added:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math2D.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/AVLTree.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/CombinedPointQueue.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PointQueue.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PolylineIntersectsPolylineAlgorithm.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection/
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection/AVLTreeTest.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/AbstractPrimitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/LinePrimitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolygonPrimitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolylinePrimitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/Primitive.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveType.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/QuadPrimitive.java
Removed:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java
Modified:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/META-INF/MANIFEST.MF
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/META-INF/MANIFEST.MF
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
Log:


Deleted: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jens von Pilgrim and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
- *
- * Contributors:
- *    Kristian Duske - initial API and implementation
- ******************************************************************************/
-package org.eclipse.draw3d.graphics;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.LineAttributes;
-
-/**
- * Saves fonts and custom dash patterns so that they can be initialized before
- * the recorded method calls are played back.
- * 
- * @author Kristian Duske
- * @version $Revision$
- * @since 06.11.2009
- */
-public class GLGraphicsRecorder extends GraphicsRecorder {
-
-	private Set&lt;int[]&gt; m_dashes = new HashSet&lt;int[]&gt;();
-
-	private Set&lt;Font&gt; m_fonts = new HashSet&lt;Font&gt;();
-
-	private void saveLineDash() {
-
-		int[] lineDash = getState().getLineDash();
-		if (lineDash != null)
-			m_dashes.add(lineDash);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setFont(org.eclipse.swt.graphics.Font)
-	 */
-	@Override
-	public void setFont(Font i_f) {
-
-		super.setFont(i_f);
-
-		if (i_f != null)
-			m_fonts.add(i_f);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
-	 */
-	@Override
-	public void setLineAttributes(LineAttributes i_attributes) {
-
-		super.setLineAttributes(i_attributes);
-		saveLineDash();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineDash(float[])
-	 */
-	@Override
-	public void setLineDash(float[] i_dash) {
-
-		super.setLineDash(i_dash);
-		saveLineDash();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineDash(int[])
-	 */
-	@Override
-	public void setLineDash(int[] i_dash) {
-
-		super.setLineDash(i_dash);
-		saveLineDash();
-	}
-}

Deleted: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -1,1076 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 Jens von Pilgrim and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
- *
- * Contributors:
- *    Kristian Duske - initial API and implementation
- ******************************************************************************/
-package org.eclipse.draw3d.graphics;
-
-import java.lang.reflect.Method;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.eclipse.draw2d.Graphics;
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.LineAttributes;
-import org.eclipse.swt.graphics.Path;
-import org.eclipse.swt.graphics.Pattern;
-import org.eclipse.swt.graphics.TextLayout;
-
-/**
- * GraphicsRecorder There should really be more documentation here.
- * 
- * @author Kristian Duske
- * @version $Revision$
- * @since 05.11.2009
- */
-public class GraphicsRecorder extends StatefulGraphics {
-
-	private static class MethodCall {
-
-		private Object[] m_args;
-
-		private Method m_method;
-
-		/**
-		 * @param i_method
-		 * @param i_args
-		 */
-		public MethodCall(Method i_method, Object[] i_args) {
-
-			m_method = i_method;
-			m_args = i_args;
-		}
-
-		public void execute(Object i_target) {
-
-			try {
-				m_method.invoke(i_target, m_args);
-			} catch (Exception e) {
-				throw new RuntimeException(e);
-			}
-		}
-	}
-
-	private static Method m_clipRect;
-
-	private static Method m_dispose;
-
-	private static Method m_drawArc;
-
-	private static Method m_drawFocus;
-
-	private static Method m_drawImageLong;
-
-	private static Method m_drawImageShort;
-
-	private static Method m_drawLine;
-
-	private static Method m_drawOval;
-
-	private static Method m_drawPath;
-
-	private static Method m_drawPoint;
-
-	private static Method m_drawPolygon;
-
-	private static Method m_drawPolygonWithArray;
-
-	private static Method m_drawPolyline;
-
-	private static Method m_drawPolylineWithArray;
-
-	private static Method m_drawRectangle;
-
-	private static Method m_drawRoundRectangle;
-
-	private static Method m_drawString;
-
-	private static Method m_drawTextLayout;
-
-	private static Method m_drawTextLong;
-
-	private static Method m_drawTextShort;
-
-	private static Method m_fillArc;
-
-	private static Method m_fillGradient;
-
-	private static Method m_fillOval;
-
-	private static Method m_fillPath;
-
-	private static Method m_fillPolygon;
-
-	private static Method m_fillPolygonWithArray;
-
-	private static Method m_fillRectangle;
-
-	private static Method m_fillRoundRectangle;
-
-	private static Method m_fillString;
-
-	private static Method m_fillText;
-
-	private static Method m_popState;
-
-	private static Method m_pushState;
-
-	private static Method m_restoreState;
-
-	private static Method m_rotate;
-
-	private static Method m_scale;
-
-	private static Method m_scaleUniform;
-
-	private static Method m_setAdvanced;
-
-	private static Method m_setAlpha;
-
-	private static Method m_setAntialias;
-
-	private static Method m_setBackgroundColor;
-
-	private static Method m_setBackgroundPattern;
-
-	private static Method m_setClip;
-
-	private static Method m_setClipWithPath;
-
-	private static Method m_setFillRule;
-
-	private static Method m_setFont;
-
-	private static Method m_setForegroundColor;
-
-	private static Method m_setForegroundPattern;
-
-	private static Method m_setInterpolation;
-
-	private static Method m_setLineAttributes;
-
-	private static Method m_setLineCap;
-
-	private static Method m_setLineDashWithFloatArray;
-
-	private static Method m_setLineDashWithIntArray;
-
-	private static Method m_setLineJoin;
-
-	private static Method m_setLineMiterLimit;
-
-	private static Method m_setLineStyle;
-
-	private static Method m_setLineWidth;
-
-	private static Method m_setLineWidthFloat;
-
-	private static Method m_setTextAntialias;
-
-	private static Method m_setXORMode;
-
-	private static Method m_shear;
-
-	private static Method m_translate;
-
-	private static Method m_translateWithFloat;
-
-	static {
-
-		Class&lt;Graphics&gt; cls = Graphics.class;
-		try {
-			m_clipRect = cls.getMethod(&quot;clipRect&quot;, Rectangle.class);
-			m_dispose = cls.getMethod(&quot;dispose&quot;);
-			m_drawArc =
-				cls.getMethod(&quot;drawArc&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class, Integer.class, Integer.class);
-			m_drawFocus =
-				cls.getMethod(&quot;drawFocus&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_drawImageShort =
-				cls.getMethod(&quot;drawImage&quot;, Image.class, Integer.class,
-					Integer.class);
-			m_drawImageLong =
-				cls.getMethod(&quot;drawImage&quot;, Image.class, Integer.class,
-					Integer.class, Integer.class, Integer.class, Integer.class,
-					Integer.class, Integer.class, Integer.class);
-			m_drawLine =
-				cls.getMethod(&quot;drawLine&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_drawOval =
-				cls.getMethod(&quot;drawOval&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_drawPath = cls.getMethod(&quot;drawPath&quot;, Path.class);
-			m_drawPoint =
-				cls.getMethod(&quot;drawPoint&quot;, Integer.class, Integer.class);
-			m_drawPolygonWithArray = cls.getMethod(&quot;drawPolygon&quot;, int[].class);
-			m_drawPolygon = cls.getMethod(&quot;drawPolygon&quot;, PointList.class);
-			m_drawPolylineWithArray =
-				cls.getMethod(&quot;drawPolyline&quot;, int[].class);
-			m_drawPolyline = cls.getMethod(&quot;drawPolyline&quot;, PointList.class);
-			m_drawRectangle =
-				cls.getMethod(&quot;drawRectangle&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_drawRoundRectangle =
-				cls.getMethod(&quot;drawRoundRectangle&quot;, Rectangle.class,
-					Integer.class, Integer.class);
-			m_drawString =
-				cls.getMethod(&quot;drawString&quot;, String.class, Integer.class,
-					Integer.class);
-			m_drawTextShort =
-				cls.getMethod(&quot;drawText&quot;, String.class, Integer.class,
-					Integer.class);
-			m_drawTextLong =
-				cls.getMethod(&quot;drawText&quot;, String.class, Integer.class,
-					Integer.class, Integer.class);
-			m_drawTextLayout =
-				cls.getMethod(&quot;drawTextLayout&quot;, TextLayout.class,
-					Integer.class, Integer.class, Integer.class, Integer.class,
-					Color.class, Color.class);
-			m_fillArc =
-				cls.getMethod(&quot;fillArc&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class, Integer.class, Integer.class);
-			m_fillGradient =
-				cls.getMethod(&quot;fillGradient&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class, Boolean.class);
-			m_fillOval =
-				cls.getMethod(&quot;fillOval&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_fillPath = cls.getMethod(&quot;fillPath&quot;, Path.class);
-			m_fillPolygonWithArray = cls.getMethod(&quot;fillPolygon&quot;, int[].class);
-			m_fillPolygon = cls.getMethod(&quot;fillPolygon&quot;, PointList.class);
-			m_fillRectangle =
-				cls.getMethod(&quot;fillRectangle&quot;, Integer.class, Integer.class,
-					Integer.class, Integer.class);
-			m_fillRoundRectangle =
-				cls.getMethod(&quot;fillRoundRectangle&quot;, Rectangle.class,
-					Integer.class, Integer.class);
-			m_fillString =
-				cls.getMethod(&quot;fillString&quot;, String.class, Integer.class,
-					Integer.class);
-			m_fillText =
-				cls.getMethod(&quot;fillText&quot;, String.class, Integer.class,
-					Integer.class);
-			m_popState = cls.getMethod(&quot;popState&quot;);
-			m_pushState = cls.getMethod(&quot;pushState&quot;);
-			m_restoreState = cls.getMethod(&quot;restoreState&quot;);
-			m_rotate = cls.getMethod(&quot;rotate&quot;, Float.class);
-			m_scaleUniform = cls.getMethod(&quot;scale&quot;, Double.class);
-			m_scale = cls.getMethod(&quot;scale&quot;, Float.class, Float.class);
-			m_setAdvanced = cls.getMethod(&quot;setAdvanced&quot;, Boolean.class);
-			m_setAlpha = cls.getMethod(&quot;setAlpha&quot;, Integer.class);
-			m_setAntialias = cls.getMethod(&quot;setAntialias&quot;, Integer.class);
-			m_setBackgroundColor =
-				cls.getMethod(&quot;setBackgroundColor&quot;, Color.class);
-			m_setBackgroundPattern =
-				cls.getMethod(&quot;setBackgroundPattern&quot;, Pattern.class);
-			m_setClipWithPath = cls.getMethod(&quot;setClip&quot;, Path.class);
-			m_setClip = cls.getMethod(&quot;setClip&quot;, Rectangle.class);
-			m_setFillRule = cls.getMethod(&quot;setFillRule&quot;, Integer.class);
-			m_setFont = cls.getMethod(&quot;setFont&quot;, Font.class);
-			m_setForegroundColor =
-				cls.getMethod(&quot;setForegroundColor&quot;, Color.class);
-			m_setForegroundPattern =
-				cls.getMethod(&quot;setForegroundPattern&quot;, Pattern.class);
-			m_setInterpolation =
-				cls.getMethod(&quot;setInterpolation&quot;, Integer.class);
-			m_setLineAttributes =
-				cls.getMethod(&quot;setLineAttributes&quot;, LineAttributes.class);
-			m_setLineCap = cls.getMethod(&quot;setLineCap&quot;, Integer.class);
-			m_setLineDashWithFloatArray =
-				cls.getMethod(&quot;setLineDash&quot;, float[].class);
-			m_setLineDashWithIntArray =
-				cls.getMethod(&quot;setLineDash&quot;, int[].class);
-			m_setLineJoin = cls.getMethod(&quot;setLineJoin&quot;, Integer.class);
-			m_setLineMiterLimit =
-				cls.getMethod(&quot;setLineMiterLimit&quot;, Float.class);
-			m_setLineStyle = cls.getMethod(&quot;setLineStyle&quot;, Integer.class);
-			m_setLineWidth = cls.getMethod(&quot;setLineWidth&quot;, Integer.class);
-			m_setLineWidthFloat =
-				cls.getMethod(&quot;setLineWidthFloat&quot;, Float.class);
-			m_setTextAntialias =
-				cls.getMethod(&quot;setTextAntialias&quot;, Integer.class);
-			m_setXORMode = cls.getMethod(&quot;setXORMode&quot;, Boolean.class);
-			m_shear = cls.getMethod(&quot;shear&quot;, Float.class, Float.class);
-			m_translateWithFloat =
-				cls.getMethod(&quot;translate&quot;, Float.class, Float.class);
-			m_translate =
-				cls.getMethod(&quot;translate&quot;, Integer.class, Integer.class);
-		} catch (Exception e) {
-			// TODO Implement catch block for SecurityException
-			e.printStackTrace();
-		}
-	}
-
-	private List&lt;MethodCall&gt; m_calls = new LinkedList&lt;MethodCall&gt;();
-
-	/**
-	 * Clears the recorded method calls.
-	 */
-	public void clear() {
-
-		m_calls.clear();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#clipRect(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public void clipRect(Rectangle i_r) {
-
-		super.clipRect(i_r);
-		record(m_clipRect, i_r);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#dispose()
-	 */
-	@Override
-	public void dispose() {
-
-		super.dispose();
-		record(m_dispose);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawArc(int, int, int, int, int, int)
-	 */
-	@Override
-	public void drawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
-		int i_length) {
-
-		record(m_drawArc, i_x, i_y, i_w, i_h, i_offset, i_length);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawFocus(int, int, int, int)
-	 */
-	@Override
-	public void drawFocus(int i_x, int i_y, int i_w, int i_h) {
-
-		record(m_drawFocus, i_x, i_y, i_w, i_h);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image,
-	 *      int, int)
-	 */
-	@Override
-	public void drawImage(Image i_srcImage, int i_x, int i_y) {
-
-		record(m_drawImageShort, i_srcImage, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image,
-	 *      int, int, int, int, int, int, int, int)
-	 */
-	@Override
-	public void drawImage(Image i_srcImage, int i_x1, int i_y1, int i_w1,
-		int i_h1, int i_x2, int i_y2, int i_w2, int i_h2) {
-
-		record(m_drawImageLong, i_srcImage, i_x1, i_y1, i_w1, i_h1, i_x2, i_y2,
-			i_w2, i_h2);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawLine(int, int, int, int)
-	 */
-	@Override
-	public void drawLine(int i_x1, int i_y1, int i_x2, int i_y2) {
-
-		record(m_drawLine, i_x1, i_y1, i_x2, i_y2);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawOval(int, int, int, int)
-	 */
-	@Override
-	public void drawOval(int i_x, int i_y, int i_w, int i_h) {
-
-		record(m_drawOval, i_x, i_y, i_w, i_h);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPath(org.eclipse.swt.graphics.Path)
-	 */
-	@Override
-	public void drawPath(Path i_path) {
-
-		record(m_drawPath, i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPoint(int, int)
-	 */
-	@Override
-	public void drawPoint(int i_x, int i_y) {
-
-		record(m_drawPoint, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolygon(int[])
-	 */
-	@Override
-	public void drawPolygon(int[] i_points) {
-
-		record(m_drawPolygonWithArray, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolygon(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void drawPolygon(PointList i_points) {
-
-		record(m_drawPolygon, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolyline(int[])
-	 */
-	@Override
-	public void drawPolyline(int[] i_points) {
-
-		record(m_drawPolylineWithArray, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolyline(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void drawPolyline(PointList i_points) {
-
-		record(m_drawPolyline, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawRectangle(int, int, int, int)
-	 */
-	@Override
-	public void drawRectangle(int i_x, int i_y, int i_width, int i_height) {
-
-		record(m_drawRectangle, i_x, i_y, i_width, i_height);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle,
-	 *      int, int)
-	 */
-	@Override
-	public void drawRoundRectangle(Rectangle i_r, int i_arcWidth,
-		int i_arcHeight) {
-
-		record(m_drawRoundRectangle, i_r, i_arcWidth, i_arcHeight);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawString(java.lang.String, int, int)
-	 */
-	@Override
-	public void drawString(String i_s, int i_x, int i_y) {
-
-		record(m_drawString, i_s, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawText(java.lang.String, int, int)
-	 */
-	@Override
-	public void drawText(String i_s, int i_x, int i_y) {
-
-		record(m_drawTextShort, i_s, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawText(java.lang.String, int, int,
-	 *      int)
-	 */
-	@Override
-	public void drawText(String i_s, int i_x, int i_y, int i_style) {
-
-		record(m_drawTextLong, i_s, i_x, i_y, i_style);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawTextLayout(org.eclipse.swt.graphics.TextLayout,
-	 *      int, int, int, int, org.eclipse.swt.graphics.Color,
-	 *      org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void drawTextLayout(TextLayout i_layout, int i_x, int i_y,
-		int i_selectionStart, int i_selectionEnd, Color i_selectionForeground,
-		Color i_selectionBackground) {
-
-		record(m_drawTextLayout, i_layout, i_x, i_y, i_selectionStart,
-			i_selectionEnd, i_selectionForeground, i_selectionBackground);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillArc(int, int, int, int, int, int)
-	 */
-	@Override
-	public void fillArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
-		int i_length) {
-
-		record(m_fillArc, i_x, i_y, i_w, i_h, i_offset, i_length);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillGradient(int, int, int, int,
-	 *      boolean)
-	 */
-	@Override
-	public void fillGradient(int i_x, int i_y, int i_w, int i_h,
-		boolean i_vertical) {
-
-		record(m_fillGradient, i_x, i_y, i_w, i_h, i_vertical);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillOval(int, int, int, int)
-	 */
-	@Override
-	public void fillOval(int i_x, int i_y, int i_w, int i_h) {
-
-		record(m_fillOval, i_x, i_y, i_w, i_h);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillPath(org.eclipse.swt.graphics.Path)
-	 */
-	@Override
-	public void fillPath(Path i_path) {
-
-		record(m_fillPath, i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillPolygon(int[])
-	 */
-	@Override
-	public void fillPolygon(int[] i_points) {
-
-		record(m_fillPolygonWithArray, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillPolygon(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void fillPolygon(PointList i_points) {
-
-		record(m_fillPolygon, i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillRectangle(int, int, int, int)
-	 */
-	@Override
-	public void fillRectangle(int i_x, int i_y, int i_width, int i_height) {
-
-		record(m_fillRectangle, i_x, i_y, i_width, i_height);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle,
-	 *      int, int)
-	 */
-	@Override
-	public void fillRoundRectangle(Rectangle i_r, int i_arcWidth,
-		int i_arcHeight) {
-
-		record(m_fillRoundRectangle, i_r, i_arcWidth, i_arcHeight);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillString(java.lang.String, int, int)
-	 */
-	@Override
-	public void fillString(String i_s, int i_x, int i_y) {
-
-		record(m_fillString, i_s, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillText(java.lang.String, int, int)
-	 */
-	@Override
-	public void fillText(String i_s, int i_x, int i_y) {
-
-		record(m_fillText, i_s, i_x, i_y);
-	}
-
-	/**
-	 * Play the recorded method calls against the given target.
-	 * 
-	 * @param i_target the target
-	 */
-	public void playback(Graphics i_target) {
-
-		if (i_target == null)
-			throw new NullPointerException(&quot;i_target must not be null&quot;);
-
-		for (MethodCall call : m_calls)
-			call.execute(i_target);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#popState()
-	 */
-	@Override
-	public void popState() {
-
-		super.popState();
-		record(m_popState);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#pushState()
-	 */
-	@Override
-	public void pushState() {
-
-		super.pushState();
-		record(m_pushState);
-	}
-
-	private void record(Method i_method, Object... args) {
-
-		m_calls.add(new MethodCall(i_method, args));
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#restoreState()
-	 */
-	@Override
-	public void restoreState() {
-
-		super.restoreState();
-		record(m_restoreState);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#rotate(float)
-	 */
-	@Override
-	public void rotate(float i_degrees) {
-
-		super.rotate(i_degrees);
-		record(m_rotate, i_degrees);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#scale(double)
-	 */
-	@Override
-	public void scale(double i_amount) {
-
-		super.scale(i_amount);
-		record(m_scaleUniform, i_amount);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#scale(float, float)
-	 */
-	@Override
-	public void scale(float i_horizontal, float i_vertical) {
-
-		super.scale(i_horizontal, i_vertical);
-		record(m_scale, i_horizontal, i_vertical);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAdvanced(boolean)
-	 */
-	@Override
-	public void setAdvanced(boolean i_advanced) {
-
-		super.setAdvanced(i_advanced);
-		record(m_setAdvanced, i_advanced);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAlpha(int)
-	 */
-	@Override
-	public void setAlpha(int i_alpha) {
-
-		super.setAlpha(i_alpha);
-		record(m_setAlpha, i_alpha);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAntialias(int)
-	 */
-	@Override
-	public void setAntialias(int i_antialias) {
-
-		super.setAntialias(i_antialias);
-		record(m_setAntialias, i_antialias);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setBackgroundColor(Color i_backgroundColor) {
-
-		super.setBackgroundColor(i_backgroundColor);
-		record(m_setBackgroundColor, i_backgroundColor);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundPattern(org.eclipse.swt.graphics.Pattern)
-	 */
-	@Override
-	public void setBackgroundPattern(Pattern i_backgroundPattern) {
-
-		super.setBackgroundPattern(i_backgroundPattern);
-		record(m_setBackgroundPattern, i_backgroundPattern);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.swt.graphics.Path)
-	 */
-	@Override
-	public void setClip(Path i_path) {
-
-		super.setClip(i_path);
-		record(m_setClipWithPath, i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public void setClip(Rectangle i_r) {
-
-		super.setClip(i_r);
-		record(m_setClip, i_r);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFillRule(int)
-	 */
-	@Override
-	public void setFillRule(int i_rule) {
-
-		super.setFillRule(i_rule);
-		record(m_setFillRule, i_rule);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFont(org.eclipse.swt.graphics.Font)
-	 */
-	@Override
-	public void setFont(Font i_f) {
-
-		super.setFont(i_f);
-		record(m_setFont, i_f);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setForegroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setForegroundColor(Color i_foregroundColor) {
-
-		super.setForegroundColor(i_foregroundColor);
-		record(m_setForegroundColor, i_foregroundColor);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setForegroundPattern(org.eclipse.swt.graphics.Pattern)
-	 */
-	@Override
-	public void setForegroundPattern(Pattern i_pattern) {
-
-		super.setForegroundPattern(i_pattern);
-		record(m_setForegroundPattern, i_pattern);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setInterpolation(int)
-	 */
-	@Override
-	public void setInterpolation(int i_interpolation) {
-
-		super.setInterpolation(i_interpolation);
-		record(m_setInterpolation, i_interpolation);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
-	 */
-	@Override
-	public void setLineAttributes(LineAttributes i_attributes) {
-
-		super.setLineAttributes(i_attributes);
-		record(m_setLineAttributes, i_attributes);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineCap(int)
-	 */
-	@Override
-	public void setLineCap(int i_cap) {
-
-		super.setLineCap(i_cap);
-		record(m_setLineCap, i_cap);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
-	 */
-	@Override
-	public void setLineDash(float[] i_dash) {
-
-		super.setLineDash(i_dash);
-		record(m_setLineDashWithFloatArray, i_dash);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
-	 */
-	@Override
-	public void setLineDash(int[] i_dash) {
-
-		super.setLineDash(i_dash);
-		record(m_setLineDashWithIntArray, i_dash);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineJoin(int)
-	 */
-	@Override
-	public void setLineJoin(int i_join) {
-
-		super.setLineJoin(i_join);
-		record(m_setLineJoin, i_join);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineMiterLimit(float)
-	 */
-	@Override
-	public void setLineMiterLimit(float i_miterLimit) {
-
-		super.setLineMiterLimit(i_miterLimit);
-		record(m_setLineMiterLimit, i_miterLimit);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineStyle(int)
-	 */
-	@Override
-	public void setLineStyle(int i_style) {
-
-		super.setLineStyle(i_style);
-		record(m_setLineStyle, i_style);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineWidth(int)
-	 */
-	@Override
-	public void setLineWidth(int i_width) {
-
-		super.setLineWidth(i_width);
-		record(m_setLineWidth, i_width);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineWidthFloat(float)
-	 */
-	@Override
-	public void setLineWidthFloat(float i_width) {
-
-		super.setLineWidthFloat(i_width);
-		record(m_setLineWidthFloat, i_width);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setTextAntialias(int)
-	 */
-	@Override
-	public void setTextAntialias(int i_value) {
-
-		super.setTextAntialias(i_value);
-		record(m_setTextAntialias, i_value);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setXORMode(boolean)
-	 */
-	@Override
-	public void setXORMode(boolean i_b) {
-
-		super.setXORMode(i_b);
-		record(m_setXORMode);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#shear(float, float)
-	 */
-	@Override
-	public void shear(float i_horz, float i_vert) {
-
-		super.shear(i_horz, i_vert);
-		record(m_shear, i_horz, i_vert);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#translate(float, float)
-	 */
-	@Override
-	public void translate(float i_dx, float i_dy) {
-
-		super.translate(i_dx, i_dy);
-		record(m_translateWithFloat, i_dx, i_dy);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#translate(int, int)
-	 */
-	@Override
-	public void translate(int i_dx, int i_dy) {
-
-		super.translate(i_dx, i_dy);
-		record(m_translate, i_dx, i_dy);
-	}
-}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/AbstractPrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/AbstractPrimitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/AbstractPrimitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * PolygonPrimitive There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public abstract class AbstractPrimitive implements Primitive {
+
+	private Rectangle m_bounds;
+
+	private PrimitiveType m_type;
+
+	protected abstract void calculateBounds(Rectangle io_bounds);
+
+	public AbstractPrimitive(PrimitiveType i_type) {
+
+		if (i_type == null)
+			throw new NullPointerException(&quot;i_type must not be null&quot;);
+
+		m_type = i_type;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.Primitive#getBounds()
+	 */
+	public Rectangle getBounds() {
+
+		if (m_bounds == null) {
+			m_bounds = new Rectangle();
+			calculateBounds(m_bounds);
+		}
+
+		return m_bounds;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.Primitive#getType()
+	 */
+	public PrimitiveType getType() {
+
+		return m_type;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.Primitive#intersects(org.eclipse.draw3d.graphics.optimizer.Primitive)
+	 */
+	public boolean intersects(Primitive i_candidate) {
+
+		if (!getBounds().intersects(i_candidate.getBounds()))
+			return false;
+
+		switch (i_candidate.getType()) {
+		case POLYGON:
+			return intersectsPolygon((PolygonPrimitive) i_candidate);
+		case QUAD:
+			return intersectsQuad((QuadPrimitive) i_candidate);
+		case POLYLINE:
+			return intersectsPolyline((PolylinePrimitive) i_candidate);
+		case LINE:
+			return intersectsLine((LinePrimitive) i_candidate);
+		default:
+			throw new AssertionError();
+		}
+	}
+
+	protected abstract boolean intersectsLine(LinePrimitive i_line);
+
+	protected abstract boolean intersectsPolygon(PolygonPrimitive i_polygon);
+
+	protected abstract boolean intersectsPolyline(PolylinePrimitive i_polyline);
+
+	protected abstract boolean intersectsQuad(QuadPrimitive i_quad);
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/LinePrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/LinePrimitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/LinePrimitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+/**
+ * LinePrimitive There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class LinePrimitive extends PolylinePrimitive {
+
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/OptimizingGraphics.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,234 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw3d.graphics.StatefulGraphics;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * OptimizingGraphics
+ * There should really be more documentation here.
+ *
+ * @author 	Kristian Duske
+ * @version	$Revision$
+ * @since 	18.11.2009
+ */
+public class OptimizingGraphics extends StatefulGraphics {
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawArc(int, int, int, int, int, int)
+	 */
+	@Override
+	public void drawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
+		int i_length) {
+		// TODO implement method OptimizingGraphics.drawArc
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawFocus(int, int, int, int)
+	 */
+	@Override
+	public void drawFocus(int i_x, int i_y, int i_w, int i_h) {
+		// TODO implement method OptimizingGraphics.drawFocus
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image, int, int)
+	 */
+	@Override
+	public void drawImage(Image i_srcImage, int i_x, int i_y) {
+		// TODO implement method OptimizingGraphics.drawImage
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image, int, int, int, int, int, int, int, int)
+	 */
+	@Override
+	public void drawImage(Image i_srcImage, int i_x1, int i_y1, int i_w1,
+		int i_h1, int i_x2, int i_y2, int i_w2, int i_h2) {
+		// TODO implement method OptimizingGraphics.drawImage
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawLine(int, int, int, int)
+	 */
+	@Override
+	public void drawLine(int i_x1, int i_y1, int i_x2, int i_y2) {
+		// TODO implement method OptimizingGraphics.drawLine
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawOval(int, int, int, int)
+	 */
+	@Override
+	public void drawOval(int i_x, int i_y, int i_w, int i_h) {
+		// TODO implement method OptimizingGraphics.drawOval
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawPolygon(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void drawPolygon(PointList i_points) {
+		// TODO implement method OptimizingGraphics.drawPolygon
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawPolyline(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void drawPolyline(PointList i_points) {
+		// TODO implement method OptimizingGraphics.drawPolyline
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawRectangle(int, int, int, int)
+	 */
+	@Override
+	public void drawRectangle(int i_x, int i_y, int i_width, int i_height) {
+		// TODO implement method OptimizingGraphics.drawRectangle
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle, int, int)
+	 */
+	@Override
+	public void drawRoundRectangle(Rectangle i_r, int i_arcWidth,
+		int i_arcHeight) {
+		// TODO implement method OptimizingGraphics.drawRoundRectangle
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawString(java.lang.String, int, int)
+	 */
+	@Override
+	public void drawString(String i_s, int i_x, int i_y) {
+		// TODO implement method OptimizingGraphics.drawString
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#drawText(java.lang.String, int, int)
+	 */
+	@Override
+	public void drawText(String i_s, int i_x, int i_y) {
+		// TODO implement method OptimizingGraphics.drawText
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillArc(int, int, int, int, int, int)
+	 */
+	@Override
+	public void fillArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
+		int i_length) {
+		// TODO implement method OptimizingGraphics.fillArc
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillGradient(int, int, int, int, boolean)
+	 */
+	@Override
+	public void fillGradient(int i_x, int i_y, int i_w, int i_h,
+		boolean i_vertical) {
+		// TODO implement method OptimizingGraphics.fillGradient
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillOval(int, int, int, int)
+	 */
+	@Override
+	public void fillOval(int i_x, int i_y, int i_w, int i_h) {
+		// TODO implement method OptimizingGraphics.fillOval
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillPolygon(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void fillPolygon(PointList i_points) {
+		// TODO implement method OptimizingGraphics.fillPolygon
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillRectangle(int, int, int, int)
+	 */
+	@Override
+	public void fillRectangle(int i_x, int i_y, int i_width, int i_height) {
+		// TODO implement method OptimizingGraphics.fillRectangle
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle, int, int)
+	 */
+	@Override
+	public void fillRoundRectangle(Rectangle i_r, int i_arcWidth,
+		int i_arcHeight) {
+		// TODO implement method OptimizingGraphics.fillRoundRectangle
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillString(java.lang.String, int, int)
+	 */
+	@Override
+	public void fillString(String i_s, int i_x, int i_y) {
+		// TODO implement method OptimizingGraphics.fillString
+
+	}
+
+	/** 
+	 * {@inheritDoc}
+	 * @see org.eclipse.draw2d.Graphics#fillText(java.lang.String, int, int)
+	 */
+	@Override
+	public void fillText(String i_s, int i_x, int i_y) {
+		// TODO implement method OptimizingGraphics.fillText
+
+	}
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolygonPrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolygonPrimitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolygonPrimitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,151 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw3d.geometry.Math2D;
+
+/**
+ * PolygonPrimitive There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class PolygonPrimitive extends PolylinePrimitive {
+
+	private boolean m_filled;
+
+	public PolygonPrimitive(int[] i_points, boolean i_filled) {
+
+		super(i_points, PrimitiveType.POLYGON);
+
+		m_filled = i_filled;
+	}
+
+	protected boolean isFilled() {
+
+		return m_filled;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#calculateBounds(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	protected void calculateBounds(Rectangle io_bounds) {
+
+		io_bounds.setLocation(0, 0);
+		io_bounds.setSize(0, 0);
+
+		int[] points = getPoints();
+		if (points.length == 0)
+			return;
+
+		io_bounds.setLocation(points[0], points[1]);
+		for (int i = 1; i &lt; points.length / 2; i++) {
+			int x = points[2 * i];
+			int y = points[2 * i + 1];
+			int r = io_bounds.x + io_bounds.width;
+			int b = io_bounds.y + io_bounds.height;
+
+			if (x &lt; io_bounds.x) {
+				io_bounds.width += io_bounds.x - x;
+				io_bounds.x = x;
+			} else if (x &gt; r)
+				io_bounds.width += x - r;
+
+			if (y &lt; io_bounds.y) {
+				io_bounds.height += io_bounds.y - y;
+				io_bounds.y = y;
+			} else if (y &gt; b)
+				io_bounds.height += y - b;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsLine(org.eclipse.draw3d.graphics.optimizer.LinePrimitive)
+	 */
+	@Override
+	protected boolean intersectsLine(LinePrimitive i_line) {
+
+		return intersectsPolyline(i_line);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsPolygon(org.eclipse.draw3d.graphics.optimizer.PolygonPrimitive)
+	 */
+	@Override
+	protected boolean intersectsPolygon(PolygonPrimitive i_polygon) {
+
+		if (isFilled()) {
+			if (i_polygon.isFilled())
+				return Math2D.polygonIntersectsPolygon(getPoints(),
+					i_polygon.getPoints());
+			else
+				return Math2D.sortedPointsInPolygon(getPoints(),
+					i_polygon.getPoints(), i_polygon.getSortedIndices(), 1) &gt; 0;
+		} else {
+			if (i_polygon.isFilled()) {
+				return Math2D.sortedPointsInPolygon(i_polygon.getPoints(),
+					getPoints(), getSortedIndices(), 1) &gt; 0;
+			} else {
+				int n = i_polygon.getPoints().length / 2;
+				int p =
+					Math2D.sortedPointsInPolygon(getPoints(),
+						i_polygon.getPoints(), i_polygon.getSortedIndices(), n);
+
+				// either the other polygon is entirely contained in this
+				// polygon or not at all
+				return p &gt; 0 &amp;&amp; p &lt; n;
+			}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsPolyline(org.eclipse.draw3d.graphics.optimizer.PolylinePrimitive)
+	 */
+	@Override
+	protected boolean intersectsPolyline(PolylinePrimitive i_polyline) {
+
+		if (isFilled())
+			return Math2D.sortedPointsInPolygon(getPoints(),
+				i_polyline.getPoints(), i_polyline.getSortedIndices(), 1) &gt; 0;
+		else {
+			int n = i_polyline.getPoints().length / 2;
+			int p =
+				Math2D.sortedPointsInPolygon(getPoints(),
+					i_polyline.getPoints(), i_polyline.getSortedIndices(), n);
+
+			// either the polyline is entirely contained in this
+			// polygon or not at all
+			return p &gt; 0 &amp;&amp; p &lt; n;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsQuad(org.eclipse.draw3d.graphics.optimizer.QuadPrimitive)
+	 */
+	@Override
+	protected boolean intersectsQuad(QuadPrimitive i_quad) {
+
+		return intersectsPolygon(i_quad);
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolylinePrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolylinePrimitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PolylinePrimitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw3d.geometry.Math2D;
+
+/**
+ * PolylinePrimitive There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class PolylinePrimitive extends AbstractPrimitive {
+
+	private int[] m_points;
+
+	private short[] m_sorted;
+
+	protected PolylinePrimitive(int[] i_points, PrimitiveType i_type) {
+
+		super(i_type);
+
+		if (i_points == null)
+			throw new NullPointerException(&quot;i_points must not be null&quot;);
+
+		m_points = i_points;
+	}
+
+	public PolylinePrimitive(int[] i_points) {
+
+		this(i_points, PrimitiveType.POLYLINE);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#calculateBounds(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	protected void calculateBounds(Rectangle io_bounds) {
+		// TODO implement method PolylinePrimitive.calculateBounds
+
+	}
+
+	protected int[] getPoints() {
+
+		return m_points;
+	}
+
+	protected short[] getSortedIndices() {
+
+		if (m_sorted == null)
+			m_sorted = Math2D.getSortedIndices(m_points);
+
+		return m_sorted;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsLine(org.eclipse.draw3d.graphics.optimizer.LinePrimitive)
+	 */
+	@Override
+	protected boolean intersectsLine(LinePrimitive i_line) {
+		// TODO implement method AbstractPrimitive.intersectsLine
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsPolygon(org.eclipse.draw3d.graphics.optimizer.PolygonPrimitive)
+	 */
+	@Override
+	protected boolean intersectsPolygon(PolygonPrimitive i_polygon) {
+		// TODO implement method AbstractPrimitive.intersectsPolygon
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsPolyline(org.eclipse.draw3d.graphics.optimizer.PolylinePrimitive)
+	 */
+	@Override
+	protected boolean intersectsPolyline(PolylinePrimitive i_polyline) {
+		// TODO implement method AbstractPrimitive.intersectsPolyline
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.optimizer.AbstractPrimitive#intersectsQuad(org.eclipse.draw3d.graphics.optimizer.QuadPrimitive)
+	 */
+	@Override
+	protected boolean intersectsQuad(QuadPrimitive i_quad) {
+		// TODO implement method AbstractPrimitive.intersectsQuad
+		return false;
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/Primitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/Primitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/Primitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Primitive
+ * There should really be more documentation here.
+ *
+ * @author 	Kristian Duske
+ * @version	$Revision$
+ * @since 	18.11.2009
+ */
+public interface Primitive {
+
+	public boolean intersects(Primitive i_candidate);
+
+	public PrimitiveType getType();
+
+	public Rectangle getBounds();
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveSet.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * PrimitiveSet There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class PrimitiveSet {
+
+	private PrimitiveSet m_parent;
+
+	private Collection&lt;Primitive&gt; m_primitives;
+
+	private PrimitiveType m_type;
+
+	public boolean add(Primitive i_primitive) {
+
+		if (i_primitive == null)
+			throw new NullPointerException(&quot;i_primitive must not be null&quot;);
+
+		if (m_type != i_primitive.getType())
+			if (m_parent != null &amp;&amp; !overlaps(i_primitive))
+				return m_parent.add(i_primitive);
+			else
+				return false;
+
+		m_primitives.add(i_primitive);
+		return true;
+	}
+
+	public List&lt;PrimitiveSet&gt; getSets(List&lt;PrimitiveSet&gt; io_result) {
+
+		List&lt;PrimitiveSet&gt; result = io_result;
+		if (result == null)
+			result = new LinkedList&lt;PrimitiveSet&gt;();
+
+		if (m_parent != null)
+			result = m_parent.getSets(result);
+
+		result.add(this);
+		return result;
+	}
+
+	protected PrimitiveType getType() {
+
+		return m_type;
+	}
+
+	protected boolean overlaps(Primitive i_candidate) {
+
+		if (i_candidate == null)
+			throw new NullPointerException(&quot;i_candidate must not be null&quot;);
+
+		for (Primitive primitive : m_primitives)
+			if (primitive.intersects(i_candidate))
+				return true;
+
+		return false;
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveType.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveType.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/PrimitiveType.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,23 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+/**
+ * PrimitiveType There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public enum PrimitiveType {
+
+	POLYGON, QUAD, POLYLINE, LINE;
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/QuadPrimitive.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/QuadPrimitive.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/optimizer/QuadPrimitive.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics.optimizer;
+
+/**
+ * QuadPrimitive There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class QuadPrimitive extends PolygonPrimitive {
+
+	public QuadPrimitive(int[] i_points, boolean i_filled) {
+		super(i_points, i_filled);
+
+		if (i_points.length != 8)
+			throw new IllegalArgumentException(
+				&quot;a quad can only contain 4 vertices&quot;);
+	}
+
+}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/META-INF/MANIFEST.MF	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/META-INF/MANIFEST.MF	2009-11-22 13:46:12 UTC (rev 394)
@@ -5,4 +5,5 @@
 Bundle-Version: 0.8
 Bundle-Vendor: Eclipse.org
 Bundle-RequiredExecutionEnvironment: J2SE-1.5
-Export-Package: org.eclipse.draw3d.geometry
+Export-Package: org.eclipse.draw3d.geometry,
+ org.eclipse.draw3d.geometry.intersection

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math2D.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math2D.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/Math2D.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,337 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry;
+
+import java.util.Comparator;
+
+/**
+ * Math2D There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 18.11.2009
+ */
+public class Math2D {
+
+	public static boolean polylineIntersectsPolyline(int[] polyline1,
+		int[] polyline2) {
+
+		return sortedPolylineIntersectsPolyline(polyline1,
+			getSortedIndices(polyline1), polyline2, getSortedIndices(polyline2));
+	}
+
+	public static boolean sortedPolylineIntersectsPolyline(int[] polyline1,
+		short[] sorted1, int[] i_polyline2, short[] sorted2) {
+
+
+	}
+
+	private static class VertexComparator implements Comparator&lt;Integer&gt; {
+
+		private int[] m_vertices;
+
+		public VertexComparator(int[] i_vertices) {
+
+			m_vertices = i_vertices;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+		 */
+		public int compare(Integer index1, Integer index2) {
+
+			int x1 = m_vertices[2 * index1];
+			int x2 = m_vertices[2 * index2];
+
+			return x1 - x2;
+		}
+
+	}
+
+	private static void checkPoints(int[] i_p, String i_name) {
+
+		if (i_p == null)
+			throw new NullPointerException(i_name + &quot; must not be null&quot;);
+
+		if (i_p.length % 2 != 0)
+			throw new IllegalArgumentException(i_name
+				+ &quot; must contain an even number of coordinates&quot;);
+
+		if (i_p.length &lt; 2)
+			throw new IllegalArgumentException(i_name
+				+ &quot; must contain at least one point&quot;);
+	}
+
+	private static void checkPolygon(int[] i_p, String i_name) {
+
+		if (i_p == null)
+			throw new NullPointerException(i_name + &quot; must not be null&quot;);
+
+		if (i_p.length % 2 != 0)
+			throw new IllegalArgumentException(i_name
+				+ &quot; must contain an even number of coordinates&quot;);
+
+		if (i_p.length &lt; 6)
+			throw new IllegalArgumentException(i_name
+				+ &quot; must contain at least three vertices&quot;);
+	}
+
+	public static short[] getSortedIndices(int[] points) {
+
+		checkPoints(points, &quot;points&quot;);
+
+		int n = points.length / 2;
+		if (n &gt; Short.MAX_VALUE)
+			throw new IllegalArgumentException(&quot;array contains too many points&quot;);
+
+		short[] sorted = new short[n];
+
+		for (short i = 0; i &lt; n; i++)
+			sorted[i] = i;
+
+		quicksort(sorted, points, 0, n - 1);
+		return sorted;
+	}
+
+	/**
+	 * Tests whether the first given polygon contains an edge that separates it
+	 * completely from the second given polygon.
+	 * 
+	 * @param i_p0 the first polygon
+	 * @param i_p1 the second polygon
+	 * @return &lt;code&gt;true&lt;/code&gt; if the first polygon contains such an edge and
+	 *         &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	private static boolean hasSeparator(int[] i_p0, int[] i_p1) {
+
+		int n0 = i_p0.length / 2;
+		for (int i0 = 0, i1 = n0 - 1; i0 &lt; n0; i1 = i0, i0++) {
+			int locx = i_p0[2 * i0];
+			int locy = i_p0[2 * i0 + 1];
+
+			int dirx = -(locy - i_p0[2 * i1 + 1]);
+			int diry = locx - i_p0[2 * i1];
+
+			if (whichSide(i_p1, locx, locy, dirx, diry) &gt; 0)
+				return true;
+		}
+
+		return false;
+	}
+
+	public static int pointsInPolygon(int[] polygon, int[] points) {
+
+		return sortedPointsInPolygon(polygon, points, getSortedIndices(points));
+	}
+
+	public static int sortedPointsInPolygon(int[] polygon, int[] points,
+		short[] sorted, int max) {
+
+		checkPolygon(polygon, &quot;polygon&quot;);
+		checkPoints(points, &quot;points&quot;);
+
+		int numVertices = polygon.length / 2;
+		int numPoints = points.length / 2;
+
+		// find index of the leftmost and rightmost polygon vertices
+		int l = 0;
+		int r = 0;
+		for (int i = 1; i &lt; numVertices; i++) {
+			if (polygon[2 * i] &lt; polygon[2 * l])
+				l = i;
+			if (polygon[2 * i] &gt; polygon[2 * r])
+				r = i;
+		}
+
+		// skip points left of first vertex
+		int pIdx = 0;
+		int px = points[2 * sorted[pIdx]];
+		while (pIdx &lt; numPoints &amp;&amp; px &lt; polygon[2 * l])
+			px = points[2 * sorted[pIdx++]];
+
+		// all points are left of first vertex
+		if (pIdx &gt;= numPoints)
+			return 0;
+
+		// initialize polygon segments
+		int us = l;
+		int ue = wrapIndex(us, numVertices, true);
+		int ls = l;
+		int le = wrapIndex(ls, numVertices, false);
+
+		int num = 0;
+		int py = points[2 * sorted[pIdx] + 1];
+
+		while (pIdx &lt; numPoints &amp;&amp; px &lt; polygon[2 * r]) {
+
+			// find upper segment that contains the point horizontally
+			// also skips vertical segments
+			while (px &gt;= polygon[2 * ue]) {
+				us = ue;
+				ue = wrapIndex(us, numVertices, true);
+			}
+
+			// find lower segment that contains the point horizontally
+			// also skips vertical segments
+			while (px &gt;= polygon[le]) {
+				ls = le;
+				le = wrapIndex(ls, numVertices, false);
+			}
+
+			int usx = polygon[2 * us];
+			int usy = polygon[2 * us + 1];
+			int uex = polygon[2 * ue];
+			int uey = polygon[2 * ue + 1];
+
+			int lsx = polygon[2 * ls];
+			int lsy = polygon[2 * ls + 1];
+			int lex = polygon[2 * le];
+			int ley = polygon[2 * le + 1];
+
+			// is the point between the upper and lower segment extrema?
+			if (py &lt;= Math.max(usy, uey) &amp;&amp; py &gt;= Math.min(lsy, ley)) {
+
+				// construct a vertical segment between the two polygon
+				// segments that has the same X coordinate as the point
+
+				int udy = uey - usy;
+				int udx = uex - usx;
+				float ug = udy / (float) udx;
+
+				int ldy = ley - lsy;
+				int ldx = lex - lsx;
+				float lg = ldy / (float) ldx;
+
+				float uy = ug * (px - usx);
+				float ly = lg * (px - lsx);
+
+				if (Math3D.in(ly, uy, px))
+					num++;
+
+				if (num &gt;= max)
+					return num;
+			}
+
+			pIdx++;
+			px = points[2 * sorted[pIdx]];
+			py = points[2 * sorted[pIdx] + 1];
+		}
+
+		return num;
+	}
+
+	/**
+	 * Determines whether the given polygons intersect. The polygon arrays
+	 * contain the vertices of the polygons in CCW order, with alternating X and
+	 * Y coordinates.
+	 * &lt;p&gt;
+	 * The algorithm implements the separating axis theorem, see
+	 * <a  href="http://www.geometrictools.com/Documentation/MethodOfSeparatingAxes.pdf">http://www.geometrictools.com/Documentation/MethodOfSeparatingAxes.pdf</a>
+	 * &lt;/p&gt;
+	 * 
+	 * @param i_p0 the first polygon
+	 * @param i_p1 the second polygon
+	 * @return &lt;code&gt;true&lt;/code&gt; if the given polygons intersect and
+	 *         &lt;code&gt;false&lt;/code&gt; otherwise
+	 * @throws NullPointerException if either of the given arrays is
+	 *             &lt;code&gt;null&lt;/code&gt;
+	 * @throws IllegalArgumentException if either of the given arrays contains
+	 *             an odd number of coordinates or if either of the given arrays
+	 *             contains less than three vertices
+	 */
+	public static boolean polygonIntersectsPolygon(int[] i_p0, int[] i_p1) {
+
+		checkPolygon(i_p0, &quot;i_p0&quot;);
+		checkPolygon(i_p1, &quot;i_p1&quot;);
+
+		if (hasSeparator(i_p0, i_p1))
+			return false;
+
+		return !hasSeparator(i_p1, i_p0);
+	}
+
+	private static void quicksort(short[] indices, int[] points, int low,
+		int high) {
+
+		int i = low;
+		int j = high;
+
+		int x = points[2 * indices[(low + high) / 2]];
+
+		while (i &lt;= j) {
+			while (points[2 * indices[i]] &lt; x)
+				i++;
+			while (points[2 * indices[j]] &gt; x)
+				j--;
+
+			if (i &lt;= j) {
+				short t = indices[i];
+				indices[i] = indices[j];
+				indices[j] = t;
+
+				i++;
+				j--;
+			}
+		}
+
+		if (low &lt; j)
+			quicksort(indices, points, low, j);
+
+		if (i &lt; high)
+			quicksort(indices, points, i, high);
+	}
+
+	private static int whichSide(int[] polygon, int locx, int locy, int dirx,
+		int diry) {
+
+		int n = polygon.length / 2;
+
+		int pos = 0;
+		int neg = 0;
+
+		for (int i = 0; i &lt; n; i++) {
+
+			// dot product
+			int t = locx * dirx + locy * diry;
+
+			if (t &gt; 0)
+				pos++;
+			else if (t &lt; 0)
+				neg++;
+
+			if (pos &gt; 0 &amp;&amp; neg &gt; 0)
+				return 0;
+		}
+
+		if (pos &gt; 0)
+			return 1;
+
+		return -1;
+	}
+
+	private static int wrapIndex(int index, int length, boolean direction) {
+
+		if (direction) {
+			if (index == length - 1)
+				return 0;
+			return index + 1;
+		}
+
+		if (index == 0)
+			return length - 1;
+
+		return index - 1;
+
+	}
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/AVLTree.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/AVLTree.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/AVLTree.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,610 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry.intersection;
+
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.NoSuchElementException;
+
+/**
+ * Pointer based implementation of an AVL tree (see
+ * <a  href="http://en.wikipedia.org/wiki/AVL_tree">http://en.wikipedia.org/wiki/AVL_tree</a>). This implementation does not allow
+ * duplicates.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @param &lt;T&gt; the data type contained in the tree
+ * @since 20.11.2009
+ */
+public class AVLTree&lt;T&gt; implements Iterable&lt;T&gt; {
+
+	private class AVLNode {
+
+		private T data;
+
+		private int height;
+
+		private AVLNode left;
+
+		private AVLNode next;
+
+		private AVLNode parent;
+
+		private AVLNode previous;
+
+		private AVLNode right;
+
+		public AVLNode(AVLNode i_parent, T i_data) {
+
+			parent = i_parent;
+			data = i_data;
+			height = 0;
+
+			m_nodeMap.put(i_data, this);
+		}
+
+		public AVLNode findNode(T i_data) {
+
+			int c = compare(i_data, data);
+			if (c &lt; 0)
+				return left.findNode(i_data);
+
+			if (c &gt; 0)
+				return right.findNode(i_data);
+
+			return this;
+		}
+
+		private int getBalance() {
+
+			int l = left != null ? left.height : -1;
+			int r = right != null ? right.height : -1;
+
+			return r - l;
+		}
+
+		public T getData() {
+
+			return data;
+		}
+
+		public AVLNode getNext() {
+
+			return this.next;
+		}
+
+		public AVLNode getPrevious() {
+
+			return this.previous;
+		}
+
+		public boolean insert(T i_data) {
+
+			int c = compare(i_data, this.data);
+			if (c &lt; 0) {
+				if (this.left == null) {
+					this.left = new AVLNode(this, i_data);
+					this.height = 1; // height was either 0 or 1
+
+					if (this.previous != null) {
+						this.previous.next = this.left;
+						this.left.previous = this.previous;
+					} else
+						m_first = this.left;
+
+					this.previous = this.left;
+					this.left.next = this;
+
+					return true;
+				} else {
+					boolean success = this.left.insert(i_data);
+					if (success) {
+						updateHeight();
+						rebalanceAfterInsert();
+					}
+					return success;
+				}
+			} else if (c &gt; 0) {
+				if (this.right == null) {
+					this.right = new AVLNode(this, i_data);
+					this.height = 1; // height was either 0 or 1
+
+					if (this.next != null) {
+						this.next.previous = this.right;
+						this.right.next = this.next;
+					} else
+						m_last = this.right;
+
+					this.next = this.right;
+					this.right.previous = this;
+
+					return true;
+				} else {
+					boolean success = this.right.insert(i_data);
+					if (success) {
+						updateHeight();
+						rebalanceAfterInsert();
+					}
+					return success;
+				}
+			} else
+				return false;
+		}
+
+		private void rebalanceAfterInsert() {
+
+			int b = getBalance();
+			if (b &lt; -1) {
+				if (left.getBalance() &lt; 0) {
+					rotateCW();
+				} else {
+					left.rotateCCW();
+					rotateCW();
+				}
+			} else if (b &gt; 1) {
+				if (right.getBalance() &gt; 0) {
+					rotateCCW();
+				} else {
+					right.rotateCW();
+					rotateCCW();
+				}
+			}
+		}
+
+		private void rebalanceAfterRemove() {
+
+			int b = getBalance();
+			if (b &lt; -1) {
+				if (left.getBalance() &lt;= 0) {
+					rotateCW();
+				} else {
+					left.rotateCCW();
+					rotateCW();
+				}
+			} else if (b &gt; 1) {
+				if (right.getBalance() &gt;= 0) {
+					rotateCCW();
+				} else {
+					right.rotateCW();
+					rotateCCW();
+				}
+			}
+		}
+
+		public boolean remove(T i_data) {
+
+			int c = compare(i_data, this.data);
+			if (c &lt; 0) {
+				if (this.left == null) {
+					return false;
+				} else {
+					boolean success = this.left.remove(i_data);
+					if (success) {
+						updateHeight();
+						rebalanceAfterRemove();
+					}
+					return success;
+				}
+			} else if (c &gt; 0) {
+				if (this.right == null) {
+					return false;
+				} else {
+					boolean success = this.right.remove(i_data);
+					if (success) {
+						updateHeight();
+						rebalanceAfterRemove();
+					}
+					return success;
+				}
+			} else {
+				m_nodeMap.remove(i_data);
+
+				if (this.left == null || this.right == null) {
+					if (this.left == null &amp;&amp; this.right == null) {
+						if (this.parent == null)
+							m_root = null;
+						else if (this == this.parent.left)
+							this.parent.left = null;
+						else
+							this.parent.right = null;
+					} else if (this.left == null) {
+						if (this.parent == null)
+							m_root = this.right;
+						else if (this == this.parent.left)
+							this.parent.left = this.right;
+						else
+							this.parent.right = this.right;
+						this.right.parent = this.parent;
+					} else if (this.right == null) {
+						if (this.parent == null)
+							m_root = this.left;
+						else if (this == this.parent.left)
+							this.parent.left = this.left;
+						else
+							this.parent.right = this.left;
+						this.left.parent = this.parent;
+					}
+
+					if (this.previous != null)
+						this.previous.next = this.next;
+					else
+						m_first = this.next;
+
+					if (this.next != null)
+						this.next.previous = this.previous;
+					else
+						m_last = this.previous;
+				} else {
+					AVLNode node = getNext();
+					this.data = node.data;
+
+					this.next = node.next;
+					if (this.next != null)
+						this.next.previous = this;
+
+					if (m_first == node)
+						m_first = this;
+
+					if (m_last == node)
+						m_last = this;
+
+					node.parent.left = node.right;
+					m_nodeMap.put(this.data, this);
+
+					while (node.parent != null) {
+						node = node.parent;
+						node.updateHeight();
+					}
+				}
+
+				return true;
+			}
+		}
+
+		private void rotateCCW() {
+
+			AVLNode tmpRight = this.right;
+			AVLNode tmpParent = this.parent;
+
+			this.right = tmpRight.left;
+			if (this.right != null)
+				this.right.parent = this;
+
+			tmpRight.left = this;
+			this.parent = tmpRight;
+
+			if (tmpParent == null) {
+				m_root = tmpRight;
+				tmpRight.parent = null;
+			} else if (tmpParent.left == this) {
+				tmpParent.left = tmpRight;
+				tmpRight.parent = tmpParent;
+			} else {
+				tmpParent.right = tmpRight;
+				tmpRight.parent = tmpParent;
+			}
+
+			updateHeight();
+			tmpRight.updateHeight();
+
+			if (tmpParent != null)
+				tmpParent.updateHeight();
+		}
+
+		private void rotateCW() {
+
+			AVLNode tmpLeft = this.left;
+			AVLNode tmpParent = this.parent;
+
+			this.left = tmpLeft.right;
+			if (this.left != null)
+				this.left.parent = this;
+
+			tmpLeft.right = this;
+			this.parent = tmpLeft;
+
+			if (tmpParent == null) {
+				m_root = tmpLeft;
+			} else if (tmpParent.left == this) {
+				tmpParent.left = tmpLeft;
+				tmpLeft.parent = tmpParent;
+			} else {
+				tmpParent.right = tmpLeft;
+				tmpLeft.parent = tmpParent;
+			}
+
+			updateHeight();
+			tmpLeft.updateHeight();
+
+			if (tmpParent != null)
+				tmpParent.updateHeight();
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.lang.Object#toString()
+		 */
+		@Override
+		public String toString() {
+
+			return data.toString() + &quot;:&quot; + height;
+		}
+
+		private void updateHeight() {
+
+			int l = this.left != null ? this.left.height : -1;
+			int r = this.right != null ? this.right.height : -1;
+
+			this.height = Math.max(l, r) + 1;
+		}
+	}
+
+	private class AVLTreeIterator implements Iterator&lt;T&gt; {
+
+		private AVLNode m_node;
+
+		public AVLTreeIterator(AVLNode i_startNode) {
+
+			m_node = i_startNode;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#hasNext()
+		 */
+		public boolean hasNext() {
+
+			return m_node != null;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#next()
+		 */
+		public T next() {
+
+			if (!hasNext())
+				throw new NoSuchElementException();
+
+			AVLNode tmp = m_node;
+			m_node = m_node.getNext();
+
+			return tmp.getData();
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#remove()
+		 */
+		public void remove() {
+
+			if (!hasNext())
+				throw new NoSuchElementException();
+
+			AVLNode tmp = m_node;
+			m_node = m_node.getNext();
+
+			AVLTree.this.remove(tmp.getData());
+		}
+	}
+
+	private Comparator&lt;? super T&gt; m_comparator;
+
+	private AVLNode m_first;
+
+	@SuppressWarnings(&quot;unused&quot;)
+	private AVLNode m_last;
+
+	private Map&lt;T, AVLNode&gt; m_nodeMap = new HashMap&lt;T, AVLNode&gt;();
+
+	private AVLNode m_root;
+
+	/**
+	 * Creates a new empty tree.
+	 */
+	public AVLTree() {
+		// nothing to initialize
+	}
+
+	/**
+	 * Creates a new empty tree that uses the given comparator to determine the
+	 * order of the inserted elements.
+	 * 
+	 * @param i_comparator the comparator
+	 */
+	public AVLTree(Comparator&lt;? super T&gt; i_comparator) {
+
+		if (i_comparator == null)
+			throw new NullPointerException(&quot;i_comparator must not be null&quot;);
+
+		m_comparator = i_comparator;
+	}
+
+	@SuppressWarnings(&quot;unchecked&quot;)
+	private int compare(T i_o1, T i_o2) {
+
+		if (m_comparator != null)
+			return m_comparator.compare(i_o1, i_o2);
+
+		Comparable&lt;? super T&gt; comparable = (Comparable&lt;? super T&gt;) i_o1;
+		return comparable.compareTo(i_o2);
+	}
+
+	/**
+	 * Indicates whether the given element is contained in this tree.
+	 * 
+	 * @param i_data the element to check for
+	 * @return &lt;code&gt;true&lt;/code&gt; if the given element is contained in this tree
+	 *         or &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public boolean contains(T i_data) {
+
+		return m_nodeMap.containsKey(i_data);
+	}
+
+	/**
+	 * Returns the successor of the given element, if any.
+	 * 
+	 * @param i_data the element whose successor is requested
+	 * @return the successor of the given element or &lt;code&gt;null&lt;/code&gt; if the
+	 *         given element is not contained in this tree or if the given
+	 *         element does not have a successor
+	 */
+	public T getNext(T i_data) {
+
+		AVLNode node = m_nodeMap.get(i_data);
+		if (node == null)
+			return null;
+
+		AVLNode nextNode = node.getNext();
+		if (nextNode == null)
+			return null;
+
+		return nextNode.getData();
+	}
+
+	/**
+	 * Returns the predecessor of the given element, if any.
+	 * 
+	 * @param i_data the element whose predecessor is requested
+	 * @return the predecessor of the given element or &lt;code&gt;null&lt;/code&gt; if the
+	 *         given element is not contained in this tree or if the given
+	 *         element does not have a predecessor
+	 */
+	public T getPrevious(T i_data) {
+
+		AVLNode node = m_nodeMap.get(i_data);
+		if (node == null)
+			return null;
+
+		AVLNode previousNode = node.getPrevious();
+		if (previousNode == null)
+			return null;
+
+		return previousNode.getData();
+	}
+
+	/**
+	 * Inserts the given element into this tree.
+	 * 
+	 * @param i_data the element to insert
+	 * @return &lt;code&gt;true&lt;/code&gt; if the given element was inserted or
+	 *         &lt;code&gt;false&lt;/code&gt; if the element was already contained in this
+	 *         tree
+	 */
+	public boolean insert(T i_data) {
+
+		if (i_data == null)
+			throw new NullPointerException(&quot;i_data must not be null&quot;);
+
+		if (m_root != null) {
+			return m_root.insert(i_data);
+		} else {
+			m_root = new AVLNode(null, i_data);
+			m_first = m_root;
+			m_last = m_root;
+			return true;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.lang.Iterable#iterator()
+	 */
+	public Iterator&lt;T&gt; iterator() {
+
+		return new AVLTreeIterator(m_first);
+	}
+
+	/**
+	 * Removes the given element from this tree.
+	 * 
+	 * @param i_data the element to remove
+	 * @return &lt;code&gt;true&lt;/code&gt; if the given element was removed or
+	 *         &lt;code&gt;false&lt;/code&gt; if the given element was not contained in this
+	 *         tree
+	 */
+	public boolean remove(T i_data) {
+
+		if (i_data == null)
+			throw new NullPointerException(&quot;i_data must not be null&quot;);
+
+		if (m_root != null)
+			return m_root.remove(i_data);
+		else
+			return false;
+	}
+
+	/**
+	 * Returns the number of elements contained in this tree.
+	 * 
+	 * @return the number of elements
+	 */
+	public int size() {
+
+		return m_nodeMap.size();
+	}
+
+	/**
+	 * Returns an array containing the elements in this tree.
+	 * 
+	 * @return an array
+	 */
+	@SuppressWarnings(&quot;unchecked&quot;)
+	public T[] toArray() {
+
+		Object[] array = new Object[size()];
+
+		int i = 0;
+		for (Object data : this)
+			array[i++] = data;
+
+		return (T[]) array;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+
+		if (m_root == null)
+			return &quot;[]&quot;;
+
+		StringBuilder b = new StringBuilder();
+		toString(m_root, b);
+		return b.toString();
+	}
+
+	private void toString(AVLNode i_node, StringBuilder i_builder) {
+
+		i_builder.append(&quot;[&quot;);
+		if (i_node.left != null)
+			toString(i_node.left, i_builder);
+		else if (i_node.right != null)
+			i_builder.append(&quot;[]&quot;);
+		i_builder.append(i_node.getData());
+		if (i_node.right != null)
+			toString(i_node.right, i_builder);
+		else if (i_node.left != null)
+			i_builder.append(&quot;[]&quot;);
+		i_builder.append(&quot;]&quot;);
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/CombinedPointQueue.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/CombinedPointQueue.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/CombinedPointQueue.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,117 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry.intersection;
+
+import java.util.Collection;
+import java.util.HashSet;
+
+/**
+ * CombinedPointQueue There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 19.11.2009
+ */
+public class CombinedPointQueue implements PointQueue {
+
+	private Collection&lt;PointQueue&gt; m_queues = new HashSet&lt;PointQueue&gt;();
+
+	private PointQueue m_insertQueue;
+
+	private static final int DEF_INSERT_SIZE = 10;
+
+	public CombinedPointQueue() {
+
+		m_insertQueue =
+			new PointQueue(new int[2 * DEF_INSERT_SIZE],
+				new int[DEF_INSERT_SIZE], 0);
+		m_queues.add(insertQueue);
+	}
+
+	public void addQueue(int[] i_points, int[] i_sorted, int i_size) {
+
+		m_queues.add(new PointQueue(i_points, i_sorted, i_size));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#isEmpty()
+	 */
+	public boolean isEmpty() {
+
+		for (PointQueue queue : m_queues)
+			if (!queue.isEmpty())
+				return false;
+
+		return m_insertQueue.isEmpty();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#next(int[])
+	 */
+	public boolean next(int[] i_result) {
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#peek(int[])
+	 */
+	public void peek(int[] i_result) {
+		// TODO implement method CombinedPointQueue.peek
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#pop(int[])
+	 */
+	public void pop(int[] i_result) {
+		// TODO implement method CombinedPointQueue.pop
+
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#previous(int[])
+	 */
+	public boolean previous(int[] i_result) {
+		// TODO implement method CombinedPointQueue.previous
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#push(int, int)
+	 */
+	public int push(int i_x, int i_y) {
+		// TODO implement method CombinedPointQueue.push
+		return 0;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.geometry.intersection.PointQueue#size()
+	 */
+	public int size() {
+		// TODO implement method CombinedPointQueue.size
+		return 0;
+	}
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PointQueue.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PointQueue.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PointQueue.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry.intersection;
+
+import java.util.NoSuchElementException;
+
+/**
+ * PointQueueImpl There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 19.11.2009
+ */
+public class PointQueue {
+
+	private int m_index;
+
+	private int m_size;
+
+	private int[] m_sorted;
+
+	public PointQueue(int[] i_sorted, int i_size) {
+
+		m_sorted = i_sorted;
+		m_size = i_size;
+		m_index = 0;
+	}
+
+	public boolean isEmpty() {
+
+		return m_index == m_size;
+	}
+
+	public int next() {
+
+		if (isEmpty())
+			throw new NoSuchElementException();
+
+		if (m_sorted[m_index] == m_size - 1)
+			return -1;
+
+		return m_sorted[m_index] + 1;
+	}
+
+	public int peek() {
+
+		if (isEmpty())
+			throw new NoSuchElementException();
+
+		return m_sorted[m_index];
+	}
+
+	public int pop() {
+
+		if (isEmpty())
+			throw new NoSuchElementException();
+
+		return m_sorted[m_index]++;
+	}
+
+	public int previous() {
+
+		if (isEmpty())
+			throw new NoSuchElementException();
+
+		if (m_sorted[m_index] == 0)
+			return -1;
+
+		return m_sorted[m_index] - 1;
+	}
+
+	public int[] push(int i_x, int i_y, int[] i_points) {
+
+		int[] points = i_points;
+		if (m_size == points.length / 2) {
+			int[] t = points;
+			points = new int[2 * points.length];
+			System.arraycopy(t, 0, points, 0, t.length);
+		}
+
+		if (m_size == m_sorted.length) {
+			int[] t = m_sorted;
+			m_sorted = new int[2 * m_sorted.length];
+			System.arraycopy(t, 0, m_sorted, 0, t.length);
+		}
+
+		// find insert position
+		// TODO use binary search
+		int ins = 0;
+		while (ins &lt; m_size &amp;&amp; points[2 * m_sorted[ins]] &lt; i_x)
+			ins++;
+
+		if (ins &lt; m_size)
+			System.arraycopy(m_sorted, ins, m_sorted, ins + 1, m_size - ins);
+
+		points[2 * m_size] = i_x;
+		points[2 * m_size + 1] = i_y;
+		m_sorted[ins] = m_size;
+
+		m_size++;
+		if (ins &lt; m_index)
+			m_index++;
+
+		return points;
+	}
+
+	public int size() {
+
+		return m_size;
+	}
+
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PolylineIntersectsPolylineAlgorithm.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PolylineIntersectsPolylineAlgorithm.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.geometry/src/java/org/eclipse/draw3d/geometry/intersection/PolylineIntersectsPolylineAlgorithm.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,142 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry.intersection;
+
+/**
+ * PolylineIntersectsPolylineAlgorithm There should really be more documentation
+ * here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 19.11.2009
+ */
+public class PolylineIntersectsPolylineAlgorithm {
+
+	private static enum Structure {
+		POLYLINE1, POLYLINE2, INTERSECTION, DONE;
+
+		public boolean isSegment() {
+
+			return this == POLYLINE1 || this == POLYLINE2;
+		}
+	}
+
+	private int[] isx;
+
+	private int[] isy;
+
+	private int is;
+
+	private int i1;
+
+	private int i2;
+
+	private int nis;
+
+	private int[] pl1;
+
+	private int[] pl2;
+
+	private int[] s1;
+
+	private int[] s2;
+
+	private int handleSegment(int[] pl, int si1, int si2) {
+
+		int x1 = pl[2 * si1];
+		int x2 = pl[2 * si2];
+
+		if (x1 == x2)
+			return testVerticalSegment(si1, si2);
+
+		if (x1 &lt; x2)
+			return insertSegment(si1, si2);
+
+		deleteSegment(si1, si2);
+		return false;
+	}
+
+	public int intersects(int i_max) {
+
+		Structure a;
+		int num = 0;
+		while ((a = next()) != Structure.DONE) {
+
+			if (a.isSegment()) {
+				int si;
+				int n;
+				int[] pl;
+
+				if (a == Structure.POLYLINE1) {
+					si = s1[i1];
+					pl = pl1;
+					n = s1.length;
+				} else {
+					si = s2[i2];
+					pl = pl2;
+					n = s2.length;
+				}
+
+				if (si == 0)
+					num += handleSegment(pl, 0, 1);
+				else if (si == n - 1)
+					num  += handleSegment(pl, n - 1, n - 2);
+				else {
+					num += handleSegment(pl, si, si - 1);
+					if (num &lt; i_max)
+						num += handleSegment(pl, si, si - 2);
+				}
+
+				if (num &gt;= i_max)
+					return num;
+			} else {
+				handleIntersection();
+			}
+		}
+
+		return num;
+	}
+
+	private Structure next() {
+
+		if (i1 == s1.length || i2 == s2.length)
+			return Structure.DONE;
+
+		int x1, x2, xis;
+		if (i1 &lt; s1.length)
+			x1 = pl1[2 * s1[i1]];
+		else
+			x1 = Integer.MAX_VALUE;
+
+		if (i2 &lt; s2.length)
+			x2 = pl2[2 * s2[i2]];
+		else
+			x2 = Integer.MAX_VALUE;
+
+		if (is &lt; nis)
+			xis = isx[is];
+		else
+			xis = Integer.MAX_VALUE;
+
+		if (x1 &lt; x2 &amp;&amp; x1 &lt; xis) {
+			i1++;
+			return Structure.POLYLINE1;
+		}
+
+		if (x2 &lt; x1 &amp;&amp; x2 &lt; xis) {
+			i2++;
+			return Structure.POLYLINE2;
+		}
+
+		is++;
+		return Structure.INTERSECTION;
+	}
+}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/META-INF/MANIFEST.MF	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/META-INF/MANIFEST.MF	2009-11-22 13:46:12 UTC (rev 394)
@@ -8,4 +8,5 @@
 Require-Bundle: org.eclipse.draw2d;bundle-version=&quot;3.4.0&quot;,
  org.eclipse.draw3d.geometry;bundle-version=&quot;0.8.0&quot;,
  org.eclipse.core.runtime;bundle-version=&quot;3.4.0&quot;
-Export-Package: org.eclipse.draw3d.graphics3d
+Export-Package: org.eclipse.draw3d.graphics3d,
+ org.eclipse.draw3d.util.resource

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -149,10 +149,11 @@
 		if (log.isLoggable(Level.FINE))
 			log.fine(&quot;creating display list with key '&quot; + i_key + &quot;'&quot;);
 
-		doCreateDisplayList(i_key, i_runnable);
+		DisplayList list = doCreateDisplayList(i_key, i_runnable);
 
 		if (log.isLoggable(Level.FINE))
-			log.fine(&quot;display list with key '&quot; + i_key + &quot;' created&quot;);
+			log.fine(&quot;display list with key '&quot; + i_key + &quot;' created under id &quot;
+				+ list.getId());
 	}
 
 	public void createDisplayLists(Map&lt;Object, Runnable&gt; i_requests) {
@@ -183,13 +184,16 @@
 		if (m_disposed)
 			return;
 
+		if (log.isLoggable(Level.FINE))
+			log.info(&quot;disposing display list manager &quot; + this);
+
 		clear();
 		m_baseIds = null;
 		m_displayLists = null;
 		m_creationStack = null;
 	}
 
-	private void doCreateDisplayList(Object i_key, Runnable i_runnable) {
+	private DisplayList doCreateDisplayList(Object i_key, Runnable i_runnable) {
 
 		if (m_displayLists.containsKey(i_key))
 			deleteDisplayLists(i_key);
@@ -220,8 +224,11 @@
 			m_graphics3D.glEndList();
 		}
 
-		m_displayLists.put(i_key, new DisplayList(id, subListIds));
+		DisplayList list = new DisplayList(id, subListIds);
+		m_displayLists.put(i_key, list);
 		m_creationStack.removeLast();
+
+		return list;
 	}
 
 	private void deleteDisplayList(Integer id) {

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -190,6 +190,10 @@
 		try {
 			if (m_textureManager != null)
 				m_textureManager.dispose();
+			if (m_fontManager != null)
+				m_fontManager.dispose();
+			if (m_displayListManager != null)
+				m_displayListManager.dispose();
 		} catch (Exception ex) {
 			log.warning(&quot;Error disposing texture manager: &quot; + ex);
 		}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -15,6 +15,7 @@
 import java.nio.IntBuffer;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.draw3d.graphics3d.DisplayListManager;
@@ -244,7 +245,6 @@
 					}
 				} finally {
 					GL11.glPopAttrib();
-					GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
 				}
 			} finally {
 				if (gc != null &amp;&amp; !gc.isDisposed())
@@ -290,10 +290,15 @@
 		if (m_disposed)
 			return;
 
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;disposing font &quot; + this);
+
 		if (m_textureId != -1) {
 			IntBuffer intBuf = Draw3DCache.getIntBuffer(1);
 			try {
 				intBuf.put(0, m_textureId);
+				intBuf.rewind();
+
 				GL11.glDeleteTextures(intBuf);
 				m_textureId = -1;
 			} finally {

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -18,6 +18,7 @@
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
@@ -281,11 +282,31 @@
 
 		checkDisposed();
 
-		for (LwjglLinePattern linePattern : m_linePatterns.values())
-			linePattern.dispose();
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;disposing graphics &quot; + this);
 
+		// for (LwjglLinePattern linePattern : m_linePatterns.values())
+		// linePattern.dispose();
+		//
+		// if (!m_images.isEmpty()) {
+		// IntBuffer textureNames = Draw3DCache.getIntBuffer(m_images.size());
+		// try {
+		// textureNames.rewind();
+		// for (Integer textureId : m_images.values())
+		// textureNames.put(textureId);
+		//
+		// textureNames.rewind();
+		// GL11.glDeleteTextures(textureNames);
+		// } finally {
+		// Draw3DCache.returnIntBuffer(textureNames);
+		// }
+		//
+		// m_images.clear();
+		// }
+
 		m_fontManager = null;
 		m_linePatterns = null;
+		m_images = null;
 
 		m_disposed = true;
 	}
@@ -368,6 +389,8 @@
 		drawImage(i_srcImage, x1, y1, w, h, x2, y2, w, h);
 	}
 
+	private Map&lt;Image, Integer&gt; m_images = new HashMap&lt;Image, Integer&gt;();
+
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -382,56 +405,71 @@
 
 		glSetRasterOffset(RasterOffset.POLYGON);
 		try {
-			ConversionSpecs specs = new ConversionSpecs();
-			specs.foregroundAlpha = 255;
-			specs.textureWidth = i_w1;
-			specs.textureHeight = i_h1;
-			specs.clip =
-				new org.eclipse.swt.graphics.Rectangle(i_x1, i_y1, i_w1, i_h1);
-			BufferInfo info =
-				new BufferInfo(m_width, m_height, GL11.GL_RGBA,
-					GL11.GL_UNSIGNED_BYTE, 1);
-			ImageConverter converter = ImageConverter.getInstance();
-			ByteBuffer buffer =
-				converter.imageToBuffer(i_srcImage, info, null, false);
-			IntBuffer nameBuffer = IntBuffer.allocate(1);
-			GL11.glGenTextures(nameBuffer);
-			int textureId = nameBuffer.get(0);
+			GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
 			try {
+				Integer textureId = m_images.get(i_srcImage);
+				if (textureId == null) {
+					ConversionSpecs specs = new ConversionSpecs();
+					specs.foregroundAlpha = 255;
+					specs.textureWidth = i_w1;
+					specs.textureHeight = i_h1;
+					specs.clip =
+						new org.eclipse.swt.graphics.Rectangle(i_x1, i_y1,
+							i_w1, i_h1);
 
-				GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
-				GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, i_w1,
-					i_h1, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
+					BufferInfo info =
+						new BufferInfo(m_width, m_height, GL11.GL_RGBA,
+							GL11.GL_UNSIGNED_BYTE, 1);
 
-				GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
-				try {
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
-					GL11.glTexEnvi(GL11.GL_TEXTURE_ENV,
-						GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
+					ByteBuffer buffer =
+						Draw3DCache.getByteBuffer(info.getSize());
+					IntBuffer nameBuffer = Draw3DCache.getIntBuffer(1);
+					try {
+						ImageConverter converter = ImageConverter.getInstance();
+						buffer =
+							converter.imageToBuffer(i_srcImage, info, buffer,
+								false);
 
-					GL11.glBegin(GL11.GL_QUADS);
-					GL11.glTexCoord2f(0, 0);
-					GL11.glVertex2i(i_x2, i_y2);
+						nameBuffer.rewind();
+						GL11.glGenTextures(nameBuffer);
 
-					GL11.glTexCoord2f(1, 0);
-					GL11.glVertex2i(i_x2 + i_w2, i_y2);
+						textureId = nameBuffer.get(0);
+						GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
+						GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA,
+							i_w1, i_h1, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE,
+							buffer);
 
-					GL11.glTexCoord2f(1, 1);
-					GL11.glVertex2i(i_x2 + i_w2, i_y2 + i_h2);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
+						GL11.glTexEnvi(GL11.GL_TEXTURE_ENV,
+							GL11.GL_TEXTURE_ENV_MODE, GL11.GL_REPLACE);
+					} finally {
+						Draw3DCache.returnIntBuffer(nameBuffer);
+						Draw3DCache.returnByteBuffer(buffer);
+					}
+				} else {
+					GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
+				}
 
-					GL11.glTexCoord2f(0, 1);
-					GL11.glVertex2i(i_x2, i_y2 + i_h2);
-					GL11.glEnd();
-				} finally {
-					GL11.glPopAttrib();
-				}
+				GL11.glBegin(GL11.GL_QUADS);
+				GL11.glTexCoord2f(0, 0);
+				GL11.glVertex2i(i_x2, i_y2);
+
+				GL11.glTexCoord2f(1, 0);
+				GL11.glVertex2i(i_x2 + i_w2, i_y2);
+
+				GL11.glTexCoord2f(1, 1);
+				GL11.glVertex2i(i_x2 + i_w2, i_y2 + i_h2);
+
+				GL11.glTexCoord2f(0, 1);
+				GL11.glVertex2i(i_x2, i_y2 + i_h2);
+				GL11.glEnd();
 			} finally {
-				GL11.glDeleteTextures(nameBuffer);
+				GL11.glPopAttrib();
 			}
 		} finally {
 			glResetRasterOffset();

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-17 16:52:29 UTC (rev 393)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -12,6 +12,7 @@
 
 import java.util.HashMap;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
@@ -265,17 +266,16 @@
 		if (m_disposed)
 			return;
 
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;disposing texture manager &quot; + this);
+
 		deactivateTexture();
 		for (LwjglTexture lwjglTexture : m_textures.values())
 			lwjglTexture.dispose();
 
 		m_textures = null;
+		m_fontManager = null;
 
-		if (m_fontManager != null) {
-			m_fontManager.dispose();
-			m_fontManager = null;
-		}
-
 		m_disposed = true;
 	}
 

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection/AVLTreeTest.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection/AVLTreeTest.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.test/src/java/org/eclipse/draw3d/geometry/intersection/AVLTreeTest.java	2009-11-22 13:46:12 UTC (rev 394)
@@ -0,0 +1,135 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.geometry.intersection;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+
+import junit.framework.TestCase;
+
+/**
+ * AVLTreeTest There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 20.11.2009
+ */
+public class AVLTreeTest extends TestCase {
+
+	private AVLTree&lt;Integer&gt; tree =
+		new AVLTree&lt;Integer&gt;(new Comparator&lt;Integer&gt;() {
+			public int compare(Integer i_o1, Integer i_o2) {
+				return i_o1 - i_o2;
+			}
+		});
+
+	private int[] toArray() {
+
+		Object[] numbers = tree.toArray();
+		int[] result = new int[numbers.length];
+
+		for (int i = 0; i &lt; numbers.length; i++)
+			result[i] = (Integer) numbers[i];
+
+		return result;
+	}
+
+	private int[] numbers(int n) {
+
+		ArrayList&lt;Integer&gt; numbers = new ArrayList&lt;Integer&gt;(n);
+		for (int i = 0; i &lt; n; i++)
+			numbers.add(i);
+
+		Collections.shuffle(numbers);
+
+		int[] result = new int[n];
+		for (int i = 0; i &lt; n; i++)
+			result[i] = numbers.get(i);
+
+		return result;
+	}
+
+	private static final int[] UNIQUE_NUMBERS_100 =
+		new int[] { 35, 98, 7, 53, 92, 66, 58, 63, 74, 89, 16, 9, 5, 34, 73, 1,
+			88, 81, 2, 83, 32, 99, 62, 33, 10, 19, 37, 65, 36, 40, 54, 48, 86,
+			70, 28, 79, 51, 87, 82, 57, 77, 59, 85, 78, 94, 27, 23, 20, 24, 22,
+			72, 17, 8, 64, 6, 29, 39, 76, 25, 12, 71, 95, 44, 0, 47, 60, 13,
+			41, 3, 42, 14, 61, 75, 90, 96, 4, 56, 15, 43, 69, 11, 45, 93, 30,
+			52, 49, 68, 38, 18, 84, 97, 80, 21, 26, 55, 67, 91, 46, 50, 31 };
+
+	private static final int[] UNIQUE_NUMBERS_10 =
+		new int[] { 35, 98, 7, 53, 92, 66, 58, 63, 74, 89 };
+
+	private static final int[] DUPLICATE_NUMBERS =
+		new int[] { 23, 0, 35, 61, 41, 55, 66, 90, 86, 55, 46, 37, 21, 29, 15,
+			87, 25, 60, 71, 82, 36, 76, 32, 48, 18, 21, 42, 76, 82, 54, 33, 92,
+			40, 46, 33, 34, 23, 41, 75, 27, 65, 55, 50, 62, 14, 14, 23, 50, 74,
+			38, 5, 69, 28, 54, 44, 8, 96, 94, 77, 76, 23, 20, 95, 99, 42, 69,
+			41, 76, 49, 28, 96, 85, 39, 35, 45, 95, 32, 6, 92, 91, 98, 52, 39,
+			91, 17, 88, 3, 93, 38, 45, 80, 93, 31, 23, 12, 79, 2, 95, 26, 27 };
+
+	public void testInsert() {
+
+		int[] numbers = UNIQUE_NUMBERS_100.clone();
+
+		for (int i = 0; i &lt; numbers.length; i++)
+			tree.insert(numbers[i]);
+
+		Arrays.sort(numbers);
+		assertTrue(Arrays.equals(numbers, toArray()));
+	}
+
+	private int[] remove(int[] numbers, int i) {
+
+		if (numbers.length == 0)
+			return numbers;
+
+		tree.remove(numbers[i]);
+
+		int[] result = new int[numbers.length - 1];
+		System.arraycopy(numbers, 0, result, 0, i);
+		System.arraycopy(numbers, i + 1, result, i, numbers.length - i - 1);
+
+		return result;
+	}
+
+	public void testRemove() {
+
+		int[] numbers =
+			Arrays.copyOf(UNIQUE_NUMBERS_10, UNIQUE_NUMBERS_10.length);
+
+		for (int i = 0; i &lt; numbers.length; i++)
+			tree.insert(numbers[i]);
+
+		for (int i = 0; i &lt; numbers.length; i++) {
+			numbers = remove(numbers, i % numbers.length);
+
+			int[] tmp = Arrays.copyOf(numbers, numbers.length);
+			Arrays.sort(tmp);
+
+			System.out.println(Arrays.toString(tmp));
+			System.out.println(Arrays.toString(toArray()));
+			assertTrue(Arrays.equals(tmp, toArray()));
+		}
+
+		/*
+		 * Random r = new Random(System.currentTimeMillis()); while
+		 * (numbers.length &gt; 0) { numbers = remove(numbers,
+		 * r.nextInt(numbers.length)); int[] tmp = Arrays.copyOf(numbers,
+		 * numbers.length); Arrays.sort(tmp);
+		 * System.out.println(Arrays.toString(tmp));
+		 * System.out.println(Arrays.toString(toArray()));
+		 * assertTrue(Arrays.equals(tmp, toArray())); }
+		 */
+	}
+}


</pre>]]></content:encoded>
		<pubDate>Sun, 22 Nov 2009 13:46:22 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00239.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r393 -	trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00238.html</link>
		<description>Author: jvonpilgrim Date: 2009-11-17 11:52:29 -0500 (Tue, 17 Nov 2009) New Revision: 393 Modified: trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3DRegistry.java Log: NEW - bug 295306: Load graphics3d extensions whenever...</description>
		<content:encoded><![CDATA[<pre>Author: jvonpilgrim
Date: 2009-11-17 11:52:29 -0500 (Tue, 17 Nov 2009)
New Revision: 393

Modified:
   trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3DRegistry.java
Log:
NEW - bug 295306: Load graphics3d extensions whenever a renderer is requested. 
<a  href="https://bugs.eclipse.org/bugs/show_bug.cgi?id=295306">https://bugs.eclipse.org/bugs/show_bug.cgi?id=295306</a>

The list of graphics3D extensions is loaded the first time it is required and then cached. The cache can be reset via resetDescriptors().

Modified: trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3DRegistry.java
===================================================================
--- trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3DRegistry.java	2009-11-16 12:30:55 UTC (rev 392)
+++ trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3DRegistry.java	2009-11-17 16:52:29 UTC (rev 393)
@@ -23,15 +23,18 @@
 import org.eclipse.core.runtime.IExtensionPoint;
 import org.eclipse.core.runtime.IExtensionRegistry;
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.draw3d.geometry.Vector3f;
-import org.eclipse.swt.opengl.GLCanvas;
-import org.osgi.framework.Bundle;
 
 /**
  * Graphics3DRegistry is aware of the existing Graphics3D implementors and can
  * create instances of them. Please note, that the Graphics3DRegistry does not
  * manage the Graphics3D instances. Once created and returned, the
  * Graphics3DRegistry does not store any reference to them any more.
+ * &lt;p&gt;
+ * Plugins implementing the {@link Graphics3D} interface register themselves
+ * using the extension point {@value #GRAPHICS3D_EP}. The plugin registry is
+ * evaluated if no descripters were found so far, the result is cached and maybe
+ * resetted using {@link #resetDescriptors()}.
+ * &lt;/p&gt;
  * 
  * @author Matthias Thiele, Jens von Pilgrim
  * @version $Revision$
@@ -41,33 +44,27 @@
 	/**
 	 * Logger for this class
 	 */
-	private static final Logger log = Logger.getLogger(Graphics3DRegistry.class
-			.getName());
+	private static final Logger log =
+		Logger.getLogger(Graphics3DRegistry.class.getName());
 
-	private final static List&lt;Graphics3DDescriptor&gt; descriptors = new Vector&lt;Graphics3DDescriptor&gt;();
-	
-	static {
-		updateDescriptors();
-	}
+	private final static List&lt;Graphics3DDescriptor&gt; descriptors =
+		new Vector&lt;Graphics3DDescriptor&gt;();
 
-	// /**
-	// * Identifies the LWJGL-Renderer implementation of Graphics3D.
-	// */
-	// public static final String G3D_IMPL_LWJGL = &quot;LWJGL&quot;;
-	//
-	// /**
-	// * Identifies the X3D-Export-Renderer implementation of Graphics3D (Not
-	// * existing yet).
-	// */
-	// public static final String G3D_IMPL_X3D = &quot;X3D&quot;;
-	//
-	// /**
-	// * Identifies the default renderer implementation of Graphics3D.
-	// */
-	// public static final String G3D_IMPL_DEFAULT = G3D_IMPL_LWJGL;
+	public static final String GRAPHICS3D_EP = &quot;org.eclipse.draw3d.graphics3d&quot;;
 
+	/**
+	 * Returns the descriptor for the default screen renderer, i.e. the first
+	 * screen renderer found.
+	 * &lt;p&gt;
+	 * The descriptors are retrieved from the plugin registry and cached. In
+	 * order to force the registry to be evaluated again, call
+	 * {@link #resetDescriptors()}.
+	 * &lt;/p&gt;
+	 * 
+	 * @return the descriptor or null, if no such descriptor was found
+	 */
 	public static Graphics3DDescriptor getDefaultScreenRenderer() {
-//		updateDescriptors();
+		updateDescriptors();
 		for (Graphics3DDescriptor descr : descriptors) {
 			if (descr.getType() == Graphics3DType.SCREEN) {
 				return descr;
@@ -78,11 +75,19 @@
 	}
 
 	/**
+	 * Returns the descritor of a {@link Graphics3D} implementation with the
+	 * given ID.
+	 * &lt;p&gt;
+	 * The descriptors are retrieved from the plugin registry and cached. In
+	 * order to force the registry to be evaluated again, call
+	 * {@link #resetDescriptors()}.
+	 * &lt;/p&gt;
+	 * 
 	 * @param i_rendererID
-	 * @return
+	 * @return the descriptor or null, if no such descriptor was found
 	 */
 	public static Graphics3DDescriptor getRenderer(String i_rendererID) {
-//		updateDescriptors();
+		updateDescriptors();
 		for (Graphics3DDescriptor descr : descriptors) {
 			if (descr.getRendererID().equals(i_rendererID)) {
 				return descr;
@@ -94,10 +99,23 @@
 		return null;
 	}
 
+	/**
+	 * Returns a list of descriptors of {@link Graphics3D} implementations for a
+	 * given {@link Graphics3DType}.
+	 * &lt;p&gt;
+	 * The descriptors are retrieved from the plugin registry and cached. In
+	 * order to force the registry to be evaluated again, call
+	 * {@link #resetDescriptors()}.
+	 * &lt;/p&gt;
+	 * 
+	 * @param type
+	 * @return the list with descriptors, may be empty
+	 */
 	public static List&lt;Graphics3DDescriptor&gt; getRenderersForType(
-			Graphics3DType type) {
-//		updateDescriptors();
-		List&lt;Graphics3DDescriptor&gt; result = new ArrayList&lt;Graphics3DDescriptor&gt;();
+		Graphics3DType type) {
+		updateDescriptors();
+		List&lt;Graphics3DDescriptor&gt; result =
+			new ArrayList&lt;Graphics3DDescriptor&gt;();
 		for (Graphics3DDescriptor descr : descriptors) {
 			if (descr.getType() == type) {
 				result.add(descr);
@@ -106,57 +124,83 @@
 		return result;
 	}
 
-	
+	/**
+	 * Reset internal cached list of Graphics3D descriptors. The next time a
+	 * renderer is requested, the descriptor list is updated.
+	 */
+	public static void resetDescriptors() {
+		descriptors.clear();
+	}
 
+	/**
+	 * Lazily reads and caches a list of descriptors. All getter methods call
+	 * this method to ensure the descriptors have been read. With
+	 * {@link #resetDescriptors()}, the cache can be cleared in order to re-read
+	 * the descriptors.
+	 */
 	private static void updateDescriptors() {
-		descriptors.clear();
+		synchronized (descriptors) {
+			if (descriptors.size() &gt; 0)
+				return;
 
-		IExtensionRegistry registry = Platform.getExtensionRegistry();
-		IExtensionPoint point = registry
-				.getExtensionPoint(&quot;org.eclipse.draw3d.graphics3d&quot;);
-		if (point == null)
-			return;
-		IExtension[] extensions = point.getExtensions();
+			IExtensionRegistry registry = Platform.getExtensionRegistry();
+			IExtensionPoint point = registry.getExtensionPoint(GRAPHICS3D_EP);
+			if (point == null) {
+				log.severe(&quot;Extension point '&quot; + GRAPHICS3D_EP + &quot;' not found&quot;); //$NON-NLS-1$
+				return;
+			}
+			IExtension[] extensions = point.getExtensions();
 
-		for (IExtension extension : extensions) {
-			String strContributorName = extension.getContributor().getName();
-			if (log.isLoggable(Level.INFO)) {
-				log.info(&quot;Extension found: &quot; + extension
+			for (IExtension extension : extensions) {
+				String strContributorName =
+					extension.getContributor().getName();
+				if (log.isLoggable(Level.INFO)) {
+					log.info(&quot;Extension found: &quot; + extension
 						+ &quot;, Contributor: &quot; + strContributorName); //$NON-NLS-1$
-			}
-			
+				}
 
-			IConfigurationElement[] ices = extension.getConfigurationElements();
-			for (IConfigurationElement element : ices) {
-				if (element.getName().equals(&quot;renderer&quot;)) {
-					Graphics3DDescriptor descriptor = new Graphics3DDescriptor();
-					descriptor.setContributorName(strContributorName);
-					descriptor.setRendererID(element.getAttribute(&quot;id&quot;));
-					descriptor.setClassname(element.getAttribute(&quot;class&quot;));
-					descriptor.setType(Graphics3DType.valueOf(element
+				IConfigurationElement[] ices =
+					extension.getConfigurationElements();
+				for (IConfigurationElement element : ices) {
+					if (element.getName().equals(&quot;renderer&quot;)) {
+						Graphics3DDescriptor descriptor =
+							new Graphics3DDescriptor();
+						descriptor.setContributorName(strContributorName);
+						descriptor.setRendererID(element.getAttribute(&quot;id&quot;));
+						descriptor.setClassname(element.getAttribute(&quot;class&quot;));
+						descriptor.setType(Graphics3DType.valueOf(element
 							.getAttribute(&quot;type&quot;)));
 
-					IConfigurationElement name = element.getChildren(&quot;name&quot;)[0];
-					descriptor.setName(name.getValue());
-					IConfigurationElement descr = element
-							.getChildren(&quot;description&quot;)[0];
-					descriptor.setDescription(descr.getValue());
+						IConfigurationElement name =
+							element.getChildren(&quot;name&quot;)[0];
+						descriptor.setName(name.getValue());
+						IConfigurationElement descr =
+							element.getChildren(&quot;description&quot;)[0];
+						descriptor.setDescription(descr.getValue());
 
-					IConfigurationElement[] params = element
-							.getChildren(&quot;parameter&quot;);
-					if (params != null) {
-						for (IConfigurationElement param : params) {
-							descriptor.getParameters().setProperty(
+						IConfigurationElement[] params =
+							element.getChildren(&quot;parameter&quot;);
+						if (params != null) {
+							for (IConfigurationElement param : params) {
+								descriptor.getParameters().setProperty(
 									param.getAttribute(&quot;name&quot;),
 									param.getAttribute(&quot;value&quot;));
+							}
 						}
-					}
 
-					descriptors.add(descriptor);
+						descriptors.add(descriptor);
 
+					}
 				}
+
 			}
+		}
 
+		if (descriptors.size() == 0) {
+			log.severe(&quot;No plugins for extension point '&quot; //$NON-NLS-1$
+				+ GRAPHICS3D_EP + &quot;' found&quot;); //$NON-NLS-1$
+			return;
+
 		}
 
 	}


</pre>]]></content:encoded>
		<pubDate>Tue, 17 Nov 2009 16:52:30 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00238.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r392 - in branches/experimental_direct_2D_rendering:	org.eclipse.draw3d/src/java/org/eclipse/draw3d/util	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00237.html</link>
		<description>Author: kduske Date: 2009-11-16 07:30:55 -0500 (Mon, 16 Nov 2009) New Revision: 392 Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/ArcHelper.java Modified: branches/experimental_direct_2D_rendering/org....</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-16 07:30:55 -0500 (Mon, 16 Nov 2009)
New Revision: 392

Added:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/ArcHelper.java
Modified:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
Log:
- optimized arc drawing code


Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/ArcHelper.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/ArcHelper.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/util/ArcHelper.java	2009-11-16 12:30:55 UTC (rev 392)
@@ -0,0 +1,154 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.util;
+
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+
+import org.eclipse.draw3d.geometry.IVector2f;
+import org.eclipse.draw3d.geometry.Vector2f;
+import org.eclipse.draw3d.geometry.Vector2fImpl;
+
+/**
+ * A fast algorithm for drawing smooth arcs using line segments. This
+ * implementation is based on <a  href="http://slabode.exofire.net/circle_draw.shtml">http://slabode.exofire.net/circle_draw.shtml</a>.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 13.11.2009
+ */
+public class ArcHelper implements Iterable&lt;IVector2f&gt; {
+
+	private class ArcIterator implements Iterator&lt;IVector2f&gt; {
+
+		private Vector2f m_next = new Vector2fImpl();
+
+		private Vector2f m_result = new Vector2fImpl();
+
+		private int m_segment = 0;
+
+		private ArcIterator() {
+
+			m_next.set(m_start);
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#hasNext()
+		 */
+		public boolean hasNext() {
+
+			return m_segment &lt;= m_numSegments;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#next()
+		 */
+		public IVector2f next() {
+
+			if (!hasNext())
+				throw new NoSuchElementException();
+
+			float x = m_next.getX();
+			float y = m_next.getY();
+
+			m_result.setX(x * m_axes.getX() + m_center.getX());
+			m_result.setY(y * -m_axes.getY() + m_center.getY());
+			m_segment++;
+
+			if (hasNext()) {
+				float t = x;
+				x = m_cos * x - m_sin * y;
+				y = m_sin * t + m_cos * y;
+
+				m_next.set(x, y);
+			}
+
+			return m_result;
+		}
+
+		/**
+		 * {@inheritDoc}
+		 * 
+		 * @see java.util.Iterator#remove()
+		 */
+		public void remove() {
+			throw new UnsupportedOperationException();
+		}
+
+	}
+
+	private static final float PI2 = (float) Math.PI * 2;
+
+	private IVector2f m_axes;
+
+	private IVector2f m_center;
+
+	private float m_cos;
+
+	private int m_numSegments;
+
+	private float m_sin;
+
+	private IVector2f m_start;
+
+	/**
+	 * Creates a new helper for drawing an ellipse arc with the given
+	 * parameters.
+	 * 
+	 * @param i_precision a precision factor, must be greater than 0 and less
+	 *            than or equal to 1
+	 * @param i_x the X coordinate of the ellipse's bounding box
+	 * @param i_y the Y coordinate of the ellipse's bounding box
+	 * @param i_width the width of the bounding box
+	 * @param i_height the height of the bounding box
+	 * @param i_start the start angle, in radians
+	 * @param i_length the angle length, in radians
+	 */
+	public ArcHelper(float i_precision, float i_x, float i_y, float i_width,
+			float i_height, float i_start, float i_length) {
+
+		if (i_precision &lt;= 0 || i_precision &gt; 1)
+			throw new IllegalArgumentException(
+				&quot;precision must be greater than 0 and less than or equal to 1&quot;);
+
+		float start = i_start % PI2;
+		float length = i_length % PI2;
+
+		m_axes = new Vector2fImpl(i_width / 2, i_height / 2);
+		m_center = new Vector2fImpl(i_x + m_axes.getX(), i_y + m_axes.getY());
+
+		float avgRadius = (m_axes.getX() + m_axes.getY()) / 2;
+		m_numSegments =
+			(int) Math.ceil(i_precision * 10 * Math.sqrt(avgRadius) * length
+				/ PI2);
+
+		float theta = length / m_numSegments;
+		m_cos = (float) Math.cos(theta);
+		m_sin = (float) Math.sin(theta);
+
+		m_start =
+			new Vector2fImpl((float) Math.cos(start), (float) Math.sin(start));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.lang.Iterable#iterator()
+	 */
+	public Iterator&lt;IVector2f&gt; iterator() {
+
+		return new ArcIterator();
+	}
+}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-12 19:23:15 UTC (rev 391)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-16 12:30:55 UTC (rev 392)
@@ -25,6 +25,7 @@
 import org.eclipse.draw2d.geometry.PrecisionRectangle;
 import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.draw3d.geometry.IMatrix4f;
+import org.eclipse.draw3d.geometry.IVector2f;
 import org.eclipse.draw3d.geometry.Math3D;
 import org.eclipse.draw3d.geometry.Matrix4f;
 import org.eclipse.draw3d.graphics.GraphicsState;
@@ -32,6 +33,7 @@
 import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFont;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
+import org.eclipse.draw3d.util.ArcHelper;
 import org.eclipse.draw3d.util.ColorConverter;
 import org.eclipse.draw3d.util.Draw3DCache;
 import org.eclipse.draw3d.util.ImageConverter.ConversionSpecs;
@@ -162,6 +164,8 @@
 	private static final float ARC_LENGTH_FACTOR =
 		4 * (float) Math.PI * (float) Math.PI;
 
+	private static final float ARC_PRECISION = 0.5f;
+
 	/**
 	 * Decrease this factor to get a larger number of segments and vice versa.
 	 */
@@ -188,12 +192,12 @@
 
 	private LwjglLinePattern m_currentLinePattern;
 
+	private DisplayListManager m_displayListManager;
+
 	private boolean m_disposed = false;
 
 	private LwjglFontManager m_fontManager;
 
-	private DisplayListManager m_displayListManager;
-
 	private int m_height;
 
 	private LastColor m_lastColor = LastColor.UNKNOWN;
@@ -450,8 +454,7 @@
 			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
-					float s =
-						m_currentLinePattern.getS(i_x1, i_y1, i_x2, i_y2);
+					float s = m_currentLinePattern.getS(i_x1, i_y1, i_x2, i_y2);
 
 					GL11.glBegin(GL11.GL_LINES);
 					GL11.glTexCoord1f(0);
@@ -908,29 +911,14 @@
 	private void glDrawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
 		int i_length) {
 
-		float start = (float) Math.toRadians(i_offset);
-		float length = (float) Math.toRadians(i_length);
+		float rOffset = (float) Math.toRadians(i_offset);
+		float rLength = (float) Math.toRadians(i_length);
 
-		float xFactor = i_w / 2;
-		float yFactor = i_h / 2;
+		ArcHelper helper =
+			new ArcHelper(ARC_PRECISION, i_x, i_y, i_w, i_h, rOffset, rLength);
 
-		float avgRadius = (xFactor + yFactor) / 2;
-		float arcLength = ARC_LENGTH_FACTOR * avgRadius / length;
-
-		float inc = ARC_SEGMENTS_FACTOR / arcLength;
-
-		float xOffset = i_x + i_w / 2;
-		float yOffset = i_y + i_h / 2;
-
-		for (float a = start; a &lt; start + length; a += ARC_INC) {
-			float x = xOffset + (float) Math.cos(a) * xFactor;
-			float y = yOffset - (float) Math.sin(a) * yFactor;
-			GL11.glVertex2f(x, y);
-		}
-
-		float x = xOffset + (float) Math.cos(start + length) * xFactor;
-		float y = yOffset - (float) Math.sin(start + length) * yFactor;
-		GL11.glVertex2f(x, y);
+		for (IVector2f v : helper)
+			GL11.glVertex2f(v.getX(), v.getY());
 	}
 
 	private void glDrawPointList(PointList i_points) {
@@ -970,28 +958,28 @@
 		float h2 = h / 2;
 
 		// left
-		GL11.glVertex2f(x1, y1 + h2);
+		// GL11.glVertex2f(x1, y1 + h2);
 		// GL11.glVertex2f(x1, y2 - h2);
 
 		// bottom left corner
 		glDrawArc(x1, y2 - h, w, h, 180, 90);
 
 		// bottom
-		GL11.glVertex2f(x1 + w2, y2);
+		// GL11.glVertex2f(x1 + w2, y2);
 		// GL11.glVertex2f(x2 - w2, y2);
 
 		// bottom right corner
 		glDrawArc(x2 - w, y2 - h, w, h, 270, 90);
 
 		// right
-		GL11.glVertex2f(x2, y2 - h2);
+		// GL11.glVertex2f(x2, y2 - h2);
 		// GL11.glVertex2f(x2, y1 + h2);
 
 		// top right corner
 		glDrawArc(x2 - w, y1, w, h, 0, 90);
 
 		// top
-		GL11.glVertex2f(x2 - w2, y1);
+		// GL11.glVertex2f(x2 - w2, y1);
 		// GL11.glVertex2f(x1 + w2, y1);
 
 		// top left corner
@@ -1524,10 +1512,10 @@
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
 	 */
 	@Override
-	public void setLineDash(int[] i_dash) {
+	public void setLineDash(float[] i_dash) {
 
 		int[] previous = getState().getLineDash();
 		super.setLineDash(i_dash);
@@ -1539,10 +1527,10 @@
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
+	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
 	 */
 	@Override
-	public void setLineDash(float[] i_dash) {
+	public void setLineDash(int[] i_dash) {
 
 		int[] previous = getState().getLineDash();
 		super.setLineDash(i_dash);


</pre>]]></content:encoded>
		<pubDate>Mon, 16 Nov 2009 12:30:55 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00237.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r391 - in branches/experimental_direct_2D_rendering:	org.eclipse.draw3d/src/java/org/eclipse/draw3d	org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes	org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture	org.eclipse.gef3d.examples.graph/src/java/org/eclipse/gef3d/examples/graph/editor/editparts</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00236.html</link>
		<description>Author: kduske Date: 2009-11-12 14:23:15 -0500 (Thu, 12 Nov 2009) New Revision: 391 Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java branches/experimental_direc...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-12 14:23:15 -0500 (Thu, 12 Nov 2009)
New Revision: 391

Modified:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglLinePattern.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java
   branches/experimental_direct_2D_rendering/org.eclipse.gef3d.examples.graph/src/java/org/eclipse/gef3d/examples/graph/editor/editparts/IntermodelEdgePart.java
Log:
- badly broken intermediate state with lots of errors, but I want to commit this for safety reasons anyway

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -463,39 +463,46 @@
 	 * 
 	 * @param i_graphics the graphics object to paint on
 	 */
-	private void paintChildren2D(Graphics i_graphics) {
+	private void paintChildren2D(final Graphics i_graphics) {
 
 		final Collection&lt;IFigure&gt; children2D = getChildren2D();
 		if (!children2D.isEmpty()) {
 			final IFigure3D figure = m_figuresFriend.figure;
-			ISurface surface = figure.getSurface();
+			final ISurface surface = figure.getSurface();
 
 			RenderContext renderContext = figure.getRenderContext();
-			Graphics3D g3d = renderContext.getGraphics3D();
+			final Graphics3D g3d = renderContext.getGraphics3D();
 
 			DisplayListManager displayListManager = g3d.getDisplayListManager();
 
 			if (surface != null &amp;&amp; surface.is2DHost()) {
 				if ((renderContext.isRedraw2DContent() || m_figuresFriend.is2DContentDirty())) {
-					final Graphics graphics = surface.activate(g3d);
+					displayListManager.interruptDisplayList();
 					try {
-						graphics.setFont(i_graphics.getFont());
-						configureGraphics(graphics);
-
 						displayListManager.createDisplayList(figure,
 							new Runnable() {
 								public void run() {
-									doPaintChildren2D(children2D, figure,
-										graphics);
+									Graphics graphics = surface.activate(g3d);
+									try {
+										graphics.setFont(i_graphics.getFont());
+										configureGraphics(graphics);
+										doPaintChildren2D(children2D, figure,
+											graphics);
+									} finally {
+										surface.deactivate(g3d);
+									}
 								}
 							});
 					} finally {
-						surface.deactivate(g3d);
+						displayListManager.resumeDisplayList();
 					}
+				}
 
-					displayListManager.executeDisplayList(figure);
-				}
+				displayListManager.executeDisplayList(figure);
 			} else {
+				Graphics graphics = i_graphics;
+				graphics.setFont(i_graphics.getFont());
+				configureGraphics(graphics);
 				doPaintChildren2D(children2D, figure, i_graphics);
 			}
 		}
@@ -555,8 +562,8 @@
 		IFigure3D figure = m_figuresFriend.figure;
 		RenderContext renderContext = figure.getRenderContext();
 
-		Graphics3D g3d = renderContext.getGraphics3D();
-		g3d.deactivateGraphics2D();
+		// Graphics3D g3d = renderContext.getGraphics3D();
+		// g3d.deactivateGraphics2D();
 
 		figure.collectRenderFragments(renderContext);
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -423,9 +423,6 @@
 		public void paint(Graphics i_graphics) {
 
 			RenderContext renderContext = getRenderContext();
-			// display list not set here, automatically created and set by
-			// render context
-			// renderContext.setDisplayListManager(m_displayListManager);
 			renderContext.setScene(LightweightSystem3D.this);
 
 			// ignore the incoming graphics object if it is not a dummy
@@ -443,8 +440,6 @@
 				paintClientArea(graphics);
 
 				renderContext.renderFragments();
-
-				// renderContext.getGraphics3D().glFlush();
 			} finally {
 				for (ISceneListener listener : m_listeners)
 					listener.renderPassFinished(getRenderContext());

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -305,10 +305,15 @@
 			}
 		};
 
-		i_displayListManager.createDisplayList(DL_OUTLINE, outline);
-		i_displayListManager.createDisplayList(DL_FILL_FRONT, front);
-		i_displayListManager.createDisplayList(DL_TEXTURE, texture);
-		i_displayListManager.createDisplayList(DL_FILL_REST, rest);
+		i_displayListManager.interruptDisplayList();
+		try {
+			i_displayListManager.createDisplayList(DL_OUTLINE, outline);
+			i_displayListManager.createDisplayList(DL_FILL_FRONT, front);
+			i_displayListManager.createDisplayList(DL_TEXTURE, texture);
+			i_displayListManager.createDisplayList(DL_FILL_REST, rest);
+		} finally {
+			i_displayListManager.resumeDisplayList();
+		}
 	}
 
 	private void renderFill(DisplayListManager displayListManager,

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -590,20 +590,32 @@
 	private void initDisplayLists(DisplayListManager i_manager,
 		final Graphics3D i_graphics3D) {
 
-		if (m_fill &amp;&amp; !i_manager.isDisplayList(m_fillKey)) {
-			i_manager.createDisplayList(m_fillKey, new Runnable() {
-				public void run() {
-					renderFill(i_graphics3D);
-				}
-			});
-		}
+		boolean initFill = m_fill &amp;&amp; !i_manager.isDisplayList(m_fillKey);
+		boolean initOutline =
+			m_outline &amp;&amp; !i_manager.isDisplayList(m_outlineKey);
 
-		if (m_outline &amp;&amp; !i_manager.isDisplayList(m_outlineKey)) {
-			i_manager.createDisplayList(m_outlineKey, new Runnable() {
-				public void run() {
-					renderOutline(i_graphics3D);
-				}
-			});
+		if (!initFill &amp;&amp; !initOutline)
+			return;
+
+		i_manager.interruptDisplayList();
+		try {
+			if (initFill) {
+				i_manager.createDisplayList(m_fillKey, new Runnable() {
+					public void run() {
+						renderFill(i_graphics3D);
+					}
+				});
+			}
+
+			if (initOutline) {
+				i_manager.createDisplayList(m_outlineKey, new Runnable() {
+					public void run() {
+						renderOutline(i_graphics3D);
+					}
+				});
+			}
+		} finally {
+			i_manager.resumeDisplayList();
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -331,38 +331,50 @@
 	private void initDisplayLists(DisplayListManager i_manager,
 		final Graphics3D i_graphics3D) {
 
-		if (m_fill &amp;&amp; !i_manager.isDisplayList(m_fillKey)) {
-			i_manager.createDisplayList(m_fillKey, new Runnable() {
-				public void run() {
-					i_graphics3D.glPushMatrix();
-					try {
-						renderFill(i_graphics3D);
-						for (int i = 0; i &lt; 3; i++) {
-							i_graphics3D.setPosition(ROTATE_Z90);
+		boolean initFill = m_fill &amp;&amp; !i_manager.isDisplayList(m_fillKey);
+		boolean initOutline =
+			m_outline &amp;&amp; !i_manager.isDisplayList(m_outlineKey);
+
+		if (!initFill &amp;&amp; !initOutline)
+			return;
+
+		i_manager.interruptDisplayList();
+		try {
+			if (initFill) {
+				i_manager.createDisplayList(m_fillKey, new Runnable() {
+					public void run() {
+						i_graphics3D.glPushMatrix();
+						try {
 							renderFill(i_graphics3D);
+							for (int i = 0; i &lt; 3; i++) {
+								i_graphics3D.setPosition(ROTATE_Z90);
+								renderFill(i_graphics3D);
+							}
+						} finally {
+							i_graphics3D.glPopMatrix();
 						}
-					} finally {
-						i_graphics3D.glPopMatrix();
 					}
-				}
-			});
-		}
+				});
+			}
 
-		if (m_outline &amp;&amp; !i_manager.isDisplayList(m_outlineKey)) {
-			i_manager.createDisplayList(m_outlineKey, new Runnable() {
-				public void run() {
-					i_graphics3D.glPushMatrix();
-					try {
-						renderOutline(i_graphics3D);
-						for (int i = 0; i &lt; 3; i++) {
-							i_graphics3D.setPosition(ROTATE_Z90);
+			if (initOutline) {
+				i_manager.createDisplayList(m_outlineKey, new Runnable() {
+					public void run() {
+						i_graphics3D.glPushMatrix();
+						try {
 							renderOutline(i_graphics3D);
+							for (int i = 0; i &lt; 3; i++) {
+								i_graphics3D.setPosition(ROTATE_Z90);
+								renderOutline(i_graphics3D);
+							}
+						} finally {
+							i_graphics3D.glPopMatrix();
 						}
-					} finally {
-						i_graphics3D.glPopMatrix();
 					}
-				}
-			});
+				});
+			}
+		} finally {
+			i_manager.resumeDisplayList();
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -11,12 +11,14 @@
 package org.eclipse.draw3d.graphics3d;
 
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
 import java.util.Queue;
 import java.util.Map.Entry;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 /**
@@ -28,17 +30,51 @@
  */
 public class DisplayListManager {
 
+	private class DisplayList {
+		private int m_id;
+
+		private int[] m_subIds;
+
+		public DisplayList(int i_id, Collection&lt;Integer&gt; i_subIds) {
+
+			m_id = i_id;
+
+			if (i_subIds != null &amp;&amp; !i_subIds.isEmpty()) {
+				m_subIds = new int[i_subIds.size()];
+
+				int i = 0;
+				for (Integer subId : i_subIds)
+					m_subIds[i++] = subId;
+			}
+		}
+
+		public int getId() {
+
+			return m_id;
+		}
+
+		public int[] getSubIds() {
+
+			return m_subIds;
+		}
+	}
+
 	@SuppressWarnings(&quot;unused&quot;)
 	private static final Logger log =
 		Logger.getLogger(DisplayListManager.class.getName());
 
 	private static final int RANGE = 10;
 
+	private boolean m_active = false;
+
 	private List&lt;Integer&gt; m_baseIds = new ArrayList&lt;Integer&gt;();
 
-	private Map&lt;Object, Integer&gt; m_displayLists =
-		new HashMap&lt;Object, Integer&gt;();
+	private LinkedList&lt;LinkedList&lt;Integer&gt;&gt; m_creationStack =
+		new LinkedList&lt;LinkedList&lt;Integer&gt;&gt;();
 
+	private Map&lt;Object, DisplayList&gt; m_displayLists =
+		new HashMap&lt;Object, DisplayList&gt;();
+
 	private final boolean m_disposed = false;
 
 	private Queue&lt;Integer&gt; m_freeIds = new LinkedList&lt;Integer&gt;();
@@ -77,11 +113,12 @@
 		m_baseIds.clear();
 		m_displayLists.clear();
 		m_freeIds.clear();
+		m_creationStack.clear();
+		m_active = false;
+
+		log.fine(&quot;display list manager cleared&quot;);
 	}
 
-	private LinkedList&lt;List&lt;Integer&gt;&gt; m_creationStack =
-		new LinkedList&lt;List&lt;Integer&gt;&gt;();
-
 	/**
 	 * Creates a new display lists with the given key. The display lists will
 	 * contain the GL commands that are executed by the given runnable. If there
@@ -105,78 +142,116 @@
 		if (i_runnable == null)
 			throw new NullPointerException(&quot;i_runnable must not be null&quot;);
 
-		if (!m_creationStack.isEmpty())
-			m_graphics3D.glEnd();
+		if (m_active)
+			throw new IllegalStateException(
+				&quot;cannot create a display list while another list is being created&quot;);
 
-		Integer id = doCreateDisplayList(i_key, i_runnable);
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;creating display list with key '&quot; + i_key + &quot;'&quot;);
 
-		if (!m_creationStack.isEmpty()) {
-			id = getNewId();
-			m_creationStack.getLast().add(id);
-			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
-		}
+		doCreateDisplayList(i_key, i_runnable);
+
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;display list with key '&quot; + i_key + &quot;' created&quot;);
 	}
 
-	private Integer doCreateDisplayList(Object i_key, Runnable i_runnable) {
+	public void createDisplayLists(Map&lt;Object, Runnable&gt; i_requests) {
 
-		Integer id = m_displayLists.get(i_key);
-		if (id == null)
-			id = getNewId();
+		if (i_requests == null)
+			throw new NullPointerException(&quot;i_requests must not be null&quot;);
 
-		List&lt;Integer&gt; subListIds = new LinkedList&lt;Integer&gt;();
+		if (m_active)
+			throw new IllegalStateException(
+				&quot;cannot create a display list while another list is being created&quot;);
+
+		if (log.isLoggable(Level.FINE))
+			log.fine(&quot;creating &quot; + i_requests.size()
+				+ &quot; display lists with keys '&quot; + i_requests.keySet() + &quot;'&quot;);
+
+		for (Entry&lt;Object, Runnable&gt; entry : i_requests.entrySet())
+			doCreateDisplayList(entry.getKey(), entry.getValue());
+
+		if (log.isLoggable(Level.FINE))
+			log.fine(i_requests.size() + &quot; display lists created&quot;);
+	}
+
+	/**
+	 * Disposes all ressources associated with this display list manager.
+	 */
+	public void dispose() {
+
+		if (m_disposed)
+			return;
+
+		clear();
+		m_baseIds = null;
+		m_displayLists = null;
+		m_creationStack = null;
+	}
+
+	private void doCreateDisplayList(Object i_key, Runnable i_runnable) {
+
+		if (m_displayLists.containsKey(i_key))
+			deleteDisplayLists(i_key);
+
+		Integer id = getNewId();
+
+		LinkedList&lt;Integer&gt; subListIds = new LinkedList&lt;Integer&gt;();
 		subListIds.add(id);
 		m_creationStack.addLast(subListIds);
 
+		m_active = true;
 		m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
 		i_runnable.run();
 		m_graphics3D.glEndList();
+		m_active = false;
 
 		if (subListIds.size() &gt; 1) {
 			id = getNewId();
+
+			if (log.isLoggable(Level.FINE))
+				log.fine(&quot;merging &quot; + subListIds.size()
+					+ &quot; display lists with ids &quot; + subListIds
+					+ &quot; into one list with key '&quot; + i_key + &quot;' and id &quot; + id);
+
 			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
 			for (Integer subListId : subListIds)
 				m_graphics3D.glCallList(subListId);
 			m_graphics3D.glEndList();
 		}
 
-		m_displayLists.put(i_key, id);
+		m_displayLists.put(i_key, new DisplayList(id, subListIds));
 		m_creationStack.removeLast();
+	}
 
-		return id;
+	private void deleteDisplayList(Integer id) {
+
+		m_graphics3D.glDeleteLists(id, 1);
+		m_freeIds.offer(id);
 	}
 
-	public void createDisplayLists(Map&lt;Object, Runnable&gt; i_requests) {
+	public void deleteDisplayLists(Object... i_keys) {
 
-		if (i_requests == null)
-			throw new NullPointerException(&quot;i_requests must not be null&quot;);
+		for (Object key : i_keys) {
+			DisplayList list = m_displayLists.get(key);
+			if (list == null)
+				throw new IllegalArgumentException(&quot;list with key '&quot; + i_keys
+					+ &quot;' does not exist&quot;);
 
-		if (!m_creationStack.isEmpty())
-			m_graphics3D.glEnd();
+			if (log.isLoggable(Level.FINE))
+				log.fine(&quot;deleting display list with key '&quot; + key + &quot;'&quot;);
 
-		for (Entry&lt;Object, Runnable&gt; entry : i_requests.entrySet())
-			doCreateDisplayList(entry.getKey(), entry.getValue());
+			deleteDisplayList(list.getId());
+			int[] subIds = list.getSubIds();
+			if (subIds != null)
+				for (int i = 0; i &lt; subIds.length; i++)
+					deleteDisplayList(subIds[i]);
 
-		if (!m_creationStack.isEmpty()) {
-			Integer id = getNewId();
-			m_creationStack.getLast().add(id);
-			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+			m_displayLists.remove(key);
 		}
 	}
 
 	/**
-	 * Disposes all ressources associated with this display list manager.
-	 */
-	public void dispose() {
-
-		if (m_disposed)
-			return;
-
-		clear();
-		m_baseIds = null;
-		m_displayLists = null;
-	}
-
-	/**
 	 * Executes the display list with the given key.
 	 * 
 	 * @param i_key the key of the display list to execute
@@ -195,11 +270,11 @@
 		if (i_key == null)
 			throw new NullPointerException(&quot;i_key must not be null&quot;);
 
-		Integer id = m_displayLists.get(i_key);
-		if (id == null)
+		DisplayList list = m_displayLists.get(i_key);
+		if (list == null)
 			throw new IllegalArgumentException(&quot;unknown display list: &quot; + i_key);
 
-		m_graphics3D.glCallList(id);
+		m_graphics3D.glCallList(list.getId());
 	}
 
 	/**
@@ -226,6 +301,18 @@
 		return baseId + m_index++;
 	}
 
+	public void interruptDisplayList() {
+
+		if (!m_creationStack.isEmpty()) {
+			if (log.isLoggable(Level.FINE))
+				log.fine(&quot;interrupting creation of display list with id &quot;
+					+ m_creationStack.getLast().getLast());
+			m_graphics3D.glEndList();
+
+			m_active = false;
+		}
+	}
+
 	/**
 	 * Indicates whether a number of display lists have been registered with
 	 * this manager.
@@ -248,4 +335,21 @@
 		return true;
 	}
 
+	public void resumeDisplayList() {
+
+		if (!m_creationStack.isEmpty()) {
+			Integer id = getNewId();
+
+			if (log.isLoggable(Level.FINE))
+				log.fine(&quot;resuming creation of display list with id &quot;
+					+ m_creationStack.getLast().getLast() + &quot; under new id &quot;
+					+ id);
+
+			m_creationStack.getLast().add(id);
+			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+
+			m_active = true;
+		}
+	}
+
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -122,9 +122,14 @@
 	public Graphics activateGraphics2D(Object i_key, IPosition3D i_position,
 		int i_width, int i_height) {
 
+		log.info(&quot;activating 2D graphics&quot;);
+
 		LwjglGraphics graphics =
-			new LwjglGraphics(i_width, i_height, getFontManager());
+			new LwjglGraphics(i_width, i_height, getDisplayListManager(),
+				getFontManager());
 
+		graphics.disableClipping();
+
 		String fontAntialias = getProperty(PROP_FONT_AA);
 		if (fontAntialias != null)
 			graphics.setOverrideTextAntialias(Boolean.valueOf(fontAntialias));
@@ -170,6 +175,8 @@
 	 */
 	public void deactivateGraphics2D() {
 
+		log.info(&quot;deactivating 2D graphics&quot;);
+
 		GL11.glPopMatrix();
 		GL11.glPopAttrib();
 	}
@@ -276,7 +283,8 @@
 
 		if (m_textureManager == null)
 			m_textureManager =
-				new LwjglTextureManager(m_context, getFontManager());
+				new LwjglTextureManager(m_context, getDisplayListManager(),
+					getFontManager());
 		else if (m_textureManager.isDisposed())
 			throw new IllegalStateException(&quot;TextureManager is disposed&quot;);
 
@@ -816,7 +824,6 @@
 			properties.setProperty(key, value);
 		else
 			properties.remove(key);
-
 	}
 
 	/**

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -108,169 +108,178 @@
 
 		m_displayListManager = i_displayListManager;
 
-		m_startChar = i_startChar;
-		m_endChar = i_endChar;
+		m_displayListManager.interruptDisplayList();
+		try {
+			m_startChar = i_startChar;
+			m_endChar = i_endChar;
 
-		int numChars = m_endChar - m_startChar + 1;
-		m_chars = new LwjglFontChar[numChars];
+			int numChars = m_endChar - m_startChar + 1;
+			m_chars = new LwjglFontChar[numChars];
 
-		Device device = i_font.getDevice();
-		Image image = null;
-		GC gc = null;
-		try {
-			image = new Image(device, 1, 1);
-			gc = new GC(image);
+			Device device = i_font.getDevice();
+			Image image = null;
+			GC gc = null;
+			try {
+				image = new Image(device, 1, 1);
+				gc = new GC(image);
 
-			gc.setFont(i_font);
-			m_fontMetrics = gc.getFontMetrics();
+				gc.setFont(i_font);
+				m_fontMetrics = gc.getFontMetrics();
 
-			m_tabWidth = gc.textExtent(&quot;\t&quot;).x;
-			int height = m_fontMetrics.getHeight();
+				m_tabWidth = gc.textExtent(&quot;\t&quot;).x;
+				int height = m_fontMetrics.getHeight();
 
-			// calculate the area needed to render all available characters
-			long area = 0;
-			for (int i = 0; i &lt; numChars; i++) {
+				// calculate the area needed to render all available characters
+				long area = 0;
+				for (int i = 0; i &lt; numChars; i++) {
 
-				char c = (char) (m_startChar + i);
-				String s = Character.toString(c);
-				Point cExtent = gc.stringExtent(s);
+					char c = (char) (m_startChar + i);
+					String s = Character.toString(c);
+					Point cExtent = gc.stringExtent(s);
 
-				m_chars[i] = new LwjglFontChar(cExtent.x, height);
-				area += (cExtent.x + 1) * (height + 1);
-			}
+					m_chars[i] = new LwjglFontChar(c, cExtent.x, height);
+					area += (cExtent.x + 1) * (height + 1);
+				}
 
-			// calculate the texture dimensions needed to hold all characters
-			int sideLength = 64; // minimum texture size
-			int textureArea = 0;
-			while (textureArea &lt; area) {
-				sideLength *= 2;
-				textureArea = sideLength * sideLength;
-			}
+				// calculate the texture dimensions needed to hold all
+				// characters
+				int sideLength = 64; // minimum texture size
+				int textureArea = 0;
+				while (textureArea &lt; area) {
+					sideLength *= 2;
+					textureArea = sideLength * sideLength;
+				}
 
-			m_width = sideLength;
-			m_height = sideLength;
+				m_width = sideLength;
+				m_height = sideLength;
 
-			gc.dispose();
-			image.dispose();
+				gc.dispose();
+				image.dispose();
 
-			// create and initialize the image and GC to draw the characters
-			image = new Image(device, m_width, m_height);
-			gc = new GC(image);
+				// create and initialize the image and GC to draw the characters
+				image = new Image(device, m_width, m_height);
+				gc = new GC(image);
 
-			gc.setTextAntialias(i_antiAliased ? SWT.ON : SWT.OFF);
-			gc.setFont(i_font);
-			gc.setForeground(device.getSystemColor(SWT.COLOR_BLACK));
-			gc.setBackground(device.getSystemColor(SWT.COLOR_WHITE));
-			gc.fillRectangle(image.getBounds());
+				gc.setTextAntialias(i_antiAliased ? SWT.ON : SWT.OFF);
+				gc.setFont(i_font);
+				gc.setForeground(device.getSystemColor(SWT.COLOR_BLACK));
+				gc.setBackground(device.getSystemColor(SWT.COLOR_WHITE));
+				gc.fillRectangle(image.getBounds());
 
-			// fill the image with the available characters
-			int x = 0;
-			int y = 0;
-			for (int i = 0; i &lt; numChars; i++) {
+				// fill the image with the available characters
+				int x = 0;
+				int y = 0;
+				for (int i = 0; i &lt; numChars; i++) {
 
-				LwjglFontChar fontChar = m_chars[i];
-				int w = fontChar.getWidth() + 1;
+					LwjglFontChar fontChar = m_chars[i];
+					int w = fontChar.getWidth() + 1;
 
-				if (x + w &gt; m_width) {
-					x = 0;
-					y += height + 1;
-				}
+					if (x + w &gt; m_width) {
+						x = 0;
+						y += height + 1;
+					}
 
-				char c = (char) (m_startChar + i);
-				String s = Character.toString(c);
-				gc.drawString(s, x, y);
+					char c = (char) (m_startChar + i);
+					String s = Character.toString(c);
+					gc.drawString(s, x, y);
 
-				float s1 = (float) x / m_width;
-				float t1 = (float) y / m_height;
-				float s2 = (float) (x + fontChar.getWidth()) / m_width;
-				float t2 = (float) (y + height) / m_height;
-				fontChar.setTextureCoords(s1, t1, s2, t2);
+					float s1 = (float) x / m_width;
+					float t1 = (float) y / m_height;
+					float s2 = (float) (x + fontChar.getWidth()) / m_width;
+					float t2 = (float) (y + height) / m_height;
+					fontChar.setTextureCoords(s1, t1, s2, t2);
 
-				x += w;
-			}
+					x += w;
+				}
 
-			// create a luminance alpha texture from the image
-			BufferInfo info =
-				new BufferInfo(m_width, m_height, GL11.GL_LUMINANCE_ALPHA,
-					GL11.GL_UNSIGNED_BYTE, 1);
+				// create a luminance alpha texture from the image
+				BufferInfo info =
+					new BufferInfo(m_width, m_height, GL11.GL_LUMINANCE_ALPHA,
+						GL11.GL_UNSIGNED_BYTE, 1);
 
-			ImageConverter converter = ImageConverter.getInstance();
-			ByteBuffer buffer =
-				converter.imageToBuffer(image, info, null, false);
+				ImageConverter converter = ImageConverter.getInstance();
+				ByteBuffer buffer =
+					converter.imageToBuffer(image, info, null, false);
 
-			GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
-			try {
-				IntBuffer intBuf = Draw3DCache.getIntBuffer(1);
+				GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
 				try {
-					GL11.glGenTextures(intBuf);
-					m_textureId = intBuf.get(0);
+					IntBuffer intBuf = Draw3DCache.getIntBuffer(1);
+					try {
+						GL11.glGenTextures(intBuf);
+						m_textureId = intBuf.get(0);
 
-					GL11.glBindTexture(GL11.GL_TEXTURE_2D, m_textureId);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
-					GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0,
-						GL11.GL_LUMINANCE_ALPHA, m_width, m_height, 0,
-						GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE, buffer);
+						GL11.glBindTexture(GL11.GL_TEXTURE_2D, m_textureId);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
+							GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
+						GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0,
+							GL11.GL_LUMINANCE_ALPHA, m_width, m_height, 0,
+							GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE,
+							buffer);
 
-					// GLU.gluBuild2DMipmaps(m_textureId, 2, m_width, m_height,
-					// GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE, buffer);
+						// GLU.gluBuild2DMipmaps(m_textureId, 2, m_width,
+						// m_height,
+						// GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE,
+						// buffer);
 
-					// generate a display list for each available character
-					Map&lt;Object, Runnable&gt; requests =
-						new HashMap&lt;Object, Runnable&gt;(m_chars.length);
-					for (final LwjglFontChar c : m_chars) {
-						requests.put(c, new Runnable() {
-							public void run() {
-								c.render(m_width, m_height);
-							}
-						});
+						// generate a display list for each available character
+						Map&lt;Object, Runnable&gt; requests =
+							new HashMap&lt;Object, Runnable&gt;(m_chars.length);
+						for (final LwjglFontChar c : m_chars) {
+							requests.put(c, new Runnable() {
+								public void run() {
+									c.render(m_width, m_height);
+								}
+							});
+						}
+
+						m_displayListManager.createDisplayLists(requests);
+					} finally {
+						Draw3DCache.returnIntBuffer(intBuf);
 					}
-
-					m_displayListManager.createDisplayLists(requests);
 				} finally {
-					Draw3DCache.returnIntBuffer(intBuf);
+					GL11.glPopAttrib();
+					GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
 				}
 			} finally {
-				GL11.glPopAttrib();
-				GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
+				if (gc != null &amp;&amp; !gc.isDisposed())
+					gc.dispose();
+				if (image != null &amp;&amp; !image.isDisposed())
+					image.dispose();
 			}
-		} finally {
-			if (gc != null &amp;&amp; !gc.isDisposed())
-				gc.dispose();
-			if (image != null &amp;&amp; !image.isDisposed())
-				image.dispose();
-		}
 
-		FontData[] fontData = i_font.getFontData();
-		StringBuilder builder = new StringBuilder();
-		for (int i = 0; i &lt; fontData.length; i++) {
-			builder.append(fontData[i].getName());
+			FontData[] fontData = i_font.getFontData();
+			StringBuilder builder = new StringBuilder();
+			for (int i = 0; i &lt; fontData.length; i++) {
+				builder.append(fontData[i].getName());
 
-			int style = fontData[i].getStyle();
-			if ((style &amp; SWT.NORMAL) != 0)
-				builder.append(&quot; Normal&quot;);
-			if ((style &amp; SWT.ITALIC) != 0)
-				builder.append(&quot; Italic&quot;);
-			if ((style &amp; SWT.BOLD) != 0)
-				builder.append(&quot; Bold&quot;);
+				int style = fontData[i].getStyle();
+				if ((style &amp; SWT.NORMAL) != 0)
+					builder.append(&quot; Normal&quot;);
+				if ((style &amp; SWT.ITALIC) != 0)
+					builder.append(&quot; Italic&quot;);
+				if ((style &amp; SWT.BOLD) != 0)
+					builder.append(&quot; Bold&quot;);
 
-			builder.append(&quot; &quot;);
-			builder.append(fontData[i].getHeight());
+				builder.append(&quot; &quot;);
+				builder.append(fontData[i].getHeight());
 
-			if (i &lt; fontData.length - 1)
-				builder.append(&quot;, &quot;);
-		}
+				if (i &lt; fontData.length - 1)
+					builder.append(&quot;, &quot;);
+			}
 
-		builder.append(&quot;, Antialiasing: &quot;);
-		builder.append(i_antiAliased);
+			builder.append(&quot;, Antialiasing: &quot;);
+			builder.append(i_antiAliased);
 
-		m_description = builder.toString();
+			m_description = builder.toString();
+		} finally {
+			m_displayListManager.resumeDisplayList();
+		}
 	}
 
 	/**

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -22,6 +22,8 @@
  */
 public class LwjglFontChar {
 
+	private char m_char;
+
 	/**
 	 * The font height.
 	 */
@@ -55,16 +57,28 @@
 	/**
 	 * Creates a new character with the given width and height.
 	 * 
+	 * @param i_char the character
 	 * @param i_width the width of this character
 	 * @param i_height the height of the font this character belongs to
 	 */
-	public LwjglFontChar(int i_width, int i_height) {
+	public LwjglFontChar(char i_char, int i_width, int i_height) {
 
+		m_char = i_char;
 		m_width = i_width;
 		m_height = i_height;
 	}
 
 	/**
+	 * Returns the width of this character.
+	 * 
+	 * @return the width of this character
+	 */
+	public int getWidth() {
+
+		return m_width;
+	}
+
+	/**
 	 * Renders this character.
 	 * 
 	 * @param i_width the width of the character texture
@@ -84,20 +98,9 @@
 		GL11.glVertex2f(m_width, 0);
 
 		GL11.glEnd();
-		GL11.glEndList();
 	}
 
 	/**
-	 * Returns the width of this character.
-	 * 
-	 * @return the width of this character
-	 */
-	public int getWidth() {
-
-		return m_width;
-	}
-
-	/**
 	 * Sets the texture coordinates of this character.
 	 * 
 	 * @param i_s1 the S coordinate of the upper left corner
@@ -112,4 +115,15 @@
 		m_s2 = i_s2;
 		m_t2 = i_t2;
 	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see java.lang.Object#toString()
+	 */
+	@Override
+	public String toString() {
+
+		return Character.toString(m_char);
+	}
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -13,6 +13,7 @@
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import org.eclipse.draw3d.graphics3d.DisplayListManager;
@@ -58,6 +59,24 @@
 
 		private int m_hashCode;
 
+		private int getFontHashCode(Font i_font) {
+
+			int result = 17;
+
+			FontData[] fontData = i_font.getFontData();
+			for (int i = 0; i &lt; fontData.length; i++) {
+				result = 37 * result + fontData[i].getName().hashCode();
+				result = 37 * result + fontData[i].getLocale().hashCode();
+				result =
+					37 * result
+						+ new Integer(fontData[i].getHeight()).hashCode();
+				result =
+					37 * result + new Integer(fontData[i].style).hashCode();
+			}
+
+			return result;
+		}
+
 		/**
 		 * Creates a new key for a given font and character range.
 		 * 
@@ -70,16 +89,12 @@
 				boolean i_antiAliased) {
 
 			m_hashCode = 17;
-			m_hashCode = 37 * m_hashCode + i_font.hashCode();
+			m_hashCode = 37 * getFontHashCode(i_font);
 			m_hashCode =
 				37 * m_hashCode + new Character(i_startChar).hashCode();
 			m_hashCode = 37 * m_hashCode + new Character(i_endChar).hashCode();
 			m_hashCode =
 				37 * m_hashCode + new Boolean(i_antiAliased).hashCode();
-
-			FontData[] fontDatas = i_font.getFontData();
-			for (FontData fontData : fontDatas)
-				m_hashCode = m_hashCode + 37 * fontData.hashCode();
 		}
 
 		/**
@@ -161,12 +176,16 @@
 
 		GLFontKey key =
 			new GLFontKey(i_font, i_startChar, i_endChar, i_antiAliased);
+
 		LwjglFont glFont = m_fonts.get(key);
 		if (glFont == null) {
 			glFont =
 				new LwjglFont(i_font, i_startChar, i_endChar, i_antiAliased,
 					m_displayListManager);
 			m_fonts.put(key, glFont);
+
+			if (log.isLoggable(Level.FINE))
+				log.fine(&quot;loaded new GL raster font &quot; + glFont);
 		}
 
 		return glFont;

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -24,10 +24,12 @@
 import org.eclipse.draw2d.geometry.PointList;
 import org.eclipse.draw2d.geometry.PrecisionRectangle;
 import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.geometry.Math3D;
 import org.eclipse.draw3d.geometry.Matrix4f;
 import org.eclipse.draw3d.graphics.GraphicsState;
 import org.eclipse.draw3d.graphics.StatefulGraphics;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFont;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.draw3d.util.ColorConverter;
@@ -114,6 +116,8 @@
  *       arc, since it will work for small arcs, but it will draw too many
  *       segments for long arcs, resulting in a performance penalty
  * @todo implement the unsupported methods
+ * @todo tweak arc factors so that less segments are created
+ * @todo cache textures for images
  */
 @SuppressWarnings(&quot;unused&quot;)
 public class LwjglGraphics extends StatefulGraphics {
@@ -147,19 +151,21 @@
 				return 0;
 			case LINE:
 			case POINT:
-				return 0.49f;
+				return 0;
+				// return 0.49f;
 			}
 
 			throw new AssertionError(&quot;unknown raster offset enum: &quot; + this);
 		}
 	}
 
-	private static final double ARC_LENGTH_FACTOR = 4 * Math.PI * Math.PI;
+	private static final float ARC_LENGTH_FACTOR =
+		4 * (float) Math.PI * (float) Math.PI;
 
 	/**
 	 * Decrease this factor to get a larger number of segments and vice versa.
 	 */
-	private static final double ARC_SEGMENTS_FACTOR = 5 * Math.PI;
+	private static final float ARC_SEGMENTS_FACTOR = 5 * (float) Math.PI;
 
 	/**
 	 * This value is used as the base for clipping plane equations.
@@ -186,6 +192,8 @@
 
 	private LwjglFontManager m_fontManager;
 
+	private DisplayListManager m_displayListManager;
+
 	private int m_height;
 
 	private LastColor m_lastColor = LastColor.UNKNOWN;
@@ -204,13 +212,19 @@
 	 * 
 	 * @param i_width the width of this graphics object
 	 * @param i_height the height of this graphics object
+	 * @param i_displayListManager the display list manager
 	 * @param i_fontManager to the font manager to use
 	 */
 	public LwjglGraphics(int i_width, int i_height,
+			DisplayListManager i_displayListManager,
 			LwjglFontManager i_fontManager) {
 
 		super();
 
+		if (i_displayListManager == null)
+			throw new NullPointerException(
+				&quot;i_displayListManager must not be null&quot;);
+
 		if (i_fontManager == null)
 			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
 
@@ -436,7 +450,7 @@
 			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
-					double s =
+					float s =
 						m_currentLinePattern.getS(i_x1, i_y1, i_x2, i_y2);
 
 					GL11.glBegin(GL11.GL_LINES);
@@ -734,9 +748,7 @@
 
 		glSetRasterOffset(RasterOffset.POLYGON);
 
-		IntBuffer shadeModel = Draw3DCache.getIntBuffer(1);
-		GL11.glGetInteger(GL11.GL_SHADE_MODEL, shadeModel);
-		GL11.glShadeModel(GL11.GL_SMOOTH);
+		GL11.glPushAttrib(GL11.GL_LIGHTING_BIT);
 		try {
 			int x1 = i_x;
 			int y1 = i_y;
@@ -764,10 +776,7 @@
 			GL11.glEnd();
 		} finally {
 			glResetRasterOffset();
-			if (shadeModel != null) {
-				GL11.glShadeModel(shadeModel.get(0));
-				Draw3DCache.returnIntBuffer(shadeModel);
-			}
+			GL11.glPopAttrib();
 		}
 	}
 
@@ -899,29 +908,29 @@
 	private void glDrawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
 		int i_length) {
 
-		double start = Math.toRadians(i_offset);
-		double length = Math.toRadians(i_length);
+		float start = (float) Math.toRadians(i_offset);
+		float length = (float) Math.toRadians(i_length);
 
-		double xFactor = i_w / 2;
-		double yFactor = i_h / 2;
+		float xFactor = i_w / 2;
+		float yFactor = i_h / 2;
 
-		double avgRadius = (xFactor + yFactor) / 2;
-		double arcLength = ARC_LENGTH_FACTOR * avgRadius / length;
+		float avgRadius = (xFactor + yFactor) / 2;
+		float arcLength = ARC_LENGTH_FACTOR * avgRadius / length;
 
-		double inc = ARC_SEGMENTS_FACTOR / arcLength;
+		float inc = ARC_SEGMENTS_FACTOR / arcLength;
 
-		double xOffset = i_x + i_w / 2;
-		double yOffset = i_y + i_h / 2;
+		float xOffset = i_x + i_w / 2;
+		float yOffset = i_y + i_h / 2;
 
-		for (double a = start; a &lt; start + length; a += inc) {
-			double x = xOffset + Math.cos(a) * xFactor;
-			double y = yOffset - Math.sin(a) * yFactor;
-			GL11.glVertex2d(x, y);
+		for (float a = start; a &lt; start + length; a += ARC_INC) {
+			float x = xOffset + (float) Math.cos(a) * xFactor;
+			float y = yOffset - (float) Math.sin(a) * yFactor;
+			GL11.glVertex2f(x, y);
 		}
 
-		double x = xOffset + Math.cos(start + length) * xFactor;
-		double y = yOffset - Math.sin(start + length) * yFactor;
-		GL11.glVertex2d(x, y);
+		float x = xOffset + (float) Math.cos(start + length) * xFactor;
+		float y = yOffset - (float) Math.sin(start + length) * yFactor;
+		GL11.glVertex2f(x, y);
 	}
 
 	private void glDrawPointList(PointList i_points) {
@@ -957,33 +966,33 @@
 		int y2 = y1 + i_r.height;
 		int w = i_arcWidth;
 		int h = i_arcHeight;
-		int w2 = w / 2;
-		int h2 = h / 2;
+		float w2 = w / 2;
+		float h2 = h / 2;
 
 		// left
-		GL11.glVertex2i(x1, y1 + h2);
-		GL11.glVertex2i(x1, y2 - h2);
+		GL11.glVertex2f(x1, y1 + h2);
+		// GL11.glVertex2f(x1, y2 - h2);
 
 		// bottom left corner
 		glDrawArc(x1, y2 - h, w, h, 180, 90);
 
 		// bottom
-		GL11.glVertex2i(x1 + w2, y2);
-		GL11.glVertex2i(x2 - w2, y2);
+		GL11.glVertex2f(x1 + w2, y2);
+		// GL11.glVertex2f(x2 - w2, y2);
 
 		// bottom right corner
 		glDrawArc(x2 - w, y2 - h, w, h, 270, 90);
 
 		// right
-		GL11.glVertex2i(x2, y2 - h2);
-		GL11.glVertex2i(x2, y1 + h2);
+		GL11.glVertex2f(x2, y2 - h2);
+		// GL11.glVertex2f(x2, y1 + h2);
 
 		// top right corner
 		glDrawArc(x2 - w, y1, w, h, 0, 90);
 
 		// top
-		GL11.glVertex2i(x2 - w2, y1);
-		GL11.glVertex2i(x1 + w2, y1);
+		GL11.glVertex2f(x2 - w2, y1);
+		// GL11.glVertex2f(x1 + w2, y1);
 
 		// top left corner
 		glDrawArc(x1, y1, w, h, 90, 90);
@@ -995,33 +1004,33 @@
 		glDrawTexturedArc(i_x, i_y, i_w, i_h, i_offset, i_length, 0);
 	}
 
-	private double glDrawTexturedArc(int i_x, int i_y, int i_w, int i_h,
-		int i_offset, int i_length, double i_s) {
+	private float glDrawTexturedArc(int i_x, int i_y, int i_w, int i_h,
+		int i_offset, int i_length, float i_s) {
 
-		double start = Math.toRadians(i_offset);
-		double length = Math.toRadians(i_length);
+		float start = (float) Math.toRadians(i_offset);
+		float length = (float) Math.toRadians(i_length);
 
-		double xFactor = i_w / 2;
-		double yFactor = i_h / 2;
+		float xFactor = i_w / 2;
+		float yFactor = i_h / 2;
 
-		double avgRadius = (xFactor + yFactor) / 2;
-		double arcLength = ARC_LENGTH_FACTOR * avgRadius / length;
+		float avgRadius = (xFactor + yFactor) / 2;
+		float arcLength = ARC_LENGTH_FACTOR * avgRadius / length;
 
-		double inc = ARC_SEGMENTS_FACTOR / arcLength;
+		float inc = ARC_SEGMENTS_FACTOR / arcLength;
 
-		double xOffset = i_x + i_w / 2;
-		double yOffset = i_y + i_h / 2;
+		float xOffset = i_x + i_w / 2;
+		float yOffset = i_y + i_h / 2;
 
-		double lastX = xOffset + Math.cos(start) * xFactor;
-		double lastY = yOffset - Math.sin(start) * yFactor;
+		float lastX = xOffset + (float) Math.cos(start) * xFactor;
+		float lastY = yOffset - (float) Math.sin(start) * yFactor;
 
-		double s = i_s;
+		float s = i_s;
 		GL11.glTexCoord1d(s);
 		GL11.glVertex2d(lastX, lastY);
 
-		for (double a = start + inc; a &lt; start + length; a += inc) {
-			double x = xOffset + Math.cos(a) * xFactor;
-			double y = yOffset - Math.sin(a) * yFactor;
+		for (float a = start + inc; a &lt; start + length; a += inc) {
+			float x = xOffset + (float) Math.cos(a) * xFactor;
+			float y = yOffset - (float) Math.sin(a) * yFactor;
 			s += m_currentLinePattern.getS(lastX, lastY, x, y);
 
 			GL11.glTexCoord1d(s);
@@ -1031,8 +1040,8 @@
 			lastY = y;
 		}
 
-		double x = xOffset + Math.cos(start + length) * xFactor;
-		double y = yOffset - Math.sin(start + length) * yFactor;
+		float x = xOffset + (float) Math.cos(start + length) * xFactor;
+		float y = yOffset - (float) Math.sin(start + length) * yFactor;
 		s += m_currentLinePattern.getS(lastX, lastY, x, y);
 
 		GL11.glTexCoord1d(s);
@@ -1049,7 +1058,7 @@
 			int lastX = vertices[0];
 			int lastY = vertices[1];
 
-			double s = 0;
+			float s = 0;
 
 			GL11.glTexCoord1d(s);
 			GL11.glVertex2i(lastX, lastY);
@@ -1076,7 +1085,7 @@
 		int x2 = i_x + i_width;
 		int y2 = i_y;
 
-		double s = 0;
+		float s = 0;
 		GL11.glTexCoord1d(s);
 		GL11.glVertex2i(x1, y1);
 
@@ -1102,11 +1111,11 @@
 		int y2 = y1 + i_r.height;
 		int w = i_arcWidth;
 		int h = i_arcHeight;
-		double w2 = (double) w / 2;
-		double h2 = (double) h / 2;
+		float w2 = w / 2;
+		float h2 = h / 2;
 
 		// left
-		double s = 0;
+		float s = 0;
 		GL11.glTexCoord1d(s);
 		GL11.glVertex2i(x1, y1 + h / 2);
 		s += m_currentLinePattern.getS(x1, y1 + h2, x1, y2 - h2);
@@ -1174,7 +1183,8 @@
 	private void glRestoreState(GraphicsState i_previous) {
 
 		Matrix4f transformation = i_previous.getTransformation();
-		if (transformation != null) {
+		if (transformation != null
+			&amp;&amp; !IMatrix4f.IDENTITY.equals(transformation)) {
 			FloatBuffer buffer = Draw3DCache.getFloatBuffer(16);
 			Matrix4f inverse = Draw3DCache.getMatrix4f();
 			try {
@@ -1380,7 +1390,8 @@
 			Object key = LwjglLinePattern.getKey(dashPattern);
 			m_currentLinePattern = m_linePatterns.get(key);
 			if (m_currentLinePattern == null) {
-				m_currentLinePattern = new LwjglLinePattern(dashPattern);
+				m_currentLinePattern =
+					new LwjglLinePattern(dashPattern, m_displayListManager);
 				m_linePatterns.put(key, m_currentLinePattern);
 			}
 			break;
@@ -1524,17 +1535,18 @@
 		if (!Arrays.equals(previous, getState().getLineDash()))
 			glSetLineStyle();
 	}
-	
-	/** 
+
+	/**
 	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
 	 */
 	@Override
 	public void setLineDash(float[] i_dash) {
-		
+
 		int[] previous = getState().getLineDash();
 		super.setLineDash(i_dash);
-		
+
 		if (!Arrays.equals(previous, getState().getLineDash()))
 			glSetLineStyle();
 	}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglLinePattern.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglLinePattern.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglLinePattern.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -14,6 +14,7 @@
 import java.nio.IntBuffer;
 
 import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.util.Draw3DCache;
 import org.eclipse.draw3d.util.converter.BufferInfo;
 import org.eclipse.draw3d.util.converter.ImageConverter;
@@ -59,73 +60,85 @@
 	 * Creates a new line pattern for the given dashing pattern.
 	 * 
 	 * @param i_dashPattern the dashing pattern
+	 * @param i_displayListManager the display list manager
 	 * @throws NullPointerException if the given pattern is &lt;code&gt;null&lt;/code&gt;
 	 */
-	public LwjglLinePattern(int[] i_dashPattern) {
+	public LwjglLinePattern(int[] i_dashPattern,
+			DisplayListManager i_displayListManager) {
 
 		if (i_dashPattern == null)
 			throw new NullPointerException(&quot;dashPattern must not be null&quot;);
 
-		// calculate the total length of the pattern
-		m_length = 0;
-		for (int i = 0; i &lt; i_dashPattern.length; i++)
-			m_length += i_dashPattern[i];
+		if (i_displayListManager == null)
+			throw new NullPointerException(
+				&quot;i_displayListManager must not be null&quot;);
 
-		Device device = Display.getCurrent();
-		Image image = null;
-		GC gc = null;
+		i_displayListManager.interruptDisplayList();
 		try {
-			image = new Image(device, m_length, 1);
-			gc = new GC(image);
+			// calculate the total length of the pattern
+			m_length = 0;
+			for (int i = 0; i &lt; i_dashPattern.length; i++)
+				m_length += i_dashPattern[i];
 
-			// paint the pattern to an image
-			gc.setForeground(device.getSystemColor(SWT.COLOR_BLACK));
-			gc.setBackground(device.getSystemColor(SWT.COLOR_WHITE));
-			gc.fillRectangle(0, 0, m_length, 1);
-			gc.setLineDash(i_dashPattern);
-			gc.drawLine(0, 0, m_length, 0);
+			Device device = Display.getCurrent();
+			Image image = null;
+			GC gc = null;
+			try {
+				image = new Image(device, m_length, 1);
+				gc = new GC(image);
 
-			// create a luminance alpha buffer from the image
-			BufferInfo info =
-				new BufferInfo(m_length, 1, GL11.GL_LUMINANCE_ALPHA,
-					GL11.GL_UNSIGNED_BYTE, 1);
+				// paint the pattern to an image
+				gc.setForeground(device.getSystemColor(SWT.COLOR_BLACK));
+				gc.setBackground(device.getSystemColor(SWT.COLOR_WHITE));
+				gc.fillRectangle(0, 0, m_length, 1);
+				gc.setLineDash(i_dashPattern);
+				gc.drawLine(0, 0, m_length, 0);
 
-			ImageConverter converter = ImageConverter.getInstance();
-			ByteBuffer buffer =
-				converter.imageToBuffer(image, info, null, false);
+				// create a luminance alpha buffer from the image
+				BufferInfo info =
+					new BufferInfo(m_length, 1, GL11.GL_LUMINANCE_ALPHA,
+						GL11.GL_UNSIGNED_BYTE, 1);
 
-			// create the texture
-			GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
-			try {
-				IntBuffer intBuf = Draw3DCache.getIntBuffer(1);
+				ImageConverter converter = ImageConverter.getInstance();
+				ByteBuffer buffer =
+					converter.imageToBuffer(image, info, null, false);
+
+				// create the texture
+				GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
 				try {
-					GL11.glDisable(GL11.GL_TEXTURE_2D);
-					GL11.glEnable(GL11.GL_TEXTURE_1D);
-					GL11.glGenTextures(intBuf);
-					m_textureId = intBuf.get(0);
+					IntBuffer intBuf = Draw3DCache.getIntBuffer(1);
+					try {
+						GL11.glDisable(GL11.GL_TEXTURE_2D);
+						GL11.glEnable(GL11.GL_TEXTURE_1D);
+						GL11.glGenTextures(intBuf);
+						m_textureId = intBuf.get(0);
 
-					GL11.glBindTexture(GL11.GL_TEXTURE_1D, m_textureId);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
-						GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
-						GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
-					GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
-						GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
-					GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0,
-						GL11.GL_LUMINANCE_ALPHA, m_length, 0,
-						GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE, buffer);
+						GL11.glBindTexture(GL11.GL_TEXTURE_1D, m_textureId);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
+							GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
+							GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+						GL11.glTexParameteri(GL11.GL_TEXTURE_1D,
+							GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+						GL11.glTexImage1D(GL11.GL_TEXTURE_1D, 0,
+							GL11.GL_LUMINANCE_ALPHA, m_length, 0,
+							GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE,
+							buffer);
+					} finally {
+						Draw3DCache.returnIntBuffer(intBuf);
+					}
 				} finally {
-					Draw3DCache.returnIntBuffer(intBuf);
+					GL11.glPopAttrib();
+					GL11.glBindTexture(GL11.GL_TEXTURE_1D, 0);
 				}
 			} finally {
-				GL11.glPopAttrib();
-				GL11.glBindTexture(GL11.GL_TEXTURE_1D, 0);
+				if (gc != null)
+					gc.dispose();
+				if (image != null)
+					image.dispose();
 			}
 		} finally {
-			if (gc != null)
-				gc.dispose();
-			if (image != null)
-				image.dispose();
+			i_displayListManager.resumeDisplayList();
 		}
 	}
 
@@ -209,14 +222,14 @@
 	 * @return the S texture coordinate for the line's end point
 	 * @throws IllegalStateException if this line pattern is disposed
 	 */
-	public double getS(double i_x1, double i_y1, double i_x2, double i_y2) {
+	public float getS(float i_x1, float i_y1, float i_x2, float i_y2) {
 
 		if (m_disposed)
 			throw new IllegalStateException(&quot;line pattern is disposed&quot;);
 
-		double dX = i_x2 - i_x1;
-		double dY = i_y2 - i_y1;
-		double lineLength = Math.sqrt(dX * dX + dY * dY);
+		float dX = i_x2 - i_x1;
+		float dY = i_y2 - i_y1;
+		float lineLength = (float) Math.sqrt(dX * dX + dY * dY);
 
 		return lineLength / m_length;
 	}
@@ -232,14 +245,14 @@
 	 * @return the S texture coordinate for the line's end point
 	 * @throws IllegalStateException if this line pattern is disposed
 	 */
-	public double getS(int i_x1, int i_y1, int i_x2, int i_y2) {
+	public float getS(int i_x1, int i_y1, int i_x2, int i_y2) {
 
 		if (m_disposed)
 			throw new IllegalStateException(&quot;line pattern is disposed&quot;);
 
 		int dX = i_x2 - i_x1;
 		int dY = i_y2 - i_y1;
-		double lineLength = Math.sqrt(dX * dX + dY * dY);
+		float lineLength = (float) Math.sqrt(dX * dX + dY * dY);
 
 		return lineLength / m_length;
 	}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -15,6 +15,7 @@
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics;
 import org.eclipse.draw3d.util.BufferUtils;
@@ -219,18 +220,30 @@
 
 	private int m_width = -1;
 
+	private DisplayListManager m_displayListmanager;
+
 	/**
 	 * Creates a new texture with the given initial dimensions.
 	 * 
 	 * @param i_width the width of the texture
 	 * @param i_height the height of the texture
+	 * @param i_displayListmanager the display list manager
 	 * @param i_fontManager the font manager to use
 	 * @throws IllegalArgumentException if the given width or height is not
 	 *             positive
 	 */
 	public LwjglTextureFbo(int i_width, int i_height,
+			DisplayListManager i_displayListmanager,
 			LwjglFontManager i_fontManager) {
 
+		if (i_displayListmanager == null)
+			throw new NullPointerException(
+				&quot;i_displayListmanager must not be null&quot;);
+
+		if (i_fontManager == null)
+			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
+
+		m_displayListmanager = i_displayListmanager;
 		m_fontManager = i_fontManager;
 		setDimensions(i_width, i_height);
 		m_glFrameBuffer = createFbo();
@@ -250,7 +263,9 @@
 		EXTFramebufferObject.glBindFramebufferEXT(
 			EXTFramebufferObject.GL_FRAMEBUFFER_EXT, m_glFrameBuffer);
 		if (!m_valid) {
-			m_graphics = new LwjglGraphics(m_width, m_height, m_fontManager);
+			m_graphics =
+				new LwjglGraphics(m_width, m_height, m_displayListmanager,
+					m_fontManager);
 
 			deleteTexture(m_glTexture);
 			m_glTexture = createTexture(m_width, m_height);

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -15,6 +15,7 @@
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.opengl.GLCanvas;
@@ -54,6 +55,8 @@
 	 */
 	private LwjglFontManager m_fontManager;
 
+	private DisplayListManager m_displayListManager;
+
 	/**
 	 * Creates a new texture manager. The main GL context is needed for pbuffer
 	 * textures.
@@ -62,16 +65,22 @@
 	 * @param i_fontManager the font manager
 	 */
 	public LwjglTextureManager(GLCanvas i_context,
+			DisplayListManager i_displayListManager,
 			LwjglFontManager i_fontManager) {
 
 		if (i_context == null)
 			throw new NullPointerException(&quot;i_context must not be null&quot;);
 
+		if (i_displayListManager == null)
+			throw new NullPointerException(
+				&quot;i_displayListManager must not be null&quot;);
+
 		if (i_fontManager == null)
 			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
 
 		m_context = i_context;
 		m_textures = new HashMap&lt;Object, LwjglTexture&gt;();
+		m_displayListManager = i_displayListManager;
 		m_fontManager = i_fontManager;
 	}
 
@@ -191,12 +200,14 @@
 
 		switch (getTextureSupport()) {
 		case FBO:
-			texture = new LwjglTextureFbo(i_width, i_height, m_fontManager);
+			texture =
+				new LwjglTextureFbo(i_width, i_height, m_displayListManager,
+					m_fontManager);
 			break;
 		case PBUFFER:
 			texture =
 				new LwjglTexturePbuffer(m_context, i_width, i_height,
-					m_fontManager);
+					m_displayListManager, m_fontManager);
 			break;
 		case SWT:
 			texture = new LwjglTextureSwt(i_width, i_height);

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -13,6 +13,7 @@
 import java.nio.IntBuffer;
 
 import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics;
 import org.eclipse.draw3d.util.ColorConverter;
@@ -131,6 +132,8 @@
 
 	private final GLCanvas m_context;
 
+	private DisplayListManager m_displayListManager;
+
 	private LwjglFontManager m_fontManager;
 
 	private int m_glTexture;
@@ -151,12 +154,14 @@
 	 *            deactivated
 	 * @param i_width the width of the texture
 	 * @param i_height the height of the texture
+	 * @param i_displayListManager the display list manager
 	 * @param i_fontManager the font manager
 	 * @throws IllegalArgumentException if the given width or height is not
 	 *             positive
 	 * @throws NullPointerException if the given context is &lt;code&gt;null&lt;/code&gt;
 	 */
 	public LwjglTexturePbuffer(GLCanvas i_context, int i_width, int i_height,
+			DisplayListManager i_displayListManager,
 			LwjglFontManager i_fontManager) {
 
 		if (i_context == null) {
@@ -165,6 +170,7 @@
 
 		m_context = i_context;
 		setDimensions(i_width, i_height);
+		m_displayListManager = i_displayListManager;
 		m_fontManager = i_fontManager;
 	}
 
@@ -182,7 +188,8 @@
 		try {
 			if (!m_valid || (m_pBuffer != null &amp;&amp; m_pBuffer.isBufferLost())) {
 				m_graphics =
-					new LwjglGraphics(m_width, m_height, m_fontManager);
+					new LwjglGraphics(m_width, m_height, m_displayListManager,
+						m_fontManager);
 
 				deleteTexture(m_glTexture);
 				deletePBuffer(m_pBuffer);

Modified: branches/experimental_direct_2D_rendering/org.eclipse.gef3d.examples.graph/src/java/org/eclipse/gef3d/examples/graph/editor/editparts/IntermodelEdgePart.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.gef3d.examples.graph/src/java/org/eclipse/gef3d/examples/graph/editor/editparts/IntermodelEdgePart.java	2009-11-11 10:03:33 UTC (rev 390)
+++ branches/experimental_direct_2D_rendering/org.eclipse.gef3d.examples.graph/src/java/org/eclipse/gef3d/examples/graph/editor/editparts/IntermodelEdgePart.java	2009-11-12 19:23:15 UTC (rev 391)
@@ -14,8 +14,6 @@
 import java.beans.PropertyChangeListener;
 
 import org.eclipse.draw2d.IFigure;
-import org.eclipse.draw3d.ArrowDecoration3D;
-import org.eclipse.gef.editparts.AbstractConnectionEditPart;
 import org.eclipse.gef3d.editparts.AbstractConnectionEditPart3D;
 import org.eclipse.gef3d.examples.graph.editor.figures.EdgeFigure3D;
 import org.eclipse.gef3d.examples.graph.model.Edge;
@@ -69,8 +67,8 @@
 		Color color = Display.getCurrent().getSystemColor(SWT.COLOR_BLUE);
 		edge.setForegroundColor(color);
 
-		edge.setTargetDecoration(new ArrowDecoration3D());
-		edge.setSourceDecoration(new ArrowDecoration3D());
+		// edge.setTargetDecoration(new ArrowDecoration3D());
+		// edge.setSourceDecoration(new ArrowDecoration3D());
 
 		return edge;
 	}


</pre>]]></content:encoded>
		<pubDate>Thu, 12 Nov 2009 19:23:16 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00236.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r390 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00235.html</link>
		<description>Author: kduske Date: 2009-11-11 05:03:33 -0500 (Wed, 11 Nov 2009) New Revision: 390 Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java Log: - minor fix in setProperty(..) Modified: trunk/org.eclipse.d...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-11 05:03:33 -0500 (Wed, 11 Nov 2009)
New Revision: 390

Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
Log:
- minor fix in setProperty(..)

Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-10 09:43:46 UTC (rev 389)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-11 10:03:33 UTC (rev 390)
@@ -747,8 +747,11 @@
 	 *      java.lang.Object)
 	 */
 	public void setProperty(String key, String value) {
-		properties.setProperty(key, value);
 
+		if (value != null)
+			properties.setProperty(key, value);
+		else
+			properties.remove(key);
 	}
 
 	/**


</pre>]]></content:encoded>
		<pubDate>Wed, 11 Nov 2009 10:03:36 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00235.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r389 -	trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00234.html</link>
		<description>Author: jvonpilgrim Date: 2009-11-10 04:43:46 -0500 (Tue, 10 Nov 2009) New Revision: 389 Modified: trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/ConnectedElementAdapter.java trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext...</description>
		<content:encoded><![CDATA[<pre>Author: jvonpilgrim
Date: 2009-11-10 04:43:46 -0500 (Tue, 10 Nov 2009)
New Revision: 389

Modified:
   trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/ConnectedElementAdapter.java
   trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelDiagram.java
   trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelRootEditPart.java
Log:
updated javadoc

Modified: trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/ConnectedElementAdapter.java
===================================================================
--- trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/ConnectedElementAdapter.java	2009-11-06 18:05:42 UTC (rev 388)
+++ trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/ConnectedElementAdapter.java	2009-11-10 09:43:46 UTC (rev 389)
@@ -21,7 +21,9 @@
 import org.eclipse.gef.GraphicalEditPart;
 
 /**
- * ConnectedElementAdapter There should really be more documentation here.
+ * Serves as the model for the {@link ConnectedElementEditPart}, working as 
+ * a proxy nesting the actually connected element (i.e. its EditPart).
+ *  
  * 
  * @author Jens von Pilgrim
  * @version $Revision$

Modified: trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelDiagram.java
===================================================================
--- trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelDiagram.java	2009-11-06 18:05:42 UTC (rev 388)
+++ trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelDiagram.java	2009-11-10 09:43:46 UTC (rev 389)
@@ -12,7 +12,9 @@
 package org.eclipse.gef3d.ext.intermodel;
 
 /**
- * IInterModelDiagram There should really be more documentation here.
+ * Empty interface to mark a diagram figure as an inter model diagram. An inter 
+ * model diagram does not have a surface, instead it is only a layer and its
+ * children are inter-model connections, such as traces.  
  * 
  * @author Jens von Pilgrim
  * @version $Revision$

Modified: trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelRootEditPart.java
===================================================================
--- trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelRootEditPart.java	2009-11-06 18:05:42 UTC (rev 388)
+++ trunk/org.eclipse.gef3d.ext/src/java/org/eclipse/gef3d/ext/intermodel/IInterModelRootEditPart.java	2009-11-10 09:43:46 UTC (rev 389)
@@ -12,7 +12,9 @@
 package org.eclipse.gef3d.ext.intermodel;
 
 /**
- * IInterModelRootEditPart There should really be more documentation here.
+ * Empty interface to mark an edit part as an inter model edit part. An
+ * inter model is only a container for inter-model connections, such as
+ * traces. That is, it is not visible itself.
  * 
  * @author Jens von Pilgrim
  * @version $Revision$


</pre>]]></content:encoded>
		<pubDate>Tue, 10 Nov 2009 09:43:47 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00234.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r388 - in branches/experimental_direct_2D_rendering:	org.eclipse.draw3d/META-INF	org.eclipse.draw3d/src/java/org/eclipse/draw3d	org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics	org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes	org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics	org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00233.html</link>
		<description>Author: kduske Date: 2009-11-06 13:05:42 -0500 (Fri, 06 Nov 2009) New Revision: 388 Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java branches/experimental_direct_2...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-06 13:05:42 -0500 (Fri, 06 Nov 2009)
New Revision: 388

Added:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsState.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/StatefulGraphics.java
Removed:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/DisplayListManager.java
Modified:
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/META-INF/MANIFEST.MF
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Export3DOperation.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/FigureSurface.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java
   branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java
Log:


Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/META-INF/MANIFEST.MF
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/META-INF/MANIFEST.MF	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/META-INF/MANIFEST.MF	2009-11-06 18:05:42 UTC (rev 388)
@@ -24,6 +24,7 @@
    org.eclipse.swt.widgets&quot;,
  org.eclipse.draw3d.camera;uses:=&quot;org.eclipse.draw3d.geometry&quot;,
  org.eclipse.draw3d.geometryext;uses:=&quot;org.eclipse.draw3d.geometry,org.eclipse.draw2d.geometry&quot;,
+ org.eclipse.draw3d.graphics,
  org.eclipse.draw3d.picking;
   uses:=&quot;org.eclipse.draw3d.camera,
    org.eclipse.draw3d.geometry,

Deleted: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/DisplayListManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/DisplayListManager.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/DisplayListManager.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Jens von Pilgrim and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
- *
- * Contributors:
- *    Kristian Duske - initial API and implementation
- ******************************************************************************/
-package org.eclipse.draw3d;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Queue;
-import java.util.logging.Logger;
-
-import org.eclipse.draw3d.graphics3d.Graphics3D;
-import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
-
-/**
- * Manages display lists during a render operation in the current GL context.
- * 
- * @author Kristian Duske
- * @version $Revision$
- * @since 24.05.2008
- */
-public class DisplayListManager {
-
-	@SuppressWarnings(&quot;unused&quot;)
-	private static final Logger log =
-		Logger.getLogger(DisplayListManager.class.getName());
-
-	private static final int RANGE = 10;
-
-	private List&lt;Integer&gt; m_baseIds = new ArrayList&lt;Integer&gt;();
-
-	private Map&lt;Object, Integer&gt; m_displayLists =
-		new HashMap&lt;Object, Integer&gt;();
-
-	private final boolean m_disposed = false;
-
-	private Queue&lt;Integer&gt; m_freeIds = new LinkedList&lt;Integer&gt;();
-
-	private Graphics3D m_graphics3D;
-
-	private int m_index = RANGE;
-
-	/**
-	 * Creates a new display list manager for the given graphics3D object.
-	 * 
-	 * @param i_graphics3D the graphics3D object that contains this manager
-	 */
-	public DisplayListManager(Graphics3D i_graphics3D) {
-
-		if (i_graphics3D == null)
-			throw new NullPointerException(&quot;i_graphics3D must not be null&quot;);
-
-		m_graphics3D = i_graphics3D;
-	}
-
-	/**
-	 * Clears all displays lists in this manager.
-	 * 
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	public void clear() {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		for (int baseId : m_baseIds)
-			m_graphics3D.glDeleteLists(baseId, RANGE);
-
-		m_index = RANGE;
-		m_baseIds.clear();
-		m_displayLists.clear();
-		m_freeIds.clear();
-	}
-
-	/**
-	 * Creates a new display lists with the given key. The display lists will
-	 * contain the GL commands that are executed by the given runnable. If there
-	 * already is a display list with the given key, it will be overwritten.
-	 * 
-	 * @param i_key the key of the new display list
-	 * @param i_runnable the code that generates the GL commands for the display
-	 *            list
-	 * @throws NullPointerException if either of the given arguments is
-	 *             &lt;code&gt;null&lt;/code&gt;
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	public void createDisplayList(Object i_key, Runnable i_runnable) {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		if (i_key == null)
-			throw new NullPointerException(&quot;i_key must not be null&quot;);
-
-		if (i_runnable == null)
-			throw new NullPointerException(&quot;i_runnable must not be null&quot;);
-
-		Integer id = m_displayLists.get(i_key);
-		if (id == null)
-			id = getNewId();
-
-		m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
-		i_runnable.run();
-		m_graphics3D.glEndList();
-
-		m_displayLists.put(i_key, id);
-	}
-
-	/**
-	 * Deletes the display lists with the given keys. If any of the given keys
-	 * is not the key of a display list that was created with this manager, it
-	 * is ignored.
-	 * 
-	 * @param i_keys the keys of the display lists to delete
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	public void deleteDisplayLists(Object... i_keys) {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		for (Object key : i_keys) {
-			int id = m_displayLists.get(key);
-			m_graphics3D.glDeleteLists(id, 1);
-			m_displayLists.remove(key);
-			m_freeIds.offer(id);
-		}
-	}
-
-	/**
-	 * Disposes all ressources associated with this display list manager.
-	 */
-	public void dispose() {
-
-		if (m_disposed)
-			return;
-
-		clear();
-		m_baseIds = null;
-		m_displayLists = null;
-	}
-
-	/**
-	 * Executes the display list with the given key.
-	 * 
-	 * @param i_key the key of the display list to execute
-	 * @throws NullPointerException if the given name is &lt;code&gt;null&lt;/code&gt;
-	 * @throws IllegalArgumentException if there is no display list with the
-	 *             given name
-	 * @throws IllegalStateException if the display list with the given name was
-	 *             created before, but has since been discarded
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	public void executeDisplayList(Object i_key) {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		if (i_key == null)
-			throw new NullPointerException(&quot;i_key must not be null&quot;);
-
-		Integer id = m_displayLists.get(i_key);
-		if (id == null)
-			throw new IllegalArgumentException(&quot;unknown display list: &quot; + i_key);
-
-		m_graphics3D.glCallList(id);
-	}
-
-	/**
-	 * Returns an unused display list ID.
-	 * 
-	 * @return an unused display list ID
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	private int getNewId() {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		if (!m_freeIds.isEmpty())
-			return m_freeIds.poll();
-
-		if (m_index == RANGE) {
-			int baseId = m_graphics3D.glGenLists(RANGE);
-			m_baseIds.add(baseId);
-			m_index = 0;
-		}
-
-		int baseId = m_baseIds.get(m_baseIds.size() - 1);
-		return baseId + m_index++;
-	}
-
-	/**
-	 * Indicates whether a number of display lists have been registered with
-	 * this manager.
-	 * 
-	 * @param i_keys the keys of the display lists to check for
-	 * @return &lt;code&gt;true&lt;/code&gt; if all display lists with the given keys are
-	 *         ready to use or &lt;code&gt;false&lt;/code&gt; otherwise
-	 * @throws IllegalStateException if this display list manager is disposed
-	 */
-	public boolean isDisplayList(Object... i_keys) {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
-
-		if (i_keys != null &amp;&amp; i_keys.length &gt; 0)
-			for (Object key : i_keys)
-				if (!m_displayLists.containsKey(key))
-					return false;
-
-		return true;
-	}
-
-}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Export3DOperation.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Export3DOperation.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Export3DOperation.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -75,7 +75,6 @@
 			rootFigure.paint(dummy);
 		} finally {
 			renderContext.setGraphics3D(g3dSave);
-			renderContext.clearDisplayListManager(); // was in try block only?!
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -33,6 +33,7 @@
 import org.eclipse.draw3d.geometry.IVector3f;
 import org.eclipse.draw3d.geometry.ParaxialBoundingBox;
 import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.picking.Picker;
 import org.eclipse.draw3d.shapes.ParaxialBoundsFigureShape;
@@ -464,69 +465,66 @@
 	 */
 	private void paintChildren2D(Graphics i_graphics) {
 
-		Collection&lt;IFigure&gt; children2D = getChildren2D();
+		final Collection&lt;IFigure&gt; children2D = getChildren2D();
 		if (!children2D.isEmpty()) {
+			final IFigure3D figure = m_figuresFriend.figure;
+			ISurface surface = figure.getSurface();
 
-			IFigure3D figure = m_figuresFriend.figure;
-
 			RenderContext renderContext = figure.getRenderContext();
+			Graphics3D g3d = renderContext.getGraphics3D();
 
-			Rectangle bounds = figure.getBounds();
-			int width = bounds.width;
-			int height = bounds.height;
+			DisplayListManager displayListManager = g3d.getDisplayListManager();
 
-			boolean repaint2D =
-				(renderContext.isRedraw2DContent() || m_figuresFriend.is2DContentDirty())
-					&amp;&amp; width &gt; 0
-					&amp;&amp; width &lt; Integer.MAX_VALUE
-					&amp;&amp; height &gt; 0
-					&amp;&amp; height &lt; Integer.MAX_VALUE;
+			if (surface != null &amp;&amp; surface.is2DHost()) {
+				if ((renderContext.isRedraw2DContent() || m_figuresFriend.is2DContentDirty())) {
+					final Graphics graphics = surface.activate(g3d);
+					try {
+						graphics.setFont(i_graphics.getFont());
+						configureGraphics(graphics);
 
-			Graphics graphics = i_graphics;
-			if (repaint2D) {
+						displayListManager.createDisplayList(figure,
+							new Runnable() {
+								public void run() {
+									doPaintChildren2D(children2D, figure,
+										graphics);
+								}
+							});
+					} finally {
+						surface.deactivate(g3d);
+					}
 
-				Graphics3D g3d = renderContext.getGraphics3D();
+					displayListManager.executeDisplayList(figure);
+				}
+			} else {
+				doPaintChildren2D(children2D, figure, i_graphics);
+			}
+		}
+	}
 
-				Graphics textureGraphics =
-					g3d.activateGraphics2D(figure, width, height,
-						figure.getAlpha(), figure.getBackgroundColor());
-
-				Font font = i_graphics.getFont();
-				textureGraphics.setFont(font);
-
-				graphics = textureGraphics;
+	/**
+	 * @param children2D
+	 * @param host
+	 * @param graphics
+	 */
+	private void doPaintChildren2D(Collection&lt;IFigure&gt; children2D,
+		IFigure3D host, Graphics graphics) {
+		graphics.pushState();
+		try {
+			for (IFigure child2D : children2D) {
+				graphics.clipRect(child2D.getBounds());
+				child2D.paint(graphics);
+				graphics.restoreState();
 			}
 
-			configureGraphics(graphics);
-			try {
-				graphics.pushState();
+			ConnectionLayer connectionLayer = host.getConnectionLayer(null);
 
-				try {
-					for (IFigure child2D : children2D) {
-						graphics.clipRect(child2D.getBounds());
-						child2D.paint(graphics);
-						// if (repaint2D)
-						// textureManager.activateTexture(figure);
-						graphics.restoreState();
-					}
-
-					ConnectionLayer connectionLayer =
-						figure.getConnectionLayer(null);
-
-					// paint the connections
-					if (connectionLayer != null) {
-						connectionLayer.paint(graphics);
-						graphics.restoreState();
-					}
-				} finally {
-					graphics.popState();
-				}
-			} finally {
-				if (repaint2D) {
-					Graphics3D g3d = renderContext.getGraphics3D();
-					g3d.deactivateGraphics2D();
-				}
+			// paint the connections
+			if (connectionLayer != null) {
+				connectionLayer.paint(graphics);
+				graphics.restoreState();
 			}
+		} finally {
+			graphics.popState();
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/FigureSurface.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/FigureSurface.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/FigureSurface.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -14,8 +14,10 @@
 
 import org.eclipse.draw2d.ConnectionLayer;
 import org.eclipse.draw2d.FigureListener;
+import org.eclipse.draw2d.Graphics;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.TreeSearch;
+import org.eclipse.draw2d.geometry.Rectangle;
 import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.geometry.IVector3f;
 import org.eclipse.draw3d.geometry.Math3D;
@@ -24,6 +26,7 @@
 import org.eclipse.draw3d.geometry.Position3D;
 import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.geometry.Vector3fImpl;
+import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.util.Draw3DCache;
 
 /**
@@ -243,4 +246,51 @@
 
 		return b.toString();
 	}
+
+	private boolean m_active = false;
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.ISurface#activate(Graphics3D)
+	 */
+	public Graphics activate(Graphics3D i_g3d) {
+
+		if (m_active)
+			throw new IllegalStateException(this
+				+ &quot; is already activated for 2D rendering&quot;);
+
+		Rectangle bounds = m_host.getBounds();
+		int width = bounds.width;
+		int height = bounds.height;
+
+		m_active = true;
+		return i_g3d.activateGraphics2D(m_host, m_host.getPosition3D(), width,
+			height);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.ISurface#deactivate()
+	 */
+	public void deactivate(Graphics3D i_g3d) {
+
+		if (!m_active)
+			throw new IllegalStateException(this
+				+ &quot; is not activated for 2D rendering&quot;);
+
+		i_g3d.deactivateGraphics2D();
+		m_active = false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.ISurface#is2DHost()
+	 */
+	public boolean is2DHost() {
+
+		return true;
+	}
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/ISurface.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -10,12 +10,14 @@
  ******************************************************************************/
 package org.eclipse.draw3d;
 
+import org.eclipse.draw2d.Graphics;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.TreeSearch;
 import org.eclipse.draw2d.geometry.Dimension;
 import org.eclipse.draw2d.geometry.Point;
 import org.eclipse.draw3d.geometry.IVector3f;
 import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.graphics3d.Graphics3D;
 
 /**
  * A surface is a 2D plane that belongs to a figure and has 2D children of that
@@ -30,6 +32,31 @@
 public interface ISurface {
 
 	/**
+	 * Activates this surface for 2D rendering. The returned graphics instance
+	 * can be used to render 2D content on this surface.
+	 * 
+	 * @param i_g3d the graphics 3D instance
+	 * @return the graphics instance to be used for rendering 2D content on this
+	 *         surface
+	 * @throws IllegalStateException if this surface is currently active for 2D
+	 *             rendering
+	 * @throws UnsupportedOperationException if this surface cannot host 2D
+	 *             content
+	 */
+	public Graphics activate(Graphics3D i_g3d);
+
+	/**
+	 * Deactivates this surface for 2D rendering.
+	 * 
+	 * @param i_g3d the graphics 3D instance
+	 * @throws IllegalStateException if this surface is currently not active for
+	 *             2D rendering
+	 * @throws UnsupportedOperationException if this surface cannot host 2D
+	 *             content
+	 */
+	public void deactivate(Graphics3D i_g3d);
+
+	/**
 	 * Returns the child figure at the given surface coordinates or
 	 * &lt;code&gt;null&lt;/code&gt; if no such figure exists. If the given tree search
 	 * structure is not &lt;code&gt;null&lt;/code&gt;, only such figures that satisfy the
@@ -201,4 +228,12 @@
 	 * @return the result vector
 	 */
 	public Vector3f getWorldLocation(Point i_surface, Vector3f o_result);
+
+	/**
+	 * Indicates whether this surface can host 2D content.
+	 * 
+	 * @return &lt;code&gt;true&lt;/code&gt; if this surface can host 2D content and
+	 *         &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public boolean is2DHost();
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -41,6 +41,7 @@
 import org.eclipse.draw3d.geometry.Transformable;
 import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.geometry.IPosition3D.PositionHint;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.draw3d.picking.Picker;
@@ -128,7 +129,7 @@
 
 			final RenderContext renderContext = getRenderContext();
 			DisplayListManager displayListManager =
-				renderContext.getDisplayListManager();
+				renderContext.getGraphics3D().getDisplayListManager();
 
 			if (!displayListManager.isDisplayList(DL_AXES))
 				displayListManager.createDisplayList(DL_AXES, new Runnable() {

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -18,6 +18,7 @@
 import java.util.logging.Logger;
 
 import org.eclipse.draw3d.RenderFragment.RenderType;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.swt.opengl.GLCanvas;
@@ -45,8 +46,6 @@
 
 	private GLCanvas m_Canvas;
 
-	private final Map&lt;Graphics3D, DisplayListManager&gt; m_displayListManagers;
-
 	private Graphics3D m_g3d = null;
 
 	private boolean m_redraw2DContent;
@@ -57,15 +56,6 @@
 	private IScene m_scene;
 
 	/**
-	 * Creates a new render context. The context is created by the
-	 * {@link LightweightSystem3D}.
-	 */
-	public RenderContext() {
-
-		m_displayListManagers = new HashMap&lt;Graphics3D, DisplayListManager&gt;();
-	}
-
-	/**
 	 * 
 	 */
 	public void activate() {
@@ -108,58 +98,16 @@
 	}
 
 	/**
-	 * Clears the display manager for the current g3d instance.
-	 */
-	public void clearDisplayListManager() {
-		if (getGraphics3D() == null) {
-			throw new IllegalStateException(&quot;no graphics3D intance set yet&quot;);
-		}
-		m_displayListManagers.remove(getGraphics3D());
-	}
-
-	/**
 	 * Disposes all {@link DisplayListManager}, clears display manager map, and
 	 * disposes the current {@link Graphics3D} instance. This method is called
 	 * by the {@link LightweightSystem3D} when the widget is disposed.
 	 */
 	public synchronized void dispose() {
 
-		try {
-			for (DisplayListManager manager : m_displayListManagers.values())
-				manager.dispose();
-
-			m_displayListManagers.clear();
-			m_g3d.dispose();
-		} catch (Exception ex) {
-			log.warning(&quot;Error disposing render context: &quot; + ex);
-		}
+		m_g3d.dispose();
 	}
 
 	/**
-	 * Returns the display list manager of this render context.
-	 * 
-	 * @return the display list manager
-	 * @throws IllegalStateException if no display list manager is set
-	 */
-	public DisplayListManager getDisplayListManager() {
-
-		if (getGraphics3D() == null) {
-			throw new IllegalStateException(&quot;no graphcis 3D instance set yet&quot;);
-		}
-
-		DisplayListManager manager = m_displayListManagers.get(getGraphics3D());
-		// if (manager == null)
-		// throw new IllegalStateException(
-		// &quot;display list manager was not set for this graphics3D instane&quot;);
-		if (manager == null) {
-			manager = new DisplayListManager(getGraphics3D());
-			m_displayListManagers.put(getGraphics3D(), manager);
-		}
-
-		return manager;
-	}
-
-	/**
 	 * Returns the Graphics3D instance which shall be used for rendering in this
 	 * context.
 	 * 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/VoidSurface.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -10,6 +10,7 @@
  ******************************************************************************/
 package org.eclipse.draw3d;
 
+import org.eclipse.draw2d.Graphics;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.draw2d.TreeSearch;
 import org.eclipse.draw2d.geometry.Point;
@@ -18,6 +19,7 @@
 import org.eclipse.draw3d.geometry.IVector3f;
 import org.eclipse.draw3d.geometry.Math3D;
 import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.picking.Hit;
 import org.eclipse.draw3d.picking.Picker;
 import org.eclipse.draw3d.util.Draw3DCache;
@@ -72,6 +74,17 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.ISurface#activate(org.eclipse.draw3d.graphics3d.Graphics3D)
+	 */
+	public Graphics activate(Graphics3D i_g3d) {
+
+		throw new UnsupportedOperationException(
+			&quot;void surface cannot host 2D content&quot;);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.ISceneListener#cameraChanged(org.eclipse.draw3d.camera.ICamera,
 	 *      org.eclipse.draw3d.camera.ICamera)
 	 */
@@ -86,6 +99,17 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.ISurface#deactivate(Graphics3D)
+	 */
+	public void deactivate(Graphics3D i_g3d) {
+
+		throw new UnsupportedOperationException(
+			&quot;void surface cannot host 2D content&quot;);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.ISurface#findFigureAt(int, int,
 	 *      org.eclipse.draw2d.TreeSearch)
 	 */
@@ -140,6 +164,22 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.ISurface#getSurfaceRotation(org.eclipse.draw3d.geometry.Vector3f)
+	 */
+	public Vector3f getSurfaceRotation(Vector3f o_result) {
+
+		Vector3f zAxis = Draw3DCache.getVector3f();
+		try {
+			getZAxis(zAxis);
+			return Math3D.eulerAngles(zAxis, IVector3f.Z_AXIS, o_result);
+		} finally {
+			Draw3DCache.returnVector3f(zAxis);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.AbstractSurface#getXAxis(org.eclipse.draw3d.geometry.Vector3f)
 	 */
 	@Override
@@ -182,6 +222,16 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.ISurface#is2DHost()
+	 */
+	public boolean is2DHost() {
+
+		return false;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.ISceneListener#renderPassFinished(org.eclipse.draw3d.RenderContext)
 	 */
 	public void renderPassFinished(RenderContext i_renderContext) {
@@ -215,20 +265,4 @@
 
 		return b.toString();
 	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.ISurface#getSurfaceRotation(org.eclipse.draw3d.geometry.Vector3f)
-	 */
-	public Vector3f getSurfaceRotation(Vector3f o_result) {
-
-		Vector3f zAxis = Draw3DCache.getVector3f();
-		try {
-			getZAxis(zAxis);
-			return Math3D.eulerAngles(zAxis, IVector3f.Z_AXIS, o_result);
-		} finally {
-			Draw3DCache.returnVector3f(zAxis);
-		}
-	}
 }

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GLGraphicsRecorder.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -0,0 +1,89 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.LineAttributes;
+
+/**
+ * Saves fonts and custom dash patterns so that they can be initialized before
+ * the recorded method calls are played back.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 06.11.2009
+ */
+public class GLGraphicsRecorder extends GraphicsRecorder {
+
+	private Set&lt;int[]&gt; m_dashes = new HashSet&lt;int[]&gt;();
+
+	private Set&lt;Font&gt; m_fonts = new HashSet&lt;Font&gt;();
+
+	private void saveLineDash() {
+
+		int[] lineDash = getState().getLineDash();
+		if (lineDash != null)
+			m_dashes.add(lineDash);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setFont(org.eclipse.swt.graphics.Font)
+	 */
+	@Override
+	public void setFont(Font i_f) {
+
+		super.setFont(i_f);
+
+		if (i_f != null)
+			m_fonts.add(i_f);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
+	 */
+	@Override
+	public void setLineAttributes(LineAttributes i_attributes) {
+
+		super.setLineAttributes(i_attributes);
+		saveLineDash();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineDash(float[])
+	 */
+	@Override
+	public void setLineDash(float[] i_dash) {
+
+		super.setLineDash(i_dash);
+		saveLineDash();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.GraphicsRecorder#setLineDash(int[])
+	 */
+	@Override
+	public void setLineDash(int[] i_dash) {
+
+		super.setLineDash(i_dash);
+		saveLineDash();
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsRecorder.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -0,0 +1,1076 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics;
+
+import java.lang.reflect.Method;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.PointList;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.LineAttributes;
+import org.eclipse.swt.graphics.Path;
+import org.eclipse.swt.graphics.Pattern;
+import org.eclipse.swt.graphics.TextLayout;
+
+/**
+ * GraphicsRecorder There should really be more documentation here.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 05.11.2009
+ */
+public class GraphicsRecorder extends StatefulGraphics {
+
+	private static class MethodCall {
+
+		private Object[] m_args;
+
+		private Method m_method;
+
+		/**
+		 * @param i_method
+		 * @param i_args
+		 */
+		public MethodCall(Method i_method, Object[] i_args) {
+
+			m_method = i_method;
+			m_args = i_args;
+		}
+
+		public void execute(Object i_target) {
+
+			try {
+				m_method.invoke(i_target, m_args);
+			} catch (Exception e) {
+				throw new RuntimeException(e);
+			}
+		}
+	}
+
+	private static Method m_clipRect;
+
+	private static Method m_dispose;
+
+	private static Method m_drawArc;
+
+	private static Method m_drawFocus;
+
+	private static Method m_drawImageLong;
+
+	private static Method m_drawImageShort;
+
+	private static Method m_drawLine;
+
+	private static Method m_drawOval;
+
+	private static Method m_drawPath;
+
+	private static Method m_drawPoint;
+
+	private static Method m_drawPolygon;
+
+	private static Method m_drawPolygonWithArray;
+
+	private static Method m_drawPolyline;
+
+	private static Method m_drawPolylineWithArray;
+
+	private static Method m_drawRectangle;
+
+	private static Method m_drawRoundRectangle;
+
+	private static Method m_drawString;
+
+	private static Method m_drawTextLayout;
+
+	private static Method m_drawTextLong;
+
+	private static Method m_drawTextShort;
+
+	private static Method m_fillArc;
+
+	private static Method m_fillGradient;
+
+	private static Method m_fillOval;
+
+	private static Method m_fillPath;
+
+	private static Method m_fillPolygon;
+
+	private static Method m_fillPolygonWithArray;
+
+	private static Method m_fillRectangle;
+
+	private static Method m_fillRoundRectangle;
+
+	private static Method m_fillString;
+
+	private static Method m_fillText;
+
+	private static Method m_popState;
+
+	private static Method m_pushState;
+
+	private static Method m_restoreState;
+
+	private static Method m_rotate;
+
+	private static Method m_scale;
+
+	private static Method m_scaleUniform;
+
+	private static Method m_setAdvanced;
+
+	private static Method m_setAlpha;
+
+	private static Method m_setAntialias;
+
+	private static Method m_setBackgroundColor;
+
+	private static Method m_setBackgroundPattern;
+
+	private static Method m_setClip;
+
+	private static Method m_setClipWithPath;
+
+	private static Method m_setFillRule;
+
+	private static Method m_setFont;
+
+	private static Method m_setForegroundColor;
+
+	private static Method m_setForegroundPattern;
+
+	private static Method m_setInterpolation;
+
+	private static Method m_setLineAttributes;
+
+	private static Method m_setLineCap;
+
+	private static Method m_setLineDashWithFloatArray;
+
+	private static Method m_setLineDashWithIntArray;
+
+	private static Method m_setLineJoin;
+
+	private static Method m_setLineMiterLimit;
+
+	private static Method m_setLineStyle;
+
+	private static Method m_setLineWidth;
+
+	private static Method m_setLineWidthFloat;
+
+	private static Method m_setTextAntialias;
+
+	private static Method m_setXORMode;
+
+	private static Method m_shear;
+
+	private static Method m_translate;
+
+	private static Method m_translateWithFloat;
+
+	static {
+
+		Class&lt;Graphics&gt; cls = Graphics.class;
+		try {
+			m_clipRect = cls.getMethod(&quot;clipRect&quot;, Rectangle.class);
+			m_dispose = cls.getMethod(&quot;dispose&quot;);
+			m_drawArc =
+				cls.getMethod(&quot;drawArc&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class, Integer.class, Integer.class);
+			m_drawFocus =
+				cls.getMethod(&quot;drawFocus&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_drawImageShort =
+				cls.getMethod(&quot;drawImage&quot;, Image.class, Integer.class,
+					Integer.class);
+			m_drawImageLong =
+				cls.getMethod(&quot;drawImage&quot;, Image.class, Integer.class,
+					Integer.class, Integer.class, Integer.class, Integer.class,
+					Integer.class, Integer.class, Integer.class);
+			m_drawLine =
+				cls.getMethod(&quot;drawLine&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_drawOval =
+				cls.getMethod(&quot;drawOval&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_drawPath = cls.getMethod(&quot;drawPath&quot;, Path.class);
+			m_drawPoint =
+				cls.getMethod(&quot;drawPoint&quot;, Integer.class, Integer.class);
+			m_drawPolygonWithArray = cls.getMethod(&quot;drawPolygon&quot;, int[].class);
+			m_drawPolygon = cls.getMethod(&quot;drawPolygon&quot;, PointList.class);
+			m_drawPolylineWithArray =
+				cls.getMethod(&quot;drawPolyline&quot;, int[].class);
+			m_drawPolyline = cls.getMethod(&quot;drawPolyline&quot;, PointList.class);
+			m_drawRectangle =
+				cls.getMethod(&quot;drawRectangle&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_drawRoundRectangle =
+				cls.getMethod(&quot;drawRoundRectangle&quot;, Rectangle.class,
+					Integer.class, Integer.class);
+			m_drawString =
+				cls.getMethod(&quot;drawString&quot;, String.class, Integer.class,
+					Integer.class);
+			m_drawTextShort =
+				cls.getMethod(&quot;drawText&quot;, String.class, Integer.class,
+					Integer.class);
+			m_drawTextLong =
+				cls.getMethod(&quot;drawText&quot;, String.class, Integer.class,
+					Integer.class, Integer.class);
+			m_drawTextLayout =
+				cls.getMethod(&quot;drawTextLayout&quot;, TextLayout.class,
+					Integer.class, Integer.class, Integer.class, Integer.class,
+					Color.class, Color.class);
+			m_fillArc =
+				cls.getMethod(&quot;fillArc&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class, Integer.class, Integer.class);
+			m_fillGradient =
+				cls.getMethod(&quot;fillGradient&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class, Boolean.class);
+			m_fillOval =
+				cls.getMethod(&quot;fillOval&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_fillPath = cls.getMethod(&quot;fillPath&quot;, Path.class);
+			m_fillPolygonWithArray = cls.getMethod(&quot;fillPolygon&quot;, int[].class);
+			m_fillPolygon = cls.getMethod(&quot;fillPolygon&quot;, PointList.class);
+			m_fillRectangle =
+				cls.getMethod(&quot;fillRectangle&quot;, Integer.class, Integer.class,
+					Integer.class, Integer.class);
+			m_fillRoundRectangle =
+				cls.getMethod(&quot;fillRoundRectangle&quot;, Rectangle.class,
+					Integer.class, Integer.class);
+			m_fillString =
+				cls.getMethod(&quot;fillString&quot;, String.class, Integer.class,
+					Integer.class);
+			m_fillText =
+				cls.getMethod(&quot;fillText&quot;, String.class, Integer.class,
+					Integer.class);
+			m_popState = cls.getMethod(&quot;popState&quot;);
+			m_pushState = cls.getMethod(&quot;pushState&quot;);
+			m_restoreState = cls.getMethod(&quot;restoreState&quot;);
+			m_rotate = cls.getMethod(&quot;rotate&quot;, Float.class);
+			m_scaleUniform = cls.getMethod(&quot;scale&quot;, Double.class);
+			m_scale = cls.getMethod(&quot;scale&quot;, Float.class, Float.class);
+			m_setAdvanced = cls.getMethod(&quot;setAdvanced&quot;, Boolean.class);
+			m_setAlpha = cls.getMethod(&quot;setAlpha&quot;, Integer.class);
+			m_setAntialias = cls.getMethod(&quot;setAntialias&quot;, Integer.class);
+			m_setBackgroundColor =
+				cls.getMethod(&quot;setBackgroundColor&quot;, Color.class);
+			m_setBackgroundPattern =
+				cls.getMethod(&quot;setBackgroundPattern&quot;, Pattern.class);
+			m_setClipWithPath = cls.getMethod(&quot;setClip&quot;, Path.class);
+			m_setClip = cls.getMethod(&quot;setClip&quot;, Rectangle.class);
+			m_setFillRule = cls.getMethod(&quot;setFillRule&quot;, Integer.class);
+			m_setFont = cls.getMethod(&quot;setFont&quot;, Font.class);
+			m_setForegroundColor =
+				cls.getMethod(&quot;setForegroundColor&quot;, Color.class);
+			m_setForegroundPattern =
+				cls.getMethod(&quot;setForegroundPattern&quot;, Pattern.class);
+			m_setInterpolation =
+				cls.getMethod(&quot;setInterpolation&quot;, Integer.class);
+			m_setLineAttributes =
+				cls.getMethod(&quot;setLineAttributes&quot;, LineAttributes.class);
+			m_setLineCap = cls.getMethod(&quot;setLineCap&quot;, Integer.class);
+			m_setLineDashWithFloatArray =
+				cls.getMethod(&quot;setLineDash&quot;, float[].class);
+			m_setLineDashWithIntArray =
+				cls.getMethod(&quot;setLineDash&quot;, int[].class);
+			m_setLineJoin = cls.getMethod(&quot;setLineJoin&quot;, Integer.class);
+			m_setLineMiterLimit =
+				cls.getMethod(&quot;setLineMiterLimit&quot;, Float.class);
+			m_setLineStyle = cls.getMethod(&quot;setLineStyle&quot;, Integer.class);
+			m_setLineWidth = cls.getMethod(&quot;setLineWidth&quot;, Integer.class);
+			m_setLineWidthFloat =
+				cls.getMethod(&quot;setLineWidthFloat&quot;, Float.class);
+			m_setTextAntialias =
+				cls.getMethod(&quot;setTextAntialias&quot;, Integer.class);
+			m_setXORMode = cls.getMethod(&quot;setXORMode&quot;, Boolean.class);
+			m_shear = cls.getMethod(&quot;shear&quot;, Float.class, Float.class);
+			m_translateWithFloat =
+				cls.getMethod(&quot;translate&quot;, Float.class, Float.class);
+			m_translate =
+				cls.getMethod(&quot;translate&quot;, Integer.class, Integer.class);
+		} catch (Exception e) {
+			// TODO Implement catch block for SecurityException
+			e.printStackTrace();
+		}
+	}
+
+	private List&lt;MethodCall&gt; m_calls = new LinkedList&lt;MethodCall&gt;();
+
+	/**
+	 * Clears the recorded method calls.
+	 */
+	public void clear() {
+
+		m_calls.clear();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#clipRect(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	public void clipRect(Rectangle i_r) {
+
+		super.clipRect(i_r);
+		record(m_clipRect, i_r);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#dispose()
+	 */
+	@Override
+	public void dispose() {
+
+		super.dispose();
+		record(m_dispose);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawArc(int, int, int, int, int, int)
+	 */
+	@Override
+	public void drawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
+		int i_length) {
+
+		record(m_drawArc, i_x, i_y, i_w, i_h, i_offset, i_length);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawFocus(int, int, int, int)
+	 */
+	@Override
+	public void drawFocus(int i_x, int i_y, int i_w, int i_h) {
+
+		record(m_drawFocus, i_x, i_y, i_w, i_h);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image,
+	 *      int, int)
+	 */
+	@Override
+	public void drawImage(Image i_srcImage, int i_x, int i_y) {
+
+		record(m_drawImageShort, i_srcImage, i_x, i_y);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawImage(org.eclipse.swt.graphics.Image,
+	 *      int, int, int, int, int, int, int, int)
+	 */
+	@Override
+	public void drawImage(Image i_srcImage, int i_x1, int i_y1, int i_w1,
+		int i_h1, int i_x2, int i_y2, int i_w2, int i_h2) {
+
+		record(m_drawImageLong, i_srcImage, i_x1, i_y1, i_w1, i_h1, i_x2, i_y2,
+			i_w2, i_h2);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawLine(int, int, int, int)
+	 */
+	@Override
+	public void drawLine(int i_x1, int i_y1, int i_x2, int i_y2) {
+
+		record(m_drawLine, i_x1, i_y1, i_x2, i_y2);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawOval(int, int, int, int)
+	 */
+	@Override
+	public void drawOval(int i_x, int i_y, int i_w, int i_h) {
+
+		record(m_drawOval, i_x, i_y, i_w, i_h);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPath(org.eclipse.swt.graphics.Path)
+	 */
+	@Override
+	public void drawPath(Path i_path) {
+
+		record(m_drawPath, i_path);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPoint(int, int)
+	 */
+	@Override
+	public void drawPoint(int i_x, int i_y) {
+
+		record(m_drawPoint, i_x, i_y);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPolygon(int[])
+	 */
+	@Override
+	public void drawPolygon(int[] i_points) {
+
+		record(m_drawPolygonWithArray, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPolygon(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void drawPolygon(PointList i_points) {
+
+		record(m_drawPolygon, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPolyline(int[])
+	 */
+	@Override
+	public void drawPolyline(int[] i_points) {
+
+		record(m_drawPolylineWithArray, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawPolyline(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void drawPolyline(PointList i_points) {
+
+		record(m_drawPolyline, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawRectangle(int, int, int, int)
+	 */
+	@Override
+	public void drawRectangle(int i_x, int i_y, int i_width, int i_height) {
+
+		record(m_drawRectangle, i_x, i_y, i_width, i_height);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawRoundRectangle(org.eclipse.draw2d.geometry.Rectangle,
+	 *      int, int)
+	 */
+	@Override
+	public void drawRoundRectangle(Rectangle i_r, int i_arcWidth,
+		int i_arcHeight) {
+
+		record(m_drawRoundRectangle, i_r, i_arcWidth, i_arcHeight);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawString(java.lang.String, int, int)
+	 */
+	@Override
+	public void drawString(String i_s, int i_x, int i_y) {
+
+		record(m_drawString, i_s, i_x, i_y);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawText(java.lang.String, int, int)
+	 */
+	@Override
+	public void drawText(String i_s, int i_x, int i_y) {
+
+		record(m_drawTextShort, i_s, i_x, i_y);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawText(java.lang.String, int, int,
+	 *      int)
+	 */
+	@Override
+	public void drawText(String i_s, int i_x, int i_y, int i_style) {
+
+		record(m_drawTextLong, i_s, i_x, i_y, i_style);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#drawTextLayout(org.eclipse.swt.graphics.TextLayout,
+	 *      int, int, int, int, org.eclipse.swt.graphics.Color,
+	 *      org.eclipse.swt.graphics.Color)
+	 */
+	@Override
+	public void drawTextLayout(TextLayout i_layout, int i_x, int i_y,
+		int i_selectionStart, int i_selectionEnd, Color i_selectionForeground,
+		Color i_selectionBackground) {
+
+		record(m_drawTextLayout, i_layout, i_x, i_y, i_selectionStart,
+			i_selectionEnd, i_selectionForeground, i_selectionBackground);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillArc(int, int, int, int, int, int)
+	 */
+	@Override
+	public void fillArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
+		int i_length) {
+
+		record(m_fillArc, i_x, i_y, i_w, i_h, i_offset, i_length);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillGradient(int, int, int, int,
+	 *      boolean)
+	 */
+	@Override
+	public void fillGradient(int i_x, int i_y, int i_w, int i_h,
+		boolean i_vertical) {
+
+		record(m_fillGradient, i_x, i_y, i_w, i_h, i_vertical);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillOval(int, int, int, int)
+	 */
+	@Override
+	public void fillOval(int i_x, int i_y, int i_w, int i_h) {
+
+		record(m_fillOval, i_x, i_y, i_w, i_h);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillPath(org.eclipse.swt.graphics.Path)
+	 */
+	@Override
+	public void fillPath(Path i_path) {
+
+		record(m_fillPath, i_path);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillPolygon(int[])
+	 */
+	@Override
+	public void fillPolygon(int[] i_points) {
+
+		record(m_fillPolygonWithArray, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillPolygon(org.eclipse.draw2d.geometry.PointList)
+	 */
+	@Override
+	public void fillPolygon(PointList i_points) {
+
+		record(m_fillPolygon, i_points);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillRectangle(int, int, int, int)
+	 */
+	@Override
+	public void fillRectangle(int i_x, int i_y, int i_width, int i_height) {
+
+		record(m_fillRectangle, i_x, i_y, i_width, i_height);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillRoundRectangle(org.eclipse.draw2d.geometry.Rectangle,
+	 *      int, int)
+	 */
+	@Override
+	public void fillRoundRectangle(Rectangle i_r, int i_arcWidth,
+		int i_arcHeight) {
+
+		record(m_fillRoundRectangle, i_r, i_arcWidth, i_arcHeight);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillString(java.lang.String, int, int)
+	 */
+	@Override
+	public void fillString(String i_s, int i_x, int i_y) {
+
+		record(m_fillString, i_s, i_x, i_y);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#fillText(java.lang.String, int, int)
+	 */
+	@Override
+	public void fillText(String i_s, int i_x, int i_y) {
+
+		record(m_fillText, i_s, i_x, i_y);
+	}
+
+	/**
+	 * Play the recorded method calls against the given target.
+	 * 
+	 * @param i_target the target
+	 */
+	public void playback(Graphics i_target) {
+
+		if (i_target == null)
+			throw new NullPointerException(&quot;i_target must not be null&quot;);
+
+		for (MethodCall call : m_calls)
+			call.execute(i_target);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#popState()
+	 */
+	@Override
+	public void popState() {
+
+		super.popState();
+		record(m_popState);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#pushState()
+	 */
+	@Override
+	public void pushState() {
+
+		super.pushState();
+		record(m_pushState);
+	}
+
+	private void record(Method i_method, Object... args) {
+
+		m_calls.add(new MethodCall(i_method, args));
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#restoreState()
+	 */
+	@Override
+	public void restoreState() {
+
+		super.restoreState();
+		record(m_restoreState);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#rotate(float)
+	 */
+	@Override
+	public void rotate(float i_degrees) {
+
+		super.rotate(i_degrees);
+		record(m_rotate, i_degrees);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#scale(double)
+	 */
+	@Override
+	public void scale(double i_amount) {
+
+		super.scale(i_amount);
+		record(m_scaleUniform, i_amount);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#scale(float, float)
+	 */
+	@Override
+	public void scale(float i_horizontal, float i_vertical) {
+
+		super.scale(i_horizontal, i_vertical);
+		record(m_scale, i_horizontal, i_vertical);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAdvanced(boolean)
+	 */
+	@Override
+	public void setAdvanced(boolean i_advanced) {
+
+		super.setAdvanced(i_advanced);
+		record(m_setAdvanced, i_advanced);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAlpha(int)
+	 */
+	@Override
+	public void setAlpha(int i_alpha) {
+
+		super.setAlpha(i_alpha);
+		record(m_setAlpha, i_alpha);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAntialias(int)
+	 */
+	@Override
+	public void setAntialias(int i_antialias) {
+
+		super.setAntialias(i_antialias);
+		record(m_setAntialias, i_antialias);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setBackgroundColor(org.eclipse.swt.graphics.Color)
+	 */
+	@Override
+	public void setBackgroundColor(Color i_backgroundColor) {
+
+		super.setBackgroundColor(i_backgroundColor);
+		record(m_setBackgroundColor, i_backgroundColor);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setBackgroundPattern(org.eclipse.swt.graphics.Pattern)
+	 */
+	@Override
+	public void setBackgroundPattern(Pattern i_backgroundPattern) {
+
+		super.setBackgroundPattern(i_backgroundPattern);
+		record(m_setBackgroundPattern, i_backgroundPattern);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.swt.graphics.Path)
+	 */
+	@Override
+	public void setClip(Path i_path) {
+
+		super.setClip(i_path);
+		record(m_setClipWithPath, i_path);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	public void setClip(Rectangle i_r) {
+
+		super.setClip(i_r);
+		record(m_setClip, i_r);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setFillRule(int)
+	 */
+	@Override
+	public void setFillRule(int i_rule) {
+
+		super.setFillRule(i_rule);
+		record(m_setFillRule, i_rule);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setFont(org.eclipse.swt.graphics.Font)
+	 */
+	@Override
+	public void setFont(Font i_f) {
+
+		super.setFont(i_f);
+		record(m_setFont, i_f);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setForegroundColor(org.eclipse.swt.graphics.Color)
+	 */
+	@Override
+	public void setForegroundColor(Color i_foregroundColor) {
+
+		super.setForegroundColor(i_foregroundColor);
+		record(m_setForegroundColor, i_foregroundColor);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setForegroundPattern(org.eclipse.swt.graphics.Pattern)
+	 */
+	@Override
+	public void setForegroundPattern(Pattern i_pattern) {
+
+		super.setForegroundPattern(i_pattern);
+		record(m_setForegroundPattern, i_pattern);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setInterpolation(int)
+	 */
+	@Override
+	public void setInterpolation(int i_interpolation) {
+
+		super.setInterpolation(i_interpolation);
+		record(m_setInterpolation, i_interpolation);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
+	 */
+	@Override
+	public void setLineAttributes(LineAttributes i_attributes) {
+
+		super.setLineAttributes(i_attributes);
+		record(m_setLineAttributes, i_attributes);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineCap(int)
+	 */
+	@Override
+	public void setLineCap(int i_cap) {
+
+		super.setLineCap(i_cap);
+		record(m_setLineCap, i_cap);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
+	 */
+	@Override
+	public void setLineDash(float[] i_dash) {
+
+		super.setLineDash(i_dash);
+		record(m_setLineDashWithFloatArray, i_dash);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
+	 */
+	@Override
+	public void setLineDash(int[] i_dash) {
+
+		super.setLineDash(i_dash);
+		record(m_setLineDashWithIntArray, i_dash);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineJoin(int)
+	 */
+	@Override
+	public void setLineJoin(int i_join) {
+
+		super.setLineJoin(i_join);
+		record(m_setLineJoin, i_join);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineMiterLimit(float)
+	 */
+	@Override
+	public void setLineMiterLimit(float i_miterLimit) {
+
+		super.setLineMiterLimit(i_miterLimit);
+		record(m_setLineMiterLimit, i_miterLimit);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineStyle(int)
+	 */
+	@Override
+	public void setLineStyle(int i_style) {
+
+		super.setLineStyle(i_style);
+		record(m_setLineStyle, i_style);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineWidth(int)
+	 */
+	@Override
+	public void setLineWidth(int i_width) {
+
+		super.setLineWidth(i_width);
+		record(m_setLineWidth, i_width);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineWidthFloat(float)
+	 */
+	@Override
+	public void setLineWidthFloat(float i_width) {
+
+		super.setLineWidthFloat(i_width);
+		record(m_setLineWidthFloat, i_width);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setTextAntialias(int)
+	 */
+	@Override
+	public void setTextAntialias(int i_value) {
+
+		super.setTextAntialias(i_value);
+		record(m_setTextAntialias, i_value);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setXORMode(boolean)
+	 */
+	@Override
+	public void setXORMode(boolean i_b) {
+
+		super.setXORMode(i_b);
+		record(m_setXORMode);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#shear(float, float)
+	 */
+	@Override
+	public void shear(float i_horz, float i_vert) {
+
+		super.shear(i_horz, i_vert);
+		record(m_shear, i_horz, i_vert);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#translate(float, float)
+	 */
+	@Override
+	public void translate(float i_dx, float i_dy) {
+
+		super.translate(i_dx, i_dy);
+		record(m_translateWithFloat, i_dx, i_dy);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#translate(int, int)
+	 */
+	@Override
+	public void translate(int i_dx, int i_dy) {
+
+		super.translate(i_dx, i_dy);
+		record(m_translate, i_dx, i_dy);
+	}
+}

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsState.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsState.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/GraphicsState.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -0,0 +1,846 @@
+package org.eclipse.draw3d.graphics;
+
+import org.eclipse.draw2d.geometry.PrecisionPoint;
+import org.eclipse.draw2d.geometry.PrecisionRectangle;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw3d.geometry.IMatrix4f;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Matrix4f;
+import org.eclipse.draw3d.geometry.Matrix4fImpl;
+import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.util.Draw3DCache;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Device;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Pattern;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * A graphics state that forwards requests for unset values to its parent state.
+ * 
+ * @author Kristian Duske
+ * @version $Revision: 383 $
+ * @since 08.03.2008
+ */
+public class GraphicsState {
+
+	/**
+	 * Creates a new graphics state that has been initialized with default
+	 * values.
+	 * 
+	 * @param i_width the width of the graphics object
+	 * @param i_height the height of the graphics object
+	 * @return the new graphics state
+	 */
+	public static GraphicsState createDefaultState() {
+
+		Display display = Display.getDefault();
+
+		Color foregroundColor = display.getSystemColor(SWT.COLOR_BLACK);
+		Color backgroundColor = display.getSystemColor(SWT.COLOR_WHITE);
+
+		GraphicsState state = new GraphicsState();
+
+		state.setClip(new Rectangle(0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE));
+		state.setAdvanced(true);
+
+		state.setForegroundColor(foregroundColor);
+		state.setBackgroundColor(backgroundColor);
+		state.setAlpha(255);
+
+		state.setLineWidth(1);
+		state.setLineStyle(SWT.LINE_SOLID);
+		state.setLineCap(SWT.CAP_FLAT);
+		state.setLineJoin(SWT.JOIN_MITER);
+		state.setLineMiterLimit(11);
+
+		state.setFont(display.getSystemFont());
+
+		state.setTransformation(Matrix4f.IDENTITY);
+		state.setXORMode(false);
+
+		state.setAntialias(SWT.ON);
+		state.setInterpolation(SWT.NONE);
+		state.setTextAntialias(SWT.ON);
+
+		state.setFillRule(SWT.FILL_WINDING);
+
+		return state;
+	}
+
+	private Boolean m_advanced;
+
+	private Integer m_alpha;
+
+	private Integer m_antialias;
+
+	private Color m_backgroundColor;
+
+	private Pattern m_backgroundPattern;
+
+	private PrecisionRectangle m_clip;
+
+	private Integer m_fillRule;
+
+	private Font m_font;
+
+	private Color m_foregroundColor;
+
+	private Pattern m_foregroundPattern;
+
+	private Integer m_interpolation;
+
+	private Integer m_lineCap;
+
+	private int[] m_lineDash;
+
+	private int m_lineDashLength;
+
+	private Integer m_lineJoin;
+
+	private FontMetrics m_fontMetrics;
+
+	private Float m_lineMiterLimit;
+
+	private Integer m_lineStyle;
+
+	private Float m_lineWidth;
+
+	private final GraphicsState m_parentState;
+
+	private Integer m_textAntialias;
+
+	private Matrix4fImpl m_transformation;
+
+	private Boolean m_xorMode;
+
+	private Font m_metricsFont;
+
+	/**
+	 * Returns the font metrics for the current font.
+	 * 
+	 * @return the font metrics
+	 */
+	public FontMetrics getFontMetrics() {
+
+		Font font = getFont();
+		if (font == null)
+			return null;
+
+		if (font.equals(m_metricsFont) &amp;&amp; m_fontMetrics != null)
+			return m_fontMetrics;
+
+		m_metricsFont = font;
+		Device device = m_metricsFont.getDevice();
+
+		Image image = null;
+		GC gc = null;
+
+		try {
+			image = new Image(device, 1, 1);
+			gc = new GC(image);
+
+			gc.setFont(m_metricsFont);
+			m_fontMetrics = gc.getFontMetrics();
+
+			return m_fontMetrics;
+		} finally {
+			if (gc != null)
+				gc.dispose();
+
+			if (image != null)
+				image.dispose();
+		}
+	}
+
+	/**
+	 * Creates a new graphics state with no parent
+	 */
+	private GraphicsState() {
+
+		m_parentState = null;
+	}
+
+	/**
+	 * Creates a new chained graphics state with the given parent.
+	 * 
+	 * @param i_parentState the parent of this state
+	 */
+	public GraphicsState(GraphicsState i_parentState) {
+
+		if (i_parentState == null)
+			throw new NullPointerException(&quot;i_parentState must not be null&quot;);
+
+		m_parentState = i_parentState;
+	}
+
+	/**
+	 * Intersects the current clipping rectangle with the given rectangle.
+	 * 
+	 * @param i_clip the rectangle to intersect with
+	 */
+	public void clipRect(Rectangle i_clip) {
+
+		if (i_clip == null)
+			return;
+
+		PrecisionRectangle currentClip = getClip();
+		if (currentClip != null &amp;&amp; !currentClip.equals(i_clip)) {
+			if (m_clip == null)
+				m_clip = new PrecisionRectangle(currentClip);
+
+			// clipping in SWTGraphics is working slightly differently as
+			// Rectangle clipping, so we emulate the SWTClipping here:
+			double l = Math.max(m_clip.preciseX(), i_clip.preciseX());
+			double r =
+				Math.min(m_clip.preciseX() + m_clip.preciseWidth(),
+					i_clip.preciseX() + i_clip.preciseWidth());
+
+			double t = Math.max(m_clip.preciseY(), i_clip.preciseY());
+			double b =
+				Math.min(m_clip.preciseY() + m_clip.preciseHeight(),
+					i_clip.preciseY() + i_clip.preciseHeight());
+
+			if (r &lt; l || b &lt; t) {
+				// width and height of -1 to avoid ceiling function from
+				// re-adding a pixel.
+				r = l - 1;
+				b = t - 1;
+			}
+
+			m_clip.setX(l);
+			m_clip.setY(t);
+			m_clip.setWidth(r - l);
+			m_clip.setHeight(b - t);
+
+			// m_clip.intersect(i_clip);
+		} else
+			m_clip = new PrecisionRectangle(i_clip);
+	}
+
+	/**
+	 * Indicates whether the graphics system is in advanced graphics mode.
+	 * 
+	 * @return &lt;code&gt;true&lt;/code&gt; if the graphics subsystem is in advanced
+	 *         graphics mode and &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public boolean getAdvanced() {
+
+		if (m_advanced != null)
+			return m_advanced;
+
+		return m_parentState.getAdvanced();
+	}
+
+	/**
+	 * Returns the alpha value of this graphics state.
+	 * 
+	 * @return the alpha value of this graphics state
+	 */
+	public int getAlpha() {
+
+		if (m_alpha != null)
+			return m_alpha;
+
+		return m_parentState.getAlpha();
+	}
+
+	/**
+	 * Returns the antialias value for this graphics state.
+	 * 
+	 * @return the antialias value for this graphics state.
+	 */
+	public int getAntialias() {
+
+		if (m_antialias != null)
+			return m_antialias;
+
+		return m_parentState.getAntialias();
+	}
+
+	/**
+	 * Returns the background color of this graphics state.
+	 * 
+	 * @return the background color
+	 */
+	public Color getBackgroundColor() {
+
+		if (m_backgroundColor != null)
+			return m_backgroundColor;
+
+		return m_parentState.getBackgroundColor();
+	}
+
+	/**
+	 * Returns the background pattern of this graphics state.
+	 * 
+	 * @return the background pattern
+	 */
+	public Pattern getBackgroundPattern() {
+
+		if (m_backgroundPattern != null)
+			return m_backgroundPattern;
+
+		if (m_parentState != null)
+			return m_parentState.getBackgroundPattern();
+
+		return null;
+	}
+
+	/**
+	 * Returns the clip rectangle of this state.
+	 * 
+	 * @return the clip rectangle
+	 */
+	public PrecisionRectangle getClip() {
+
+		if (m_clip != null)
+			return m_clip;
+
+		if (m_parentState != null)
+			return m_parentState.getClip();
+
+		return null;
+	}
+
+	/**
+	 * Returns the fill rule of this graphics state.
+	 * 
+	 * @return the fill rule of this graphics state
+	 */
+	public int getFillRule() {
+
+		if (m_fillRule != null)
+			return m_fillRule;
+
+		return m_parentState.getFillRule();
+	}
+
+	/**
+	 * Returns the font of this graphics state.
+	 * 
+	 * @return the font
+	 */
+	public Font getFont() {
+
+		if (m_font != null)
+			return m_font;
+
+		return m_parentState.getFont();
+	}
+
+	/**
+	 * Returns the foreground color of this graphics state.
+	 * 
+	 * @return the foreground color
+	 */
+	public Color getForegroundColor() {
+
+		if (m_foregroundColor != null)
+			return m_foregroundColor;
+
+		return m_parentState.getForegroundColor();
+	}
+
+	/**
+	 * Returns the foreground parttern for this graphics state.
+	 * 
+	 * @return the foreground pattern
+	 */
+	public Pattern getForegroundPattern() {
+
+		if (m_foregroundPattern != null)
+			return m_foregroundPattern;
+
+		if (m_parentState != null)
+			return m_parentState.getForegroundPattern();
+
+		return null;
+	}
+
+	/**
+	 * Returns the interpolation setting for this graphics state.
+	 * 
+	 * @return the interpolation setting
+	 */
+	public int getInterpolation() {
+
+		if (m_interpolation != null)
+			return m_interpolation;
+
+		return m_parentState.getInterpolation();
+	}
+
+	/**
+	 * Returns the line cap setting for this graphics state
+	 * 
+	 * @return the line cap setting
+	 */
+	public int getLineCap() {
+
+		if (m_lineCap != null)
+			return m_lineCap;
+
+		return m_parentState.getLineCap();
+	}
+
+	/**
+	 * Returns the custom line dash pattern.
+	 * 
+	 * @return the custom line dash pattern
+	 */
+	public int[] getLineDash() {
+
+		if (m_lineDash != null)
+			return m_lineDash;
+
+		if (m_parentState != null)
+			return m_parentState.getLineDash();
+
+		return null;
+	}
+
+	/**
+	 * Returns the total length of the line dash pattern. The total length of a
+	 * line dash pattern is the sum of all the elements of the pattern array.
+	 * 
+	 * @return the total length of the line dash pattern
+	 */
+	public int getLineDashLength() {
+
+		if (m_lineDash != null)
+			return m_lineDashLength;
+
+		return m_parentState.getLineDashLength();
+	}
+
+	/**
+	 * Returns the line join style for this graphics state.
+	 * 
+	 * @return the line join style for this graphics state
+	 */
+	public int getLineJoin() {
+
+		if (m_lineJoin != null)
+			return m_lineJoin;
+
+		return m_parentState.getLineJoin();
+	}
+
+	/**
+	 * Returns the line miter limit of this graphics state.
+	 * 
+	 * @return the line miter limit of this graphics state
+	 */
+	public float getLineMiterLimit() {
+
+		if (m_lineMiterLimit != null)
+			return m_lineMiterLimit;
+
+		return m_parentState.getLineMiterLimit();
+	}
+
+	/**
+	 * Returns the line style of this graphics state.
+	 * 
+	 * @return the line style
+	 */
+	public int getLineStyle() {
+
+		if (m_lineStyle != null)
+			return m_lineStyle;
+
+		return m_parentState.getLineStyle();
+	}
+
+	/**
+	 * Returns the line width of this graphics state.
+	 * 
+	 * @return the line width
+	 */
+	public float getLineWidth() {
+
+		if (m_lineWidth != null)
+			return m_lineWidth;
+
+		return m_parentState.getLineWidth();
+	}
+
+	/**
+	 * Returns the parent graphics state.
+	 * 
+	 * @return the parent graphics state
+	 */
+	public GraphicsState getParent() {
+
+		return m_parentState;
+	}
+
+	/**
+	 * Returns the text antialias value of this graphics state.
+	 * 
+	 * @return the text antialias value
+	 */
+	public int getTextAntialias() {
+
+		if (m_textAntialias != null)
+			return m_textAntialias;
+
+		return m_parentState.getTextAntialias();
+	}
+
+	/**
+	 * Returns the transformation matrix of this graphics state.
+	 * 
+	 * @return the transformation matrix
+	 */
+	public Matrix4f getTransformation() {
+
+		return m_transformation;
+	}
+
+	/**
+	 * Indicates whether XOR mode drawing is enabled.
+	 * 
+	 * @return &lt;code&gt;true&lt;/code&gt; if XOR drawing mode is enabled or
+	 *         &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public boolean getXORMode() {
+
+		if (m_xorMode != null)
+			return m_xorMode;
+
+		return m_parentState.getXORMode();
+	}
+
+	/**
+	 * Rotates the coordinates system by the given angle counterclockwise.
+	 * 
+	 * @param i_degrees the rotation angle in degrees
+	 */
+	public void rotate(float i_degrees) {
+
+		if (m_transformation == null)
+			m_transformation = new Matrix4fImpl();
+
+		Matrix4f rot = Draw3DCache.getMatrix4f();
+		try {
+			// don't use Math3d.rotate() here because when rotating about
+			// the z axis, we can use a shorthand:
+			double radians = Math.toRadians(i_degrees);
+			float sin = (float) Math.sin(radians);
+			float cos = (float) Math.cos(radians);
+
+			rot.setIdentity();
+			rot.set(0, 0, cos);
+			rot.set(1, 0, sin);
+			rot.set(1, 1, cos);
+			rot.set(0, 1, -sin);
+
+			Math3D.mul(rot, m_transformation, m_transformation);
+		} finally {
+			Draw3DCache.returnMatrix4f(rot);
+		}
+	}
+
+	/**
+	 * Scales the current transformation and corrects the clipping rectangle by
+	 * the given factors.
+	 * 
+	 * @param i_horizontal the horizontal scaling factor
+	 * @param i_vertical the vertical scaling factor
+	 */
+	public void scale(float i_horizontal, float i_vertical) {
+
+		if (m_transformation == null)
+			m_transformation = new Matrix4fImpl();
+
+		Vector3f scale = Draw3DCache.getVector3f();
+		try {
+			scale.set(i_horizontal, i_vertical, 0);
+			Math3D.scale(scale, m_transformation, m_transformation);
+		} finally {
+			Draw3DCache.returnVector3f(scale);
+		}
+	}
+
+	/**
+	 * Specifies whether the graphics system is in advanced graphics mode.
+	 * 
+	 * @param i_advanced &lt;code&gt;true&lt;/code&gt; if the graphics system is in advanced
+	 *            graphics mode and &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public void setAdvanced(boolean i_advanced) {
+
+		m_advanced = i_advanced;
+	}
+
+	/**
+	 * Sets the alpha value of this graphics state.
+	 * 
+	 * @param i_alpha the alpha value
+	 */
+	public void setAlpha(int i_alpha) {
+
+		m_alpha = i_alpha;
+	}
+
+	/**
+	 * Sets the antialias value for this graphics state.
+	 * 
+	 * @param i_antialias the antialias value
+	 */
+	public void setAntialias(int i_antialias) {
+
+		m_antialias = i_antialias;
+	}
+
+	/**
+	 * Sets the background color of this graphics state.
+	 * 
+	 * @param i_backgroundColor the new background color
+	 */
+	public void setBackgroundColor(Color i_backgroundColor) {
+
+		m_backgroundColor = i_backgroundColor;
+	}
+
+	/**
+	 * Sets the background pattern of this graphics state.
+	 * 
+	 * @param i_backgroundPattern the background pattern
+	 */
+	public void setBackgroundPattern(Pattern i_backgroundPattern) {
+
+		m_backgroundPattern = i_backgroundPattern;
+	}
+
+	/**
+	 * Sets the clip rectangleof this state.
+	 * 
+	 * @param i_clip the clip rectangle
+	 */
+	public void setClip(Rectangle i_clip) {
+
+		if (i_clip == null) {
+			m_clip = null;
+			return;
+		}
+
+		if (m_clip == null) {
+			m_clip = new PrecisionRectangle(i_clip);
+			return;
+		}
+
+		m_clip.setX(i_clip.preciseX());
+		m_clip.setY(i_clip.preciseY());
+		m_clip.setWidth(i_clip.preciseWidth());
+		m_clip.setHeight(i_clip.preciseHeight());
+	}
+
+	/**
+	 * Sets the fill rule of this graphics state.
+	 * 
+	 * @param i_fillRule the fill rule of this graphics state
+	 */
+	public void setFillRule(int i_fillRule) {
+
+		m_fillRule = i_fillRule;
+	}
+
+	/**
+	 * Sets the font of this graphics state.
+	 * 
+	 * @param i_font the font
+	 */
+	public void setFont(Font i_font) {
+
+		m_font = i_font;
+
+		m_fontMetrics = null;
+		m_metricsFont = null;
+	}
+
+	/**
+	 * Sets the foreground color of this graphics state.
+	 * 
+	 * @param i_foregroundColor the foreground color
+	 */
+	public void setForegroundColor(Color i_foregroundColor) {
+
+		m_foregroundColor = i_foregroundColor;
+	}
+
+	/**
+	 * Sets the foreground pattern of this graphics state.
+	 * 
+	 * @param i_foregroundPattern the foreground pattern
+	 */
+	public void setForegroundPattern(Pattern i_foregroundPattern) {
+
+		m_foregroundPattern = i_foregroundPattern;
+	}
+
+	/**
+	 * Sets the interpolation setting for this graphics state.
+	 * 
+	 * @param i_interpolation the interpolation setting
+	 */
+	public void setInterpolation(int i_interpolation) {
+
+		m_interpolation = i_interpolation;
+	}
+
+	/**
+	 * Sets the line cap value of this graphics state.
+	 * 
+	 * @param i_lineCap the line cap value
+	 */
+	public void setLineCap(int i_lineCap) {
+
+		m_lineCap = i_lineCap;
+	}
+
+	/**
+	 * Sets the custom line dash pattern.
+	 * 
+	 * @param i_lineDash the custom line dash pattern
+	 */
+	public void setLineDash(int[] i_lineDash) {
+
+		m_lineDash = i_lineDash;
+		m_lineDashLength = 0;
+
+		if (m_lineDash != null)
+			for (int i = 0; i &lt; m_lineDash.length; i++)
+				m_lineDashLength += m_lineDash[i];
+	}
+
+	/**
+	 * Sets the line join value of this graphics state.
+	 * 
+	 * @param i_lineJoin the line join value
+	 */
+	public void setLineJoin(int i_lineJoin) {
+
+		m_lineJoin = i_lineJoin;
+	}
+
+	/**
+	 * Sets the line miter limit of this graphics state.
+	 * 
+	 * @param i_lineMiterLimit the new line miter limit
+	 */
+	public void setLineMiterLimit(float i_lineMiterLimit) {
+
+		m_lineMiterLimit = i_lineMiterLimit;
+	}
+
+	/**
+	 * Sets the line style of this graphics state.
+	 * 
+	 * @param i_lineStyle the line style
+	 */
+	public void setLineStyle(int i_lineStyle) {
+
+		m_lineStyle = i_lineStyle;
+	}
+
+	/**
+	 * Sets the line width of this graphics state.
+	 * 
+	 * @param i_lineWidth the line width
+	 */
+	public void setLineWidth(float i_lineWidth) {
+
+		m_lineWidth = i_lineWidth;
+	}
+
+	/**
+	 * Sets the text antialias value of this graphics state.
+	 * 
+	 * @param i_textAntialias the text antialias value
+	 */
+	public void setTextAntialias(int i_textAntialias) {
+
+		m_textAntialias = i_textAntialias;
+	}
+
+	/**
+	 * Sets the current transformation.
+	 * 
+	 * @param i_transformation the current transformation
+	 */
+	public void setTransformation(IMatrix4f i_transformation) {
+
+		if (m_transformation == null)
+			m_transformation = new Matrix4fImpl(i_transformation);
+		else
+			m_transformation.set(i_transformation);
+	}
+
+	/**
+	 * Specifies whether XOR mode drawing is enabled.
+	 * 
+	 * @param i_xorMode &lt;code&gt;true&lt;/code&gt; if XOR mode should be enabled or
+	 *            &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public void setXORMode(boolean i_xorMode) {
+
+		m_xorMode = i_xorMode;
+	}
+
+	/**
+	 * Shears the current transformation and corrects the clipping rectangle by
+	 * the given amounts.
+	 * 
+	 * @param i_horz the horizontal shearing amount
+	 * @param i_vert the vertical shearing amount
+	 */
+	public void shear(float i_horz, float i_vert) {
+
+		if (m_transformation == null)
+			m_transformation = new Matrix4fImpl();
+
+		Matrix4f shear = Draw3DCache.getMatrix4f();
+		try {
+			shear.setIdentity();
+			shear.set(1, 0, i_horz);
+			shear.set(0, 1, i_vert);
+
+			Math3D.mul(shear, m_transformation, m_transformation);
+		} finally {
+			Draw3DCache.returnMatrix4f(shear);
+		}
+	}
+
+	/**
+	 * Translates the current transformation and corrects the clipping rectangle
+	 * by the given amounts.
+	 * 
+	 * @param i_dX the X translation
+	 * @param i_dY the Y translation
+	 */
+	public void translate(float i_dX, float i_dY) {
+
+		if (m_transformation == null)
+			m_transformation = new Matrix4fImpl();
+
+		Vector3f trans = Draw3DCache.getVector3f();
+		try {
+			trans.set(i_dX, i_dY, 0);
+			Math3D.translate(m_transformation, trans, m_transformation);
+
+			if (m_clip == null)
+				m_clip = new PrecisionRectangle(m_parentState.getClip());
+
+			m_clip.translate(new PrecisionPoint(-i_dX, -i_dY));
+		} finally {
+			Draw3DCache.returnVector3f(trans);
+		}
+	}
+}
\ No newline at end of file

Added: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/StatefulGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/StatefulGraphics.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/graphics/StatefulGraphics.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -0,0 +1,798 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics;
+
+import java.util.EmptyStackException;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.LineAttributes;
+import org.eclipse.swt.graphics.Pattern;
+
+/**
+ * Abstract base class for all graphics implementations that have a state.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 06.11.2009
+ */
+public abstract class StatefulGraphics extends Graphics {
+
+	private GraphicsState m_defaultState;
+
+	private boolean m_disposed = false;
+
+	private GraphicsState m_state;
+
+	/**
+	 * Creates and initializes a new instance.
+	 */
+	public StatefulGraphics() {
+
+		m_defaultState = GraphicsState.createDefaultState();
+		m_state = new GraphicsState(m_defaultState);
+	}
+
+	/**
+	 * Throws an {@link IllegalStateException} if this graphics is disposed.
+	 */
+	protected void checkDisposed() {
+
+		if (m_disposed)
+			throw new IllegalStateException(this + &quot; is disposed&quot;);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#clipRect(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	public void clipRect(Rectangle i_r) {
+
+		m_state.clipRect(i_r);
+	}
+
+	/**
+	 * Converts the given float dash pattern to an int pattern.
+	 * 
+	 * @param i_dash the pattern to convert
+	 * @return the converted pattern or &lt;code&gt;null&lt;/code&gt; if the given pattern
+	 *         is &lt;code&gt;null&lt;/code&gt;
+	 */
+	protected int[] convertDash(float[] i_dash) {
+
+		if (i_dash == null)
+			return null;
+
+		int[] result = new int[i_dash.length];
+		for (int i = 0; i &lt; i_dash.length; i++)
+			result[i] = (int) i_dash[i];
+
+		return result;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#dispose()
+	 */
+	@Override
+	public void dispose() {
+
+		checkDisposed();
+
+		m_disposed = true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getAdvanced()
+	 */
+	@Override
+	public boolean getAdvanced() {
+
+		checkDisposed();
+
+		return m_state.getAdvanced();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getAlpha()
+	 */
+	@Override
+	public int getAlpha() {
+
+		checkDisposed();
+
+		return m_state.getAlpha();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getAntialias()
+	 */
+	@Override
+	public int getAntialias() {
+
+		checkDisposed();
+
+		return m_state.getAntialias();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getBackgroundColor()
+	 */
+	@Override
+	public Color getBackgroundColor() {
+
+		checkDisposed();
+
+		return m_state.getBackgroundColor();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getClip(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	public Rectangle getClip(Rectangle o_rect) {
+
+		checkDisposed();
+
+		Rectangle clip = m_state.getClip();
+		o_rect.setBounds(clip);
+
+		return o_rect;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getFillRule()
+	 */
+	@Override
+	public int getFillRule() {
+
+		checkDisposed();
+
+		return m_state.getFillRule();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getFont()
+	 */
+	@Override
+	public Font getFont() {
+
+		checkDisposed();
+
+		return m_state.getFont();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getFontMetrics()
+	 */
+	@Override
+	public FontMetrics getFontMetrics() {
+
+		checkDisposed();
+
+		return m_state.getFontMetrics();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getForegroundColor()
+	 */
+	@Override
+	public Color getForegroundColor() {
+
+		checkDisposed();
+
+		return m_state.getForegroundColor();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getInterpolation()
+	 */
+	@Override
+	public int getInterpolation() {
+
+		checkDisposed();
+
+		return m_state.getInterpolation();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineAttributes()
+	 */
+	@Override
+	public LineAttributes getLineAttributes() {
+
+		checkDisposed();
+
+		LineAttributes attrs = new LineAttributes(m_state.getLineWidth());
+		attrs.cap = m_state.getLineCap();
+		attrs.dashOffset = 0;
+		attrs.join = m_state.getLineJoin();
+		attrs.miterLimit = m_state.getLineMiterLimit();
+		attrs.style = m_state.getLineStyle();
+
+		int[] lineDash = m_state.getLineDash();
+		if (lineDash == null)
+			attrs.dash = null;
+		else {
+			attrs.dash = new float[lineDash.length];
+			for (int i = 0; i &lt; lineDash.length; i++)
+				attrs.dash[i] = lineDash[i];
+		}
+
+		return attrs;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineCap()
+	 */
+	@Override
+	public int getLineCap() {
+
+		checkDisposed();
+
+		return m_state.getLineCap();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineJoin()
+	 */
+	@Override
+	public int getLineJoin() {
+
+		checkDisposed();
+
+		return m_state.getLineJoin();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineMiterLimit()
+	 */
+	@Override
+	public float getLineMiterLimit() {
+
+		checkDisposed();
+
+		return m_state.getLineMiterLimit();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineStyle()
+	 */
+	@Override
+	public int getLineStyle() {
+
+		checkDisposed();
+
+		return m_state.getLineStyle();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineWidth()
+	 */
+	@Override
+	public int getLineWidth() {
+
+		checkDisposed();
+
+		return Math.round(m_state.getLineWidth());
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getLineWidthFloat()
+	 */
+	@Override
+	public float getLineWidthFloat() {
+
+		checkDisposed();
+
+		return m_state.getLineWidth();
+	}
+
+	/**
+	 * Returns the current state.
+	 * 
+	 * @return the current state
+	 */
+	protected GraphicsState getState() {
+
+		return m_state;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getTextAntialias()
+	 */
+	@Override
+	public int getTextAntialias() {
+
+		checkDisposed();
+
+		return m_state.getTextAntialias();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#getXORMode()
+	 */
+	@Override
+	public boolean getXORMode() {
+
+		checkDisposed();
+
+		return m_state.getXORMode();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#popState()
+	 */
+	@Override
+	public void popState() {
+
+		checkDisposed();
+
+		if (m_state.getParent() == m_defaultState)
+			throw new EmptyStackException();
+
+		m_state = m_state.getParent();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#pushState()
+	 */
+	@Override
+	public void pushState() {
+
+		checkDisposed();
+
+		m_state = new GraphicsState(m_state);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#restoreState()
+	 */
+	@Override
+	public void restoreState() {
+
+		checkDisposed();
+
+		m_state = new GraphicsState(m_state.getParent());
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#rotate(float)
+	 */
+	@Override
+	public void rotate(float i_degrees) {
+
+		checkDisposed();
+
+		if (i_degrees != 0)
+			m_state.rotate(i_degrees);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#scale(double)
+	 */
+	@Override
+	public void scale(double i_amount) {
+
+		checkDisposed();
+
+		if (i_amount != 0)
+			m_state.scale((float) i_amount, (float) i_amount);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#scale(float, float)
+	 */
+	@Override
+	public void scale(float i_horizontal, float i_vertical) {
+
+		checkDisposed();
+
+		if (i_horizontal != 0 || i_vertical != 0)
+			m_state.scale(i_horizontal, i_vertical);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAdvanced(boolean)
+	 */
+	@Override
+	public void setAdvanced(boolean i_advanced) {
+
+		checkDisposed();
+
+		m_state.setAdvanced(i_advanced);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAlpha(int)
+	 */
+	@Override
+	public void setAlpha(int i_alpha) {
+
+		checkDisposed();
+
+		m_state.setAlpha(i_alpha);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setAntialias(int)
+	 */
+	@Override
+	public void setAntialias(int i_antialias) {
+
+		checkDisposed();
+
+		m_state.setAntialias(i_antialias);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setBackgroundColor(org.eclipse.swt.graphics.Color)
+	 */
+	@Override
+	public void setBackgroundColor(Color i_backgroundColor) {
+
+		checkDisposed();
+
+		m_state.setBackgroundColor(i_backgroundColor);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setBackgroundPattern(org.eclipse.swt.graphics.Pattern)
+	 */
+	@Override
+	public void setBackgroundPattern(Pattern i_backgroundPattern) {
+
+		checkDisposed();
+
+		m_state.setBackgroundPattern(i_backgroundPattern);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.draw2d.geometry.Rectangle)
+	 */
+	@Override
+	public void setClip(Rectangle i_r) {
+
+		checkDisposed();
+
+		m_state.setClip(i_r);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setFillRule(int)
+	 */
+	@Override
+	public void setFillRule(int i_fillRule) {
+
+		checkDisposed();
+
+		m_state.setFillRule(i_fillRule);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setFont(org.eclipse.swt.graphics.Font)
+	 */
+	@Override
+	public void setFont(Font i_font) {
+
+		checkDisposed();
+
+		m_state.setFont(i_font);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setForegroundColor(org.eclipse.swt.graphics.Color)
+	 */
+	@Override
+	public void setForegroundColor(Color i_foregroundColor) {
+
+		checkDisposed();
+
+		m_state.setForegroundColor(i_foregroundColor);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setInterpolation(int)
+	 */
+	@Override
+	public void setInterpolation(int i_interpolation) {
+
+		checkDisposed();
+
+		m_state.setInterpolation(i_interpolation);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
+	 */
+	@Override
+	public void setLineAttributes(LineAttributes i_attributes) {
+
+		checkDisposed();
+
+		if (i_attributes == null)
+			return;
+
+		m_state.setLineCap(i_attributes.cap);
+		m_state.setLineJoin(i_attributes.join);
+		m_state.setLineMiterLimit(i_attributes.miterLimit);
+		m_state.setLineStyle(i_attributes.style);
+		m_state.setLineWidth(i_attributes.width);
+
+		m_state.setLineDash(convertDash(i_attributes.dash));
+		if (i_attributes.dash != null)
+			m_state.setLineStyle(SWT.LINE_CUSTOM);
+		else
+			m_state.setLineStyle(SWT.LINE_SOLID);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineCap(int)
+	 */
+	@Override
+	public void setLineCap(int i_cap) {
+
+		checkDisposed();
+
+		m_state.setLineCap(i_cap);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineDash(float[])
+	 */
+	@Override
+	public void setLineDash(float[] i_dash) {
+
+		checkDisposed();
+
+		if (i_dash != null) {
+			m_state.setLineStyle(SWT.LINE_CUSTOM);
+			m_state.setLineDash(convertDash(i_dash));
+		} else {
+			m_state.setLineStyle(SWT.LINE_SOLID);
+			m_state.setLineDash(null);
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
+	 */
+	@Override
+	public void setLineDash(int[] i_dash) {
+
+		checkDisposed();
+
+		if (i_dash != null)
+			m_state.setLineStyle(SWT.LINE_CUSTOM);
+		else
+			m_state.setLineStyle(SWT.LINE_SOLID);
+
+		m_state.setLineDash(i_dash);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineJoin(int)
+	 */
+	@Override
+	public void setLineJoin(int i_lineJoin) {
+
+		checkDisposed();
+
+		m_state.setLineJoin(i_lineJoin);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineMiterLimit(float)
+	 */
+	@Override
+	public void setLineMiterLimit(float i_lineMiterLimit) {
+
+		checkDisposed();
+
+		m_state.setLineMiterLimit(i_lineMiterLimit);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineStyle(int)
+	 */
+	@Override
+	public void setLineStyle(int i_lineStyle) {
+
+		checkDisposed();
+
+		m_state.setLineStyle(i_lineStyle);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineWidth(int)
+	 */
+	@Override
+	public void setLineWidth(int i_lineWidth) {
+
+		checkDisposed();
+
+		m_state.setLineWidth(i_lineWidth);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setLineWidthFloat(float)
+	 */
+	@Override
+	public void setLineWidthFloat(float i_lineWidth) {
+
+		checkDisposed();
+
+		m_state.setLineWidth(i_lineWidth);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setTextAntialias(int)
+	 */
+	@Override
+	public void setTextAntialias(int i_textAntialias) {
+
+		checkDisposed();
+
+		m_state.setTextAntialias(i_textAntialias);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#setXORMode(boolean)
+	 */
+	@Override
+	public void setXORMode(boolean i_enabled) {
+
+		checkDisposed();
+
+		m_state.setXORMode(i_enabled);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#shear(float, float)
+	 */
+	@Override
+	public void shear(float i_horz, float i_vert) {
+
+		checkDisposed();
+
+		if (i_horz != 0 || i_vert != 0)
+			m_state.shear(i_horz, i_vert);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#translate(float, float)
+	 */
+	@Override
+	public void translate(float i_dx, float i_dy) {
+
+		checkDisposed();
+
+		if (i_dx != 0 || i_dy != 0)
+			m_state.translate(i_dx, i_dy);
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.draw2d.Graphics#translate(int, int)
+	 */
+	@Override
+	public void translate(int i_dx, int i_dy) {
+
+		checkDisposed();
+
+		if (i_dx != 0 || i_dy != 0)
+			m_state.translate(i_dx, i_dy);
+	}
+}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CuboidShape.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -14,7 +14,6 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
-import org.eclipse.draw3d.DisplayListManager;
 import org.eclipse.draw3d.RenderContext;
 import org.eclipse.draw3d.geometry.IPosition3D;
 import org.eclipse.draw3d.geometry.IVector2f;
@@ -23,6 +22,7 @@
 import org.eclipse.draw3d.geometry.Vector2fImpl;
 import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.geometry.Vector3fImpl;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.swt.SWT;
@@ -198,7 +198,7 @@
 	@Override
 	protected void doRender(RenderContext i_renderContext) {
 		DisplayListManager displayListManager =
-			i_renderContext.getDisplayListManager();
+			i_renderContext.getGraphics3D().getDisplayListManager();
 
 		Graphics3D g3d = i_renderContext.getGraphics3D();
 		initDisplayLists(displayListManager, g3d);

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/CylinderShape.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -13,13 +13,13 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.eclipse.draw3d.DisplayListManager;
 import org.eclipse.draw3d.RenderContext;
 import org.eclipse.draw3d.geometry.IPosition3D;
 import org.eclipse.draw3d.geometry.IVector3f;
 import org.eclipse.draw3d.geometry.Math3D;
 import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.geometry.Vector3fImpl;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.draw3d.util.Draw3DCache;
@@ -472,7 +472,7 @@
 
 		Graphics3D g3d = i_renderContext.getGraphics3D();
 		DisplayListManager displayListManager =
-			i_renderContext.getDisplayListManager();
+			i_renderContext.getGraphics3D().getDisplayListManager();
 
 		initDisplayLists(displayListManager, g3d);
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/shapes/SphereShape.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -13,7 +13,6 @@
 import java.util.HashMap;
 import java.util.Map;
 
-import org.eclipse.draw3d.DisplayListManager;
 import org.eclipse.draw3d.RenderContext;
 import org.eclipse.draw3d.geometry.IPosition3D;
 import org.eclipse.draw3d.geometry.IVector3f;
@@ -21,6 +20,7 @@
 import org.eclipse.draw3d.geometry.Position3DImpl;
 import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.geometry.Vector3fImpl;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.draw3d.picking.Query;
@@ -303,7 +303,7 @@
 
 		Graphics3D g3d = i_renderContext.getGraphics3D();
 		DisplayListManager displayListManager =
-			i_renderContext.getDisplayListManager();
+			i_renderContext.getGraphics3D().getDisplayListManager();
 
 		initDisplayLists(displayListManager, g3d);
 

Copied: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java (from rev 387, branches/experimental_direct_2D_rendering/org.eclipse.draw3d/src/java/org/eclipse/draw3d/DisplayListManager.java)
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	                        (rev 0)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/DisplayListManager.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -0,0 +1,251 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.graphics3d;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Queue;
+import java.util.Map.Entry;
+import java.util.logging.Logger;
+
+/**
+ * Manages display lists during a render operation in the current GL context.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 24.05.2008
+ */
+public class DisplayListManager {
+
+	@SuppressWarnings(&quot;unused&quot;)
+	private static final Logger log =
+		Logger.getLogger(DisplayListManager.class.getName());
+
+	private static final int RANGE = 10;
+
+	private List&lt;Integer&gt; m_baseIds = new ArrayList&lt;Integer&gt;();
+
+	private Map&lt;Object, Integer&gt; m_displayLists =
+		new HashMap&lt;Object, Integer&gt;();
+
+	private final boolean m_disposed = false;
+
+	private Queue&lt;Integer&gt; m_freeIds = new LinkedList&lt;Integer&gt;();
+
+	private Graphics3D m_graphics3D;
+
+	private int m_index = RANGE;
+
+	/**
+	 * Creates a new display list manager for the given graphics3D object.
+	 * 
+	 * @param i_graphics3D the graphics3D object that contains this manager
+	 */
+	public DisplayListManager(Graphics3D i_graphics3D) {
+
+		if (i_graphics3D == null)
+			throw new NullPointerException(&quot;i_graphics3D must not be null&quot;);
+
+		m_graphics3D = i_graphics3D;
+	}
+
+	/**
+	 * Clears all displays lists in this manager.
+	 * 
+	 * @throws IllegalStateException if this display list manager is disposed
+	 */
+	public void clear() {
+
+		if (m_disposed)
+			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
+
+		for (int baseId : m_baseIds)
+			m_graphics3D.glDeleteLists(baseId, RANGE);
+
+		m_index = RANGE;
+		m_baseIds.clear();
+		m_displayLists.clear();
+		m_freeIds.clear();
+	}
+
+	private LinkedList&lt;List&lt;Integer&gt;&gt; m_creationStack =
+		new LinkedList&lt;List&lt;Integer&gt;&gt;();
+
+	/**
+	 * Creates a new display lists with the given key. The display lists will
+	 * contain the GL commands that are executed by the given runnable. If there
+	 * already is a display list with the given key, it will be overwritten.
+	 * 
+	 * @param i_key the key of the new display list
+	 * @param i_runnable the code that generates the GL commands for the display
+	 *            list
+	 * @throws NullPointerException if either of the given arguments is
+	 *             &lt;code&gt;null&lt;/code&gt;
+	 * @throws IllegalStateException if this display list manager is disposed
+	 */
+	public void createDisplayList(Object i_key, Runnable i_runnable) {
+
+		if (m_disposed)
+			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
+
+		if (i_key == null)
+			throw new NullPointerException(&quot;i_key must not be null&quot;);
+
+		if (i_runnable == null)
+			throw new NullPointerException(&quot;i_runnable must not be null&quot;);
+
+		if (!m_creationStack.isEmpty())
+			m_graphics3D.glEnd();
+
+		Integer id = doCreateDisplayList(i_key, i_runnable);
+
+		if (!m_creationStack.isEmpty()) {
+			id = getNewId();
+			m_creationStack.getLast().add(id);
+			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+		}
+	}
+
+	private Integer doCreateDisplayList(Object i_key, Runnable i_runnable) {
+
+		Integer id = m_displayLists.get(i_key);
+		if (id == null)
+			id = getNewId();
+
+		List&lt;Integer&gt; subListIds = new LinkedList&lt;Integer&gt;();
+		subListIds.add(id);
+		m_creationStack.addLast(subListIds);
+
+		m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+		i_runnable.run();
+		m_graphics3D.glEndList();
+
+		if (subListIds.size() &gt; 1) {
+			id = getNewId();
+			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+			for (Integer subListId : subListIds)
+				m_graphics3D.glCallList(subListId);
+			m_graphics3D.glEndList();
+		}
+
+		m_displayLists.put(i_key, id);
+		m_creationStack.removeLast();
+
+		return id;
+	}
+
+	public void createDisplayLists(Map&lt;Object, Runnable&gt; i_requests) {
+
+		if (i_requests == null)
+			throw new NullPointerException(&quot;i_requests must not be null&quot;);
+
+		if (!m_creationStack.isEmpty())
+			m_graphics3D.glEnd();
+
+		for (Entry&lt;Object, Runnable&gt; entry : i_requests.entrySet())
+			doCreateDisplayList(entry.getKey(), entry.getValue());
+
+		if (!m_creationStack.isEmpty()) {
+			Integer id = getNewId();
+			m_creationStack.getLast().add(id);
+			m_graphics3D.glNewList(id, Graphics3DDraw.GL_COMPILE);
+		}
+	}
+
+	/**
+	 * Disposes all ressources associated with this display list manager.
+	 */
+	public void dispose() {
+
+		if (m_disposed)
+			return;
+
+		clear();
+		m_baseIds = null;
+		m_displayLists = null;
+	}
+
+	/**
+	 * Executes the display list with the given key.
+	 * 
+	 * @param i_key the key of the display list to execute
+	 * @throws NullPointerException if the given name is &lt;code&gt;null&lt;/code&gt;
+	 * @throws IllegalArgumentException if there is no display list with the
+	 *             given name
+	 * @throws IllegalStateException if the display list with the given name was
+	 *             created before, but has since been discarded
+	 * @throws IllegalStateException if this display list manager is disposed
+	 */
+	public void executeDisplayList(Object i_key) {
+
+		if (m_disposed)
+			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
+
+		if (i_key == null)
+			throw new NullPointerException(&quot;i_key must not be null&quot;);
+
+		Integer id = m_displayLists.get(i_key);
+		if (id == null)
+			throw new IllegalArgumentException(&quot;unknown display list: &quot; + i_key);
+
+		m_graphics3D.glCallList(id);
+	}
+
+	/**
+	 * Returns an unused display list ID.
+	 * 
+	 * @return an unused display list ID
+	 * @throws IllegalStateException if this display list manager is disposed
+	 */
+	private int getNewId() {
+
+		if (m_disposed)
+			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
+
+		if (!m_freeIds.isEmpty())
+			return m_freeIds.poll();
+
+		if (m_index == RANGE) {
+			int baseId = m_graphics3D.glGenLists(RANGE);
+			m_baseIds.add(baseId);
+			m_index = 0;
+		}
+
+		int baseId = m_baseIds.get(m_baseIds.size() - 1);
+		return baseId + m_index++;
+	}
+
+	/**
+	 * Indicates whether a number of display lists have been registered with
+	 * this manager.
+	 * 
+	 * @param i_keys the keys of the display lists to check for
+	 * @return &lt;code&gt;true&lt;/code&gt; if all display lists with the given keys are
+	 *         ready to use or &lt;code&gt;false&lt;/code&gt; otherwise
+	 * @throws IllegalStateException if this display list manager is disposed
+	 */
+	public boolean isDisplayList(Object... i_keys) {
+
+		if (m_disposed)
+			throw new IllegalStateException(&quot;display list manager is disposed&quot;);
+
+		if (i_keys != null &amp;&amp; i_keys.length &gt; 0)
+			for (Object key : i_keys)
+				if (!m_displayLists.containsKey(key))
+					return false;
+
+		return true;
+	}
+
+}

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -14,7 +14,7 @@
 package org.eclipse.draw3d.graphics3d;
 
 import org.eclipse.draw2d.Graphics;
-import org.eclipse.swt.graphics.Color;
+import org.eclipse.draw3d.geometry.IPosition3D;
 import org.eclipse.swt.opengl.GLCanvas;
 
 /**
@@ -55,14 +55,13 @@
 	 * 
 	 * @param i_key Object associated respective to associate with the activated
 	 *            graphics objects.
+	 * @param i_position the position to use for setting up the transformation
 	 * @param i_width Desired width of the graphics object.
 	 * @param i_height Desired height of the graphics object.
-	 * @param i_alpha Desired alpha value of the graphics object.
-	 * @param i_color Desired background color of the graphics object.
 	 * @return The activated graphics object.
 	 */
-	public Graphics activateGraphics2D(Object i_key, int i_width, int i_height,
-		int i_alpha, Color i_color);
+	public Graphics activateGraphics2D(Object i_key, IPosition3D i_position,
+		int i_width, int i_height);
 
 	/**
 	 * Deactivates the active graphics object.
@@ -82,6 +81,13 @@
 	public Graphics3DDescriptor getDescriptor();
 
 	/**
+	 * Returns the display list manager for this instance.
+	 * 
+	 * @return the display list manager
+	 */
+	public DisplayListManager getDisplayListManager();
+
+	/**
 	 * Gets an ID for the graphics object associated with the given key object.
 	 * 
 	 * @param i_key The key object.

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -17,13 +17,19 @@
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.geometry.IPosition3D;
+import org.eclipse.draw3d.geometry.Math3D;
+import org.eclipse.draw3d.geometry.Matrix4f;
+import org.eclipse.draw3d.geometry.Vector3f;
 import org.eclipse.draw3d.graphics3d.AbstractGraphics3DDraw;
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.Graphics3D;
 import org.eclipse.draw3d.graphics3d.Graphics3DDescriptor;
 import org.eclipse.draw3d.graphics3d.Graphics3DException;
 import org.eclipse.draw3d.graphics3d.Graphics3DOffscreenBufferConfig;
 import org.eclipse.draw3d.graphics3d.Graphics3DOffscreenBuffers;
+import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics;
 import org.eclipse.draw3d.graphics3d.lwjgl.offscreen.LwjglOffscreenBackBuffers;
 import org.eclipse.draw3d.graphics3d.lwjgl.offscreen.LwjglOffscreenBufferConfig;
@@ -35,6 +41,8 @@
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.opengl.GLCanvas;
 import org.lwjgl.LWJGLException;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL13;
 import org.lwjgl.opengl.GLContext;
 
 /**
@@ -49,6 +57,16 @@
 public class Graphics3DLwjgl extends AbstractGraphics3DDraw implements
 		Graphics3D {
 	/**
+	 * Indicates which attribute groups must be saved prior to using this.
+	 */
+	private static final int ATTRIB_MASK =
+		GL11.GL_LIGHTING_BIT | GL11.GL_CURRENT_BIT | GL11.GL_TRANSFORM_BIT
+			| GL11.GL_LINE_BIT | GL11.GL_POLYGON_BIT | GL11.GL_TEXTURE_BIT
+			| GL11.GL_VIEWPORT_BIT | GL11.GL_DEPTH_BUFFER_BIT
+			| GL11.GL_COLOR_BUFFER_BIT | GL13.GL_MULTISAMPLE_BIT
+			| GL11.GL_ENABLE_BIT;
+
+	/**
 	 * Logger for this class
 	 */
 	private static final Logger log =
@@ -67,6 +85,8 @@
 	 */
 	public GLCanvas m_context = null;
 
+	private LwjglFontManager m_fontManager;
+
 	private boolean m_log2D;
 
 	/**
@@ -74,8 +94,10 @@
 	 * content. It is lazily created in
 	 * {@link #activateGraphics2D(Object, int, int, int, Color)}.
 	 */
-	public LwjglTextureManager m_textureManager = null;
+	private LwjglTextureManager m_textureManager = null;
 
+	private DisplayListManager m_displayListManager = null;
+
 	Properties properties = new Properties();
 
 	/**
@@ -95,33 +117,48 @@
 	 * {@inheritDoc}
 	 * 
 	 * @see org.eclipse.draw3d.graphics3d.Graphics3D#activateGraphics2D(Object,
-	 *      int, int, int, Color)
+	 *      int, int)
 	 */
-	public Graphics activateGraphics2D(Object i_key, int i_width, int i_height,
-		int i_alpha, Color i_color) {
+	public Graphics activateGraphics2D(Object i_key, IPosition3D i_position,
+		int i_width, int i_height) {
 
-		LwjglTextureManager textureManager = getTextureManager();
+		LwjglGraphics graphics =
+			new LwjglGraphics(i_width, i_height, getFontManager());
 
-		if (!textureManager.contains(i_key))
-			textureManager.createTexture(i_key, i_width, i_height);
+		String fontAntialias = getProperty(PROP_FONT_AA);
+		if (fontAntialias != null)
+			graphics.setOverrideTextAntialias(Boolean.valueOf(fontAntialias));
 		else
-			textureManager.resizeTexture(i_key, i_width, i_height);
+			graphics.setOverrideTextAntialias(null);
 
-		textureManager.activateTexture(i_key);
-		textureManager.clearTexture(i_key, i_color, i_alpha);
+		// save all state variables that may be changed by the graphics object
+		GL11.glPushAttrib(ATTRIB_MASK);
 
-		Graphics graphics = textureManager.getGraphics();
-		if (graphics instanceof LwjglGraphics) {
-			LwjglGraphics lwjglGraphics = (LwjglGraphics) graphics;
-			String fontAntialias = getProperty(PROP_FONT_AA);
-			if (fontAntialias != null)
-				lwjglGraphics.setOverrideTextAntialias(Boolean.valueOf(fontAntialias));
-			else
-				lwjglGraphics.setOverrideTextAntialias(null);
+		GL11.glMatrixMode(GL11.GL_MODELVIEW);
+		GL11.glPushMatrix();
+
+		Matrix4f m = Draw3DCache.getMatrix4f();
+		Vector3f t = Draw3DCache.getVector3f();
+		try {
+			t.set(0, 0, 0.001f);
+			m.set(i_position.getRotationLocationMatrix());
+			Math3D.translate(m, t, m);
+			setMatrix(m);
+		} finally {
+			Draw3DCache.returnVector3f(t);
+			Draw3DCache.returnMatrix4f(m);
 		}
 
+		GL11.glShadeModel(GL11.GL_FLAT);
+		GL11.glDisable(GL11.GL_DEPTH_TEST);
+		// GL11.glDepthFunc(GL11.GL_LEQUAL);
+		// GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO);
+		GL11.glDisable(GL11.GL_CULL_FACE);
+		GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
+		GL11.glEnable(GL11.GL_LINE_SMOOTH);
+
 		if (m_log2D)
-			graphics = new LogGraphics(graphics);
+			return new LogGraphics(graphics);
 
 		return graphics;
 	}
@@ -133,8 +170,8 @@
 	 */
 	public void deactivateGraphics2D() {
 
-		if (m_textureManager != null)
-			m_textureManager.deactivateTexture();
+		GL11.glPopMatrix();
+		GL11.glPopAttrib();
 	}
 
 	/**
@@ -160,6 +197,14 @@
 		return descriptor;
 	}
 
+	private LwjglFontManager getFontManager() {
+
+		if (m_fontManager == null)
+			m_fontManager = new LwjglFontManager(getDisplayListManager());
+
+		return m_fontManager;
+	}
+
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -230,7 +275,8 @@
 	private LwjglTextureManager getTextureManager() {
 
 		if (m_textureManager == null)
-			m_textureManager = new LwjglTextureManager(m_context);
+			m_textureManager =
+				new LwjglTextureManager(m_context, getFontManager());
 		else if (m_textureManager.isDisposed())
 			throw new IllegalStateException(&quot;TextureManager is disposed&quot;);
 
@@ -240,6 +286,19 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.graphics3d.Graphics3D#getDisplayListManager()
+	 */
+	public DisplayListManager getDisplayListManager() {
+
+		if (m_displayListManager == null)
+			m_displayListManager = new DisplayListManager(this);
+
+		return m_displayListManager;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw3d.graphics3d.Graphics3DDraw#glBegin(int)
 	 */
 	public void glBegin(int mode) {
@@ -722,17 +781,12 @@
 		m_log2D = i_log2D;
 	}
 
-	/**
-	 * Sets the position.
-	 * 
-	 * @see org.eclipse.draw3d.graphics3d.Graphics3DDraw#setPosition(IPosition3D)
-	 */
-	public void setPosition(IPosition3D i_position) {
+	private void setMatrix(IMatrix4f i_matrix) {
 
 		FloatBuffer buffer = Draw3DCache.getFloatBuffer(16);
 		try {
 			buffer.rewind();
-			i_position.getTransformationMatrix().toBufferRowMajor(buffer);
+			i_matrix.toBufferRowMajor(buffer);
 			buffer.rewind();
 			org.lwjgl.opengl.GL11.glMultMatrix(buffer);
 		} finally {
@@ -741,14 +795,28 @@
 	}
 
 	/**
+	 * Sets the position.
+	 * 
+	 * @see org.eclipse.draw3d.graphics3d.Graphics3DDraw#setPosition(IPosition3D)
+	 */
+	public void setPosition(IPosition3D i_position) {
+
+		setMatrix(i_position.getTransformationMatrix());
+	}
+
+	/**
 	 * {@inheritDoc}
 	 * 
 	 * @see org.eclipse.draw3d.graphics3d.Graphics3D#setProperty(java.lang.String,
 	 *      java.lang.Object)
 	 */
 	public void setProperty(String key, String value) {
-		properties.setProperty(key, value);
 
+		if (value != null)
+			properties.setProperty(key, value);
+		else
+			properties.remove(key);
+
 	}
 
 	/**

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -13,8 +13,12 @@
 
 import java.nio.ByteBuffer;
 import java.nio.IntBuffer;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.logging.Logger;
 
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
+import org.eclipse.draw3d.graphics3d.Graphics3DDraw;
 import org.eclipse.draw3d.util.Draw3DCache;
 import org.eclipse.draw3d.util.converter.BufferInfo;
 import org.eclipse.draw3d.util.converter.ImageConverter;
@@ -52,8 +56,6 @@
 	private static final Logger log =
 		Logger.getLogger(LwjglFont.class.getName());
 
-	private int m_baseListId = -1;
-
 	private LwjglFontChar[] m_chars;
 
 	private final String m_description;
@@ -64,6 +66,8 @@
 
 	private FontMetrics m_fontMetrics;
 
+	private DisplayListManager m_displayListManager;
+
 	/**
 	 * The height of the character texture.
 	 */
@@ -89,14 +93,21 @@
 	 * @param i_endChar the last available character
 	 * @param i_antiAliased whether or not the font should be rendered with
 	 *            antialiasing
+	 * @param i_displayListManager the display list manager
 	 * @throws NullPointerException if the given font is &lt;code&gt;null&lt;/code&gt;
 	 */
 	public LwjglFont(Font i_font, char i_startChar, char i_endChar,
-			boolean i_antiAliased) {
+			boolean i_antiAliased, DisplayListManager i_displayListManager) {
 
 		if (i_font == null)
 			throw new NullPointerException(&quot;i_font must not be null&quot;);
 
+		if (i_displayListManager == null)
+			throw new NullPointerException(
+				&quot;i_displayListManager must not be null&quot;);
+
+		m_displayListManager = i_displayListManager;
+
 		m_startChar = i_startChar;
 		m_endChar = i_endChar;
 
@@ -200,18 +211,28 @@
 					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
 						GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
 					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
+						GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
 					GL11.glTexParameteri(GL11.GL_TEXTURE_2D,
-						GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
+						GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
 					GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0,
 						GL11.GL_LUMINANCE_ALPHA, m_width, m_height, 0,
 						GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE, buffer);
 
+					// GLU.gluBuild2DMipmaps(m_textureId, 2, m_width, m_height,
+					// GL11.GL_LUMINANCE_ALPHA, GL11.GL_UNSIGNED_BYTE, buffer);
+
 					// generate a display list for each available character
-					m_baseListId = GL11.glGenLists(numChars);
-					for (int i = 0; i &lt; m_chars.length; i++)
-						m_chars[i].buildList(m_baseListId + i, m_width,
-							m_height);
+					Map&lt;Object, Runnable&gt; requests =
+						new HashMap&lt;Object, Runnable&gt;(m_chars.length);
+					for (final LwjglFontChar c : m_chars) {
+						requests.put(c, new Runnable() {
+							public void run() {
+								c.render(m_width, m_height);
+							}
+						});
+					}
+
+					m_displayListManager.createDisplayLists(requests);
 				} finally {
 					Draw3DCache.returnIntBuffer(intBuf);
 				}
@@ -271,11 +292,6 @@
 			}
 		}
 
-		if (m_baseListId != -1) {
-			GL11.glDeleteLists(m_baseListId, m_chars.length);
-			m_baseListId = -1;
-		}
-
 		m_chars = null;
 		m_disposed = true;
 	}
@@ -360,63 +376,55 @@
 		if (i_string == null)
 			throw new NullPointerException(&quot;i_string must not be null&quot;);
 
-		IntBuffer intBuf = Draw3DCache.getIntBuffer(16);
+		GL11.glPushAttrib(GL11.GL_TEXTURE_BIT | GL11.GL_COLOR_BUFFER_BIT);
 		try {
-			intBuf.rewind();
-			GL11.glGetInteger(GL11.GL_TEXTURE_BINDING_2D, intBuf);
-			int currentTexture = intBuf.get(0);
+			GL11.glBindTexture(GL11.GL_TEXTURE_2D, m_textureId);
+			GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE,
+				GL11.GL_BLEND);
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
 
-			GL11.glPushAttrib(GL11.GL_TEXTURE_BIT);
+			GL11.glEnable(GL11.GL_BLEND);
+			GL11.glBlendFunc(Graphics3DDraw.GL_SRC_ALPHA,
+				Graphics3DDraw.GL_ONE_MINUS_SRC_ALPHA);
+
+			GL11.glMatrixMode(GL11.GL_MODELVIEW);
+			GL11.glPushMatrix();
 			try {
-				GL11.glBindTexture(GL11.GL_TEXTURE_2D, m_textureId);
-				GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE,
-					GL11.GL_BLEND);
-				GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+				GL11.glTranslatef(i_x, i_y, 0);
 
-				GL11.glMatrixMode(GL11.GL_MODELVIEW);
-				GL11.glPushMatrix();
-				try {
-					GL11.glTranslatef(i_x, i_y, 0);
+				int height = m_fontMetrics.getHeight();
+				int line = 0;
+				for (int i = 0; i &lt; i_string.length(); i++) {
+					char c = i_string.charAt(i);
 
-					int height = m_fontMetrics.getHeight();
-					int line = 0;
-					for (int i = 0; i &lt; i_string.length(); i++) {
-						char c = i_string.charAt(i);
+					switch (c) {
+					case '\t':
+						if (i_expand)
+							GL11.glTranslatef(m_tabWidth, 0, 0);
+						break;
 
-						switch (c) {
-						case '\t':
-							if (i_expand)
-								GL11.glTranslatef(m_tabWidth, 0, 0);
-							break;
-
-						case '\n':
-							if (i_expand) {
-								GL11.glPopMatrix();
-								GL11.glPushMatrix();
-								GL11.glTranslatef(i_x, i_y + (++line * height),
-									0);
-							}
-							break;
-						default:
-							int index = c - m_startChar;
-							if (index &gt;= 0 &amp;&amp; index &lt; m_chars.length) {
-								LwjglFontChar fontChar = m_chars[index];
-								GL11.glCallList(fontChar.getListId());
-								GL11.glTranslatef(fontChar.getWidth(), 0, 0);
-							}
-							break;
+					case '\n':
+						if (i_expand) {
+							GL11.glPopMatrix();
+							GL11.glPushMatrix();
+							GL11.glTranslatef(i_x, i_y + (++line * height), 0);
 						}
+						break;
+					default:
+						int index = c - m_startChar;
+						if (index &gt;= 0 &amp;&amp; index &lt; m_chars.length) {
+							LwjglFontChar fontChar = m_chars[index];
+							m_displayListManager.executeDisplayList(fontChar);
+							GL11.glTranslatef(fontChar.getWidth(), 0, 0);
+						}
+						break;
 					}
-				} finally {
-					GL11.glPopMatrix();
 				}
 			} finally {
-				GL11.glPopAttrib();
-				if (currentTexture != m_textureId)
-					GL11.glBindTexture(GL11.GL_TEXTURE_2D, currentTexture);
+				GL11.glPopMatrix();
 			}
 		} finally {
-			Draw3DCache.returnIntBuffer(intBuf);
+			GL11.glPopAttrib();
 		}
 	}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontChar.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -28,11 +28,6 @@
 	private final int m_height;
 
 	/**
-	 * The id of the display list that renders this character.
-	 */
-	private int m_listId = -1;
-
-	/**
 	 * The S texture coordinate of the upper left corner of this character.
 	 */
 	private float m_s1;
@@ -70,15 +65,13 @@
 	}
 
 	/**
-	 * Builds a display list for this character.
+	 * Renders this character.
 	 * 
-	 * @param i_listId the id of the display list to build
 	 * @param i_width the width of the character texture
 	 * @param i_height the height of the character texture
 	 */
-	public void buildList(int i_listId, int i_width, int i_height) {
+	public void render(int i_width, int i_height) {
 
-		GL11.glNewList(i_listId, GL11.GL_COMPILE);
 		GL11.glBegin(GL11.GL_QUADS);
 
 		GL11.glTexCoord2f(m_s1, m_t1);
@@ -92,21 +85,9 @@
 
 		GL11.glEnd();
 		GL11.glEndList();
-
-		m_listId = i_listId;
 	}
 
 	/**
-	 * Returns the id of the display list that renders this character.
-	 * 
-	 * @return the list id
-	 */
-	public int getListId() {
-
-		return m_listId;
-	}
-
-	/**
 	 * Returns the width of this character.
 	 * 
 	 * @return the width of this character

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -15,6 +15,7 @@
 import java.util.Map;
 import java.util.logging.Logger;
 
+import org.eclipse.draw3d.graphics3d.DisplayListManager;
 import org.eclipse.draw3d.graphics3d.lwjgl.texture.LwjglTextureManager;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.graphics.FontData;
@@ -28,14 +29,22 @@
  */
 public class LwjglFontManager {
 
+	private DisplayListManager m_displayListManager;
+
 	/**
 	 * The font manager is created by the texture manager (
 	 * {@link LwjglTextureManager}), this class should not be created by other
 	 * classes.
+	 * 
+	 * @param i_displayListManager the display list manager
 	 */
-	public LwjglFontManager() {
+	public LwjglFontManager(DisplayListManager i_displayListManager) {
 
-		// nothing to initliaze
+		if (i_displayListManager == null)
+			throw new NullPointerException(
+				&quot;i_displayListManager must not be null&quot;);
+
+		m_displayListManager = i_displayListManager;
 	}
 
 	/**
@@ -155,7 +164,8 @@
 		LwjglFont glFont = m_fonts.get(key);
 		if (glFont == null) {
 			glFont =
-				new LwjglFont(i_font, i_startChar, i_endChar, i_antiAliased);
+				new LwjglFont(i_font, i_startChar, i_endChar, i_antiAliased,
+					m_displayListManager);
 			m_fonts.put(key, glFont);
 		}
 

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -16,21 +16,18 @@
 import java.nio.FloatBuffer;
 import java.nio.IntBuffer;
 import java.util.Arrays;
-import java.util.EmptyStackException;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.logging.Logger;
 
 import org.eclipse.draw2d.Graphics;
 import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.PrecisionPoint;
 import org.eclipse.draw2d.geometry.PrecisionRectangle;
 import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.draw3d.geometry.IMatrix4f;
 import org.eclipse.draw3d.geometry.Math3D;
 import org.eclipse.draw3d.geometry.Matrix4f;
-import org.eclipse.draw3d.geometry.Matrix4fImpl;
-import org.eclipse.draw3d.geometry.Vector3f;
+import org.eclipse.draw3d.graphics.GraphicsState;
+import org.eclipse.draw3d.graphics.StatefulGraphics;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFont;
 import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
 import org.eclipse.draw3d.util.ColorConverter;
@@ -42,9 +39,7 @@
 import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Device;
 import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontMetrics;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.LineAttributes;
 import org.eclipse.swt.graphics.Pattern;
 import org.eclipse.swt.graphics.TextLayout;
 import org.eclipse.swt.widgets.Display;
@@ -121,727 +116,29 @@
  * @todo implement the unsupported methods
  */
 @SuppressWarnings(&quot;unused&quot;)
-public class LwjglGraphics extends Graphics {
+public class LwjglGraphics extends StatefulGraphics {
 
-	/**
-	 * A graphics state that forwards requests for not set values to its parent
-	 * state.
-	 * 
-	 * @author Kristian Duske
-	 * @version $Revision$
-	 * @since 08.03.2008
-	 */
-	private class GraphicsState {
+	private enum LastColor {
 
-		private Boolean m_advanced;
-
-		private Integer m_alpha;
-
-		private Integer m_antialias;
-
-		private Color m_backgroundColor;
-
-		private Pattern m_backgroundPattern;
-
-		private PrecisionRectangle m_clip;
-
-		private Integer m_fillRule;
-
-		private Font m_font;
-
-		private Color m_foregroundColor;
-
-		private Pattern m_foregroundPattern;
-
-		private Integer m_interpolation;
-
-		private Integer m_lineCap;
-
-		private int[] m_lineDash;
-
-		private int m_lineDashLength;
-
-		private Integer m_lineJoin;
-
-		private Float m_lineMiterLimit;
-
-		private Integer m_lineStyle;
-
-		private Float m_lineWidth;
-
-		private final GraphicsState m_parentState;
-
-		private Integer m_textAntialias;
-
-		private Matrix4fImpl m_transformation;
-
-		private Boolean m_xorMode;
-
 		/**
-		 * Creates a new chained graphics state with the given parent.
-		 * 
-		 * @param i_parentState the parent of this state
+		 * The last OpenGL color set by this graphics was the background color.
 		 */
-		public GraphicsState(GraphicsState i_parentState) {
+		BACKGROUND,
 
-			m_parentState = i_parentState;
-		}
-
 		/**
-		 * Intersects the current clipping rectangle with the given rectangle.
-		 * 
-		 * @param i_clip the rectangle to intersect with
+		 * The last OpenGL color set by this graphics was the foreground color.
 		 */
-		public void clipRect(Rectangle i_clip) {
+		FOREGROUND,
 
-			if (i_clip == null)
-				return;
-
-			PrecisionRectangle currentClip = getClip();
-			if (currentClip != null &amp;&amp; !currentClip.equals(i_clip)) {
-				if (m_clip == null)
-					m_clip = new PrecisionRectangle(currentClip);
-
-				// clipping in SWTGraphics is working slightly differently as
-				// Rectangle clipping, so we emulate the SWTClipping here:
-				double l = Math.max(m_clip.preciseX(), i_clip.preciseX());
-				double r =
-					Math.min(m_clip.preciseX() + m_clip.preciseWidth(),
-						i_clip.preciseX() + i_clip.preciseWidth());
-
-				double t = Math.max(m_clip.preciseY(), i_clip.preciseY());
-				double b =
-					Math.min(m_clip.preciseY() + m_clip.preciseHeight(),
-						i_clip.preciseY() + i_clip.preciseHeight());
-
-				if (r &lt; l || b &lt; t) {
-					// width and height of -1 to avoid ceiling function from
-					// re-adding a pixel.
-					r = l - 1;
-					b = t - 1;
-				}
-
-				m_clip.setX(l);
-				m_clip.setY(t);
-				m_clip.setWidth(r - l);
-				m_clip.setHeight(b - t);
-
-				// m_clip.intersect(i_clip);
-			} else
-				m_clip = new PrecisionRectangle(i_clip);
-		}
-
 		/**
-		 * Indicates whether the graphics system is in advanced graphics mode.
-		 * 
-		 * @return &lt;code&gt;true&lt;/code&gt; if the graphics subsystem is in advanced
-		 *         graphics mode and &lt;code&gt;false&lt;/code&gt; otherwise
+		 * The last OpenGL color set by this graphics is unknown.
 		 */
-		public boolean getAdvanced() {
-
-			if (m_advanced != null)
-				return m_advanced;
-
-			return m_parentState.getAdvanced();
-		}
-
-		/**
-		 * Returns the alpha value of this graphics state.
-		 * 
-		 * @return the alpha value of this graphics state
-		 */
-		public int getAlpha() {
-
-			if (m_alpha != null)
-				return m_alpha;
-
-			return m_parentState.getAlpha();
-		}
-
-		/**
-		 * Returns the antialias value for this graphics state.
-		 * 
-		 * @return the antialias value for this graphics state.
-		 */
-		public int getAntialias() {
-
-			if (m_antialias != null)
-				return m_antialias;
-
-			return m_parentState.getAntialias();
-		}
-
-		/**
-		 * Returns the background color of this graphics state.
-		 * 
-		 * @return the background color
-		 */
-		public Color getBackgroundColor() {
-
-			if (m_backgroundColor != null)
-				return m_backgroundColor;
-
-			return m_parentState.getBackgroundColor();
-		}
-
-		/**
-		 * Returns the background pattern of this graphics state.
-		 * 
-		 * @return the background pattern
-		 */
-		public Pattern getBackgroundPattern() {
-
-			if (m_backgroundPattern != null)
-				return m_backgroundPattern;
-
-			if (m_parentState != null)
-				return m_parentState.getBackgroundPattern();
-
-			return null;
-		}
-
-		/**
-		 * Returns the clip rectangle of this state.
-		 * 
-		 * @return the clip rectangle
-		 */
-		public PrecisionRectangle getClip() {
-
-			if (m_clip != null)
-				return m_clip;
-
-			return m_parentState.getClip();
-		}
-
-		/**
-		 * Returns the fill rule of this graphics state.
-		 * 
-		 * @return the fill rule of this graphics state
-		 */
-		public int getFillRule() {
-
-			if (m_fillRule != null)
-				return m_fillRule;
-
-			return m_parentState.getFillRule();
-		}
-
-		/**
-		 * Returns the font of this graphics state.
-		 * 
-		 * @return the font
-		 */
-		public Font getFont() {
-
-			if (m_font != null)
-				return m_font;
-
-			return m_parentState.getFont();
-		}
-
-		/**
-		 * Returns the foreground color of this graphics state.
-		 * 
-		 * @return the foreground color
-		 */
-		public Color getForegroundColor() {
-
-			if (m_foregroundColor != null)
-				return m_foregroundColor;
-
-			return m_parentState.getForegroundColor();
-		}
-
-		public Pattern getForegroundPattern() {
-
-			if (m_foregroundPattern != null)
-				return m_foregroundPattern;
-
-			if (m_parentState != null)
-				return m_parentState.getForegroundPattern();
-
-			return null;
-		}
-
-		/**
-		 * Returns the interpolation setting for this graphics state.
-		 * 
-		 * @return the interpolation setting
-		 */
-		public int getInterpolation() {
-
-			if (m_interpolation != null)
-				return m_interpolation;
-
-			return m_parentState.getInterpolation();
-		}
-
-		/**
-		 * Returns the line cap setting for this graphics state
-		 * 
-		 * @return the line cap setting
-		 */
-		public int getLineCap() {
-
-			if (m_lineCap != null)
-				return m_lineCap;
-
-			return m_parentState.getLineCap();
-		}
-
-		/**
-		 * Returns the custom line dash pattern.
-		 * 
-		 * @return the custom line dash pattern
-		 */
-		public int[] getLineDash() {
-
-			if (m_lineDash != null)
-				return m_lineDash;
-
-			if (m_parentState != null)
-				return m_parentState.getLineDash();
-
-			return null;
-		}
-
-		/**
-		 * Returns the total length of the line dash pattern. The total length
-		 * of a line dash pattern is the sum of all the elements of the pattern
-		 * array.
-		 * 
-		 * @return the total length of the line dash pattern
-		 */
-		public int getLineDashLength() {
-
-			if (m_lineDash != null)
-				return m_lineDashLength;
-
-			return m_parentState.getLineDashLength();
-		}
-
-		public int getLineJoin() {
-
-			if (m_lineJoin != null)
-				return m_lineJoin;
-
-			return m_parentState.getLineJoin();
-		}
-
-		/**
-		 * Returns the line miter limit of this graphics state.
-		 * 
-		 * @return the line miter limit of this graphics state
-		 */
-		public float getLineMiterLimit() {
-
-			if (m_lineMiterLimit != null)
-				return m_lineMiterLimit;
-
-			return m_parentState.getLineMiterLimit();
-		}
-
-		/**
-		 * Returns the line style of this graphics state.
-		 * 
-		 * @return the line style
-		 */
-		public int getLineStyle() {
-
-			if (m_lineStyle != null)
-				return m_lineStyle;
-
-			return m_parentState.getLineStyle();
-		}
-
-		/**
-		 * Returns the line width of this graphics state.
-		 * 
-		 * @return the line width
-		 */
-		public float getLineWidth() {
-
-			if (m_lineWidth != null)
-				return m_lineWidth;
-
-			return m_parentState.getLineWidth();
-		}
-
-		/**
-		 * Returns the parent graphics state.
-		 * 
-		 * @return the parent graphics state
-		 */
-		public GraphicsState getParent() {
-
-			return m_parentState;
-		}
-
-		/**
-		 * Returns the text antialias value of this graphics state.
-		 * 
-		 * @return the text antialias value
-		 */
-		public int getTextAntialias() {
-
-			if (m_textAntialias != null)
-				return m_textAntialias;
-
-			return m_parentState.getTextAntialias();
-		}
-
-		/**
-		 * Returns the transformation matrix of this graphics state.
-		 * 
-		 * @return the transformation matrix
-		 */
-		public Matrix4f getTransformation() {
-
-			return m_transformation;
-		}
-
-		/**
-		 * Indicates whether XOR mode drawing is enabled.
-		 * 
-		 * @return &lt;code&gt;true&lt;/code&gt; if XOR drawing mode is enabled or
-		 *         &lt;code&gt;false&lt;/code&gt; otherwise
-		 */
-		public boolean getXORMode() {
-
-			if (m_xorMode != null)
-				return m_xorMode;
-
-			return m_parentState.getXORMode();
-		}
-
-		/**
-		 * Rotates the coordinates system by the given angle counterclockwise.
-		 * 
-		 * @param i_degrees the rotation angle in degrees
-		 */
-		public void rotate(float i_degrees) {
-
-			if (m_transformation == null)
-				m_transformation = new Matrix4fImpl();
-
-			Matrix4f rot = Draw3DCache.getMatrix4f();
-			try {
-				// don't use Math3d.rotate() here because when rotating about
-				// the z axis, we can use a shorthand:
-				double radians = Math.toRadians(i_degrees);
-				float sin = (float) Math.sin(radians);
-				float cos = (float) Math.cos(radians);
-
-				rot.setIdentity();
-				rot.set(0, 0, cos);
-				rot.set(1, 0, sin);
-				rot.set(1, 1, cos);
-				rot.set(0, 1, -sin);
-
-				Math3D.mul(rot, m_transformation, m_transformation);
-			} finally {
-				Draw3DCache.returnMatrix4f(rot);
-			}
-		}
-
-		/**
-		 * Scales the current transformation and corrects the clipping rectangle
-		 * by the given factors.
-		 * 
-		 * @param i_horizontal the horizontal scaling factor
-		 * @param i_vertical the vertical scaling factor
-		 */
-		public void scale(float i_horizontal, float i_vertical) {
-
-			if (m_transformation == null)
-				m_transformation = new Matrix4fImpl();
-
-			Vector3f scale = Draw3DCache.getVector3f();
-			try {
-				scale.set(i_horizontal, i_vertical, 0);
-				Math3D.scale(scale, m_transformation, m_transformation);
-			} finally {
-				Draw3DCache.returnVector3f(scale);
-			}
-		}
-
-		/**
-		 * Specifies whether the graphics system is in advanced graphics mode.
-		 * 
-		 * @param i_advanced &lt;code&gt;true&lt;/code&gt; if the graphics system is in
-		 *            advanced graphics mode and &lt;code&gt;false&lt;/code&gt; otherwise
-		 */
-		public void setAdvanced(boolean i_advanced) {
-
-			m_advanced = i_advanced;
-		}
-
-		/**
-		 * Sets the alpha value of this graphics state.
-		 * 
-		 * @param i_alpha the alpha value
-		 */
-		public void setAlpha(int i_alpha) {
-
-			m_alpha = i_alpha;
-		}
-
-		/**
-		 * Sets the antialias value for this graphics state.
-		 * 
-		 * @param i_antialias the antialias value
-		 */
-		public void setAntialias(int i_antialias) {
-
-			m_antialias = i_antialias;
-		}
-
-		/**
-		 * Sets the background color of this graphics state.
-		 * 
-		 * @param i_backgroundColor the new background color
-		 */
-		public void setBackgroundColor(Color i_backgroundColor) {
-
-			m_backgroundColor = i_backgroundColor;
-		}
-
-		/**
-		 * Sets the background pattern of this graphics state.
-		 * 
-		 * @param i_backgroundPattern the background pattern
-		 */
-		public void setBackgroundPattern(Pattern i_backgroundPattern) {
-
-			m_backgroundPattern = i_backgroundPattern;
-		}
-
-		/**
-		 * Sets the clip rectangleof this state.
-		 * 
-		 * @param i_clip the clip rectangle
-		 */
-		public void setClip(Rectangle i_clip) {
-
-			if (i_clip == null) {
-				m_clip = null;
-				return;
-			}
-
-			if (m_clip == null) {
-				m_clip = new PrecisionRectangle(i_clip);
-				return;
-			}
-
-			m_clip.setX(i_clip.preciseX());
-			m_clip.setY(i_clip.preciseY());
-			m_clip.setWidth(i_clip.preciseWidth());
-			m_clip.setHeight(i_clip.preciseHeight());
-		}
-
-		/**
-		 * Sets the fill rule of this graphics state.
-		 * 
-		 * @param i_fillRule the fill rule of this graphics state
-		 */
-		public void setFillRule(int i_fillRule) {
-
-			m_fillRule = i_fillRule;
-		}
-
-		/**
-		 * Sets the font of this graphics state.
-		 * 
-		 * @param i_font the font
-		 */
-		public void setFont(Font i_font) {
-
-			m_font = i_font;
-		}
-
-		/**
-		 * Sets the foreground color of this graphics state.
-		 * 
-		 * @param i_foregroundColor the foreground color
-		 */
-		public void setForegroundColor(Color i_foregroundColor) {
-
-			m_foregroundColor = i_foregroundColor;
-		}
-
-		/**
-		 * Sets the foreground pattern of this graphics state.
-		 * 
-		 * @param i_foregroundPattern the foreground pattern
-		 */
-		public void setForegroundPattern(Pattern i_foregroundPattern) {
-
-			m_foregroundPattern = i_foregroundPattern;
-		}
-
-		/**
-		 * Sets the interpolation setting for this graphics state.
-		 * 
-		 * @param i_interpolation the interpolation setting
-		 */
-		public void setInterpolation(int i_interpolation) {
-
-			m_interpolation = i_interpolation;
-		}
-
-		/**
-		 * Sets the line cap value of this graphics state.
-		 * 
-		 * @param i_lineCap the line cap value
-		 */
-		public void setLineCap(int i_lineCap) {
-
-			m_lineCap = i_lineCap;
-		}
-
-		/**
-		 * Sets the custom line dash pattern.
-		 * 
-		 * @param i_lineDash the custom line dash pattern
-		 */
-		public void setLineDash(int[] i_lineDash) {
-
-			m_lineDash = i_lineDash;
-			m_lineDashLength = 0;
-
-			if (m_lineDash != null)
-				for (int i = 0; i &lt; m_lineDash.length; i++)
-					m_lineDashLength += m_lineDash[i];
-		}
-
-		/**
-		 * Sets the line join value of this graphics state.
-		 * 
-		 * @param i_lineJoin the line join value
-		 */
-		public void setLineJoin(int i_lineJoin) {
-
-			m_lineJoin = i_lineJoin;
-		}
-
-		/**
-		 * Sets the line miter limit of this graphics state.
-		 * 
-		 * @param i_lineMiterLimit the new line miter limit
-		 */
-		public void setLineMiterLimit(float i_lineMiterLimit) {
-
-			m_lineMiterLimit = i_lineMiterLimit;
-		}
-
-		/**
-		 * Sets the line style of this graphics state.
-		 * 
-		 * @param i_lineStyle the line style
-		 */
-		public void setLineStyle(int i_lineStyle) {
-
-			m_lineStyle = i_lineStyle;
-		}
-
-		/**
-		 * Sets the line width of this graphics state.
-		 * 
-		 * @param i_lineWidth the line width
-		 */
-		public void setLineWidth(float i_lineWidth) {
-
-			m_lineWidth = i_lineWidth;
-		}
-
-		/**
-		 * Sets the text antialias value of this graphics state.
-		 * 
-		 * @param i_textAntialias the text antialias value
-		 */
-		public void setTextAntialias(int i_textAntialias) {
-
-			m_textAntialias = i_textAntialias;
-		}
-
-		/**
-		 * Sets the current transformation.
-		 * 
-		 * @param i_transformation the current transformation
-		 */
-		public void setTransformation(IMatrix4f i_transformation) {
-
-			if (m_transformation == null)
-				m_transformation = new Matrix4fImpl(i_transformation);
-			else
-				m_transformation.set(i_transformation);
-		}
-
-		/**
-		 * Specifies whether XOR mode drawing is enabled.
-		 * 
-		 * @param i_xorMode &lt;code&gt;true&lt;/code&gt; if XOR mode should be enabled or
-		 *            &lt;code&gt;false&lt;/code&gt; otherwise
-		 */
-		public void setXORMode(boolean i_xorMode) {
-
-			m_xorMode = i_xorMode;
-		}
-
-		/**
-		 * Shears the current transformation and corrects the clipping rectangle
-		 * by the given amounts.
-		 * 
-		 * @param i_horz the horizontal shearing amount
-		 * @param i_vert the vertical shearing amount
-		 */
-		public void shear(float i_horz, float i_vert) {
-
-			if (m_transformation == null)
-				m_transformation = new Matrix4fImpl();
-
-			Matrix4f shear = Draw3DCache.getMatrix4f();
-			try {
-				shear.setIdentity();
-				shear.set(1, 0, i_horz);
-				shear.set(0, 1, i_vert);
-
-				Math3D.mul(shear, m_transformation, m_transformation);
-			} finally {
-				Draw3DCache.returnMatrix4f(shear);
-			}
-		}
-
-		/**
-		 * Translates the current transformation and corrects the clipping
-		 * rectangle by the given amounts.
-		 * 
-		 * @param i_dX the X translation
-		 * @param i_dY the Y translation
-		 */
-		public void translate(float i_dX, float i_dY) {
-
-			if (m_transformation == null)
-				m_transformation = new Matrix4fImpl();
-
-			Vector3f trans = Draw3DCache.getVector3f();
-			try {
-				trans.set(i_dX, i_dY, 0);
-				Math3D.translate(m_transformation, trans, m_transformation);
-
-				if (m_clip == null)
-					m_clip = new PrecisionRectangle(m_parentState.getClip());
-
-				m_clip.translate(new PrecisionPoint(-i_dX, -i_dY));
-			} finally {
-				Draw3DCache.returnVector3f(trans);
-			}
-		}
+		UNKNOWN
 	}
 
 	private enum RasterOffset {
 
-		POLYGON, LINE, POINT;
+		LINE, POINT, POLYGON;
 
 		public float getOffset() {
 
@@ -857,24 +154,6 @@
 		}
 	}
 
-	private enum LastColor {
-
-		/**
-		 * The last OpenGL color set by this graphics was the background color.
-		 */
-		BACKGROUND,
-
-		/**
-		 * The last OpenGL color set by this graphics was the foreground color.
-		 */
-		FOREGROUND,
-
-		/**
-		 * The last OpenGL color set by this graphics is unknown.
-		 */
-		UNKNOWN
-	}
-
 	private static final double ARC_LENGTH_FACTOR = 4 * Math.PI * Math.PI;
 
 	/**
@@ -903,41 +182,24 @@
 
 	private LwjglLinePattern m_currentLinePattern;
 
-	private GraphicsState m_defaultState;
-
 	private boolean m_disposed = false;
 
-	private boolean m_disposeFonts = false;
-
 	private LwjglFontManager m_fontManager;
 
 	private int m_height;
 
 	private LastColor m_lastColor = LastColor.UNKNOWN;
 
+	private RasterOffset m_lastOffset;
+
 	private Map&lt;Object, LwjglLinePattern&gt; m_linePatterns =
 		new HashMap&lt;Object, LwjglLinePattern&gt;();
 
-	private GraphicsState m_state;
+	private Boolean m_overrideTextAntialias;
 
 	private int m_width;
 
-	private Boolean m_overrideTextAntialias;
-
 	/**
-	 * Specifies whether the font antialiasing setting should be overridden.
-	 * 
-	 * @param i_overrideTextAntialias if &lt;code&gt;true&lt;/code&gt;, font antialiasing is
-	 *            always enabled, if &lt;code&gt;false&lt;/code&gt;, it's always disabled,
-	 *            if &lt;code&gt;null&lt;/code&gt;, the value set by
-	 *            {@link #setTextAntialias(int)} is used.
-	 */
-	public void setOverrideTextAntialias(Boolean i_overrideTextAntialias) {
-
-		m_overrideTextAntialias = i_overrideTextAntialias;
-	}
-
-	/**
 	 * Creates a new OpenGL graphics object with the given width and height;
 	 * 
 	 * @param i_width the width of this graphics object
@@ -947,25 +209,22 @@
 	public LwjglGraphics(int i_width, int i_height,
 			LwjglFontManager i_fontManager) {
 
+		super();
+
+		if (i_fontManager == null)
+			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
+
 		m_width = i_width;
 		m_height = i_height;
 
-		initDefaultGraphicsState();
-
 		glSetClip();
 		glSetLineWidth();
 		glSetLineStyle();
 		glSetXORMode();
 
-		setFontManager(i_fontManager);
+		m_fontManager = i_fontManager;
 	}
 
-	private void checkDisposed() {
-
-		if (m_disposed)
-			throw new IllegalStateException(&quot;graphics is disposed&quot;);
-	}
-
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -976,7 +235,7 @@
 
 		checkDisposed();
 
-		m_state.clipRect(i_clipRect);
+		super.clipRect(i_clipRect);
 		glSetClip();
 	}
 
@@ -1004,9 +263,6 @@
 
 		checkDisposed();
 
-		if (m_disposeFonts)
-			m_fontManager.dispose();
-
 		for (LwjglLinePattern linePattern : m_linePatterns.values())
 			linePattern.dispose();
 
@@ -1030,7 +286,7 @@
 		glSetForegroundColor();
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					GL11.glBegin(GL11.GL_LINE_STRIP);
@@ -1177,7 +433,7 @@
 		glSetForegroundColor();
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					double s =
@@ -1228,7 +484,7 @@
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
 			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					GL11.glBegin(GL11.GL_LINE_LOOP);
@@ -1263,7 +519,7 @@
 		glSetForegroundColor();
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					GL11.glBegin(GL11.GL_LINE_STRIP);
@@ -1296,7 +552,7 @@
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
 			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					GL11.glBegin(GL11.GL_LINE_LOOP);
@@ -1340,7 +596,7 @@
 		glSetRasterOffset(RasterOffset.LINE);
 		try {
 			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+			if (getState().getLineStyle() == SWT.LINE_CUSTOM) {
 				m_currentLinePattern.activate();
 				try {
 					GL11.glBegin(GL11.GL_LINE_LOOP);
@@ -1424,11 +680,22 @@
 	public void enableClipping() {
 
 		if (!m_clippingEnabled) {
-			glSetClip();
 			m_clippingEnabled = true;
+			glSetClip();
 		}
 	}
 
+	private boolean equals(Object i_o1, Object i_o2) {
+
+		if (i_o1 != null)
+			return i_o1.equals(i_o2);
+
+		if (i_o2 != null)
+			return i_o2.equals(i_o1);
+
+		return true;
+	}
+
 	/**
 	 * {@inheritDoc}
 	 * 
@@ -1620,270 +887,15 @@
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#getAdvanced()
+	 * @see org.eclipse.draw2d.Graphics#getAbsoluteScale()
 	 */
 	@Override
-	public boolean getAdvanced() {
+	public double getAbsoluteScale() {
 
-		checkDisposed();
-
-		return m_state.getAdvanced();
+		// just return 1.0
+		return super.getAbsoluteScale();
 	}
 
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getAlpha()
-	 */
-	@Override
-	public int getAlpha() {
-
-		checkDisposed();
-
-		return m_state.getAlpha();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getAntialias()
-	 */
-	@Override
-	public int getAntialias() {
-
-		checkDisposed();
-
-		return m_state.getAntialias();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getBackgroundColor()
-	 */
-	@Override
-	public Color getBackgroundColor() {
-
-		checkDisposed();
-
-		return m_state.getBackgroundColor();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getClip(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public Rectangle getClip(Rectangle o_rect) {
-
-		checkDisposed();
-
-		Rectangle clip = m_state.getClip();
-		o_rect.setBounds(clip);
-
-		return o_rect;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFillRule()
-	 */
-	@Override
-	public int getFillRule() {
-
-		checkDisposed();
-
-		return m_state.getFillRule();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFont()
-	 */
-	@Override
-	public Font getFont() {
-
-		checkDisposed();
-
-		return m_state.getFont();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFontMetrics()
-	 */
-	@Override
-	public FontMetrics getFontMetrics() {
-
-		checkDisposed();
-
-		LwjglFont glFont = glGetFont();
-		return glFont.getFontMetrics();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getForegroundColor()
-	 */
-	@Override
-	public Color getForegroundColor() {
-
-		checkDisposed();
-
-		return m_state.getForegroundColor();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getInterpolation()
-	 */
-	@Override
-	public int getInterpolation() {
-
-		checkDisposed();
-
-		return m_state.getInterpolation();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineAttributes()
-	 */
-	@Override
-	public LineAttributes getLineAttributes() {
-
-		checkDisposed();
-
-		LineAttributes attrs = new LineAttributes(m_state.getLineWidth());
-		attrs.cap = m_state.getLineCap();
-		attrs.dashOffset = 0;
-		attrs.join = m_state.getLineJoin();
-		attrs.miterLimit = m_state.getLineMiterLimit();
-		attrs.style = m_state.getLineStyle();
-
-		int[] lineDash = m_state.getLineDash();
-		if (lineDash == null)
-			attrs.dash = null;
-		else {
-			attrs.dash = new float[lineDash.length];
-			for (int i = 0; i &lt; lineDash.length; i++)
-				attrs.dash[i] = lineDash[i];
-		}
-
-		return attrs;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineCap()
-	 */
-	@Override
-	public int getLineCap() {
-
-		checkDisposed();
-
-		return m_state.getLineCap();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineJoin()
-	 */
-	@Override
-	public int getLineJoin() {
-
-		checkDisposed();
-
-		return m_state.getLineJoin();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineMiterLimit()
-	 */
-	@Override
-	public float getLineMiterLimit() {
-
-		checkDisposed();
-
-		return m_state.getLineMiterLimit();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineStyle()
-	 */
-	@Override
-	public int getLineStyle() {
-
-		checkDisposed();
-
-		return m_state.getLineStyle();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineWidth()
-	 */
-	@Override
-	public int getLineWidth() {
-
-		checkDisposed();
-
-		return Math.round(m_state.getLineWidth());
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineWidthFloat()
-	 */
-	@Override
-	public float getLineWidthFloat() {
-
-		checkDisposed();
-
-		return m_state.getLineWidth();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getTextAntialias()
-	 */
-	@Override
-	public int getTextAntialias() {
-
-		checkDisposed();
-
-		return m_state.getTextAntialias();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getXORMode()
-	 */
-	@Override
-	public boolean getXORMode() {
-
-		checkDisposed();
-
-		return m_state.getXORMode();
-	}
-
 	private void glDrawArc(int i_x, int i_y, int i_w, int i_h, int i_offset,
 		int i_length) {
 
@@ -1983,31 +995,6 @@
 		glDrawTexturedArc(i_x, i_y, i_w, i_h, i_offset, i_length, 0);
 	}
 
-	private RasterOffset m_lastOffset;
-
-	private void glSetRasterOffset(RasterOffset i_offset) {
-
-		if (m_lastOffset != null)
-			throw new IllegalStateException(&quot;raster offset was not reset&quot;);
-
-		if (i_offset.getOffset() != 0)
-			GL11.glTranslatef(i_offset.getOffset(), i_offset.getOffset(), 0);
-
-		m_lastOffset = i_offset;
-	}
-
-	private void glResetRasterOffset() {
-
-		if (m_lastOffset == null)
-			throw new IllegalStateException(&quot;raster offset was reset&quot;);
-
-		if (m_lastOffset.getOffset() != 0)
-			GL11.glTranslatef(-m_lastOffset.getOffset(),
-				-m_lastOffset.getOffset(), 0);
-
-		m_lastOffset = null;
-	}
-
 	private double glDrawTexturedArc(int i_x, int i_y, int i_w, int i_h,
 		int i_offset, int i_length, double i_s) {
 
@@ -2159,11 +1146,6 @@
 
 	private LwjglFont glGetFont() {
 
-		if (m_fontManager == null) {
-			m_fontManager = new LwjglFontManager();
-			m_disposeFonts = true;
-		}
-
 		int antialias = getAntialias();
 		if (m_overrideTextAntialias != null) {
 			if (m_overrideTextAntialias)
@@ -2172,11 +1154,23 @@
 				antialias = SWT.OFF;
 		}
 
-		Font font = m_state.getFont();
+		Font font = getState().getFont();
 		return m_fontManager.getFont(font, (char) 32, (char) 127,
 			antialias == SWT.ON);
 	}
 
+	private void glResetRasterOffset() {
+
+		if (m_lastOffset == null)
+			throw new IllegalStateException(&quot;raster offset was reset&quot;);
+
+		if (m_lastOffset.getOffset() != 0)
+			GL11.glTranslatef(-m_lastOffset.getOffset(),
+				-m_lastOffset.getOffset(), 0);
+
+		m_lastOffset = null;
+	}
+
 	private void glRestoreState(GraphicsState i_previous) {
 
 		Matrix4f transformation = i_previous.getTransformation();
@@ -2198,26 +1192,26 @@
 		}
 
 		if (i_previous.getClip() == null) {
-			if (m_state.getClip() != null)
+			if (getState().getClip() != null)
 				glSetClip();
 		} else {
-			if (!i_previous.getClip().equals(m_state.getClip()))
+			if (!i_previous.getClip().equals(getState().getClip()))
 				glSetClip();
 		}
 
-		if (i_previous.getLineWidth() != m_state.getLineWidth())
+		if (i_previous.getLineWidth() != getState().getLineWidth())
 			glSetLineWidth();
 
-		if (i_previous.getLineStyle() != m_state.getLineStyle()
+		if (i_previous.getLineStyle() != getState().getLineStyle()
 			|| (i_previous.getLineStyle() == SWT.LINE_CUSTOM
-				&amp;&amp; m_state.getLineStyle() == SWT.LINE_CUSTOM &amp;&amp; !Arrays.equals(
-				i_previous.getLineDash(), m_state.getLineDash())))
+				&amp;&amp; getState().getLineStyle() == SWT.LINE_CUSTOM &amp;&amp; !Arrays.equals(
+				i_previous.getLineDash(), getState().getLineDash())))
 			glSetLineStyle();
 
-		if (i_previous.getXORMode() != m_state.getXORMode())
+		if (i_previous.getXORMode() != getState().getXORMode())
 			glSetXORMode();
 
-		if (i_previous.getAntialias() != m_state.getAntialias())
+		if (i_previous.getAntialias() != getState().getAntialias())
 			glSetAntialias();
 
 		m_lastColor = LastColor.UNKNOWN;
@@ -2225,7 +1219,7 @@
 
 	private void glSetAntialias() {
 
-		if (m_state.getAntialias() == SWT.ON) {
+		if (getState().getAntialias() == SWT.ON) {
 			GL11.glEnable(GL11.GL_LINE_SMOOTH);
 			GL11.glEnable(GL11.GL_POINT_SMOOTH);
 			GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
@@ -2241,8 +1235,8 @@
 		if (m_lastColor == LastColor.BACKGROUND)
 			return;
 
-		Color backgroundColor = m_state.getBackgroundColor();
-		int alpha = m_state.getAlpha();
+		Color backgroundColor = getState().getBackgroundColor();
+		int alpha = getState().getAlpha();
 
 		ColorConverter.toFloatArray(backgroundColor, alpha, TMP_F4);
 		GL11.glColor4f(TMP_F4[0], TMP_F4[1], TMP_F4[2], TMP_F4[3]);
@@ -2255,72 +1249,85 @@
 		if (!m_clippingEnabled)
 			return;
 
-		Rectangle clip = m_state.getClip();
-		if (!clip.equals(m_currentClip)) {
-			GL11.glMatrixMode(GL11.GL_MODELVIEW);
-			GL11.glPushMatrix();
-			try {
-				DoubleBuffer buffer = Draw3DCache.getDoubleBuffer(16);
-				try {
-					// left plane
-					if (clip.x &gt; 0) {
-						double a = CLIP_BASE / clip.x;
-						buffer.put(0, a);
-						buffer.put(1, 0);
-						buffer.put(2, 0);
-						buffer.put(3, -CLIP_BASE);
-						GL11.glEnable(GL11.GL_CLIP_PLANE0);
-						GL11.glClipPlane(GL11.GL_CLIP_PLANE0, buffer);
-					} else {
-						GL11.glDisable(GL11.GL_CLIP_PLANE0);
-					}
+		Rectangle clip = getState().getClip();
+		if (clip == null) {
+			if (m_currentClip != null) {
+				GL11.glDisable(GL11.GL_CLIP_PLANE0);
+				GL11.glDisable(GL11.GL_CLIP_PLANE1);
+				GL11.glDisable(GL11.GL_CLIP_PLANE2);
+				GL11.glDisable(GL11.GL_CLIP_PLANE3);
+				m_currentClip = null;
+			}
+			return;
+		} else if (clip.equals(m_currentClip))
+			return;
 
-					// top plane
-					if (clip.y &gt; 0) {
-						double b = CLIP_BASE / clip.y;
-						buffer.put(0, 0);
-						buffer.put(1, b);
-						buffer.put(2, 0);
-						buffer.put(3, -CLIP_BASE);
-						GL11.glEnable(GL11.GL_CLIP_PLANE1);
-						GL11.glClipPlane(GL11.GL_CLIP_PLANE1, buffer);
-					} else {
-						GL11.glDisable(GL11.GL_CLIP_PLANE1);
-					}
+		if (m_currentClip == null)
+			m_currentClip = new Rectangle();
 
-					// right plane
-					if (clip.x + clip.width &lt; m_width - 1) {
-						double a = -CLIP_BASE / (clip.x + clip.width);
-						buffer.put(0, a);
-						buffer.put(1, 0);
-						buffer.put(2, 0);
-						buffer.put(3, CLIP_BASE);
-						GL11.glEnable(GL11.GL_CLIP_PLANE2);
-						GL11.glClipPlane(GL11.GL_CLIP_PLANE2, buffer);
-					} else {
-						GL11.glDisable(GL11.GL_CLIP_PLANE2);
-					}
+		GL11.glMatrixMode(GL11.GL_MODELVIEW);
+		GL11.glPushMatrix();
+		try {
+			DoubleBuffer buffer = Draw3DCache.getDoubleBuffer(16);
+			try {
+				// left plane
+				if (clip.x &gt; 0) {
+					double a = CLIP_BASE / clip.x;
+					buffer.put(0, a);
+					buffer.put(1, 0);
+					buffer.put(2, 0);
+					buffer.put(3, -CLIP_BASE);
+					GL11.glEnable(GL11.GL_CLIP_PLANE0);
+					GL11.glClipPlane(GL11.GL_CLIP_PLANE0, buffer);
+				} else {
+					GL11.glDisable(GL11.GL_CLIP_PLANE0);
+				}
 
-					// bottom plane
-					if (clip.y + clip.height &lt; m_height - 1) {
-						double b = -CLIP_BASE / (clip.y + clip.height);
-						buffer.put(0, 0);
-						buffer.put(1, b);
-						buffer.put(2, 0);
-						buffer.put(3, CLIP_BASE);
-						GL11.glEnable(GL11.GL_CLIP_PLANE3);
-						GL11.glClipPlane(GL11.GL_CLIP_PLANE3, buffer);
-					} else {
-						GL11.glDisable(GL11.GL_CLIP_PLANE3);
-					}
+				// top plane
+				if (clip.y &gt; 0) {
+					double b = CLIP_BASE / clip.y;
+					buffer.put(0, 0);
+					buffer.put(1, b);
+					buffer.put(2, 0);
+					buffer.put(3, -CLIP_BASE);
+					GL11.glEnable(GL11.GL_CLIP_PLANE1);
+					GL11.glClipPlane(GL11.GL_CLIP_PLANE1, buffer);
+				} else {
+					GL11.glDisable(GL11.GL_CLIP_PLANE1);
+				}
 
-					m_currentClip.setBounds(clip);
-				} finally {
-					Draw3DCache.returnDoubleBuffer(buffer);
+				// right plane
+				if (clip.x + clip.width &lt; m_width - 1) {
+					double a = -CLIP_BASE / (clip.x + clip.width);
+					buffer.put(0, a);
+					buffer.put(1, 0);
+					buffer.put(2, 0);
+					buffer.put(3, CLIP_BASE);
+					GL11.glEnable(GL11.GL_CLIP_PLANE2);
+					GL11.glClipPlane(GL11.GL_CLIP_PLANE2, buffer);
+				} else {
+					GL11.glDisable(GL11.GL_CLIP_PLANE2);
 				}
+
+				// bottom plane
+				if (clip.y + clip.height &lt; m_height - 1) {
+					double b = -CLIP_BASE / (clip.y + clip.height);
+					buffer.put(0, 0);
+					buffer.put(1, b);
+					buffer.put(2, 0);
+					buffer.put(3, CLIP_BASE);
+					GL11.glEnable(GL11.GL_CLIP_PLANE3);
+					GL11.glClipPlane(GL11.GL_CLIP_PLANE3, buffer);
+				} else {
+					GL11.glDisable(GL11.GL_CLIP_PLANE3);
+				}
+
+				m_currentClip.setBounds(clip);
 			} finally {
-				GL11.glPopMatrix();
+				Draw3DCache.returnDoubleBuffer(buffer);
 			}
+		} finally {
+			GL11.glPopMatrix();
 		}
 	}
 
@@ -2329,8 +1336,8 @@
 		if (m_lastColor == LastColor.FOREGROUND)
 			return;
 
-		Color foregroundColor = m_state.getForegroundColor();
-		int alpha = m_state.getAlpha();
+		Color foregroundColor = getState().getForegroundColor();
+		int alpha = getState().getAlpha();
 
 		ColorConverter.toFloatArray(foregroundColor, alpha, TMP_F4);
 		GL11.glColor4f(TMP_F4[0], TMP_F4[1], TMP_F4[2], TMP_F4[3]);
@@ -2340,7 +1347,7 @@
 
 	private void glSetLineStyle() {
 
-		int lineStyle = m_state.getLineStyle();
+		int lineStyle = getState().getLineStyle();
 		switch (lineStyle) {
 		case SWT.LINE_SOLID:
 			m_currentLinePattern = null;
@@ -2369,7 +1376,7 @@
 		case SWT.LINE_CUSTOM:
 			GL11.glDisable(GL11.GL_LINE_STIPPLE);
 
-			int[] dashPattern = m_state.getLineDash();
+			int[] dashPattern = getState().getLineDash();
 			Object key = LwjglLinePattern.getKey(dashPattern);
 			m_currentLinePattern = m_linePatterns.get(key);
 			if (m_currentLinePattern == null) {
@@ -2385,13 +1392,24 @@
 
 	private void glSetLineWidth() {
 
-		float lineWidth = m_state.getLineWidth();
+		float lineWidth = getState().getLineWidth();
 		GL11.glLineWidth(lineWidth);
 	}
 
+	private void glSetRasterOffset(RasterOffset i_offset) {
+
+		if (m_lastOffset != null)
+			throw new IllegalStateException(&quot;raster offset was not reset&quot;);
+
+		if (i_offset.getOffset() != 0)
+			GL11.glTranslatef(i_offset.getOffset(), i_offset.getOffset(), 0);
+
+		m_lastOffset = i_offset;
+	}
+
 	private void glSetXORMode() {
 
-		if (m_state.getXORMode()) {
+		if (getState().getXORMode()) {
 			GL11.glEnable(GL11.GL_COLOR_LOGIC_OP);
 			GL11.glLogicOp(GL11.GL_XOR);
 		} else {
@@ -2399,44 +1417,6 @@
 		}
 	}
 
-	private void initDefaultGraphicsState() {
-
-		Display display = Display.getDefault();
-
-		Color foregroundColor = display.getSystemColor(SWT.COLOR_BLACK);
-		Color backgroundColor = display.getSystemColor(SWT.COLOR_WHITE);
-
-		m_defaultState = new GraphicsState(null);
-
-		m_defaultState.setAdvanced(true);
-
-		m_defaultState.setForegroundColor(foregroundColor);
-		m_defaultState.setBackgroundColor(backgroundColor);
-		m_defaultState.setAlpha(255);
-
-		m_defaultState.setLineWidth(1);
-		m_defaultState.setLineStyle(SWT.LINE_SOLID);
-		m_defaultState.setLineCap(SWT.CAP_FLAT);
-		m_defaultState.setLineJoin(SWT.JOIN_MITER);
-		m_defaultState.setLineMiterLimit(11);
-
-		m_defaultState.setFont(display.getSystemFont());
-
-		m_currentClip = new Rectangle(0, 0, m_width, m_height);
-		m_defaultState.setClip(m_currentClip);
-
-		m_defaultState.setTransformation(Matrix4f.IDENTITY);
-		m_defaultState.setXORMode(false);
-
-		m_defaultState.setAntialias(SWT.ON);
-		m_defaultState.setInterpolation(SWT.NONE);
-		m_defaultState.setTextAntialias(SWT.ON);
-
-		m_defaultState.setFillRule(SWT.FILL_WINDING);
-
-		m_state = new GraphicsState(m_defaultState);
-	}
-
 	/**
 	 * Indicates whether clipping is enabled.
 	 * 
@@ -2456,35 +1436,23 @@
 	@Override
 	public void popState() {
 
-		if (m_state.getParent() == m_defaultState)
-			throw new EmptyStackException();
+		GraphicsState currentState = getState();
 
-		GraphicsState currentState = m_state;
-		m_state = m_state.getParent();
+		super.popState();
 		glRestoreState(currentState);
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#pushState()
-	 */
-	@Override
-	public void pushState() {
-
-		m_state = new GraphicsState(m_state);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
 	 * @see org.eclipse.draw2d.Graphics#restoreState()
 	 */
 	@Override
 	public void restoreState() {
 
-		GraphicsState currentState = m_state;
-		m_state = new GraphicsState(m_state.getParent());
+		GraphicsState currentState = getState();
+
+		super.restoreState();
 		glRestoreState(currentState);
 	}
 
@@ -2496,13 +1464,10 @@
 	@Override
 	public void rotate(float i_degrees) {
 
-		checkDisposed();
+		super.rotate(i_degrees);
 
-		if (i_degrees == 0)
-			return;
-
-		m_state.rotate(i_degrees);
-		GL11.glRotatef(i_degrees, 0, 0, 1);
+		if (i_degrees != 0)
+			GL11.glRotatef(i_degrees, 0, 0, 1);
 	}
 
 	/**
@@ -2524,299 +1489,73 @@
 	@Override
 	public void scale(float i_horizontal, float i_vertical) {
 
-		checkDisposed();
+		super.scale(i_horizontal, i_vertical);
 
-		if (i_horizontal == 0 &amp;&amp; i_vertical == 0)
-			return;
-
-		m_state.scale(i_horizontal, i_vertical);
-		GL11.glScalef(i_horizontal, i_vertical, 0);
+		if (i_horizontal != 0 || i_vertical != 0)
+			GL11.glScalef(i_horizontal, i_vertical, 0);
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAdvanced(boolean)
-	 */
-	@Override
-	public void setAdvanced(boolean i_advanced) {
-
-		checkDisposed();
-
-		m_state.setAdvanced(i_advanced);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAlpha(int)
-	 */
-	@Override
-	public void setAlpha(int i_alpha) {
-
-		checkDisposed();
-
-		m_state.setAlpha(i_alpha);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAntialias(int)
-	 */
-	@Override
-	public void setAntialias(int i_antialias) {
-
-		checkDisposed();
-
-		m_state.setAntialias(i_antialias);
-		glSetAntialias();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setBackgroundColor(Color i_backgroundColor) {
-
-		checkDisposed();
-
-		m_state.setBackgroundColor(i_backgroundColor);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundPattern(org.eclipse.swt.graphics.Pattern)
-	 */
-	@Override
-	public void setBackgroundPattern(Pattern i_backgroundPattern) {
-
-		checkDisposed();
-
-		m_state.setBackgroundPattern(i_backgroundPattern);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
 	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.draw2d.geometry.Rectangle)
 	 */
 	@Override
 	public void setClip(Rectangle i_clip) {
 
-		checkDisposed();
+		PrecisionRectangle previous = getState().getClip();
+		super.setClip(i_clip);
 
-		if (i_clip == null) {
-			if (m_state.getClip() == null)
-				return;
-		} else {
-			if (i_clip.equals(m_state.getClip()))
-				return;
-		}
-
-		m_state.setClip(i_clip);
-		glSetClip();
+		if (!equals(previous, getState().getClip()))
+			glSetClip();
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFillRule(int)
-	 */
-	@Override
-	public void setFillRule(int i_fillRule) {
-
-		checkDisposed();
-
-		m_state.setFillRule(i_fillRule);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFont(org.eclipse.swt.graphics.Font)
-	 */
-	@Override
-	public void setFont(Font i_font) {
-
-		checkDisposed();
-
-		m_state.setFont(i_font);
-	}
-
-	/**
-	 * Sets the font manager to be used by this graphics.
-	 * 
-	 * @param i_fontManager the font manager
-	 * @throws NullPointerException if the given font manager is
-	 *             &lt;code&gt;null&lt;/code&gt;
-	 */
-	public void setFontManager(LwjglFontManager i_fontManager) {
-
-		if (i_fontManager == null)
-			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
-
-		if (m_fontManager != null &amp;&amp; m_disposeFonts)
-			m_fontManager.dispose();
-
-		m_fontManager = i_fontManager;
-		m_disposeFonts = false;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setForegroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setForegroundColor(Color i_foregroundColor) {
-
-		checkDisposed();
-
-		m_state.setForegroundColor(i_foregroundColor);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setInterpolation(int)
-	 */
-	@Override
-	public void setInterpolation(int i_interpolation) {
-
-		checkDisposed();
-
-		m_state.setInterpolation(i_interpolation);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineAttributes(org.eclipse.swt.graphics.LineAttributes)
-	 */
-	@Override
-	public void setLineAttributes(LineAttributes i_attributes) {
-
-		checkDisposed();
-
-		if (i_attributes == null)
-			return;
-
-		setLineCap(i_attributes.cap);
-		setLineJoin(i_attributes.join);
-		setLineMiterLimit(i_attributes.miterLimit);
-		setLineStyle(i_attributes.style);
-		setLineWidthFloat(i_attributes.width);
-		setLineDash(i_attributes.dash);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineCap(int)
-	 */
-	@Override
-	public void setLineCap(int i_cap) {
-
-		checkDisposed();
-
-		m_state.setLineCap(i_cap);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineDash(float[])
-	 */
-	@Override
-	public void setLineDash(float[] i_dash) {
-
-		checkDisposed();
-
-		if (i_dash == null)
-			setLineDash((int[]) null);
-		else {
-			int[] newDash = new int[i_dash.length];
-			for (int i = 0; i &lt; i_dash.length; i++)
-				newDash[i] = (int) i_dash[i];
-			setLineDash(newDash);
-		}
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
 	 * @see org.eclipse.draw2d.Graphics#setLineDash(int[])
 	 */
 	@Override
 	public void setLineDash(int[] i_dash) {
 
-		if (i_dash != null) {
-			if (m_state.getLineStyle() == SWT.LINE_CUSTOM
-				&amp;&amp; Arrays.equals(i_dash, m_state.getLineDash()))
-				return;
+		int[] previous = getState().getLineDash();
+		super.setLineDash(i_dash);
 
-			m_state.setLineStyle(SWT.LINE_CUSTOM);
-		} else {
-			if (m_state.getLineStyle() != SWT.LINE_CUSTOM
-				&amp;&amp; m_state.getLineDash() == null)
-				return;
-
-			m_state.setLineStyle(SWT.LINE_SOLID);
-		}
-
-		m_state.setLineDash(i_dash);
-		glSetLineStyle();
+		if (!Arrays.equals(previous, getState().getLineDash()))
+			glSetLineStyle();
 	}
-
-	/**
+	
+	/** 
 	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineJoin(int)
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#setLineDash(float[])
 	 */
 	@Override
-	public void setLineJoin(int i_lineJoin) {
-
-		checkDisposed();
-
-		m_state.setLineJoin(i_lineJoin);
+	public void setLineDash(float[] i_dash) {
+		
+		int[] previous = getState().getLineDash();
+		super.setLineDash(i_dash);
+		
+		if (!Arrays.equals(previous, getState().getLineDash()))
+			glSetLineStyle();
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineMiterLimit(float)
-	 */
-	@Override
-	public void setLineMiterLimit(float i_lineMiterLimit) {
-
-		checkDisposed();
-
-		m_state.setLineMiterLimit(i_lineMiterLimit);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
 	 * @see org.eclipse.draw2d.Graphics#setLineStyle(int)
 	 */
 	@Override
 	public void setLineStyle(int i_lineStyle) {
 
-		checkDisposed();
-
 		if ((i_lineStyle &amp; LINE_STYLES) == 0)
 			throw new IllegalArgumentException(&quot;unknown line style: &quot;
 				+ i_lineStyle);
 
-		if (m_state.getLineStyle() == i_lineStyle)
-			return;
+		int previous = getState().getLineStyle();
+		super.setLineStyle(i_lineStyle);
 
-		m_state.setLineStyle(i_lineStyle);
-		glSetLineStyle();
+		if (previous != getLineStyle())
+			glSetLineStyle();
 	}
 
 	/**
@@ -2827,13 +1566,7 @@
 	@Override
 	public void setLineWidth(int i_lineWidth) {
 
-		checkDisposed();
-
-		if (m_state.getLineWidth() == i_lineWidth)
-			return;
-
-		m_state.setLineWidth(i_lineWidth);
-		glSetLineWidth();
+		setLineWidthFloat(i_lineWidth);
 	}
 
 	/**
@@ -2844,22 +1577,24 @@
 	@Override
 	public void setLineWidthFloat(float i_lineWidth) {
 
-		checkDisposed();
+		float previous = getLineWidthFloat();
+		super.setLineWidthFloat(i_lineWidth);
 
-		m_state.setLineWidth(i_lineWidth);
+		if (previous != getLineWidthFloat())
+			glSetLineWidth();
 	}
 
 	/**
-	 * {@inheritDoc}
+	 * Specifies whether the font antialiasing setting should be overridden.
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#setTextAntialias(int)
+	 * @param i_overrideTextAntialias if &lt;code&gt;true&lt;/code&gt;, font antialiasing is
+	 *            always enabled, if &lt;code&gt;false&lt;/code&gt;, it's always disabled,
+	 *            if &lt;code&gt;null&lt;/code&gt;, the value set by
+	 *            {@link #setTextAntialias(int)} is used.
 	 */
-	@Override
-	public void setTextAntialias(int i_textAntialias) {
+	public void setOverrideTextAntialias(Boolean i_overrideTextAntialias) {
 
-		checkDisposed();
-
-		m_state.setTextAntialias(i_textAntialias);
+		m_overrideTextAntialias = i_overrideTextAntialias;
 	}
 
 	/**
@@ -2870,13 +1605,11 @@
 	@Override
 	public void setXORMode(boolean i_enabled) {
 
-		checkDisposed();
+		boolean previous = getXORMode();
+		super.setXORMode(i_enabled);
 
-		if (m_state.getXORMode() == i_enabled)
-			return;
-
-		m_state.setXORMode(i_enabled);
-		glSetXORMode();
+		if (previous != getXORMode())
+			glSetXORMode();
 	}
 
 	/**
@@ -2887,27 +1620,25 @@
 	@Override
 	public void shear(float i_horz, float i_vert) {
 
-		checkDisposed();
+		super.shear(i_horz, i_vert);
 
-		if (i_horz == 0 &amp;&amp; i_vert == 0)
-			return;
+		if (i_horz != 0 || i_vert != 0) {
+			FloatBuffer buffer = Draw3DCache.getFloatBuffer(16);
+			Matrix4f matrix = Draw3DCache.getMatrix4f();
+			try {
+				matrix.setIdentity();
+				matrix.set(1, 0, i_horz);
+				matrix.set(0, 1, i_vert);
 
-		FloatBuffer buffer = Draw3DCache.getFloatBuffer(16);
-		Matrix4f matrix = Draw3DCache.getMatrix4f();
-		try {
-			m_state.shear(i_horz, i_vert);
-			matrix.setIdentity();
-			matrix.set(1, 0, i_horz);
-			matrix.set(0, 1, i_vert);
+				buffer.rewind();
+				matrix.toBufferRowMajor(buffer);
+				buffer.rewind();
 
-			buffer.rewind();
-			matrix.toBufferRowMajor(buffer);
-			buffer.rewind();
-
-			GL11.glMultMatrix(buffer);
-		} finally {
-			Draw3DCache.returnFloatBuffer(buffer);
-			Draw3DCache.returnMatrix4f(matrix);
+				GL11.glMultMatrix(buffer);
+			} finally {
+				Draw3DCache.returnFloatBuffer(buffer);
+				Draw3DCache.returnMatrix4f(matrix);
+			}
 		}
 	}
 
@@ -2919,24 +1650,20 @@
 	@Override
 	public void translate(float i_dx, float i_dy) {
 
-		checkDisposed();
+		super.translate(i_dx, i_dy);
 
-		if (i_dx == 0 &amp;&amp; i_dy == 0)
-			return;
-
-		m_state.translate(i_dx, i_dy);
-		GL11.glTranslatef(i_dx, i_dy, 0);
+		if (i_dx != 0 || i_dy != 0)
+			GL11.glTranslatef(i_dx, i_dy, 0);
 	}
 
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw2d.Graphics#translate(int, int)
+	 * @see org.eclipse.draw3d.graphics.StatefulGraphics#translate(int, int)
 	 */
 	@Override
-	public void translate(int i_dX, int i_dY) {
+	public void translate(int i_dx, int i_dy) {
 
-		translate((float) i_dX, (float) i_dY);
+		translate((float) i_dx, (float) i_dy);
 	}
-
 }

Modified: branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java
===================================================================
--- branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-05 14:43:26 UTC (rev 387)
+++ branches/experimental_direct_2D_rendering/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureManager.java	2009-11-06 18:05:42 UTC (rev 388)
@@ -59,30 +59,23 @@
 	 * textures.
 	 * 
 	 * @param i_context the main GL context
+	 * @param i_fontManager the font manager
 	 */
-	public LwjglTextureManager(GLCanvas i_context) {
+	public LwjglTextureManager(GLCanvas i_context,
+			LwjglFontManager i_fontManager) {
 
 		if (i_context == null)
 			throw new NullPointerException(&quot;i_context must not be null&quot;);
 
+		if (i_fontManager == null)
+			throw new NullPointerException(&quot;i_fontManager must not be null&quot;);
+
 		m_context = i_context;
 		m_textures = new HashMap&lt;Object, LwjglTexture&gt;();
+		m_fontManager = i_fontManager;
 	}
 
 	/**
-	 * This method should not be called from outside, it is only defined public
-	 * here for tests.
-	 * 
-	 * @return the font manager
-	 */
-	public LwjglFontManager getFontManager() {
-		if (m_fontManager == null) { // lazy initialization
-			m_fontManager = new LwjglFontManager();
-		}
-		return m_fontManager;
-	}
-
-	/**
 	 * Activates the texture with the given key for rendering.
 	 * 
 	 * @param i_key the unique key to identify the texture
@@ -161,8 +154,7 @@
 				log.fine(&quot;Pbuffer texture support detected&quot;);
 				m_textureSupport = TextureSupport.PBUFFER;
 			} else {
-				log
-					.fine(&quot;No hardware support for accelerated texture drawing detected, using SWT images&quot;);
+				log.fine(&quot;No hardware support for accelerated texture drawing detected, using SWT images&quot;);
 				m_textureSupport = TextureSupport.SWT;
 			}
 		}
@@ -199,12 +191,12 @@
 
 		switch (getTextureSupport()) {
 		case FBO:
-			texture = new LwjglTextureFbo(i_width, i_height, getFontManager());
+			texture = new LwjglTextureFbo(i_width, i_height, m_fontManager);
 			break;
 		case PBUFFER:
 			texture =
 				new LwjglTexturePbuffer(m_context, i_width, i_height,
-					getFontManager());
+					m_fontManager);
 			break;
 		case SWT:
 			texture = new LwjglTextureSwt(i_width, i_height);


</pre>]]></content:encoded>
		<pubDate>Fri, 06 Nov 2009 18:05:46 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00233.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>


	<item>
		<title>[gef3d-commits] r387 - branches</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00232.html</link>
		<description>Author: kduske Date: 2009-11-05 09:43:26 -0500 (Thu, 05 Nov 2009) New Revision: 387 Added: branches/experimental_direct_2D_rendering/ Log: - new branch for some experimentation with directly rendering the 2D content instead of (or in addition to) using tex...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:43:26 -0500 (Thu, 05 Nov 2009)
New Revision: 387

Added:
   branches/experimental_direct_2D_rendering/
Log:
- new branch for some experimentation with directly rendering the 2D content instead of (or in addition to) using textures


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:43:26 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00232.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r386 - in trunk/org.eclipse.draw3d.ui: .	src/org/eclipse/draw3d/ui/preferences	src/org/eclipse/draw3d/ui/preferences/dialog</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00231.html</link>
		<description>Author: kduske Date: 2009-11-05 09:39:13 -0500 (Thu, 05 Nov 2009) New Revision: 386 Added: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/Draw3DPreferencePage.java trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:39:13 -0500 (Thu, 05 Nov 2009)
New Revision: 386

Added:
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/Draw3DPreferencePage.java
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/KeyFieldEditorPreferencePage.java
Modified:
   trunk/org.eclipse.draw3d.ui/plugin.xml
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/PrefNames.java
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/ScenePreferenceDistributor.java
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/CameraPreferencePage.java
   trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/PreferenceInitializer.java
Log:
- added preference for overriding the font antialiasing


Modified: trunk/org.eclipse.draw3d.ui/plugin.xml
===================================================================
--- trunk/org.eclipse.draw3d.ui/plugin.xml	2009-11-05 14:38:38 UTC (rev 385)
+++ trunk/org.eclipse.draw3d.ui/plugin.xml	2009-11-05 14:39:13 UTC (rev 386)
@@ -10,9 +10,20 @@
    &lt;extension
          point=&quot;org.eclipse.ui.preferencePages&quot;&gt;
       &lt;page
+            class=&quot;org.eclipse.draw3d.ui.preferences.dialog.Draw3DPreferencePage&quot;
+            id=&quot;org.eclipse.draw3d.ui.draw3dPreferences&quot;
+            name=&quot;Draw3D&quot;&gt;
+      &lt;/page&gt;
+      &lt;page
+            category=&quot;org.eclipse.draw3d.ui.draw3dPreferences&quot;
             class=&quot;org.eclipse.draw3d.ui.preferences.dialog.CameraPreferencePage&quot;
+            id=&quot;org.eclipse.draw3d.ui.page1&quot;
+            name=&quot;Camera Controls&quot;&gt;
+      &lt;/page&gt;
+      &lt;page
+            class=&quot;org.eclipse.draw3d.ui.WorkbenchPreferencePage2&quot;
             id=&quot;org.eclipse.draw3d.ui.cameraPreferences&quot;
-            name=&quot;Draw3D&quot;&gt;
+            name=&quot;name&quot;&gt;
       &lt;/page&gt;
    &lt;/extension&gt;
    &lt;extension

Modified: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/PrefNames.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/PrefNames.java	2009-11-05 14:38:38 UTC (rev 385)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/PrefNames.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -20,6 +20,24 @@
 public interface PrefNames {
 
 	/**
+	 * Preference value to indiciate that the font antialiasing setting is
+	 * determined by the editor.
+	 */
+	public static final String FONT_AA_EDITOR = &quot;editor&quot;;
+
+	/**
+	 * Preference value to indiciate that the font antialiasing setting is
+	 * overridden to be always on.
+	 */
+	public static final String FONT_AA_ON = &quot;on&quot;;
+
+	/**
+	 * Preference value to indiciate that the font antialiasing setting is
+	 * overridden to be always off.
+	 */
+	public static final String FONT_AA_OFF = &quot;off&quot;;
+
+	/**
 	 * Preference name for the backward key binding.
 	 */
 	public static final String KEY_BACKWARD = &quot;moveBackwardKey&quot;;
@@ -86,6 +104,11 @@
 	public static final String LWS_DRAW_AXES = &quot;lwsDrawCoordinateAxes&quot;;
 
 	/**
+	 * Preference name for the font antialasing value.
+	 */
+	public static final String LWS_FONT_AA = &quot;lwsFontAntialias&quot;;
+
+	/**
 	 * Preference name for the modifier key for camera orbit mode.
 	 */
 	public static final String MOD_ORBIT = &quot;cameraOrbitMode&quot;;

Modified: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/ScenePreferenceDistributor.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/ScenePreferenceDistributor.java	2009-11-05 14:38:38 UTC (rev 385)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/ScenePreferenceDistributor.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -13,6 +13,7 @@
 import java.util.logging.Logger;
 
 import org.eclipse.draw3d.IScene;
+import org.eclipse.draw3d.IScene.FontAntialias;
 import org.eclipse.draw3d.camera.FirstPersonCamera;
 import org.eclipse.draw3d.camera.ICamera;
 import org.eclipse.jface.preference.IPreferenceStore;
@@ -35,11 +36,11 @@
 	/**
 	 * The default camera type.
 	 */
-	public static final String DEFAULT_CAMERA_TYPE = FirstPersonCamera.class
-			.getName();
+	public static final String DEFAULT_CAMERA_TYPE =
+		FirstPersonCamera.class.getName();
 
-	private static final Logger log = Logger
-			.getLogger(ScenePreferenceDistributor.class.getName());
+	private static final Logger log =
+		Logger.getLogger(ScenePreferenceDistributor.class.getName());
 
 	private IScene m_scene;
 
@@ -47,10 +48,8 @@
 	 * Creates a new instance that distributes preference changes to the given
 	 * scene.
 	 * 
-	 * @param i_scene
-	 *            the scene
-	 * @param i_store
-	 *            the preference store
+	 * @param i_scene the scene
+	 * @param i_store the preference store
 	 */
 	public ScenePreferenceDistributor(IScene i_scene) {
 
@@ -61,14 +60,11 @@
 	 * Returns the camera of the given type or the default camera type if the
 	 * given type is unavailable.
 	 * 
-	 * @param type
-	 *            the type name of the camera to return
+	 * @param type the type name of the camera to return
 	 * @return the camera of the given type
-	 * @throws NullPointerException
-	 *             if the given type is &lt;code&gt;null&lt;/code&gt;
-	 * @throws IllegalArgumentException
-	 *             if the given type is the default camera type, but it cannot
-	 *             be loaded
+	 * @throws NullPointerException if the given type is &lt;code&gt;null&lt;/code&gt;
+	 * @throws IllegalArgumentException if the given type is the default camera
+	 *             type, but it cannot be loaded
 	 */
 	private ICamera getCamera(String type) {
 
@@ -81,7 +77,7 @@
 		} catch (Exception ex) {
 			if (DEFAULT_CAMERA_TYPE.equals(type))
 				throw new IllegalArgumentException(&quot;Default camera type &quot;
-						+ DEFAULT_CAMERA_TYPE + &quot; is unavailable&quot;, ex);
+					+ DEFAULT_CAMERA_TYPE + &quot; is unavailable&quot;, ex);
 
 			log.severe(&quot;Unable to load camera type &quot; + type);
 			return getCamera(DEFAULT_CAMERA_TYPE);
@@ -100,6 +96,7 @@
 		m_scene.setDebug(i_store.getBoolean(LWS_DEBUG));
 		setSceneBackgroundColor(i_store.getString(LWS_BACKGROUND));
 		setSceneCamera(i_store.getString(LWS_CAMERA_TYPE));
+		setSceneFontAntialias(i_store.getString(LWS_FONT_AA));
 	}
 
 	/**
@@ -127,8 +124,23 @@
 			setSceneBackgroundColor(newValue);
 		else if (name.equals(LWS_CAMERA_TYPE))
 			setSceneCamera(newValue);
+		else if (name.equals(LWS_FONT_AA)) {
+			setSceneFontAntialias(newValue);
+		}
+
+		m_scene.render(name.equals(LWS_FONT_AA));
 	}
 
+	private void setSceneFontAntialias(String i_value) {
+
+		if (i_value.equals(FONT_AA_ON))
+			m_scene.setFontAntialias(FontAntialias.ON);
+		else if (i_value.equals(FONT_AA_OFF))
+			m_scene.setFontAntialias(FontAntialias.OFF);
+		else
+			m_scene.setFontAntialias(FontAntialias.EDITOR);
+	}
+
 	private void setSceneBackgroundColor(String i_value) {
 
 		RGB rgb = StringConverter.asRGB(i_value);
@@ -144,7 +156,7 @@
 		ICamera currentCamera = m_scene.getCamera();
 
 		if (currentCamera != null
-				&amp;&amp; !currentCamera.getClass().equals(newCamera.getClass()))
+			&amp;&amp; !currentCamera.getClass().equals(newCamera.getClass()))
 			m_scene.setCamera(newCamera);
 	}
 

Modified: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/CameraPreferencePage.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/CameraPreferencePage.java	2009-11-05 14:38:38 UTC (rev 385)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/CameraPreferencePage.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2008 Jens von Pilgrim and others.
+ * Copyright (c) 2009 Jens von Pilgrim and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -12,97 +12,142 @@
 
 import static org.eclipse.draw3d.ui.preferences.PrefNames.*;
 
+import java.util.Collection;
+import java.util.LinkedList;
+
 import org.eclipse.core.runtime.Platform;
-import org.eclipse.draw3d.camera.FirstPersonCamera;
-import org.eclipse.draw3d.camera.RestrictedFirstPersonCamera;
 import org.eclipse.draw3d.ui.Draw3DUIPlugin;
 import org.eclipse.draw3d.ui.preferences.PrefNames;
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.ColorFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.preference.PreferencePage;
 import org.eclipse.jface.preference.ScaleFieldEditor;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
 import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Group;
 import org.eclipse.ui.IWorkbench;
 import org.eclipse.ui.IWorkbenchPreferencePage;
 
 /**
- * Provides the implementation of the camera preferences.
+ * Preference page implementation for camera control settings.
  * 
  * @author Kristian Duske
  * @version $Revision$
- * @since 4.3.2008
+ * @since 03.11.2009
  */
-public class CameraPreferencePage extends FieldEditorPreferencePage implements
-		IWorkbenchPreferencePage {
+public class CameraPreferencePage extends PreferencePage implements
+		IWorkbenchPreferencePage, IPropertyChangeListener {
 
+	private Collection&lt;FieldEditor&gt; m_editors = new LinkedList&lt;FieldEditor&gt;();
+
+	private FieldEditor m_invalidEditor;
+
 	/**
-	 * Creates a new instance.
+	 * Creates a new preference page.
 	 */
 	public CameraPreferencePage() {
-		super(GRID);
+
 		setPreferenceStore(Draw3DUIPlugin.getDefault().getPreferenceStore());
-		setDescription(&quot;GEF 3D camera preferences&quot;);
+		setDescription(&quot;Draw3D camera preferences&quot;);
 	}
 
+	private void addEditor(FieldEditor i_editor) {
+
+		m_editors.add(i_editor);
+
+		i_editor.setPage(this);
+		i_editor.setPropertyChangeListener(this);
+		i_editor.setPreferenceStore(getPreferenceStore());
+		i_editor.load();
+	}
+
 	private void addKeyEditor(String i_prefName, String i_label,
-		int i_keyStrokeLimit) {
+		int i_keyStrokeLimit, Composite i_parent) {
 
-		Composite parent = getFieldEditorParent();
-
 		KeyBindingFieldEditor keyEditor =
-			new KeyBindingFieldEditor(i_prefName, i_label, parent);
+			new KeyBindingFieldEditor(i_prefName, i_label, i_parent);
 
 		keyEditor.setKeyStrokeLimit(i_keyStrokeLimit);
-		addField(keyEditor);
+		addEditor(keyEditor);
 	}
 
+	private void checkState() {
+
+		for (FieldEditor editor : m_editors)
+			if (!editor.isValid()) {
+				m_invalidEditor = editor;
+				setValid(false);
+				break;
+			}
+	}
+
 	/**
-	 * Creates the field editors. Field editors are abstractions of the common
-	 * GUI blocks needed to manipulate various types of preferences. Each field
-	 * editor knows how to save and restore itself.
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
 	 */
 	@Override
-	public void createFieldEditors() {
+	protected Control createContents(Composite i_parent) {
 
-		Composite parent = getFieldEditorParent();
+		Composite control = new Composite(i_parent, SWT.NULL);
+		control.setLayout(new GridLayout(1, true));
 
-		String[][] cameraTypes =
-			new String[][] {
-				{ &quot;Default first person camera&quot;,
-					FirstPersonCamera.class.getName() },
-				{ &quot;Restricted first person camera&quot;,
-					RestrictedFirstPersonCamera.class.getName() } };
+		createMouseControls(control);
+		createKeyboardControls(control);
 
-		addField(new RadioGroupFieldEditor(PrefNames.LWS_CAMERA_TYPE,
-			&quot;Camera type:&quot;, 1, cameraTypes, parent));
+		checkState();
+		return control;
+	}
 
-		addField(new ColorFieldEditor(PrefNames.LWS_BACKGROUND,
-			&quot;Background color&quot;, parent));
+	private void createKeyboardControls(Composite i_parent) {
 
-		addField(new BooleanFieldEditor(PrefNames.LWS_DRAW_AXES, &quot;Draw axes&quot;,
-			parent));
+		Group keyboardGroup = new Group(i_parent, SWT.NULL);
+		keyboardGroup.setText(&quot;Keyboard&quot;);
+		keyboardGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
 
-		addField(new BooleanFieldEditor(PrefNames.LWS_DEBUG, &quot;Debug&quot;, parent));
+		FillLayout fillLayout = new FillLayout();
+		fillLayout.marginWidth = 10;
+		fillLayout.marginHeight = 10;
+		keyboardGroup.setLayout(fillLayout);
 
-		addField(new ScaleFieldEditor(PrefNames.MOUSE_SENSITIVITY,
-			&quot;Mouse sensitivity:&quot;, parent, 1, 100, 1, 20));
+		Composite editorParent = new Composite(keyboardGroup, SWT.NULL);
 
-		addKeyEditor(KEY_FORWARD, &quot;Move forward:&quot;, 1);
-		addKeyEditor(KEY_BACKWARD, &quot;Move backward:&quot;, 1);
+		addKeyEditor(KEY_FORWARD, &quot;Move forward:&quot;, 1, editorParent);
+		addKeyEditor(KEY_BACKWARD, &quot;Move backward:&quot;, 1, editorParent);
 
-		addKeyEditor(KEY_LEFT, &quot;Move left:&quot;, 1);
-		addKeyEditor(KEY_RIGHT, &quot;Move right:&quot;, 1);
+		addKeyEditor(KEY_LEFT, &quot;Move left:&quot;, 1, editorParent);
+		addKeyEditor(KEY_RIGHT, &quot;Move right:&quot;, 1, editorParent);
 
-		addKeyEditor(KEY_UP, &quot;Move up:&quot;, 1);
-		addKeyEditor(KEY_DOWN, &quot;Move down:&quot;, 1);
+		addKeyEditor(KEY_UP, &quot;Move up:&quot;, 1, editorParent);
+		addKeyEditor(KEY_DOWN, &quot;Move down:&quot;, 1, editorParent);
 
-		addKeyEditor(KEY_ROLL_CCW, &quot;Roll left:&quot;, 1);
-		addKeyEditor(KEY_ROLL_CW, &quot;Roll right:&quot;, 1);
+		addKeyEditor(KEY_ROLL_CCW, &quot;Roll left:&quot;, 1, editorParent);
+		addKeyEditor(KEY_ROLL_CW, &quot;Roll right:&quot;, 1, editorParent);
 
-		addKeyEditor(KEY_CENTER, &quot;Center view&quot;, 1);
+		addKeyEditor(KEY_CENTER, &quot;Center view&quot;, 1, editorParent);
+	}
 
+	private void createMouseControls(Composite i_parent) {
+
+		Group mouseGroup = new Group(i_parent, SWT.NULL);
+		mouseGroup.setText(&quot;Mouse&quot;);
+		mouseGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false));
+
+		FillLayout fillLayout = new FillLayout();
+		fillLayout.marginWidth = 10;
+		fillLayout.marginHeight = 10;
+		mouseGroup.setLayout(fillLayout);
+
+		Composite editorParent = new Composite(mouseGroup, SWT.NULL);
+
+		addEditor(new ScaleFieldEditor(PrefNames.MOUSE_SENSITIVITY,
+			&quot;Mouse sensitivity:&quot;, editorParent, 1, 100, 1, 20));
+
 		String[] modOrbitLabels;
 		int[] modOrbitValues;
 		if (Platform.OS_MACOSX.equals(Platform.getOS())) {
@@ -114,12 +159,101 @@
 			modOrbitValues = new int[] { SWT.SHIFT, SWT.CONTROL, SWT.ALT };
 		}
 
-		addField(new BitFieldEditor(PrefNames.MOD_ORBIT, &quot;Orbit key:&quot;,
-			modOrbitLabels.length, modOrbitLabels, modOrbitValues, parent));
+		addEditor(new BitFieldEditor(PrefNames.MOD_ORBIT, &quot;Orbit key:&quot;,
+			modOrbitLabels.length, modOrbitLabels, modOrbitValues, editorParent));
 	}
 
-	public void init(IWorkbench workbench) {
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
+	 */
+	public void init(IWorkbench i_workbench) {
 		// nothing to do
 	}
 
-}
\ No newline at end of file
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.preference.PreferencePage#performApply()
+	 */
+	@Override
+	protected void performApply() {
+
+		for (FieldEditor editor : m_editors)
+			editor.store();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.preference.PreferencePage#performCancel()
+	 */
+	@Override
+	public boolean performCancel() {
+
+		for (FieldEditor editor : m_editors)
+			editor.load();
+
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
+	 */
+	@Override
+	protected void performDefaults() {
+
+		for (FieldEditor editor : m_editors)
+			editor.loadDefault();
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.preference.PreferencePage#performOk()
+	 */
+	@Override
+	public boolean performOk() {
+
+		performApply();
+		return true;
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
+	 */
+	public void propertyChange(PropertyChangeEvent i_event) {
+
+		String property = i_event.getProperty();
+		if (FieldEditor.IS_VALID.equals(property)) {
+			Object newValue = i_event.getNewValue();
+			if (newValue instanceof Boolean) {
+				boolean valid = ((Boolean) newValue).booleanValue();
+				if (valid) {
+					checkState();
+				} else {
+					m_invalidEditor = (FieldEditor) i_event.getSource();
+					setValid(valid);
+				}
+			}
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
+	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+	 */
+	@Override
+	public void setVisible(boolean i_visible) {
+		super.setVisible(i_visible);
+
+		if (i_visible &amp;&amp; m_invalidEditor != null)
+			m_invalidEditor.setFocus();
+	}
+}

Copied: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/Draw3DPreferencePage.java (from rev 362, trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/CameraPreferencePage.java)
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/Draw3DPreferencePage.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/Draw3DPreferencePage.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.ui.preferences.dialog;
+
+import org.eclipse.draw3d.camera.FirstPersonCamera;
+import org.eclipse.draw3d.camera.RestrictedFirstPersonCamera;
+import org.eclipse.draw3d.ui.Draw3DUIPlugin;
+import org.eclipse.draw3d.ui.preferences.PrefNames;
+import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.jface.preference.ColorFieldEditor;
+import org.eclipse.jface.preference.ComboFieldEditor;
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.jface.preference.RadioGroupFieldEditor;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+/**
+ * Preference page implementation for general Draw3D settings.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 4.3.2008
+ */
+public class Draw3DPreferencePage extends FieldEditorPreferencePage implements
+		IWorkbenchPreferencePage {
+
+	/**
+	 * Creates a new instance.
+	 */
+	public Draw3DPreferencePage() {
+		super(GRID);
+		setPreferenceStore(Draw3DUIPlugin.getDefault().getPreferenceStore());
+		setDescription(&quot;Draw3D general preferences&quot;);
+	}
+
+	/**
+	 * Creates the field editors. Field editors are abstractions of the common
+	 * GUI blocks needed to manipulate various types of preferences. Each field
+	 * editor knows how to save and restore itself.
+	 */
+	@Override
+	public void createFieldEditors() {
+
+		String[][] cameraTypes =
+			new String[][] {
+				{ &quot;Default first person camera&quot;,
+					FirstPersonCamera.class.getName() },
+				{ &quot;Restricted first person camera&quot;,
+					RestrictedFirstPersonCamera.class.getName() } };
+
+		addField(new RadioGroupFieldEditor(PrefNames.LWS_CAMERA_TYPE,
+			&quot;Camera type:&quot;, 1, cameraTypes, getFieldEditorParent()));
+
+		addField(new ColorFieldEditor(PrefNames.LWS_BACKGROUND,
+			&quot;Background color&quot;, getFieldEditorParent()));
+
+		addField(new BooleanFieldEditor(PrefNames.LWS_DRAW_AXES, &quot;Draw axes&quot;,
+			getFieldEditorParent()));
+
+		addField(new BooleanFieldEditor(PrefNames.LWS_DEBUG, &quot;Debug&quot;,
+			getFieldEditorParent()));
+
+		String[][] fontOptions =
+			new String[][] {
+				new String[] { &quot;Editor setting&quot;, PrefNames.FONT_AA_EDITOR },
+				new String[] { &quot;Always on (ignore editor setting)&quot;,
+					PrefNames.FONT_AA_ON },
+				new String[] { &quot;Always off (ignore editor setting)&quot;,
+					PrefNames.FONT_AA_OFF } };
+		addField(new ComboFieldEditor(PrefNames.LWS_FONT_AA,
+			&quot;Font antialiasing&quot;, fontOptions, getFieldEditorParent()));
+	}
+
+	public void init(IWorkbench workbench) {
+		// nothing to do
+	}
+}
\ No newline at end of file

Added: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/KeyFieldEditorPreferencePage.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/KeyFieldEditorPreferencePage.java	                        (rev 0)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/KeyFieldEditorPreferencePage.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jens von Pilgrim and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * <a  href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ *
+ * Contributors:
+ *    Kristian Duske - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.draw3d.ui.preferences.dialog;
+
+import org.eclipse.jface.preference.FieldEditorPreferencePage;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Abstract base implementation for preference pages that contain editors for
+ * key bindings.
+ * 
+ * @author Kristian Duske
+ * @version $Revision$
+ * @since 03.11.2009
+ */
+public abstract class KeyFieldEditorPreferencePage extends
+		FieldEditorPreferencePage {
+
+	/**
+	 * Creates a new preference pages with the given style.
+	 * 
+	 * @param i_style the style
+	 */
+	public KeyFieldEditorPreferencePage(int i_style) {
+
+		super(i_style);
+	}
+
+	/**
+	 * Adds a key binding field editor with the given preference name, label and
+	 * key stroke limit.
+	 * 
+	 * @param i_prefName the name of the preference in the preference store
+	 * @param i_label the label
+	 * @param i_keyStrokeLimit the maximum number of keystrokes
+	 * @param i_parent the parent composite
+	 */
+	protected void addKeyEditor(String i_prefName, String i_label,
+		int i_keyStrokeLimit, Composite i_parent) {
+
+		KeyBindingFieldEditor keyEditor =
+			new KeyBindingFieldEditor(i_prefName, i_label, i_parent);
+
+		keyEditor.setKeyStrokeLimit(i_keyStrokeLimit);
+		addField(keyEditor);
+	}
+}

Modified: trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/PreferenceInitializer.java
===================================================================
--- trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/PreferenceInitializer.java	2009-11-05 14:38:38 UTC (rev 385)
+++ trunk/org.eclipse.draw3d.ui/src/org/eclipse/draw3d/ui/preferences/dialog/PreferenceInitializer.java	2009-11-05 14:39:13 UTC (rev 386)
@@ -43,18 +43,20 @@
 	@Override
 	public void initializeDefaultPreferences() {
 
-		IPreferenceStore store = Draw3DUIPlugin.getDefault()
-				.getPreferenceStore();
+		IPreferenceStore store =
+			Draw3DUIPlugin.getDefault().getPreferenceStore();
 
 		store.setDefault(LWS_CAMERA_TYPE,
-				ScenePreferenceDistributor.DEFAULT_CAMERA_TYPE);
+			ScenePreferenceDistributor.DEFAULT_CAMERA_TYPE);
 
 		Display display = Display.getCurrent();
 		Color backgroundColor = display.getSystemColor(SWT.COLOR_GRAY);
 
-		store.setDefault(LWS_BACKGROUND, StringConverter
-				.asString(backgroundColor.getRGB()));
+		store.setDefault(LWS_BACKGROUND,
+			StringConverter.asString(backgroundColor.getRGB()));
 
+		store.setDefault(LWS_FONT_AA, FONT_AA_EDITOR);
+
 		store.setDefault(LWS_DEBUG, false);
 		store.setDefault(LWS_DRAW_AXES, true);
 		store.setDefault(MOUSE_SENSITIVITY, 10);


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:39:14 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00231.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r385 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00230.html</link>
		<description>Author: kduske Date: 2009-11-05 09:38:38 -0500 (Thu, 05 Nov 2009) New Revision: 385 Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java Log: - removed raster offset Modified: trunk/org.ecli...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:38:38 -0500 (Thu, 05 Nov 2009)
New Revision: 385

Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java
Log:
- removed raster offset


Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java	2009-11-05 14:38:22 UTC (rev 384)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTexturePbuffer.java	2009-11-05 14:38:38 UTC (rev 385)
@@ -208,9 +208,6 @@
 				GLU.gluOrtho2D(0, m_width, m_height, 0);
 				GL11.glViewport(0, 0, m_width, m_height);
 
-				GL11.glTranslatef(LwjglGraphics.RASTER_OFFSET,
-					LwjglGraphics.RASTER_OFFSET, 0);
-
 				m_valid = true;
 			} else {
 				m_pBuffer.makeCurrent();


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:38:39 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00230.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>

 
	</channel>
	</rss>
<!-- MHonArc v2.6.10 -->
