Package com.ibm.icu.text

Examples of com.ibm.icu.text.BreakIterator


    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

     * @param type
     * @draft ICU 3.6
     * @provisional This API might change or be removed in a future release.
     */
    protected BreakIterator guessBreakIterator(int type) {
        BreakIterator bitr = null;
        ULocale brkLocale = getAvailableLocale(TYPE_BREAKITERATOR);
        if (brkLocale == null) {
            brkLocale = ULocale.ROOT;
        }
        switch (type) {
View Full Code Here

                        if(!csp.addStringCaseClosure(str, foldSet)) {
                            foldSet.add(str); // does not map to code points: add the folded string itself
                        }
                    }
                } else {
                    BreakIterator bi = BreakIterator.getWordInstance(root);
                    Iterator it = strings.iterator();
                    while (it.hasNext()) {
                        str = (String)it.next();
                        foldSet.add(UCharacter.toLowerCase(root, str));
                        foldSet.add(UCharacter.toTitleCase(root, str, bi));
View Full Code Here

  public void inform(ResourceLoader loader) throws IOException {
    assert tailored != null : "init must be called first!";
    if (tailored.isEmpty()) {
      config = new DefaultICUTokenizerConfig(cjkAsWords);
    } else {
      final BreakIterator breakers[] = new BreakIterator[UScript.CODE_LIMIT];
      for (Map.Entry<Integer,String> entry : tailored.entrySet()) {
        int code = entry.getKey();
        String resourcePath = entry.getValue();
        breakers[code] = parseRules(resourcePath, loader);
      }
View Full Code Here

     * @param type
     * @draft ICU 3.6
     * @provisional This API might change or be removed in a future release.
     */
    protected BreakIterator guessBreakIterator(int type) {
        BreakIterator bitr = null;
        ULocale brkLocale = getAvailableLocale(TYPE_BREAKITERATOR);
        if (brkLocale == null) {
          brkLocale = ULocale.ROOT;
        }
        switch (type) {
View Full Code Here

        text.setLayoutData(gd);
        return text;
    }

    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

  private void computeTextFragments(GC gc) {
    if (textFragments != null)
      return;
    ArrayList 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));
View Full Code Here

TOP

Related Classes of com.ibm.icu.text.BreakIterator

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.