Package java.text

Examples of java.text.BreakIterator$BreakIteratorGetter


                return null;
            }
        case AccessibleText.WORD:
            try {
                String s = unoObject.getText();
                BreakIterator words = BreakIterator.getWordInstance(getLocale(index));
                words.setText(s);
                int end = words.following(index);
                end = words.previous();
                int start = words.previous();
                if (start == BreakIterator.DONE) {
                    return null;
                }
                return s.substring(start, end);
            } catch (IllegalArgumentException e) {
                return null;
            } catch (IndexOutOfBoundsException e) {
                return null;
            }
        case AccessibleText.SENTENCE:
            try {
                String s = unoObject.getText();
                BreakIterator sentence =
                    BreakIterator.getSentenceInstance(getLocale(index));
                sentence.setText(s);
                int end = sentence.following(index);
                end = sentence.previous();
                int start = sentence.previous();
                if (start == BreakIterator.DONE) {
                    return null;
                }
                return s.substring(start, end);
            } catch (IllegalArgumentException e) {
View Full Code Here


                return null;
            }
        case AccessibleText.WORD:
            try {
                String s = unoObject.getText();
                BreakIterator words = BreakIterator.getWordInstance(getLocale(index));
                words.setText(s);
                int end = words.following(index);
                return s.substring(words.previous(), end);
            } catch (IllegalArgumentException e) {
                return null;
            } catch (IndexOutOfBoundsException e) {
                return null;
            }
        case AccessibleText.SENTENCE:
            try {
                String s = unoObject.getText();
                BreakIterator sentence =
                    BreakIterator.getSentenceInstance(getLocale(index));
                sentence.setText(s);
                int end = sentence.following(index);
                return s.substring(sentence.previous(), end);
            } catch (IllegalArgumentException e) {
                return null;
            } catch (IndexOutOfBoundsException e) {
                return null;
            }
View Full Code Here

              else
              {
                // Get a BreakIterator.  Note that this code doesn't
                // really work for multi-lingual pages (e.g., an English
                // page that contains some Japanese text).
                BreakIterator breaks = BreakIterator.getLineInstance(
                  context.getViewRoot().getLocale());
                breaks.setText(textString);

                _writeTextWithBreaks(context, breaks, textString, columns);
              }
            } // endif wrapping on
            else
View Full Code Here

    {
      return;
    }

    long minimumChunkWidth = 0;
    BreakIterator wordInstance = BreakIterator.getWordInstance();
    wordInstance.setText(text);

    final boolean antiAliasing = RenderUtility.isFontSmooth(getStyleSheet(), data);
    final FontRenderContext fontRenderContext = new FontRenderContext(null, antiAliasing, true);

    int start = wordInstance.first();
    for (int end = wordInstance.next(); end != BreakIterator.DONE; start = end, end = wordInstance.next())
    {
      String word = text.substring(start, end);
      AttributedCharacterIterator attributedCharacterIterator =
          new RichTextSpecProducer(data, resourceManager).computeText(this, word).createAttributedCharacterIterator();
      TextLayout t = new TextLayout(attributedCharacterIterator, fontRenderContext);
View Full Code Here

        // expression (see the Javadoc for class Pattern).
        // Need to avoid both String.split and regular expressions, in order to
        // compile against JCL Foundation (bug 80053).
        // Also need to do this in an NL-sensitive way. The use of BreakIterator
        // was suggested in bug 90579.
        BreakIterator iter = BreakIterator.getWordInstance();
        iter.setText(text);
        int i = iter.first();
        while (i != java.text.BreakIterator.DONE && i < text.length()) {
            int j = iter.following(i);
            if (j == java.text.BreakIterator.DONE)
                j = text.length();
            if (Character.isLetterOrDigit(text.charAt(i))) {
                String word = text.substring(i, j);
                if (match(word))
View Full Code Here

  {
    // Just to be explicit: we're only testing the US locale here.
    Locale loc = Locale.US;
    Locale.setDefault (loc);

    BreakIterator bi = BreakIterator.getSentenceInstance (loc);

    String[] r1 = { "How much time is left?  ",
        "We don't know." };
    check ("How much", "How much time is left?  We don't know.", r1,
     bi, harness);
View Full Code Here

    // Just to be explicit: we're only testing the US locale here.
    Locale loc = Locale.US;
    Locale.setDefault (loc);

    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)
      {
  x = bi.next();
  ++i;
  harness.check (x, i <= t1.length() ? i : BreakIterator.DONE);
      }
  }
View Full Code Here

  {
    // Just to be explicit: we're only testing the US locale here.
    Locale loc = Locale.US;
    Locale.setDefault (loc);

    BreakIterator bi = BreakIterator.getWordInstance (loc);

    String[] r1 = { "How", " ", "much", " ", "time", " ", "is", " ",
        "left", "?", "  ", "We", " ", "don't", " ",
        "know", "." };
    check ("How much", "How much time is left?  We don't know.", r1,
View Full Code Here

  {
    // Just to be explicit: we're only testing the US locale here.
    Locale loc = Locale.US;
    Locale.setDefault (loc);

    BreakIterator bi = BreakIterator.getLineInstance (loc);

    String[] r1 = { "How ", "much ", "time ", "is ", "left?  ",
        "We ", "don't ", "know." };
    check ("How much", "How much time is left?  We don't know.", r1,
     bi, harness);
View Full Code Here

        return out.toString();
    }

    protected static String breakLines(String str,int lineWidth,int indent) {
        StringBuffer out=new StringBuffer();
        BreakIterator i=BreakIterator.getLineInstance();
        i.setText(str);
        int curPos=0;
        int curLinePos=indent;
        int next=i.first();
        while (next!=BreakIterator.DONE) {
            String curSpan=str.substring(curPos,next);
            if (curLinePos+curSpan.length()>lineWidth) {
                out.append(System.getProperty("line.separator"));
                for (int j=0;j<indent;++j)
                    out.append(" ");
                curLinePos=indent;
            }
            out.append(curSpan);
            curLinePos+=curSpan.length();
            curPos=next;
            next=i.next();
        }
        return out.toString();
    }
View Full Code Here

TOP

Related Classes of java.text.BreakIterator$BreakIteratorGetter

Copyright © 2018 www.massapicom. 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.