sdr 0.7

net.cscott.sdr.calls
Class TaggedFormation

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

public class TaggedFormation
extends Formation

A TaggedFormation 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.

Tests:
Fetch tagged dancers from a TaggedFormation:
js> FormationList = FormationList.js(this); undefined;
js> f = FormationList.STATIC_SQUARE ; f.getClass()
class net.cscott.sdr.calls.NamedTaggedFormation
js> [ f.location(d) for each (d in Iterator(f.tagged(TaggedFormation.Tag.BEAU)))]
1,3,s,-3,1,e,3,-1,w,-1,-3,n

Nested Class Summary
static class TaggedFormation.Tag
          Dancer descriptions based on position in the Formation.
 
Field Summary
 
Fields inherited from class net.cscott.sdr.calls.Formation
dancerNames, FOUR_SQUARE, location, selected, SQUARED_SET
 
Constructor Summary
  TaggedFormation(Formation f, MultiMap<Dancer,TaggedFormation.Tag> tags)
           
protected TaggedFormation(Map<Dancer,Position> location, Set<Dancer> selected, MultiMap<Dancer,TaggedFormation.Tag> tags)
           
protected TaggedFormation(TaggedFormation tf, Map<Dancer,Dancer> map)
           
 
Method Summary
 TaggedFormation addTags(MultiMap<Dancer,TaggedFormation.Tag> newTags)
          Add additional tags to the given formation.
static TaggedFormation coerce(Formation f)
           
 boolean equals(Object o)
           
 int hashCode()
           
 boolean isTagged(Dancer d, Set<TaggedFormation.Tag> tags)
          Return true if the dancer is tagged by any tag in the given set of tags
 boolean isTagged(Dancer d, TaggedFormation.Tag tag)
          Returns true if the dancer is tagged by the given tag.
 TaggedFormation map(Dancer... dancers)
          Replace the dancers in this formation with the given dancers, specified in the "sorted dancers" order (left-to-right, top-to-bottom).
 TaggedFormation map(Map<Dancer,Dancer> map)
           
 TaggedFormation mapStd(StandardDancer... dancers)
          Special case of Formation.map(Dancer...) which allows you to specify half the dancers, and fills in the rest with their opposites to result in a symmetric formation.
 TaggedFormation move(Dancer d, Position p)
          Return a formation like this one, except that the given dancer is moved to the specified position.
 TaggedFormation select(Collection<Dancer> d)
          Build a new formation with only the given dancers selected.
 Set<Dancer> tagged(Set<TaggedFormation.Tag> tags)
          Return the set of dancers tagged by any of the given set of tags.
 Set<Dancer> tagged(TaggedFormation.Tag tag)
          Return the set of dancers tagged with the given tag.
 Set<TaggedFormation.Tag> tags(Dancer d)
          Return the non-primitive tags attached to this dancer.
 String toString()
           
 
Methods inherited from class net.cscott.sdr.calls.Formation
bounds, bounds, dancerComparator, dancers, isCentered, isSelected, location, mirror, onlySelected, recenter, rotate, select, selectedDancers, sortedDancers, toStringDiagram, toStringDiagram, toStringDiagram, toStringDiagramWithDetails, toStringDiagramWithDetails, toStringDiagramWithDetails
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TaggedFormation

protected TaggedFormation(Map<Dancer,Position> location,
                          Set<Dancer> selected,
                          MultiMap<Dancer,TaggedFormation.Tag> tags)

TaggedFormation

protected TaggedFormation(TaggedFormation tf,
                          Map<Dancer,Dancer> map)

TaggedFormation

public TaggedFormation(Formation f,
                       MultiMap<Dancer,TaggedFormation.Tag> tags)
Method Detail

isTagged

public boolean isTagged(Dancer d,
                        TaggedFormation.Tag tag)
Returns true if the dancer is tagged by the given tag. The tag can be either a primitive dancer tag, or a formation-dependent tag.


isTagged

public boolean isTagged(Dancer d,
                        Set<TaggedFormation.Tag> tags)
Return true if the dancer is tagged by any tag in the given set of tags


tagged

public Set<Dancer> tagged(TaggedFormation.Tag tag)
Return the set of dancers tagged with the given tag. The tag can be either a primitive dancer tag or a formation-dependent tag.


tagged

public Set<Dancer> tagged(Set<TaggedFormation.Tag> tags)
Return the set of dancers tagged by any of the given set of tags.


tags

public Set<TaggedFormation.Tag> tags(Dancer d)
Return the non-primitive tags attached to this dancer. WARNING: because this does not include primitive tags, you should use this method only to transfer tag information between TaggedFormations, not to test whether a given dancer has a particular tag. Use isTagged(Dancer, net.cscott.sdr.calls.TaggedFormation.Tag) if you want to check whether a dancer has a particular tag.


select

public TaggedFormation select(Collection<Dancer> d)
Description copied from class: Formation
Build a new formation with only the given dancers selected.

Overrides:
select in class Formation

move

public TaggedFormation move(Dancer d,
                            Position p)
Description copied from class: Formation
Return a formation like this one, except that the given dancer is moved to the specified position. js> f = Formation.SQUARED_SET; f.toStringDiagram("|") | 3Gv 3Bv | |4B> 2G< | |4G> 2B< | | 1B^ 1G^ js> f.move(StandardDancer.COUPLE_1_BOY, Position.getGrid(-1,0,"e")).toStringDiagram("|") | 3Gv 3Bv | |4B> 2G< | 1B> |4G> 2B< | | 1G^

Overrides:
move in class Formation

addTags

public TaggedFormation addTags(MultiMap<Dancer,TaggedFormation.Tag> newTags)
Add additional tags to the given formation.


equals

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

hashCode

public int hashCode()
Overrides:
hashCode in class Formation

toString

public String toString()
Overrides:
toString in class Formation

map

public TaggedFormation map(Map<Dancer,Dancer> map)
Overrides:
map in class Formation

map

public TaggedFormation map(Dancer... dancers)
Replace the dancers in this formation with the given dancers, specified in the "sorted dancers" order (left-to-right, top-to-bottom).

Overrides:
map in class Formation
Tests:
Demonstrate usage of call in scripts:
js> FormationList = FormationList.js(this); undefined;
js> const SD = StandardDancer; const l = net.cscott.sdr.util.Tools.l;
js> f = FormationList.TRADE_BY; f.toStringDiagram();
^    ^

v    v

^    ^

v    v
js> // infinitest doesn't like overloaded methods in Rhino...
js> f.map(l(SD.COUPLE_1_BOY, SD.COUPLE_1_GIRL,
  >         SD.COUPLE_2_GIRL, SD.COUPLE_2_BOY,
  >         SD.COUPLE_4_BOY, SD.COUPLE_4_GIRL,
  >         SD.COUPLE_3_GIRL, SD.COUPLE_3_BOY)
  >         .toArray(java.lang.reflect.Array.newInstance(Dancer,0))
  >      ).toStringDiagram();
1B^  1G^

2Gv  2Bv

4B^  4G^

3Gv  3Bv

mapStd

public TaggedFormation mapStd(StandardDancer... dancers)
Special case of Formation.map(Dancer...) which allows you to specify half the dancers, and fills in the rest with their opposites to result in a symmetric formation.

Overrides:
mapStd in class Formation
Tests:
Demonstrate usage of call in scripts:
js> FormationList = FormationList.js(this); undefined;
js> const SD = StandardDancer;
js> f = FormationList.TRADE_BY; undefined;
js> f.mapStd([SD.COUPLE_1_BOY, SD.COUPLE_1_GIRL,
  >           SD.COUPLE_2_GIRL, SD.COUPLE_2_BOY]).toStringDiagram();
1B^  1G^

2Gv  2Bv

4B^  4G^

3Gv  3Bv

coerce

public static TaggedFormation coerce(Formation f)

sdr 0.7

Copyright © 2006-2009 C. Scott Ananian