org.progeeks.util.swing
Class RenderedIcon

java.lang.Object
  extended by org.progeeks.util.swing.RenderedIcon
All Implemented Interfaces:
javax.swing.Icon

public class RenderedIcon
extends java.lang.Object
implements javax.swing.Icon

Pre-renders a wrapped icon to a BufferedImage to make future renders potentially faster. This is useful for wrapping composite and scaled icons.

Version:
$Revision: 1.3 $
Author:
Paul Speed

Constructor Summary
RenderedIcon()
          Creates an empty icon.
RenderedIcon(javax.swing.Icon icon)
          Creates an icon that wraps the specified icon and renders it to a buffered image for future painting.
 
Method Summary
 javax.swing.Icon getIcon()
          Returns the wrapped icon.
 int getIconHeight()
           
 int getIconWidth()
           
 void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
          Paints this icon, caching the internally wrapped icon in a buffered image if it has not been cached already.
 void setIcon(javax.swing.Icon icon)
          Sets a new icon to this rendered icon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RenderedIcon

public RenderedIcon()
Creates an empty icon.


RenderedIcon

public RenderedIcon(javax.swing.Icon icon)
Creates an icon that wraps the specified icon and renders it to a buffered image for future painting. The rendering isn't done until the first paint call.

Method Detail

setIcon

public void setIcon(javax.swing.Icon icon)
Sets a new icon to this rendered icon. The specified icon will be cached to a buffered image the next time this icon is painted.


getIcon

public javax.swing.Icon getIcon()
Returns the wrapped icon.


getIconWidth

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

getIconHeight

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

paintIcon

public void paintIcon(java.awt.Component c,
                      java.awt.Graphics g,
                      int x,
                      int y)
Paints this icon, caching the internally wrapped icon in a buffered image if it has not been cached already.

Specified by:
paintIcon in interface javax.swing.Icon


Copyright © 2002-2003 Paul Speed. All Rights Reserved.