sdr 0.7

net.cscott.sdr.calls
Class DanceState

java.lang.Object
  extended by net.cscott.sdr.calls.DanceState

public class DanceState
extends Object

DanceState captures all the dynamic information about a dance: the current formation and the queues of dancer actions and calls. It includes a link to a DanceProgram which is the static information about the dance.

Author:
C. Scott Ananian

Field Summary
 DanceProgram dance
           
 
Constructor Summary
DanceState(DanceProgram dance, Formation f)
           
DanceState(DanceProgram dance, Formation f, Map<String,String> properties)
           
 
Method Summary
 void add(Dancer d, DancerPath dp)
          Move the given dancer along the specified dancer path.
 DanceState cloneAndClear()
          Return a new independent dance state with the same static state and current formation, but empty movements and actions.
 DanceState cloneAndClear(Formation formation)
          Similar to cloneAndClear(), but allows you to specify the new 'current formation' of the result.
 Formation currentFormation()
          Return the last in the list of timed formations.
 Fraction currentTime()
          Return the time of the last formation.
 Set<Dancer> dancers()
          Return all the Dancers in this DanceState.
 Set<Dancer> designated()
          Look at the top of the designated dancer stack.
 Formation formationAt(Fraction time)
          Return the latest formation at or preceding the given time.
 List<TimedFormation> formations()
          Return a sorted list of TimedFormations describing the net effect of the DancerPaths in this DanceState.
 List<DancerPath> movements(Dancer d)
          Return all the DancerPaths, in order, performed by the given Dancer.
 void popDesignated()
          Pop the top off the designated dancer stack.
 String property(String name, String defaultValue)
          Access the environment's property map.
 void pushDesignated(Set<Dancer> designated)
          Add the set of designated dancers to the stack stored in the DanceState.
 void syncDancers()
          Add "do nothing" actions as necessary so that every dancer's next action will occur at the same time.
 void syncDancers(Fraction time)
          Add "do nothing" actions as necessary so that every dancer's next action will occur at the given time.
 TaggedFormation tagDesignated(Formation f)
          Add the 'DESIGNATED' tag to the given Formation.
 FormationMatch tagDesignated(FormationMatch fm)
          Add the 'DESIGNATED' tag to the given FormationMatch.
 String toString()
           
 void unsyncDancers()
          Remove any trailing "do nothing" actions so that the next action flows directly from the previous one.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

dance

public final DanceProgram dance
Constructor Detail

DanceState

public DanceState(DanceProgram dance,
                  Formation f,
                  Map<String,String> properties)

DanceState

public DanceState(DanceProgram dance,
                  Formation f)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

currentFormation

public Formation currentFormation()
Return the last in the list of timed formations.


currentTime

public Fraction currentTime()
Return the time of the last formation.


cloneAndClear

public DanceState cloneAndClear()
Return a new independent dance state with the same static state and current formation, but empty movements and actions. The timing of the current formation is reset to zero. This is used for independently evaluation subcalls, when we then want to apply a transformation to the timing, positions, movements, formations, etc, before adding them to the parent state.

Returns:
a new clean DanceState

cloneAndClear

public DanceState cloneAndClear(Formation formation)
Similar to cloneAndClear(), but allows you to specify the new 'current formation' of the result. This is useful for concepts which alter the shape of the current formation (say, creating a mirror image) before applying the subcall.

Parameters:
formation - what result.currentFormation() should return.
Returns:
a new clean DanceState.

pushDesignated

public void pushDesignated(Set<Dancer> designated)
Add the set of designated dancers to the stack stored in the DanceState.

Parameters:
designated -

popDesignated

public void popDesignated()
Pop the top off the designated dancer stack.


designated

public Set<Dancer> designated()
Look at the top of the designated dancer stack.


tagDesignated

public TaggedFormation tagDesignated(Formation f)
Add the 'DESIGNATED' tag to the given Formation.


tagDesignated

public FormationMatch tagDesignated(FormationMatch fm)
Add the 'DESIGNATED' tag to the given FormationMatch.


property

public String property(String name,
                       String defaultValue)
Access the environment's property map.

See Also:
ExprList._PROPERTY

add

public void add(Dancer d,
                DancerPath dp)
Move the given dancer along the specified dancer path. This will alter the currentFormation(), and may create additional intermediate formations, if the DancerPath.time falls in between existing formations.


syncDancers

public void syncDancers()
Add "do nothing" actions as necessary so that every dancer's next action will occur at the same time.


syncDancers

public void syncDancers(Fraction time)
Add "do nothing" actions as necessary so that every dancer's next action will occur at the given time.


unsyncDancers

public void unsyncDancers()
Remove any trailing "do nothing" actions so that the next action flows directly from the previous one. This is used in "roll" -- I don't know if it's useful for any other calls.


movements

public List<DancerPath> movements(Dancer d)
Return all the DancerPaths, in order, performed by the given Dancer.


dancers

public Set<Dancer> dancers()
Return all the Dancers in this DanceState.


formations

public List<TimedFormation> formations()
Return a sorted list of TimedFormations describing the net effect of the DancerPaths in this DanceState. The first element in the list will match the starting formation provided when this DanceState was constructed, will have an absolute time of Fraction.ZERO, and will have all dancers selected. The final element in the list will represent the final state. Formations should not be considered animation targets: not all dancers will have moved in all formations. For example, if dancer #1 has a movement which takes 2 beats, and dancer #2 has two movements which take 1 each, the result list will include the starting formation, with time 0, an intermediate formation with time 1 where dancer #1 is in their starting position and dancer #2 has taken their first movement, and a final position with time 2 where both dancer #1 and dancer #2 have moved. Consult the list of DancerPaths for accurate animation information.


formationAt

public Formation formationAt(Fraction time)
Return the latest formation at or preceding the given time.


sdr 0.7

Copyright © 2006-2009 C. Scott Ananian