algoanim.animalscript
Class AnimalGenerator

java.lang.Object
  extended by algoanim.primitives.generators.Generator
      extended by algoanim.animalscript.AnimalGenerator
All Implemented Interfaces:
GeneratorInterface
Direct Known Subclasses:
AnimalArcGenerator, AnimalArrayBasedQueueGenerator, AnimalArrayBasedStackGenerator, AnimalArrayGenerator, AnimalArrayMarkerGenerator, AnimalCircleGenerator, AnimalCircleSegGenerator, AnimalConceptualQueueGenerator, AnimalConceptualStackGenerator, AnimalDoubleMatrixGenerator, AnimalEllipseGenerator, AnimalEllipseSegGenerator, AnimalGraphGenerator, AnimalGroupGenerator, AnimalIntMatrixGenerator, AnimalJHAVETextInteractionGenerator, AnimalListBasedQueueGenerator, AnimalListBasedStackGenerator, AnimalListElementGenerator, AnimalPointGenerator, AnimalPolygonGenerator, AnimalPolylineGenerator, AnimalRectGenerator, AnimalSourceCodeGenerator, AnimalSquareGenerator, AnimalStringMatrixGenerator, AnimalTextGenerator, AnimalTriangleGenerator, AnimalVariablesGenerator, AnimalVHDLElementGenerator, AnimalWireGenerator, AVInteractionTextGenerator

public abstract class AnimalGenerator
extends Generator

This class implements functionality which is shared by all AnimalScript generators. Especially this applies to operations that can be performed on all primitives.

Author:
Stephan Mehlhase

Field Summary
 
Fields inherited from class algoanim.primitives.generators.Generator
lang
 
Constructor Summary
AnimalGenerator(Language aLang)
          Provides the given Language object to the Generator.
 
Method Summary
protected  boolean addBooleanOption(AnimationProperties ap, java.lang.String key, java.lang.String entry, java.lang.StringBuilder builder)
           
protected  boolean addBooleanSwitch(AnimationProperties ap, java.lang.String key, java.lang.String ifTrue, java.lang.String otherwise, java.lang.StringBuilder builder)
           
protected  boolean addColorOption(AnimationProperties ap, java.lang.StringBuilder builder)
           
protected  boolean addColorOption(AnimationProperties ap, java.lang.String key, java.lang.String entry, java.lang.StringBuilder builder)
           
protected  void addFontOption(AnimationProperties ap, java.lang.String key, java.lang.StringBuilder builder)
           
protected  void addFontOption(AnimationProperties ap, java.lang.String key, java.lang.String tag, java.lang.StringBuilder builder)
           
protected  boolean addIntOption(AnimationProperties ap, java.lang.String key, java.lang.String entry, java.lang.StringBuilder builder)
           
protected  void addWithTiming(java.lang.StringBuilder sb, Timing delay, Timing duration)
           
 void changeColor(Primitive elem, java.lang.String colorType, java.awt.Color newColor, Timing delay, Timing d)
          Changes the color of a specified part of a Primitive after a given delay.
 void exchange(Primitive p, Primitive q)
          Exchanges to Primitives after a given delay.
 void hide(Primitive q, Timing t)
          Hides a Primitive after a given delay.
static java.lang.String makeColorDef(java.awt.Color aColor)
          Creates a color definition in AnimalScript for the given values of red, green and blue.
static java.lang.String makeColorDef(int r, int g, int b)
          Creates a color definition in AnimalScript for the given values of red, green and blue.
static java.lang.String makeDisplayOptionsDef(DisplayOptions d)
          Creates the AnimalScript code for a DisplayOptions object.
static java.lang.String makeDisplayOptionsDef(DisplayOptions d, AnimationProperties props)
          Creates the AnimalScript code for a DisplayOptions object.
static java.lang.String makeDurationTimingDef(Timing duration)
          Creates the AnimalScript code for a duration Timing.
static java.lang.String makeHiddenDef(AnimationProperties props)
          Creates the AnimalScript representation for a hidden object
static java.lang.String makeNodeDef(Node n)
          Creates the definition of a Node in AnimalScript.
static java.lang.String makeOffsetTimingDef(Timing delay)
          Creates the AnimalScript represantation of a Timing.
 void moveBy(Primitive p, java.lang.String moveType, int dx, int dy, Timing delay, Timing duration)
          Moves a Primitive to a point
 void moveTo(Primitive p, java.lang.String direction, java.lang.String moveType, Node target, Timing delay, Timing duration)
          Moves a Primitive to a point
 void moveVia(Primitive elem, java.lang.String direction, java.lang.String moveType, Primitive via, Timing delay, Timing d)
          Moves a Primitive along a Path in a given direction after a set delay.
 void rotate(Primitive p, Node center, int degrees, Timing t, Timing d)
          Rotates a Primitive by a given angle around a finite point after a delay.
 void rotate(Primitive p, Primitive around, int degrees, Timing t, Timing d)
          Rotates a Primitive around itself by a given angle after a delay.
 void show(Primitive p, Timing t)
          Unhides a Primitive after a given delay.
 
Methods inherited from class algoanim.primitives.generators.Generator
getLanguage, isNameUsed, isValidDirection
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnimalGenerator

public AnimalGenerator(Language aLang)
Provides the given Language object to the Generator.

Parameters:
aLang - the related Language object
Method Detail

makeNodeDef

public static java.lang.String makeNodeDef(Node n)
Creates the definition of a Node in AnimalScript.

Parameters:
n - the node for which the code shall be created.
Returns:
the code.

makeColorDef

public static java.lang.String makeColorDef(int r,
                                            int g,
                                            int b)
Creates a color definition in AnimalScript for the given values of red, green and blue. All values must be between 0 and 255. If not, the values are calculated by modulo operation to fit.

Parameters:
r - the red part of the color (must between 0 - 255)
g - the green part of the color (must between 0 - 255)
b - the blue part of the color (must between 0 - 255)
Returns:
the String description for the color passed in

makeColorDef

public static java.lang.String makeColorDef(java.awt.Color aColor)
Creates a color definition in AnimalScript for the given values of red, green and blue. All values must be between 0 and 255. If not, the values are calculated by modulo operation to fit.

Parameters:
aColor - the color to be converted to a String
Returns:
the String description for the color passed in

makeOffsetTimingDef

public static java.lang.String makeOffsetTimingDef(Timing delay)
Creates the AnimalScript represantation of a Timing.

Parameters:
delay - the Timing to handle.
Returns:
the string representation of the Timing.

makeHiddenDef

public static java.lang.String makeHiddenDef(AnimationProperties props)
Creates the AnimalScript representation for a hidden object

Parameters:
props - the properties item
Returns:
the string representation of the Timing.

makeDurationTimingDef

public static java.lang.String makeDurationTimingDef(Timing duration)
Creates the AnimalScript code for a duration Timing.

Parameters:
duration - the Timing for which the code shall be created.
Returns:
the string representation of the Timing.

makeDisplayOptionsDef

public static java.lang.String makeDisplayOptionsDef(DisplayOptions d)
Creates the AnimalScript code for a DisplayOptions object.

Parameters:
d - the DisplayOptions for which the code shall be created.
Returns:
the string representation of the DisplayOptions.

makeDisplayOptionsDef

public static java.lang.String makeDisplayOptionsDef(DisplayOptions d,
                                                     AnimationProperties props)
Creates the AnimalScript code for a DisplayOptions object.

Parameters:
d - the DisplayOptions for which the code shall be created.
Returns:
the string representation of the DisplayOptions.

exchange

public void exchange(Primitive p,
                     Primitive q)
Description copied from interface: GeneratorInterface
Exchanges to Primitives after a given delay.

Parameters:
p - the first Primitive.
q - the second Primitive.
See Also:
GeneratorInterface.exchange(algoanim.primitives.Primitive, algoanim.primitives.Primitive)

hide

public void hide(Primitive q,
                 Timing t)
Description copied from interface: GeneratorInterface
Hides a Primitive after a given delay.

Parameters:
q - the Primitive to hide.
t - the delay before the operation is performed.
See Also:
#hide(algoanim.primitives.Primitive, algoanim.util.Timing)

rotate

public void rotate(Primitive p,
                   Primitive around,
                   int degrees,
                   Timing t,
                   Timing d)
Description copied from interface: GeneratorInterface
Rotates a Primitive around itself by a given angle after a delay.

Parameters:
p - the Primitive to rotate.
degrees - the angle by which the Primitive shall be rotated.
t - the delay after which the operation shall be performed.
d - the duration of the operation.
See Also:
#rotate(algoanim.primitives.Primitive, algoanim.primitives.Primitive, int, algoanim.util.Timing, algoanim.util.Timing)

rotate

public void rotate(Primitive p,
                   Node center,
                   int degrees,
                   Timing t,
                   Timing d)
Description copied from interface: GeneratorInterface
Rotates a Primitive by a given angle around a finite point after a delay.

Parameters:
p - the Primitive to rotate.
center - the Point around which the Primitive shall be rotated.
degrees - the angle by which the Primitive shall be rotated.
t - the delay after which the operation shall be performed.
d - the duration of the operation.
See Also:
#rotate(algoanim.primitives.Primitive, algoanim.util.Node, int, algoanim.util.Timing, algoanim.util.Timing)

show

public void show(Primitive p,
                 Timing t)
Description copied from interface: GeneratorInterface
Unhides a Primitive after a given delay.

Parameters:
p - the Primitive to show.
t - the delay before the operation is performed.
See Also:
#show(algoanim.primitives.Primitive, algoanim.util.Timing)

moveVia

public void moveVia(Primitive elem,
                    java.lang.String direction,
                    java.lang.String moveType,
                    Primitive via,
                    Timing delay,
                    Timing d)
             throws IllegalDirectionException
Description copied from interface: GeneratorInterface
Moves a Primitive along a Path in a given direction after a set delay.

Parameters:
elem - the Primitive to move.
direction - the direction to move the Primitive.
moveType - the type of the movement.
via - the Arc, along which the Primitive is moved.
delay - the delay, before the operation is performed.
d - the duration of the operation.
Throws:
IllegalDirectionException
See Also:
#moveVia(algoanim.primitives.Primitive, java.lang.String, java.lang.String, algoanim.primitives.Primitive, algoanim.util.Timing, algoanim.util.Timing)

moveTo

public void moveTo(Primitive p,
                   java.lang.String direction,
                   java.lang.String moveType,
                   Node target,
                   Timing delay,
                   Timing duration)
            throws IllegalDirectionException
Description copied from interface: GeneratorInterface
Moves a Primitive to a point

Parameters:
p - the Primitive to move.
direction - the direction to move the Primitive.
moveType - the type of the movement.
target - the point where the Primitive is moved to.
delay - the delay, before the operation is performed.
duration - the duration of the operation.
Throws:
IllegalDirectionException
See Also:
#moveTo(algoanim.primitives.Primitive, java.lang.String, java.lang.String, algoanim.util.Node, algoanim.util.Timing, algoanim.util.Timing)

moveBy

public void moveBy(Primitive p,
                   java.lang.String moveType,
                   int dx,
                   int dy,
                   Timing delay,
                   Timing duration)
Description copied from interface: GeneratorInterface
Moves a Primitive to a point

Parameters:
p - the Primitive to move.
moveType - the type of the movement.
dx - the x offset to move
dy - the y offset to move
delay - the delay, before the operation is performed.
duration - the duration of the operation.
See Also:
#moveBy(algoanim.primitives.Primitive, java.lang.String, int, int, algoanim.util.Timing, algoanim.util.Timing)

addIntOption

protected boolean addIntOption(AnimationProperties ap,
                               java.lang.String key,
                               java.lang.String entry,
                               java.lang.StringBuilder builder)

addBooleanOption

protected boolean addBooleanOption(AnimationProperties ap,
                                   java.lang.String key,
                                   java.lang.String entry,
                                   java.lang.StringBuilder builder)

addBooleanSwitch

protected boolean addBooleanSwitch(AnimationProperties ap,
                                   java.lang.String key,
                                   java.lang.String ifTrue,
                                   java.lang.String otherwise,
                                   java.lang.StringBuilder builder)

addWithTiming

protected void addWithTiming(java.lang.StringBuilder sb,
                             Timing delay,
                             Timing duration)

addColorOption

protected boolean addColorOption(AnimationProperties ap,
                                 java.lang.StringBuilder builder)

addColorOption

protected boolean addColorOption(AnimationProperties ap,
                                 java.lang.String key,
                                 java.lang.String entry,
                                 java.lang.StringBuilder builder)

addFontOption

protected void addFontOption(AnimationProperties ap,
                             java.lang.String key,
                             java.lang.StringBuilder builder)

addFontOption

protected void addFontOption(AnimationProperties ap,
                             java.lang.String key,
                             java.lang.String tag,
                             java.lang.StringBuilder builder)

changeColor

public void changeColor(Primitive elem,
                        java.lang.String colorType,
                        java.awt.Color newColor,
                        Timing delay,
                        Timing d)
Description copied from interface: GeneratorInterface
Changes the color of a specified part of a Primitive after a given delay.

Parameters:
elem - the Primitive to which the action shall be applied.
colorType - the part of the Primitive to change.
newColor - the new color.
delay - the delay, before the operation is performed.
d - the duration of the operation.
See Also:
#changeColor(algoanim.primitives.Primitive, java.lang.String, java.awt.Color, algoanim.util.Timing, algoanim.util.Timing)