Examples of stringWidth()


Examples of java.awt.FontMetrics.stringWidth()

      g.drawString( versionStr, x1, y1 ) ;
      g.drawString( buildStr, x1, y2 ) ;

      g.setFont( font2) ;
      fm = g.getFontMetrics( font2 ) ;
      g.drawString( "JabRef", (getWidth() - fm.stringWidth("JabRef")) /2, fm.getHeight()+10) ;


      for ( TextBlock block : textBlocks){
        if (block.isVisible()) // only if Block is marked as visible
        {
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

    private void calculateBaseUnits() {
        // This calculation comes from:
        // http://support.microsoft.com/default.aspx?scid=kb;EN-US;125681
        FontMetrics metrics = Toolkit.getDefaultToolkit().getFontMetrics(
                                         UIManager.getFont("Button.font"));
        baseUnitX = metrics.stringWidth(
                      "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
        baseUnitX = (baseUnitX / 26 + 1) / 2;
        // The -1 comes from experimentation.
        baseUnitY = metrics.getAscent() + metrics.getDescent() - 1;
    }
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

            // get the global values we use in relation to our current font
            FontMetrics fm = this.getFontMetrics(this.getFont());
            if (fm == null) {
                return;
            }
            width = fm.stringWidth("X") * cols; //$NON-NLS-1$
            height = fm.getHeight() + 4;
        }

        public void addNotify() {
            // automatically invoked after our Canvas is created but
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

            // from the centerText method in "Java Examples in a Nutshell"
            FontMetrics fm = this.getFontMetrics(this.getFont());
            if (fm == null) {
                return;
            }
            int sWidth = fm.stringWidth(s);
            int sx = (w - sWidth) / 2;
            int sy = (h - fm.getHeight()) / 2 + fm.getAscent();
            g.drawString(s, sx, sy);
        }
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

                  } else if (iconType.equals(ActionButton.LARGE_ICONS)) {
                      imagePath = (String) action.getValue(Action.IMAGE_PATH);
                  }
                  String n = (String) action.getValue(Action.SHORT_DESCRIPTION);
                  n = n == null ? action.getName() : n;
                  w = Math.max(w, fm.stringWidth(n));
                  itemHeight = Math.max(itemHeight, fm.getHeight());
                  if (imagePath != null) {
                      Image img = UIUtil.loadImage(action.getClass(), imagePath);
                      if (img != null) {
                          UIUtil.waitFor(img, this);
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

    g.fillRect(1, 1, (int) ((float) (bounds.width - 2) * scale),
        bounds.height - 2);
    String s = progressString != null ? progressString : (int) (scale * 100F)
        + "%"; //$NON-NLS-1$
    FontMetrics fm = getFontMetrics(getFont());
    int swidth = fm.stringWidth(s);
    g.setColor(getForeground());
    g.drawString(s, (bounds.width - swidth) / 2, bounds.height / 2
        + ( fm.getMaxAscent() / 2));
  }

View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

            // get the global values we use in relation to our current font
            FontMetrics fm = this.getFontMetrics(this.getFont());
            if (fm == null) {
                return;
            }
            width = fm.stringWidth("X") * cols; //$NON-NLS-1$
            height = fm.getHeight() + 4;
        }

        public void addNotify() {
            // automatically invoked after our Canvas is created but
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

                    + NODE_WIDTH, y + yName + fontMetrics.getHeight()
                    + Y_OFFSET);

            g.setColor(Color.BLACK);
            String name = node.getName();
            int nameWidth = fontMetrics.stringWidth(name);

            g.drawString(getTruncatedString(name, NODE_WIDTH - xName,
                    fontMetrics), x + xName, y + yName
                    + fontMetrics.getHeight());
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

        BufferedImage tmpImage = new BufferedImage(10, 10,
                BufferedImage.TYPE_INT_RGB);

        FontMetrics fmetric = tmpImage.getGraphics().getFontMetrics(
        myUIConfiguration.getChartMainFont().deriveFont(12f));
        int fourEmWidth = fmetric.stringWidth("mmmm");
       
        int width = 0;
        int height = getTree().getTreeTable().getRowHeight()*3 + HEADER_OFFSET;
        for (Iterator tasks = myItemsToConsider.iterator(); tasks.hasNext();) {
            DefaultMutableTreeNode nextTreeNode = (DefaultMutableTreeNode) tasks
View Full Code Here

Examples of java.awt.FontMetrics.stringWidth()

            if ("None".equals(next.toString())) {
                continue;
            }
            if (isVisible(next)) {
                height += getTree().getTreeTable().getRowHeight();
                int nbchar = fmetric.stringWidth(next.getName())+next.getManager().getTaskHierarchy().getDepth(next)*fourEmWidth;
                if (nbchar > width) {
                    width = nbchar;
                }
            }
        }
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.