sdr 0.7

net.cscott.sdr.calls.ast
Class Prim

java.lang.Object
  extended by net.cscott.sdr.calls.ast.AstNode
      extended by net.cscott.sdr.calls.ast.SeqCall
          extended by net.cscott.sdr.calls.ast.Prim

public class Prim
extends SeqCall

A Prim represents a primitive action: a certain distance traveled forward and to the side, while rotating a certain amount, performed in a certain number of beats. Prim is a leaf node in a our AST.

Version:
$Id: Prim.java,v 1.12 2007-03-07 19:56:21 cananian Exp $
Author:
C. Scott Ananian

Nested Class Summary
static class Prim.Direction
          The Prim.Direction enumeration tells whether the movement is relative to the center of the formation.
static class Prim.Flag
          The Prim.Flag enumeration represents various properties of the movement described by this Prim.
 
Field Summary
 Prim.Direction dirRot
          Is the movement direction relative to the center of the formation?
 Prim.Direction dirX
          Is the movement direction relative to the center of the formation?
 Prim.Direction dirY
          Is the movement direction relative to the center of the formation?
 Set<Prim.Flag> flags
          Flags refining this motion.
 ExactRotation rot
          Amount of rotation.
static Prim STAND_STILL
           
 Fraction time
          The number of beats which this motion should take.
 Fraction x
          Amount of movement in the 'sashay' direction (dancer's right/left).
 Fraction y
          Amount of movement in the 'walking' direction (dancer forward and back).
 
Fields inherited from class net.cscott.sdr.calls.ast.AstNode
type
 
Constructor Summary
Prim(Prim.Direction dirX, Fraction x, Prim.Direction dirY, Fraction y, Prim.Direction dirRot, ExactRotation rot, Fraction time, Prim.Flag... flags)
           
 
Method Summary
<T> SeqCall
accept(TransformVisitor<T> v, T t)
          Visitor pattern implementation for transformations.
<RESULT,CLOSURE>
RESULT
accept(ValueVisitor<RESULT,CLOSURE> v, CLOSURE cl)
          Visitor pattern implementation for computations.
 String argsToString()
           
 Prim build(Prim.Direction dirX, Fraction x, Prim.Direction dirY, Fraction y, Prim.Direction dirRot, ExactRotation rot, Fraction time, Prim.Flag... flags)
          Factory: creates new Prim only if it would differ from this.
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isIndeterminate()
          True if the result of SeqCall.parts() can not be used for fractionalization.
 Expr parts()
          How many 'parts' are represented by this SeqCall.
 Prim scaleTime(Fraction f)
          Create a new Prim, identical to this one except that the time is scaled by the given fraction.
static Prim valueOf(String s)
           
 
Methods inherited from class net.cscott.sdr.calls.ast.AstNode
toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

x

public final Fraction x
Amount of movement in the 'sashay' direction (dancer's right/left).


y

public final Fraction y
Amount of movement in the 'walking' direction (dancer forward and back).


rot

public final ExactRotation rot
Amount of rotation.


dirX

public final Prim.Direction dirX
Is the movement direction relative to the center of the formation?


dirY

public final Prim.Direction dirY
Is the movement direction relative to the center of the formation?


dirRot

public final Prim.Direction dirRot
Is the movement direction relative to the center of the formation?


time

public final Fraction time
The number of beats which this motion should take.


flags

public final Set<Prim.Flag> flags
Flags refining this motion.


STAND_STILL

public static final Prim STAND_STILL
Constructor Detail

Prim

public Prim(Prim.Direction dirX,
            Fraction x,
            Prim.Direction dirY,
            Fraction y,
            Prim.Direction dirRot,
            ExactRotation rot,
            Fraction time,
            Prim.Flag... flags)
Method Detail

parts

public Expr parts()
Description copied from class: SeqCall
How many 'parts' are represented by this SeqCall. Should be Expr.literal(Fraction.ONE) for all but Part.

Specified by:
parts in class SeqCall

isIndeterminate

public boolean isIndeterminate()
Description copied from class: SeqCall
True if the result of SeqCall.parts() can not be used for fractionalization.

Specified by:
isIndeterminate in class SeqCall

accept

public <T> SeqCall accept(TransformVisitor<T> v,
                          T t)
Description copied from class: AstNode
Visitor pattern implementation for transformations. Each AstNode accepts a TransformVisitor and a value, and returns an instance of its own type (ie, Seq.accept(tv, "A") returns a Seq). The 't' parameter is a closure.

Specified by:
accept in class SeqCall

accept

public <RESULT,CLOSURE> RESULT accept(ValueVisitor<RESULT,CLOSURE> v,
                                      CLOSURE cl)
Description copied from class: AstNode
Visitor pattern implementation for computations. Each AstNode accepts a ValueVisitor and a closure, and returns an object of the appropriate result type.

Specified by:
accept in class AstNode

argsToString

public String argsToString()
Overrides:
argsToString in class AstNode

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

scaleTime

public Prim scaleTime(Fraction f)
Create a new Prim, identical to this one except that the time is scaled by the given fraction.


build

public Prim build(Prim.Direction dirX,
                  Fraction x,
                  Prim.Direction dirY,
                  Fraction y,
                  Prim.Direction dirRot,
                  ExactRotation rot,
                  Fraction time,
                  Prim.Flag... flags)
Factory: creates new Prim only if it would differ from this.


valueOf

public static Prim valueOf(String s)
                    throws IllegalArgumentException
Throws:
IllegalArgumentException

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian