Examples of FontMetrics


Examples of java.awt.FontMetrics

    int ty = 170;
   
    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

      }
      g2.setFont(new Font(fontName, style, fontSize));
    }

    final Font f = g2.getFont();
    final FontMetrics fm = g2.getFontMetrics(f);
    final FontRenderContext frc = g2.getFontRenderContext();
    final double y = area.getCenterY();

    final int highest = getHighest();
    for (int i = getLowest(); i <= highest; i++)
    {
      final double x = valueToJava2D(i, area);
      final String text = String.valueOf(i);

      final float width;
      if (useFontMetricsGetStringBounds)
      {
        final Rectangle2D bounds = fm.getStringBounds(text, g2);
        // getStringBounds() can return incorrect height for some Unicode
        // characters...see bug parade 6183356, let's replace it with
        // 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

Examples of java.awt.FontMetrics

            if( m_color!=null )
            {
                g.setColor( m_color );
            }           
           
            FontMetrics fm = g.getFontMetrics();
            int width = fm.stringWidth(m_text) + 20;
            int height = fm.getHeight();
           
            g.drawString(m_text, getWidth() - width, getHeight() - height);
        }
    }
View Full Code Here

Examples of java.awt.FontMetrics

   * @param table
   * @return total width of the table
   */
  private int setColumnSize(JTable table){
    int ret =0;
    FontMetrics fm = table.getFontMetrics(table.getFont());
    for (int i = 0 ; i < table.getColumnCount() ; i++){
      int max = 0;
      for (int j = 0 ; j < table.getRowCount() ; j++){
        String value = (String)table.getValueAt(j,i);
        if (value!=null){
          int taille = fm.stringWidth(value);
          if (taille > max)
            max = taille;
        }
      }
      String nom = (String)table.getColumnModel().getColumn(i).getIdentifier();
      int taille = fm.stringWidth(nom);
      if (taille > max)
        max = taille;
      table.getColumnModel().getColumn(i).setPreferredWidth(max+10);
      ret+=max+10;
    }
View Full Code Here

Examples of java.awt.FontMetrics

    }

    private void calculateSize() {
        newMetricsNeeded = false;

        FontMetrics fontMetrics = getFontMetrics(getFont());
        stringAscent = fontMetrics.getAscent();
        stringDescent = fontMetrics.getDescent();
        stringWidth = fontMetrics.stringWidth(message) + shadowX;
        stringHeight = stringAscent + stringDescent + shadowY;

        //  Set initial yoffset
        calculateInitialYOffset();
    }
View Full Code Here

Examples of java.awt.FontMetrics

      mygfx.setFont(labelFont);
  // Just in case, requested font unavailable
  else
      mygfx = g;

  FontMetrics fm = mygfx.getFontMetrics();

  int offset = 0;
  double w = (double) size.width;
  double ppu = w / (max - min);
  while (ppu * tickIncrement < 2) {
      tickIncrement += 10;
  }

  int pix_inc = (int)(tickIncrement * ppu);
  int labelSpan = labelIncrement * tickIncrement;

  for (int i = min, x = 0, j = 0;
    i <= max;
    i += tickIncrement, x += pix_inc) {
      if (i % labelSpan == 0) {
     String label = String.valueOf(min + (j * labelSpan));
    offset = 0;
    // Place leftmost label to right
    if (i != min)
        offset = fm.stringWidth(label) / 2;
          if (i >= max// Place rightmost label to left
        offset = fm.stringWidth(label);
   
    mygfx.drawString(label, x - offset, size.height/2);
          mygfx.drawLine(x, size.height/2, x, size.height);
    j++;
      } else
View Full Code Here

Examples of java.awt.FontMetrics

    {
      // This was originaly done every time.
      // and the count of instantiated objects was amazing
      _prefSize = new Dimension();
      _prefSize.height = 20;
      FontMetrics fm = getFontMetrics(getFont());
      Calendar cal = Calendar.getInstance();
      cal.set(Calendar.HOUR_OF_DAY, 23);
      cal.set(Calendar.MINUTE, 59);
      cal.set(Calendar.SECOND, 59);
      _prefSize.width = fm.stringWidth(_fmt.format(cal.getTime()));
      Border border = getBorder();
      if (border != null)
      {
        Insets ins = border.getBorderInsets(this);
        if (ins != null)
View Full Code Here

Examples of org.apache.fontbox.afm.FontMetrics

        {
            InputStream afmStream = url.openStream();
            try
            {
                AFMParser parser = new AFMParser(afmStream);
                FontMetrics metric = parser.parse();
                STANDARD14_AFM_MAP.put(fontName, metric);
            }
            finally
            {
                afmStream.close();
View Full Code Here

Examples of org.apache.fop.fonts.FontMetrics

        int size = ((Integer) word.getParentArea().getTrait(Trait.FONT_SIZE)).intValue();
        AFPFont tf = (AFPFont) fontInfo.getFonts().get(name);

        String s = word.getWord();

        FontMetrics metrics = fontInfo.getMetricsFor(name);

        super.renderWord(word);
    }
View Full Code Here

Examples of org.eclipse.swt.graphics.FontMetrics

  }

 
  public static int computeFontHeight(Drawable element) {
    GC gc = new GC(element);
      FontMetrics fm = gc.getFontMetrics ();
      gc.dispose();
      return fm.getHeight();
  }
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.