com.threerings.cast
Class CompositedActionFrames

java.lang.Object
  extended by com.threerings.cast.CompositedActionFrames
All Implemented Interfaces:
ActionFrames, DirectionCodes

public class CompositedActionFrames
extends Object
implements ActionFrames, DirectionCodes

An implementation of the MultiFrameImage interface that is used to lazily create composited character frames when they are requested.


Nested Class Summary
static class CompositedActionFrames.ComponentFrames
          Used to associate a CharacterComponent with its ActionFrames for a particular action.
protected  class CompositedActionFrames.CompositedFramesKey
          Used to cache composited frames for a particular action and orientation.
 
Field Summary
protected  String _action
          The action for which we're compositing frames.
protected  Map<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> _frameCache
          Used to cache our composited action frame images.
protected  ImageManager _imgr
          The image manager from whom we can obtain prepared volatile images onto which to render our composited actions.
protected  CompositedActionFrames.CompositedFramesKey _key
          Used to avoid creating a new key object every time we do a cache lookup.
protected  int _orientCount
          The number of orientations.
protected  CompositedActionFrames.ComponentFrames[] _sources
          Our source components and action frames.
 
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
CompositedActionFrames(ImageManager imgr, Map<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> frameCache, String action, CompositedActionFrames.ComponentFrames[] sources)
          Constructs a set of composited action frames with the supplied source frames and colorization configuration.
 
Method Summary
 ActionFrames cloneColorized(Colorization[] zations)
          Creates a clone of these action frames which will have the supplied colorizations applied to the frame images.
 ActionFrames cloneTranslated(int dx, int dy)
          Creates a clone of these action frames which will have the supplied translation applied to the frame images.
protected  CompositedMultiFrameImage createFrames(int orient)
          Creates our underlying multi-frame image for a particular orientation.
 TrimmedMultiFrameImage getFrames(int orient)
          Returns the multi-frame image that comprises the frames for the specified orientation.
 int getOrientationCount()
          Returns the number of orientations available in this set of action frames.
 int getXOrigin(int orient, int frameIdx)
          Returns the x offset from the upper left of the image to the "origin" for this character frame.
 int getYOrigin(int orient, int frameIdx)
          Returns the y offset from the upper left of the image to the "origin" for this character frame.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_imgr

protected ImageManager _imgr
The image manager from whom we can obtain prepared volatile images onto which to render our composited actions.


_frameCache

protected Map<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> _frameCache
Used to cache our composited action frame images.


_action

protected String _action
The action for which we're compositing frames.


_orientCount

protected int _orientCount
The number of orientations.


_sources

protected CompositedActionFrames.ComponentFrames[] _sources
Our source components and action frames.


_key

protected CompositedActionFrames.CompositedFramesKey _key
Used to avoid creating a new key object every time we do a cache lookup.

Constructor Detail

CompositedActionFrames

public CompositedActionFrames(ImageManager imgr,
                              Map<CompositedActionFrames.CompositedFramesKey,CompositedMultiFrameImage> frameCache,
                              String action,
                              CompositedActionFrames.ComponentFrames[] sources)
Constructs a set of composited action frames with the supplied source frames and colorization configuration. The actual component frame images will not be composited until they are requested.

Method Detail

getOrientationCount

public int getOrientationCount()
Description copied from interface: ActionFrames
Returns the number of orientations available in this set of action frames.

Specified by:
getOrientationCount in interface ActionFrames

getFrames

public TrimmedMultiFrameImage getFrames(int orient)
Description copied from interface: ActionFrames
Returns the multi-frame image that comprises the frames for the specified orientation.

Specified by:
getFrames in interface ActionFrames

getXOrigin

public int getXOrigin(int orient,
                      int frameIdx)
Description copied from interface: ActionFrames
Returns the x offset from the upper left of the image to the "origin" for this character frame. A sprite with location (x, y) will be rendered such that its origin is coincident with that location.

Specified by:
getXOrigin in interface ActionFrames

getYOrigin

public int getYOrigin(int orient,
                      int frameIdx)
Description copied from interface: ActionFrames
Returns the y offset from the upper left of the image to the "origin" for this character frame. A sprite with location (x, y) will be rendered such that its origin is coincident with that location.

Specified by:
getYOrigin in interface ActionFrames

cloneColorized

public ActionFrames cloneColorized(Colorization[] zations)
Description copied from interface: ActionFrames
Creates a clone of these action frames which will have the supplied colorizations applied to the frame images.

Specified by:
cloneColorized in interface ActionFrames

cloneTranslated

public ActionFrames cloneTranslated(int dx,
                                    int dy)
Description copied from interface: ActionFrames
Creates a clone of these action frames which will have the supplied translation applied to the frame images.

Specified by:
cloneTranslated in interface ActionFrames

createFrames

protected CompositedMultiFrameImage createFrames(int orient)
Creates our underlying multi-frame image for a particular orientation.