hmi.elckerlyc.faceengine.faceunit
Class TimedFaceUnit

java.lang.Object
  extended by hmi.elckerlyc.planunit.AbstractPlanUnit
      extended by hmi.elckerlyc.faceengine.faceunit.TimedFaceUnit
All Implemented Interfaces:
PlanUnit

public class TimedFaceUnit
extends AbstractPlanUnit

When you do not set an end time peg, 'UNKNOWN' is assumed. This leads to the faceunit being timed as starttime..starttime+getpreferredduration When you do not set a start time peg, the animation cannot be played

Author:
Dennis Reidsma

Field Summary
 FaceUnit fu
           
protected  ArrayList<KeyPosition> progressHandled
           
private  PlanUnitTimeManager puTimeManager
           
 
Fields inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
bmlBlockPeg
 
Constructor Summary
TimedFaceUnit(BMLBlockPeg bbPeg, String i, String bmlId, FaceUnit f)
          Constructor
 
Method Summary
 void cleanup()
           
 List<String> getAvailableSyncs()
          Get the list of sync ids that can be used in this behavior.
 double getEndTime()
          Get the global end time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 FaceUnit getFaceUnit()
           
 KeyPosition getKeyPosition(String kid)
          Gets the keyposition with id id
 KeyPosition getKeyPosition(TimePeg sp)
           
 double getNextPegTime(String pid)
           
 Map<KeyPosition,TimePeg> getPegs()
           
 double getPegTime(String pid)
           
 double getPreferedDuration()
          0 is unknown/persistent
 double getPrevPegTime(String pid)
           
 double getRelativeTime(String syncId)
          Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points
 String getReplacementGroup()
          Get the PlanUnit replacement group (=typically the BML behavior) Used to determine the currently active persistent PlanUnit for this group in the player Only one group is active at a time null is none
 double getStartTime()
          Get the global start time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 double getTime(String syncId)
          Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)
 TimePeg getTimePeg(String pid)
          null is not set
 boolean hasValidTiming()
          Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).
 void playUnit(double time)
           
private  void sendProgress(double t, double time)
          Send progress feedback for all key positions passed at canonical time t.
 void setParameterValue(String paramId, float value)
          Sets a parameter value
 void setParameterValue(String paramId, String value)
          Sets a parameter value
 void setTimePeg(KeyPosition kp, TimePeg sp)
           
 void setTimePeg(String kid, TimePeg sp)
          Assigns a TimePeg to a sync in the PlanUnit
protected  void stopUnit(double time)
           
 
Methods inherited from class hmi.elckerlyc.planunit.AbstractPlanUnit
addFeedbackListener, feedback, getBMLBlockPeg, getBMLId, getId, getState, isDone, isLurking, isPlaying, isSubUnit, play, reset, resetUnit, setState, setSubUnit, start, startUnit, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

fu

public final FaceUnit fu

progressHandled

protected ArrayList<KeyPosition> progressHandled

puTimeManager

private final PlanUnitTimeManager puTimeManager
Constructor Detail

TimedFaceUnit

public TimedFaceUnit(BMLBlockPeg bbPeg,
                     String i,
                     String bmlId,
                     FaceUnit f)
Constructor

Parameters:
i - behaviour id
bmlId - BML block id
f - face unit
Method Detail

hasValidTiming

public boolean hasValidTiming()
Description copied from interface: PlanUnit
Checks if the timing of this plan unit is 'valid' (e.g. stuff like start is earlier than end, but also planunit specific stuff like biomechanically possible timing).

Returns:
true if valid

getPegs

public Map<KeyPosition,TimePeg> getPegs()

getKeyPosition

public KeyPosition getKeyPosition(TimePeg sp)

getPrevPegTime

public double getPrevPegTime(String pid)

getNextPegTime

public double getNextPegTime(String pid)

getPegTime

public double getPegTime(String pid)

getTimePeg

public TimePeg getTimePeg(String pid)
Description copied from interface: PlanUnit
null is not set


getAvailableSyncs

public List<String> getAvailableSyncs()
Description copied from interface: PlanUnit
Get the list of sync ids that can be used in this behavior. The list is ordered in relative time and maintains the BML order for BML syncIds. All BML syncs should be present in this list.

Specified by:
getAvailableSyncs in interface PlanUnit
Overrides:
getAvailableSyncs in class AbstractPlanUnit

getEndTime

public double getEndTime()
Description copied from interface: PlanUnit
Get the global end time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)


setTimePeg

public void setTimePeg(String kid,
                       TimePeg sp)
Description copied from interface: PlanUnit
Assigns a TimePeg to a sync in the PlanUnit


setTimePeg

public void setTimePeg(KeyPosition kp,
                       TimePeg sp)

getStartTime

public double getStartTime()
Description copied from interface: PlanUnit
Get the global start time of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)


getTime

public double getTime(String syncId)
Description copied from interface: PlanUnit
Get the global time of sync syncId of the PlanUnit, TimePeg.VALUEUNKNOWN if not known (yet)

Specified by:
getTime in interface PlanUnit
Overrides:
getTime in class AbstractPlanUnit

getRelativeTime

public double getRelativeTime(String syncId)
                       throws RelativeSyncNotFoundException
Description copied from interface: PlanUnit
Get the relative timing of this sync id Implementing classes should at least provide valid relative times for the BML sync points

Specified by:
getRelativeTime in interface PlanUnit
Overrides:
getRelativeTime in class AbstractPlanUnit
Returns:
relative time in range [0..1]
Throws:
RelativeSyncNotFoundException

getKeyPosition

public KeyPosition getKeyPosition(String kid)
Gets the keyposition with id id


sendProgress

private void sendProgress(double t,
                          double time)
Send progress feedback for all key positions passed at canonical time t.

Parameters:
t - canonical time 0 <= t <=1
time - time since start of BML execution

playUnit

public void playUnit(double time)
              throws PlayException
Specified by:
playUnit in class AbstractPlanUnit
Throws:
PlayException

cleanup

public void cleanup()

getFaceUnit

public FaceUnit getFaceUnit()
Returns:
the encapsulated face unit

stopUnit

protected void stopUnit(double time)
                 throws PlayException
Specified by:
stopUnit in class AbstractPlanUnit
Throws:
PlayException

getReplacementGroup

public String getReplacementGroup()
Description copied from interface: PlanUnit
Get the PlanUnit replacement group (=typically the BML behavior) Used to determine the currently active persistent PlanUnit for this group in the player Only one group is active at a time null is none

Specified by:
getReplacementGroup in interface PlanUnit
Overrides:
getReplacementGroup in class AbstractPlanUnit

getPreferedDuration

public double getPreferedDuration()
Description copied from interface: PlanUnit
0 is unknown/persistent

Specified by:
getPreferedDuration in interface PlanUnit
Overrides:
getPreferedDuration in class AbstractPlanUnit

setParameterValue

public void setParameterValue(String paramId,
                              String value)
Description copied from interface: PlanUnit
Sets a parameter value


setParameterValue

public void setParameterValue(String paramId,
                              float value)
Description copied from interface: PlanUnit
Sets a parameter value