movements
Class PersonMovementInAUnit

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

class PersonMovementInAUnit
extends PersonMovement

This class implements a movement of a person over a period of time. This class is used when the person is participating in a unit. This class is given both the position of the person within the unit and a pointer to an object that defines the movement of the unit. This class is then able to calculate the position of the person.

A single object of this class is constructed to represent the entire movement of the person in the unit, even though the movement of the unit may consist of a series of sub-movements.


Field Summary
private  double facingR
           
private  int forwardsOffset
           
private  int sidewaysOffset
           
protected  int tickLength
           
private  PersonMovement unitMovement
           
private  ParticipantPosition unitPosition
          Work object used to obtain the position of the unit.
 
Constructor Summary
(package private) PersonMovementInAUnit(PersonMovement unitMovement, int forwardsOffset, int sidewaysOffset, double facing)
          Construct a movement of a person for the period that the person is participating in a unit.
 
Method Summary
(package private)  ParticipantPosition getPosition(int ticksIntoMovement)
           
(package private)  void getPosition(ParticipantPosition position, int ticksIntoMovement)
           
(package private)  int getTickLength()
           
private  void readObject(java.io.ObjectInputStream in)
           
(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

forwardsOffset

private int forwardsOffset

sidewaysOffset

private int sidewaysOffset

facingR

private double facingR

unitMovement

private PersonMovement unitMovement

unitPosition

private transient ParticipantPosition unitPosition
Work object used to obtain the position of the unit.


tickLength

protected int tickLength
Constructor Detail

PersonMovementInAUnit

PersonMovementInAUnit(PersonMovement unitMovement,
                      int forwardsOffset,
                      int sidewaysOffset,
                      double facing)
Construct a movement of a person for the period that the person is participating in a unit. The movement consists of moving to keep the given fixed position relative to the unit.

The time length of this movement is the same as the time length of the unit's movements.

Parameters:
unitMovement - A PersonMovement object that specifies the positions of the unit during the movement.
Method Detail

readObject

private void readObject(java.io.ObjectInputStream in)
                 throws java.io.IOException,
                        java.lang.ClassNotFoundException
Throws:
java.io.IOException
java.lang.ClassNotFoundException

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

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