You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by gb...@apache.org on 2009/10/20 20:11:28 UTC

svn commit: r827755 - /incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Author: gbrown
Date: Tue Oct 20 18:11:27 2009
New Revision: 827755

URL: http://svn.apache.org/viewvc?rev=827755&view=rev
Log:
Fix minor wrapping issue in TextNodeView.

Modified:
    incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java

Modified: incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java
URL: http://svn.apache.org/viewvc/incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java?rev=827755&r1=827754&r2=827755&view=diff
==============================================================================
--- incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java (original)
+++ incubator/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin.java Tue Oct 20 18:11:27 2009
@@ -839,49 +839,46 @@
                 int breakWidth = getBreakWidth();
                 CharacterIterator ci = textNode.getCharacterIterator(start);
 
-                if (breakWidth == 0) {
-                    glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
-                        textNode.getCharacterIterator(start));
-                    length = ci.getEndIndex() - start;
-                } else {
-                    float lineWidth = 0;
-                    int lastWhitespaceIndex = -1;
+                float lineWidth = 0;
+                int lastWhitespaceIndex = -1;
 
-                    char c = ci.first();
-                    while (c != CharacterIterator.DONE
-                        && lineWidth < breakWidth) {
-                        if (Character.isWhitespace(c)) {
-                            lastWhitespaceIndex = ci.getIndex();
-                        }
+                char c = ci.first();
+                while (c != CharacterIterator.DONE
+                    && lineWidth < breakWidth) {
+                    if (Character.isWhitespace(c)) {
+                        lastWhitespaceIndex = ci.getIndex();
+                    }
 
-                        int i = ci.getIndex();
-                        Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1,
-                            FONT_RENDER_CONTEXT);
-                        lineWidth += characterBounds.getWidth();
+                    int i = ci.getIndex();
+                    Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1,
+                        FONT_RENDER_CONTEXT);
+                    lineWidth += characterBounds.getWidth();
 
-                        c = ci.current();
-                    }
+                    c = ci.current();
+                }
 
-                    int end;
-                    if (lineWidth < breakWidth) {
-                        end = ci.getEndIndex();
-                    } else {
-                        if (lastWhitespaceIndex == -1) {
-                            end = ci.getIndex();
-                        } else {
-                            end = lastWhitespaceIndex + 1;
+                int end;
+                if (lineWidth < breakWidth) {
+                    end = ci.getEndIndex();
+                } else {
+                    if (lastWhitespaceIndex == -1) {
+                        end = ci.getIndex() - 1;
+                        if (end <= start) {
+                            end = start + 1;
                         }
+                    } else {
+                        end = lastWhitespaceIndex + 1;
                     }
+                }
 
-                    glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
-                        textNode.getCharacterIterator(start, end));
+                glyphVector = font.createGlyphVector(FONT_RENDER_CONTEXT,
+                    textNode.getCharacterIterator(start, end));
 
-                    if (end < ci.getEndIndex()) {
-                        length = end - start;
-                        next = new TextNodeView(textNode, end);
-                    } else {
-                        length = ci.getEndIndex() - start;
-                    }
+                if (end < ci.getEndIndex()) {
+                    length = end - start;
+                    next = new TextNodeView(textNode, end);
+                } else {
+                    length = ci.getEndIndex() - start;
                 }
 
                 Rectangle2D logicalBounds = glyphVector.getLogicalBounds();