movements
Class TransitionGenerator

java.lang.Object
  extended bymovements.TransitionGenerator

class TransitionGenerator
extends java.lang.Object

This class takes as input a series of movements that may be disjointed in space. That is, one movement may end with a participant at one place on the dance floor but the next movement may start with the dancer in a different place on the dance floor. Without the transitional processing done by this class the dancer would appear to be making sudden jumps.

Data is input by making calls to the addSubMovement and the addTransition methods. Movements are appended using the addSubMovement method. If two movements are disjointed then a call to addTransition must come between the two calls to addSubMovement. The addTransition method takes as parameters the number of prior ticks and the number of following ticks in the transition period.

Once the movements and transition points have been added, getMovement will get a PersonMovement object that makes the series of movements with smooth transitioning between the disjointed movements.


Field Summary
private  PersonMovementList movementList
          Sub movements are initially added to this list.
private  int previousTransitionFollowingTicks
          If there is an outstanding transition then this contains the number of ticks in the second part of the transition, i.e.
private  PersonMovement previousTransitionPriorMovement
          If there is an outstanding transition then this contains the movement for the first part of the transition, i.e.
private  int previousTransitionType
          If there is an outstanding transition then this contains the type of that transition.
private  PersonMovementList resultMovement
           
private  int totalTickLength
          Total length of all movements passed to the object so far
 
Constructor Summary
(package private) TransitionGenerator()
          Construct an empty list of movements.
 
Method Summary
(package private)  void addSubMovement(PersonMovement movement)
           
(package private)  void addTransition(int priorTicks, int followingTicks, int transitionType)
           
(package private)  void getCurrentPosition(ParticipantPosition position)
          Returns the position of the participant when the last movement ended.
(package private)  PersonMovement getMovement()
          This method must not be called until all calls to addSubMovement and addTransition have been made.
(package private)  int getTickLength()
           
(package private)  boolean isValidStartPosition(ParticipantPosition followingPosition)
          Determines if the given position is a valid starting point for the next movement.
private  void processPreviousTransition()
          There may be a previous transition that has not been appended to the output movement.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

resultMovement

private PersonMovementList resultMovement

movementList

private PersonMovementList movementList
Sub movements are initially added to this list.


previousTransitionPriorMovement

private PersonMovement previousTransitionPriorMovement
If there is an outstanding transition then this contains the movement for the first part of the transition, i.e. the period from when the transition starts until the transition point. If there is no outstanding transition then this will be null.


previousTransitionFollowingTicks

private int previousTransitionFollowingTicks
If there is an outstanding transition then this contains the number of ticks in the second part of the transition, i.e. the period from the transtion point until the transition ends. If there is no outstanding transition then this will be undefined.


previousTransitionType

private int previousTransitionType
If there is an outstanding transition then this contains the type of that transition. The constants that this field can take are listed in the Transition class.


totalTickLength

private int totalTickLength
Total length of all movements passed to the object so far

Constructor Detail

TransitionGenerator

TransitionGenerator()
Construct an empty list of movements.

Method Detail

addSubMovement

void addSubMovement(PersonMovement movement)

getTickLength

int getTickLength()

processPreviousTransition

private void processPreviousTransition()
There may be a previous transition that has not been appended to the output movement. This method will write any previous transition.


addTransition

void addTransition(int priorTicks,
                   int followingTicks,
                   int transitionType)
             throws TransitionStartsBeforeFigureStarts,
                    TransitionNotCompletedException
Throws:
TransitionStartsBeforeFigureStarts
TransitionNotCompletedException

getMovement

PersonMovement getMovement()
                     throws TransitionNotCompletedException
This method must not be called until all calls to addSubMovement and addTransition have been made. Results are undefined if any methods are called after this method.

Throws:
TransitionNotCompletedException

getCurrentPosition

void getCurrentPosition(ParticipantPosition position)
                  throws PositionRequiredButNoPriorMovementException,
                         PositionRequiredButImmediatelyAfterTransitionException
Returns the position of the participant when the last movement ended.

Certain movements, such as the 'move' or the 'shift' elements, do not define the starting position but use the position where the previous movement left the participant. This method provides that position.

The method will raise an exception if it is called immediately after a call to addTransition. The reason it does this is because a transition implies a disjoint, the position after a disjoint is not the same as the position before a disjoint so it would be incorrect to return the position before the transtion point. This exception will be raised if the XML specification has a 'transition' element followed by, say, a 'move' element.

Throws:
PositionRequiredButNoPriorMovementException
PositionRequiredButImmediatelyAfterTransitionException

isValidStartPosition

boolean isValidStartPosition(ParticipantPosition followingPosition)
Determines if the given position is a valid starting point for the next movement.

If the last method called was addTransition then any point is a valid starting point because this object will figure out how to transition to it. If the last method called was addSubMovement then the next movement must start at the same point where the previous movement ended.



Copyright © 2003 Nigel Westbury