Package furbelow

Class ScaledIcon

java.lang.Object
furbelow.ScaledIcon
All Implemented Interfaces:
Icon

public class ScaledIcon extends Object implements Icon
Provides a scaled version of a given icon. Aspect ratio is optionally preserved; the icon will be centered in any extra space given its size.
  • Constructor Details

    • ScaledIcon

      public ScaledIcon(Icon icon)
      Create a scalable version of the given Icon.
    • ScaledIcon

      public ScaledIcon(Icon icon, int width, int height)
      Create an icon that properly scales to the desired size. The aspect ratio will be preserved.
    • ScaledIcon

      public ScaledIcon(Icon icon, int width, int height, boolean preserveAspect)
      Create an icon that properly scales to the desired size, and whether to preserve the aspect ratio.
  • Method Details

    • setPreserveAspect

      public void setPreserveAspect(boolean p)
    • setSize

      public void setSize(Dimension size)
    • setSize

      public void setSize(int w, int h)
    • paintIcon

      public void paintIcon(Component c, Graphics g, int x, int y)
      Paint the icon scaled appropriately.
      Specified by:
      paintIcon in interface Icon
    • getIconWidth

      public int getIconWidth()
      Specified by:
      getIconWidth in interface Icon
    • getIconHeight

      public int getIconHeight()
      Specified by:
      getIconHeight in interface Icon