Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 


Eclipse Platform
Release 3.5

org.eclipse.jface.resource
Class ColorRegistry

java.lang.Object
  extended by 

org.eclipse.core.commands.common.EventManager
      extended by 

org.eclipse.jface.resource.ResourceRegistry
          extended by 
org.eclipse.jface.resource.ColorRegistry

public class ColorRegistry
extends ResourceRegistry

A color registry maintains a mapping between symbolic color names and SWT Colors.

A color registry owns all of the Color objects registered with it, and automatically disposes of them when the SWT Display that creates the Colors 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
protected   Display display
          This registries Display.
protected   Runnable displayRunnable
          Runnable that cleans up the manager on disposal of the display.
 
Constructor Summary
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.
 
Method Summary
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 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.
 
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
 
Methods inherited from class java.lang. Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

display

protected 
Display display
This registries Display. All colors will be allocated using it.


displayRunnable

protected 
Runnable displayRunnable
Runnable that cleans up the manager on disposal of the display.

Constructor Detail

ColorRegistry

public ColorRegistry()
Create a new instance of the receiver that is hooked to the current display.

See Also:
Display.getCurrent()

ColorRegistry

public ColorRegistry(
Display display)
Create a new instance of the receiver.

Parameters:
display - the Display to hook into.

ColorRegistry

public ColorRegistry(
Display display,
                     boolean cleanOnDisplayDisposal)
Create a new instance of the receiver.

Parameters:
display - the Display to hook into
cleanOnDisplayDisposal - whether all fonts allocated by this ColorRegistry should be disposed when the display is disposed
Since:
3.1
Method Detail

get

public 
Color get(
String symbolicName)
Returns the color associated with the given symbolic color name, or null if no such definition exists.

Parameters:
symbolicName - symbolic color name
Returns:
the Color or null

getKeySet

public 
Set getKeySet()
Specified by:
getKeySet in class ResourceRegistry
Returns:
the set of keys this manager knows about. This collection should be immutable.

getRGB

public 
RGB getRGB(
String symbolicName)
Returns the color data associated with the given symbolic color name.

Parameters:
symbolicName - symbolic color name.
Returns:
the RGB data, or null if the symbolic name is not valid.

getColorDescriptor

public 
ColorDescriptor getColorDescriptor(
String symbolicName)
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 use getColorDescriptor(String, ColorDescriptor) instead.

Parameters:
symbolicName -
Returns:
the color descriptor associated with the given symbolic color name or an unspecified sentinel.
Since:
3.1

getColorDescriptor

public 
ColorDescriptor getColorDescriptor(
String symbolicName,
                                          
ColorDescriptor defaultValue)
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 -
defaultValue -
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 class ResourceRegistry

hasValueFor

public boolean hasValueFor(
String colorKey)
Description copied from class: ResourceRegistry
Return whether or not the receiver has a value for the supplied key.

Specified by:
hasValueFor in class ResourceRegistry
Parameters:
colorKey - the key
Returns:
true if there is a value for this key

put

public void put(
String symbolicName,
                
RGB colorData)
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 name
colorData - an RGB object

Eclipse Platform
Release 3.5

Guidelines for using Eclipse APIs.

Copyright (c) Eclipse contributors and others 2000, 2008. All rights reserved.


 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire