Class Figur

Class Figur

java.lang.Object
   |
   +----Figur

class Figur
extends Object
implements Runnable
Figur is the main class for storing/displaying the dance figures. It is (should be) an abstract class. Don't create an instance of it. Create only objects of the classes SlowWaltz, Tango, SlowFox and Quickstep.
See Also:
SlowWaltz, Tango, SlowFox, Quickstep

Variable Index

 o BPM
beats per minute == Takte * Tempo
 o Takte
Is this dance a 3/4 dance (e.g.

Constructor Index

 o Figur(Dance)
Constructor initialize some always needed variables.

Method Index

 o BottomEdge()
Return the bottom edge of the floors.
 o CalcWTime(float)
Calculate waiting time.
 o Dance()
Start the animation.
 o DoDStep()
Does one step on the female (Lady) floor.
 o DoHStep()
Does one step on the male (Gent) floor.
 o HideComStr()
Hide the takt/time string (slow/quick or heel/toe) on both floors.
 o LeftEdge()
Return the left edge of the male floor
 o NextNNTime()
Next non zero (german: Null) time.
 o PrevNNTime()
Previsious non zero (german: Null) waiting time.
 o RightEdge()
Return the right edge of the female floor (plus some additional space
 o SetCounter(int)
Set the time counter value.
 o ShowComStr()
Show the takt/time string (slow/quick or heel/toe) on both floors.
 o StopDance()
Stop the animation.
 o ThreadsAlive()
Is at least one of the dancing threads (male/female) alive?
 o clearSteps()
Clear all done steps.
 o drawNum(Graphics, boolean)
Draw the time/takt number.
 o drawTitel(Graphics)
Draw the dance and figur name on the top of the applet.
 o inSingleStep()
Are we in single step mode?
 o leaveSingleStep()
Leave the single step mode.
 o run()
Main function for the animation feature.
 o stepBackw()
Take one step backward (in single step mode).
 o stepForw()
Does on step forward (in single step mode)
 o toString()
Returns a String object representing.
 o useComStrHT()
Use the heel/toe string for the comment field.
 o useComStrTime()
Use the time (slow/quick) string for the comment field.

Variables

 o Takte
  public int Takte
Is this dance a 3/4 dance (e.g. slow waltz) (=> Takte = 3) or a 4/4 dance (e.g. quickstep) (=> Takte = 4)
 o BPM
  public int BPM
beats per minute == Takte * Tempo

Constructors

 o Figur
  protected Figur(Dance app)
Constructor initialize some always needed variables.
Parameters:
app - pointer to the main dance applet (e.g. needed for Dance.engl

Methods

 o CalcWTime
  public long CalcWTime(float time)
Calculate waiting time. Gets a float time number relative to the dance tact and returns the waiting time in milli secs.
Parameters:
time - time relative to the dance tact
Returns:
waiting time in milli secs.
 o NextNNTime
  public float NextNNTime()
Next non zero (german: Null) time. Looks from the current step forward for the next step with waiting time greater zero.
Returns:
next non zero waiting time. If no such time exists, return one.
 o PrevNNTime
  public float PrevNNTime()
Previsious non zero (german: Null) waiting time. Looks from the current step backward to find the next (smalles) waiting time greater zero.
Returns:
previsious waiting time greater zero. Returns zero, if no such time exists.
 o DoHStep
  public float DoHStep()
Does one step on the male (Gent) floor.
Returns:
the waiting time until the next male step is to do or -1 if there was no step to do. (The last step has a waiting time > 0 too, so -1 comes, if there was already no step to do.)
 o DoDStep
  public float DoDStep()
Does one step on the female (Lady) floor.
Returns:
the waiting time until the next female step is to do or -1 if there was no step to do. (The last step has a waiting time > 0 too, so -1 comes, if there was already no step to do.)
 o stepForw
  public void stepForw()
Does on step forward (in single step mode)
 o stepBackw
  public void stepBackw()
Take one step backward (in single step mode). If not in single step mode, do all steps and go into single step mode.
 o inSingleStep
  public boolean inSingleStep()
Are we in single step mode?
 o leaveSingleStep
  public void leaveSingleStep()
Leave the single step mode. Needed initializations does the Dance class
 o clearSteps
  public void clearSteps()
Clear all done steps. After the next repaint(), no feeds are on the floors.
 o ShowComStr
  public void ShowComStr()
Show the takt/time string (slow/quick or heel/toe) on both floors.
See Also:
ShowComStr
 o HideComStr
  public void HideComStr()
Hide the takt/time string (slow/quick or heel/toe) on both floors.
See Also:
HideComStr
 o useComStrHT
  public void useComStrHT()
Use the heel/toe string for the comment field.
See Also:
useComStrHT
 o useComStrTime
  public void useComStrTime()
Use the time (slow/quick) string for the comment field.
See Also:
useComStrTime
 o run
  public void run()
Main function for the animation feature. This function will be started twice. As well for the male thread (thread name "Herr") an for the female thread (thread name "Dame"). It does step by step and sleep() between the steps. repaint() is only needed, if the waiting time is an fraction of the takt because the sound thread already does a repaint every takt beat. If all steps are set, the threads does kill themself and, if it was the last thread, the sound thread will also be killed.
 o Dance
  public synchronized void Dance()
Start the animation. Set the tempo/BPM, starts the male/female threads and than start the sound thread.
 o StopDance
  public synchronized void StopDance()
Stop the animation. E.g. if the "play" button is hit while an animation still runs, the animation will be aborted. Than all missing steps are done quickly.
 o ThreadsAlive
  public boolean ThreadsAlive()
Is at least one of the dancing threads (male/female) alive?
 o SetCounter
  public void SetCounter(int c)
Set the time counter value. Needed in single step mode. Counter value -1 means, hide the counter window.
 o drawTitel
  public void drawTitel(Graphics g)
Draw the dance and figur name on the top of the applet.
 o drawNum
  public void drawNum(Graphics g,
                      boolean update)
Draw the time/takt number. The value of this counter is maintained from the sound class.
Parameters:
g - actual graphics context
update - only an update or an whole repaint
See Also:
Sound, GetNumImg
 o LeftEdge
  public int LeftEdge()
Return the left edge of the male floor
 o RightEdge
  public int RightEdge()
Return the right edge of the female floor (plus some additional space
 o BottomEdge
  public int BottomEdge()
Return the bottom edge of the floors.
 o toString
  public String toString()
Returns a String object representing.
Overrides:
toString in class Object