Examples of FontMetrics


Examples of java.awt.FontMetrics

public TextFieldWidget(SectionWidget sw, Field field) {
    super(sw, field);

    // Calculate line height.
    Font f = field.getFormat().getFont();
    FontMetrics fm = swingField.getComponent().getFontMetrics(f);
    lineHeight = fm.getHeight();
}
View Full Code Here

Examples of java.awt.FontMetrics

  else formatted = getDateFormatterFor(fmtStr).format((Date)value);
    }
    else {
  formatted = value.toString();
  if (format.isWrap()) {
      FontMetrics fm =
        getWrappingCalcsLabel().getFontMetrics(format.getFont());
      formatted =
    StringUtils.join(StringUtils.wrap(formatted, fm,
              (int)field.getBounds().width),
         "\n");
View Full Code Here

Examples of java.awt.FontMetrics

      }
    }

    // draw everything onto an image before drawing to avoid flicker
    Graphics og = offscreen.getGraphics();
    FontMetrics fm = og.getFontMetrics();

    // clear background color
    og.setColor(bgColor);
    og.fillRect(0, 0, offscreen.getWidth(null), offscreen.getHeight(null));

    og.setColor(fgColor);
    String message = getDescriptionForState();

    // if we had a failure of some sort, notify the user
    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());
        }
      }
    } else {
      og.setColor(fgColor);

      painting = true;

      // get position at the middle of the offscreen buffer
      int x = offscreen.getWidth(null)/2;
      int y = offscreen.getHeight(null)/2;

      // draw logo
      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;

      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

    g.setColor(getBackground());
    g.fillRect(insets.left, insets.top, width, height);
    g.setFont(getFont());
    g.setColor(getForeground());

    FontMetrics metrics = g.getFontMetrics(getFont());

    int xoffset = 0;
    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);
      xoffset += tokenWidth;
    }
View Full Code Here

Examples of java.awt.FontMetrics

    //
    // The code below may be weird, but at least it is predictable weird.
    final ExtendedBaselineInfo baselineInfo = renderableText.getBaselineInfo();
    final long baseline = baselineInfo.getBaseline(baselineInfo.getDominantBaseline());

    final FontMetrics fm = g2.getFontMetrics();
    final Rectangle2D rect = fm.getMaxCharBounds(g2);
    final long awtBaseLine = StrictGeomUtility.toInternalValue(-rect.getY());

    final GlyphList gs = renderableText.getGlyphs();
    if (metaData.isFeatureSupported(OutputProcessorFeature.FAST_FONTRENDERING) &&
        isNormalTextSpacing(renderableText))
View Full Code Here

Examples of java.awt.FontMetrics

      if (iter.getIndex() == iter.getRunStart())
      {
        if (stringbuffer.length() > 0)
        {
          drawString(stringbuffer.toString(), x, y);
          final FontMetrics fontmetrics = getFontMetrics();
          x = (float) ((double) x + fontmetrics.getStringBounds(stringbuffer.toString(), this).getWidth());
          stringbuffer.delete(0, stringbuffer.length());
        }
        doAttributes(iter);
      }
      stringbuffer.append(c);
View Full Code Here

Examples of java.awt.FontMetrics

            int x = point1.x + (symbol_.getIconWidth() / 2);
            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;
            y += h;
View Full Code Here

Examples of java.awt.FontMetrics

                                                     Font f, String s) {
        BufferedImage bi = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
        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

    g.setColor(Color.black);
    Point boxUpperLeft = new Point(60, 60);
    Dimension boxSize  = new Dimension(200, 200);
    Font f = new Font("TimesRoman", Font.PLAIN, 14);
    g.setFont(f);
    FontMetrics fm = g.getFontMetrics(f);
    BoundingBox box = new BoundingBox(boxUpperLeft, boxSize);
    String string = "Hello World! this is a really long string";
    int padding = 10;
    BoundingBox child = null;
    try {
View Full Code Here

Examples of java.awt.FontMetrics

               (int)box.getAbsoluteLocation().getY(),
               (int)box.getSize().getWidth(),
               (int)box.getSize().getHeight());
    Font f = new Font("Helvetica", Font.PLAIN, 12);
    g.setFont(f);
    FontMetrics fm = g.getFontMetrics();
    String line1 = "Line 1";
    String line2 = "Line 2";
    String line3 = "Line 3 realllllly loooooong   .h gkjhg kjh gkjh gkjhg kjhg kjhg kjh gk jbhg";
    int padding = 5;
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.