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);
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

    g.setFont(new Font(font.getName(), font.getStyle(), fontSize));

    FontMetrics fontMetrics = g.getFontMetrics();
    int vMargin = fontSize + height / 8;
    int hMargin = (width - fontMetrics.charsWidth(text.toCharArray(), 0,
        text.length())) / 2;

    g.setColor(color);
    g.drawString(text, x + hMargin, y + vMargin);
  }
View Full Code Here

            SWContext swctx = (SWContext)ctx;
            FontMetrics fm = swctx.fm;
            char[] chars = swctx.chars;
            int wid = 0;
            do {
                wid += fm.charsWidth(chars, 0, chars.length);
            } while (--numReps >= 0);
        }
    }

    public static class CharsBounds extends TextMeasureTests {
View Full Code Here

            char[] chars = swctx.chars;
            int wid = 0;
            Rectangle r = null;
            do {
                r = null;
                int dx = fm.charsWidth(chars, 0, chars.length);
                int dy = fm.getAscent() + fm.getDescent() + fm.getLeading();
                int x = 0;
                int y = -fm.getAscent();
                r = new Rectangle(x, y, dx, dy);
            } while (--numReps >= 0);
View Full Code Here

          nextX = e.nextTabStop(nextX, 0);
          stableX = nextX; // Cache ending x-coord. of tab.
          start = i + 1; // Do charsWidth() from next char.
        }
        else {
          nextX = stableX + fm.charsWidth(text, start, i - start + 1);
        }
        if (x >= currX && x < nextX) {
          if ((x - currX) < (nextX - x)) {
            return last + i - token.textOffset;
          }
View Full Code Here

          // adjacent whitespace into a single token, there
          // aren't usually any characters to compute a width
          // for here, so we check before calling.
          w = i - currentStart;
          if (w > 0)
            width += fm.charsWidth(text, currentStart, w);
          currentStart = i + 1;
          width = e.nextTabStop(width, 0);
        }
      }
      // Most (non-whitespace) tokens will have characters at this
View Full Code Here

      }
      // Most (non-whitespace) tokens will have characters at this
      // point to get the widths for, so we don't check for w>0 (mini-
      // optimization).
      w = endBefore - currentStart;
      width += fm.charsWidth(text, currentStart, w);
    }
    return width - x0;
  }

View Full Code Here

      switch (text[i]) {

        case '\t':

          // Fill in background.
          nextX = x+fm.charsWidth(text, flushIndex,flushLen);
          float nextNextX = e.nextTabStop(nextX, 0);
          if (bg!=null) {
            paintBackground(x,y, nextNextX-x,height, g,
                    ascent, host, bg, !selected);
          }
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.