Added the default implementation for all the stubbed functions in the
abstract GlyphVector class.

2006-05-19  Lillian Angel  <[EMAIL PROTECTED]>

        * java/awt/font/GlyphVector.java
        (getGlyphCharIndex): Implemented.
        (getGlyphCharIndices): Implemented.
        (getGlyphOutline): Implemented.
        (getGlyphVisualBounds): Implemented.
        (getGlyphVisualBounds): Implemented.
        (getPixelBounds): Implemented.
        (getLayoutFlags): Implemented.

Index: java/awt/font/GlyphVector.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/awt/font/GlyphVector.java,v
retrieving revision 1.3
diff -u -r1.3 GlyphVector.java
--- java/awt/font/GlyphVector.java	22 Mar 2006 19:15:24 -0000	1.3
+++ java/awt/font/GlyphVector.java	19 May 2006 14:27:45 -0000
@@ -38,8 +38,6 @@
 
 package java.awt.font;
 
-import gnu.classpath.NotImplementedException;
-
 import java.awt.Font;
 import java.awt.Rectangle;
 import java.awt.Shape;
@@ -48,6 +46,7 @@
 import java.awt.geom.Rectangle2D;
 
 /**
+ * @author Lillian Angel (langel at redhat dot com)
  * @author Michael Koch
  */
 public abstract class GlyphVector implements Cloneable
@@ -72,16 +71,22 @@
   public abstract FontRenderContext getFontRenderContext ();
     
   public int getGlyphCharIndex (int glyphIndex)
-    throws NotImplementedException
   {
-    throw new Error ("not implemented");
+    return glyphIndex;
   }
     
-  public int[] getGlyphCharIndices (int beginGlyphIndex, int numEntries,
-                                    int[] codeReturn)
-    throws NotImplementedException
+  public int[] getGlyphCharIndices(int beginGlyphIndex, int numEntries,
+                                   int[] codeReturn)
   {
-    throw new Error ("not implemented");
+    if (codeReturn == null)
+      codeReturn = new int[numEntries];
+
+    int i = 0;
+    int j = beginGlyphIndex;
+    while (j < numEntries)
+      codeReturn[i++] = getGlyphCharIndex(j++);
+    
+    return codeReturn;
   }
     
   public abstract int getGlyphCode (int glyphIndex);
@@ -98,17 +103,27 @@
 
   public abstract Shape getGlyphOutline (int glyphIndex);
 
-  public Shape getGlyphOutline (int glyphIndex, float x, float y)
-    throws NotImplementedException
+  public Shape getGlyphOutline(int glyphIndex, float x, float y)
   {
-    throw new Error ("not implemented");
+    Shape s = getGlyphOutline(glyphIndex);
+    
+    // This is the only way to translate the origin of a shape
+    AffineTransform at = AffineTransform.getTranslateInstance(x, y);
+    return at.createTransformedShape(s);
   }
 
-  public Rectangle getGlyphPixelBounds (int index, FontRenderContext renderFRC,
-                                        float x, float y)
-    throws NotImplementedException
+  public Rectangle getGlyphPixelBounds(int index, FontRenderContext renderFRC,
+                                       float x, float y)
   {
-    throw new Error ("not implemented");
+    Rectangle bounds = new Rectangle();
+    Rectangle2D rect = getGlyphVisualBounds(index).getBounds2D();
+    
+    bounds.x = (int) (rect.getX() + x);
+    bounds.y = (int) (rect.getY() + y);
+    bounds.width = (int) rect.getMaxX() - bounds.x;
+    bounds.height = (int) rect.getMaxY() - bounds.y;
+    
+    return bounds;
   }
 
   public abstract Point2D getGlyphPosition (int glyphIndex);
@@ -121,10 +136,9 @@
 
   public abstract Shape getGlyphVisualBounds (int glyphIndex);
 
-  public int getLayoutFlags ()
-    throws NotImplementedException
+  public int getLayoutFlags()
   {
-    throw new Error ("not implemented");
+    return 0;
   }
 
   public abstract Rectangle2D getLogicalBounds ();
@@ -137,9 +151,16 @@
 
   public Rectangle getPixelBounds (FontRenderContext renderFRC,
                                    float x, float y)
-    throws NotImplementedException
   {
-    throw new Error ("not implemented");
+    Rectangle bounds = new Rectangle();
+    Rectangle2D rect = getVisualBounds();
+    
+    bounds.x = (int) (rect.getX() + x);
+    bounds.y = (int) (rect.getY() + y);
+    bounds.width = (int) rect.getMaxX() - bounds.x;
+    bounds.height = (int) rect.getMaxY() - bounds.y;
+    
+    return bounds;
   }
 
   public abstract Rectangle2D getVisualBounds ();

Reply via email to