bibliothek.gui.dock.common.intern.color
Class ColorTransmitter<D extends DockColor>

java.lang.Object
  extended by bibliothek.gui.dock.common.intern.color.ColorTransmitter<D>
Type Parameters:
D - the kind of DockColor used in this transmitter
All Implemented Interfaces:
ColorBridge, UIBridge<Color,DockColor>
Direct Known Subclasses:
BubbleDisplayerTransmitter, MinimizedButtonColorTransmitter, TabColorTransmitter, TitleColorTransmitter

public abstract class ColorTransmitter<D extends DockColor>
extends Object
implements ColorBridge

A ColorTransmitter observes some ColorMaps and transmits some Colors of these maps to a set of DockColors.

Author:
Benjamin Sigg

Constructor Summary
ColorTransmitter(String... keys)
          Creates a new ColorTransmitter.
 
Method Summary
 void add(String id, DockColor color)
          Adds a new UIValue that gets its resource from this bridge.
protected abstract  Color get(Color color, String id, D observer)
          Called when a color needs to be set whose key has been registered at this ColorTransmitter.
protected abstract  CDockable getDockable(D observer)
          Gets the CDockable which is associated with observer.
protected  Color getFirstNonNull(ColorMap map, String... keys)
          Gets the first non- null color of map that matches a given key.
 void remove(String id, DockColor color)
          Removes a value from this bridge.
protected  void set(String id, Color color, CDockable dockable)
          Transmits color to all DockColors which listen to the given id and which are associated with dockable.
 void set(String id, Color color, DockColor observer)
          Called by the UIProperties when one resource or UIValue has been exchanged.
 void setControl(CControl control)
          Sets the CControl which should be observed for new CDockables by this transmitter.
protected abstract  void update(CDockable dockable, String key, Color color)
          Called when a color in a ColorMap has changed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorTransmitter

public ColorTransmitter(String... keys)
Creates a new ColorTransmitter.

Parameters:
keys - the keys which should be monitored by this transmitter
Method Detail

add

public void add(String id,
                DockColor color)
Description copied from interface: UIBridge
Adds a new UIValue that gets its resource from this bridge.

Specified by:
add in interface UIBridge<Color,DockColor>
Parameters:
id - the id of the resource the new value needs
color - a value that can be modified by this bride

remove

public void remove(String id,
                   DockColor color)
Description copied from interface: UIBridge
Removes a value from this bridge.

Specified by:
remove in interface UIBridge<Color,DockColor>
Parameters:
id - the id of the resource the value needed
color - the value that is no longer in use

setControl

public void setControl(CControl control)
Sets the CControl which should be observed for new CDockables by this transmitter.

Parameters:
control - the observed control, can be null

set

public void set(String id,
                Color color,
                DockColor observer)
Description copied from interface: UIBridge
Called by the UIProperties when one resource or UIValue has been exchanged. Normally an UIBridge can just call UIValue.set(Object) with the argument value.

Specified by:
set in interface UIBridge<Color,DockColor>
Parameters:
id - the identifier of the resource
color - the new resource, can be null
observer - the value that is affected by the change

get

protected abstract Color get(Color color,
                             String id,
                             D observer)
Called when a color needs to be set whose key has been registered at this ColorTransmitter.

Parameters:
color - the original color
id - the key of the color
observer - the destination for the color
Returns:
the color that should be set to observer

update

protected abstract void update(CDockable dockable,
                               String key,
                               Color color)
Called when a color in a ColorMap has changed.

Parameters:
dockable - the owner of the map
key - the name of the changed color
color - the new value of the color in the map, can be null

getDockable

protected abstract CDockable getDockable(D observer)
Gets the CDockable which is associated with observer.

Parameters:
observer - some observer
Returns:
the associated dockable or null

getFirstNonNull

protected Color getFirstNonNull(ColorMap map,
                                String... keys)
Gets the first non- null color of map that matches a given key.

Parameters:
map - a map of colors
keys - some keys that will be read from index 0 upward.
Returns:
the first Color that is not null or null

set

protected void set(String id,
                   Color color,
                   CDockable dockable)
Transmits color to all DockColors which listen to the given id and which are associated with dockable.

Parameters:
id - the id of the changed color
color - the new color, might be null
dockable - the associated dockable, might be null