You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2010/04/15 16:17:14 UTC

svn commit: r934422 - in /pivot/trunk: wtk-terra/src/org/apache/pivot/wtk/skin/terra/ wtk/src/org/apache/pivot/wtk/ wtk/src/org/apache/pivot/wtk/effects/ wtk/src/org/apache/pivot/wtk/media/drawing/ wtk/src/org/apache/pivot/wtk/skin/

Author: gbrown
Date: Thu Apr 15 14:17:14 2010
New Revision: 934422

URL: http://svn.apache.org/viewvc?rev=934422&view=rev
Log:
Fix for PIVOT-393.

Modified:
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
    pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Text.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
    pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraMeterSkin.java Thu Apr 15 14:17:14 2010
@@ -50,7 +50,6 @@ public class TerraMeterSkin extends Comp
     private Color textColor;
     private Color textFillColor;
 
-    private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, false);
     private static final int DEFAULT_WIDTH = 100;
     private static final int DEFAULT_HEIGHT = 12;
 
@@ -88,7 +87,8 @@ public class TerraMeterSkin extends Comp
 
             if (text != null
                 && text.length() > 0) {
-                Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
                 preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;
             } else {
                 preferredWidth = 0;
@@ -117,7 +117,8 @@ public class TerraMeterSkin extends Comp
 
             if (text != null
                 && text.length() > 0) {
-                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                LineMetrics lm = font.getLineMetrics("", fontRenderContext);
                 preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
             } else {
                 preferredHeight = 0;
@@ -140,10 +141,11 @@ public class TerraMeterSkin extends Comp
         int preferredHeight = 0;
         if (text != null
             && text.length() > 0) {
-            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
             preferredWidth = (int)Math.ceil(stringBounds.getWidth()) + 2;
 
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             preferredHeight = (int)Math.ceil(lm.getHeight()) + 2;
         }
 
@@ -172,7 +174,8 @@ public class TerraMeterSkin extends Comp
 
             if (text != null
                 && text.length() > 0) {
-                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                LineMetrics lm = font.getLineMetrics("", fontRenderContext);
                 float ascent = lm.getAscent();
                 float textHeight = lm.getHeight();
 
@@ -198,15 +201,11 @@ public class TerraMeterSkin extends Comp
         graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
             RenderingHints.VALUE_ANTIALIAS_ON);
 
-        if (FONT_RENDER_CONTEXT.isAntiAliased()) {
-            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                Platform.getTextAntialiasingHint());
-        }
-
-        if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
-            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        }
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+            fontRenderContext.getAntiAliasingHint());
+        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+            fontRenderContext.getFractionalMetricsHint());
 
         if (meter.getOrientation() == Orientation.HORIZONTAL) {
             drawMeter(meter, graphics, width, height);
@@ -238,10 +237,11 @@ public class TerraMeterSkin extends Comp
         String text = meter.getText();
         if (text != null
             && text.length() > 0) {
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             float ascent = lm.getAscent();
 
-            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
+            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
             float textWidth = (float)stringBounds.getWidth();
             float textHeight = (float)stringBounds.getHeight();
 

Modified: pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java (original)
+++ pivot/trunk/wtk-terra/src/org/apache/pivot/wtk/skin/terra/TerraTextInputSkin.java Thu Apr 15 14:17:14 2010
@@ -151,7 +151,6 @@ public class TerraTextInputSkin extends 
 
     private Dimensions averageCharacterSize;
 
-    private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, false);
     private static final int SCROLL_RATE = 50;
     private static final char BULLET = 0x2022;
 
@@ -218,7 +217,8 @@ public class TerraTextInputSkin extends 
 
     @Override
     public int getBaseline(int width, int height) {
-        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
         float ascent = lm.getAscent();
         float textHeight = lm.getHeight();
 
@@ -250,7 +250,8 @@ public class TerraTextInputSkin extends 
                     ci= textNode.getCharacterIterator();
                 }
 
-                glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, ci);
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                glyphVector = font.createGlyphVector(fontRenderContext, ci);
 
                 Rectangle2D textBounds = glyphVector.getLogicalBounds();
                 int textWidth = (int)textBounds.getWidth();
@@ -318,17 +319,13 @@ public class TerraTextInputSkin extends 
         GraphicsUtilities.drawLine(graphics, 0, 0, width, Orientation.HORIZONTAL);
 
         // Paint the content
-        if (FONT_RENDER_CONTEXT.isAntiAliased()) {
-            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                Platform.getTextAntialiasingHint());
-        }
-
-        if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
-            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-        }
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+        graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+            fontRenderContext.getAntiAliasingHint());
+        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+            fontRenderContext.getFractionalMetricsHint());
 
-        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
         float ascent = lm.getAscent();
         float textHeight = lm.getHeight();
 
@@ -509,11 +506,13 @@ public class TerraTextInputSkin extends 
         this.font = font;
 
         int missingGlyphCode = font.getMissingGlyphCode();
-        GlyphVector missingGlyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+
+        GlyphVector missingGlyphVector = font.createGlyphVector(fontRenderContext,
             new int[] {missingGlyphCode});
         Rectangle2D textBounds = missingGlyphVector.getLogicalBounds();
 
-        Rectangle2D maxCharBounds = font.getMaxCharBounds(FONT_RENDER_CONTEXT);
+        Rectangle2D maxCharBounds = font.getMaxCharBounds(fontRenderContext);
         averageCharacterSize = new Dimensions((int)Math.ceil(textBounds.getWidth()),
             (int)Math.ceil(maxCharBounds.getHeight()));
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/ApplicationContext.java Thu Apr 15 14:17:14 2010
@@ -1743,6 +1743,12 @@ public abstract class ApplicationContext
         displays.remove(display);
     }
 
+    protected static void invalidateDisplays() {
+        for (Display display : displays) {
+            display.invalidate();
+        }
+    }
+
     protected static void addApplication(Application application) {
         applications.add(application);
     }

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/Platform.java Thu Apr 15 14:17:14 2010
@@ -18,6 +18,7 @@ package org.apache.pivot.wtk;
 
 import java.awt.RenderingHints;
 import java.awt.Toolkit;
+import java.awt.font.FontRenderContext;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -27,7 +28,7 @@ import org.apache.pivot.wtk.Keyboard.Mod
  * Provides platform-specific information.
  */
 public class Platform {
-    private static Object textAntialiasingHint = null;
+    private static FontRenderContext fontRenderContext;
 
     private static final int DEFAULT_MULTI_CLICK_INTERVAL = 400;
     private static final int DEFAULT_CURSOR_BLINK_RATE = 600;
@@ -45,36 +46,46 @@ public class Platform {
             COMMAND_MODIFIER = Modifier.CTRL;
             KEYSTROKE_MODIFIER_SEPARATOR = "-";
         }
-    }
 
-    /**
-     * Returns the system text anti-aliasing hint.
-     */
-    public static Object getTextAntialiasingHint() {
-        if (textAntialiasingHint == null) {
-            Toolkit toolkit = Toolkit.getDefaultToolkit();
-            java.util.Map<?, ?> fontDesktopHints =
-                (java.util.Map<?, ?>)toolkit.getDesktopProperty("awt.font.desktophints");
-
-            if (fontDesktopHints == null) {
-                textAntialiasingHint = RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
-            } else {
-                textAntialiasingHint = fontDesktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
-                if (textAntialiasingHint.equals(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF)) {
-                    textAntialiasingHint = RenderingHints.VALUE_TEXT_ANTIALIAS_ON;
-                }
-
-                // Listen for changes to the property
-                toolkit.addPropertyChangeListener("awt.font.desktophints", new PropertyChangeListener() {
-                    @Override
-                    public void propertyChange(PropertyChangeEvent event) {
-                        Platform.textAntialiasingHint = null;
-                    }
-                });
+        // Initialize the font render context
+        initializeFontRenderContext();
+
+        // Listen for changes to the font desktop hints property
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        toolkit.addPropertyChangeListener("awt.font.desktophints", new PropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent event) {
+                initializeFontRenderContext();
+                ApplicationContext.invalidateDisplays();
             }
+        });
+    }
+
+    public static FontRenderContext getFontRenderContext() {
+        return fontRenderContext;
+    }
+
+    private static void initializeFontRenderContext() {
+        Object aaHint = null;
+        Object fmHint = null;
+
+        Toolkit toolkit = Toolkit.getDefaultToolkit();
+        java.util.Map<?, ?> fontDesktopHints =
+            (java.util.Map<?, ?>)toolkit.getDesktopProperty("awt.font.desktophints");
+        if (fontDesktopHints != null) {
+            aaHint = fontDesktopHints.get(RenderingHints.KEY_TEXT_ANTIALIASING);
+            fmHint = fontDesktopHints.get(RenderingHints.KEY_FRACTIONALMETRICS);
+        }
+
+        if (aaHint == null) {
+            aaHint = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT;
+        }
+
+        if (fmHint == null) {
+            fmHint = RenderingHints.VALUE_FRACTIONALMETRICS_DEFAULT;
         }
 
-        return textAntialiasingHint;
+        fontRenderContext = new FontRenderContext(null, aaHint, fmHint);
     }
 
     /**

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/effects/ScaleDecorator.java Thu Apr 15 14:17:14 2010
@@ -18,6 +18,7 @@ package org.apache.pivot.wtk.effects;
 
 import java.awt.Graphics2D;
 import java.awt.RenderingHints;
+import java.awt.font.FontRenderContext;
 import java.awt.geom.AffineTransform;
 
 import org.apache.pivot.wtk.Bounds;
@@ -344,8 +345,12 @@ public class ScaleDecorator implements D
     public Graphics2D prepare(Component component, Graphics2D graphics) {
         graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
             RenderingHints.VALUE_ANTIALIAS_ON);
+
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
         graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-            Platform.getTextAntialiasingHint());
+            fontRenderContext.getAntiAliasingHint());
+        graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+            fontRenderContext.getFractionalMetricsHint());
 
         int tx = getTranslatedX(component);
         int ty = getTranslatedY(component);

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Text.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Text.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Text.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/media/drawing/Text.java Thu Apr 15 14:17:14 2010
@@ -78,7 +78,6 @@ public class Text extends Shape {
     private TextListenerList textListeners = new TextListenerList();
 
     public static final Font DEFAULT_FONT = new Font("Verdana", Font.PLAIN, 11);
-    private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, true);
 
     public Text() {
         setFill(Color.BLACK);
@@ -191,24 +190,17 @@ public class Text extends Shape {
 
         // Draw the text
         if (glyphVectors.getLength() > 0) {
-            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-                RenderingHints.VALUE_ANTIALIAS_ON);
-
-            if (FONT_RENDER_CONTEXT.isAntiAliased()) {
-                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                    Platform.getTextAntialiasingHint());
-            }
-
-            if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
-                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-            }
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                fontRenderContext.getAntiAliasingHint());
+            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                fontRenderContext.getFractionalMetricsHint());
 
             Paint fill = getFill();
             Paint stroke = getStroke();
             int strokeThickness = getStrokeThickness();
 
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             float ascent = lm.getAscent();
 
             float y = 0;
@@ -265,6 +257,8 @@ public class Text extends Shape {
     @Override
     protected void validate() {
         if (!isValid()) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+
             glyphVectors = new ArrayList<GlyphVector>();
 
             int width, height;
@@ -275,7 +269,7 @@ public class Text extends Shape {
                     height = 0;
                 } else {
                     // Create a single glyph vector representing the entire string
-                    GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, text);
+                    GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, text);
                     glyphVectors.add(glyphVector);
 
                     Rectangle2D textBounds = glyphVector.getLogicalBounds();
@@ -299,8 +293,7 @@ public class Text extends Shape {
                             lastWhitespaceIndex = i;
                         }
 
-                        Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1,
-                            FONT_RENDER_CONTEXT);
+                        Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1, fontRenderContext);
                         lineWidth += characterBounds.getWidth();
 
                         if (lineWidth > this.width
@@ -313,7 +306,7 @@ public class Text extends Shape {
                             // Append the current line
                             if ((i - 1) - start > 0) {
                                 StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
-                                GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
+                                GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
                                 glyphVectors.add(glyphVector);
 
                                 Rectangle2D textBounds = glyphVector.getLogicalBounds();
@@ -330,7 +323,7 @@ public class Text extends Shape {
                     // Append the final line
                     if ((i - 1) - start > 0) {
                         StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
-                        GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
+                        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
                         glyphVectors.add(glyphVector);
 
                         Rectangle2D textBounds = glyphVector.getLogicalBounds();

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/BorderSkin.java Thu Apr 15 14:17:14 2010
@@ -45,10 +45,7 @@ import org.apache.pivot.wtk.Theme;
  * TODO Add styles to support different border styles (e.g. inset, outset) or
  * create subclasses for these border types.
  */
-public class BorderSkin extends ContainerSkin
-    implements BorderListener {
-    private FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);
-
+public class BorderSkin extends ContainerSkin implements BorderListener {
     private Font font;
     private Color color;
     private Color titleColor;
@@ -86,6 +83,7 @@ public class BorderSkin extends Containe
         String title = border.getTitle();
         if (title != null
             && title.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             Rectangle2D headingBounds = font.getStringBounds(title, fontRenderContext);
             preferredWidth = (int)Math.ceil(headingBounds.getWidth());
 
@@ -118,6 +116,7 @@ public class BorderSkin extends Containe
         String title = border.getTitle();
         if (title != null
             && title.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
             topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
         }
@@ -156,6 +155,7 @@ public class BorderSkin extends Containe
             String title = border.getTitle();
             if (title != null
                 && title.length() > 0) {
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
                 LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
                 topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
             }
@@ -187,6 +187,7 @@ public class BorderSkin extends Containe
         String title = border.getTitle();
         if (title != null
             && title.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
             topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
         }
@@ -214,6 +215,7 @@ public class BorderSkin extends Containe
         String title = border.getTitle();
         if (title != null
             && title.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             LineMetrics lm = font.getLineMetrics(title, fontRenderContext);
             titleAscent = lm.getAscent();
             topThickness = Math.max((int)Math.ceil(lm.getHeight()), topThickness);
@@ -248,15 +250,11 @@ public class BorderSkin extends Containe
 
         // Draw the title
         if (title != null) {
-            if (fontRenderContext.isAntiAliased()) {
-                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                    Platform.getTextAntialiasingHint());
-            }
-
-            if (fontRenderContext.usesFractionalMetrics()) {
-                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-            }
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                fontRenderContext.getAntiAliasingHint());
+            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                fontRenderContext.getFractionalMetricsHint());
 
             // Note that we add one pixel to the string bounds for spacing
             Rectangle2D titleBounds = font.getStringBounds(title, fontRenderContext);

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/LabelSkin.java Thu Apr 15 14:17:14 2010
@@ -61,8 +61,6 @@ public class LabelSkin extends Component
     private ArrayList<GlyphVector> glyphVectors = null;
     private float textHeight = -1;
 
-    private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, true);
-
     public LabelSkin() {
         Theme theme = Theme.getTheme();
         font = theme.getFont();
@@ -91,7 +89,8 @@ public class LabelSkin extends Component
         int preferredWidth;
         if (text != null
             && text.length() > 0) {
-            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
             preferredWidth = (int)Math.ceil(stringBounds.getWidth());
         } else {
             preferredWidth = 0;
@@ -109,7 +108,8 @@ public class LabelSkin extends Component
 
         float preferredHeight;
         if (text != null) {
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             float lineHeight = lm.getHeight();
 
             preferredHeight = lineHeight;
@@ -132,7 +132,7 @@ public class LabelSkin extends Component
                     }
 
                     Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1,
-                        FONT_RENDER_CONTEXT);
+                        fontRenderContext);
                     lineWidth += characterBounds.getWidth();
 
                     if (lineWidth > width
@@ -162,10 +162,12 @@ public class LabelSkin extends Component
         Label label = (Label)getComponent();
         String text = label.getText();
 
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+
         int preferredWidth;
         if (text != null
             && text.length() > 0) {
-            Rectangle2D stringBounds = font.getStringBounds(text, FONT_RENDER_CONTEXT);
+            Rectangle2D stringBounds = font.getStringBounds(text, fontRenderContext);
             preferredWidth = (int)Math.ceil(stringBounds.getWidth());
         } else {
             preferredWidth = 0;
@@ -173,7 +175,7 @@ public class LabelSkin extends Component
 
         preferredWidth += (padding.left + padding.right);
 
-        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
         int preferredHeight = (int)Math.ceil(lm.getHeight()) + (padding.top + padding.bottom);
 
         return new Dimensions(preferredWidth, preferredHeight);
@@ -181,7 +183,8 @@ public class LabelSkin extends Component
 
     @Override
     public int getBaseline(int width, int height) {
-        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
         float ascent = lm.getAscent();
 
         float textHeight;
@@ -224,6 +227,8 @@ public class LabelSkin extends Component
             int n = text.length();
 
             if (n > 0) {
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+
                 if (wrapText) {
                     int width = getWidth() - (padding.left + padding.right);
 
@@ -238,8 +243,7 @@ public class LabelSkin extends Component
                             lastWhitespaceIndex = i;
                         }
 
-                        Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1,
-                            FONT_RENDER_CONTEXT);
+                        Rectangle2D characterBounds = font.getStringBounds(text, i, i + 1, fontRenderContext);
                         lineWidth += characterBounds.getWidth();
 
                         if (lineWidth > width
@@ -252,7 +256,7 @@ public class LabelSkin extends Component
                             // Append the current line
                             if ((i - 1) - start >= 0) {
                                 StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
-                                GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
+                                GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
                                 glyphVectors.add(glyphVector);
 
                                 Rectangle2D textBounds = glyphVector.getLogicalBounds();
@@ -268,14 +272,14 @@ public class LabelSkin extends Component
                     // Append the final line
                     if ((i - 1) - start >= 0) {
                         StringCharacterIterator line = new StringCharacterIterator(text, start, i, start);
-                        GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, line);
+                        GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, line);
                         glyphVectors.add(glyphVector);
 
                         Rectangle2D textBounds = glyphVector.getLogicalBounds();
                         textHeight += textBounds.getHeight();
                     }
                 } else {
-                    GlyphVector glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT, text);
+                    GlyphVector glyphVector = font.createGlyphVector(fontRenderContext, text);
                     glyphVectors.add(glyphVector);
 
                     Rectangle2D textBounds = glyphVector.getLogicalBounds();
@@ -301,20 +305,13 @@ public class LabelSkin extends Component
             graphics.setFont(font);
             graphics.setPaint(color);
 
-            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
-                RenderingHints.VALUE_ANTIALIAS_ON);
-
-            if (FONT_RENDER_CONTEXT.isAntiAliased()) {
-                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                    Platform.getTextAntialiasingHint());
-            }
-
-            if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
-                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-            }
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                fontRenderContext.getAntiAliasingHint());
+            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                fontRenderContext.getFractionalMetricsHint());
 
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             float ascent = lm.getAscent();
             float lineHeight = lm.getHeight();
 

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/SeparatorSkin.java Thu Apr 15 14:17:14 2010
@@ -40,10 +40,7 @@ import org.apache.pivot.wtk.Theme;
 /**
  * Separator skin.
  */
-public class SeparatorSkin extends ComponentSkin
-    implements SeparatorListener {
-    private FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);
-
+public class SeparatorSkin extends ComponentSkin implements SeparatorListener {
     private Font font;
     private Color color;
     private Color headingColor;
@@ -76,6 +73,7 @@ public class SeparatorSkin extends Compo
 
         if (heading != null
             && heading.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             Rectangle2D headingBounds = font.getStringBounds(heading, fontRenderContext);
             preferredWidth = (int)Math.ceil(headingBounds.getWidth())
                 + (padding.left + padding.right);
@@ -93,6 +91,7 @@ public class SeparatorSkin extends Compo
 
         if (heading != null
             && heading.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
             preferredHeight = Math.max((int)Math.ceil(lm.getAscent() + lm.getDescent()
                 + lm.getLeading()), preferredHeight);
@@ -124,17 +123,13 @@ public class SeparatorSkin extends Compo
 
         if (heading != null
             && heading.length() > 0) {
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
             LineMetrics lm = font.getLineMetrics(heading, fontRenderContext);
 
-            if (fontRenderContext.isAntiAliased()) {
-                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                    Platform.getTextAntialiasingHint());
-            }
-
-            if (fontRenderContext.usesFractionalMetrics()) {
-                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                    RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-            }
+            graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                fontRenderContext.getAntiAliasingHint());
+            graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                fontRenderContext.getFractionalMetricsHint());
 
             graphics.setFont(font);
             graphics.setPaint(headingColor);

Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=934422&r1=934421&r2=934422&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Thu Apr 15 14:17:14 2010
@@ -742,7 +742,8 @@ public class TextAreaSkin extends Compon
                 }
 
                 // Recalculate terminator bounds
-                LineMetrics lm = font.getLineMetrics("", 0, 0, FONT_RENDER_CONTEXT);
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                LineMetrics lm = font.getLineMetrics("", 0, 0, fontRenderContext);
                 int terminatorHeight = (int)Math.ceil(lm.getHeight());
 
                 int terminatorY;
@@ -976,6 +977,7 @@ public class TextAreaSkin extends Compon
         public void validate() {
             if (!isValid()) {
                 TextNode textNode = (TextNode)getNode();
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
 
                 int breakWidth = getBreakWidth();
                 CharacterIterator ci = textNode.getCharacterIterator(start);
@@ -991,8 +993,7 @@ public class TextAreaSkin extends Compon
                     }
 
                     int i = ci.getIndex();
-                    Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1,
-                        FONT_RENDER_CONTEXT);
+                    Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1, fontRenderContext);
                     lineWidth += characterBounds.getWidth();
 
                     c = ci.current();
@@ -1012,7 +1013,7 @@ public class TextAreaSkin extends Compon
                     }
                 }
 
-                glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
+                glyphVector = font.createGlyphVector(fontRenderContext,
                     textNode.getCharacterIterator(start, end));
 
                 if (end < ci.getEndIndex()) {
@@ -1035,17 +1036,13 @@ public class TextAreaSkin extends Compon
             if (glyphVector != null) {
                 TextArea textArea = (TextArea)getComponent();
 
-                if (FONT_RENDER_CONTEXT.isAntiAliased()) {
-                    graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
-                        Platform.getTextAntialiasingHint());
-                }
-
-                if (FONT_RENDER_CONTEXT.usesFractionalMetrics()) {
-                    graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
-                        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
-                }
+                FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+                graphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
+                    fontRenderContext.getAntiAliasingHint());
+                graphics.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
+                    fontRenderContext.getFractionalMetricsHint());
 
-                LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+                LineMetrics lm = font.getLineMetrics("", fontRenderContext);
                 float ascent = lm.getAscent();
 
                 graphics.setFont(font);
@@ -1131,7 +1128,8 @@ public class TextAreaSkin extends Compon
 
         @Override
         public int getInsertionPoint(int x, int y) {
-            LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+            FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+            LineMetrics lm = font.getLineMetrics("", fontRenderContext);
             float ascent = lm.getAscent();
 
             int n = glyphVector.getNumGlyphs();
@@ -1436,7 +1434,6 @@ public class TextAreaSkin extends Compon
     private boolean wrapText = true;
 
     private static final int PARAGRAPH_TERMINATOR_WIDTH = 4;
-    private static final FontRenderContext FONT_RENDER_CONTEXT = new FontRenderContext(null, true, true);
     private static final int SCROLL_RATE = 30;
 
     public TextAreaSkin() {
@@ -1535,7 +1532,8 @@ public class TextAreaSkin extends Compon
 
     @Override
     public int getBaseline(int width, int height) {
-        LineMetrics lm = font.getLineMetrics("", FONT_RENDER_CONTEXT);
+        FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+        LineMetrics lm = font.getLineMetrics("", fontRenderContext);
         float ascent = lm.getAscent();
         return margin.top + Math.round(ascent);
     }