VASSAL.build.module.map
Class CompoundPieceCollection

java.lang.Object
  |
  +--VASSAL.build.module.map.CompoundPieceCollection
All Implemented Interfaces:
PieceCollection
Direct Known Subclasses:
DefaultPieceCollection, LayeredPieceCollection.Collection

public abstract class CompoundPieceCollection
extends java.lang.Object
implements PieceCollection

Base class for PieceCollection implementation that organize pieces into distinct layers. The layers are drawn in order of their index, i.e. layer 0 is on the bottom.


Field Summary
protected  SimplePieceCollection[] layers
           
 
Constructor Summary
protected CompoundPieceCollection(int layerCount)
           
 
Method Summary
 void add(GamePiece p)
          Adds a piece
 boolean canMerge(GamePiece p1, GamePiece p2)
          Return true if the two pieces can be merged into a single stack
protected  boolean canPiecesMerge(GamePiece p1, GamePiece p2)
           
protected  boolean canStackAndPieceMerge(Stack s, GamePiece p)
           
protected  boolean canStacksMerge(Stack s1, Stack s2)
           
 void clear()
          Remove all pieces
protected  PieceCollection getCollectionForPiece(GamePiece p)
           
protected abstract  int getLayerForPiece(GamePiece p)
           
 GamePiece[] getPieces()
          Return all pieces in the collection as a read-only array
 int indexOf(GamePiece p)
          Returns the index of a piece.
protected  void initLayers(int layerCount)
           
 void moveToBack(GamePiece p)
          Reposition a piece to the back of all others in the same layer
 void moveToFront(GamePiece p)
          Reposition a piece to the front of all others in the same layer
 void remove(GamePiece p)
          Removes the piece
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

layers

protected SimplePieceCollection[] layers
Constructor Detail

CompoundPieceCollection

protected CompoundPieceCollection(int layerCount)
Method Detail

initLayers

protected void initLayers(int layerCount)

getLayerForPiece

protected abstract int getLayerForPiece(GamePiece p)

getCollectionForPiece

protected PieceCollection getCollectionForPiece(GamePiece p)

add

public void add(GamePiece p)
Description copied from interface: PieceCollection
Adds a piece
Specified by:
add in interface PieceCollection

clear

public void clear()
Description copied from interface: PieceCollection
Remove all pieces
Specified by:
clear in interface PieceCollection

getPieces

public GamePiece[] getPieces()
Description copied from interface: PieceCollection
Return all pieces in the collection as a read-only array
Specified by:
getPieces in interface PieceCollection

indexOf

public int indexOf(GamePiece p)
Description copied from interface: PieceCollection
Returns the index of a piece. When painting the map, pieces are drawn in order of index
Specified by:
indexOf in interface PieceCollection

remove

public void remove(GamePiece p)
Description copied from interface: PieceCollection
Removes the piece
Specified by:
remove in interface PieceCollection

moveToBack

public void moveToBack(GamePiece p)
Description copied from interface: PieceCollection
Reposition a piece to the back of all others in the same layer
Specified by:
moveToBack in interface PieceCollection

moveToFront

public void moveToFront(GamePiece p)
Description copied from interface: PieceCollection
Reposition a piece to the front of all others in the same layer
Specified by:
moveToFront in interface PieceCollection

canMerge

public boolean canMerge(GamePiece p1,
                        GamePiece p2)
Description copied from interface: PieceCollection
Return true if the two pieces can be merged into a single stack
Specified by:
canMerge in interface PieceCollection

canStacksMerge

protected boolean canStacksMerge(Stack s1,
                                 Stack s2)

canStackAndPieceMerge

protected boolean canStackAndPieceMerge(Stack s,
                                        GamePiece p)

canPiecesMerge

protected boolean canPiecesMerge(GamePiece p1,
                                 GamePiece p2)