This fixes some smaller issues in JComponent. The visibleRect check from
repaint() is now moved to the RepaintManager.addDirtyRegion (just in
case, somebody calls this method directly instead of repaint()). Also, I
changed the getVisibleRect() method back to creating a new Rectangle
object instead of using rectCache. This has led to strange interferences
with classes that change the returned Rectangle.

2006-02-27  Roman Kennke  <[EMAIL PROTECTED]>

        * javax/swing/JComponent.java
        (rectCache): Made field static to save memory.
        (getVisibleRect): Don't use rectCache and create new Rectangle
        instance instead.
        (repaint(Rectangle)): Directly call
RepaintManager.addDirtyRegion().
        (repaint(long,int,int,int,int)): Directly call
        RepaintManager.addDirtyRegion(). The visibleRect check is now
        performed in the RepaintManager.

/Roman
Index: javax/swing/JComponent.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/JComponent.java,v
retrieving revision 1.104
diff -u -r1.104 JComponent.java
--- javax/swing/JComponent.java	16 Feb 2006 10:56:30 -0000	1.104
+++ javax/swing/JComponent.java	27 Feb 2006 12:49:59 -0000
@@ -554,7 +554,7 @@
    * so that it doesn't get modified in another context within the same
    * method call chain.
    */
-  private transient Rectangle rectCache;
+  private static transient Rectangle rectCache;
 
   /**
    * The default locale of the component.
@@ -1389,16 +1389,15 @@
    * Return the component's visible rectangle in a new [EMAIL PROTECTED] Rectangle},
    * rather than via a return slot.
    *
-   * @return The component's visible rectangle
+   * @return the component's visible rectangle
    *
    * @see #computeVisibleRect(Rectangle)
    */
   public Rectangle getVisibleRect()
   {
-    if (rectCache == null)
-      rectCache = new Rectangle();
-    computeVisibleRect(rectCache);
-    return rectCache;
+    Rectangle r = new Rectangle();
+    computeVisibleRect(r);
+    return r;
   }
 
   /**
@@ -2204,12 +2203,8 @@
    */
   public void repaint(long tm, int x, int y, int width, int height)
   {
-    // TODO: Maybe add this visibleRect stuff to RepaintManager.
-     Rectangle r = getVisibleRect();
-     Rectangle dirty = SwingUtilities.computeIntersection(x, y, width, height, r);
-     RepaintManager.currentManager(this).addDirtyRegion(this, dirty.x, dirty.y,
-                                                        dirty.width,
-                                                        dirty.height);
+     RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width,
+                                                        height);
   }
 
   /**
@@ -2221,7 +2216,8 @@
    */
   public void repaint(Rectangle r)
   {
-    repaint(0, r.x, r.y, r.width, r.height);
+    RepaintManager.currentManager(this).addDirtyRegion(this, r.x, r.y, r.width,
+                                                       r.height);
   }
 
   /**

Reply via email to