public class ColorRegistry extends ResourceRegistry
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).
Modifier and Type | Field and Description |
---|---|
protected Display |
display
This registries
Display . |
protected Runnable |
displayRunnable
Runnable that cleans up the manager on disposal of the display.
|
Constructor and Description |
---|
ColorRegistry()
Create 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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
clearCaches()
Disposes all currently allocated resources.
|
Color |
get(String symbolicName)
Returns the
color associated with the given symbolic color
name, or null if no such definition exists. |
ColorDescriptor |
getColorDescriptor(String symbolicName)
Returns the color descriptor associated with the given symbolic color
name.
|
ColorDescriptor |
getColorDescriptor(String symbolicName,
ColorDescriptor defaultValue)
Returns the color descriptor associated with the given symbolic color
name.
|
Set<String> |
getKeySet() |
RGB |
getRGB(String symbolicName)
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 |
put(String symbolicName,
RGB colorData)
Adds (or replaces) a color to this color registry under the given
symbolic name.
|
addListener, fireMappingChanged, removeListener
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
protected Display display
Display
. All colors will be allocated using
it.protected Runnable displayRunnable
public ColorRegistry()
Display.getCurrent()
public ColorRegistry(Display display)
display
- the Display
to hook into.public ColorRegistry(Display display, boolean cleanOnDisplayDisposal)
display
- the Display
to hook intocleanOnDisplayDisposal
- whether all fonts allocated by this ColorRegistry
should be disposed when the display is disposedpublic Color get(String symbolicName)
color
associated with the given symbolic color
name, or null
if no such definition exists.symbolicName
- symbolic color nameColor
or null
public Set<String> getKeySet()
getKeySet
in class ResourceRegistry
public RGB getRGB(String symbolicName)
symbolicName
- symbolic color name.RGB
data, or null
if the symbolic name
is not valid.public ColorDescriptor getColorDescriptor(String symbolicName)
getColorDescriptor(String, ColorDescriptor)
instead.symbolicName
- public ColorDescriptor getColorDescriptor(String symbolicName, ColorDescriptor defaultValue)
symbolicName
- defaultValue
- protected void clearCaches()
ResourceRegistry
clearCaches
in class ResourceRegistry
public boolean hasValueFor(String colorKey)
ResourceRegistry
hasValueFor
in class ResourceRegistry
colorKey
- the keytrue
if there is a value for this keypublic void put(String symbolicName, RGB colorData)
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.
symbolicName
- the symbolic color namecolorData
- an RGB
object
Copyright (c) 2000, 2015 Eclipse Contributors and others. All rights reserved.Guidelines for using Eclipse APIs.