VASSAL.counters
Class UsePrototype
java.lang.Object
|
+--VASSAL.counters.Decorator
|
+--VASSAL.counters.UsePrototype
- All Implemented Interfaces:
- EditablePiece, GamePiece
- public class UsePrototype
- extends Decorator
- implements EditablePiece
This trait is a placeholder for a pre-defined series of traits specified
in a PrototypeDefinition object. When a piece
that uses a prototype is defined in a module, it is simply assigned the name
of a particular prototype definition. When that piece is during a game,
the UsePrototype trait is substituted for the list of traits in the prototype
definition. From that point on, the piece has no record that those traits
were defined in a prototype instead of assigned to piece directly. This is
necessary so that subsequent changes to a prototype definition don't invalidate
games that were saved using previous versions of the module.
|
Field Summary |
static java.lang.String |
ID
|
| Methods inherited from class VASSAL.counters.Decorator |
getDecorator, getId, getInner, getInnermost, getMap, getOutermost, getParent, getPosition, getProperty, getState, getType, mergeState, setId, setInner, setMap, setParent, setPosition, setProperty, setState |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface VASSAL.counters.GamePiece |
getId, getMap, getParent, getPosition, getProperty, getState, getType, setId, setMap, setParent, setPosition, setProperty, setState |
ID
public static final java.lang.String ID
UsePrototype
public UsePrototype()
UsePrototype
public UsePrototype(java.lang.String type,
GamePiece inner)
getDescription
public java.lang.String getDescription()
- Description copied from interface:
EditablePiece
- A plain-English description of this type of piece
- Specified by:
getDescription in interface EditablePiece
getHelpFile
public HelpFile getHelpFile()
- Specified by:
getHelpFile in interface EditablePiece
mySetType
public void mySetType(java.lang.String type)
- Description copied from interface:
EditablePiece
- Set the type information for this piece. See
Decorator.myGetType()
- Specified by:
mySetType in interface EditablePiece
myGetKeyCommands
protected KeyCommand[] myGetKeyCommands()
- Overrides:
myGetKeyCommands in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
getKeyCommands
protected KeyCommand[] getKeyCommands()
- Description copied from class:
Decorator
- The set of key commands that will populate the piece's right-click menu.
The key commands are accessible through the
Properties.KEY_COMMANDS property.
The commands for a Decorator are a composite of Decorator.myGetKeyCommands() and the
commands of its inner piece.
- Overrides:
getKeyCommands in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- Returns:
- the commands for this piece and its inner piece
buildPrototype
protected void buildPrototype()
getExpandedInner
public GamePiece getExpandedInner()
- Build a new GamePiece instance based on the traits in the referenced
PrototypeDefinition.
Substitute the new instance for Decorator.getInner() and return it.
If the referenced definition does not exist, return the default inner piece.
- Returns:
- the new instance
myGetState
public java.lang.String myGetState()
- Overrides:
myGetState in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
myGetType
public java.lang.String myGetType()
- Overrides:
myGetType in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
keyEvent
public Command keyEvent(javax.swing.KeyStroke stroke)
- Description copied from interface:
GamePiece
- Keyboard events are forward to this method when a piece is selected
The GamePiece can respond in any way it likes
- Specified by:
keyEvent in interface GamePiece- Overrides:
keyEvent in class Decorator
- Following copied from interface:
VASSAL.counters.GamePiece
- Returns:
- a
Command that, when executed, will invoke
the same response. Usually a ChangePiece command. - See Also:
ForwardToKeyBuffer
myKeyEvent
public Command myKeyEvent(javax.swing.KeyStroke stroke)
- Description copied from class:
Decorator
- The response of this trait alone to the given KeyStroke
- Overrides:
myKeyEvent in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- Parameters:
stroke - - Returns:
- null if no effect
- See Also:
Decorator.keyEvent(javax.swing.KeyStroke)
mySetState
public void mySetState(java.lang.String newState)
- Description copied from class:
Decorator
- Set just the state of this trait
- Overrides:
mySetState in class Decorator
- Following copied from class:
VASSAL.counters.Decorator
- See Also:
Decorator.myGetState()
boundingBox
public java.awt.Rectangle boundingBox()
- Description copied from interface:
GamePiece
- The area which this GamePiece occupies when
drawn at the point (0,0)
- Specified by:
boundingBox in interface GamePiece
draw
public void draw(java.awt.Graphics g,
int x,
int y,
java.awt.Component obs,
double zoom)
- Description copied from interface:
GamePiece
- Draw this GamePiece
- Specified by:
draw in interface GamePiece
- Following copied from interface:
VASSAL.counters.GamePiece
- Parameters:
g - x - x-location of the center of the piecey - y-location of the center of the pieceobs - the Component on which this piece is being drawnzoom - the scaling factor.
getName
public java.lang.String getName()
- Description copied from interface:
GamePiece
- The plain English name for this piece
- Specified by:
getName in interface GamePiece
getShape
public java.awt.Shape getShape()
- Description copied from interface:
GamePiece
- The shape of the piece from the user's viewpoint. This defines the area
in which the user must click to select or move the piece, for example.
Like
GamePiece.boundingBox(), it assumes the position is (0,0) and must be translated
to the actual location where the piece is being drawn.
- Specified by:
getShape in interface GamePiece
getPrototypeName
public java.lang.String getPrototypeName()
getEditor
public PieceEditor getEditor()
- Description copied from interface:
EditablePiece
- Get the configurer for this trait
- Specified by:
getEditor in interface EditablePiece- Overrides:
getEditor in class Decorator