javoids
Class SpriteVector<E extends BasicSprite>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.Vector<E>
              extended by javoids.SpriteVector<E>
Type Parameters:
E - the type of sprite being stored
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Iterable<E>, java.util.Collection<E>, java.util.List<E>, java.util.RandomAccess

public class SpriteVector<E extends BasicSprite>
extends java.util.Vector<E>

A vecotr class to hold many sprites.

Author:
mallette
See Also:
Serialized Form

Field Summary
private static long serialVersionUID
          This is the version used for serializing/deserializing (storing/retrieving) this object
 
Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
SpriteVector(int maxParts)
           
 
Method Summary
 boolean add(E basicSprite)
          add a sprite to this vector.
 boolean addAll(SpriteVector<E> sprites)
          add all the sprites from another SpriteVector to this vector.
 void drawSprites(java.awt.Graphics2D g2d, java.awt.Graphics2D foregroundImage)
          Draw all of the sprites in this vector.
 void moveSprites()
          move all the sprites in the vector
 void moveSpritesGravity(java.util.Collection<? extends BasicSprite> sprites)
          Move the sprites in the vector toward/away from the sprites in another vector (if the other sprites are gravity sources).
 void moveSpritesHoming(java.util.Collection<? extends BasicSprite> sprites)
          Move the sprites in the vector to the target sprites in another vector (if they are homing) going to the closest one.
 void removeDead()
          Remove the dead sprites from the vector
 java.lang.String toString()
          Provide a String representation of this object.
 
Methods inherited from class java.util.Vector
add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
iterator, listIterator, listIterator
 

Field Detail

serialVersionUID

private static final long serialVersionUID
This is the version used for serializing/deserializing (storing/retrieving) this object

See Also:
Constant Field Values
Constructor Detail

SpriteVector

public SpriteVector(int maxParts)
Parameters:
maxParts -
Method Detail

moveSprites

public void moveSprites()
move all the sprites in the vector


moveSpritesHoming

public void moveSpritesHoming(java.util.Collection<? extends BasicSprite> sprites)
Move the sprites in the vector to the target sprites in another vector (if they are homing) going to the closest one.

Parameters:
sprites - the other sprites that are targets.

moveSpritesGravity

public void moveSpritesGravity(java.util.Collection<? extends BasicSprite> sprites)
Move the sprites in the vector toward/away from the sprites in another vector (if the other sprites are gravity sources). Applying the effect from each gravity source/sink.

Parameters:
sprites - the other sprites that are targets.

removeDead

public void removeDead()
Remove the dead sprites from the vector


drawSprites

public void drawSprites(java.awt.Graphics2D g2d,
                        java.awt.Graphics2D foregroundImage)
Draw all of the sprites in this vector.

Parameters:
g2d - the graphics context
foregroundImage - the foreground image to redraw the sprites on

add

public boolean add(E basicSprite)
add a sprite to this vector.

Specified by:
add in interface java.util.Collection<E extends BasicSprite>
Specified by:
add in interface java.util.List<E extends BasicSprite>
Overrides:
add in class java.util.Vector<E extends BasicSprite>
Parameters:
basicSprite - the sprite to add
Returns:
true if successful, otherwise return false

addAll

public boolean addAll(SpriteVector<E> sprites)
add all the sprites from another SpriteVector to this vector.

Parameters:
sprites - the sprites to add to this vector
Returns:
true if successful, otherwise return false

toString

public java.lang.String toString()
Provide a String representation of this object.

Overrides:
toString in class java.util.Vector<E extends BasicSprite>
Returns:
String A representation of the object for debugging.