Package java.text

Examples of java.text.BreakIterator.current()


    int previous = iter.first();
   
    AttributedCharacterIterator best = null;
   
    while (iter.next() != BreakIterator.DONE) {
      final AttributedCharacterIterator candidate = text.getIterator(null, previous, iter.current());

      if (getPixelWidth(candidate) <= width) {
        // check for line breaks within the provided text
        // unfortunately, the BreakIterators are too dumb to tell *why* they consider the
        // location a break, so the check needs to be implemented here
View Full Code Here


        // unfortunately, the BreakIterators are too dumb to tell *why* they consider the
        // location a break, so the check needs to be implemented here
        final CharacterIterator cit = iter.getText();
        if (isHardLineBreak(cit)) {
          lines.add(candidate);
          previous = iter.current();
          best = null;
        } else {
          best = candidate;
        }
      } else {
View Full Code Here

        // a special check for a hard line break just after the word
        // that got moved to the next line
        final CharacterIterator cit = iter.getText();
        if (isHardLineBreak(cit)) {
          lines.add(text.getIterator(null, previous, iter.current()));
          previous = iter.current();
        }
       
        // Pick the shortest candidate possible (backtrack a bit, if needed)
        if (iter.current() > previous + 1) {
View Full Code Here

        // a special check for a hard line break just after the word
        // that got moved to the next line
        final CharacterIterator cit = iter.getText();
        if (isHardLineBreak(cit)) {
          lines.add(text.getIterator(null, previous, iter.current()));
          previous = iter.current();
        }
       
        // Pick the shortest candidate possible (backtrack a bit, if needed)
        if (iter.current() > previous + 1) {
          iter.previous();
View Full Code Here

          lines.add(text.getIterator(null, previous, iter.current()));
          previous = iter.current();
        }
       
        // Pick the shortest candidate possible (backtrack a bit, if needed)
        if (iter.current() > previous + 1) {
          iter.previous();
        }

        best = null;
View Full Code Here

    // return the original iterator if there are no suitable break points
    AttributedCharacterIterator best = text;
    wordIterator.setText(text);
   
    while (wordIterator.next() != BreakIterator.DONE) {
      final AttributedCharacterIterator candidate = tmpText.getIterator(null, tmpText.getIterator().getBeginIndex(), wordIterator.current() - offset);
     
      if (getPixelWidth(candidate) <= width) {
        best = candidate;
      } else {
        return best;
View Full Code Here

      List<String> tokens = new ArrayList<String>();
      BreakIterator bi = BreakIterator.getWordInstance(aLocale);
      bi.setText(aText);
      int begin = 0;
      while (bi.next() != BreakIterator.DONE) {
        tokens.add(aText.substring(begin, bi.current()));
        begin = bi.current();
      }
      return tokens.toArray(new String[tokens.size()]);
    }
}
View Full Code Here

      BreakIterator bi = BreakIterator.getWordInstance(aLocale);
      bi.setText(aText);
      int begin = 0;
      while (bi.next() != BreakIterator.DONE) {
        tokens.add(aText.substring(begin, bi.current()));
        begin = bi.current();
      }
      return tokens.toArray(new String[tokens.size()]);
    }
}
View Full Code Here

    String t1 = "How much time is left?  We don't know.";
    BreakIterator bi = BreakIterator.getCharacterInstance (loc);

    bi.setText (t1);
    int x = bi.current();

    harness.check (x, 0);
    int i = 0;
    while (x != BreakIterator.DONE && i <= t1.length() + 1)
      {
View Full Code Here

    // Parse out sentences using Java's text-handling API
    BreakIterator bi = BreakIterator.getSentenceInstance(locale);
    bi.setText(text);
    int idx = 0;
    while(bi.next() != BreakIterator.DONE) {
      String sentence = text.substring(idx, bi.current());
      idx = bi.current();
      result.add(new ArrayList<Text>());

      // Parse out words in the sentence
      BreakIterator wi = BreakIterator.getWordInstance(locale);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.