Package org.eclipse.jface.resource
Class ColorRegistry
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.resource.ResourceRegistry
org.eclipse.jface.resource.ColorRegistry
A color registry maintains a mapping between symbolic color names and SWT
Color
s.
A color registry owns all of the Color
objects registered with
it, and automatically disposes of them when the SWT Display that creates the
Color
s is disposed. Because of this, clients do not need to
(indeed, must not attempt to) dispose of Color
objects
themselves.
Methods are provided for registering listeners that will be kept apprised of changes to list of registed colors.
Clients may instantiate this class (it was not designed to be subclassed).
- Since:
- 3.0
- Restriction:
- This class is not intended to be subclassed by clients.
-
Field Summary
-
Constructor Summary
ConstructorDescriptionCreate a new instance of the receiver that is hooked to the current display.ColorRegistry
(Display display) Create a new instance of the receiver.ColorRegistry
(Display display, boolean cleanOnDisplayDisposal) Create a new instance of the receiver. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Disposes all currently allocated resources.Returns thecolor
associated with the given symbolic color name, ornull
if no such definition exists.getColorDescriptor
(String symbolicName) Returns the color descriptor associated with the given symbolic color name.getColorDescriptor
(String symbolicName, ColorDescriptor defaultValue) Returns the color descriptor associated with the given symbolic color name.Returns the color data associated with the given symbolic color name.boolean
hasValueFor
(String colorKey) Return whether or not the receiver has a value for the supplied key.void
Adds (or replaces) a color to this color registry under the given symbolic name.Methods inherited from class org.eclipse.jface.resource.ResourceRegistry
addListener, fireMappingChanged, removeListener
Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Field Details
-
display
This registriesDisplay
. All colors will be allocated using it. -
displayRunnable
Runnable that cleans up the manager on disposal of the display.
-
-
Constructor Details
-
ColorRegistry
public ColorRegistry()Create a new instance of the receiver that is hooked to the current display.- See Also:
-
ColorRegistry
Create a new instance of the receiver.- Parameters:
display
- theDisplay
to hook into.
-
ColorRegistry
Create a new instance of the receiver.- Parameters:
display
- theDisplay
to hook intocleanOnDisplayDisposal
- whether all colors allocated by thisColorRegistry
should be disposed when the display is disposed- Since:
- 3.1
-
-
Method Details
-
get
Returns thecolor
associated with the given symbolic color name, ornull
if no such definition exists.- Parameters:
symbolicName
- symbolic color name- Returns:
- the
Color
ornull
-
getKeySet
- Specified by:
getKeySet
in classResourceRegistry
- Returns:
- the set of keys this manager knows about. This collection should be immutable.
-
getRGB
Returns the color data associated with the given symbolic color name.- Parameters:
symbolicName
- symbolic color name.- Returns:
- the
RGB
data, ornull
if the symbolic name is not valid.
-
getColorDescriptor
Returns the color descriptor associated with the given symbolic color name. As of 3.4 if this color is not defined then an unspecified color is returned. Users that wish to ensure a reasonable default value should usegetColorDescriptor(String, ColorDescriptor)
instead.- Parameters:
symbolicName
- symbolic color name- Returns:
- the color descriptor associated with the given symbolic color name or an unspecified sentinel.
- Since:
- 3.1
-
getColorDescriptor
Returns the color descriptor associated with the given symbolic color name. If this name does not exist within the registry the supplied default value will be used.- Parameters:
symbolicName
- symbolic color namedefaultValue
- return value if symbolic color name is unknown- Returns:
- the color descriptor associated with the given symbolic color name or the default
- Since:
- 3.4
-
clearCaches
protected void clearCaches()Description copied from class:ResourceRegistry
Disposes all currently allocated resources.- Specified by:
clearCaches
in classResourceRegistry
-
hasValueFor
Description copied from class:ResourceRegistry
Return whether or not the receiver has a value for the supplied key.- Specified by:
hasValueFor
in classResourceRegistry
- Parameters:
colorKey
- the key- Returns:
true
if there is a value for this key
-
put
Adds (or replaces) a color to this color registry under the given symbolic name.A property change event is reported whenever the mapping from a symbolic name to a color changes. The source of the event is this registry; the property name is the symbolic color name.
- Parameters:
symbolicName
- the symbolic color namecolorData
- anRGB
object
-