From 2330ed8aafa2e100b7f0f1642b6b3101924f6cbb Mon Sep 17 00:00:00 2001
From: Kenneth Russel <kbrussel@alum.mit.edu>
Date: Sun, 11 Feb 2007 01:13:40 +0000
Subject: Added setColor(Color) convenience method

git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@1126 232f8b59-042b-4e1e-8c03-345bb8c30851
---
 src/classes/com/sun/opengl/util/j2d/TextRenderer.java | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

(limited to 'src/classes/com/sun/opengl')

diff --git a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
index 0ad84c90c..d5afc3d82 100755
--- a/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
+++ b/src/classes/com/sun/opengl/util/j2d/TextRenderer.java
@@ -281,6 +281,22 @@ public class TextRenderer {
     beginRendering(false, 0, 0);
   }
 
+  private float[] compArray;
+  /** Changes the current color of this TextRenderer to the supplied
+      one. The default color is opaque white.
+
+      @param color the new color to use for rendering text
+      @throws GLException If an OpenGL context is not current when this method is called
+  */
+  public void setColor(Color color) throws GLException {
+    // Get color's RGBA components as floats in the range [0,1].
+    if (compArray == null) {
+      compArray = new float[4];
+    }
+    color.getRGBComponents(compArray);
+    setColor(compArray[0], compArray[1], compArray[2], compArray[3]);
+  }
+
   /** Changes the current color of this TextRenderer to the supplied
       one, where each component ranges from 0.0f - 1.0f. The alpha
       component, if used, does not need to be premultiplied into the
-- 
cgit v1.2.3