Class CachedHiDPIIcon
java.lang.Object
org.openide.util.CachedHiDPIIcon
- All Implemented Interfaces:
Icon
Abstract base class for
Icon implementations that need to cache scaled bitmap
representations for HiDPI displays. Bitmaps for multiple HiDPI scaling factors can be cached at
the same time, e.g. for multi-monitor setups. Thread-safe.- Since:
- 9.15
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCachedHiDPIIcon(int width, int height) Constructor to be used by subclasses. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract ImagecreateAndPaintImage(Component c, ColorModel colorModel, int deviceWidth, int deviceHeight, double scale) Create a scaled image containing the graphics of this icon.protected static final BufferedImagecreateBufferedImage(ColorModel colorModel, int deviceWidth, int deviceHeight) Utility method to create a compatibleBufferedImagefrom the parameters passed tocreateAndPaintImage(Component, ColorModel, int, int, double).final intfinal intfinal void
-
Constructor Details
-
CachedHiDPIIcon
protected CachedHiDPIIcon(int width, int height) Constructor to be used by subclasses. For HiDPI screens, dimensions are specified in logical pixels rather than device pixels, as in the superclass.- Parameters:
width- the width of the iconheight- the height of the icon
-
-
Method Details
-
paintIcon
-
getIconWidth
public final int getIconWidth()- Specified by:
getIconWidthin interfaceIcon
-
getIconHeight
public final int getIconHeight()- Specified by:
getIconHeightin interfaceIcon
-
createAndPaintImage
protected abstract Image createAndPaintImage(Component c, ColorModel colorModel, int deviceWidth, int deviceHeight, double scale) Create a scaled image containing the graphics of this icon. The result may be cached. The dimensions are specfied in device pixels rather than logical pixels, i.e. with HiDPI scaling applied.- Parameters:
c- the component that was passed toIcon.paintIcon(Component,Graphics,int,int). The cache will not be invalidated ifcor its state changes, so subclasses should avoid depending on it if possible. This parameter exists mainly to ensure compatibility with existing Icon implementations that may be used as delegates. Future implementations might also elect to simply pass a dummy Component instance here.colorModel- theColorModelof the surface on which the image will be painted (may be passed tocreateBufferedImage(ColorModel, int, int)in the common case)deviceWidth- the required width of the image, in device pixels (>=1)deviceHeight- the required height of the image, in device pixels (>=1)scale- the HiDPI scaling factor detected ingraphicsConfiguration
-
createBufferedImage
protected static final BufferedImage createBufferedImage(ColorModel colorModel, int deviceWidth, int deviceHeight) Utility method to create a compatibleBufferedImagefrom the parameters passed tocreateAndPaintImage(Component, ColorModel, int, int, double). May be called by implementors of the latter to create a surface to draw on and return.- Parameters:
colorModel- the requiredColorModeldeviceWidth- the required width of the image, in device pixels (>=1)deviceHeight- the required height of the image, in device pixels (>=1)- Returns:
- an image compatible with the given parameters
-