Package generic.theme
Class GIcon
java.lang.Object
generic.theme.GIcon
- All Implemented Interfaces:
Icon
- Direct Known Subclasses:
GIconUIResource
An
Icon
whose value is dynamically determined by looking up its id into a global
icon table that is determined by the active GTheme
.
The idea is for developers to not use specific icons in their code, but to instead use a GIcon with an id that hints at its use. For example, instead of hard coding a label's icon by coding "label.setIcon(ResourceManager.loadImage("images/refresh.png", you would do something like label.setIcon(new GIcon("icon.refresh"). Then in a "[module name].theme.properties" file (located in the module's data directory), you would set the default value by adding this line "icon.refresh = images/refresh.png".
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns the current delegate for this GIcon.int
int
getId()
Returns the id for this GIcon.Returns the image for this icon.getUrl()
Returns the url used to load the icon delegate of this class.int
hashCode()
void
void
refresh
(GThemeValueMap currentValues) Reloads the delegate.static void
refreshAll
(GThemeValueMap currentValues) Static method for notifying all the existing GIcon that icons have changed and they should reload their cached indirect icon.toString()
-
Constructor Details
-
GIcon
Construct a GIcon with an id that will be used to look up the current icon associated with that id, which can be changed at runtime.- Parameters:
id
- the id used to lookup the current value for this icon
-
-
Method Details
-
refreshAll
Static method for notifying all the existing GIcon that icons have changed and they should reload their cached indirect icon.- Parameters:
currentValues
- the map of all current theme values
-
getId
Returns the id for this GIcon.- Returns:
- the id for this GIcon.
-
getUrl
Returns the url used to load the icon delegate of this class. If the delegate icon was not loaded from a url, then null will be returned.- Returns:
- the icon or null
-
getImageIcon
Returns the image for this icon.- Returns:
- the image
-
paintIcon
-
getIconWidth
public int getIconWidth()- Specified by:
getIconWidth
in interfaceIcon
-
getIconHeight
public int getIconHeight()- Specified by:
getIconHeight
in interfaceIcon
-
refresh
Reloads the delegate.- Parameters:
currentValues
- the map of current theme values
-
getDelegate
Returns the current delegate for this GIcon. Note that this delegate can change when the theme changes or is edited.- Returns:
- the current delegate icon for this GIcon.
-
hashCode
public int hashCode() -
equals
-
toString
-