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 2010/09/07 23:14:07 UTC
svn commit: r993535 -
/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java
Author: gbrown
Date: Tue Sep 7 21:14:06 2010
New Revision: 993535
URL: http://svn.apache.org/viewvc?rev=993535&view=rev
Log:
TextAreaSkin2 bug fixes.
Modified:
pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java
Modified: pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java
URL: http://svn.apache.org/viewvc/pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java?rev=993535&r1=993534&r2=993535&view=diff
==============================================================================
--- pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java (original)
+++ pivot/trunk/wtk/src/org/apache/pivot/wtk/skin/TextAreaSkin2.java Tue Sep 7 21:14:06 2010
@@ -170,56 +170,53 @@ public class TextAreaSkin2 extends Compo
height = 0;
// Re-layout glyphs and recalculate size
+ FontRenderContext fontRenderContext = Platform.getFontRenderContext();
+
CharSequence characters = paragraph.getCharacters();
int n = characters.length();
- if (n > 0) {
- FontRenderContext fontRenderContext = Platform.getFontRenderContext();
-
- float lineWidth = 0;
- int lastWhitespaceIndex = -1;
-
- int start = 0;
- int i = 0;
-
- // NOTE We use a character iterator here only because it is the most
- // efficient way to measure the character bounds (as of Java 6, the version
- // of Font#getStringBounds() that takes a String performs a string copy,
- // whereas the version that takes a character iterator does not)
- CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);
- while (i < n) {
- char c = characters.charAt(i);
- if (Character.isWhitespace(c)) {
- lastWhitespaceIndex = i;
- }
+ int i = 0;
+ int start = 0;
+ float lineWidth = 0;
+ int lastWhitespaceIndex = -1;
+
+ // NOTE We use a character iterator here only because it is the most
+ // efficient way to measure the character bounds (as of Java 6, the version
+ // of Font#getStringBounds() that takes a String performs a string copy,
+ // whereas the version that takes a character iterator does not)
+ CharSequenceCharacterIterator ci = new CharSequenceCharacterIterator(characters);
+ while (i < n) {
+ char c = characters.charAt(i);
+ if (Character.isWhitespace(c)) {
+ lastWhitespaceIndex = i;
+ }
- Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1, fontRenderContext);
- lineWidth += characterBounds.getWidth();
+ Rectangle2D characterBounds = font.getStringBounds(ci, i, i + 1, fontRenderContext);
+ lineWidth += characterBounds.getWidth();
- if (lineWidth > breakWidth) {
- if (lastWhitespaceIndex == -1) {
- if (start == i) {
- appendLine(characters, start, start + 1, fontRenderContext);
- } else {
- appendLine(characters, start, i, fontRenderContext);
- i--;
- }
+ if (lineWidth > breakWidth) {
+ if (lastWhitespaceIndex == -1) {
+ if (start == i) {
+ appendLine(characters, start, start + 1, fontRenderContext);
} else {
- appendLine(characters, start, lastWhitespaceIndex, fontRenderContext);
- i = lastWhitespaceIndex;
+ appendLine(characters, start, i, fontRenderContext);
+ i--;
}
-
- start = i + 1;
-
- lineWidth = 0;
- lastWhitespaceIndex = -1;
+ } else {
+ appendLine(characters, start, lastWhitespaceIndex, fontRenderContext);
+ i = lastWhitespaceIndex;
}
- i++;
+ start = i + 1;
+
+ lineWidth = 0;
+ lastWhitespaceIndex = -1;
}
- appendLine(characters, start, i, fontRenderContext);
+ i++;
}
+
+ appendLine(characters, start, i, fontRenderContext);
}
valid = true;