harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apetre...@apache.org
Subject svn commit: r553164 - in /harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common: java/awt/ToolkitImpl.java org/apache/harmony/awt/gl/CommonGraphics2DFactory.java org/apache/harmony/awt/wtk/GraphicsFactory.java
Date Wed, 04 Jul 2007 10:54:27 GMT
Author: apetrenko
Date: Wed Jul  4 03:54:26 2007
New Revision: 553164

URL: http://svn.apache.org/viewvc?view=rev&rev=553164
Log:
Patch for HARMONY-3719 "Graphics.getFontMetrics() throws HeadlessExcetion if headless"

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java?view=diff&rev=553164&r1=553163&r2=553164
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/ToolkitImpl.java
Wed Jul  4 03:54:26 2007
@@ -31,6 +31,7 @@
 import java.util.Hashtable;
 import java.util.Map;
 import java.util.Properties;
+import org.apache.harmony.awt.gl.font.FontMetricsImpl;
 import org.apache.harmony.awt.datatransfer.DTK;
 import org.apache.harmony.awt.gl.*;
 import org.apache.harmony.awt.gl.image.*;
@@ -38,6 +39,8 @@
 class ToolkitImpl extends Toolkit {
     static final Hashtable<Serializable, Image> imageCache = new Hashtable<Serializable,
Image>();
 
+    static final FontMetrics cacheFM[] =  new FontMetrics[10];
+
     @Override
     public void sync() {
         lockAWT();
@@ -126,13 +129,37 @@
         }
     }
 
+    /**
+     * Returns FontMetrics object that keeps metrics of the specified font.
+     * 
+     * @param font specified Font
+     * @return FontMetrics object corresponding to the specified Font object
+     */
     @SuppressWarnings("deprecation")
     @Override
     @Deprecated
     public FontMetrics getFontMetrics(Font font) {
         lockAWT();
         try {
-            return getGraphicsFactory().getFontMetrics(font);
+            FontMetrics fm;
+            for (FontMetrics element : cacheFM) {
+                fm = element;
+                if (fm == null){
+                    break;
+                }
+
+                if (fm.getFont().equals(font)){
+                    return fm;
+                }
+            }
+            fm = new FontMetricsImpl(font);
+
+            System.arraycopy(cacheFM, 0, cacheFM, 1, cacheFM.length -1);
+            cacheFM[0] = fm;
+
+            return fm;
+
+//            return getGraphicsFactory().getFontMetrics(font);
         } finally {
             unlockAWT();
         }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java?view=diff&rev=553164&r1=553163&r2=553164
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/CommonGraphics2DFactory.java
Wed Jul  4 03:54:26 2007
@@ -24,7 +24,6 @@
 import java.awt.FontMetrics;
 import java.awt.peer.FontPeer;
 
-import org.apache.harmony.awt.gl.font.FontMetricsImpl;
 import org.apache.harmony.awt.wtk.GraphicsFactory;
 
 /**
@@ -36,33 +35,7 @@
     // static instance of CommonGraphics2DFactory
     public static CommonGraphics2DFactory inst;
 
-    /**
-     * Returns FontMetrics object that keeps metrics of the specified font.
-     * 
-     * @param font specified Font
-     * @return FontMetrics object corresponding to the specified Font object
-     */
-    public FontMetrics getFontMetrics(Font font) {
-        FontMetrics fm;
-        for (FontMetrics element : cacheFM) {
-            fm = element;
-            if (fm == null){
-                break;
-            }
-
-            if (fm.getFont().equals(font)){
-                return fm;
-            }
-        }
-        fm = new FontMetricsImpl(font);
-
-        System.arraycopy(cacheFM, 0, cacheFM, 1, cacheFM.length -1);
-        cacheFM[0] = fm;
-
-        return fm;
-    }
     // Font methods
-
     public FontPeer getFontPeer(Font font) {
         return getFontManager().getFontPeer(font.getName(), font.getStyle(), font.getSize());
     }

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java?view=diff&rev=553164&r1=553163&r2=553164
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/wtk/GraphicsFactory.java
Wed Jul  4 03:54:26 2007
@@ -34,7 +34,6 @@
  * and font stuff instances factories.
  */
 public interface GraphicsFactory {
-    static final FontMetrics cacheFM[] =  new FontMetrics[10];
     
     /**
      * This method creates Graphics2D instance for specified native window.
@@ -70,7 +69,6 @@
     GraphicsEnvironment createGraphicsEnvironment(WindowFactory wf);
     
     // Font methods
-    FontMetrics getFontMetrics(Font font);
     FontManager getFontManager();
     FontPeer getFontPeer(Font font);
     Font embedFont(String fontFilePath);



Mime
View raw message