summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--javax/swing/JComponent.java23
2 files changed, 23 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 4d1d65ff4..bd980b198 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2006-02-16 Roman Kennke <kennke@aicas.com>
+
+ * javax/swing/JComponent.java
+ (rectCache): Made field non-static to avoid nasty interferences.
+ (computeVisibleRect): Avoid creation of new Rectangles and double
+ calculations on ints by using Swing.computeIntersection() instead
+ of Rectangle2D.intersect().
+ (repaint): Interect the dirty region with the visible rectangle
+ of this component to avoid unnecessary painting.
+
2006-02-16 Gary Benson <gbenson@redhat.com>
* java/lang/Thread.java (stop): Add a missing access check.
diff --git a/javax/swing/JComponent.java b/javax/swing/JComponent.java
index 0e11eb83c..38e469c7d 100644
--- a/javax/swing/JComponent.java
+++ b/javax/swing/JComponent.java
@@ -64,7 +64,6 @@ import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
-import java.awt.geom.Rectangle2D;
import java.awt.peer.LightweightPeer;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
@@ -555,7 +554,7 @@ public abstract class JComponent extends Container implements Serializable
* so that it doesn't get modified in another context within the same
* method call chain.
*/
- private static transient Rectangle rectCache;
+ private transient Rectangle rectCache;
/**
* The default locale of the component.
@@ -1379,9 +1378,8 @@ public abstract class JComponent extends Container implements Serializable
{
((JComponent) c).computeVisibleRect(rect);
rect.translate(-getX(), -getY());
- Rectangle2D.intersect(rect,
- new Rectangle(0, 0, getWidth(), getHeight()),
- rect);
+ rect = SwingUtilities.computeIntersection(0, 0, getWidth(),
+ getHeight(), rect);
}
else
rect.setRect(0, 0, getWidth(), getHeight());
@@ -1397,9 +1395,10 @@ public abstract class JComponent extends Container implements Serializable
*/
public Rectangle getVisibleRect()
{
- Rectangle r = new Rectangle();
- computeVisibleRect(r);
- return r;
+ if (rectCache == null)
+ rectCache = new Rectangle();
+ computeVisibleRect(rectCache);
+ return rectCache;
}
/**
@@ -2205,8 +2204,12 @@ public abstract class JComponent extends Container implements Serializable
*/
public void repaint(long tm, int x, int y, int width, int height)
{
- RepaintManager.currentManager(this).addDirtyRegion(this, x, y, width,
- 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);
}
/**