snakeprogram
Class Snake

java.lang.Object
  extended by snakeprogram.Snake
All Implemented Interfaces:
java.lang.Iterable<java.lang.Integer>

public class Snake
extends java.lang.Object
implements java.lang.Iterable<java.lang.Integer>


Field Summary
static int CLOSED_SNAKE
           
static int OPEN_SNAKE
           
 int TYPE
           
 
Constructor Summary
Snake(java.util.ArrayList<double[]> coord, int i, int type)
          Creates a new snake with position data.
Snake(int type)
          Creates a new snake does not have any position data
 
Method Summary
 void addCoordinates(int frame, java.util.ArrayList<double[]> Xs)
          Adds or replaces the coordinates in the frame.
 void clearSnake(int frame)
          Removes the snake from frame, note frames start at 1
 boolean exists(int frame)
          Checks if snake exists in frame
 double findLength(int time)
          Finds the length, cumulative distance between points in a given frame.
 java.util.ArrayList<double[]> getCoordinates(int i)
           
 int getLastFrame()
           
 int getSize(int frame)
          Gets the number of points in the given frame
 boolean isEmpty()
          Checks every frame to see if the snake is too short then returns whether or not there are snakes left
 java.util.Iterator<java.lang.Integer> iterator()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPEN_SNAKE

public static final int OPEN_SNAKE
See Also:
Constant Field Values

CLOSED_SNAKE

public static final int CLOSED_SNAKE
See Also:
Constant Field Values

TYPE

public final int TYPE
Constructor Detail

Snake

public Snake(int type)
Creates a new snake does not have any position data

Parameters:
type - could be either an OPEN_SNAKE or a CLOSED_SNAKE for the respective curve types

Snake

public Snake(java.util.ArrayList<double[]> coord,
             int i,
             int type)
Creates a new snake with position data.

Parameters:
coord - xcoordinates
i - frame that the current coordinates correspond too.
type - could be either an OPEN_SNAKE or a CLOSED_SNAKE for the respective curve types
Method Detail

getCoordinates

public java.util.ArrayList<double[]> getCoordinates(int i)

findLength

public double findLength(int time)
Finds the length, cumulative distance between points in a given frame.


getSize

public int getSize(int frame)
Gets the number of points in the given frame


exists

public boolean exists(int frame)
Checks if snake exists in frame


clearSnake

public void clearSnake(int frame)
Removes the snake from frame, note frames start at 1

Parameters:
frame - the frame to be removed from

isEmpty

public boolean isEmpty()
Checks every frame to see if the snake is too short then returns whether or not there are snakes left


addCoordinates

public void addCoordinates(int frame,
                           java.util.ArrayList<double[]> Xs)
Adds or replaces the coordinates in the frame.

Parameters:
frame - frame that will recieve the new coordinates
Xs - x coordinates

iterator

public java.util.Iterator<java.lang.Integer> iterator()
Specified by:
iterator in interface java.lang.Iterable<java.lang.Integer>

getLastFrame

public int getLastFrame()