movements
Class PersonMovementTimeShifted

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

class PersonMovementTimeShifted
extends PersonMovement

This class implements a movement where the participant takes the track of a given underlying movement but the speed at which the participant moves along the track in adjusted.

This object is constructed from the original PersonMovement object and from an array of time adjustments. The time adjustments are used to shift the time before passing on the request for the participant's position to the underlying PersonMovement object. For example, if a request is made to the PersonMovementTimeShifted object for the position at tick 8 and the time adjustments indicate that the participant has been slowed and is currently two ticks behind where the participant would normally be, then the PersonMovementTimeShifted object will pass tick 6 onto the underlying PersonMovement to obtain the position.


Field Summary
private  int[] adjustments
          The amount by which each tick must be adjusted before being passed on the the underlying PersonMovement object when getting the participant's postion.
private  PersonMovement originalMovement
          The movement that would have been taken by the participant had no adjustment been made to avoid a collision.
protected  int tickLength
           
 
Constructor Summary
(package private) PersonMovementTimeShifted(PersonMovement originalMovement, int[] adjustments)
           
 
Method Summary
(package private)  ParticipantPosition getPosition(int ticksIntoMovement)
           
(package private)  void getPosition(ParticipantPosition position, int ticksIntoMovement)
           
(package private)  int getTickLength()
           
(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.
 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

originalMovement

private PersonMovement originalMovement
The movement that would have been taken by the participant had no adjustment been made to avoid a collision.


adjustments

private int[] adjustments
The amount by which each tick must be adjusted before being passed on the the underlying PersonMovement object when getting the participant's postion.


tickLength

protected int tickLength
Constructor Detail

PersonMovementTimeShifted

PersonMovementTimeShifted(PersonMovement originalMovement,
                          int[] adjustments)
Method Detail

getPosition

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

Trace

public void Trace(java.lang.String indent)
Overrides:
Trace 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.


splitMovementInternal

protected PersonMovement splitMovementInternal(int subPeriodStartTick,
                                               int subPeriodEndTick)
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.



Copyright © 2003 Nigel Westbury