Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  //
  // Nenya library - tools for developing networked games
  // Copyright (C) 2002-2012 Three Rings Design, Inc., All Rights Reserved
  // https://github.com/threerings/nenya
  //
  // This library is free software; you can redistribute it and/or modify it
  // under the terms of the GNU Lesser General Public License as published
  // by the Free Software Foundation; either version 2.1 of the License, or
  // (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 // Lesser General Public License for more details.
 //
 // You should have received a copy of the GNU Lesser General Public
 // License along with this library; if not, write to the Free Software
 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 
 package com.threerings.cast;
 
 import java.util.Map;
 
 
 
An implementation of the com.threerings.media.util.MultiFrameImage interface that is used to lazily create composited character frames when they are requested.
 
 public class CompositedActionFrames
     implements ActionFramesDirectionCodes
 {
    
Used to associate a CharacterComponent with its ActionFrames for a particular action.
 
     public static class ComponentFrames
     {
         public CharacterComponent ccomp;
 
         public ActionFrames frames;
 
         public ComponentFrames () {
         }
 
         public ComponentFrames (
             CharacterComponent ccompActionFrames frames) {
             this. = ccomp;
             this. = frames;
         }
 
         @Override
         public String toString () {
             return  + ":" + ;
         }
     }

    
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.
 
     public CompositedActionFrames (
         ImageManager imgrMap<CompositedFramesKeyCompositedMultiFrameImageframeCache,
         String actionComponentFrames[] sources)
     {
         // sanity check
         if (sources == null || sources.length == 0) {
             String errmsg = "Requested to composite invalid set of source " +
                 "frames! [action=" + action +
                 ", sources=" + StringUtil.toString(sources) + "].";
             throw new RuntimeException(errmsg);
         }
 
          = imgr;
          = frameCache;
          = sources;
          = action;
 
         // the sources must all have the same orientation count, so we
         // just use the first
     }
 
     // documentation inherited from interface
     public int getOrientationCount ()
     {
         return ;
     }
 
     // documentation inherited from interface
     public TrimmedMultiFrameImage getFrames (int orient)
     {
         .setOrient(orient);
         CompositedMultiFrameImage cmfi =
            .get();
        if (cmfi == null) {
            cmfi = createFrames(orient);
            .put(new CompositedFramesKey(orient), cmfi);
        }
        return cmfi;
    }
    // documentation inherited from interface
    public int getXOrigin (int orientint frameIdx)
    {
            getFrames(orient);
        return cmfi.getXOrigin(frameIdx);
    }
    // documentation inherited from interface
    public int getYOrigin (int orientint frameIdx)
    {
            getFrames(orient);
        return cmfi.getYOrigin(frameIdx);
    }
    // documentation inherited from interface
    public ActionFrames cloneColorized (Colorization[] zations)
    {
        throw new RuntimeException("What you talkin' about Willis?");
    }
    // documentation inherited from interface
    public ActionFrames cloneTranslated (int dxint dy)
    {
        ComponentFrames[] tsources = new ComponentFrames[.];
        for (int ii = 0; ii < .ii++) {
            tsources[ii] = new ComponentFrames(
                [ii].[ii]..cloneTranslated(dxdy));
        }
        return new CompositedActionFrames(tsources);
    }

    
Creates our underlying multi-frame image for a particular orientation.
    protected CompositedMultiFrameImage createFrames (int orient)
    {
        return new CompositedMultiFrameImage(orient);
    }

    
Used to cache composited frames for a particular action and orientation.
    protected class CompositedFramesKey
    {
        public CompositedFramesKey (int orient) {
             = orient;
        }
        public void setOrient (int orient) {
             = orient;
        }
        public CompositedActionFrames getOwner () {
            return CompositedActionFrames.this;
        }
        @Override
        public boolean equals (Object other) {
            CompositedFramesKey okey = (CompositedFramesKey)other;
            return ((getOwner() == okey.getOwner()) &&
                    ( == okey._orient));
        }
        @Override
        public int hashCode () {
            return CompositedActionFrames.this.hashCode() ^ ;
        }
        protected int _orient;
    }

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

    
Used to cache our composited action frame images.
The action for which we're compositing frames.
    protected String _action;

    
The number of orientations.
    protected int _orientCount;

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

    
Used to avoid creating a new key object every time we do a cache lookup.
    protected CompositedFramesKey _key = new CompositedFramesKey(0);
New to GrepCode? Check out our FAQ X