org.pushingpixels.flamingo.api.common.icon
Class DecoratedResizableIcon

java.lang.Object
  extended by org.pushingpixels.flamingo.api.common.icon.DecoratedResizableIcon
All Implemented Interfaces:
javax.swing.Icon, AsynchronousLoading, ResizableIcon

public class DecoratedResizableIcon
extends java.lang.Object
implements ResizableIcon, AsynchronousLoading

Implementation of ResizableIcon that adds decorations to a main icon.


Nested Class Summary
static interface DecoratedResizableIcon.IconDecorator
          Icon decorator interface.
 
Field Summary
protected  java.util.List<DecoratedResizableIcon.IconDecorator> decorators
          List of icon decorators.
protected  ResizableIcon delegate
          The main delegate icon.
 
Constructor Summary
DecoratedResizableIcon(ResizableIcon delegate)
          Creates a new decorated icon with no decorators.
DecoratedResizableIcon(ResizableIcon delegate, DecoratedResizableIcon.IconDecorator... decorators)
          Creates a new decorated icon.
 
Method Summary
 void addAsynchronousLoadListener(AsynchronousLoadListener l)
          Adds listener on the asynchronous loading events.
 void addIconDecorator(DecoratedResizableIcon.IconDecorator decorator)
          Adds the specified decorator to the end of the decorator sequence.
 int getIconHeight()
           
 int getIconWidth()
           
 boolean isLoading()
          Returns indication whether the content is still loading.
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
           
 void removeAsynchronousLoadListener(AsynchronousLoadListener l)
          Removes listener on the asynchronous loading events.
 void removeIconDecorator(DecoratedResizableIcon.IconDecorator decorator)
          Removes the specified decorator.
 void setDimension(java.awt.Dimension newDimension)
          Changes the dimension of this icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

delegate

protected ResizableIcon delegate
The main delegate icon.


decorators

protected java.util.List<DecoratedResizableIcon.IconDecorator> decorators
List of icon decorators.

Constructor Detail

DecoratedResizableIcon

public DecoratedResizableIcon(ResizableIcon delegate,
                              DecoratedResizableIcon.IconDecorator... decorators)
Creates a new decorated icon.

Parameters:
delegate - The main icon.
decorators - Icon decorators.

DecoratedResizableIcon

public DecoratedResizableIcon(ResizableIcon delegate)
Creates a new decorated icon with no decorators. Decorators can be added later with addIconDecorator(IconDecorator).

Parameters:
delegate - Main icon.
Method Detail

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface javax.swing.Icon

setDimension

public void setDimension(java.awt.Dimension newDimension)
Description copied from interface: ResizableIcon
Changes the dimension of this icon.

Specified by:
setDimension in interface ResizableIcon
Parameters:
newDimension - New dimension for this icon.

addIconDecorator

public void addIconDecorator(DecoratedResizableIcon.IconDecorator decorator)
Adds the specified decorator to the end of the decorator sequence. If the specified decorator already exists, it is not moved to the end of the sequence.

Parameters:
decorator - Decorator to add.

removeIconDecorator

public void removeIconDecorator(DecoratedResizableIcon.IconDecorator decorator)
Removes the specified decorator.

Parameters:
decorator - Decorator to remove.

addAsynchronousLoadListener

public void addAsynchronousLoadListener(AsynchronousLoadListener l)
Description copied from interface: AsynchronousLoading
Adds listener on the asynchronous loading events.

Specified by:
addAsynchronousLoadListener in interface AsynchronousLoading
Parameters:
l - Listener to add.

removeAsynchronousLoadListener

public void removeAsynchronousLoadListener(AsynchronousLoadListener l)
Description copied from interface: AsynchronousLoading
Removes listener on the asynchronous loading events.

Specified by:
removeAsynchronousLoadListener in interface AsynchronousLoading
Parameters:
l - Listener to remove.

isLoading

public boolean isLoading()
Description copied from interface: AsynchronousLoading
Returns indication whether the content is still loading.

Specified by:
isLoading in interface AsynchronousLoading
Returns:
true if the content is still loading, false otherwise.