Package java.awt

Examples of java.awt.FontMetrics.stringWidth()


        int minWidth = 0;
        FontMetrics fontMetrics = label.getFontMetrics(label.getFont());
        int height = fontMetrics.getHeight();
        for (T presentable : getAllPossibleValues()) {
            int width = fontMetrics.stringWidth(presentable.getName());
            if (presentable.getIcon() != null) {
                width = width + 16;
            }
            minWidth = Math.max(minWidth, width);
        }
View Full Code Here


            if (presentable.getIcon() != null) {
                width = width + 16;
            }
            minWidth = Math.max(minWidth, width);
        }
        int width = fontMetrics.stringWidth(text);
        if (icon != null) {
            width = width + 16;
        }
        minWidth = Math.max(minWidth, width);
        label.setPreferredSize(new Dimension(minWidth + 6, height));
View Full Code Here

        Point2D p = t.transform (
          new Point2D.Double (point.getX (), point.getY ()), null);
        g.drawString (text, (int) p.getX (), (int) p.getY ());
       
        FontMetrics fontMetrics = g.getFontMetrics ();
        textWidth = fontMetrics.stringWidth (text);
        textActualHeight = fontMetrics.getAscent () - fontMetrics.getDescent ();
    }
   
    /**
     * Gets the list of selected points.
View Full Code Here

        RenderingHints.VALUE_FRACTIONALMETRICS_ON);
    ctx.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
        RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
    FontMetrics fm = ctx.getFontMetrics();

    int width = fm.stringWidth(label);
    ctx.translate(x + width / 2 * Math.cos(angle),
        y + width / 2 * Math.sin(Math.abs(angle)));
    ctx.rotate(angle);
    ctx.translate(-width / 2, fm.getMaxAscent());
    ctx.setPaint(strokeColor);
View Full Code Here

    }
   
    Font font = itemList.getFont();
    FontMetrics fontMetrics = itemList.getFontMetrics(font);
    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
    int width = fontMetrics.stringWidth(maxBuffer.toString()) + 10;
    width = Math.min(width, screen.width -100);
    int rowCount = Math.min(itemVector.size(), 10);
    itemList.setVisibleRowCount(rowCount);
    itemList.setFixedCellWidth(width);
  }
View Full Code Here

        }

        nameLabel.setText(columnName);

        FontMetrics fontMetrics = nameLabel.getFontMetrics(nameLabel.getFont());
        width += fontMetrics.stringWidth(columnName) + 24;
        mainPanel.setPreferredSize(new Dimension(width, (int) mainPanel.getPreferredSize().getHeight()));

        return mainPanel;
    }
View Full Code Here

    final int height = getHeight();

    // Get size of text
    graphics.setFont(getFont());
    final FontMetrics fontMetrics = graphics.getFontMetrics();
    final int dxText = fontMetrics.stringWidth(label);
    final int dxMargin = 10;

    // Does text fit with a nice margin?
    if (dxText > width - dxMargin)
    {
View Full Code Here

    final int height = getHeight();

    // Get size of text
    graphics.setFont(getFont());
    final FontMetrics fontMetrics = graphics.getFontMetrics();
    final int dxText = fontMetrics.stringWidth(label);
    final int dxMargin = 10;

    // Does text fit with a nice margin?
    if (dxText > width - dxMargin)
    {
View Full Code Here

    cluePointSize=pointSize;
    if (this.getGraphics()==null) return;
    Point location = this.getLocation();
    Font f=new Font("",Font.BOLD,cluePointSize);
    FontMetrics fm= this.getGraphics().getFontMetrics(f);
    int fontWidth=fm.stringWidth("0");
    int fontHeight=fm.getHeight();
    rowBox.setFontAndSize(f, fontWidth, fontHeight);
    columnBox.setFontAndSize(f, fontWidth, fontHeight);
    repack();
  }
View Full Code Here

   * @return longest width - relies on FontMetrics.stringWidth for calculation
   */
  private int getMaxColumnWidth(int index) {
    FontMetrics metrics = getGraphics().getFontMetrics();
    int longestWidth =
      metrics.stringWidth("  " + table.getColumnName(index) + "  ")
      + (2 * table.getColumnModel().getColumnMargin());

    for (int i = 0, j = tableModel.getRowCount(); i < j; i++) {
      Component c =
        renderer.getTableCellRendererComponent(
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.