VASSAL.build.module.map
Class StackMetrics

java.lang.Object
  |
  +--VASSAL.build.AbstractBuildable
        |
        +--VASSAL.build.AbstractConfigurable
              |
              +--VASSAL.build.module.map.StackMetrics
All Implemented Interfaces:
AutoConfigurable, Buildable, Configurable
Direct Known Subclasses:
HandMetrics

public class StackMetrics
extends AbstractConfigurable

Encapsulates information on how to draw expanded and unexpanded views of a stack


Inner classes inherited from class VASSAL.build.AutoConfigurable
AutoConfigurable.Util
 
Field Summary
protected  java.awt.Color blankColor
           
static java.lang.String BOTTOM_KEY
           
protected  javax.swing.KeyStroke bottomKey
           
static java.lang.String COLOR
           
protected  boolean disabled
           
static java.lang.String DISABLED
           
static java.lang.String DOWN_KEY
           
protected  javax.swing.KeyStroke downKey
           
static java.lang.String EXSEP_X
           
static java.lang.String EXSEP_Y
           
protected  int exSepX
           
protected  int exSepY
           
protected  PieceFilter selectedVisible
           
static java.lang.String TOP_KEY
           
protected  javax.swing.KeyStroke topKey
           
static java.lang.String UNEXSEP_X
           
static java.lang.String UNEXSEP_Y
           
protected  int unexSepX
           
protected  int unexSepY
           
protected  PieceFilter unselectedVisible
           
static java.lang.String UP_KEY
           
protected  javax.swing.KeyStroke upKey
           
 
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, name
 
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents
 
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
 
Constructor Summary
StackMetrics()
           
StackMetrics(boolean dis, int exSx, int exSy, int unexSx, int unexSy)
           
 
Method Summary
 void addTo(Buildable b)
          Adds this component to its parent.
 Stack createStack(GamePiece p)
           
 void draw(Stack stack, java.awt.Graphics g, int x, int y, java.awt.Component obs, double zoom)
          Different instances of StackMetrics may render a Stack in different ways.
 void draw(Stack stack, java.awt.Point location, java.awt.Graphics g, Map map, double zoom, java.awt.Rectangle visibleRect)
          Draw only those pieces in the target stack whose boundingBoxes fall within the given visibleRect This method is considerably faster than the other draw method.
protected  void drawUnexpanded(GamePiece p, java.awt.Graphics g, int x, int y, java.awt.Component obs, double zoom)
          Draw a GamePiece that is not the top piece in an unexpanded Stack Default implementation is a white square with a black border
 java.lang.Class[] getAllowableConfigureComponents()
          Return a list of valid sub-component Classes.
 java.lang.String[] getAttributeDescriptions()
          Return an array of Strings describing the attributes of this object.
 java.lang.String[] getAttributeNames()
           
 java.lang.Class[] getAttributeTypes()
          Return the Class for the attributes of this object.
 java.lang.String getAttributeValueString(java.lang.String name)
          Called by the AbstractBuildable.getBuildElement(org.w3c.dom.Document) method to write the attributes into an XML element
 VisibilityCondition getAttributeVisibility(java.lang.String name)
          By default, all attributes are visible
 java.lang.String getConfigureName()
          The name of this Configurable Object
static java.lang.String getConfigureTypeName()
           
 int getContents(Stack parent, java.awt.Point[] positions, java.awt.Shape[] shapes, java.awt.Rectangle[] boundingBoxes, int x, int y)
          Fill the argument arrays with the positions, selection bounds and bounding boxes of the pieces in the argument stack
 HelpFile getHelpFile()
           
 javax.swing.KeyStroke getMoveBottomKey()
           
 javax.swing.KeyStroke getMoveDownKey()
           
 javax.swing.KeyStroke getMoveTopKey()
           
 javax.swing.KeyStroke getMoveUpKey()
           
 boolean isStackingEnabled()
           
 Command merge(GamePiece fixed, GamePiece add)
          Place a GamePiece on top of another GamePiece Create/remove stacks as necessary
protected  void nextPosition(java.awt.Point currentPos, java.awt.Rectangle currentBounds, java.awt.Point nextPos, java.awt.Rectangle nextBounds, int dx, int dy)
           
 java.awt.Point relativePosition(Stack parent, GamePiece c)
           
 void removeFrom(Buildable parent)
          Remove this component from its parent
 void setAttribute(java.lang.String name, java.lang.Object value)
          Called by the AbstractBuildable.build(org.w3c.dom.Element) method, where value is the String value read by the XML attribute.
 
Methods inherited from class VASSAL.build.AbstractConfigurable
addPropertyChangeListener, getConfigureComponents, getConfigurer, remove, setConfigureName
 
Methods inherited from class VASSAL.build.AbstractBuildable
add, build, getBuildComponents, getBuildElement, getComponents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface VASSAL.build.Buildable
add, build, getBuildElement
 

Field Detail

exSepX

protected int exSepX

exSepY

protected int exSepY

unexSepX

protected int unexSepX

unexSepY

protected int unexSepY

disabled

protected boolean disabled

topKey

protected javax.swing.KeyStroke topKey

bottomKey

protected javax.swing.KeyStroke bottomKey

upKey

protected javax.swing.KeyStroke upKey

downKey

protected javax.swing.KeyStroke downKey

unselectedVisible

protected PieceFilter unselectedVisible

selectedVisible

protected PieceFilter selectedVisible

blankColor

protected java.awt.Color blankColor

EXSEP_X

public static final java.lang.String EXSEP_X

EXSEP_Y

public static final java.lang.String EXSEP_Y

UNEXSEP_X

public static final java.lang.String UNEXSEP_X

UNEXSEP_Y

public static final java.lang.String UNEXSEP_Y

DISABLED

public static final java.lang.String DISABLED

TOP_KEY

public static final java.lang.String TOP_KEY

BOTTOM_KEY

public static final java.lang.String BOTTOM_KEY

UP_KEY

public static final java.lang.String UP_KEY

DOWN_KEY

public static final java.lang.String DOWN_KEY

COLOR

public static final java.lang.String COLOR
Constructor Detail

StackMetrics

public StackMetrics()

StackMetrics

public StackMetrics(boolean dis,
                    int exSx,
                    int exSy,
                    int unexSx,
                    int unexSy)
Method Detail

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Description copied from interface: AutoConfigurable
Called by the Buildable.build(org.w3c.dom.Element) method, where value is the String value read by the XML attribute. Can also be called with Object value to set the attribute.
Overrides:
setAttribute in class AbstractBuildable
Following copied from class: VASSAL.build.AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

getAttributeValueString

public java.lang.String getAttributeValueString(java.lang.String name)
Description copied from interface: AutoConfigurable
Called by the Buildable.getBuildElement(org.w3c.dom.Document) method to write the attributes into an XML element
Overrides:
getAttributeValueString in class AbstractBuildable
Following copied from class: VASSAL.build.AbstractBuildable
Parameters:
key - the name of the attribute. Will be one of those listed in AbstractBuildable.getAttributeNames()

addTo

public void addTo(Buildable b)
Description copied from interface: Buildable
Adds this component to its parent. In order to make Buildable objects extensible, the child is reponsible for adding itself to the parent. That way, Buildable subcomponents can be defined in an extension package without needing to modify the containing class.

draw

public void draw(Stack stack,
                 java.awt.Graphics g,
                 int x,
                 int y,
                 java.awt.Component obs,
                 double zoom)
Different instances of StackMetrics may render a Stack in different ways. The default algorithm is: If not expanded, all but the top visible GamePiece is drawn as a white square with size given by GamePiece.getShape(). The separation between GamePieces is given by relativePosition(VASSAL.counters.Stack, VASSAL.counters.GamePiece) If expanded, all GamePieces are drawn with separation given by relativePosition(VASSAL.counters.Stack, VASSAL.counters.GamePiece). GamePiece that are selected are drawn in front of other GamePieces, even those above them in the stack

draw

public void draw(Stack stack,
                 java.awt.Point location,
                 java.awt.Graphics g,
                 Map map,
                 double zoom,
                 java.awt.Rectangle visibleRect)
Draw only those pieces in the target stack whose boundingBoxes fall within the given visibleRect This method is considerably faster than the other draw method.
Parameters:
stack -  
g -  
location - the location of the stack in component coordinates
zoom -  
visibleRect - the visible rectangle in component coordinates

drawUnexpanded

protected void drawUnexpanded(GamePiece p,
                              java.awt.Graphics g,
                              int x,
                              int y,
                              java.awt.Component obs,
                              double zoom)
Draw a GamePiece that is not the top piece in an unexpanded Stack Default implementation is a white square with a black border

getContents

public int getContents(Stack parent,
                       java.awt.Point[] positions,
                       java.awt.Shape[] shapes,
                       java.awt.Rectangle[] boundingBoxes,
                       int x,
                       int y)
Fill the argument arrays with the positions, selection bounds and bounding boxes of the pieces in the argument stack
Parameters:
parent - The parent Stack
positions - If non-null will contain a Point giving the position of each piece in parent
shapes - If non-null will contain a Shape giving the shape of for each piece in parent
boundingBoxes - If non-null will contain a Rectangle giving the bounding box for each piece in parent
x - the x-location of the parent
y - the y-location of the parent
Returns:
the number of pieces processed in the stack

nextPosition

protected void nextPosition(java.awt.Point currentPos,
                            java.awt.Rectangle currentBounds,
                            java.awt.Point nextPos,
                            java.awt.Rectangle nextBounds,
                            int dx,
                            int dy)

relativePosition

public java.awt.Point relativePosition(Stack parent,
                                       GamePiece c)

isStackingEnabled

public boolean isStackingEnabled()

removeFrom

public void removeFrom(Buildable parent)
Description copied from interface: Configurable
Remove this component from its parent

getConfigureName

public java.lang.String getConfigureName()
Description copied from interface: Configurable
The name of this Configurable Object
Overrides:
getConfigureName in class AbstractConfigurable

getConfigureTypeName

public static java.lang.String getConfigureTypeName()

getHelpFile

public HelpFile getHelpFile()
Following copied from interface: VASSAL.build.Configurable
Returns:
a HelpFilte describing how to use and configure this component

getAllowableConfigureComponents

public java.lang.Class[] getAllowableConfigureComponents()
Description copied from interface: Configurable
Return a list of valid sub-component Classes. If a Class appears in this list, then instances of that class may be added to this component from the Configuration Window.

getAttributeNames

public java.lang.String[] getAttributeNames()
Overrides:
getAttributeNames in class AbstractBuildable
Following copied from interface: VASSAL.build.AutoConfigurable
Returns:
an array of Strings giving all attributes of this Buildable component that will be written to/read from an XML element

getAttributeDescriptions

public java.lang.String[] getAttributeDescriptions()
Description copied from class: AbstractConfigurable
Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object. The order of descriptions should be the same as the order of names in AbstractBuildable.getAttributeNames()
Overrides:
getAttributeDescriptions in class AbstractConfigurable

getAttributeTypes

public java.lang.Class[] getAttributeTypes()
Description copied from class: AbstractConfigurable
Return the Class for the attributes of this object. Valid classes are: String, Integer, Double, Boolean, Image, Color, and KeyStroke The order of classes should be the same as the order of names in AbstractBuildable.getAttributeNames()
Overrides:
getAttributeTypes in class AbstractConfigurable

getAttributeVisibility

public VisibilityCondition getAttributeVisibility(java.lang.String name)
Description copied from class: AbstractConfigurable
By default, all attributes are visible
Overrides:
getAttributeVisibility in class AbstractConfigurable
Following copied from class: VASSAL.build.AbstractConfigurable
Parameters:
name -  
Returns:
 

createStack

public Stack createStack(GamePiece p)

getMoveUpKey

public javax.swing.KeyStroke getMoveUpKey()

getMoveDownKey

public javax.swing.KeyStroke getMoveDownKey()

getMoveTopKey

public javax.swing.KeyStroke getMoveTopKey()

getMoveBottomKey

public javax.swing.KeyStroke getMoveBottomKey()

merge

public Command merge(GamePiece fixed,
                     GamePiece add)
Place a GamePiece on top of another GamePiece Create/remove stacks as necessary
Returns:
a Command that accomplishes this task