コード例 #1
0
    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(
              com.bric.image.ImageLoader.createImage(original.getImage()),
              Scalr.Method.QUALITY,
              Scalr.Mode.AUTOMATIC,
              width,
              height,
              Scalr.OP_ANTIALIAS);
      return new ImageIcon(scaledImage);
    }