Package bibliothek.gui.dock.common.theme
Class ThemeMap
java.lang.Object
bibliothek.gui.dock.common.theme.ThemeMap
A map of
ThemeFactorys. This map can change the DockTheme
of its associated CControl. New factories can be added or removed
from the map.- Author:
- Benjamin Sigg
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstandard key for theCBasicThemestatic final Stringstandard key for theCBubbleThemestatic final Stringstandard key for theCEclipseThemestatic final Stringstandard key for theCFlatThemestatic final Stringstandard key for theCSmoothTheme -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(String key, ThemeFactory factory) Addsfactoryat the end of this map.voidaddThemeMapListener(ThemeMapListener listener) Adds a new listener to this map.getFactory(int index) Gets theindex'th factory.getFactory(String key) Searches the factory which is associated withkey.getKey(int index) Gets the key of theindex'th element.Gets the object which will modify theDockThemebefore applying the theme to theDockController.Gets the currently selected factory.Gets the name of the currently selected factory.intindexOf(ThemeFactory factory) Searches forfactoryand returns its index.intSearches forkeyand returns its location.voidinsert(int index, String key, ThemeFactory factory) Inserts a new factory into this map.protected ThemeMapListener[]Gets an array containing allThemeMapListeners of this map.voidput(String key, ThemeFactory factory) Searches for an entry namedkeyand changes its factory.voidremove(int index) Removes theindex'th entry of this map.booleanDeletes the factory associated withkey.voidremoveThemeMapListener(ThemeMapListener listener) Removes a listener from this map.voidselect(int index) Changes the selected factory.voidselect(int index, boolean force) Changes the selected factory.voidselect(ThemeFactory factory) Changes the selected factory tofactory.voidChanges the selected factory.voidChanges the selected factory.voidsetModifier(DockThemeModifier modifier) Sets the object which will modify theDockThemebefore applying the theme to theDockController.intsize()Gets the number of elements of this map.
-
Field Details
-
KEY_BASIC_THEME
standard key for theCBasicTheme- See Also:
-
KEY_BUBBLE_THEME
standard key for theCBubbleTheme- See Also:
-
KEY_ECLIPSE_THEME
standard key for theCEclipseTheme- See Also:
-
KEY_FLAT_THEME
standard key for theCFlatTheme- See Also:
-
KEY_SMOOTH_THEME
standard key for theCSmoothTheme- See Also:
-
-
Constructor Details
-
ThemeMap
public ThemeMap()Creates a new empty map. -
ThemeMap
Creates a new map and wires this map tocontrol. Ensures that the standard themes are available.
Every change of the selected factory will change the theme ofcontrol, and this map will ensure that the name of the theme is stored in theApplicationResourceManager.- Parameters:
control- the control to monitor
-
-
Method Details
-
addThemeMapListener
Adds a new listener to this map. The listener will be informed when a factory is changed or the theme changes.- Parameters:
listener- the new listener
-
removeThemeMapListener
Removes a listener from this map.- Parameters:
listener- the listener to remove
-
listeners
Gets an array containing allThemeMapListeners of this map.- Returns:
- the list of listeners
-
setModifier
Sets the object which will modify theDockThemebefore applying the theme to theDockController.- Parameters:
modifier- the new modifier, can benull
-
getModifier
Gets the object which will modify theDockThemebefore applying the theme to theDockController.- Returns:
- the modifier, can be
null
-
select
Changes the selected factory. If there is no factory with namekeyorkeyisnull, then thenull-factory is selected.- Parameters:
key- the name of the newly selected factory, can benull
-
select
Changes the selected factory. If there is no factory with namekeyorkeyisnull, then thenull-factory is selected.- Parameters:
key- the name of the newly selected factory, can benullforce-trueif the theme is to be loaded even if it is already selected
-
select
Changes the selected factory tofactory.- Parameters:
factory- the factory to select- Throws:
IllegalArgumentException- iffactoryis not registered in this map.
-
select
public void select(int index) Changes the selected factory.- Parameters:
index- the index of the newly selected factory, -1 will deselect any factory
-
select
public void select(int index, boolean force) Changes the selected factory.- Parameters:
index- the index of the newly selected factory, -1 will deselect any factoryforce-trueif an update should be forced even if there seems not to be a change
-
getSelectedKey
Gets the name of the currently selected factory.- Returns:
- the name or
null
-
getSelectedFactory
Gets the currently selected factory.- Returns:
- the factory or
null
-
size
public int size()Gets the number of elements of this map.- Returns:
- the number of elements
-
put
Searches for an entry namedkeyand changes its factory. If no such entry is found, thenfactoryis added at the end of this map.- Parameters:
key- the name of the factoryfactory- the new factory
-
add
Addsfactoryat the end of this map. If there is already a factory namedkey, then that other factory is first removed.- Parameters:
key- the key of the new factoryfactory- the new factory
-
insert
Inserts a new factory into this map. If there is already a factorykeyin this map, then that other factory is removed.- Parameters:
index- the index where to insert the new factorykey- the key of the new factoryfactory- the new factory
-
remove
public void remove(int index) Removes theindex'th entry of this map.- Parameters:
index- the name of the element to remove
-
remove
Deletes the factory associated withkey.- Parameters:
key- the name of the element to remove- Returns:
trueif the element was deleted,falseif no element namedkeywas found
-
indexOf
Searches forfactoryand returns its index.- Parameters:
factory- the factory to search- Returns:
- its index or -1
-
indexOf
Searches forkeyand returns its location.- Parameters:
key- the key to search- Returns:
- the index or -1
-
getKey
Gets the key of theindex'th element.- Parameters:
index- the index of the element- Returns:
- the key to that element
-
getFactory
Gets theindex'th factory.- Parameters:
index- the index of the factory- Returns:
- the factory, not
null
-
getFactory
Searches the factory which is associated withkey.- Parameters:
key- the unique name of a factory- Returns:
- the factory, may be
null
-