Examples of charWidth()


Examples of java.awt.FontMetrics.charWidth()

    }

    public Dimension getPreferredSize() {
        FontMetrics fm = getFontMetrics(getFont());
        return new Dimension(
            fm.charWidth('0')*68,
            fm.getHeight()*(model_.getLength()+15)/16
        );
    }

    public void setModel(BinaryModel m) {
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

            FontMetrics fm = getFontMetrics(f);

            for (char i = ' '; i <= 'z'; i++) {

                int cw = fm.charWidth(i);

                if (width == -1 || cw == width) {

                    width = cw;
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

                    String str = doc.getText(soff, size);
                    FontMetrics fm = text.getFontMetrics(text.getFont());
                    int h = fm.getHeight();
                    for (int i = 0; i < size; i++) {
                        Rectangle r = text.modelToView(soff + i);
                        r.width = fm.charWidth(str.charAt(i));
                        r.height = h;
                        if (r.contains(point)) {
                            text.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
                            break;
                        }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

  }

  public void setTabWidth(int charactersPerTab) {
    this.tabWidth = charactersPerTab;
    FontMetrics fm = getFontMetrics(getFont());
    int charWidth = fm.charWidth('w');
    int tabWidth = charWidth * charactersPerTab;

    TabStop[] tabs = new TabStop[50];

    for(int j = 0; j < tabs.length; j++) {
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

            for (int i = 0; i < captchaCode.length(); i++) {

                // this is a separate canvas used for the character so that
                // we can rotate it independently
                int charWidth = fontMetrics.charWidth(captchaCode.charAt(i));
                int charDim = Math.max(maxAdvance, fontHeight);
                int halfCharDim = (charDim / 2);

                BufferedImage charImage = new BufferedImage(charDim, charDim, BufferedImage.TYPE_INT_ARGB);
                Graphics2D charGraphics = charImage.createGraphics();
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    if (end > text.length()) { setInteger(component, "end", end = text.length(), 0); }
    int offset = getInteger(component, ":offset", 0);
    int off = offset;
    Font currentfont = (Font) get(component, "font");
    FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
    int caret = hidden ? (fm.charWidth('*') * end) :
      fm.stringWidth(text.substring(0, end));
    if (off > caret) {
      off = caret;
    }
    else if (off < caret - width + 4) {
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

      off = caret;
    }
    else if (off < caret - width + 4) {
      off = caret - width + 4;
    }
    off = Math.max(0, Math.min(off, (hidden ? (fm.charWidth('*') *
      text.length()) : fm.stringWidth(text)) - width + 4));
    if (off != offset) {
      setInteger(component, ":offset", off, 0);
    }
  }
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

      int columns = getInteger(component, "columns", 0);
      int rows = getInteger(component, "rows", 0); // 'e' -> 'm' ?
      Font currentfont = (Font) get(component, "font");
      FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
      return new Dimension(
        ((columns > 0) ? (columns * fm.charWidth('e') + 2) : 76) + 2 + block,
        ((rows > 0) ? (rows * fm.getHeight() - fm.getLeading() + 2) : 76) + 2 + block);
    }
    if ("tabbedpane" == classname) {
      String placement = getString(component, "placement", "top");
      boolean horizontal = ((placement != "left") && (placement != "right"));
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

  private Dimension getFieldSize(Object component) {
    int columns = getInteger(component, "columns", 0);
    Font currentfont = (Font) get(component, "font");
    FontMetrics fm = getFontMetrics((currentfont != null) ? currentfont : font);
    return new Dimension(((columns > 0) ?
      (columns * fm.charWidth('e')) : 76) + 4,
      fm.getAscent() + fm.getDescent() + 4); // fm.stringWidth(text)
  }

  /**
   * @param component a widget including the text and icon parameters
View Full Code Here

Examples of java.awt.FontMetrics.charWidth()

    int caret = 0;
    if (focus) {
      int start = getInteger(component, "start", 0);
      int end = getInteger(component, "end", 0);
      caret = hidden ? (fm.charWidth('*') * end) :
        fm.stringWidth(text.substring(0, end));
      if (start != end) {
        int is = hidden ? (fm.charWidth('*') * start) :
          fm.stringWidth(text.substring(0, start));
        g.setColor(c_select);
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.