This patch makes the textlayout caching in Swing disabled when the system property gnu.javax.swing.noGraphics2D is set (just like for the gradients and textures in the OceanTheme). This makes the X peers work again.

2006-07-17  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/plaf/basic/BasicButtonListener.java
        (propertyChange): Only do the text layout caching as long
        as the noGraphics2D property isn't set.
        * javax/swing/plaf/basic/BasicMenuItemUI.java
        (PropertyChangeHandler.propertyChange): Only do the text layout
        caching as long as the noGraphics2D property isn't set.

/Roman
Index: javax/swing/plaf/basic/BasicButtonListener.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicButtonListener.java,v
retrieving revision 1.14
diff -u -1 -2 -r1.14 BasicButtonListener.java
--- javax/swing/plaf/basic/BasicButtonListener.java	21 Jun 2006 13:13:40 -0000	1.14
+++ javax/swing/plaf/basic/BasicButtonListener.java	17 Jul 2006 08:33:17 -0000
@@ -29,24 +29,26 @@
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 package javax.swing.plaf.basic;
 
+import gnu.classpath.SystemProperties;
+
 import java.awt.event.ActionEvent;
 import java.awt.event.FocusEvent;
 import java.awt.event.FocusListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseListener;
 import java.awt.event.MouseMotionListener;
 import java.awt.font.FontRenderContext;
 import java.awt.font.TextLayout;
 import java.awt.geom.AffineTransform;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 
@@ -62,26 +64,28 @@
   FocusListener, ChangeListener, PropertyChangeListener
 {
   public BasicButtonListener(AbstractButton b)
   {
     // Do nothing here.
   }
   
   public void propertyChange(PropertyChangeEvent e)
   {
     // Store the TextLayout for this in a client property for speed-up
     // painting of the label.
     String property = e.getPropertyName();
-    if (property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
-        || property.equals("font"))
+    if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+         || property.equals("font"))
+        && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+        == null)
       {
         AbstractButton b = (AbstractButton) e.getSource();
         String text = b.getText();
         if (text == null)
           text = "";
         FontRenderContext frc = new FontRenderContext(new AffineTransform(),
                                                       false, false);
         TextLayout layout = new TextLayout(text, b.getFont(), frc);
         b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
       }
   }
   
Index: javax/swing/plaf/basic/BasicMenuItemUI.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicMenuItemUI.java,v
retrieving revision 1.48
diff -u -1 -2 -r1.48 BasicMenuItemUI.java
--- javax/swing/plaf/basic/BasicMenuItemUI.java	21 Jun 2006 13:13:40 -0000	1.48
+++ javax/swing/plaf/basic/BasicMenuItemUI.java	17 Jul 2006 08:33:18 -0000
@@ -29,24 +29,26 @@
 modules, and to copy and distribute the resulting executable under
 terms of your choice, provided that you also meet, for each linked
 independent module, the terms and conditions of the license of that
 module.  An independent module is a module which is not derived from
 or based on this library.  If you modify this library, you may extend
 this exception to your version of the library, but you are not
 obligated to do so.  If you do not wish to do so, delete this
 exception statement from your version. */
 
 
 package javax.swing.plaf.basic;
 
+import gnu.classpath.SystemProperties;
+
 import java.awt.Color;
 import java.awt.Component;
 import java.awt.Container;
 import java.awt.Dimension;
 import java.awt.Font;
 import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.Insets;
 import java.awt.Rectangle;
 import java.awt.event.ActionEvent;
 import java.awt.event.ItemEvent;
 import java.awt.event.ItemListener;
@@ -247,26 +249,29 @@
           InputMap map = SwingUtilities.getUIInputMap(menuItem, 
               JComponent.WHEN_IN_FOCUSED_WINDOW);
           if (map != null)
             map.remove((KeyStroke) e.getOldValue());
           else
             map = new ComponentInputMapUIResource(menuItem);
 
           KeyStroke accelerator = (KeyStroke) e.getNewValue();
           if (accelerator != null)
             map.put(accelerator, "doClick");
         }
       // TextLayout caching for speed-up drawing of text.
-      else if (property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
-          || property.equals("font"))
+      else if ((property.equals(AbstractButton.TEXT_CHANGED_PROPERTY)
+                || property.equals("font"))
+               && SystemProperties.getProperty("gnu.javax.swing.noGraphics2D")
+               == null)
+               
         {
           AbstractButton b = (AbstractButton) e.getSource();
           String text = b.getText();
           if (text == null)
             text = "";
           FontRenderContext frc = new FontRenderContext(new AffineTransform(),
                                                         false, false);
           TextLayout layout = new TextLayout(text, b.getFont(), frc);
           b.putClientProperty(BasicGraphicsUtils.CACHED_TEXT_LAYOUT, layout);
         }
     }
   }

Reply via email to