com.threerings.media.sprite
Class SpriteIcon

java.lang.Object
  extended by com.threerings.media.sprite.SpriteIcon
All Implemented Interfaces:
Icon

public class SpriteIcon
extends Object
implements Icon

Implements the icon interface, using a Sprite to render the icon image.


Field Summary
protected  int _padding
          Used to put a bit of padding around the sprite image.
protected  Sprite _sprite
          The sprite used to render this icon.
 
Constructor Summary
SpriteIcon(Sprite sprite)
          Creates a sprite icon that will use the supplied sprite to render itself.
SpriteIcon(Sprite sprite, int padding)
          Creates a sprite icon that will use the supplied sprite to render itself.
 
Method Summary
 int getIconHeight()
           
 int getIconWidth()
           
 void paintIcon(Component c, Graphics g, int x, int y)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_sprite

protected Sprite _sprite
The sprite used to render this icon.


_padding

protected int _padding
Used to put a bit of padding around the sprite image.

Constructor Detail

SpriteIcon

public SpriteIcon(Sprite sprite)
Creates a sprite icon that will use the supplied sprite to render itself. This sprite should not be used for anything else while being used in this icon because it will be "moved" when the icon is rendered. The sprite's origin will be set to the bottom center of the label.


SpriteIcon

public SpriteIcon(Sprite sprite,
                  int padding)
Creates a sprite icon that will use the supplied sprite to render itself. This sprite should not be used for anything else while being used in this icon because it will be "moved" when the icon is rendered. The sprite's origin will be set to the bottom center of the label.

Parameters:
sprite - the sprite to render in this label.
padding - the number of pixels of blank space to put on all four sides of the sprite.
Method Detail

paintIcon

public void paintIcon(Component c,
                      Graphics g,
                      int x,
                      int y)
Specified by:
paintIcon in interface Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface Icon