Index: javax/swing/text/BoxView.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/BoxView.java,v retrieving revision 1.5 diff -u -r1.5 BoxView.java --- javax/swing/text/BoxView.java 5 Oct 2005 21:46:41 -0000 1.5 +++ javax/swing/text/BoxView.java 6 Oct 2005 20:14:51 -0000 @@ -295,18 +295,19 @@ { // Adjust size if the size is changed. Rectangle bounds = a.getBounds(); + if (bounds.width != getWidth() || bounds.height != getHeight()) setSize(bounds.width, bounds.height); Rectangle inside = getInsideAllocation(a); - Rectangle copy = new Rectangle(inside); int count = getViewCount(); for (int i = 0; i < count; ++i) { copy.setBounds(inside); childAllocation(i, copy); - paintChild(g, copy, i); + if (!copy.isEmpty()) + paintChild(g, copy, i); } } @@ -522,9 +523,6 @@ */ protected void layout(int width, int height) { - this.width = width; - this.height = height; - baselineLayout(width, X_AXIS, offsetsX, spansX); baselineLayout(height, Y_AXIS, offsetsY, spansY); } @@ -614,6 +612,9 @@ layoutChanged(X_AXIS); if (this.height != (int) height) layoutChanged(Y_AXIS); + + this.width = (int) width; + this.height = (int) height; Rectangle outside = new Rectangle(0, 0, this.width, this.height); Rectangle inside = getInsideAllocation(outside); Index: javax/swing/text/CompositeView.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/CompositeView.java,v retrieving revision 1.6 diff -u -r1.6 CompositeView.java --- javax/swing/text/CompositeView.java 13 Sep 2005 23:44:49 -0000 1.6 +++ javax/swing/text/CompositeView.java 6 Oct 2005 20:14:51 -0000 @@ -434,10 +434,16 @@ */ protected int getViewIndexAtPosition(int pos) { - // We have one child view allocated for each child element in - // loadChildren(), so this should work. - Element el = getElement(); - int index = el.getElementIndex(pos); + int index = -1; + for (int i = 0; i < children.length; i++) + { + if (children[i].getStartOffset() >= pos + && children[i].getEndOffset() < pos) + { + index = i; + break; + } + } return index; } @@ -474,8 +480,8 @@ insideAllocation = inside; } } - inside.x = alloc.x - insets.left; - inside.y = alloc.y - insets.top; + inside.x = alloc.x + insets.left; + inside.y = alloc.y + insets.top; inside.width = alloc.width - insets.left - insets.right; inside.height = alloc.height - insets.top - insets.bottom; return inside; Index: javax/swing/text/FlowView.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/FlowView.java,v retrieving revision 1.2 diff -u -r1.2 FlowView.java --- javax/swing/text/FlowView.java 25 Aug 2005 19:11:50 -0000 1.2 +++ javax/swing/text/FlowView.java 6 Oct 2005 20:14:51 -0000 @@ -42,6 +42,7 @@ import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Shape; +import java.util.Iterator; import java.util.Vector; import javax.swing.event.DocumentEvent; @@ -183,11 +184,17 @@ { View child = createView(fv, offset, spanLeft, rowIndex); if (child == null) - break; + { + offset = -1; + break; + } int span = (int) child.getPreferredSpan(flowAxis); if (span > spanLeft) - break; + { + offset = -1; + break; + } row.append(child); spanLeft -= span; @@ -218,13 +225,15 @@ View logicalView = getLogicalView(fv); int viewIndex = logicalView.getViewIndex(offset, Position.Bias.Forward); + if (viewIndex == -1) + return null; + View child = logicalView.getView(viewIndex); int flowAxis = fv.getFlowAxis(); int span = (int) child.getPreferredSpan(flowAxis); if (span <= spanLeft) return child; - else if (child.getBreakWeight(flowAxis, offset, spanLeft) > BadBreakWeight) // FIXME: What to do with the pos parameter here? @@ -326,7 +335,19 @@ */ public int getViewIndex(int pos, Position.Bias b) { - return getElement().getElementIndex(pos); + int index = -1; + int i = 0; + for (Iterator it = children.iterator(); it.hasNext(); i++) + { + View child = (View) it.next(); + if (child.getStartOffset() >= pos + && child.getEndOffset() < pos) + { + index = i; + break; + } + } + return index; } /** Index: javax/swing/text/GlyphView.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/GlyphView.java,v retrieving revision 1.7 diff -u -r1.7 GlyphView.java --- javax/swing/text/GlyphView.java 14 Sep 2005 21:26:07 -0000 1.7 +++ javax/swing/text/GlyphView.java 6 Oct 2005 20:14:54 -0000 @@ -44,6 +44,7 @@ import java.awt.Graphics; import java.awt.Rectangle; import java.awt.Shape; +import java.awt.Toolkit; import java.text.BreakIterator; import javax.swing.SwingConstants; @@ -258,7 +259,7 @@ public float getHeight(GlyphView view) { Font font = view.getFont(); - FontMetrics metrics = view.getContainer().getFontMetrics(font); + FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(font); float height = metrics.getHeight(); return height; } @@ -377,7 +378,7 @@ { Element el = view.getElement(); Font font = view.getFont(); - FontMetrics fm = view.getContainer().getFontMetrics(font); + FontMetrics fm = Toolkit.getDefaultToolkit().getFontMetrics(font); Segment txt = view.getText(p0, p1); int span = Utilities.getTabbedTextWidth(txt, fm, (int) x, te, p0); return span; Index: javax/swing/text/Utilities.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/Utilities.java,v retrieving revision 1.13 diff -u -r1.13 Utilities.java --- javax/swing/text/Utilities.java 28 Sep 2005 14:59:31 -0000 1.13 +++ javax/swing/text/Utilities.java 6 Oct 2005 20:14:54 -0000 @@ -232,9 +232,16 @@ // At the end of the for loop, this holds the requested model location int pos; int currentX = x0; + for (pos = p0; pos < s.getEndIndex(); pos++) { char nextChar = s.array[pos]; + if (nextChar == 0) + { + if (! round) + pos--; + break; + } if (nextChar != '\n') currentX += fm.charWidth(nextChar); else Index: javax/swing/text/View.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/swing/text/View.java,v retrieving revision 1.20 diff -u -r1.20 View.java --- javax/swing/text/View.java 5 Oct 2005 21:46:41 -0000 1.20 +++ javax/swing/text/View.java 6 Oct 2005 20:14:54 -0000 @@ -86,10 +86,9 @@ { View parent = getParent(); if (parent == null) - throw new AssertionError(getClass().getName() - + ": the parent of a View must not be null."); - - return parent.getContainer(); + return null; + else + return parent.getContainer(); } public Document getDocument()