com.threerings.media.sprite
Class LabelSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.media.sprite.LabelSprite
All Implemented Interfaces:
Pathable, DirectionCodes, Shape

public class LabelSprite
extends Sprite

A sprite that uses a label to render itself. If the label has not been previously laid out (see Label.layout(java.awt.Component)) it will be done when the sprite is added to a media panel. If the label is altered after the sprite is created, updateBounds() should be called.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite
Sprite.CancelledOp, Sprite.CompletedOp
 
Field Summary
protected  boolean _antiAliased
          Whether or not to use anti-aliased rendering.
protected  Label _label
          The label associated with this sprite.
 
Fields inherited from class com.threerings.media.sprite.Sprite
_orient, _ox, _oxoff, _oy, _oyoff, _path, _pathStamp
 
Fields inherited from class com.threerings.media.AbstractMedia
_bounds, _firstTick, _mgr, _observers, _renderOrder, HUD_LAYER
 
Fields inherited from interface com.threerings.util.DirectionCodes
CARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST
 
Constructor Summary
LabelSprite(Label label)
          Constructs a label sprite that renders itself with the specified label.
 
Method Summary
 Label getLabel()
          Returns the label displayed by this sprite.
protected  void init()
          Called when the media has had its manager set.
protected  void layoutLabel()
          Lays out our underlying label which must be done if the text is changed.
 void paint(Graphics2D gfx)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void setAntiAliased(boolean antiAliased)
          Indicates that our label should be rendered with antialiased text.
 void updateBounds()
          Updates the bounds of the sprite after a change to the label.
 
Methods inherited from class com.threerings.media.sprite.Sprite
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, hitTest, inside, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, setOrientation, shutdown, tick, tickPath, toString, updateRenderOrigin, viewLocationDidChange
 
Methods inherited from class com.threerings.media.AbstractMedia
addObserver, contains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, invalidateAfterChange, naturalCompareTo, queueNotification, removeObserver, renderCompareTo, setRenderOrder, toString, willStart
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.threerings.media.util.Pathable
getBounds
 

Field Detail

_label

protected Label _label
The label associated with this sprite.


_antiAliased

protected boolean _antiAliased
Whether or not to use anti-aliased rendering.

Constructor Detail

LabelSprite

public LabelSprite(Label label)
Constructs a label sprite that renders itself with the specified label.

Method Detail

getLabel

public Label getLabel()
Returns the label displayed by this sprite.


setAntiAliased

public void setAntiAliased(boolean antiAliased)
Indicates that our label should be rendered with antialiased text.


updateBounds

public void updateBounds()
Updates the bounds of the sprite after a change to the label.


init

protected void init()
Description copied from class: AbstractMedia
Called when the media has had its manager set. Derived classes may override this method, but should be sure to call super.init().

Overrides:
init in class AbstractMedia

paint

public void paint(Graphics2D gfx)
Description copied from class: AbstractMedia
Called by the appropriate manager to request that the media render itself with the given graphics context. The media may wish to inspect the clipping region that has been set on the graphics context to render itself more efficiently. This method will only be called after it has been established that this media's bounds intersect the clipping region.

Overrides:
paint in class Sprite

layoutLabel

protected void layoutLabel()
Lays out our underlying label which must be done if the text is changed.