Class IconUtils
java.lang.Object
uno.anahata.asi.swing.icons.IconUtils
A utility class for loading, scaling, and managing a global registry of icons.
This class provides high-quality icon scaling by leveraging the legacy
Image.SCALE_SMOOTH algorithm, which has proven to produce superior
results for small UI icons compared to single-step Graphics2D scaling.
- Author:
- anahata
-
Field Summary
FieldsModifier and TypeFieldDescriptionA global registry for mapping icon IDs to actual Icon objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic IconCreates an icon for adding items to the context by overlaying a small Anahata badge on a large blue '+' symbol.static IcongetDisabledIcon(Icon icon) Creates a disabled (grayed out and semi-transparent) version of the given icon.static IconRetrieves an icon from the global registry or loads it from the classpath.static IconRetrieves a square icon of the specified size.static ImageIconLoads an icon from the classpath resources and scales it to the specified size.Gets a list of images for the Anahata logo in various sizes.static IconCreates an icon for removing items from the context by overlaying a small Anahata badge on a large red '-' symbol.private static IcongetSymbolBaseIcon(boolean isAdd) Internal helper to create an icon with a symbol base and an Anahata badge.static voidregisterIcon(String id, Icon icon) Registers an icon in the global registry.static ImageConverts any standard Swing Icon to a java.awt.Image.
-
Field Details
-
ICON_REGISTRY
-
-
Constructor Details
-
IconUtils
public IconUtils()
-
-
Method Details
-
registerIcon
-
getIcon
-
getIcon
-
getIcon
Loads an icon from the classpath resources and scales it to the specified size.Implementation details: Uses
Image.getScaledInstance(int, int, int)withImage.SCALE_SMOOTHto ensure the best possible quality for small icons, matching the visual fidelity of the V1 architecture.- Parameters:
name- The name of the icon file.width- The desired width.height- The desired height.- Returns:
- A scaled ImageIcon, or null if the resource is not found.
-
toImage
Converts any standard Swing Icon to a java.awt.Image.Implementation details: If the icon is an instance of
ImageIcon, it returns the underlying image directly. Otherwise, it creates aBufferedImageand paints the icon into it. This allows programmatic icons to be used for window icons and other native-facing APIs.- Parameters:
icon- The icon to convert.- Returns:
- The resulting Image, or null if the input was null.
-
getDisabledIcon
-
getLogoImages
-
getAddIcon
Creates an icon for adding items to the context by overlaying a small Anahata badge on a large blue '+' symbol.- Returns:
- The 'Add to Context' icon.
-
getRemoveIcon
Creates an icon for removing items from the context by overlaying a small Anahata badge on a large red '-' symbol.- Returns:
- The 'Remove from Context' icon.
-
getSymbolBaseIcon
Internal helper to create an icon with a symbol base and an Anahata badge.- Parameters:
isAdd- True for '+', false for '-'.- Returns:
- The combined icon.
-

