movements
Class PersonMovementList

java.lang.Object
  extended bymovements.PersonMovement
      extended bymovements.PersonMovementList
All Implemented Interfaces:
java.io.Serializable

class PersonMovementList
extends PersonMovement

This class is a PersonMovement implementation for a movement that is a list of movements. The length of this movement is the sum of the lengths of the movements in the list. Every movement in the list must start where the previous movement ended with the participant both in the same position and facing in the same direction.


Field Summary
private  int cachedMovementIndex
           
private  int cachedMovementStartTick
           
private  java.util.Vector subMovements
          The array of sub-movements.
protected  int tickLength
           
 
Constructor Summary
(package private) PersonMovementList()
          Construct an empty list of movements.
 
Method Summary
(package private)  void AddSubMovement(PersonMovement movement)
          Append a movement to the end of the list of movements.
(package private)  ParticipantPosition getPosition(int ticksIntoMovement)
           
(package private)  void getPosition(ParticipantPosition position, int ticksIntoMovement)
           
(package private)  int getTickLength()
           
(package private)  boolean isEmpty()
           
(package private)  PersonMovement splitMovement(int subPeriodStartTick, int subPeriodEndTick)
          Provides a movement that covers only a period of this movement.
protected  PersonMovement splitMovementInternal(int subPeriodStartTick, int subPeriodEndTick)
          Provides a movement that covers only a period of this movement.
protected  PersonMovement subMovementAt(int index)
          Wrapper for the subMovements Vector member.
 void Trace(java.lang.String indent)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

subMovements

private java.util.Vector subMovements
The array of sub-movements.


cachedMovementIndex

private transient int cachedMovementIndex

cachedMovementStartTick

private transient int cachedMovementStartTick

tickLength

protected int tickLength
Constructor Detail

PersonMovementList

PersonMovementList()
Construct an empty list of movements. An empty list is not a valid ParticipantMovement object so the user must call the AddMovement method at least once before calling any of the ParticipantMovement abstract methods.

Method Detail

AddSubMovement

void AddSubMovement(PersonMovement movement)
Append a movement to the end of the list of movements.

All movements must start with the participant in the same position (including facing in the same direction) as when the previous movement ended. The PersonMovement interface requires that all movements are continuous.


subMovementAt

protected PersonMovement subMovementAt(int index)
Wrapper for the subMovements Vector member.


isEmpty

boolean isEmpty()

Trace

public void Trace(java.lang.String indent)
Overrides:
Trace in class PersonMovement

getPosition

void getPosition(ParticipantPosition position,
                 int ticksIntoMovement)
Specified by:
getPosition in class PersonMovement

splitMovementInternal

protected PersonMovement splitMovementInternal(int subPeriodStartTick,
                                               int subPeriodEndTick)
Description copied from class: PersonMovement
Provides a movement that covers only a period of this movement. This is a default implementation that uses the PersonMovementSplitter to provide the desired sub-movement. However, most implementations of PersonMovement can do this more efficiently and so override this method. By allowing each PersonMovement implementation to implement this, we get a simpler tree of PersonMovement objects.

Overrides:
splitMovementInternal in class PersonMovement

getTickLength

int getTickLength()

getPosition

ParticipantPosition getPosition(int ticksIntoMovement)

splitMovement

final PersonMovement splitMovement(int subPeriodStartTick,
                                   int subPeriodEndTick)
Provides a movement that covers only a period of this movement. This method does some error checking and handles the request in a couple of trivial situations. It calls an implementation specific method to handle the non-trivial cases.



Copyright © 2003 Nigel Westbury