Package com.formdev.flatlaf.util
Class ScaledImageIcon
java.lang.Object
com.formdev.flatlaf.util.ScaledImageIcon
- All Implemented Interfaces:
Icon
- Direct Known Subclasses:
FlatTitlePaneIcon
Scales the given image icon using the system and user scale factors and
paints the icon at system scale factor 1x. This gives best scaling quality.
If the given image icon supports multiple resolutions, the best resolution
variant is used. The last scaled image is cached for faster repainting.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionScaledImageIcon
(ImageIcon imageIcon) ScaledImageIcon
(ImageIcon imageIcon, int iconWidth, int iconHeight) -
Method Summary
Modifier and TypeMethodDescriptionint
int
protected Image
getResolutionVariant
(int destImageWidth, int destImageHeight) private BufferedImage
image2bufferedImage
(Image image) void
private void
paintLastImage
(Graphics g, int x, int y) private BufferedImage
scaleImage
(BufferedImage image, int targetWidth, int targetHeight, Object scalingInterpolation) Scales the given image to the target dimensions.
-
Field Details
-
imageIcon
-
iconWidth
private final int iconWidth -
iconHeight
private final int iconHeight -
lastSystemScaleFactor
private double lastSystemScaleFactor -
lastUserScaleFactor
private float lastUserScaleFactor -
lastImage
-
-
Constructor Details
-
ScaledImageIcon
-
ScaledImageIcon
-
-
Method Details
-
getIconWidth
public int getIconWidth()- Specified by:
getIconWidth
in interfaceIcon
-
getIconHeight
public int getIconHeight()- Specified by:
getIconHeight
in interfaceIcon
-
paintIcon
-
getResolutionVariant
-
paintLastImage
-
scaleImage
private BufferedImage scaleImage(BufferedImage image, int targetWidth, int targetHeight, Object scalingInterpolation) Scales the given image to the target dimensions. This is the same what imgscalr library (https://github.com/rkalla/imgscalr) would do when invoking Scalr.resize(). -
image2bufferedImage
-