sdr 0.21

net.cscott.sdr.calls
Class Formation

java.lang.Object
  extended by net.cscott.sdr.calls.Formation
Direct Known Subclasses:
TaggedFormation

public class Formation
extends Object

A Formation is a set of dancers and positions for them. Certain dancers in the formation can be selected. In addition, all dancers can be tagged with modifiers such as 'BEAU', 'BELLE', 'LEADER', 'TRAILER', etc.


Field Summary
static Formation FOUR_SQUARE
           
protected  Map<Dancer,Position> location
           
protected  Set<Dancer> selected
           
static Formation SQUARED_SET
           
 
Constructor Summary
  Formation(Formation f, Map<Dancer,Dancer> map)
           
  Formation(Map<Dancer,Position> location)
           
protected Formation(Map<Dancer,Position> location, Set<Dancer> selected)
           
 
Method Summary
 Box bounds()
          Return the bounds of this formation, which is the bounding box around all the dancers' bounding boxes.
 Box bounds(Dancer d)
          Return the bounds of the given dancer -- always its position plus or minus 1 unit on the x and y axes.
 Set<Dancer> dancers()
           
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isCentered()
           
 boolean isSelected(Dancer d)
           
 Position location(Dancer d)
           
 Formation onlySelected()
          Create a new formation containing only the selected dancers from this formation.
 Formation recenter()
          Build a new formation, centered on 0,0
 Formation rotate(ExactRotation rotation)
          Build a new formation, like this one except rotated around 0,0.
 Formation select(Set<Dancer> s)
          Build a new formation with only the given dancers selected.
 Set<Dancer> selectedDancers()
           
 String toString()
           
 String toStringDiagram()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

location

protected final Map<Dancer,Position> location

selected

protected final Set<Dancer> selected

SQUARED_SET

public static final Formation SQUARED_SET

FOUR_SQUARE

public static final Formation FOUR_SQUARE
Constructor Detail

Formation

protected Formation(Map<Dancer,Position> location,
                    Set<Dancer> selected)

Formation

public Formation(Map<Dancer,Position> location)

Formation

public Formation(Formation f,
                 Map<Dancer,Dancer> map)
Method Detail

onlySelected

public Formation onlySelected()
Create a new formation containing only the selected dancers from this formation.


isSelected

public boolean isSelected(Dancer d)

selectedDancers

public Set<Dancer> selectedDancers()

dancers

public Set<Dancer> dancers()

location

public Position location(Dancer d)

bounds

public Box bounds()
Return the bounds of this formation, which is the bounding box around all the dancers' bounding boxes. This means that the 1 unit border from bounds(Dancer) applies here as well. If there are no dancers, returns a zero-width, zero-height box centered at the origin.


bounds

public Box bounds(Dancer d)
Return the bounds of the given dancer -- always its position plus or minus 1 unit on the x and y axes.


select

public Formation select(Set<Dancer> s)
Build a new formation with only the given dancers selected.


recenter

public Formation recenter()
Build a new formation, centered on 0,0


rotate

public Formation rotate(ExactRotation rotation)
Build a new formation, like this one except rotated around 0,0. We rotate CW by the amount given in the rotation parameter; "north" corresponds to no rotation.


isCentered

public boolean isCentered()

equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Overrides:
toString in class Object

toStringDiagram

public String toStringDiagram()

sdr 0.21

Copyright (c) 2006 C. Scott Ananian