Examples of charsWidth()


Examples of java.awt.FontMetrics.charsWidth()

    if (chars == null) {
      return 0;
    }

    FontMetrics metrics = HELPER_LABEL.getFontMetrics(font);
    return metrics.charsWidth(chars, offset, length);
  }

  /**
   * Creates a text area that holds a help text.
   *
 
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

      FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
      int width = 0, height = 0;
      int caretx = 0; int carety = 0;
      for (int i = 0, j = 0; j <= chars.length; j++) {
        if ((j == chars.length) || (chars[j] == '\n')) {
          width = Math.max(width, fm.charsWidth(chars, i, j - i));
          if ((end >= i) && (end <= j)) {
            caretx = fm.charsWidth(chars, i, end - i);
            carety = height;
          }
          height += fm.getHeight();
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

      int caretx = 0; int carety = 0;
      for (int i = 0, j = 0; j <= chars.length; j++) {
        if ((j == chars.length) || (chars[j] == '\n')) {
          width = Math.max(width, fm.charsWidth(chars, i, j - i));
          if ((end >= i) && (end <= j)) {
            caretx = fm.charsWidth(chars, i, end - i);
            carety = height;
          }
          height += fm.getHeight();
          i = j + 1;
        }
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

      FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
      int lines = (height - 4 + fm.getLeading()) / fm.getHeight();
      boolean prevletter = false; int n = chars.length; int linecount = 0;
      for (int i = 0, j = -1, k = 0; k <= n; k++) { // j is the last space index (before k)
        if (((k == n) || (chars[k] == '\n') || (chars[k] == ' ')) &&
            (j > i) && (fm.charsWidth(chars, i, k - i) > width)) {
          chars[j] = '\n';
          k--; // draw line to the begin of the current word (+ spaces) if it is out of width
        }
        else if ((k == n) || (chars[k] == '\n')) { // draw line to the text/line end
          j = k; prevletter = false;
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

        if ((j == chars.length) || (chars[j] == '\n')) {
          if (clipy + clipheight <= ascent) { break; } // the next lines are bellow paint rectangle
          if (clipy < ascent + fontheight) { // this line is not above painting area
            if (focus && (is != ie) && (ie >= i) && (is <= j)) {
              int xs = (is < i) ? -1 : ((is > j) ? (viewwidth - 1) :
                fm.charsWidth(chars, i, is - i));
              int xe = ((j != -1) && (ie > j)) ? (viewwidth - 1) :
                fm.charsWidth(chars, i, ie - i);
              g.setColor(c_select);
              g.fillRect(1 + xs, ascent, xe - xs + evm, fontheight + evm);
            }
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

          if (clipy < ascent + fontheight) { // this line is not above painting area
            if (focus && (is != ie) && (ie >= i) && (is <= j)) {
              int xs = (is < i) ? -1 : ((is > j) ? (viewwidth - 1) :
                fm.charsWidth(chars, i, is - i));
              int xe = ((j != -1) && (ie > j)) ? (viewwidth - 1) :
                fm.charsWidth(chars, i, ie - i);
              g.setColor(c_select);
              g.fillRect(1 + xs, ascent, xe - xs + evm, fontheight + evm);
            }
            g.setColor(enabled ? c_text : c_disable);
            g.drawChars(chars, i, j - i, 1, ascent + fontascent);
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

              g.fillRect(1 + xs, ascent, xe - xs + evm, fontheight + evm);
            }
            g.setColor(enabled ? c_text : c_disable);
            g.drawChars(chars, i, j - i, 1, ascent + fontascent);
            if (focus && (end >= i) && (end <= j)) {
              int caret = fm.charsWidth(chars, i, end - i);
              g.setColor(c_focus);
              g.fillRect(caret, ascent, 1 + evm, fontheight + evm);
            }
          }
          ascent += fontheight;
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

        else if (keycode == KeyEvent.VK_DOWN) { y += fh; }
        else {
          int dy = getRectangle(component, ":port").height;
          y += (keycode == KeyEvent.VK_PAGE_UP) ? -dy : dy; // VK_PAGE_DOWN
        }
        int x = fm.charsWidth(chars, linestart, iend - linestart);
        iend = getCaretLocation(component, x, y, true, false);
        if (!shiftdown) { istart = iend; }
      }
      else return processField(component, shiftdown, controldown, modifiers,
          keychar, keycode, true, false, false);
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

            for (int i = 0; i < SCREEN_HEIGHT; i++) {
                int offset = i * SCREEN_WIDTH;
                int lenght = SCREEN_WIDTH;
                if (offset <= cursorOffset && cursorOffset < offset + SCREEN_WIDTH) {
                    FontMetrics fm = getFontMetrics(getFont());
                    int x = margin + fm.charsWidth(buffer, offset, cursorOffset - offset);
                    int y = h + i * h;
                    int width = fm.charWidth(buffer[cursorOffset]);
                    g.drawLine(x, y, x + width, y);
                }
                g.drawChars(buffer, offset, lenght, margin, h + i * h);
 
View Full Code Here

Examples of java.awt.FontMetrics.charsWidth()

            for (int i = 0; i < getHeight(); i++) {
                graphics.drawChars(textBuffer, offset, length, 0, y);
           
                // draw the cursor
                if (cursorVisible && (cursorOffset >= offset) && (cursorOffset < (offset + length))) {
                    final int x1 = fm.charsWidth(buffer, offset, cursorOffset - offset);
                    final char charUnderCursor = buffer[cursorOffset];
                    final int width = fm.charWidth(charUnderCursor);
                   
                    graphics.fillRect(x1, y - fontHeight + 1, width, fontHeight);
                    if (charUnderCursor >= ' ') {
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.