Hi, the attached patch sets the numLines variable to -1 if the allocation area is emtpy. Not doing so will cause exceptions because it would have been tried to lay out text into a non-existing rectangle.
With this the NavigationFilter example will finally show up but you will notice
that it does not work at all. This is due to [0].
The ChangeLog:
2006-04-20 Robert Schuster <[EMAIL PROTECTED]>
* javax/swing/text/WrappedPlainView.java: Initialize
WrappedLine.numLines with -1.
(WrappedPlainView.WrappedLine.getPreferredSpan): Check whether
numLines is -1 and reculcalate the value appropriately.
(WrappedPlainView.WrappedLine.updateDamage): Set numLines to -1 if
allocation area is empty.
cya
Robert
[0] - http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27220
Index: javax/swing/text/WrappedPlainView.java
===================================================================
RCS file: /cvsroot/classpath/classpath/javax/swing/text/WrappedPlainView.java,v
retrieving revision 1.16
diff -u -r1.16 WrappedPlainView.java
--- javax/swing/text/WrappedPlainView.java 2 Apr 2006 21:16:03 -0000 1.16
+++ javax/swing/text/WrappedPlainView.java 20 Apr 2006 08:20:04 -0000
@@ -419,7 +419,7 @@
class WrappedLine extends View
{
/** Used to cache the number of lines for this View **/
- int numLines;
+ int numLines = -1;
public WrappedLine(Element elem)
{
@@ -489,6 +489,10 @@
*/
public float getPreferredSpan(int axis)
{
+ // numLines may be invalid at this point and needs to be calculated.
+ if (numLines == -1)
+ determineNumLines();
+
if (axis == X_AXIS)
return getWidth();
else if (axis == Y_AXIS)
@@ -632,6 +636,16 @@
*/
void updateDamage (Rectangle a)
{
+ // If the allocation area is empty we can't do anything useful.
+ // As determining the number of lines is impossible in that state we
+ // reset it to an invalid value which can then be recalculated at a
+ // later point.
+ if (a.isEmpty())
+ {
+ numLines = -1;
+ return;
+ }
+
int oldNumLines = numLines;
determineNumLines();
signature.asc
Description: OpenPGP digital signature
