Examples of stringWidth()


Examples of java.awt.FontMetrics.stringWidth()

      String str = Strings.get("ttyDesc", "" + rows, "" + cols);
      FontMetrics fm = g.getFontMetrics();
      int strWidth = fm.stringWidth(str);
      if (strWidth + BORDER > bds.getWidth()) {
        str = Strings.get("ttyDescShort");
        strWidth = fm.stringWidth(str);
      }
      int x = bds.getX() + (bds.getWidth() - strWidth) / 2;
      int y = bds.getY() + (bds.getHeight() + fm.getAscent()) / 2;
      g.drawString(str, x, y);
    }
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

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

    FontMetrics metrics = HELPER_LABEL.getFontMetrics(font);
    return metrics.stringWidth(str);
  }

  /**
   * Gets the width of the specified char array.
   *
 
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

    if (fatalError) {
      String[] errorMessage = (certificateRefused) ? certificateRefusedMessage : genericErrorMessage;

      for(int i=0; i<errorMessage.length; i++) {
        if(errorMessage[i] != null) {
          int messageX = (offscreen.getWidth(null) - fm.stringWidth(errorMessage[i])) / 2;
          int messageY = (offscreen.getHeight(null) - (fm.getHeight() * errorMessage.length)) / 2;

          og.drawString(errorMessage[i], messageX, messageY + i*fm.getHeight());
        }
      }
 
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

      if (logo != null) {
        og.drawImage(logoBuffer, x-logo.getWidth(null)/2, y-logo.getHeight(null)/2, this);
      }

      // draw message
      int messageX = (offscreen.getWidth(null) - fm.stringWidth(message)) / 2;
      int messageY = y + 20;

      if (logo != null) messageY += logo.getHeight(null)/2;
      else if (progressbar != null) messageY += progressbar.getHeight(null)/2;
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

      og.drawString(message, messageX, messageY);

      // draw subtaskmessage, if any
      if(subtaskMessage.length() > 0) {
        messageX = (offscreen.getWidth(null) - fm.stringWidth(subtaskMessage)) / 2;
        og.drawString(subtaskMessage, messageX, messageY+20);
      }

      // draw loading bar, clipping it depending on percentage done
      if (progressbar != null) {
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

    int yoffset = metrics.getHeight();

    StringTokenizer tokenizer = new StringTokenizer(text, " ", true);
    while (tokenizer.hasMoreTokens()) {
      String token = tokenizer.nextToken();
      int tokenWidth = metrics.stringWidth(token);
      if (xoffset + tokenWidth > width) {
        yoffset += metrics.getHeight();
        xoffset = 0;
      }
      g.drawString(token, xoffset + insets.left, yoffset + insets.bottom);
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

            int y = point1.y + symbol_.getIconHeight()
                    + echelon_.getIconHeight();
            Font font = new Font("Helvetica", java.awt.Font.PLAIN, 10);
            g.setFont(font);
            FontMetrics fm = g.getFontMetrics();
            int w = fm.stringWidth(eunit.bottom1);
            int h = fm.getHeight();
            total_height += h;
            if (w > total_width)
                total_width = w;
            x -= w / 2;
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

        Graphics g = bi.getGraphics();
        g.setFont(f);
        g.setColor(Color.black);
        FontMetrics fm = g.getFontMetrics();

        int stringWidth = fm.stringWidth(s);
        int stringHeight = f.getSize() - 2;
        g.drawString(s, (width - stringWidth) / 2, height - (height - stringHeight) / 2);
        return new ImageIcon(bi);
    }
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

    for(int i=0;i<modes.length;i++)
      g.drawString(modes[i],100+(50*i),ty-14);
   
    FontMetrics fm = g.getFontMetrics();
    for(int i=0;i<fonts.length;i++)
      g.drawString(fonts[i],98-fm.stringWidth(fonts[i]),ty+(12*i));
   
    Font cf = g.getFont();
   
    for(int i=0;i<fonts.length;i++) {
      for(int j=0;j<modes.length;j++) {
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

        // something correct
        width = (float) bounds.getWidth();
      }
      else
      {
        width = fm.stringWidth(text);
      }


      final LineMetrics metrics = f.getLineMetrics(text, frc);
      final float descent = metrics.getDescent();
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.