Package java.awt

Examples of java.awt.FontMetrics.stringWidth()


      int ty = y + (height - th) / 2 + ta;
      g.drawString(text, cx, ty);
      if (mnemonic) {
        int imnemonic = getInteger(component, "mnemonic", -1);
        if ((imnemonic != -1) && (imnemonic < text.length())) {
          int mx = cx + fm.stringWidth(text.substring(0, imnemonic));
          g.drawLine(mx, ty + 1, mx + fm.charWidth(text.charAt(imnemonic)), ty + 1);
        }
      }
      if (underline) { // for link button
        g.drawLine(cx, ty + 1, cx + tw, ty + 1);
View Full Code Here


        int currentSize = a_font.getSize();

        while(maxSize - minSize > 2)
        {
            FontMetrics fm = a_g.getFontMetrics(new Font(a_font.getName(), a_font.getStyle(), currentSize));
            int fontWidth = fm.stringWidth(a_text);
            int fontHeight = fm.getHeight();

            if((fontWidth > a_width) || (fontHeight > a_height))
            {
                maxSize = currentSize;
View Full Code Here

        {
            fontSize = FontHelpers.getMaxFontSizeForRect(g, f, heldText, heldRectWidth, heldRectHeight);
            heldFont = new Font(heldFontName, Font.PLAIN, fontSize);

            FontMetrics fm = getGraphics().getFontMetrics(heldFont);
            heldTextX = heldRectX + (heldRectWidth - fm.stringWidth(heldText)) / 2;
            heldTextY = heldRectY + fm.getMaxAscent();
        }
    }
   
    /**
 
View Full Code Here

    @Override
    public Dimension getPreferredSize() {
      final Dimension size = super.getPreferredSize();
      final FontMetrics fm = getFontMetrics(getFont());
      size.width = fm.stringWidth(getText()) + getInsets().left + getInsets().right + 5;
      return size;
    }
  }

  /** Overridden for performance reasons. See the <a href="#override">Implementation Note</a> for more information. */
 
View Full Code Here

        if (logo != null) {
            width = logo.getWidth(this);
            height += logo.getHeight(this);
        } else {
            final FontMetrics metrics = getFontMetrics(logoFont);
            width = metrics.stringWidth(LOGO_TEXT);
            height = metrics.getHeight();
        }
        height += PADDING;

        final Dimension text = textBounds();
View Full Code Here

        final FontMetrics titleMetrics = getFontMetrics(titleFont);
        int width = 0;
        int height = 0;

        // framework details
        width = titleMetrics.stringWidth(AboutIsis.getFrameworkName());
        height += titleLineHeight;
        width = Math.max(width, textMetrics.stringWidth(AboutIsis.getFrameworkCopyrightNotice()));
        height += textLineHeight;
        width = Math.max(width, textMetrics.stringWidth(frameworkVersion()));
        height += textLineHeight;
View Full Code Here

        height += textLineHeight;

        // application details
        String text = AboutIsis.getApplicationName();
        if (text != null) {
            width = Math.max(width, titleMetrics.stringWidth(text));
            height += titleLineHeight;
        }
        text = AboutIsis.getApplicationCopyrightNotice();
        if (text != null) {
            width = Math.max(width, textMetrics.stringWidth(text));
View Full Code Here

        if (dummy.length() < 2) {
            dummy = DUMMY_STRING;
        }

        Dimension d = new Dimension();
        d.width = metrics.stringWidth(dummy) + 16;
        d.height = lineCount * h + 100;
        setPreferredSize(d);
        setSize(d);
    }

View Full Code Here

        }

        for (int i = startLine; i < endLine; i++) {
            String text;
            text = Integer.toString(i + 1) + " ";
            int w = metrics.stringWidth(text);
            int y = i * h;
            g.setColor(Color.blue);
            g.drawString(text, 0, y + ascent);
            int x = width - ascent;

View Full Code Here

    final MfDcState state = file.getCurrentState();
    final MfLogFont lFont = state.getLogFont();

    state.prepareDrawText();
    final FontMetrics metrics = graphics.getFontMetrics();
    final int textWidth = metrics.stringWidth(text);
    final Point p = getScaledOrigin();
    final int x = p.x + calcDeltaX(state.getVerticalTextAlignment(), textWidth);
    int y = p.y + calcDeltaY(state.getHorizontalTextAlignment(), metrics);

    if (isOpaque() || state.getBkMode() != BrushConstants.TRANSPARENT)
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.