chrriis.dj.swingsuite
Class LayeredIcon

java.lang.Object
  extended by javax.swing.ImageIcon
      extended by chrriis.dj.swingsuite.LayeredIcon
All Implemented Interfaces:
Serializable, Accessible, Icon

public class LayeredIcon
extends ImageIcon

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.ImageIcon
ImageIcon.AccessibleImageIcon
 
Field Summary
 
Fields inherited from class javax.swing.ImageIcon
tracker
 
Constructor Summary
LayeredIcon(int width, int height)
           
 
Method Summary
 void addIcon(Icon icon)
          Add an icon starting at the top left corner.
 void addIcon(Icon icon, int x, int y)
          Add an icon starting at a specific location.
 void addIcon(Icon icon, Point location)
          Add an icon starting at a specific location.
 void addIcon(Icon icon, Point location, int zOrder)
          Add an icon starting at a specific location.
 Component getComponent()
           
 int getIconCount()
          Get the number of icons.
 int getIconHeight()
           
 Point[] getIconLocations()
          Get all the icon locations.
 Icon[] getIcons()
          Get all the icons.
 int getIconWidth()
           
 Image getImage()
           
 void paintIcon(Component component, Graphics g, int x, int y)
           
 void removeAllIcons()
          Remove all icons.
 void removeIcon(Icon icon)
          Remove an icon.
 void setComponent(Component component)
          Set the component to which this icon is attached.
 
Methods inherited from class javax.swing.ImageIcon
getAccessibleContext, getDescription, getImageLoadStatus, getImageObserver, loadImage, setDescription, setImage, setImageObserver, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LayeredIcon

public LayeredIcon(int width,
                   int height)
Method Detail

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon
Overrides:
getIconWidth in class ImageIcon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon
Overrides:
getIconHeight in class ImageIcon

paintIcon

public void paintIcon(Component component,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon
Overrides:
paintIcon in class ImageIcon

getIcons

public Icon[] getIcons()
Get all the icons.

Returns:
the icons.

getIconLocations

public Point[] getIconLocations()
Get all the icon locations.

Returns:
the locations of all the icons.

getIconCount

public int getIconCount()
Get the number of icons.

Returns:
the number of icons.

removeIcon

public void removeIcon(Icon icon)
Remove an icon.

Parameters:
icon - the icon to remove.

removeAllIcons

public void removeAllIcons()
Remove all icons.


addIcon

public void addIcon(Icon icon)
Add an icon starting at the top left corner.

Parameters:
icon - the icon to add.

addIcon

public void addIcon(Icon icon,
                    int x,
                    int y)
Add an icon starting at a specific location.

Parameters:
icon - the icon to add.
x - the x coordinate.
y - the y coordinate.

addIcon

public void addIcon(Icon icon,
                    Point location)
Add an icon starting at a specific location.

Parameters:
icon - the icon to add.
location - the location.

addIcon

public void addIcon(Icon icon,
                    Point location,
                    int zOrder)
Add an icon starting at a specific location.

Parameters:
icon - the icon to add.
location - the location.
zOrder - the zOrder of this icon, where 0 means at the back.

getImage

public Image getImage()
Overrides:
getImage in class ImageIcon

getComponent

public Component getComponent()

setComponent

public void setComponent(Component component)
Set the component to which this icon is attached. It is automatically set when paintComponent is called, but if that did not happen, it sometimes is needed to set it explicitely.