<?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>Fri, 06 Nov 2009 18:10:30 GMT</pubDate>
		<lastBuildDate>Fri, 06 Nov 2009 18:10:30 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] 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>
	<item>
		<title>[gef3d-commits] r384 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00229.html</link>
		<description>Author: kduske Date: 2009-11-05 09:38:22 -0500 (Thu, 05 Nov 2009) New Revision: 384 Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java Log: - generate mipmaps for textures Modified: trunk/org....</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:38:22 -0500 (Thu, 05 Nov 2009)
New Revision: 384

Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java
Log:
- generate mipmaps for textures


Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java	2009-11-05 14:38:00 UTC (rev 383)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/texture/LwjglTextureFbo.java	2009-11-05 14:38:22 UTC (rev 384)
@@ -115,7 +115,7 @@
 			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.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_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,
@@ -213,7 +213,7 @@
 
 	private int m_glTexture = 0;
 
-	private LwjglGraphics m_graphics;
+	private Graphics m_graphics;
 
 	private int m_height = -1;
 
@@ -287,9 +287,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);
 	}
 
 	/**
@@ -320,6 +317,10 @@
 
 		GL11.glFlush();
 
+		// calculate mipmaps
+		GL11.glBindTexture(GL11.GL_TEXTURE_2D, m_glTexture);
+		EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
+
 		// restore OpenGL state
 		GL11.glMatrixMode(GL11.GL_MODELVIEW);
 		GL11.glPopMatrix();


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:38:22 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00229.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r383 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00228.html</link>
		<description>Author: kduske Date: 2009-11-05 09:38:00 -0500 (Thu, 05 Nov 2009) New Revision: 383 Removed: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphicsLog.java Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/ec...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:38:00 -0500 (Thu, 05 Nov 2009)
New Revision: 383

Removed:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphicsLog.java
Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
Log:
- added support for overriding the text antialiasing setting


Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-05 14:37:28 UTC (rev 382)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphics.java	2009-11-05 14:38:00 UTC (rev 383)
@@ -120,6 +120,7 @@
  *       segments for long arcs, resulting in a performance penalty
  * @todo implement the unsupported methods
  */
+@SuppressWarnings(&quot;unused&quot;)
 public class LwjglGraphics extends Graphics {
 
 	/**
@@ -205,15 +206,13 @@
 				// 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());
+					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());
+					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
@@ -840,6 +839,24 @@
 		}
 	}
 
+	private enum RasterOffset {
+
+		POLYGON, LINE, POINT;
+
+		public float getOffset() {
+
+			switch (this) {
+			case POLYGON:
+				return 0;
+			case LINE:
+			case POINT:
+				return 0.49f;
+			}
+
+			throw new AssertionError(&quot;unknown raster offset enum: &quot; + this);
+		}
+	}
+
 	private enum LastColor {
 
 		/**
@@ -878,11 +895,6 @@
 	private static final Logger log =
 		Logger.getLogger(LwjglGraphics.class.getName());
 
-	/**
-	 * Offset value needed for correct rasterization.
-	 */
-	public static final float RASTER_OFFSET = 0.375f;
-
 	private static final float[] TMP_F4 = new float[4];
 
 	private boolean m_clippingEnabled = true;
@@ -910,7 +922,22 @@
 
 	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
@@ -1001,20 +1028,24 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					GL11.glBegin(GL11.GL_LINE_STRIP);
+					glDrawTexturedArc(i_x, i_y, i_w, i_h, i_offset, i_length);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINE_STRIP);
-				glDrawTexturedArc(i_x, i_y, i_w, i_h, i_offset, i_length);
+				glDrawArc(i_x, i_y, i_w, i_h, i_offset, i_length);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINE_STRIP);
-			glDrawArc(i_x, i_y, i_w, i_h, i_offset, i_length);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
 	}
 
@@ -1075,59 +1106,61 @@
 
 		checkDisposed();
 
-		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);
+		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);
+			try {
 
-			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.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.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);
+				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);
 
-				GL11.glBegin(GL11.GL_QUADS);
-				GL11.glTexCoord2f(0, 0);
-				GL11.glVertex2i(i_x2, i_y2);
+					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, 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(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();
+					GL11.glTexCoord2f(0, 1);
+					GL11.glVertex2i(i_x2, i_y2 + i_h2);
+					GL11.glEnd();
+				} finally {
+					GL11.glPopAttrib();
+				}
 			} finally {
-				GL11.glPopAttrib();
+				GL11.glDeleteTextures(nameBuffer);
 			}
 		} finally {
-			GL11.glDeleteTextures(nameBuffer);
+			glResetRasterOffset();
 		}
 	}
 
@@ -1142,26 +1175,31 @@
 		checkDisposed();
 
 		glSetForegroundColor();
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					double s =
+						m_currentLinePattern.getS(i_x1, i_y1, i_x2, i_y2);
 
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
-				double s = m_currentLinePattern.getS(i_x1, i_y1, i_x2, i_y2);
-
+					GL11.glBegin(GL11.GL_LINES);
+					GL11.glTexCoord1f(0);
+					GL11.glVertex2i(i_x1, i_y1);
+					GL11.glTexCoord1d(s);
+					GL11.glVertex2i(i_x2, i_y2);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINES);
-				GL11.glTexCoord1f(0);
 				GL11.glVertex2i(i_x1, i_y1);
-				GL11.glTexCoord1d(s);
 				GL11.glVertex2i(i_x2, i_y2);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINES);
-			GL11.glVertex2i(i_x1, i_y1);
-			GL11.glVertex2i(i_x2, i_y2);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
 	}
 
@@ -1187,21 +1225,25 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					GL11.glBegin(GL11.GL_LINE_LOOP);
+					glDrawTexturedPointList(i_points);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINE_LOOP);
-				glDrawTexturedPointList(i_points);
+				glDrawPointList(i_points);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINE_LOOP);
-			glDrawPointList(i_points);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
 	}
 
@@ -1219,20 +1261,24 @@
 			return;
 
 		glSetForegroundColor();
-
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					GL11.glBegin(GL11.GL_LINE_STRIP);
+					glDrawTexturedPointList(i_points);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINE_STRIP);
-				glDrawTexturedPointList(i_points);
+				glDrawPointList(i_points);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINE_STRIP);
-			glDrawPointList(i_points);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
 	}
 
@@ -1247,21 +1293,25 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					GL11.glBegin(GL11.GL_LINE_LOOP);
+					glDrawTexturedRectangle(i_x, i_y, i_width, i_height);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINE_LOOP);
-				glDrawTexturedRectangle(i_x, i_y, i_width, i_height);
+				glDrawRectangle(i_x, i_y, i_width, i_height);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINE_LOOP);
-			glDrawRectangle(i_x, i_y, i_width, i_height);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
 
 		/*-
@@ -1287,23 +1337,26 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
-
-		if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
-			m_currentLinePattern.activate();
-			try {
+		glSetRasterOffset(RasterOffset.LINE);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
+			if (m_state.getLineStyle() == SWT.LINE_CUSTOM) {
+				m_currentLinePattern.activate();
+				try {
+					GL11.glBegin(GL11.GL_LINE_LOOP);
+					glDrawTexturedRoundRectangle(i_r, i_arcWidth, i_arcHeight);
+					GL11.glEnd();
+				} finally {
+					m_currentLinePattern.deactivate();
+				}
+			} else {
 				GL11.glBegin(GL11.GL_LINE_LOOP);
-				glDrawTexturedRoundRectangle(i_r, i_arcWidth, i_arcHeight);
+				glDrawRoundRectangle(i_r, i_arcWidth, i_arcHeight);
 				GL11.glEnd();
-			} finally {
-				m_currentLinePattern.deactivate();
 			}
-		} else {
-			GL11.glBegin(GL11.GL_LINE_LOOP);
-			glDrawRoundRectangle(i_r, i_arcWidth, i_arcHeight);
-			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
 		}
-
 	}
 
 	/**
@@ -1317,8 +1370,13 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-		LwjglFont glFont = glGetFont();
-		glFont.renderString(i_s, i_x, i_y, false);
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			LwjglFont glFont = glGetFont();
+			glFont.renderString(i_s, i_x, i_y, false);
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1332,8 +1390,13 @@
 		checkDisposed();
 
 		glSetForegroundColor();
-		LwjglFont glFont = glGetFont();
-		glFont.renderString(i_s, i_x, i_y, true);
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			LwjglFont glFont = glGetFont();
+			glFont.renderString(i_s, i_x, i_y, true);
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1378,12 +1441,16 @@
 		checkDisposed();
 
 		glSetBackgroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-
-		GL11.glBegin(GL11.GL_POLYGON);
-		GL11.glVertex2f(i_x + (float) i_w / 2, i_y + (float) i_h / 2);
-		glDrawArc(i_x, i_y, i_w, i_h, i_offset, i_length);
-		GL11.glEnd();
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+			GL11.glBegin(GL11.GL_POLYGON);
+			GL11.glVertex2f(i_x + (float) i_w / 2, i_y + (float) i_h / 2);
+			glDrawArc(i_x, i_y, i_w, i_h, i_offset, i_length);
+			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1397,25 +1464,44 @@
 		boolean i_vertical) {
 
 		checkDisposed();
-		// TODO evaluate i_vertical
-		int x1 = i_x;
-		int y1 = i_y;
-		int x2 = i_x + i_width;
-		int y2 = i_y + i_height;
 
-		GL11.glBegin(GL11.GL_QUADS);
-		// GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-		// GL11.glColor3f(1.0f,0.0f,0.0f); -- test
-		glSetForegroundColor(); // from
-		GL11.glVertex2i(x1, y1);
-		GL11.glVertex2i(x2, y1);
+		glSetRasterOffset(RasterOffset.POLYGON);
 
-		glSetBackgroundColor(); // to
-		// GL11.glColor3f(0.0f,1.0f,0.0f); -- test
-		GL11.glVertex2i(x2, y2);
-		GL11.glVertex2i(x1, y2);
-		GL11.glEnd();
+		IntBuffer shadeModel = Draw3DCache.getIntBuffer(1);
+		GL11.glGetInteger(GL11.GL_SHADE_MODEL, shadeModel);
+		GL11.glShadeModel(GL11.GL_SMOOTH);
+		try {
+			int x1 = i_x;
+			int y1 = i_y;
+			int x2 = i_x + i_width;
+			int y2 = i_y + i_height;
 
+			GL11.glBegin(GL11.GL_QUADS);
+			glSetForegroundColor(); // from
+			if (i_vertical) {
+				GL11.glVertex2i(x1, y1);
+				GL11.glVertex2i(x2, y1);
+			} else {
+				GL11.glVertex2i(x1, y2);
+				GL11.glVertex2i(x1, y1);
+			}
+
+			glSetBackgroundColor(); // to
+			if (i_vertical) {
+				GL11.glVertex2i(x2, y2);
+				GL11.glVertex2i(x1, y2);
+			} else {
+				GL11.glVertex2i(x2, y1);
+				GL11.glVertex2i(x2, y2);
+			}
+			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
+			if (shadeModel != null) {
+				GL11.glShadeModel(shadeModel.get(0));
+				Draw3DCache.returnIntBuffer(shadeModel);
+			}
+		}
 	}
 
 	/**
@@ -1440,11 +1526,15 @@
 		checkDisposed();
 
 		glSetBackgroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-
-		GL11.glBegin(GL11.GL_POLYGON);
-		glDrawPointList(i_points);
-		GL11.glEnd();
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+			GL11.glBegin(GL11.GL_POLYGON);
+			glDrawPointList(i_points);
+			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1458,11 +1548,15 @@
 		checkDisposed();
 
 		glSetBackgroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-
-		GL11.glBegin(GL11.GL_QUADS);
-		glDrawRectangle(i_x, i_y, i_width, i_height);
-		GL11.glEnd();
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+			GL11.glBegin(GL11.GL_QUADS);
+			glDrawRectangle(i_x, i_y, i_width, i_height);
+			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1478,11 +1572,15 @@
 		checkDisposed();
 
 		glSetBackgroundColor();
-		GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
-
-		GL11.glBegin(GL11.GL_POLYGON);
-		glDrawRoundRectangle(i_r, i_arcWidth, i_arcHeight);
-		GL11.glEnd();
+		glSetRasterOffset(RasterOffset.POLYGON);
+		try {
+			GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
+			GL11.glBegin(GL11.GL_POLYGON);
+			glDrawRoundRectangle(i_r, i_arcWidth, i_arcHeight);
+			GL11.glEnd();
+		} finally {
+			glResetRasterOffset();
+		}
 	}
 
 	/**
@@ -1885,6 +1983,31 @@
 		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) {
 
@@ -2041,8 +2164,17 @@
 			m_disposeFonts = true;
 		}
 
+		int antialias = getAntialias();
+		if (m_overrideTextAntialias != null) {
+			if (m_overrideTextAntialias)
+				antialias = SWT.ON;
+			else
+				antialias = SWT.OFF;
+		}
+
 		Font font = m_state.getFont();
-		return m_fontManager.getFont(font, (char) 32, (char) 127);
+		return m_fontManager.getFont(font, (char) 32, (char) 127,
+			antialias == SWT.ON);
 	}
 
 	private void glRestoreState(GraphicsState i_previous) {
@@ -2128,9 +2260,6 @@
 			GL11.glMatrixMode(GL11.GL_MODELVIEW);
 			GL11.glPushMatrix();
 			try {
-				// undo raster offset
-				GL11.glTranslatef(-RASTER_OFFSET, -RASTER_OFFSET, 0);
-
 				DoubleBuffer buffer = Draw3DCache.getDoubleBuffer(16);
 				try {
 					// left plane
@@ -2369,6 +2498,9 @@
 
 		checkDisposed();
 
+		if (i_degrees == 0)
+			return;
+
 		m_state.rotate(i_degrees);
 		GL11.glRotatef(i_degrees, 0, 0, 1);
 	}

Deleted: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphicsLog.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphicsLog.java	2009-11-05 14:37:28 UTC (rev 382)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/graphics/LwjglGraphicsLog.java	2009-11-05 14:38:00 UTC (rev 383)
@@ -1,1040 +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.graphics3d.lwjgl.graphics;
-
-import java.util.logging.FileHandler;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import org.eclipse.draw2d.geometry.PointList;
-import org.eclipse.draw2d.geometry.Rectangle;
-import org.eclipse.draw3d.graphics3d.lwjgl.font.LwjglFontManager;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Path;
-import org.eclipse.swt.graphics.Pattern;
-import org.eclipse.swt.graphics.TextLayout;
-
-/**
- * An extension of LwjglGraphics that logs all calls that change the
- * state of the graphics object.
- * 
- * @author Kristian Duske
- * @version $Revision$
- * @since 18.06.2008
- */
-public class LwjglGraphicsLog extends LwjglGraphics {
-
-	private final Logger log;
-
-	/**
-	 * @param i_width
-	 * @param i_height
-	 */
-	public LwjglGraphicsLog(int i_width, int i_height, LwjglFontManager fontManager) {
-
-		super(i_width, i_height, fontManager);
-
-		log = Logger.getLogger(LwjglGraphicsLog.class.getName());
-		log.setUseParentHandlers(false);
-
-		Handler[] handlers = log.getHandlers();
-		for (int i = 0; i &lt; handlers.length; i++)
-			log.removeHandler(handlers[i]);
-
-		try {
-			String logFile = &quot;/%h/logGraphics.%u.%g.log&quot;;
-			FileHandler handler = new FileHandler(logFile, true);
-			handler.setFormatter(new Formatter() {
-
-				@Override
-				public String format(LogRecord i_record) {
-
-					return i_record.getMessage() + &quot;\n&quot;;
-				}
-			});
-
-			log.addHandler(handler);
-		} catch (Exception ex) {
-			log.warning(ex.getMessage());
-			throw new RuntimeException(
-					&quot;caught exception while configuring LwjglGraphicsLog&quot;
-							+ ex);
-		}
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#clipRect(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public void clipRect(Rectangle i_r) {
-
-		log.info(&quot;clipRect(&quot; + newRectangle(i_r) + &quot;);&quot;);
-		super.clipRect(i_r);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#dispose()
-	 */
-	@Override
-	public void dispose() {
-
-		super.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) {
-
-		log.info(&quot;drawArc(&quot; + intArgs(i_x, i_y, i_w, i_h, i_offset, i_length)
-				+ &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawFocus(&quot; + intArgs(i_x, i_y, i_w, i_h) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawImage(&lt;image&gt;, &quot; + intArgs(i_x, i_y) + &quot;);&quot;);
-
-		super.drawImage(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) {
-
-		log.info(&quot;drawImage(&lt;image&gt;, &quot;
-				+ intArgs(i_x1, i_y1, i_w1, i_h1, i_x2, i_y2, i_w2, i_h2)
-				+ &quot;);&quot;);
-
-		super.drawImage(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) {
-
-		log.info(&quot;drawLine(&quot; + intArgs(i_x1, i_y1, i_x2, i_y2) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawOval(&quot; + intArgs(i_x, i_y, i_w, i_h) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawPath(&lt;path&gt;);&quot;);
-
-		super.drawPath(i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolygon(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void drawPolygon(PointList i_points) {
-
-		log.info(&quot;drawPolygon(&quot; + newPointList(i_points) + &quot;);&quot;);
-
-		super.drawPolygon(i_points);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#drawPolyline(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void drawPolyline(PointList i_points) {
-
-		log.info(&quot;drawPolyline(&quot; + newPointList(i_points) + &quot;);&quot;);
-
-		super.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) {
-
-		log
-				.info(&quot;drawRectangle(&quot; + intArgs(i_x, i_y, i_width, i_height)
-						+ &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawRoundRectangle(&quot; + newRectangle(i_r) + &quot;, &quot;
-				+ intArgs(i_arcWidth, i_arcHeight) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawString(&quot; + string(i_s) + &quot;, &quot; + intArgs(i_x, i_y) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;drawText(&quot; + string(i_s) + &quot;, &quot; + intArgs(i_x, i_y) + &quot;);&quot;);
-
-		super.drawText(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) {
-
-		log.info(&quot;drawText(&quot; + string(i_s) + &quot;, &quot; + intArgs(i_x, i_y, i_style)
-				+ &quot;);&quot;);
-
-		super.drawText(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) {
-
-		log.info(&quot;drawTextLayout(&lt;layout&gt;, &quot;
-				+ intArgs(i_x, i_y, i_selectionStart, i_selectionEnd) + &quot;, &quot;
-				+ newColor(i_selectionForeground) + &quot;, &quot;
-				+ newColor(i_selectionBackground) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillArc(&quot; + intArgs(i_x, i_y, i_w, i_h, i_offset, i_length)
-				+ &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillGradient(&quot; + intArgs(i_x, i_y, i_w, i_h) + &quot;, &quot;
-				+ i_vertical + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillOval(&quot; + intArgs(i_x, i_y, i_w, i_h) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillPath(&lt;path&gt;);&quot;);
-
-		super.fillPath(i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#fillPolygon(org.eclipse.draw2d.geometry.PointList)
-	 */
-	@Override
-	public void fillPolygon(PointList i_points) {
-
-		log.info(&quot;fillPolygon(&quot; + newPointList(i_points) + &quot;);&quot;);
-
-		super.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) {
-
-		log
-				.info(&quot;fillRectangle(&quot; + intArgs(i_x, i_y, i_width, i_height)
-						+ &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillRoundRectangle(&quot; + newRectangle(i_r) + &quot;, &quot;
-				+ intArgs(i_arcWidth, i_arcHeight) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillString(&quot; + string(i_s) + &quot;, &quot; + intArgs(i_x, i_y) + &quot;);&quot;);
-
-		super.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) {
-
-		log.info(&quot;fillText(&quot; + string(i_s) + &quot;, &quot; + intArgs(i_x, i_y) + &quot;);&quot;);
-
-		super.fillText(i_s, i_x, i_y);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics#getAlpha()
-	 */
-	@Override
-	public int getAlpha() {
-
-		return super.getAlpha();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getAntialias()
-	 */
-	@Override
-	public int getAntialias() {
-
-		return super.getAntialias();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getBackgroundColor()
-	 */
-	@Override
-	public Color getBackgroundColor() {
-
-		return super.getBackgroundColor();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getClip(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public Rectangle getClip(Rectangle i_rect) {
-
-		return super.getClip(i_rect);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFillRule()
-	 */
-	@Override
-	public int getFillRule() {
-
-		return super.getFillRule();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFont()
-	 */
-	@Override
-	public Font getFont() {
-
-		return super.getFont();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getFontMetrics()
-	 */
-	@Override
-	public FontMetrics getFontMetrics() {
-
-		return super.getFontMetrics();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getForegroundColor()
-	 */
-	@Override
-	public Color getForegroundColor() {
-
-		return super.getForegroundColor();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getInterpolation()
-	 */
-	@Override
-	public int getInterpolation() {
-
-		return super.getInterpolation();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineCap()
-	 */
-	@Override
-	public int getLineCap() {
-
-		return super.getLineCap();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineJoin()
-	 */
-	@Override
-	public int getLineJoin() {
-
-		return super.getLineJoin();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineStyle()
-	 */
-	@Override
-	public int getLineStyle() {
-
-		return super.getLineStyle();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getLineWidth()
-	 */
-	@Override
-	public int getLineWidth() {
-
-		return super.getLineWidth();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getTextAntialias()
-	 */
-	@Override
-	public int getTextAntialias() {
-
-		return super.getTextAntialias();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#getXORMode()
-	 */
-	@Override
-	public boolean getXORMode() {
-
-		return super.getXORMode();
-	}
-
-	private String intArgs(int... args) {
-
-		StringBuilder builder = new StringBuilder();
-
-		for (int i = 0; i &lt; args.length; i++) {
-			builder.append(args[i]);
-			if (i &lt; args.length - 1)
-				builder.append(&quot;, &quot;);
-		}
-
-		return builder.toString();
-	}
-
-	private String newColor(Color i_rgb) {
-
-		return &quot;new org.eclipse.swt.graphics.Color(display, &quot;
-				+ intArgs(i_rgb.getRed(), i_rgb.getGreen(), i_rgb.getBlue())
-				+ &quot;)&quot;;
-	}
-
-	private String newIntArray(int[] i_array) {
-
-		StringBuilder builder = new StringBuilder();
-
-		builder.append(&quot;(int[]) [&quot;);
-		for (int i = 0; i &lt; i_array.length; i++) {
-			builder.append(i_array[i]);
-			if (i &lt; i_array.length - 1)
-				builder.append(&quot;, &quot;);
-		}
-		builder.append(&quot;]&quot;);
-
-		return builder.toString();
-	}
-
-	private String newPointList(PointList i_points) {
-
-		StringBuilder builder = new StringBuilder();
-
-		builder.append(&quot;new org.eclipse.draw2d.geometry.PointList(&quot;);
-		builder.append(newIntArray(i_points.toIntArray()));
-		builder.append(&quot;)&quot;);
-
-		return builder.toString();
-	}
-
-	private String newRectangle(Rectangle i_r) {
-
-		return &quot;new org.eclipse.draw2d.geometry.Rectangle(&quot;
-				+ intArgs(i_r.x, i_r.y, i_r.width, i_r.height) + &quot;)&quot;;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#popState()
-	 */
-	@Override
-	public void popState() {
-
-		log.info(&quot;popState()&quot;);
-
-		super.popState();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#pushState()
-	 */
-	@Override
-	public void pushState() {
-
-		log.info(&quot;pushState();&quot;);
-
-		super.pushState();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#restoreState()
-	 */
-	@Override
-	public void restoreState() {
-
-		log.info(&quot;restoreState();&quot;);
-
-		super.restoreState();
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#rotate(float)
-	 */
-	@Override
-	public void rotate(float i_degrees) {
-
-		log.info(&quot;rotate(&quot; + i_degrees + &quot;f);&quot;);
-
-		super.rotate(i_degrees);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#scale(double)
-	 */
-	@Override
-	public void scale(double i_amount) {
-
-		log.info(&quot;scale(&quot; + i_amount + &quot;d);&quot;);
-
-		super.scale(i_amount);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#scale(float, float)
-	 */
-	@Override
-	public void scale(float i_horizontal, float i_vertical) {
-
-		log.info(&quot;scale(&quot; + i_horizontal + &quot;f, &quot; + i_vertical + &quot;f);&quot;);
-
-		super.scale(i_horizontal, i_vertical);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics#setAlpha(int)
-	 */
-	@Override
-	public void setAlpha(int i_alpha) {
-
-		log.info(&quot;setAlpha(&quot; + i_alpha + &quot;);&quot;);
-
-		super.setAlpha(i_alpha);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setAntialias(int)
-	 */
-	@Override
-	public void setAntialias(int i_value) {
-
-		log.info(&quot;setAntialias(&quot; + i_value + &quot;);&quot;);
-
-		super.setAntialias(i_value);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setBackgroundColor(Color i_rgb) {
-
-		log.info(&quot;setBackgroundColor(&quot; + newColor(i_rgb) + &quot;);&quot;);
-
-		super.setBackgroundColor(i_rgb);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setBackgroundPattern(org.eclipse.swt.graphics.Pattern)
-	 */
-	@Override
-	public void setBackgroundPattern(Pattern i_pattern) {
-
-		log.info(&quot;setBackgroundPattern(&lt;pattern&gt;);&quot;);
-
-		super.setBackgroundPattern(i_pattern);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.swt.graphics.Path)
-	 */
-	@Override
-	public void setClip(Path i_path) {
-
-		log.info(&quot;setClip(&lt;path&gt;);&quot;);
-
-		super.setClip(i_path);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setClip(org.eclipse.draw2d.geometry.Rectangle)
-	 */
-	@Override
-	public void setClip(Rectangle i_r) {
-
-		log.info(&quot;setClip(&quot; + newRectangle(i_r) + &quot;);&quot;);
-
-		super.setClip(i_r);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFillRule(int)
-	 */
-	@Override
-	public void setFillRule(int i_rule) {
-
-		log.info(&quot;setFillRule(&quot; + i_rule + &quot;);&quot;);
-
-		super.setFillRule(i_rule);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setFont(org.eclipse.swt.graphics.Font)
-	 */
-	@Override
-	public void setFont(Font i_f) {
-
-		FontData[] fontData = i_f.getFontData();
-
-		StringBuilder builder = new StringBuilder();
-		builder.append(&quot;new org.eclipse.swt.graphics.Font(display, &quot;);
-		builder.append(&quot;(org.eclipse.swt.graphics.FontData[]) [&quot;);
-		for (int i = 0; i &lt; fontData.length; i++) {
-			builder.append(&quot;new org.eclipse.swt.graphics.FontData(&quot;);
-			builder.append(string(fontData[i].getName()));
-			builder.append(&quot;, &quot;);
-			builder.append(fontData[i].getHeight());
-			builder.append(&quot;, &quot;);
-			builder.append(fontData[i].getStyle());
-			builder.append(&quot;)&quot;);
-			if (i &lt; fontData.length - 1)
-				builder.append(&quot;, &quot;);
-		}
-
-		builder.append(&quot;])&quot;);
-
-		log.info(&quot;setFont(&quot; + builder.toString() + &quot;);&quot;);
-
-		super.setFont(i_f);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setForegroundColor(org.eclipse.swt.graphics.Color)
-	 */
-	@Override
-	public void setForegroundColor(Color i_rgb) {
-
-		log.info(&quot;setForegroundColor(&quot; + newColor(i_rgb) + &quot;);&quot;);
-
-		super.setForegroundColor(i_rgb);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setForegroundPattern(org.eclipse.swt.graphics.Pattern)
-	 */
-	@Override
-	public void setForegroundPattern(Pattern i_pattern) {
-
-		log.info(&quot;setForegroundPattern(&lt;pattern&gt;);&quot;);
-
-		super.setForegroundPattern(i_pattern);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setInterpolation(int)
-	 */
-	@Override
-	public void setInterpolation(int i_interpolation) {
-
-		log.info(&quot;setInterpolation(&quot; + i_interpolation + &quot;);&quot;);
-
-		super.setInterpolation(i_interpolation);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineCap(int)
-	 */
-	@Override
-	public void setLineCap(int i_cap) {
-
-		log.info(&quot;setLineCap(&quot; + i_cap + &quot;);&quot;);
-
-		super.setLineCap(i_cap);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics#setLineDash(int[])
-	 */
-	@Override
-	public void setLineDash(int[] i_dash) {
-
-		log.info(&quot;setLineDash(&quot; + newIntArray(i_dash) + &quot;);&quot;);
-
-		super.setLineDash(i_dash);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineJoin(int)
-	 */
-	@Override
-	public void setLineJoin(int i_join) {
-
-		log.info(&quot;setLineJoin(&quot; + i_join + &quot;);&quot;);
-
-		super.setLineJoin(i_join);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineStyle(int)
-	 */
-	@Override
-	public void setLineStyle(int i_style) {
-
-		log.info(&quot;setLineStyle(&quot; + i_style + &quot;);&quot;);
-
-		super.setLineStyle(i_style);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setLineWidth(int)
-	 */
-	@Override
-	public void setLineWidth(int i_width) {
-
-		log.info(&quot;setLineWidth(&quot; + i_width + &quot;);&quot;);
-
-		super.setLineWidth(i_width);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setTextAntialias(int)
-	 */
-	@Override
-	public void setTextAntialias(int i_value) {
-
-		log.info(&quot;setTextAntialias(&quot; + i_value + &quot;);&quot;);
-
-		super.setTextAntialias(i_value);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#setXORMode(boolean)
-	 */
-	@Override
-	public void setXORMode(boolean i_b) {
-
-		log.info(&quot;setXORMode(&quot; + i_b + &quot;);&quot;);
-
-		super.setXORMode(i_b);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#shear(float, float)
-	 */
-	@Override
-	public void shear(float i_horz, float i_vert) {
-
-		log.info(&quot;shear(&quot; + i_horz + &quot;f, &quot; + i_vert + &quot;f);&quot;);
-
-		super.shear(i_horz, i_vert);
-	}
-
-	private String string(String i_str) {
-
-		return &quot;\&quot;&quot; + i_str + &quot;\&quot;&quot;;
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#translate(float, float)
-	 */
-	@Override
-	public void translate(float i_dx, float i_dy) {
-
-		log.info(&quot;translate(&quot; + i_dx + &quot;f, &quot; + i_dy + &quot;f);&quot;);
-
-		super.translate(i_dx, i_dy);
-	}
-
-	/**
-	 * {@inheritDoc}
-	 * 
-	 * @see org.eclipse.draw2d.Graphics#translate(int, int)
-	 */
-	@Override
-	public void translate(int i_dx, int i_dy) {
-
-		log.info(&quot;translate(&quot; + intArgs(i_dx, i_dy) + &quot;);&quot;);
-
-		super.translate(i_dx, i_dy);
-	}
-
-}


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:38:00 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00228.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r382 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00227.html</link>
		<description>Author: kduske Date: 2009-11-05 09:37:28 -0500 (Thu, 05 Nov 2009) New Revision: 382 Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphic...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:37:28 -0500 (Thu, 05 Nov 2009)
New Revision: 382

Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
Log:
- added support for antialiased and non-antialiased 2D fonts


Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-05 14:37:07 UTC (rev 381)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFont.java	2009-11-05 14:37:28 UTC (rev 382)
@@ -87,9 +87,12 @@
 	 * @param i_font the SWT font to render
 	 * @param i_startChar the first available character
 	 * @param i_endChar the last available character
+	 * @param i_antiAliased whether or not the font should be rendered with
+	 *            antialiasing
 	 * @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) {
+	public LwjglFont(Font i_font, char i_startChar, char i_endChar,
+			boolean i_antiAliased) {
 
 		if (i_font == null)
 			throw new NullPointerException(&quot;i_font must not be null&quot;);
@@ -143,6 +146,7 @@
 			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));
@@ -242,6 +246,9 @@
 				builder.append(&quot;, &quot;);
 		}
 
+		builder.append(&quot;, Antialiasing: &quot;);
+		builder.append(i_antiAliased);
+
 		m_description = builder.toString();
 	}
 

Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java
===================================================================
--- trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-05 14:37:07 UTC (rev 381)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/font/LwjglFontManager.java	2009-11-05 14:37:28 UTC (rev 382)
@@ -29,49 +29,21 @@
 public class LwjglFontManager {
 
 	/**
-	 * The font manager is created by the texture manager 
-	 * ({@link LwjglTextureManager}), this class should not be created by
-	 * other classes.
+	 * The font manager is created by the texture manager (
+	 * {@link LwjglTextureManager}), this class should not be created by other
+	 * classes.
 	 */
 	public LwjglFontManager() {
+
+		// nothing to initliaze
 	}
-	
-	
-//	/**
-//	 * The font manager instance which is shared between all graphics instances
-//	 * created within the same thread.
-//	 */
-//	private static final ThreadLocal&lt;LwjglFontManager&gt; fontManager = new ThreadLocal&lt;LwjglFontManager&gt;() {
-//		/**
-//		 * {@inheritDoc}
-//		 * 
-//		 * @see java.lang.ThreadLocal#initialValue()
-//		 */
-//		@Override
-//		protected LwjglFontManager initialValue() {
-//
-//			return new LwjglFontManager();
-//		}
-//	};
-//
-//	/**
-//	 * Gets the thread's font manager instance.
-//	 * 
-//	 * @return
-//	 */
-//	public static LwjglFontManager getFontManager() {
-//		return fontManager.get();
-//	}
-//
+
 	/**
 	 * Key for the font map.
 	 * 
 	 * @author Kristian Duske
 	 * @version $Revision$
 	 * @since 10.06.2008
-	 * @see $HeadURL:
-	 *      <a  href="https://gorgo.fernuni-hagen.de/OpenglGEF/trunk/org.eclipse">https://gorgo.fernuni-hagen.de/OpenglGEF/trunk/org.eclipse</a>.
-	 *      draw3d/src/java/de/feu/draw3d/font/LwjglFontManager.java $
 	 */
 	private class GLFontKey {
 
@@ -83,17 +55,22 @@
 		 * @param i_font the font
 		 * @param i_startChar the start character
 		 * @param i_endChar the end character
+		 * @param i_antiAliased whether or not the font is antialiased
 		 */
-		public GLFontKey(Font i_font, char i_startChar, char i_endChar) {
+		public GLFontKey(Font i_font, char i_startChar, char i_endChar,
+				boolean i_antiAliased) {
 
 			m_hashCode = 17;
 			m_hashCode = 37 * m_hashCode + i_font.hashCode();
-			m_hashCode = 37 * m_hashCode + i_startChar;
-			m_hashCode = 37 * m_hashCode + i_endChar;
+			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 = 37 * fontData.hashCode();
+				m_hashCode = m_hashCode + 37 * fontData.hashCode();
 		}
 
 		/**
@@ -130,12 +107,13 @@
 	}
 
 	@SuppressWarnings(&quot;unused&quot;)
-	private static final Logger log = Logger.getLogger(LwjglFontManager.class
-			.getName());
+	private static final Logger log =
+		Logger.getLogger(LwjglFontManager.class.getName());
 
 	private boolean m_disposed = false;
 
-	private Map&lt;GLFontKey, LwjglFont&gt; m_fonts = new HashMap&lt;GLFontKey, LwjglFont&gt;();
+	private Map&lt;GLFontKey, LwjglFont&gt; m_fonts =
+		new HashMap&lt;GLFontKey, LwjglFont&gt;();
 
 	/**
 	 * Disposes all managed fonts.
@@ -158,10 +136,13 @@
 	 * @param i_font the SWT font
 	 * @param i_startChar the start character
 	 * @param i_endChar the end character
+	 * @param i_antiAliased whether or not the font should be rendered with
+	 *            antialiasing
 	 * @return the GL font
 	 * @throws NullPointerException if the given SWT font is &lt;code&gt;null&lt;/code&gt;
 	 */
-	public LwjglFont getFont(Font i_font, char i_startChar, char i_endChar) {
+	public LwjglFont getFont(Font i_font, char i_startChar, char i_endChar,
+		boolean i_antiAliased) {
 
 		if (m_disposed)
 			throw new IllegalStateException(&quot;font manager is disposed&quot;);
@@ -169,10 +150,12 @@
 		if (i_font == null)
 			throw new NullPointerException(&quot;i_font must not be null&quot;);
 
-		GLFontKey key = new GLFontKey(i_font, i_startChar, i_endChar);
+		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);
+			glFont =
+				new LwjglFont(i_font, i_startChar, i_endChar, i_antiAliased);
 			m_fonts.put(key, glFont);
 		}
 
@@ -190,8 +173,7 @@
 		StringBuilder builder = new StringBuilder();
 
 		builder.append(&quot;LwjglFontManager [&quot;);
-		for (Iterator&lt;LwjglFont&gt; iter = m_fonts.values().iterator(); iter
-				.hasNext();) {
+		for (Iterator&lt;LwjglFont&gt; iter = m_fonts.values().iterator(); iter.hasNext();) {
 			LwjglFont glFont = iter.next();
 
 			builder.append(&quot;Font: &quot;);


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:37:29 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00227.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r381 -	trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00226.html</link>
		<description>Author: kduske Date: 2009-11-05 09:37:07 -0500 (Thu, 05 Nov 2009) New Revision: 381 Modified: trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java Log: - override font antialiasing in LWJGLGraphics if a property ...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:37:07 -0500 (Thu, 05 Nov 2009)
New Revision: 381

Modified:
   trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java
Log:
- override font antialiasing in LWJGLGraphics if a property has been set


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-05 14:36:11 UTC (rev 380)
+++ trunk/org.eclipse.draw3d.lwjgl/src/java/org/eclipse/draw3d/graphics3d/lwjgl/Graphics3DLwjgl.java	2009-11-05 14:37:07 UTC (rev 381)
@@ -24,6 +24,7 @@
 import org.eclipse.draw3d.graphics3d.Graphics3DException;
 import org.eclipse.draw3d.graphics3d.Graphics3DOffscreenBufferConfig;
 import org.eclipse.draw3d.graphics3d.Graphics3DOffscreenBuffers;
+import org.eclipse.draw3d.graphics3d.lwjgl.graphics.LwjglGraphics;
 import org.eclipse.draw3d.graphics3d.lwjgl.offscreen.LwjglOffscreenBackBuffers;
 import org.eclipse.draw3d.graphics3d.lwjgl.offscreen.LwjglOffscreenBufferConfig;
 import org.eclipse.draw3d.graphics3d.lwjgl.offscreen.LwjglOffscreenBuffersFbo;
@@ -109,10 +110,20 @@
 		textureManager.activateTexture(i_key);
 		textureManager.clearTexture(i_key, i_color, i_alpha);
 
+		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);
+		}
+
 		if (m_log2D)
-			return new LogGraphics(textureManager.getGraphics());
-		else
-			return textureManager.getGraphics();
+			graphics = new LogGraphics(graphics);
+
+		return graphics;
 	}
 
 	/**


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:37:09 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00226.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r380 -	trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00225.html</link>
		<description>Author: kduske Date: 2009-11-05 09:36:11 -0500 (Thu, 05 Nov 2009) New Revision: 380 Modified: trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java Log: - minor changes Modified: trunk/org.eclipse.draw3d.graphics3d/src/...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:36:11 -0500 (Thu, 05 Nov 2009)
New Revision: 380

Modified:
   trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java
Log:
- minor changes


Modified: trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java
===================================================================
--- trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java	2009-11-05 14:36:04 UTC (rev 379)
+++ trunk/org.eclipse.draw3d.graphics3d/src/java/org/eclipse/draw3d/graphics3d/Graphics3D.java	2009-11-05 14:36:11 UTC (rev 380)
@@ -36,25 +36,33 @@
 public interface Graphics3D extends Graphics3DDraw, Graphics3DUtil {
 
 	/**
+	 * Property name for the font antialias property. Possible values are:
+	 * &lt;ul&gt;
+	 * &lt;li&gt;&lt;code&gt;Boolean.toString(true)&lt;/code&gt; to always enable font
+	 * antialiasing&lt;/li&gt;
+	 * &lt;li&gt;&lt;code&gt;Boolean.toString(false)&lt;/code&gt; to always diable font
+	 * antialiasing&lt;/li&gt;
+	 * &lt;li&gt;&lt;code&gt;null&lt;/code&gt; to let the embedded editors control font
+	 * antialiasing&lt;/li&gt;
+	 * &lt;/ul&gt;
+	 */
+	public static final String PROP_FONT_AA = &quot;fontAntialias&quot;;
+
+	/**
 	 * Activates a graphics object which will receive all following draw
 	 * operations. If a graphics object was already created for the given key
 	 * object (which can e.g. be a figure), it will be re-used.
 	 * 
-	 * @param i_key
-	 *            Object associated respective to associate with the activated
+	 * @param i_key Object associated respective to associate with the activated
 	 *            graphics objects.
-	 * @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.
+	 * @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);
+		int i_alpha, Color i_color);
 
 	/**
 	 * Deactivates the active graphics object.
@@ -76,43 +84,36 @@
 	/**
 	 * Gets an ID for the graphics object associated with the given key object.
 	 * 
-	 * @param i_key
-	 *            The key object.
+	 * @param i_key The key object.
 	 * @return The ID of the graphics object associated with the key object.
-	 * @throws IllegalArgumentException
-	 *             If there is no graphics object associated with the key object
-	 *             yet.
+	 * @throws IllegalArgumentException If there is no graphics object
+	 *             associated with the key object yet.
 	 */
 	public int getGraphics2DId(Object i_key);
 
 	/**
 	 * Creates an offscreen buffer for the current rendering implementation.
 	 * 
-	 * @param i_height
-	 *            The height of the buffer
-	 * @param i_width
-	 *            The width of the buffer
-	 * @param i_bufferConfig
-	 *            The configuration for the buffer
+	 * @param i_height The height of the buffer
+	 * @param i_width The width of the buffer
+	 * @param i_bufferConfig The configuration for the buffer
 	 * @return A new offscreen buffer instance
 	 */
 	public Graphics3DOffscreenBuffers getGraphics3DOffscreenBuffer(
-			int i_height, int i_width,
-			Graphics3DOffscreenBufferConfig i_bufferConfig);
+		int i_height, int i_width,
+		Graphics3DOffscreenBufferConfig i_bufferConfig);
 
 	/**
 	 * Creates a configuration for an offscreen buffer. This object may be used
 	 * either to create an offscreen buffer immediately or may be saved to
 	 * create several offscreen buffers of the same type.
 	 * 
-	 * @param i_buffers
-	 *            Determines which buffer possibilities to use.
-	 * @param i_args
-	 *            Arguments for the buffer
+	 * @param i_buffers Determines which buffer possibilities to use.
+	 * @param i_args Arguments for the buffer
 	 * @return The created offscreen buffer configuration instance.
 	 */
 	public Graphics3DOffscreenBufferConfig getGraphics3DOffscreenBufferConfig(
-			int i_buffers, int... i_args);
+		int i_buffers, int... i_args);
 
 	/**
 	 * Returns the ID of the Graphics3D instance, e.g. the class name. This ID
@@ -134,8 +135,7 @@
 	 * Returns whether there is a graphics object associate with the given key
 	 * object.
 	 * 
-	 * @param i_key
-	 *            The key object.
+	 * @param i_key The key object.
 	 * @return &lt;code&gt;true&lt;/code&gt; if there was a graphics object associated to
 	 *         the key obect previously or &lt;code&gt;false&lt;/code&gt; otherwise
 	 */
@@ -156,8 +156,7 @@
 	/**
 	 * Enables logging of 2D drawing operations.
 	 * 
-	 * @param i_log2D
-	 *            &lt;code&gt;true&lt;/code&gt; if 2D logging should be enabled and
+	 * @param i_log2D &lt;code&gt;true&lt;/code&gt; if 2D logging should be enabled and
 	 *            &lt;code&gt;false&lt;/code&gt; otherwise
 	 */
 	public void setLog2D(boolean i_log2D);


</pre>]]></content:encoded>
		<pubDate>Thu, 05 Nov 2009 14:36:11 GMT</pubDate>
		<guid isPermaLink="true">http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00225.html</guid>
		<author>genie@xxxxxxx (genie)</author>
	</item>
	<item>
		<title>[gef3d-commits] r379 -	trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d</title>
		<link>http://dev.eclipse.org/mhonarc/lists/gef3d-commits/msg00224.html</link>
		<description>Author: kduske Date: 2009-11-05 09:36:04 -0500 (Thu, 05 Nov 2009) New Revision: 379 Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/IScene.java trunk/org.eclipse.draw3d...</description>
		<content:encoded><![CDATA[<pre>Author: kduske
Date: 2009-11-05 09:36:04 -0500 (Thu, 05 Nov 2009)
New Revision: 379

Modified:
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/IScene.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
   trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java
Log:
- added boolean flag to IScene.render that forces a redraw of all 2D content
- added support for specifying whether 2D text should be antialiased


Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-10-24 16:11:36 UTC (rev 378)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/Figure3DHelper.java	2009-11-05 14:36:04 UTC (rev 379)
@@ -471,34 +471,26 @@
 
 			RenderContext renderContext = figure.getRenderContext();
 
+			Rectangle bounds = figure.getBounds();
+			int width = bounds.width;
+			int height = bounds.height;
+
 			boolean repaint2D =
-				m_figuresFriend.is2DContentDirty()
-					&amp;&amp; !figure.getBounds().isEmpty();
+				(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;
 
 			Graphics graphics = i_graphics;
 			if (repaint2D) {
 
 				Graphics3D g3d = renderContext.getGraphics3D();
-				Rectangle bounds = figure.getBounds();
 
 				Graphics textureGraphics =
-					g3d.activateGraphics2D(figure, bounds.width, bounds.height,
+					g3d.activateGraphics2D(figure, width, height,
 						figure.getAlpha(), figure.getBackgroundColor());
 
-				/*
-				 * if (!textureManager.contains(figure)) {
-				 * textureManager.createTexture(figure, bounds.width,
-				 * bounds.height); } else { textureManager.resizeTexture(figure,
-				 * bounds.width, bounds.height); }
-				 * textureManager.activateTexture(figure);
-				 * textureManager.clearTexture(figure,
-				 * figure.getBackgroundColor(), figure.getAlpha()); Graphics
-				 * textureGraphics = textureManager.getGraphics(); Graphics
-				 * textureGraphics = g3d.activateGraphics2D(figure,
-				 * bounds.width, bounds.height, figure.getAlpha(), figure
-				 * .getBackgroundColor());
-				 */
-
 				Font font = i_graphics.getFont();
 				textureGraphics.setFont(font);
 

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/IScene.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/IScene.java	2009-10-24 16:11:36 UTC (rev 378)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/IScene.java	2009-11-05 14:36:04 UTC (rev 379)
@@ -25,6 +25,28 @@
 public interface IScene {
 
 	/**
+	 * Enumerates the options for 2D font antialiasing.
+	 * 
+	 * @author Kristian Duske
+	 * @version $Revision$
+	 * @since 03.11.2009
+	 */
+	public enum FontAntialias {
+		/**
+		 * 2D font antialiasing is determined by the embedded editor.
+		 */
+		EDITOR,
+		/**
+		 * 2D font antialiasing is always off.
+		 */
+		OFF,
+		/**
+		 * 2D font antialiasing is always on.
+		 */
+		ON
+	}
+
+	/**
 	 * Adds the given listener to this scene. If the given listener is already
 	 * registered with this scene, nothing happens.
 	 * 
@@ -72,8 +94,10 @@
 
 	/**
 	 * Instructs the scene to render itself.
+	 * 
+	 * @param i_redraw2D if &lt;code&gt;true&lt;/code&gt;, all 2D content will be redrawn
 	 */
-	public void render();
+	public void render(boolean i_redraw2D);
 
 	/**
 	 * Sets the background color of this scene.
@@ -104,4 +128,12 @@
 	 *            &lt;code&gt;false&lt;/code&gt; otherwise
 	 */
 	public void setDrawAxes(boolean i_drawAxes);
+
+	/**
+	 * Specifies how 2D font antialiasing should be handled in this scene.
+	 * 
+	 * @param i_antialias the antialias value
+	 * @see FontAntialias
+	 */
+	public void setFontAntialias(FontAntialias i_antialias);
 }
\ No newline at end of file

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-10-24 16:11:36 UTC (rev 378)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/LightweightSystem3D.java	2009-11-05 14:36:04 UTC (rev 379)
@@ -671,7 +671,7 @@
 		// updateManager.addDirtyRegion(getRootFigure(), 0, 0, 1000, 10000);
 		// updateManager.performUpdate();
 
-		render();
+		render(false);
 	}
 
 	/**
@@ -801,10 +801,14 @@
 	/**
 	 * {@inheritDoc}
 	 * 
-	 * @see org.eclipse.draw3d.IScene#render()
+	 * @see org.eclipse.draw3d.IScene#render(boolean)
 	 */
-	public void render() {
+	public void render(boolean i_redraw2d) {
 
+		if (i_redraw2d)
+			m_renderContext.setRedraw2DContent();
+
+		getUpdateManager().addInvalidFigure(getRootFigure());
 		getUpdateManager().performUpdate();
 	}
 
@@ -920,6 +924,29 @@
 	/**
 	 * {@inheritDoc}
 	 * 
+	 * @see org.eclipse.draw3d.IScene#setFontAntialias(org.eclipse.draw3d.IScene.FontAntialias)
+	 */
+	public void setFontAntialias(FontAntialias i_antialias) {
+
+		switch (i_antialias) {
+		case ON:
+			m_renderContext.getGraphics3D().setProperty(
+				Graphics3D.PROP_FONT_AA, Boolean.toString(true));
+			break;
+		case OFF:
+			m_renderContext.getGraphics3D().setProperty(
+				Graphics3D.PROP_FONT_AA, Boolean.toString(false));
+			break;
+		default:
+			m_renderContext.getGraphics3D().setProperty(
+				Graphics3D.PROP_FONT_AA, null);
+			break;
+		}
+	}
+
+	/**
+	 * {@inheritDoc}
+	 * 
 	 * @see org.eclipse.draw2d.LightweightSystem#setUpdateManager(org.eclipse.draw2d.UpdateManager)
 	 */
 	@Override

Modified: trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java
===================================================================
--- trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java	2009-10-24 16:11:36 UTC (rev 378)
+++ trunk/org.eclipse.draw3d/src/java/org/eclipse/draw3d/RenderContext.java	2009-11-05 14:36:04 UTC (rev 379)
@@ -49,6 +49,8 @@
 
 	private Graphics3D m_g3d = null;
 
+	private boolean m_redraw2DContent;
+
 	private Map&lt;RenderType, List&lt;RenderFragment&gt;&gt; m_renderFragments =
 		new HashMap&lt;RenderType, List&lt;RenderFragment&gt;&gt;();
 
@@ -102,6 +104,7 @@
 		m_renderFragments.clear();
 		// m_displayListManagers.clear();
 		m_scene = null;
+		m_redraw2DContent = false;
 	}
 
 	/**
@@ -176,6 +179,17 @@
 	}
 
 	/**
+	 * Indicates whether 2D content should be redrawn.
+	 * 
+	 * @return &lt;code&gt;true&lt;/code&gt; if 2D content should be redrawn and
+	 *         &lt;code&gt;false&lt;/code&gt; otherwise
+	 */
+	public boolean isRedraw2DContent() {
+
+		return m_redraw2DContent;
+	}
+
+	/**
 	 * Renders all render fragments.
 	 */
 	public void renderFragments() {
@@ -222,6 +236,15 @@
 	}
 
 	/**
+	 * Calling this method forces all 2D content to be redrawn during the next
+	 * render pass.
+	 */
+	public void setRedraw2DContent() {
+
+		m_redraw2DContent = true;
+	}
+
+	/**
 	 * Sets the scene
 	 * 
 	 * @param i_scene the scene


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

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