当前位置: 首页>>代码示例>>Java>>正文


Java方法java.awt.Canvas.getFontMetrics代码示例

以下是Java方法java.awt.Canvas.getFontMetrics的代码示例。如果您正苦于以下问题:Java Canvas.getFontMetrics方法的具体用法?Java Canvas.getFontMetrics怎么用?Java Canvas.getFontMetrics使用的例子?那么恭喜您, 这里整理的方法代码示例例程将为您提供帮助。您也可以进一步了解该方法所在java.awt.Canvas的用法示例。

本文一共展示了Canvas.getFontMetrics的3个开源代码实例,这些例子默认根据受欢迎程度排序。您可以为喜欢的代码打CALL点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getScaledIcon

import java.awt.Canvas; //导入方法依赖的package包/类
private ImageIcon getScaledIcon(ImageIcon original) {
  Canvas c = new Canvas();
  FontMetrics fm = c.getFontMetrics(new JPanel().getFont());

  int height = (int) (fm.getHeight() * 2f);
  int width = original.getIconWidth() / original.getIconHeight() * height;

  BufferedImage scaledImage;
  if (!scraper.isEnabled()) {
    scaledImage = Scalr.resize(ImageCache.createImage(original.getImage()), Scalr.Method.QUALITY, Scalr.Mode.AUTOMATIC, width, height,
        Scalr.OP_GRAYSCALE);
  }
  else {
    scaledImage = Scalr.resize(ImageCache.createImage(original.getImage()), Scalr.Method.QUALITY, Scalr.Mode.AUTOMATIC, width, height,
        Scalr.OP_ANTIALIAS);
  }
  return new ImageIcon(scaledImage);
}
 
开发者ID:tinyMediaManager,项目:tinyMediaManager,完整代码来源:MovieScraperSettingsPanel.java


示例2: FontSystem

import java.awt.Canvas; //导入方法依赖的package包/类
public FontSystem(String fontFamily, int fontStyle, int fontWeight, int fontSize)
{
    int style;
    switch (fontStyle)
    {
        case com.kitfox.svg.Text.TXST_ITALIC:
            style = java.awt.Font.ITALIC;
            break;
        default:
            style = java.awt.Font.PLAIN;
            break;
    }

    int weight;
    switch (fontWeight)
    {
        case com.kitfox.svg.Text.TXWE_BOLD:
        case com.kitfox.svg.Text.TXWE_BOLDER:
            weight = java.awt.Font.BOLD;
            break;
        default:
            weight = java.awt.Font.PLAIN;
            break;
    }
    sysFont = new java.awt.Font(fontFamily, style | weight, (int) fontSize);
    
    Canvas c = new Canvas();
    fm = c.getFontMetrics(sysFont);
    
    FontFace face = new FontFace();
    face.setAscent(fm.getAscent());
    face.setDescent(fm.getDescent());
    face.setUnitsPerEm(fm.charWidth('M'));
    setFontFace(face);
}
 
开发者ID:Longri,项目:cachebox3.0,完整代码来源:FontSystem.java


示例3: getScaledIcon

import java.awt.Canvas; //导入方法依赖的package包/类
private ImageIcon getScaledIcon(ImageIcon original) {
  Canvas c = new Canvas();
  FontMetrics fm = c.getFontMetrics(getFont());

  int height = (int) (fm.getHeight() * 2f);
  int width = original.getIconWidth() / original.getIconHeight() * height;

  BufferedImage scaledImage = Scalr.resize(ImageCache.createImage(original.getImage()), Scalr.Method.QUALITY, Scalr.Mode.AUTOMATIC, width, height,
      Scalr.OP_ANTIALIAS);
  return new ImageIcon(scaledImage);
}
 
开发者ID:tinyMediaManager,项目:tinyMediaManager,完整代码来源:MovieTrailerSettingsPanel.java



注:本文示例均筛选自Github平台上各路大神开发的开源项目,代码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。