Package java.awt

Examples of java.awt.FontMetrics.charsWidth()


          // But, we assume the approximation is close enough for
          // our drawing a dot for the space.

          // "flushLen+1" ensures text is aligned correctly (or,
          // aligned the same as in getWidth()).
          nextX = x+fm.charsWidth(text, flushIndex,flushLen+1);
          int width = fm.charWidth(' ');

          // Paint background.
          if (bg!=null) {
            paintBackground(x,y, nextX-x,height, g,
View Full Code Here


          break;

      }
    }

    nextX = x+fm.charsWidth(text, flushIndex,flushLen);

    if (flushLen>0 && nextX>=clipStart) {
      if (bg!=null) {
        paintBackground(x,y, nextX-x,height, g,
              ascent, host, bg, !selected);
View Full Code Here

    for (int i=textOffs; i<end; i++) {
      switch (text[i]) {
        case '\t':
          nextX = e.nextTabStop(
            x+fm.charsWidth(text, flushIndex,flushLen), 0);
          if (bg!=null) {
            paintBackground(x,y, nextX-x,fm.getHeight(),
                  g, fm.getAscent(), host, bg, !selected);
          }
          if (flushLen > 0) {
View Full Code Here

          flushLen += 1;
          break;
      }
    }

    nextX = x+fm.charsWidth(text, flushIndex,flushLen);

    if (flushLen>0 && nextX>=clipStart) {
      if (bg!=null) {
        paintBackground(x,y, nextX-x,fm.getHeight(),
                g, fm.getAscent(), host, bg, !selected);
View Full Code Here

    // Note different token types (MLC's, whitespace) could possibly be
    // using different fonts, which means we can't cache the actual width
    // of a tab as it may be different per-token-type.  We could keep a
    // per-token-type cache, but we'd have to clear it whenever they
    // modified token styles.
    int tabW = fm.charsWidth(tabBuf, 0, tabSize);

    // Draw any tab lines.  Here we're assuming that "x" is the left
    // margin of the editor.
    g.setColor(host.getTabLineColor());
    int x0 = x + tabW;
View Full Code Here

        int size = 20;
        Font f = new Font("Serif", Font.PLAIN, size);
        g.setFont(f);
        FontMetrics fm = g.getFontMetrics();
        char[] arr = label.toCharArray();
        int width = fm.charsWidth(arr, 0, arr.length);
        int fs = (2 * size * d.width) / (3 * width);
        f = new Font("Serif", Font.PLAIN, fs);
        g.setFont(f);
        int x = (d.width - (fs * width) / size) / 2;
        int y = (d.height + (2 * fs) / 3) / 2;
View Full Code Here

      int chi = 0;
      while (chi < nameChars.length && lbi < lineBreaks.length) {
        int len = emlen;
        if (chi + len > nameChars.length)
          len = nameChars.length - chi;
        int chw = fm.charsWidth(nameChars, chi, len);
        if (chw > width) {
          while (len > 1) {
            len--;
            chw = fm.charsWidth(nameChars, chi, len);
            if (chw <= width)
View Full Code Here

          len = nameChars.length - chi;
        int chw = fm.charsWidth(nameChars, chi, len);
        if (chw > width) {
          while (len > 1) {
            len--;
            chw = fm.charsWidth(nameChars, chi, len);
            if (chw <= width)
              break;
          }
        } else {
          while (chi + len < nameChars.length) {
View Full Code Here

              break;
          }
        } else {
          while (chi + len < nameChars.length) {
            len++;
            int chw1 = fm.charsWidth(nameChars, chi, len);
            if (chw1 > width) {
              len--;
              break;
            }
            chw = chw1;
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.