com.threerings.media.sprite
Class OrientableImageSprite

java.lang.Object
  extended by com.threerings.media.AbstractMedia
      extended by com.threerings.media.sprite.Sprite
          extended by com.threerings.media.sprite.ImageSprite
              extended by com.threerings.media.sprite.OrientableImageSprite
All Implemented Interfaces:
Pathable, DirectionCodes, Shape
Direct Known Subclasses:
FadableImageSprite

public class OrientableImageSprite
extends ImageSprite

An image sprite that uses AWT's rotation methods to render itself in different orientations.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.media.sprite.Sprite
Sprite.CancelledOp, Sprite.CompletedOp
 
Field Summary
 
Fields inherited from class com.threerings.media.sprite.ImageSprite
_animMode, _firstStamp, _frameDelay, _frameIdx, _frames, DEFAULT_FRAME_RATE, MOVEMENT_CUED, NO_ANIMATION, TIME_BASED, TIME_SEQUENTIAL
 
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
OrientableImageSprite()
          Creates a new orientable image sprite.
OrientableImageSprite(Mirage image)
          Creates a new orientable image sprite.
OrientableImageSprite(MultiFrameImage frames)
          Creates a new orientable image sprite.
 
Method Summary
protected  void accomodateFrame(int frameIdx, int width, int height)
          Must adjust the bounds to accommodate the our new frame.
 void paint(Graphics2D graphics)
          Called by the appropriate manager to request that the media render itself with the given graphics context.
 void setOrientation(int orient)
          Sprites have an orientation in one of the eight cardinal directions: DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc.
 
Methods inherited from class com.threerings.media.sprite.ImageSprite
hitTest, init, layout, setAnimationMode, setFrameIndex, setFrameRate, setFrames, setMirage, tick, toString
 
Methods inherited from class com.threerings.media.sprite.Sprite
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, inside, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, shutdown, tickPath, 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
 

Constructor Detail

OrientableImageSprite

public OrientableImageSprite()
Creates a new orientable image sprite.


OrientableImageSprite

public OrientableImageSprite(Mirage image)
Creates a new orientable image sprite.

Parameters:
image - the image to render

OrientableImageSprite

public OrientableImageSprite(MultiFrameImage frames)
Creates a new orientable image sprite.

Parameters:
frames - the frames to render
Method Detail

accomodateFrame

protected void accomodateFrame(int frameIdx,
                               int width,
                               int height)
Description copied from class: ImageSprite
Must adjust the bounds to accommodate the our new frame. This includes changing the width and height to reflect the size of the new frame and also updating the render origin (if necessary) and calling Sprite.updateRenderOrigin() to reflect those changes in the sprite's bounds.

Overrides:
accomodateFrame in class ImageSprite
Parameters:
frameIdx - the index of our new frame.
width - the width of the new frame.
height - the height of the new frame.

setOrientation

public void setOrientation(int orient)
Description copied from class: Sprite
Sprites have an orientation in one of the eight cardinal directions: DirectionCodes.NORTH, DirectionCodes.NORTHEAST, etc. Derived classes can choose to override this member function and select a different set of images based on their orientation, or they can ignore the orientation information.

Specified by:
setOrientation in interface Pathable
Overrides:
setOrientation in class Sprite
See Also:
DirectionCodes

paint

public void paint(Graphics2D graphics)
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 ImageSprite