bibliothek.gui.dock.util
Class BackgroundAlgorithm

java.lang.Object
  extended by bibliothek.gui.dock.util.BackgroundAlgorithm
All Implemented Interfaces:
BackgroundComponent, UIValue<BackgroundPaint>
Direct Known Subclasses:
DisplayerScreenDockWindow.Background

public abstract class BackgroundAlgorithm
extends Object
implements BackgroundComponent

A utility class for managing BackgroundPaint, BackgroundComponent and PaintableComponent at the same time.

Author:
Benjamin Sigg

Field Summary
 
Fields inherited from interface bibliothek.gui.dock.util.BackgroundComponent
KIND
 
Constructor Summary
BackgroundAlgorithm(Path kind, String id)
          Creates a new algorithm.
 
Method Summary
 void addListener(BackgroundAlgorithmListener listener)
          Adds an observer to this algorithm.
 BackgroundPaint getPaint()
          Gets the BackgroundPaint of this UIValue.
 Transparency getTransparency()
          Tells whether this component is transparent or not.
 void paint(PaintableComponent component, Graphics g)
          Paints component using the graphics context g.
 void removeListener(BackgroundAlgorithmListener listener)
          Removes the observer listener from this algorithm.
 void repaint()
          Informs this component that it should be repainted.
 void set(BackgroundPaint value)
          Called when the underlying resource of this UIValue changes.
 void setController(DockController controller)
          Sets the source of the BackgroundPaint.
 void setTransparency(Transparency transparency)
          Informs this component whether it should be transparent or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.util.BackgroundComponent
getComponent
 

Constructor Detail

BackgroundAlgorithm

public BackgroundAlgorithm(Path kind,
                           String id)
Creates a new algorithm.

Parameters:
kind - the kind of UIValue this is
id - the identifier of this UIValue
Method Detail

addListener

public void addListener(BackgroundAlgorithmListener listener)
Adds an observer to this algorithm. The observer will be informed when properties of this algorithm change.

Parameters:
listener - the new observer, not null

removeListener

public void removeListener(BackgroundAlgorithmListener listener)
Removes the observer listener from this algorithm.

Parameters:
listener - the listener to remove

setController

public void setController(DockController controller)
Sets the source of the BackgroundPaint.

Parameters:
controller - the new controller, can be null

repaint

public void repaint()
Description copied from interface: BackgroundComponent
Informs this component that it should be repainted.

Specified by:
repaint in interface BackgroundComponent

set

public void set(BackgroundPaint value)
Description copied from interface: UIValue
Called when the underlying resource of this UIValue changes.

Specified by:
set in interface UIValue<BackgroundPaint>
Parameters:
value - the new value

setTransparency

public void setTransparency(Transparency transparency)
Description copied from interface: BackgroundComponent
Informs this component whether it should be transparent or not. A transparent component does not paint a background, while a non-transparent component paints every part of its background. This property is optional and not every component can fully support transparency: It should be noted, that together with a BackgroundPaint, any component can be made to look as if transparent.

Specified by:
setTransparency in interface BackgroundComponent
Parameters:
transparency - whether to paint a background or not

getTransparency

public Transparency getTransparency()
Description copied from interface: BackgroundComponent
Tells whether this component is transparent or not.

Specified by:
getTransparency in interface BackgroundComponent
Returns:
how the background is painted
See Also:
BackgroundComponent.setTransparency(Transparency)

getPaint

public BackgroundPaint getPaint()
Gets the BackgroundPaint of this UIValue.

Returns:
the value, can be null

paint

public void paint(PaintableComponent component,
                  Graphics g)
Paints component using the graphics context g. This method ensures that PaintableComponent.paintBackground(Graphics) and PaintableComponent.paintForeground(Graphics) are not called with a null argument. component does not need to track how often its paint-methods are called, that is done by this method.

Parameters:
component - the component to paint
g - the graphics context to use