@Override public int first() { fIndex= fIterator.first(); return fIndex; }
@Override public int first() { fIndex = fIterator.first(); return fIndex; }
@Override public int first() { fIndex = fIterator.first(); return fIndex; }
@Override public int first() { // Don't suppress a break opportunity at the beginning of text. return delegate.first(); }
@Override public int first() { fIndex= fIterator.first(); return fIndex; }
@Override public int first() { return fIcuBrkItr.first(); }
public int first() { fIndex= fIterator.first(); return fIndex; }
private List<String> getAllWords(final String preparedString) { final List<String> words = new ArrayList<>(); final BreakIterator breakIterator = BreakIterator.getWordInstance(); breakIterator.setText(preparedString); int start = breakIterator.first(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { words.add(preparedString.substring(start, end)); } return words; } }
private boolean matchesSegments(String id) { BreakIterator iter = BreakIterator.getWordInstance(); iter.setText(id); int i = iter.first(); while (i != java.text.BreakIterator.DONE && i < id.length()) { int j = iter.following(i); if (j == java.text.BreakIterator.DONE) { j = id.length(); } // match the word if (Character.isLetterOrDigit(id.charAt(i))) { String word = id.substring(i, j); if (matches(word)) return true; } i = j; } return false; } }
int i = iter.first(); while (i != java.text.BreakIterator.DONE && i < text.length()) { int j = iter.following(i);
public static int computeMinimumWidth(GC gc, String text) { BreakIterator wb = BreakIterator.getWordInstance(); wb.setText(text); int last = 0; int width = 0; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { String word = text.substring(last, loc); Point extent = gc.textExtent(word); width = Math.max(width, extent.x); last = loc; } String lastWord = text.substring(last); Point extent = gc.textExtent(lastWord); width = Math.max(width, extent.x); return width; }
public static int computeMinimumWidth(GC gc, String text) { BreakIterator wb = BreakIterator.getWordInstance(); wb.setText(text); int last = 0; int width = 0; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { String word = text.substring(last, loc); Point extent = gc.textExtent(word); width = Math.max(width, extent.x); last = loc; } String lastWord = text.substring(last); Point extent = gc.textExtent(lastWord); width = Math.max(width, extent.x); return width; }
private void computeTextFragments(GC gc) { if (textFragments != null) return; ArrayList<TextFragment> list = new ArrayList<>(); BreakIterator wb = BreakIterator.getLineInstance(); wb.setText(getText()); int cursor = 0; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { if (loc == 0) continue; String word = text.substring(cursor, loc); Point extent = gc.textExtent(word); list.add(new TextFragment((short) loc, (short) extent.x)); cursor = loc; } textFragments = list.toArray(new TextFragment[list .size()]); }
/** * Finds a good line breaking point */ private int getLineBreak(String line, GC gc) { lineBreaker.setText(line); int lastGoodIndex = 0; int currentIndex = lineBreaker.first(); int width = gc.textExtent(line.substring(0, currentIndex)).x; while (width < maxWidth && currentIndex != BreakIterator.DONE) { lastGoodIndex = currentIndex; currentIndex = lineBreaker.next(); if (currentIndex == BreakIterator.DONE) { break; } width = gc.textExtent(line.substring(0, currentIndex)).x; } return lastGoodIndex; }
private void computeTextFragments(GC gc) { if (textFragments != null) return; ArrayList<TextFragment> list = new ArrayList<>(); BreakIterator wb = BreakIterator.getLineInstance(); wb.setText(getText()); int cursor = 0; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { if (loc == 0) continue; String word = text.substring(cursor, loc); Point extent = gc.textExtent(word); list.add(new TextFragment((short) loc, (short) extent.x)); cursor = loc; } textFragments = list.toArray(new TextFragment[list .size()]); }
/** * Gets a list of words/tokens from a text container. * @param tc the text container to process. * @return the list of words/tokens. */ private List<String> getWordsFromDefaultBreaker (TextContainer tc) { // Get the plain text to process String content; if ( tc.contentIsOneSegment() ) { content = TextUnitUtil.getText(tc.getFirstContent()); } else { content = TextUnitUtil.getText(tc.getUnSegmentedContentCopy()); } if ( content.length() == 0 ) { return Collections.emptyList(); } // Break down the text into "words" if ( breaker == null ) { breaker = BreakIterator.getWordInstance(srcLocale); } breaker.setText(content); ArrayList<String> words = new ArrayList<String>(); int start = breaker.first(); for ( int end=breaker.next(); end!=BreakIterator.DONE; start=end, end=breaker.next()) { addWord(words, content.substring(start, end)); } return words; }
fPredecessor= fWordIterator.first(); fSuccessor= fWordIterator.next();
fPredecessor= fWordIterator.first(); fSuccessor= fWordIterator.next();
fPredecessor= fWordIterator.first(); fSuccessor= fWordIterator.next();
int width = bounds.width; for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) { String line = text.substring(saved, loc); Point extent = gc.textExtent(line);