Package swingtree.style
Class ScalableImageIcon
java.lang.Object
javax.swing.ImageIcon
swingtree.style.ScalableImageIcon
- All Implemented Interfaces:
Serializable,Accessible,Icon
A wrapper for
ImageIcon that automatically scales the image to the
current UI.scale() value defined in the current SwingTree
library context singleton.- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class javax.swing.ImageIcon
ImageIcon.AccessibleImageIcon -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionbooleanintReturns the unscaled height of the icon.intReturns the unscaled width of the icon.intExposes the height of the icon, or -1 if the icon does not have a fixed height.
Note that the returned height is dynamically scaled according to the currentUI.scale()value.intExposes the width of the icon, or -1 if the icon does not have a fixed width.
Note that the returned width is dynamically scaled according to the currentUI.scale()value.getImage()inthashCode()static ScalableImageIconA factory method that creates a newScalableImageIconthat will render the suppliedImageIconusing the given base size scaled according to the current DPI settings.voidvoidtoString()Returns a newScalableImageIconthat will render the image at the given size.Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImageObserver
-
Method Details
-
of
A factory method that creates a newScalableImageIconthat will render the suppliedImageIconusing the given base size scaled according to the current DPI settings.If the given
ImageIconis already aScalableImageIcon, a new instance will be created from the existing one usingwithSize(Size).- Parameters:
size- The size to render the icon at.icon- The icon to render.- Returns:
- A new
ScalableImageIconthat will render the image scaled according to the current DPI settings.
-
withSize
Returns a newScalableImageIconthat will render the image at the given size.
Note that the returned icon will be a new instance and will not affect the current icon.
- Parameters:
size- The size to render the icon at.- Returns:
- A new
ScalableImageIconthat will render the image at the given size.
-
getIconWidth
public int getIconWidth()Exposes the width of the icon, or -1 if the icon does not have a fixed width.
Note that the returned width is dynamically scaled according to the currentUI.scale()value. This is to ensure that the icon is rendered at the correct size according to the current DPI settings. If you want the unscaled width, usegetBaseWidth().- Specified by:
getIconWidthin interfaceIcon- Overrides:
getIconWidthin classImageIcon- Returns:
- The width of the icon, or -1 if the icon does not have a width.
-
getIconHeight
public int getIconHeight()Exposes the height of the icon, or -1 if the icon does not have a fixed height.
Note that the returned height is dynamically scaled according to the currentUI.scale()value. This is to ensure that the icon is rendered at the correct size according to the current DPI settings. If you want the unscaled height, usegetBaseHeight().- Specified by:
getIconHeightin interfaceIcon- Overrides:
getIconHeightin classImageIcon- Returns:
- The height of the icon, or -1 if the icon does not have a height.
-
getBaseWidth
public int getBaseWidth()Returns the unscaled width of the icon. This is the width of the icon as it was originally loaded and is not affected by the currentUI.scale()value.
If you want a width that is more suited for rendering according to the current DPI settings, use
getIconWidth().- Returns:
- The unscaled width of the icon.
-
getBaseHeight
public int getBaseHeight()Returns the unscaled height of the icon. This is the height of the icon as it was originally loaded and is not affected by the currentUI.scale()value.
If you want a height that is more suited for rendering according to the current DPI settings, use
getIconHeight().- Returns:
- The unscaled height of the icon.
-
paintIcon
-
getImage
-
setImage
-
toString
-
equals
-
hashCode
public int hashCode()
-