This should significantly improve performance in Swing text components.
Before we always called repaint() on _the whole component_ for each and
every little insert/remove/change operation. With this fix, this is
going down to the actual views which can calculate a much better repaint
region.
2006-11-10 Roman Kennke <[EMAIL PROTECTED]>
* javax/swing/text/View.java
(updateLayout): Only repaint when needed.
/Roman
Index: javax/swing/text/View.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v
retrieving revision 1.37
diff -u -1 -5 -r1.37 View.java
--- javax/swing/text/View.java 6 Nov 2006 16:02:54 -0000 1.37
+++ javax/swing/text/View.java 10 Nov 2006 20:22:40 -0000
@@ -613,34 +613,36 @@
}
/**
* Updates the layout.
*
* @param ec the ElementChange that describes the changes to the element
* @param ev the DocumentEvent that describes the changes to the model
* @param shape the current allocation for this view
*
* @since 1.3
*/
protected void updateLayout(DocumentEvent.ElementChange ec,
DocumentEvent ev, Shape shape)
{
if (ec != null && shape != null)
- preferenceChanged(null, true, true);
- Container c = getContainer();
- if (c != null)
- c.repaint();
+ {System.err.println("ec: " + ec);
+ preferenceChanged(null, true, true);
+ Container c = getContainer();
+ if (c != null)
+ c.repaint();
+ }
}
/**
* Maps a position in the document into the coordinate space of the View.
* The output rectangle usually reflects the font height but has a width
* of zero.
*
* @param pos the position of the character in the model
* @param a the area that is occupied by the view
* @param b either [EMAIL PROTECTED] Position.Bias#Forward} or
* [EMAIL PROTECTED] Position.Bias#Backward} depending on the preferred
* direction bias. If <code>null</code> this defaults to
* <code>Position.Bias.Forward</code>
*
* @return a rectangle that gives the location of the document position