Package java.text

Examples of java.text.BreakIterator$BreakIteratorCache


              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


  public static final String DEBUG_FOCUS = DEBUG + "/focus"; //$NON-NLS-1$

  public static final String FOCUS_SCROLLING = "focusScrolling"; //$NON-NLS-1$

  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;
    }
View Full Code Here

    width = Math.max(width, extent.x);
    return width;
  }

  public static Point computeWrapSize(GC gc, String text, int wHint) {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();

    int saved = 0;
    int last = 0;
    int height = lineHeight;
    int maxWidth = 0;

    for (int loc = wb.first(); loc != BreakIterator.DONE; loc = wb.next()) {
      String word = text.substring(saved, loc);
      Point extent = gc.textExtent(word);
      if (extent.x > wHint) {
        // overflow
        saved = last;
View Full Code Here

    paintWrapText(gc, text, bounds, false);
  }

  public static void paintWrapText(GC gc, String text, Rectangle bounds,
      boolean underline) {
    BreakIterator wb = BreakIterator.getWordInstance();
    wb.setText(text);
    FontMetrics fm = gc.getFontMetrics();
    int lineHeight = fm.getHeight();
    int descent = fm.getDescent();

    int saved = 0;
    int last = 0;
    int y = bounds.y;
    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);

      if (extent.x > width) {
        // overflow
View Full Code Here

            int pstart = (parent == null ? start : parent.getStartOffset());
            int pend = (parent == null ? end : parent.getEndOffset());

            Segment s = getText(pstart, pend);
            s.first();
            BreakIterator breaker = getBreaker();
            breaker.setText(s);

            // Backward search should start from end+1 unless there's NO end+1
            int startFrom = end + (pend > end ? 1 : 0);
            for (;;) {
                startFrom = breaker.preceding(s.offset + (startFrom - pstart))
                          + (pstart - s.offset);
                if (startFrom > start) {
                    // The break spot is within the view
                    bs[ix++] = startFrom;
                } else {
View Full Code Here

     * @param prefix1 ����ǰ׺
     * @param prefix2 �ڶ��м������е�ǰ׺
     * @return ��ʽ������ַ���
     */
    private String formatLines(String text, int maxLength, Locale locale, String prefix1, String prefix) {
        BreakIterator boundary = BreakIterator.getLineInstance(locale);
        StringBuffer result = new StringBuffer(prefix1);

        boundary.setText(text);

        int start = boundary.first();
        int end = boundary.next();
        int lineLength = 0;

        while (end != BreakIterator.DONE) {
            String word = text.substring(start, end);

            lineLength = lineLength + word.length();

            if (lineLength >= maxLength) {
                result.append("\n").append(prefix);
                lineLength = word.length();
            }

            result.append(word);
            start = end;
            end = boundary.next();
        }

        return result.toString();
    }
View Full Code Here

      docids[i] = scoreDocs[i].doc;
    }
    IndexReaderContext readerContext = reader.getContext();
    List<AtomicReaderContext> leaves = readerContext.leaves();

    BreakIterator bi = (BreakIterator)breakIterator.clone();

    // sort for sequential io
    Arrays.sort(docids);
    Arrays.sort(fields);
   
View Full Code Here

     * Regular Expression:
     *   Before C: [{cased==true}][{wordBoundary!=true}]*
     *   After C: !([{wordBoundary!=true}]*[{cased}])
     */
    private static boolean isFinalCased(String src, int index, Locale locale) {
        BreakIterator wordBoundary = BreakIterator.getWordInstance(locale);
        wordBoundary.setText(src);
        int ch;

        // Look for a preceding 'cased' letter
        for (int i = index; (i >= 0) && !wordBoundary.isBoundary(i);
                i -= Character.charCount(ch)) {

            ch = src.codePointBefore(i);
            if (isCased(ch)) {

                int len = src.length();
                // Check that there is no 'cased' letter after the index
                for (i = index + Character.charCount(src.codePointAt(index));
                        (i < len) && !wordBoundary.isBoundary(i);
                        i += Character.charCount(ch)) {

                    ch = src.codePointAt(i);
                    if (isCased(ch)) {
                        return false;
View Full Code Here

            switch (part) {
            case AccessibleText.CHARACTER:
                return TextComponent.this.getText().substring(index, index+1);
            case AccessibleText.WORD:  {
                    String s = TextComponent.this.getText();
                    BreakIterator words = BreakIterator.getWordInstance();
                    words.setText(s);
                    int end = words.following(index);
                    return s.substring(words.previous(), end);
                }
            case AccessibleText.SENTENCE:  {
                    String s = TextComponent.this.getText();
                    BreakIterator sentence = BreakIterator.getSentenceInstance();
                    sentence.setText(s);
                    int end = sentence.following(index);
                    return s.substring(sentence.previous(), end);
                }
            default:
                return null;
            }
        }
View Full Code Here

                   return null;
                }
                return TextComponent.this.getText().substring(index+1, index+2);
            case AccessibleText.WORD:  {
                    String s = TextComponent.this.getText();
                    BreakIterator words = BreakIterator.getWordInstance();
                    words.setText(s);
                    int start = findWordLimit(index, words, NEXT, s);
                    if (start == BreakIterator.DONE || start >= s.length()) {
                        return null;
                    }
                    int end = words.following(start);
                    if (end == BreakIterator.DONE || end >= s.length()) {
                        return null;
                    }
                    return s.substring(start, end);
                }
            case AccessibleText.SENTENCE:  {
                    String s = TextComponent.this.getText();
                    BreakIterator sentence = BreakIterator.getSentenceInstance();
                    sentence.setText(s);
                    int start = sentence.following(index);
                    if (start == BreakIterator.DONE || start >= s.length()) {
                        return null;
                    }
                    int end = sentence.following(start);
                    if (end == BreakIterator.DONE || end >= s.length()) {
                        return null;
                    }
                    return s.substring(start, end);
                }
View Full Code Here

TOP

Related Classes of java.text.BreakIterator$BreakIteratorCache

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.