}
@Override
public void validate() {
if (!isValid()) {
TextNode textNode = (TextNode)getNode();
FontRenderContext fontRenderContext = Platform.getFontRenderContext();
int breakWidth = getBreakWidth();
CharacterIterator ci = textNode.getCharacterIterator(start);
float lineWidth = 0;
int lastWhitespaceIndex = -1;
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, fontRenderContext);
lineWidth += characterBounds.getWidth();
c = ci.current();
}
int end;
if (wrapText) {
if (textNode.getCharacterCount() == 0) {
end = start;
} else {
if (lineWidth < breakWidth) {
end = ci.getEndIndex();
} else {
if (lastWhitespaceIndex == -1) {
end = ci.getIndex() - 1;
if (end <= start) {
end = start + 1;
}
} else {
end = lastWhitespaceIndex + 1;
}
}
}
} else {
end = ci.getEndIndex();
}
glyphVector = font.createGlyphVector(fontRenderContext,
textNode.getCharacterIterator(start, end));
if (end < ci.getEndIndex()) {
length = end - start;
next = new TextNodeView(textNode, end);
} else {