text:
package com.percipient24.cgc.art;

import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.utils.Array;
import com.percipient24.cgc.CGCWorld;
import com.percipient24.cgc.ChainGame;
import com.percipient24.cgc.ChaseApp;
import com.percipient24.cgc.entities.terrain.Water;
import com.percipient24.input.InputManager;

/*
 * Contains the logic for rendering animations
 *
 * @version 0.3 14/2/17
 * @author Christopher Rider
 * @author William Ziegler
 */
public class TextureAnimationDrawer
{
	public static final float RUN_ANIM_FRAME_TIME = 1.0f/12.0f;
	public static final float STAND_ANIM_FRAME_TIME = 1.0f/8.0f;
	public static final float HIT_ANIM_FRAME_TIME = 1.0f/8.0f; // TODO Fix this when there's an animation
	public static final float JUMP_ANIM_FRAME_TIME = 1.0f/8.0f; // TODO Fix this when there's an animation
	public static final float PUNCH_ANIM_FRAME_TIME = 0.053f; // Roughly 18.5 fps
	public static final float DIE_ANIM_FRAME_TIME = 1.0f;
	public static final float TIED_ANIM_FRAME_TIME = 1.0f/8.0f;
	public static final float TERRAIN_ANIM_FRAME_TIME = 3.0f/4.0f; // TODO Fix this when there's an animation
	public static final float GATE_ANIM_FRAME_TIME = 1.0f/16.0f;

	// Character Animations
	public static Animation[] prisonerRunLowAnims;
	public static Animation[] prisonerRunMidAnims;
	public static Animation[] prisonerRunHighAnims;
	public static Animation[] prisonerStandLowAnims;
	public static Animation[] prisonerStandMidAnims;
	public static Animation[] prisonerStandHighAnims;
	public static Animation[] prisonerHitAnims;
	public static Animation[] prisonerJumpAnims;
	public static Animation[] prisonerPunchLowAnims;
	public static Animation[] prisonerPunchMidAnims;
	public static Animation[] prisonerPunchHighAnims;
	public static Animation[] prisonerDieLowAnims;
	public static Animation[] prisonerDieMidAnims;
	public static Animation[] prisonerDieHighAnims;
	public static Animation[] prisonerTiedLowAnims;
	public static Animation[] prisonerTiedMidAnims;
	public static Animation[] prisonerTiedHighAnims;
	public static Animation[] copRunLowAnims;
	public static Animation[] copRunMidAnims;
	public static Animation[] copRunHighAnims;
	public static Animation[] copStandLowAnims;
	public static Animation[] copStandMidAnims;
	public static Animation[] copStandHighAnims;
	public static Animation[] copHitAnims;
	public static Animation[] copJumpAnims;
	public static Animation[] copPunchAnims;
	public static Animation[] copDieLowAnims;
	public static Animation[] copDieMidAnims;
	public static Animation[] copDieHighAnims;

	// Terrain Animations
	public static Animation[] bgAnims;
	public static Animation[] bridgeAnims;
	public static Animation[] currentAnims;
	public static Animation[] mudAnims;
	public static Animation[] waterAnims;
	public static Animation ouyaWater;
	public static Animation ouyaMud;

	// World Animations
	public static Animation[] chainAnims;
	public static Animation[] fenceAnims;
	public static Animation gateAnim;
	public static Animation helicopterAnim;
	public static Animation hwallAnim;
	public static Animation[] postAnims;
	public static Animation sensorAnim;
	public static Animation trackAnim;
	public static Animation trackSolid;
	public static Animation[] trainAnims;
	public static Animation[] treeAnims;
	public static Animation[] towerAnims;
	public static Animation[] vwallAnims;
	public static Animation coinAnim;

	// HUD Animations
	public static Animation[] calloutAnims;
	public static Animation copUpArrowAnim;
	public static Animation copDownArrowAnim;
	public static Animation barBackAnim;
	public static Animation grabFillAnim;
	public static Animation staminaFillAnim;
	public static Animation dazedAnim;
	public static Animation hudTankAnim;
	public static Animation offScreenTimerAnim;
	public static Animation prisonerDownArrowAnim;
	public static Animation prisonerUpArrowAnim;
	public static Animation progConvictAnim;
	public static Animation progCopAnim;
	public static Animation progFinishAnim;
	public static Animation progMeterAnim;
	public static Animation progTrackAppearAnim;
	public static Animation progTrackVanishAnim;
	public static Animation sensorSqrAni;
	public static Animation sensorStarAnim;
	public static Animation sensorTriAnim;
	public static Animation[] keyHeadAnims;
	public static Animation keepGoingAnim;
	public static Animation punchMeAnim;

	// Boss Animations
	public static Animation boostAnim;
	public static Animation crashAnim;
	public static Animation[] jeepAnims;
	public static Animation pallBearerAnim;
	public static Animation sheriffAnim;
	public static Animation steelHorseAnim;
	public static Animation[] tankAnims;

	// Projectile Animations
	public static Animation bulletAnim;
	public static Animation explosionAnim;
	public static Animation tankShellAnim;

	// Targeting Animations
	public static Animation spotlightAnim;
	public static Animation[] targetingAnims;

	/*
	 * Creates a new TextureAnimationDrawer object
	 *
	 * @param myApp					The ChaseApp to use
	 * @param input					The InputManager used by this game
	 */
	public TextureAnimationDrawer(ChaseApp myApp, InputManager input)
	{
		loadCharacterAnimations(input);
		loadTerrainAnimations();
		loadWorldAnimations();
		loadHUDAnimations();
		loadBossAnimations();
		loadProjectileAnimations();
		loadTargetingAnimations();
	}

	/*
	 * Loads textures for targeting icons
	 */
	private void loadTargetingAnimations()
	{
		Array<TextureRegion> targeterRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/targeter"));
		targetingAnims = new Animation[targeterRegions.size];
		for (int i = 0; i < targetingAnims.length; i++)
		{
			Animation newTargetAnimation = new Animation(1.0f, targeterRegions.get(i));
			newTargetAnimation.setPlayMode(Animation.PlayMode.LOOP);
			targetingAnims[i] = newTargetAnimation;
		}

		spotlightAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/spotlight")));
		spotlightAnim.setPlayMode(Animation.PlayMode.LOOP);
	}

	/*
	 * Loads textures for projectiles and projectile-related entities
	 */
	private void loadProjectileAnimations()
	{
		explosionAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("explosion")));
		explosionAnim.setPlayMode(Animation.PlayMode.LOOP);

		tankShellAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("tankshell")));
		tankShellAnim.setPlayMode(Animation.PlayMode.LOOP);

		bulletAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("bullet")));
		bulletAnim.setPlayMode(Animation.PlayMode.LOOP);
	}

	/*
	 * Loads textures for anything not game world related
	 */
	private void loadHUDAnimations()
	{
		barBackAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/grabbackground")));
		barBackAnim.setPlayMode(Animation.PlayMode.LOOP);

		grabFillAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/grabfill")));
		grabFillAnim.setPlayMode(Animation.PlayMode.LOOP);

		staminaFillAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/staminafill")));
		staminaFillAnim.setPlayMode(Animation.PlayMode.LOOP);

		dazedAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/dizzydonuts")));
		dazedAnim.setPlayMode(Animation.PlayMode.LOOP);

		Array<TextureRegion> calloutRegions = new Array<TextureRegion>();
		calloutAnims = new Animation[ChainGame.numPlayers];
		for (int i = 0; i < ChainGame.numPlayers; i++)
		{
			calloutRegions.add(ChaseApp.atlas.findRegion("overlayanimations/callout", i));
			Animation calloutAnim = new Animation(1.0f, calloutRegions.get(i));
			calloutAnim.setPlayMode(Animation.PlayMode.LOOP);
			calloutAnims[i] = calloutAnim;
		}

		offScreenTimerAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/offscreentimer")));
		offScreenTimerAnim.setPlayMode(Animation.PlayMode.LOOP);

		copUpArrowAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/cop_up")));
		copUpArrowAnim.setPlayMode(Animation.PlayMode.LOOP);

		copDownArrowAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/cop_down")));
		copDownArrowAnim.setPlayMode(Animation.PlayMode.LOOP);

		prisonerUpArrowAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/prisoner_up")));
		prisonerUpArrowAnim.setPlayMode(Animation.PlayMode.LOOP);

		prisonerDownArrowAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/prisoner_down")));
		prisonerDownArrowAnim.setPlayMode(Animation.PlayMode.LOOP);

		progMeterAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progressmeter")));
		progMeterAnim.setPlayMode(Animation.PlayMode.LOOP);

		progTrackVanishAnim = new Animation(1/15f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progresstraintrack")));
		progTrackVanishAnim.setPlayMode(Animation.PlayMode.NORMAL);

		progTrackAppearAnim = new Animation(1/15f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progresstraintrack")));
		progTrackAppearAnim.setPlayMode(Animation.PlayMode.REVERSED);

		progFinishAnim = new Animation(1/15f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progressfinish")));
		progFinishAnim.setPlayMode(Animation.PlayMode.REVERSED);

		progConvictAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progressconvict")));
		progConvictAnim.setPlayMode(Animation.PlayMode.LOOP);

		progCopAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/progresscop")));
		progCopAnim.setPlayMode(Animation.PlayMode.LOOP);

		hudTankAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/hudtank")));
		hudTankAnim.setPlayMode(Animation.PlayMode.LOOP);

		sensorTriAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/sensortriangle")));
		sensorTriAnim.setPlayMode(Animation.PlayMode.LOOP);

		sensorSqrAni = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/sensorsquare")));
		sensorSqrAni.setPlayMode(Animation.PlayMode.LOOP);

		sensorStarAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/sensorstar")));
		sensorStarAnim.setPlayMode(Animation.PlayMode.LOOP);

		keepGoingAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/keepgoing")));
		keepGoingAnim.setPlayMode(Animation.PlayMode.LOOP);

		punchMeAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("overlayanimations/punch_me")));
		punchMeAnim.setPlayMode(Animation.PlayMode.LOOP);
	}

	/*
	 * Loads textures for entities inside the game world
	 */
	private void loadWorldAnimations()
	{
		Array<TextureRegion> towerRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("guardtower"));
		towerAnims = new Animation[towerRegions.size];
		for (int i = 0; i < towerAnims.length; i++)
		{
			Animation newTowerAnimation = new Animation(1.0f, towerRegions.get(i));
			newTowerAnimation.setPlayMode(Animation.PlayMode.LOOP);
			towerAnims[i] = newTowerAnimation;
		}

		Array<TextureRegion> treeRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("tree"));
		treeAnims = new Animation[treeRegions.size];
		for (int i = 0; i < treeAnims.length; i++)
		{
			Animation newTreeAnimation = new Animation(1.0f, treeRegions.get(i));
			newTreeAnimation.setPlayMode(Animation.PlayMode.LOOP);
			treeAnims[i] = newTreeAnimation;
		}

		Array<TextureRegion> chainRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("chain"));
		chainAnims= new Animation[2];
		for (int i = 0; i < chainAnims.length; i++)
		{
			Animation newChainAnimation = new Animation(0.125f, chainRegions);
			newChainAnimation.setPlayMode(Animation.PlayMode.LOOP_PINGPONG);
			chainAnims[i] = newChainAnimation;
			chainRegions.reverse();
		}

		hwallAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("hwall")));
		hwallAnim.setPlayMode(Animation.PlayMode.LOOP);

		Array<TextureRegion> vwallRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("vwall"));
		vwallAnims = new Animation[vwallRegions.size];
		for (int i = 0; i < vwallAnims.length; i++)
		{
			Animation newVwallAnimation = new Animation(1.0f, vwallRegions.get(i));
			newVwallAnimation.setPlayMode(Animation.PlayMode.LOOP);
			vwallAnims [i] = newVwallAnimation;
		}

		//TODO: play with this number to get a non-seizure inducing animation
		trackAnim = new Animation(0.03125f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("track")));
		trackAnim.setPlayMode(Animation.PlayMode.LOOP);

		Array<TextureRegion> oneTrack = new Array<TextureRegion>();
		oneTrack.add(ChaseApp.atlas.findRegion("track", 0));
		trackSolid = new Animation(1.0f, oneTrack);

		Array<TextureRegion> trainRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("train"));
		trainAnims = new Animation[trainRegions.size];
		for (int i = 0; i < trainAnims.length; i++)
		{
			Animation newTrainAnimation = new Animation(1.0f, trainRegions.get(i));
			newTrainAnimation.setPlayMode(Animation.PlayMode.LOOP);
			trainAnims[i] = newTrainAnimation;
		}

		Array<TextureRegion> fenceRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("fence"));
		fenceAnims = new Animation[fenceRegions.size];
		for (int i = 0; i < fenceAnims.length; i++)
		{
			Animation newFenceAnimation = new Animation(1.0f, fenceRegions.get(i));
			newFenceAnimation.setPlayMode(Animation.PlayMode.LOOP);
			fenceAnims[i] = newFenceAnimation;
		}

		Array<TextureRegion> postRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("post"));
		postAnims = new Animation[postRegions.size];
		for (int i = 0; i < postAnims.length; i++)
		{
			Animation newPostAnimation = new Animation(1.0f, postRegions.get(i));
			newPostAnimation.setPlayMode(Animation.PlayMode.LOOP);
			postAnims[i] = newPostAnimation;
		}

		gateAnim = new Animation(GATE_ANIM_FRAME_TIME,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("gate")));
		gateAnim.setPlayMode(Animation.PlayMode.NORMAL);

		sensorAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("sensor")));
		sensorAnim.setPlayMode(Animation.PlayMode.LOOP);

		helicopterAnim = new Animation(0.05f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("helicopter")));
		helicopterAnim.setPlayMode(Animation.PlayMode.LOOP);

		coinAnim = new Animation(0.08f,
			new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/coin")));
		coinAnim.setPlayMode(Animation.PlayMode.LOOP);
	}

	/*
	 * Loads textures for game bosses and boss-related entities
	 */
	private void loadBossAnimations()
	{
		sheriffAnim = new Animation(1.0f, new Array<TextureRegion>(ChaseApp.atlas.findRegions("sheriff")));
		sheriffAnim.setPlayMode(Animation.PlayMode.LOOP);

		Array<TextureRegion> jeepRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("jeep"));
		jeepAnims = new Animation[jeepRegions.size];
		for (int i = 0; i < jeepAnims.length; i++)
		{
			Animation newJeepAnimation = new Animation(1.0f, jeepRegions.get(i));
			newJeepAnimation.setPlayMode(Animation.PlayMode.LOOP);
			jeepAnims[i] = newJeepAnimation;
		}

		steelHorseAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("steelhorse")));
		steelHorseAnim.setPlayMode(Animation.PlayMode.LOOP);

		boostAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("booststeelhorse")));
		boostAnim.setPlayMode(Animation.PlayMode.LOOP);

		crashAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("crashsteelhorse")));
		crashAnim.setPlayMode(Animation.PlayMode.LOOP);

		pallBearerAnim = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("pallbearer")));
		pallBearerAnim.setPlayMode(Animation.PlayMode.LOOP);

		Array<TextureRegion> tankRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("tank"));
		tankAnims = new Animation[tankRegions.size];
		for (int i = 0; i < tankAnims.length; i++)
		{
			Animation newTankAnimation = new Animation(1.0f, tankRegions.get(i));
			newTankAnimation.setPlayMode(Animation.PlayMode.LOOP);
			tankAnims[i] = newTankAnimation;
		}
	}

	public static void loadDefaultCharacterAnimations(InputManager input) {
		int max_players = 10;
		prisonerRunLowAnims = new Animation[max_players];
		prisonerRunMidAnims = new Animation[max_players];
		prisonerRunHighAnims = new Animation[max_players];
		prisonerStandLowAnims = new Animation[max_players];
		prisonerStandMidAnims = new Animation[max_players];
		prisonerStandHighAnims = new Animation[max_players];
		prisonerHitAnims = new Animation[max_players];
		prisonerJumpAnims = new Animation[max_players];
		prisonerPunchLowAnims = new Animation[max_players];
		prisonerPunchMidAnims = new Animation[max_players];
		prisonerPunchHighAnims = new Animation[max_players];
		prisonerDieLowAnims = new Animation[max_players];
		prisonerDieMidAnims = new Animation[max_players];
		prisonerDieHighAnims = new Animation[max_players];
		prisonerTiedLowAnims = new Animation[max_players];
		prisonerTiedMidAnims = new Animation[max_players];
		prisonerTiedHighAnims = new Animation[max_players];
		keyHeadAnims = new Animation[max_players];

		for (int i = 0; i < input.controlList.length; i++)
		{
			int pid = i;

			// Load the run cycle
			Animation newAnimation;

			newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunlow0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerRunLowAnims[pid] = newAnimation;

			newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunmid0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerRunMidAnims[pid] = newAnimation;

			newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunhigh0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerRunHighAnims[pid] = newAnimation;

			newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandlow0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerStandLowAnims[pid] = newAnimation;

			newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandmid0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerStandMidAnims[pid] = newAnimation;

			newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandhigh0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerStandHighAnims[pid] = newAnimation;

			newAnimation = new Animation(HIT_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conhit0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerHitAnims[pid] = newAnimation;

			newAnimation = new Animation(JUMP_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conjump0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerJumpAnims[pid] = newAnimation;

			newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchlow0")));
			newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
			prisonerPunchLowAnims[pid] = newAnimation;

			newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchmid0")));
			newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
			prisonerPunchMidAnims[pid] = newAnimation;

			newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchhigh0")));
			newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
			prisonerPunchHighAnims[pid] = newAnimation;

			newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condielow0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerDieLowAnims[pid] = newAnimation;

			newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condiemid0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerDieMidAnims[pid] = newAnimation;

			newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condiehigh0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerDieHighAnims[pid] = newAnimation;

			newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglelow0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerTiedLowAnims[pid] = newAnimation;

			newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglemid0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerTiedMidAnims[pid] = newAnimation;

			newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
					new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglehigh0")));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			prisonerTiedHighAnims[pid] = newAnimation;

			AtlasRegion keyHeadTempRegion = ChaseApp.atlas.findRegion("overlayanimations/keyhead", 0);
		}
	}

	/*
	 * Loads textures for player icons
	 *
	 * @param input					The InputManager used by the game
	 */
	private void loadCharacterAnimations(InputManager input)
	{
		// Load prisoner animations
		prisonerRunLowAnims = new Animation[CGCWorld.numPlayers];
		prisonerRunMidAnims = new Animation[CGCWorld.numPlayers];
		prisonerRunHighAnims = new Animation[CGCWorld.numPlayers];
		prisonerStandLowAnims = new Animation[CGCWorld.numPlayers];
		prisonerStandMidAnims = new Animation[CGCWorld.numPlayers];
		prisonerStandHighAnims = new Animation[CGCWorld.numPlayers];
		prisonerHitAnims = new Animation[CGCWorld.numPlayers];
		prisonerJumpAnims = new Animation[CGCWorld.numPlayers];
		prisonerPunchLowAnims = new Animation[CGCWorld.numPlayers];
		prisonerPunchMidAnims = new Animation[CGCWorld.numPlayers];
		prisonerPunchHighAnims = new Animation[CGCWorld.numPlayers];
		prisonerDieLowAnims = new Animation[CGCWorld.numPlayers];
		prisonerDieMidAnims = new Animation[CGCWorld.numPlayers];
		prisonerDieHighAnims = new Animation[CGCWorld.numPlayers];
		prisonerTiedLowAnims = new Animation[CGCWorld.numPlayers];
		prisonerTiedMidAnims = new Animation[CGCWorld.numPlayers];
		prisonerTiedHighAnims = new Animation[CGCWorld.numPlayers];
		keyHeadAnims = new Animation[CGCWorld.numPlayers];

		for (int i = 0; i < input.controlList.length; i++)
		{
			if (input.controlList[i].isUsed())
			{
				int charChoice = input.controlList[i].getConvictChoice();
				int pid = input.controlList[i].getPID();

				// Load the run cycle
				Animation newAnimation;
				Array<AtlasRegion> conRegions = ChaseApp.atlas.findRegions("gameanimations/conrunlow"+
				 String.valueOf(charChoice));
				if (conRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunlow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunLowAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/conrunmid"+
						String.valueOf(charChoice));
				if (conRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunmid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunMidAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/conrunhigh"+
						String.valueOf(charChoice));
				if (conRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conrunhigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerRunHighAnims[pid] = newAnimation;
				}

				// Load the stand cycle
				conRegions = ChaseApp.atlas.findRegions("gameanimations/constandlow" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandlow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandLowAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/constandmid" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandmid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandMidAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/constandhigh" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/constandhigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerStandHighAnims[pid] = newAnimation;
				}

				// Load the hit animations
				conRegions = ChaseApp.atlas.findRegions("gameanimations/conhit" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(HIT_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerHitAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(HIT_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conhit0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerHitAnims[pid] = newAnimation;
				}

				// Load the jump animations
				conRegions = ChaseApp.atlas.findRegions("gameanimations/conjump" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(JUMP_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerJumpAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(JUMP_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conjump0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerJumpAnims[pid] = newAnimation;
				}

				// Load the punch animations
				conRegions = ChaseApp.atlas.findRegions("gameanimations/conpunchlow" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchlow0")));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchLowAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/conpunchmid" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchmid0")));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchMidAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/conpunchhigh" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/conpunchhigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.NORMAL);
					prisonerPunchHighAnims[pid] = newAnimation;
				}

				// Load the death animations
				conRegions = ChaseApp.atlas.findRegions("gameanimations/condielow" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condielow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieLowAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/condiemid" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condiemid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieMidAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/condiehigh" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/condiehigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerDieHighAnims[pid] = newAnimation;
				}

				// Load the tied animations
				conRegions = ChaseApp.atlas.findRegions("gameanimations/construgglelow" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglelow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedLowAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/construgglemid" +
						String.valueOf(charChoice));
				if(conRegions.size != 0)
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglemid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedMidAnims[pid] = newAnimation;
				}

				conRegions = ChaseApp.atlas.findRegions("gameanimations/construgglehigh" +
						String.valueOf(charChoice));
				if (conRegions.size != 0)
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME, new Array<TextureRegion>(conRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(TIED_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/construgglehigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					prisonerTiedHighAnims[pid] = newAnimation;
				}

				AtlasRegion keyHeadTempRegion = ChaseApp.atlas.findRegion("overlayanimations/keyhead", charChoice);
				if (keyHeadTempRegion != null)
				{
					keyHeadAnims[pid] = new Animation(1.0f, (TextureRegion)keyHeadTempRegion);
				}
				else
				{
					keyHeadAnims[pid] = new Animation(1.0f,
							(TextureRegion)ChaseApp.atlas.findRegion("overlayanimations/keyhead", 0));
				}
			}
		}

		// Load cop animations
		copRunLowAnims = new Animation[CGCWorld.numPlayers];
		copRunMidAnims = new Animation[CGCWorld.numPlayers];
		copRunHighAnims = new Animation[CGCWorld.numPlayers];
		copStandLowAnims = new Animation[CGCWorld.numPlayers];
		copStandMidAnims = new Animation[CGCWorld.numPlayers];
		copStandHighAnims = new Animation[CGCWorld.numPlayers];
		copHitAnims = new Animation[CGCWorld.numPlayers];
		copJumpAnims = new Animation[CGCWorld.numPlayers];
		copPunchAnims = new Animation[CGCWorld.numPlayers];
		copDieLowAnims = new Animation[CGCWorld.numPlayers];
		copDieMidAnims = new Animation[CGCWorld.numPlayers];
		copDieHighAnims = new Animation[CGCWorld.numPlayers];

		// Assign cops to players
		for (int i = 0; i < input.controlList.length; i++)
		{
			if (input.controlList[i].isUsed())
			{
				int charChoice = input.controlList[i].getCopChoice();
				int pid = input.controlList[i].getPID();

				// Load the run cycle
				Animation newAnimation;
				Array<AtlasRegion> copRegions = ChaseApp.atlas.findRegions("gameanimations/coprunlow"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/coprunlow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunLowAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/coprunmid"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/coprunmid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunMidAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/conrunhigh"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(RUN_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/coprunhigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copRunHighAnims[pid] = newAnimation;
				}

				// Load the stand animation
				copRegions = ChaseApp.atlas.findRegions("gameanimations/copstandlow"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copstandlow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandLowAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/copstandmid"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copstandmid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandMidAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/copstandhigh"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(STAND_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copstandhigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copStandHighAnims[pid] = newAnimation;
				}

				// Load the hit animation
				copRegions = ChaseApp.atlas.findRegions("gameanimations/cophit"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(HIT_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copHitAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(HIT_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/cophit0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copHitAnims[pid] = newAnimation;
				}

				// Load the jump animation
				copRegions = ChaseApp.atlas.findRegions("gameanimations/copjump"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(JUMP_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copJumpAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(JUMP_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copjump0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copJumpAnims[pid] = newAnimation;
				}

				// Load the punch animation
				copRegions = ChaseApp.atlas.findRegions("gameanimations/coppunch"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copPunchAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(PUNCH_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/coppunch0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copPunchAnims[pid] = newAnimation;
				}

				// Load the death animation
				copRegions = ChaseApp.atlas.findRegions("gameanimations/copdielow"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieLowAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copdielow0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieLowAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/copdiemid"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieMidAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copdiemid0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieMidAnims[pid] = newAnimation;
				}

				copRegions = ChaseApp.atlas.findRegions("gameanimations/copdiehigh"+
						String.valueOf(charChoice));
				if (copRegions.size != 0)
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME, new Array<TextureRegion>(copRegions));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieHighAnims[pid] = newAnimation;
				}
				else
				{
					newAnimation = new Animation(DIE_ANIM_FRAME_TIME,
							new Array<TextureRegion>(ChaseApp.atlas.findRegions("gameanimations/copdiehigh0")));
					newAnimation.setPlayMode(Animation.PlayMode.LOOP);
					copDieHighAnims[pid] = newAnimation;
				}
			}
		}
	}

	/*
	 * Loads textures for the various terrain in the game
	 */
	private void loadTerrainAnimations()
	{
		Animation bgAnimation = new Animation(1.0f,
				new TextureRegion[]{ChaseApp.atlas.createSprite("terrainanimations/background")});
		bgAnimation.setPlayMode(Animation.PlayMode.LOOP);
		bgAnims = new Animation[]{bgAnimation};

		// Load Mud animations - should be ok with any number of frames, as long as they follow the right format
		mudAnims = new Animation[13];
		for (int i = 0; i <= 12; i++)
		{
			Array<TextureRegion> mudRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimations/mud"+i));
			Animation newAnimation = new Animation(TERRAIN_ANIM_FRAME_TIME, new Array<TextureRegion>(mudRegions));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			mudAnims[i] = newAnimation;
		}

		waterAnims = new Animation[13];
		for (int i = 0; i <= 12; i++)
		{
			Array<TextureRegion> waterRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimations/water"+i));
			Animation newAnimation = new Animation(TERRAIN_ANIM_FRAME_TIME, new Array<TextureRegion>(waterRegions));
			newAnimation.setPlayMode(Animation.PlayMode.LOOP);
			waterAnims[i] = newAnimation;
		}

		currentAnims = new Animation[9];
		for (int i = 0; i <= 8; i++)
		{
			Animation newAnimation;
			Array<AtlasRegion> currentRegions = ChaseApp.atlas.findRegions("terrainanimations/current"+i);
			if (currentRegions.size != 0)
			{
				newAnimation = new Animation(Water.CURRENT_FRAME_TIME, new Array<TextureRegion>(currentRegions));
				newAnimation.setPlayMode(Animation.PlayMode.LOOP);
				currentAnims[i] = newAnimation;
			}
			else
			{
				newAnimation = new Animation(Water.CURRENT_FRAME_TIME,
						new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimation/current0")));
				newAnimation.setPlayMode(Animation.PlayMode.LOOP);
				currentAnims[i] = newAnimation;
			}
		}

		Array<TextureRegion> bridgeRegions = new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimations/bridge"));
		bridgeAnims = new Animation[bridgeRegions.size];
		for (int i = 0; i < bridgeAnims.length; i++)
		{
			Animation newBridgeAnimation  = new Animation(1.0f, bridgeRegions.get(i));
			newBridgeAnimation.setPlayMode(Animation.PlayMode.LOOP);
			bridgeAnims[i] = newBridgeAnimation;
		}

		ouyaWater = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimations/allWater")));
		ouyaWater.setPlayMode(Animation.PlayMode.LOOP);

		ouyaMud = new Animation(1.0f,
				new Array<TextureRegion>(ChaseApp.atlas.findRegions("terrainanimations/allMud")));
		ouyaMud.setPlayMode(Animation.PlayMode.LOOP);
	}

	/*
	 * Draws a single frame of an Animation
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param frame					Which frame to draw
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 */
	public void drawFrame(SpriteBatch sBatch, Animation region, float frame, float x, float y)
	{
		sBatch.draw(region.getKeyFrame(frame), x, y);
	}

	/*
	 * Draws a single frame of an Animation
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param frame					Which frame to draw
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 * @param originX				The X-coordinate of the drawn frame's origin point
	 * @param originY				The Y-coordinate of the drawn frame's origin point
	 * @param scaleX				The X-scaling of the drawn frame
	 * @param scaleY				The Y-scaling of the drawn frame
	 */
	public void drawFrame(SpriteBatch sBatch, Animation region, float frame, float x, float y,
			float originX, float originY, float scaleX, float scaleY)
	{
		sBatch.draw(region.getKeyFrame(frame), x, y, originX, originY,
				gWidth(region), gHeight(region), scaleX, scaleY, 0);
	}

	/*
	 * Draws a single frame of an Animation
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param frame					Which frame to draw
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 * @param scaleX				The X-scaling of the drawn frame
	 * @param scaleY				The Y-scaling of the drawn frame
	 */
	public void drawFrame(SpriteBatch sBatch, Animation region, float frame, float x, float y, float scaleX, float scaleY)
	{
		sBatch.draw(region.getKeyFrame(frame), x, y, gWidth(region) / 2, gHeight(region) / 2,
				gWidth(region), gHeight(region), scaleX, scaleY, 0);
	}

	/*
	 * Draws a single frame of an Animation based on elapsed time
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param time					The elapsed time of the Animation
	 * @param looping				Whether or not the Animation should loop
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 */
	public void drawAnimation(SpriteBatch sBatch, Animation region, float time, boolean looping, float x, float y)
	{
		sBatch.draw(region.getKeyFrame(time, looping), x, y);
	}

	/*
	 * Draws a single frame of an Animation based on elapsed time
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param time					The elapsed time of the Animation
	 * @param looping				Whether or not the Animation should loop
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 * @param scaleX				The X-scaling of the drawn frame
	 * @param scaleY				The Y-scaling of the drawn frame
	 */
	public void drawAnimation(SpriteBatch sBatch, Animation region, float time, boolean looping,
			float x, float y, float scaleX, float scaleY)
	{
		sBatch.draw(region.getKeyFrame(time, looping), x, y, gWidth(region) / 2, gHeight(region) / 2,
				gWidth(region), gHeight(region), scaleX, scaleY, 0);
	}

	/*
	 * Draws a single frame of an Animation based on elapsed time
	 *
	 * @param sBatch				The SpriteBatch to use
	 * @param region				The Animation the frame is from
	 * @param time					The elapsed time of the Animation
	 * @param looping				Whether or not the Animation should loop
	 * @param x						The X-coordinate of the drawn frame
	 * @param y						The Y-coordinate of the drawn frame
	 * @param originX				The X-coordinate of the drawn frame's origin point
	 * @param originY				The Y-coordinate of the drawn frame's origin point
	 * @param scaleX				The X-scaling of the drawn frame
	 * @param scaleY				The Y-scaling of the drawn frame
	 */
	public void drawAnimation(SpriteBatch sBatch, Animation region, float time, boolean looping,
			float x, float y, float originX, float originY, float scaleX, float scaleY)
	{
		sBatch.draw(region.getKeyFrame(time, looping), x, y, originX, originY,
				gWidth(region), gHeight(region), scaleX, scaleY, 0);
	}

	/*
	 * Gets the width of an Animation
	 *
	 * @param animation				The Animation to examine
	 * @return						The width of the Animation
	 */
	public int gWidth(Animation animation)
	{
		return animation.getKeyFrame(0).getRegionWidth();
	}

	/*
	 * Gets the height of an Animation
	 *
	 * @param animation				The Animation to examine
	 * @return						The height of the Animation
	 */
	public int gHeight(Animation animation)
	{
		return animation.getKeyFrame(0).getRegionHeight();
	}
} //End class


text:
ACCEPTED

#### According to
Index Fungorum

#### Published in
null

#### Original name
Lachnum badium Rehm

### Remarks
null

redpajama_set_name: RedPajamaGithub


text:
(function(audiojs, audiojsInstance, container) {
  // Use the path to the audio.js file to create relative paths to the swf and player graphics
  // Remember that some systems (e.g. ruby on rails) append strings like '?1301478336' to asset paths
  var path = (function() {
    var re = new RegExp('audio(\.min)?\.js.*'),
        scripts = document.getElementsByTagName('script');
    for (var i = 0, ii = scripts.length; i < ii; i++) {
      var path = scripts[i].getAttribute('src');
      if(re.test(path)) return path.replace(re, '');
    }
  })();

  // ##The audiojs interface
  // This is the global object which provides an interface for creating new `audiojs` instances.
  // It also stores all of the construction helper methods and variables.
  container[audiojs] = {
    instanceCount: 0,
    instances: {},
    // The markup for the swf. It is injected into the page if there is not support for the `<audio>` element. The `$n`s are placeholders.
    // `$1` The name of the flash movie
    // `$2` The path to the swf
    // `$3` Cache invalidation
    flashSource: '\
      <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="$1" width="1" height="1" name="$1" style="position: absolute; left: -1px;"> \
        <param name="movie" value="$2?playerInstance='+audiojs+'.instances[\'$1\']&datetime=$3"> \
        <param name="allowscriptaccess" value="always"> \
        <embed name="$1" src="$2?playerInstance='+audiojs+'.instances[\'$1\']&datetime=$3" width="1" height="1" allowscriptaccess="always"> \
      </object>',

    // ### The main settings object
    // Where all the default settings are stored. Each of these variables and methods can be overwritten by the user-provided `options` object.
    settings: {
      autoplay: false,
      loop: false,
      preload: true,
      imageLocation: path + 'player-graphics.gif',
      swfLocation: path + 'audiojs.swf',
      useFlash: (function() {
        var a = document.createElement('audio');
        return !(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
      })(),
      hasFlash: (function() {
        if (navigator.plugins && navigator.plugins.length && navigator.plugins['Shockwave Flash']) {
          return true;
        } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
          var mimeType = navigator.mimeTypes['application/x-shockwave-flash'];
          return mimeType && mimeType.enabledPlugin;
        } else {
          try {
            var ax = new ActiveXObject('ShockwaveFlash.ShockwaveFlash');
            return true;
          } catch (e) {}
        }
        return false;
      })(),
      // The default markup and classes for creating the player:
      createPlayer: {
        markup: '\

 \

 \

 \

 \

 \

 \

 \

 \

 \

 \

 \
            00:00/00:00 \

 \

',
        playPauseClass: 'play-pause',
        scrubberClass: 'scrubber',
        progressClass: 'progress',
        loaderClass: 'loaded',
        timeClass: 'time',
        durationClass: 'duration',
        playedClass: 'played',
        errorMessageClass: 'error-message',
        playingClass: 'playing',
        loadingClass: 'loading',
        errorClass: 'error'
      },
      // The default event callbacks:
      trackEnded: function(e) {},
      flashError: function() {
        var player = this.settings.createPlayer,
            errorMessage = getByClass(player.errorMessageClass, this.wrapper),
            html = 'Missing flash player plugin.';
        if (this.mp3) html += ' Download audio file.';
        container[audiojs].helpers.removeClass(this.wrapper, player.loadingClass);
        container[audiojs].helpers.addClass(this.wrapper, player.errorClass);
        errorMessage.innerHTML = html;
      },
      loadError: function(e) {
        var player = this.settings.createPlayer,
            errorMessage = getByClass(player.errorMessageClass, this.wrapper);
        container[audiojs].helpers.removeClass(this.wrapper, player.loadingClass);
        container[audiojs].helpers.addClass(this.wrapper, player.errorClass);
        errorMessage.innerHTML = 'Error loading: "'+this.mp3+'"';
      },
      init: function() {
        var player = this.settings.createPlayer;
        container[audiojs].helpers.addClass(this.wrapper, player.loadingClass);
      },
      loadStarted: function() {
        var player = this.settings.createPlayer,
            duration = getByClass(player.durationClass, this.wrapper),
            m = Math.floor(this.duration / 60),
            s = Math.floor(this.duration % 60);
        container[audiojs].helpers.removeClass(this.wrapper, player.loadingClass);
        duration.innerHTML = ((m<10?'0':'')+m+':'+(s<10?'0':'')+s);
      },
      loadProgress: function(percent) {
        var player = this.settings.createPlayer,
            scrubber = getByClass(player.scrubberClass, this.wrapper),
            loaded = getByClass(player.loaderClass, this.wrapper);
        loaded.style.width = (scrubber.offsetWidth * percent) + 'px';
      },
      playPause: function() {
        if (this.playing) this.settings.play();
        else this.settings.pause();
      },
      play: function() {
        var player = this.settings.createPlayer;
        container[audiojs].helpers.addClass(this.wrapper, player.playingClass);
      },
      pause: function() {
        var player = this.settings.createPlayer;
        container[audiojs].helpers.removeClass(this.wrapper, player.playingClass);
      },
      updatePlayhead: function(percent) {
        var player = this.settings.createPlayer,
            scrubber = getByClass(player.scrubberClass, this.wrapper),
            progress = getByClass(player.progressClass, this.wrapper);
        progress.style.width = (scrubber.offsetWidth * percent) + 'px';

        var played = getByClass(player.playedClass, this.wrapper),
            p = this.duration * percent,
            m = Math.floor(p / 60),
            s = Math.floor(p % 60);
        played.innerHTML = ((m<10?'0':'')+m+':'+(s<10?'0':'')+s);
      }
    },

    // ### Contructor functions

    // `create()`
    // Used to create a single `audiojs` instance.
    // If an array is passed then it calls back to `createAll()`.
    // Otherwise, it creates a single instance and returns it.
    create: function(element, options) {
      var options = options || {}
      if (element.length) {
        return this.createAll(options, element);
      } else {
        return this.newInstance(element, options);
      }
    },

    // `createAll()`
    // Creates multiple `audiojs` instances.
    // If `elements` is `null`, then automatically find any `<audio>` tags on the page and create `audiojs` instances for them.
    createAll: function(options, elements) {
      var audioElements = elements || document.getElementsByTagName('audio'),
          instances = []
          options = options || {};
      for (var i = 0, ii = audioElements.length; i < ii; i++) {
        instances.push(this.newInstance(audioElements[i], options));
      }
      return instances;
    },

    // ### Creating and returning a new instance
    // This goes through all the steps required to build out a usable `audiojs` instance.
    newInstance: function(element, options) {
      var element = element,
          s = this.helpers.clone(this.settings),
          id = 'audiojs'+this.instanceCount,
          wrapperId = 'audiojs_wrapper'+this.instanceCount,
          instanceCount = this.instanceCount++;

      // Check for `autoplay`, `loop` and `preload` attributes and write them into the settings.
      if (element.getAttribute('autoplay') != null) s.autoplay = true;
      if (element.getAttribute('loop') != null) s.loop = true;
      if (element.getAttribute('preload') == 'none') s.preload = false;
      // Merge the default settings with the user-defined `options`.
      if (options) this.helpers.merge(s, options);

      // Inject the player html if required.
      if (s.createPlayer.markup) element = this.createPlayer(element, s.createPlayer, wrapperId);
      else element.parentNode.setAttribute('id', wrapperId);

      // Return a new `audiojs` instance.
      var audio = new container[audiojsInstance](element, s);

      // If `<audio>` or mp3 playback isn't supported, insert the swf & attach the required events for it.
      if (s.useFlash && s.hasFlash) {
        this.injectFlash(audio, id);
        this.attachFlashEvents(audio.wrapper, audio);
      } else if (s.useFlash && !s.hasFlash) {
        this.settings.flashError.apply(audio);
      }

      // Attach event callbacks to the new audiojs instance.
      if (!s.useFlash || (s.useFlash && s.hasFlash)) this.attachEvents(audio.wrapper, audio);

      // Store the newly-created `audiojs` instance.
      this.instances[id] = audio;
      return audio;
    },

    // ### Helper methods for constructing a working player
    // Inject a wrapping div and the markup for the html player.
    createPlayer: function(element, player, id) {
      var wrapper = document.createElement('div'),
          newElement = element.cloneNode(true);
      wrapper.setAttribute('class', 'audiojs');
      wrapper.setAttribute('className', 'audiojs');
      wrapper.setAttribute('id', id);

      // Fix IE's broken implementation of `innerHTML` & `cloneNode` for HTML5 elements.
      if (newElement.outerHTML && !document.createElement('audio').canPlayType) {
        newElement = this.helpers.cloneHtml5Node(element);
        wrapper.innerHTML = player.markup;
        wrapper.appendChild(newElement);
        element.outerHTML = wrapper.outerHTML;
        wrapper = document.getElementById(id);
      } else {
        wrapper.appendChild(newElement);
        wrapper.innerHTML = wrapper.innerHTML + player.markup;
        element.parentNode.replaceChild(wrapper, element);
      }
      return wrapper.getElementsByTagName('audio')[0];
    },

    // Attaches useful event callbacks to an `audiojs` instance.
    attachEvents: function(wrapper, audio) {
      if (!audio.settings.createPlayer) return;
      var player = audio.settings.createPlayer,
          playPause = getByClass(player.playPauseClass, wrapper),
          scrubber = getByClass(player.scrubberClass, wrapper),
          leftPos = function(elem) {
            var curleft = 0;
            if (elem.offsetParent) {
              do { curleft += elem.offsetLeft; } while (elem = elem.offsetParent);
            }
            return curleft;
          };

      container[audiojs].events.addListener(playPause, 'click', function(e) {
        audio.playPause.apply(audio);
      });

      container[audiojs].events.addListener(scrubber, 'click', function(e) {
        var relativeLeft = e.clientX - leftPos(this);
        audio.skipTo(relativeLeft / scrubber.offsetWidth);
      });

      // _If flash is being used, then the following handlers don't need to be registered._
      if (audio.settings.useFlash) return;

      // Start tracking the load progress of the track.
      container[audiojs].events.trackLoadProgress(audio);

      container[audiojs].events.addListener(audio.element, 'timeupdate', function(e) {
        audio.updatePlayhead.apply(audio);
      });

      container[audiojs].events.addListener(audio.element, 'ended', function(e) {
        audio.trackEnded.apply(audio);
      });

      container[audiojs].events.addListener(audio.source, 'error', function(e) {
        // on error, cancel any load timers that are running.
        clearInterval(audio.readyTimer);
        clearInterval(audio.loadTimer);
        audio.settings.loadError.apply(audio);
      });

    },

    // Flash requires a slightly different API to the `<audio>` element, so this method is used to overwrite the standard event handlers.
    attachFlashEvents: function(element, audio) {
      audio['swfReady'] = false;
      audio['load'] = function(mp3) {
        // If the swf isn't ready yet then just set `audio.mp3`. `init()` will load it in once the swf is ready.
        audio.mp3 = mp3;
        if (audio.swfReady) audio.element.load(mp3);
      }
      audio['loadProgress'] = function(percent, duration) {
        audio.loadedPercent = percent;
        audio.duration = duration;
        audio.settings.loadStarted.apply(audio);
        audio.settings.loadProgress.apply(audio, [percent]);
      }
      audio['skipTo'] = function(percent) {
        if (percent > audio.loadedPercent) return;
        audio.updatePlayhead.call(audio, [percent])
        audio.element.skipTo(percent);
      }
      audio['updatePlayhead'] = function(percent) {
        audio.settings.updatePlayhead.apply(audio, [percent]);
      }
      audio['play'] = function() {
        // If the audio hasn't started preloading, then start it now.
        // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
        if (!audio.settings.preload) {
          audio.settings.preload = true;
          audio.element.init(audio.mp3);
        }
        audio.playing = true;
        // IE doesn't allow a method named `play()` to be exposed through `ExternalInterface`, so lets go with `pplay()`.
        // <http://dev.nuclearrooster.com/2008/07/27/externalinterfaceaddcallback-can-cause-ie-js-errors-with-certain-keyworkds/>
        audio.element.pplay();
        audio.settings.play.apply(audio);
      }
      audio['pause'] = function() {
        audio.playing = false;
        // Use `ppause()` for consistency with `pplay()`, even though it isn't really required.
        audio.element.ppause();
        audio.settings.pause.apply(audio);
      }
      audio['setVolume'] = function(v) {
        audio.element.setVolume(v);
      }
      audio['loadStarted'] = function() {
        // Load the mp3 specified by the audio element into the swf.
        audio.swfReady = true;
        if (audio.settings.preload) audio.element.init(audio.mp3);
        if (audio.settings.autoplay) audio.play.apply(audio);
      }
    },

    // ### Injecting an swf from a string
    // Build up the swf source by replacing the `$keys` and then inject the markup into the page.
    injectFlash: function(audio, id) {
      var flashSource = this.flashSource.replace(/\$1/g, id);
      flashSource = flashSource.replace(/\$2/g, audio.settings.swfLocation);
      // `(+new Date)` ensures the swf is not pulled out of cache. The fixes an issue with Firefox running multiple players on the same page.
      flashSource = flashSource.replace(/\$3/g, (+new Date + Math.random()));
      // Inject the player markup using a more verbose `innerHTML` insertion technique that works with IE.
      var html = audio.wrapper.innerHTML,
          div = document.createElement('div');
      div.innerHTML = flashSource + html;
      audio.wrapper.innerHTML = div.innerHTML;
      audio.element = this.helpers.getSwf(id);
    },

    // ## Helper functions
    helpers: {
      // **Merge two objects, with `obj2` overwriting `obj1`**
      // The merge is shallow, but that's all that is required for our purposes.
      merge: function(obj1, obj2) {
        for (attr in obj2) {
          if (obj1.hasOwnProperty(attr) || obj2.hasOwnProperty(attr)) {
            obj1[attr] = obj2[attr];
          }
        }
      },
      // **Clone a javascript object (recursively)**
      clone: function(obj){
        if (obj == null || typeof(obj) !== 'object') return obj;
        var temp = new obj.constructor();
        for (var key in obj) temp[key] = arguments.callee(obj[key]);
        return temp;
      },
      // **Adding/removing classnames from elements**
      addClass: function(element, className) {
        var re = new RegExp('(\\s|^)'+className+'(\\s|$)');
        if (re.test(element.className)) return;
        element.className += ' ' + className;
      },
      removeClass: function(element, className) {
        var re = new RegExp('(\\s|^)'+className+'(\\s|$)');
        element.className = element.className.replace(re,' ');
      },
      // **Handle all the IE6+7 requirements for cloning `<audio>` nodes**
      // Create a html5-safe document fragment by injecting an `<audio>` element into the document fragment.
      cloneHtml5Node: function(audioTag) {
        var fragment = document.createDocumentFragment(),
            doc = fragment.createElement ? fragment : document;
        doc.createElement('audio');
        var div = doc.createElement('div');
        fragment.appendChild(div);
        div.innerHTML = audioTag.outerHTML;
        return div.firstChild;
      },
      // **Cross-browser `<object>` / `<embed>` element selection**
      getSwf: function(name) {
        var swf = document[name] || window[name];
        return swf.length > 1 ? swf[swf.length - 1] : swf;
      }
    },
    // ## Event-handling
    events: {
      memoryLeaking: false,
      listeners: [],
      // **A simple cross-browser event handler abstraction**
      addListener: function(element, eventName, func) {
        // For modern browsers use the standard DOM-compliant `addEventListener`.
        if (element.addEventListener) {
          element.addEventListener(eventName, func, false);
          // For older versions of Internet Explorer, use `attachEvent`.
          // Also provide a fix for scoping `this` to the calling element and register each listener so the containing elements can be purged on page unload.
        } else if (element.attachEvent) {
          this.listeners.push(element);
          if (!this.memoryLeaking) {
            window.attachEvent('onunload', function() {
              if(this.listeners) {
                for (var i = 0, ii = this.listeners.length; i < ii; i++) {
                  container[audiojs].events.purge(this.listeners[i]);
                }
              }
            });
            this.memoryLeaking = true;
          }
          element.attachEvent('on' + eventName, function() {
            func.call(element, window.event);
          });
        }
      },

      trackLoadProgress: function(audio) {
        // If `preload` has been set to `none`, then we don't want to start loading the track yet.
        if (!audio.settings.preload) return;

        var readyTimer,
            loadTimer,
            audio = audio,
            ios = (/(ipod|iphone|ipad)/i).test(navigator.userAgent);

        // Use timers here rather than the official `progress` event, as Chrome has issues calling `progress` when loading mp3 files from cache.
        readyTimer = setInterval(function() {
          if (audio.element.readyState > -1) {
            // iOS doesn't start preloading the mp3 until the user interacts manually, so this stops the loader being displayed prematurely.
            if (!ios) audio.init.apply(audio);
          }
          if (audio.element.readyState > 1) {
            if (audio.settings.autoplay) audio.play.apply(audio);
            clearInterval(readyTimer);
            // Once we have data, start tracking the load progress.
            loadTimer = setInterval(function() {
              audio.loadProgress.apply(audio);
              if (audio.loadedPercent >= 1) clearInterval(loadTimer);
            });
          }
        }, 10);
        audio.readyTimer = readyTimer;
        audio.loadTimer = loadTimer;
      },

      // **Douglas Crockford's IE6 memory leak fix**
      // <http://javascript.crockford.com/memory/leak.html>
      // This is used to release the memory leak created by the circular references created when fixing `this` scoping for IE. It is called on page unload.
      purge: function(d) {
        var a = d.attributes, i;
        if (a) {
          for (i = 0; i < a.length; i += 1) {
            if (typeof d[a[i].name] === 'function') d[a[i].name] = null;
          }
        }
        a = d.childNodes;
        if (a) {
          for (i = 0; i < a.length; i += 1) purge(d.childNodes[i]);
        }
      },

      // **DOMready function**
      // As seen here: <https://github.com/dperini/ContentLoaded/>.
      ready: (function() { return function(fn) {
        var win = window, done = false, top = true,
        doc = win.document, root = doc.documentElement,
        add = doc.addEventListener ? 'addEventListener' : 'attachEvent',
        rem = doc.addEventListener ? 'removeEventListener' : 'detachEvent',
        pre = doc.addEventListener ? '' : 'on',
        init = function(e) {
          if (e.type == 'readystatechange' && doc.readyState != 'complete') return;
          (e.type == 'load' ? win : doc)[rem](pre + e.type, init, false);
          if (!done && (done = true)) fn.call(win, e.type || e);
        },
        poll = function() {
          try { root.doScroll('left'); } catch(e) { setTimeout(poll, 50); return; }
          init('poll');
        };
        if (doc.readyState == 'complete') fn.call(win, 'lazy');
        else {
          if (doc.createEventObject && root.doScroll) {
            try { top = !win.frameElement; } catch(e) { }
            if (top) poll();
          }
          doc[add](pre + 'DOMContentLoaded', init, false);
          doc[add](pre + 'readystatechange', init, false);
          win[add](pre + 'load', init, false);
        }
      }
      })()

    }
  }

  // ## The audiojs class
  // We create one of these per `<audio>` and then push them into `audiojs['instances']`.
  container[audiojsInstance] = function(element, settings) {
    // Each audio instance returns an object which contains an API back into the `<audio>` element.
    this.element = element;
    this.wrapper = element.parentNode;
    this.source = element.getElementsByTagName('source')[0] || element;
    // First check the `<audio>` element directly for a src and if one is not found, look for a `<source>` element.
    this.mp3 = (function(element) {
      var source = element.getElementsByTagName('source')[0];
      return element.getAttribute('src') || (source ? source.getAttribute('src') : null);
    })(element);
    this.settings = settings;
    this.loadStartedCalled = false;
    this.loadedPercent = 0;
    this.duration = 1;
    this.playing = false;
  }

  container[audiojsInstance].prototype = {
    // API access events:
    // Each of these do what they need do and then call the matching methods defined in the settings object.
    updatePlayhead: function() {
      var percent = this.element.currentTime / this.duration;
      this.settings.updatePlayhead.apply(this, [percent]);
    },
    skipTo: function(percent) {
      if (percent > this.loadedPercent) return;
      this.element.currentTime = this.duration * percent;
      this.updatePlayhead();
    },
    load: function(mp3) {
      this.loadStartedCalled = false;
      this.source.setAttribute('src', mp3);
      // The now outdated `load()` method is required for Safari 4
      this.element.load();
      this.mp3 = mp3;
      container[audiojs].events.trackLoadProgress(this);
    },
    loadError: function() {
      this.settings.loadError.apply(this);
    },
    init: function() {
      this.settings.init.apply(this);
    },
    loadStarted: function() {
      // Wait until `element.duration` exists before setting up the audio player.
      if (!this.element.duration) return false;

      this.duration = this.element.duration;
      this.updatePlayhead();
      this.settings.loadStarted.apply(this);
    },
    loadProgress: function() {
      if (this.element.buffered != null && this.element.buffered.length) {
        // Ensure `loadStarted()` is only called once.
        if (!this.loadStartedCalled) {
          this.loadStartedCalled = this.loadStarted();
        }
        var durationLoaded = this.element.buffered.end(this.element.buffered.length - 1);
        this.loadedPercent = durationLoaded / this.duration;

        this.settings.loadProgress.apply(this, [this.loadedPercent]);
      }
    },
    playPause: function() {
      if (this.playing) this.pause();
      else this.play();
    },
    play: function() {
      var ios = (/(ipod|iphone|ipad)/i).test(navigator.userAgent);
      // On iOS this interaction will trigger loading the mp3, so run `init()`.
      if (ios && this.element.readyState == 0) this.init.apply(this);
      // If the audio hasn't started preloading, then start it now.
      // Then set `preload` to `true`, so that any tracks loaded in subsequently are loaded straight away.
      if (!this.settings.preload) {
        this.settings.preload = true;
        this.element.setAttribute('preload', 'auto');
        container[audiojs].events.trackLoadProgress(this);
      }
      this.playing = true;
      this.element.play();
      this.settings.play.apply(this);
    },
    pause: function() {
      this.playing = false;
      this.element.pause();
      this.settings.pause.apply(this);
    },
    setVolume: function(v) {
      this.element.volume = v;
    },
    trackEnded: function(e) {
      this.skipTo.apply(this, [0]);
      if (!this.settings.loop) this.pause.apply(this);
      this.settings.trackEnded.apply(this);
    }
  }

  // **getElementsByClassName**
  // Having to rely on `getElementsByTagName` is pretty inflexible internally, so a modified version of Dustin Diaz's `getElementsByClassName` has been included.
  // This version cleans things up and prefers the native DOM method if it's available.
  var getByClass = function(searchClass, node) {
    var matches = [];
    node = node || document;

    if (node.getElementsByClassName) {
      matches = node.getElementsByClassName(searchClass);
    } else {
      var i, l,
          els = node.getElementsByTagName("*"),
          pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");

      for (i = 0, l = els.length; i < l; i++) {
        if (pattern.test(els[i].className)) {
          matches.push(els[i]);
        }
      }
    }
    return matches.length > 1 ? matches : matches[0];
  };
// The global variable names are passed in here and can be changed if they conflict with anything else.
})('audiojs', 'audiojsInstance', this);


text:
package signalproc.output;

import org.trianacode.taskgraph.Task;
import org.trianacode.taskgraph.Unit;
import triana.types.GraphType;
import triana.types.ProcessDoublesInterface;
import triana.types.TrianaType;

/**
 * A SGTGrapher unit.
 *
 * @author Rob Davies
 * @version $Revision $
 */
public class SGTGrapher extends Unit implements ProcessDoublesInterface {

    TrianaType input;
    private int counter = 0;
    signalproc.output.GraphLabels graphLabels = null;
    int lineStyle;

    public void process() throws Exception {
        getTask().setParameter("numberOfInputs", String.valueOf(getInputNodeCount()));

        for (int count = 0; count < getInputNodeCount(); count++) { // loop over all input nodes
            getTask().setParameterType("SGTGraphData_" + count, Task.TRANSIENT);

            if (getTask().getDataInputNode(count).isConnected()) { // only get data from connected input nodes
                input = (TrianaType) getInputAtNode(count);

                if (isClipInName(GraphLabels.Graph_Labels_ClipIn_Tag)) {
                    System.out.println("SGTGrapher, node " + count + " getting clipIn");
                    Object obj = getClipIn(GraphLabels.Graph_Labels_ClipIn_Tag);
                    if (obj instanceof signalproc.output.GraphLabels) {
                        graphLabels = (signalproc.output.GraphLabels) obj;
                        getTask().setParameter("clipInExists", "true");
                        getTask().setParameter("lineStyle", String.valueOf(graphLabels.getLineStyle()));
                        getTask().setParameter("mainTitle", graphLabels.getTitle());
                        getTask().setParameter("xtitle", graphLabels.getXTitle());
                        getTask().setParameter("ytitle", graphLabels.getYTitle());
                        getTask().setParameter("lineKeyTitle", graphLabels.getLineKeyTitle());
                        getTask().setParameter("markType", String.valueOf(graphLabels.getMarkType()));
                        getTask().setParameter("markSize", String.valueOf(graphLabels.getMarkSize()));
                    }
                }

                if (input instanceof GraphType) { // if the input os of type GraphType
                    getTask().setParameter("SGTGraphData_" + count, input);
                }
            } else {
                getTask().setParameter("SGTGraphData_" + count, "notConnected");
            }
            getTask().setParameter("clipInExists", "false"); // reset for the next dataaset
        }

        getTask().setParameter("finished", String.valueOf(++counter));
    }

    /**
     * Initialses information specific to SGTGrapher.
     */
    public void init() {
        super.init();
        setDefaultInputNodes(1);
        setDefaultOutputNodes(0);
        setMinimumInputNodes(1);
        setMaximumInputNodes(Integer.MAX_VALUE);
        setMaximumOutputNodes(0);
        // set these to true if your unit can process double-precision
        // arrays       setRequireDoubleInputs(false);
        setParameterUpdatePolicy(Task.IMMEDIATE_UPDATE);

        // Initialise pop-up description and help file location
        setPopUpDescription("A graphical-displaying unit for rendering input signals");
        setHelpFileLocation("SGTGrapher.html");

        setParameterPanelClass("signalproc.output.SGTGrapherPanel");

        defineParameter("requireDoubleInputs", new Boolean(false), INTERNAL);
        defineParameter("canProcessDoubleArrays", new Boolean(false), INTERNAL);
        defineParameter("xtitle", "", TRANSIENT);
        defineParameter("ytitle", "", TRANSIENT);
        defineParameter("lineStyle", "-1", TRANSIENT);
        defineParameter("clipInExists", "false", TRANSIENT);
        defineParameter("lineKeyTitle", "", TRANSIENT);
        defineParameter("markType", "-1", TRANSIENT);
        defineParameter("markSize", "-1", TRANSIENT);
        defineParameter("finished", "0", TRANSIENT);
        defineParameter("numberOfInputs", "0", TRANSIENT);

        setDefaultNodeRequirement(ESSENTIAL_IF_CONNECTED);
    }

    /**
     * Called when the unit is reset. Restores the unit's variables to values specified by the parameters.
     */
    public void reset() {
        // Set unit variables to the values specified by the parameters
    }

    public void parameterUpdate(String paramname, Object value) {
        // Code to update local variables
    }

    /**
     * @return a string containing the names of the types allowed to be input to SGTGrapher, each separated by a white
     *         space.
     */
    public String[] getInputTypes() {
        return new String[]{"GraphType"};
    }

    /**
     * @return a string containing the names of the types output from SGTGrapher, each separated by a white space.
     */
    public String[] getOutputTypes() {
        return new String[]{"none"};
    }

    public boolean getRequireDoubleInputs() {
        return ((Boolean) getParameter("requireDoubleInputs")).booleanValue();
    }

    public boolean getCanProcessDoubleArrays() {
        return ((Boolean) getParameter("canProcessDoubleArrays")).booleanValue();
    }

    public void setRequireDoubleInputs(boolean state) {
        setParameter("requireDoubleInputs", new Boolean(state));
    }

    public void setCanProcessDoubleArrays(boolean state) {
        setParameter("canProcessDoubleArrays", new Boolean(state));
    }

}


text:
"""
    This is our TX server that will listen on the appropriate UNIX socket and
    server as general API to all of our services.

    (c) 2015 Massachusetts Institute of Technology
 """
# Native
import time
import logging
logger = logging.getLogger(__name__)

# CATAN
from catan.comms import TxServer
from catan.datalink import UDPTransmitter
import catan.globals as G

if __name__ == "__main__":

    logging.basicConfig()

    node_id = 0
    node_dict = { #NodeID   :         (IP, PORT)
                    0       : ('127.0.0.1',G.UDP_DEFAULT_PORT)
                 }

    # Initialize our low-level transmitter
    udp_transmit = UDPTransmitter(node_id,node_dict)

    # Start our server
    server = TxServer(udp_transmit,G.TX_DEFAULT_SOCK)

    server.serve_forever()


text:
require 'est'
require 'nokogiri'
require 'tmpdir'
require 'slop'
require 'English'

Before do
  @cwd = Dir.pwd
  @dir = Dir.mktmpdir('test')
  FileUtils.mkdir_p(@dir) unless File.exist?(@dir)
  Dir.chdir(@dir)
  @opts = Slop.parse ['-v', '-s', @dir] do
    on 'v', 'verbose'
    on 's', 'source', argument: :required
  end
end

After do
  Dir.chdir(@cwd)
  FileUtils.rm_rf(@dir) if File.exist?(@dir)
end

Given(/^I have a "([^"]*)" file with content:$/) do |file, text|
  FileUtils.mkdir_p(File.dirname(file)) unless File.exist?(file)
  File.open(file, 'w') do |f|
    f.write(text)
  end
end

When(/^I run est$/) do
  @xml = Nokogiri::XML.parse(Est::Base.new(@opts).xml)
end

Then(/^XML matches "([^"]+)"$/) do |xpath|
  fail "XML doesn't match \"#{xpath}\":\n#{@xml}" if @xml.xpath(xpath).empty?
end

When(/^I run est it fails with "([^"]*)"$/) do |txt|
  begin
    Est::Base.new(@opts).xml
    passed = true
  rescue Est::Error => ex
    unless ex.message.include?(txt)
      raise "Est failed but exception doesn't contain \"#{txt}\": #{ex.message}"
    end
  end
  fail "Est didn't fail" if passed
end

When(/^I run bin\/est with "([^"]*)"$/) do |arg|
  home = File.join(File.dirname(__FILE__), '../..')
  @stdout = `ruby -I#{home}/lib #{home}/bin/est #{arg}`
  @exitstatus = $CHILD_STATUS.exitstatus
end

Then(/^Stdout contains "([^"]*)"$/) do |txt|
  unless @stdout.include?(txt)
    fail "STDOUT doesn't contain '#{txt}':\n#{@stdout}"
  end
end

Then(/^Stdout is empty$/) do
  fail "STDOUT is not empty:\n#{@stdout}" unless @stdout == ''
end

Then(/^XML file "([^"]+)" matches "([^"]+)"$/) do |file, xpath|
  fail "File #{file} doesn't exit" unless File.exist?(file)
  xml = Nokogiri::XML.parse(File.read(file))
  xml.remove_namespaces!
  if xml.xpath(xpath).empty?
    fail "XML file #{file} doesn't match \"#{xpath}\":\n#{xml}"
  end
end

Then(/^Exit code is zero$/) do
  fail "Non-zero exit code #{@exitstatus}" unless @exitstatus == 0
end

Then(/^Exit code is not zero$/) do
  fail 'Zero exit code' if @exitstatus == 0
end

When(/^I run bash with$/) do |text|
  FileUtils.copy_entry(@cwd, File.join(@dir, 'est'))
  @stdout = `#{text}`
  @exitstatus = $CHILD_STATUS.exitstatus
end


text:
<?php

namespace Apollina\Template\Functions;

/**
 * This class manage the Template
 *
 * @category  	Apollina
 * @package     Apollina\Template\Functions
 * @author    	Judicaël Paquet <judicael.paquet@gmail.com>
 * @copyright 	Copyright (c) 2013-2014 PAQUET Judicaël FR Inc. (https://github.com/las93)
 * @license   	https://github.com/las93/venus2/blob/master/LICENSE.md Tout droit réservé à PAQUET Judicaël
 * @version   	Release: 3.0.0
 * @filesource	https://github.com/las93/venus2
 * @link      	https://github.com/las93
 * @since     	3.0.0
 */
class ConfigLoad
{
	/**
	 * run before
	 *
	 * @access public
	 * @param  array $aParams parameters
	 * @return \Apollina\Template\ConfigLoad
	 */
	public function replaceBy($aParams = array())
	{
		$sFile = '';

		if (isset($aParams['file'])) { $sFile = $aParams['file']; }
		else { new \Exception('ConfigLoad: file obligatory');}

		$sViewDirectory = str_replace('lib'.DIRECTORY_SEPARATOR.'Template'.DIRECTORY_SEPARATOR.'Function',
			'src'.DIRECTORY_SEPARATOR.PORTAL.DIRECTORY_SEPARATOR.'View'.DIRECTORY_SEPARATOR, __DIR__);

		$aConfVars = parse_ini_file($sViewDirectory.$sFile);

		$sContent = '';
		$sContent = $this->_constructVar($sContent, $aConfVars, '$_aProtectedVar[\'app\'][\'config\']');

		return '<?php '.$sContent.'; ?>';
	}

	/**
	 * constructor of var on recursive mode
	 *
	 * @access private
	 * @param  string $sContent content to return
	 * @param  array $aConfVars var to parse
	 * @return unknown
	 */
	private function _constructVar($sContent, $aConfVars, $sVarTemplate)
	{
		foreach ($aConfVars as $mKey => $mOne) {

			if (is_array($mOne)) {

				$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = array(); ';
				$sContent = $this->_constructVar($sContent, $mOne, $sVarTemplate.'[\''.$mKey.'\']');
			}
			else {

				$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = "'.$mOne.'"; ';
			}
		}

		return $sContent;
	}
}


text:
require 'chef-workflow/support/knife'

ChefWorkflow::KnifeSupport.add_attribute :fc_cookbooks_path, File.join(Dir.pwd, 'cookbooks')
ChefWorkflow::KnifeSupport.add_attribute :fc_options, [ ]

namespace :chef do
  namespace :cookbooks do
    desc "Run the cookbooks through foodcritic"
    task :foodcritic do
      resolve_task = Rake::Task["chef:cookbooks:resolve"] rescue nil
      resolve_task.invoke if resolve_task

      if File.directory?(ChefWorkflow::KnifeSupport.fc_cookbooks_path)
        Bundler.with_clean_env do
          sh "foodcritic #{ChefWorkflow::KnifeSupport.fc_cookbooks_path} #{ChefWorkflow::KnifeSupport.fc_options.join(" ")}"
        end
      end
    end
  end
end


text:
package de.oliver_heger.linedj.platform.audio.model

import de.oliver_heger.linedj.shared.archive.media.MediaFileID
import de.oliver_heger.linedj.shared.archive.metadata.MediaMetaData

import scala.beans.BeanProperty

object SongData {
  /** Constant for an unknown song duration. */
  val UnknownDuration: Int = -1

  /** Constant for an unknown track number. */
  val UnknownTrackNumber: Int = -1
}

/**
  * A data class that holds information about a song.
  *
  * The song is mainly described by its unique ID and the meta data available
  * for it. As meta data is optional, some important properties like title or
  * artist are provided explicitly. They can be resolved when an instance is
  * created and are then available for direct access.
  *
  * This class may also be used by model classes for UI controls displaying song
  * information. Therefore, it has to expose properties following the Java Beans
  * standard.
  *
  * @param id       the ID of this song in the media archive
  * @param metaData meta data about this song
  */
case class SongData(id: MediaFileID, metaData: MediaMetaData,
                    @BeanProperty title: String,
                    @BeanProperty artist: String,
                    @BeanProperty album: String) {

  import SongData._

  /**
    * The duration of this song (in milliseconds) as bean property. If the
    * duration is unknown, result is less than zero.
    */
  lazy val getDuration: Int = metaData.duration getOrElse UnknownDuration

  /**
    * Returns a flag whether a duration is defined for this song in meta data.
    * If this function returns '''true''', ''getDuration'' will return a
    * correct duration value. Otherwise, a special negative value is returned.
    *
    * @return a flag whether the duration is defined for this song
    */
  def hasDuration: Boolean = metaData.duration.isDefined

  /**
    * The track number as bean property. If the track number is unknown, a
    * negative number is returned.
    */
  lazy val getTrackNumber: Int = metaData.trackNumber getOrElse UnknownTrackNumber

  /**
    * Returns a flag whether a track number is defined for this song in meta
    * data. If this function returns '''true''', ''getTrackNumber'' will return
    * a correct track number. Otherwise, a special negative value is returned.
    *
    * @return a flag whether the track number is defined for this song
    */
  def hasTrackNumber: Boolean = metaData.trackNumber.isDefined
}


text: Syntropy website


text:
/**
*============================================================================
*  The Ohio State University Research Foundation, The University of Chicago -
*  Argonne National Laboratory, Emory University, SemanticBits LLC,
*  and Ekagra Software Technologies Ltd.
*
*  Distributed under the OSI-approved BSD 3-Clause License.
*  See http://ncip.github.com/cagrid-portal/LICENSE.txt for details.
*============================================================================
**/
/**
 *
 */
package gov.nih.nci.cagrid.portal.portlet.authn;

import gov.nih.nci.cagrid.portal.domain.PortalUser;

import javax.portlet.PortletSession;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import org.springframework.beans.factory.annotation.Required;
import org.springframework.validation.BindException;
import org.springframework.web.portlet.ModelAndView;
import org.springframework.web.portlet.mvc.AbstractController;

/**
 * @author Joshua Phillips
 *
 */
public class ViewLoginController extends AbstractController {

	private String portalUserAttributeName;
	private String viewName;
	private String errorsAttributeName;

	/**
	 *
	 */
	public ViewLoginController() {

	}

	protected ModelAndView handleRenderRequestInternal(RenderRequest request,
			RenderResponse response) throws Exception {
		ModelAndView mav = null;
		BindException errors = null;
		if(getErrorsAttributeName() != null){
			errors = (BindException)request.getAttribute(getErrorsAttributeName());
		}
		if(errors != null){
			mav = new ModelAndView(getViewName(), errors.getModel());
		}else{
			mav = new ModelAndView(getViewName());
		}

		logger.debug("Looking for PortalUser under '" + getPortalUserAttributeName() + "'");

		PortalUser user = (PortalUser) request.getPortletSession()
				.getAttribute(getPortalUserAttributeName(),
						PortletSession.APPLICATION_SCOPE);
		if (user != null) {
			mav.addObject("portalUser", user);
		} else {
			mav.addObject("registerUrl", request.getPreferences().getValue("registerUrl", ""));
		}

		return mav;
	}

	@Required
	public String getPortalUserAttributeName() {
		return portalUserAttributeName;
	}

	public void setPortalUserAttributeName(String portalUserAttributeName) {
		this.portalUserAttributeName = portalUserAttributeName;
	}

	@Required
	public String getViewName() {
		return viewName;
	}

	public void setViewName(String viewName) {
		this.viewName = viewName;
	}

	public String getErrorsAttributeName() {
		return errorsAttributeName;
	}

	public void setErrorsAttributeName(String errorsAttributeName) {
		this.errorsAttributeName = errorsAttributeName;
	}

}


text:
This library is used to access The Link Emperor API.

## Installation

Add this line to your application's Gemfile:

    gem 'linkemperor-api'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install linkemperor-api

## Usage

Include the gem on your project and use it like this:

    require 'linkemperor-api'

    # Customers
    api = LinkemperorCustomer.new('<api_key>')
    api.desired_method

    # Vendors
    api = LinkemperorVendor.new('<api_key>')
    api.desired_method

For details on the available operations, check documentation available on
http://www.linkemperor.com/api-documentation

## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request


text: sudo /usr/local/ssl/misc/CA.sh -newca