bibliothek.gui.dock.util.color
Class ColorManager

java.lang.Object
  extended by bibliothek.gui.dock.util.color.ColorManager

public class ColorManager
extends Object

A ColorManager contains Colors, ColorProviders and DockColors. Some DockColors are associated with a ColorProvider. If a Color in this manager is set, then each DockColor that listens for that color gets informed about the change either through its provider or directly from the manager.

Author:
Benjamin Sigg

Constructor Summary
ColorManager()
           
 
Method Summary
<D extends DockColor>
void
add(String colorId, Class<? super D> kind, D observer)
          Installs a new observer.
 void clear(Priority priority)
          Removes all values that stored under the given priority.
 Color get(String id)
          Gets a color of this manager.
protected  ColorProvider<?> getProviderFor(Class<?> clazz)
          Searches a provider that can be used for clazz.
 void lockUpdate()
          Tells this manager to stall all updates.
<D extends DockColor>
void
publish(Priority priority, Class<? extends D> kind, ColorProvider<D> provider)
          Adds a new provider of colors to this manager.
 void put(Priority priority, String id, Color color)
          Sets a color of this manager.
 void remove(DockColor observer)
          Uninstalls an observer
 void unlockUpdate()
          Tells this manager no longer to stall updates.
 void unpublish(Priority priority, Class<? extends DockColor> kind)
          Removes the ColorProvider that handles DockColors of kind kind.
 void unpublish(Priority priority, ColorProvider<?> provider)
          Searches for all occurrences of provider and removes them.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorManager

public ColorManager()
Method Detail

lockUpdate

public void lockUpdate()
Tells this manager to stall all updates. No DockColor will be informed when a color or provider changes.


unlockUpdate

public void unlockUpdate()
Tells this manager no longer to stall updates. This triggers a full update on all DockColors.


publish

public <D extends DockColor> void publish(Priority priority,
                                          Class<? extends D> kind,
                                          ColorProvider<D> provider)
Adds a new provider of colors to this manager.

Type Parameters:
D - the kind of observers this provider likes
Parameters:
priority - the importance of the new provider
kind - the kind of observers this provider likes
provider - the new provider

unpublish

public void unpublish(Priority priority,
                      Class<? extends DockColor> kind)
Removes the ColorProvider that handles DockColors of kind kind.

Parameters:
priority - the importance of the provider
kind - some kind of DockColor

unpublish

public void unpublish(Priority priority,
                      ColorProvider<?> provider)
Searches for all occurrences of provider and removes them. All DockColors that used provider are redistributed.

Parameters:
priority - the importance of the provider
provider - the provider to remove

add

public <D extends DockColor> void add(String colorId,
                                      Class<? super D> kind,
                                      D observer)
Installs a new observer.

Type Parameters:
D - the type of the observer
Parameters:
colorId - the id of the color that should be observed
kind - the type of the observer
observer - the new observer

remove

public void remove(DockColor observer)
Uninstalls an observer

Parameters:
observer - the observer to remove

getProviderFor

protected ColorProvider<?> getProviderFor(Class<?> clazz)
Searches a provider that can be used for clazz.

Parameters:
clazz - the type whose provider is searched
Returns:
the provider or null

put

public void put(Priority priority,
                String id,
                Color color)
Sets a color of this manager.

Parameters:
priority - the importance of this value
id - the id of the color
color - the new color

get

public Color get(String id)
Gets a color of this manager.

Parameters:
id - the id of the color
Returns:
the color or null
See Also:
put(Priority, String, Color)

clear

public void clear(Priority priority)
Removes all values that stored under the given priority.

Parameters:
priority - the priority whose elements should be removed