package model.state;

import java.awt.Dimension;
import java.util.List;
import java.util.Map;
import util.JSONable;
import engine.visual.animation.AnimationSequence;
import engine.visual.animation.NullAnimationSequence;


/**
 * A data wrapper object used to group the pertinent information for a
 * spritesheet. Internal data is intentionally made public as this is just a
 * data wrapper to simplify the passing of data
 * 
 * @author Rahul, Zach, Steve
 *
 */

public class AnimatorState implements JSONable {

    private String imageTag;
    private Dimension viewportSize;
    private int numCols;
    private Map<List<AnimationTag>, AnimationSequence> animationMap;

    /**
     * Create the Spritesheet
     * 
     * @param imageTag
     *        the tag for the image that will be sent to the save/load
     *        utility to get the image
     * @param frameDimensions
     *        the dimensions of a frame of the spritesheet
     * @param numCols
     *        the number of columns across in the spritesheet
     */
    public AnimatorState (String imageTag,
                          Dimension frameDimensions,
                          int numCols,
                          Map<List<AnimationTag>, AnimationSequence> animationMap) {
        this.imageTag = imageTag;
        this.viewportSize = frameDimensions;
        this.numCols = numCols;
        this.animationMap = animationMap;
    }

    public void addAnimationSequence (List<AnimationTag> tag, AnimationSequence seq) {
        animationMap.put(tag, seq);
    }

    public AnimationSequence getAnimationSequence (List<AnimationTag> tag) {
        return (animationMap.containsKey(tag)) ? animationMap.get(tag)
                                              : new NullAnimationSequence();
    }

    public boolean containsAnimationSequence (List<AnimationTag> tag) {
        return animationMap.containsKey(tag);
    }

    public String getImageTag () {
        return imageTag;
    }

    public Dimension getViewportSize () {
        return viewportSize;
    }

    public int getNumCols () {
        return numCols;
    }
}

@@ -1015,24 +1015,107 @@
 spritesheet%0A
+     * @param animationMap%0A     * %09%09  map of Animation tags to Animation sequences%0A
      */%0A    
@@ -1498,635 +1498,2302 @@
     
-public void addAnimationSequence (List%3CAnimationTag%3E tag, AnimationSequence seq) %7B%0A        animationMap.put(tag, seq);%0A    %7D%0A%0A    public AnimationSequence getAnimationSequence (List%3CAnimationTag%3E tag) %7B%0A        return (animationMap.containsKey(tag)) ? animationMap.get(tag)%0A                                              : new NullAnimationSequence();%0A    %7D%0A%0A    public boolean containsAnimationSequence (List%3CAnimationTag%3E tag) %7B%0A        return animationMap.containsKey(tag);%0A    %7D%0A%0A    public String getImageTag () %7B%0A        return imageTag;%0A    %7D%0A%0A    public Dimension getViewportSize () %7B%0A        return viewportSize;%0A    %7D%0A
+/**%0A     * Adds an animation to the AnimatorState's animationMap%0A     * @param tag%0A     * %09%09  a list of animation tags which serves as a key in%0A     *        animationMap%0A     * @param seq%0A     *        an animation sequence to which the tag is mapped%0A     */%0A    public void addAnimationSequence (List%3CAnimationTag%3E tag, AnimationSequence seq) %7B%0A        animationMap.put(tag, seq);%0A    %7D%0A%0A    /**%0A     * Returns the associated animation sequence given an animation%0A     * tag list as a key. If the animation sequence is not in the map,%0A     * a null animation sequence is returned%0A     * %0A     * @param tag%0A     *        a list of animation tags which serves as a key in %0A     *        animationMap%0A     * @return AnimationSequence%0A     * %09%09   the animation sequence to which the tag is mapped%0A     *         if there is no mapping to the tag, a NullAnimationSequence%0A     *         is returned.%0A     */%0A    public AnimationSequence getAnimationSequence (List%3CAnimationTag%3E tag) %7B%0A        return (animationMap.containsKey(tag)) ? animationMap.get(tag)%0A                                              : new NullAnimationSequence();%0A    %7D%0A%0A    /**%0A     * Checks if the given list of animation tags is in the keyset of%0A     * the animationMap%0A     * %0A     * @param tag%0A     *        a list of animation tags which serves as a key in %0A     *        animationMap%0A     * @return boolean%0A     *         true if the tag is in the keyset of the animationMap%0A     *         false if the tag is not in the keyset of the animationMap%0A     */%0A    public boolean containsAnimationSequence (List%3CAnimationTag%3E tag) %7B%0A        return animationMap.containsKey(tag);%0A    %7D%0A%0A    /**%0A     * Returns the imageTag of this instance of AnimatorState%0A     * %0A     * @return String%0A     *         the imageTag of the AnimatorState%0A     */%0A    public String getImageTag () %7B%0A        return imageTag;%0A    %7D%0A%0A    /**%0A     * Returns the size of the viewport%0A     * %0A     * @return Dimension%0A     *         a dimensions object which contains%0A     *         the size of the user's screen%0A     */%0A    public Dimension getViewportSize () %7B%0A        return viewportSize;%0A    %7D%0A%0A    /**%0A     * Returns the number of columns in the spritesheet%0A     * %0A     * @return int%0A     *         the number of columns in the spritesheet%0A     */
 %0A   

improve comments in AnimatorState.java