Package generic.theme
Class GTheme
java.lang.Object
generic.theme.GThemeValueMap
generic.theme.GTheme
- Direct Known Subclasses:
DiscoverableGTheme
Class to store all the configurable appearance properties (Colors, Fonts, Icons, Look and Feel)
in an application.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Stringstatic final Stringstatic final Stringstatic StringFields inherited from class generic.theme.GThemeValueMap
colorMap, fontMap, iconMap, propertyMap -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for creating a GTheme with an associated File.Creates a new GTheme with the given name, the defaultLookAndFeelfor the platform and not using dark defaults.Creates a new empty GTheme with the given name,LookAndFeel, and whether or not to use dark defaults. -
Method Summary
Modifier and TypeMethodDescriptionbooleangetFile()Returns the file associated with this theme.Returns the name of the LookAndFeel associated with this GThemegetName()Returns the name of this GThemeReturns a String that can be used to find and restore this theme.inthashCode()booleanReturns true if this theme has aLookAndFeelthat is supported by the current platform.booleanReturns true if this theme can not be changedstatic GThemeReads a theme from a file.voidsave()Saves this theme to its associated file.voidSets the Color for the given idvoidsetColorRef(String id, String refId) Sets a referred Color for the given idvoidSets the Font for the given idvoidsetFontRef(String id, String refId) Sets a referred font for the given idvoidSets the icon for the given idvoidsetIconRef(String id, String refId) Sets a referred icon id for the given idtoString()booleanReturns true if this theme should use dark defaultsMethods inherited from class generic.theme.GThemeValueMap
addColor, addFont, addIcon, addProperty, checkForUnresolvedReferences, clear, containsColor, containsFont, containsIcon, containsProperty, getChangedValues, getColor, getColorIds, getColors, getExternalIconFiles, getFont, getFontIds, getFonts, getIcon, getIconIds, getIcons, getProperties, getProperty, getPropertyIds, getResolvedColor, getResolvedFont, getResolvedIcon, getResolvedProperty, isEmpty, load, removeColor, removeFont, removeIcon, removeProperty, size
-
Field Details
-
FILE_PREFIX
- See Also:
-
JAVA_ICON
- See Also:
-
FILE_EXTENSION
-
ZIP_FILE_EXTENSION
-
-
Constructor Details
-
GTheme
Creates a new GTheme with the given name, the defaultLookAndFeelfor the platform and not using dark defaults. This theme will be using all the standard defaults from the theme.property files and the defaults from the default LookAndFeel.- Parameters:
name- the name for this GTheme
-
GTheme
Creates a new empty GTheme with the given name,LookAndFeel, and whether or not to use dark defaults.- Parameters:
name- the name for the new GThemelafType- the look and feel type used by this theme
-
GTheme
Constructor for creating a GTheme with an associated File.- Parameters:
file- the file that this theme will save toname- the name of the new themelafType- theLafTypefor the new themeuseDarkDefaults- true if this new theme uses dark defaults
-
-
Method Details
-
getName
Returns the name of this GTheme- Returns:
- the name of this GTheme
-
getLookAndFeelType
Returns the name of the LookAndFeel associated with this GTheme- Returns:
- the name of the LookAndFeel associated with this GTheme
-
useDarkDefaults
public boolean useDarkDefaults()Returns true if this theme should use dark defaults- Returns:
- true if this theme should use dark defaults
-
getThemeLocater
Returns a String that can be used to find and restore this theme.- Returns:
- a String that can be used to find and restore this theme.
-
getFile
Returns the file associated with this theme.- Returns:
- the file associated with this theme.
-
setColor
Sets the Color for the given id- Parameters:
id- the id to associate with the given Colorcolor- the Color to associate with the given id
-
setColorRef
Sets a referred Color for the given id- Parameters:
id- the id to associate with the refIdrefId- the id of an indirect Color lookup for the given id.
-
setFont
Sets the Font for the given id- Parameters:
id- the id to associate with the given Fontfont- the Font to associate with the given id
-
setFontRef
Sets a referred font for the given id- Parameters:
id- the id to associate with the given Font reference idrefId- the id of an indirect Font lookup for the given id.
-
setIcon
Sets the icon for the given id- Parameters:
id- the id to associate with the given IconPathicon- the icon to assign to the given id
-
setIconRef
Sets a referred icon id for the given id- Parameters:
id- the id to associate with the given FontrefId- the id of an indirect Icon lookup for the given id.
-
toString
-
hashCode
public int hashCode()- Overrides:
hashCodein classGThemeValueMap
-
equals
- Overrides:
equalsin classGThemeValueMap
-
hasSupportedLookAndFeel
public boolean hasSupportedLookAndFeel()Returns true if this theme has aLookAndFeelthat is supported by the current platform.- Returns:
- true if this theme has a
LookAndFeelthat is supported by the current platform.
-
save
Saves this theme to its associated file.- Throws:
IOException- if an I/O error occurs when writing the file
-
isReadOnly
public boolean isReadOnly()Returns true if this theme can not be changed- Returns:
- true if this theme can not be changed
-
loadTheme
Reads a theme from a file. The file can be either a theme file or a zip file containing a theme file and optionally a set of icon files.- Parameters:
file- the file to read.- Returns:
- the theme that was read from the file
- Throws:
IOException- if an error occurred trying to read a theme from the file.
-