private int findNextStop(final String aText, final int aStartIndex) { int length = 0; int lastStop = 0; while (true) { final int index = aStartIndex + length; if (index >= aText.length()) return index; final char code = aText.charAt(index); if (code == '\n' || code == '|') return index; final int width = font.substringWidth(aText, aStartIndex, length); if (width >= blockWidth) return lastStop; if (code == ' ') lastStop = index; length++; } }
public final void update( final DynamicArray aEntries, final Rectangle aBounds, final FontGenerator aFont) { final int numberOfEntries = aEntries.size; final float spacing = calcSuitableSpacing(aBounds.height, aEntries.size, aFont.charHeight()); final int entriesOffset = (int) ((aBounds.height - numberOfEntries * spacing) / 2); final int offsetX = aBounds.x; final int offsetY = (int) (aBounds.y + entriesOffset + spacing / 2); for (int idx = 0; idx < numberOfEntries; idx++) { final PositionableEntry entry = (PositionableEntry) aEntries.get(idx); entry.setAvailableWidth(aBounds.width); final Position position = entry.getPositionByReference(); position.x = offsetX; position.y = (int) (offsetY + idx * spacing); } }