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 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 Details

    • layers

      protected SimplePieceCollection[] layers
    • bottomLayer

      protected int bottomLayer
    • enabled

      protected boolean[] enabled
  • Constructor Details

    • CompoundPieceCollection

      protected CompoundPieceCollection​(int layerCount)
  • Method Details

    • initLayers

      protected void initLayers​(int layerCount)
    • getLayerForPiece

      public int getLayerForPiece​(GamePiece p)
    • getLayerNameForPiece

      public String getLayerNameForPiece​(GamePiece p)
    • getLayerForName

      public int getLayerForName​(String layerName)
    • 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 currently-visible pieces in the collection as a read-only array
      Specified by:
      getPieces in interface PieceCollection
    • getPieces

      protected GamePiece[] getPieces​(boolean includeDisabled)
    • getAllPieces

      public GamePiece[] getAllPieces()
      Description copied from interface: PieceCollection
      Return all pieces in the collection, regardless of visibility
      Specified by:
      getAllPieces 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)
    • getLayerCount

      public int getLayerCount()
    • setBottomLayer

      public void setBottomLayer​(int layer)
    • getBottomLayer

      public int getBottomLayer()
    • getTopLayer

      public int getTopLayer()
    • rotate

      public void rotate​(boolean rotateUp, boolean skipNullLayers)
    • rotate

      public void rotate​(boolean rotateUp)
    • setLayerEnabled

      public void setLayerEnabled​(int layer, boolean b)
    • toggleLayerEnabled

      public void toggleLayerEnabled​(int layer)
    • setLayerEnabled

      public void setLayerEnabled​(String layer, boolean b)
    • toggleLayerEnabled

      public void toggleLayerEnabled​(String layer)
    • reset

      public void reset()