public class BaseIconTheme extends java.lang.Object implements IconTheme
This class represents an icon theme, which is basically a mapping of symbolic icon names, and real icons (or icon paths). This is useful to change an application's icons in an easy way. An icon theme is usually read from disk on start up, but can also be created or modified on a later time.
IconTheme.Icon
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
defaultIconName |
protected IconTheme |
defaultTheme |
protected java.lang.String |
description |
protected java.util.Map<java.lang.String,java.lang.String> |
groupsDescriptions |
protected java.util.Map<java.lang.String,IconTheme.Icon> |
iconList |
protected java.lang.String |
id |
protected static Logger |
logger |
protected java.lang.String |
name |
protected java.util.Map<java.lang.String,java.lang.String> |
subgroupsDescriptions |
NO_ICON_NAME
Constructor and Description |
---|
BaseIconTheme() |
BaseIconTheme(IconTheme defaultIconTheme) |
Modifier and Type | Method and Description |
---|---|
void |
addGroupImage(java.lang.String group,
java.net.URL resource) |
void |
addSubgroupImage(java.lang.String group,
java.lang.String subgroup,
java.net.URL resource) |
protected void |
deferredLoad()
Override this to load icons on demand instead of load on the creation of
the theme.
|
boolean |
exists(java.lang.String iconName)
Returns
true if the icon theme contains a mapping for the
specified iconName. |
void |
export(java.io.File folder) |
javax.swing.ImageIcon |
get(java.lang.String name)
Gets the ImageIcon associated with the provided name, if the name
is present in the theme.
|
javax.swing.ImageIcon |
get(java.lang.String iconName,
java.lang.ClassLoader loader)
Deprecated.
use get(String iconName) instead.
|
IconTheme |
getDefault() |
javax.swing.ImageIcon |
getDefaultIcon()
Return the icon used as icon by default when the requested icon
not exists.
|
java.lang.String |
getDescription()
Gets the theme description.
|
java.lang.String |
getGroupDescription(java.lang.String group) |
java.util.List<SimpleImage> |
getGroupImages(java.lang.String group) |
java.lang.String |
getID() |
java.lang.String |
getName()
Gets the theme name of the theme
|
javax.swing.ImageIcon |
getNoIcon()
Deprecated.
use getDefaultIcon
|
java.lang.String |
getSubgroupDescription(java.lang.String group,
java.lang.String subgroup) |
java.util.List<SimpleImage> |
getSubgroupImages(java.lang.String group,
java.lang.String subgroup) |
IconTheme.Icon |
getThemeIcon(java.lang.String name)
Return the ThemeIcon associated with the name.
|
java.util.Iterator<IconTheme.Icon> |
getThemeIcons()
Return an iterator over the ThemIcon in the theme.
|
boolean |
isMyIcon(java.lang.String name) |
java.util.Iterator<java.lang.String> |
iterator()
Return an iterator over the names of the icons in the theme.
|
void |
load(java.lang.Object resource)
Load the icons of the theme
|
boolean |
matchID(java.lang.String id) |
void |
register(java.lang.String name,
javax.swing.ImageIcon image)
Deprecated.
use
#registerDefault(PluginServices, String, String, ImageIcon, Object) |
void |
register(java.lang.String name,
java.lang.Object resource)
Deprecated.
use
#registerDefault(PluginServices, String, String, ImageIcon, Object) |
void |
register(java.lang.String provider,
java.lang.String group,
java.lang.String name,
javax.swing.ImageIcon icon,
java.net.URL resource)
Register a icon in the theme.
|
IconTheme.Icon |
register(java.lang.String provider,
java.lang.String group,
java.lang.String subgroup,
java.lang.String name,
javax.swing.ImageIcon icon,
java.net.URL resource) |
void |
registerDefault(java.lang.String name,
javax.swing.ImageIcon image)
Deprecated.
use
#registerDefault(PluginServices, String, String, ImageIcon, Object) |
void |
registerDefault(java.lang.String name,
java.lang.Object resource)
Deprecated.
use
#registerDefault(PluginServices, String, String, ImageIcon, Object) |
void |
registerDefault(java.lang.String provider,
java.lang.String group,
java.lang.String name,
javax.swing.ImageIcon icon,
java.net.URL resource)
Register a icon in the theme.
|
IconTheme.Icon |
registerDefault(java.lang.String provider,
java.lang.String group,
java.lang.String subgroup,
java.lang.String name,
javax.swing.ImageIcon icon,
java.net.URL resource) |
void |
setDefault(IconTheme def) |
void |
setDefaultIcon(javax.swing.ImageIcon icon)
Set the default icon to use when the requestd icon not exists.
|
void |
setDefaultIcon(java.lang.String name) |
void |
setDefaultIcon(java.net.URL resource) |
void |
setDescription(java.lang.String description)
Sets the theme description.
|
void |
setGroupDescription(java.lang.String group,
java.lang.String description) |
void |
setID(java.lang.String id) |
void |
setName(java.lang.String themeName)
Sets the theme name of the theme
|
void |
setSubgroupDescription(java.lang.String group,
java.lang.String subgroup,
java.lang.String description) |
java.lang.String |
toString()
Returns the name of the icon theme
|
protected static Logger logger
protected java.lang.String id
protected java.lang.String name
protected java.lang.String description
protected java.util.Map<java.lang.String,IconTheme.Icon> iconList
protected IconTheme defaultTheme
protected java.lang.String defaultIconName
protected java.util.Map<java.lang.String,java.lang.String> groupsDescriptions
protected java.util.Map<java.lang.String,java.lang.String> subgroupsDescriptions
public BaseIconTheme()
public BaseIconTheme(IconTheme defaultIconTheme)
public void load(java.lang.Object resource)
protected void deferredLoad()
public void setDefault(IconTheme def)
setDefault
in interface IconTheme
public IconTheme getDefault()
getDefault
in interface IconTheme
public boolean exists(java.lang.String iconName)
IconTheme
true
if the icon theme contains a mapping for the
specified iconName.public java.util.Iterator<java.lang.String> iterator()
IconTheme
public java.util.Iterator<IconTheme.Icon> getThemeIcons()
IconTheme
getThemeIcons
in interface IconTheme
public IconTheme.Icon getThemeIcon(java.lang.String name)
IconTheme
getThemeIcon
in interface IconTheme
name
- of the iconpublic boolean isMyIcon(java.lang.String name)
public javax.swing.ImageIcon get(java.lang.String name)
IconTheme
null
if
this not exists.public java.lang.String getName()
IconTheme
public void setName(java.lang.String themeName)
IconTheme
public java.lang.String getDescription()
IconTheme
getDescription
in interface IconTheme
public void setDescription(java.lang.String description)
IconTheme
setDescription
in interface IconTheme
public java.lang.String toString()
toString
in class java.lang.Object
public javax.swing.ImageIcon getDefaultIcon()
IconTheme
getDefaultIcon
in interface IconTheme
public void setDefaultIcon(javax.swing.ImageIcon icon)
IconTheme
setDefaultIcon
in interface IconTheme
public void setDefaultIcon(java.net.URL resource)
setDefaultIcon
in interface IconTheme
public void setDefaultIcon(java.lang.String name)
setDefaultIcon
in interface IconTheme
public void register(java.lang.String provider, java.lang.String group, java.lang.String name, javax.swing.ImageIcon icon, java.net.URL resource)
IconTheme
public IconTheme.Icon register(java.lang.String provider, java.lang.String group, java.lang.String subgroup, java.lang.String name, javax.swing.ImageIcon icon, java.net.URL resource)
public void registerDefault(java.lang.String provider, java.lang.String group, java.lang.String name, javax.swing.ImageIcon icon, java.net.URL resource) throws java.lang.IllegalArgumentException
IconTheme
registerDefault
in interface IconTheme
provider
- name of the icongroup
- name for the icon.name
- of iconjava.lang.IllegalArgumentException
- if name is null/empty or icon/resource are nullpublic IconTheme.Icon registerDefault(java.lang.String provider, java.lang.String group, java.lang.String subgroup, java.lang.String name, javax.swing.ImageIcon icon, java.net.URL resource)
registerDefault
in interface IconTheme
public javax.swing.ImageIcon getNoIcon()
public void registerDefault(java.lang.String name, javax.swing.ImageIcon image)
#registerDefault(PluginServices, String, String, ImageIcon, Object)
registerDefault
in interface IconTheme
name
- image
- public void registerDefault(java.lang.String name, java.lang.Object resource)
#registerDefault(PluginServices, String, String, ImageIcon, Object)
registerDefault
in interface IconTheme
name
- resource
- public void register(java.lang.String name, javax.swing.ImageIcon image)
#registerDefault(PluginServices, String, String, ImageIcon, Object)
public void register(java.lang.String name, java.lang.Object resource)
#registerDefault(PluginServices, String, String, ImageIcon, Object)
public javax.swing.ImageIcon get(java.lang.String iconName, java.lang.ClassLoader loader)
public java.lang.String getGroupDescription(java.lang.String group)
getGroupDescription
in interface IconTheme
public void setGroupDescription(java.lang.String group, java.lang.String description)
setGroupDescription
in interface IconTheme
public java.lang.String getSubgroupDescription(java.lang.String group, java.lang.String subgroup)
getSubgroupDescription
in interface IconTheme
public void setSubgroupDescription(java.lang.String group, java.lang.String subgroup, java.lang.String description)
setSubgroupDescription
in interface IconTheme
public void addGroupImage(java.lang.String group, java.net.URL resource)
addGroupImage
in interface IconTheme
public java.util.List<SimpleImage> getGroupImages(java.lang.String group)
getGroupImages
in interface IconTheme
public void addSubgroupImage(java.lang.String group, java.lang.String subgroup, java.net.URL resource)
addSubgroupImage
in interface IconTheme
public java.util.List<SimpleImage> getSubgroupImages(java.lang.String group, java.lang.String subgroup)
getSubgroupImages
in interface IconTheme