Package VASSAL.counters
Class UsePrototype
java.lang.Object
VASSAL.counters.Decorator
VASSAL.counters.UsePrototype
- All Implemented Interfaces:
PropertyNameSource
,PropertySource
,EditablePiece
,GamePiece
,PropertyExporter
,StateMergeable
,PersistentPropertyContainer
,RecursionLimiter.Loopable
public class UsePrototype extends Decorator implements EditablePiece, RecursionLimiter.Loopable
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.-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
UsePrototype.Editor
-
Field Summary
Fields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAME
-
Constructor Summary
Constructors Constructor Description UsePrototype()
UsePrototype(String type, GamePiece inner)
-
Method Summary
Modifier and Type Method Description Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)protected void
buildPrototype()
void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePieceString
getComponentName()
String
getComponentTypeName()
String
getDescription()
A plain-English description of this type of piecePieceEditor
getEditor()
Get the configurer for this traitGamePiece
getExpandedInner()
Build a new GamePiece instance based on the traits in the referencedPrototypeDefinition
.HelpFile
getHelpFile()
protected KeyCommand[]
getKeyCommands()
The set of key commands that will populate the piece's right-click menu.String
getName()
The plain English name for this pieceString
getPrototypeName()
Shape
getShape()
The shape of the piece from the user's viewpoint.Command
keyEvent(KeyStroke stroke)
Append the command returned byDecorator.myKeyEvent(javax.swing.KeyStroke)
with the command returned by the inner piece'sGamePiece.keyEvent(javax.swing.KeyStroke)
method.protected KeyCommand[]
myGetKeyCommands()
String
myGetState()
String
myGetType()
Command
myKeyEvent(KeyStroke stroke)
The response of this trait alone to the given KeyStrokevoid
mySetState(String newState)
Set just the state of this traitvoid
mySetType(String type)
Set the type information for this piece.void
setInner(GamePiece p)
Set the inner GamePieceMethods inherited from class VASSAL.counters.Decorator
getCommandDescription, getDecorator, getI18nData, getI18nData, getI18nData, getId, getInner, getInnermost, getLocalizedName, getLocalizedProperty, getMap, getOuter, getOutermost, getParent, getPersistentProperty, getPosition, getProperties, getProperty, getPropertyNames, getState, getTranslation, getType, isSelected, mergeState, putOldProperties, repack, reportDataError, reportDataError, reportDataError, setId, setMap, setOldProperties, setOldProperties, setParent, setPersistentProperty, setPosition, setProperty, setSelected, setState, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface VASSAL.counters.GamePiece
getId, getLocalizedName, getMap, getParent, getPosition, getProperty, getState, getType, setId, setMap, setParent, setPosition, setProperty, setState
Methods inherited from interface VASSAL.counters.PropertyExporter
getProperties
Methods inherited from interface VASSAL.build.module.properties.PropertySource
getLocalizedProperty
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
-
Constructor Details
-
UsePrototype
public UsePrototype() -
UsePrototype
-
-
Method Details
-
getDescription
Description copied from interface:EditablePiece
A plain-English description of this type of piece- Specified by:
getDescription
in interfaceEditablePiece
-
getHelpFile
- Specified by:
getHelpFile
in interfaceEditablePiece
-
mySetType
Description copied from interface:EditablePiece
Set the type information for this piece. SeeDecorator.myGetType()
- Specified by:
mySetType
in interfaceEditablePiece
-
myGetKeyCommands
- Specified by:
myGetKeyCommands
in classDecorator
- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
-
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 theProperties.KEY_COMMANDS
property. The commands for a Decorator are a composite ofDecorator.myGetKeyCommands()
and the commands of its inner piece.- Overrides:
getKeyCommands
in classDecorator
- Returns:
- the commands for this piece and its inner piece
-
setInner
Description copied from class:Decorator
Set the inner GamePiece -
buildPrototype
protected void buildPrototype() -
getExpandedInner
Build a new GamePiece instance based on the traits in the referencedPrototypeDefinition
. Substitute the new instance forDecorator.getInner()
and return it. If the referenced definition does not exist, return the default inner piece.- Returns:
- the new instance
-
myGetState
- Specified by:
myGetState
in classDecorator
- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
myGetType
- Specified by:
myGetType
in classDecorator
- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
keyEvent
Description copied from class:Decorator
Append the command returned byDecorator.myKeyEvent(javax.swing.KeyStroke)
with the command returned by the inner piece'sGamePiece.keyEvent(javax.swing.KeyStroke)
method.- Specified by:
keyEvent
in interfaceGamePiece
- Overrides:
keyEvent
in classDecorator
- Parameters:
stroke
- Stroke to apply- Returns:
- Generated Command or null if no effect
- See Also:
ForwardToKeyBuffer
-
myKeyEvent
Description copied from class:Decorator
The response of this trait alone to the given KeyStroke- Specified by:
myKeyEvent
in classDecorator
- Parameters:
stroke
- Stroke to apply- Returns:
- Generated Command or null if no effect
- See Also:
Decorator.keyEvent(javax.swing.KeyStroke)
-
mySetState
Description copied from class:Decorator
Set just the state of this trait- Specified by:
mySetState
in classDecorator
- See Also:
Decorator.myGetState()
-
boundingBox
Description copied from interface:GamePiece
The area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBox
in interfaceGamePiece
-
draw
Description copied from interface:GamePiece
Draw this GamePiece -
getName
Description copied from interface:GamePiece
The plain English name for this piece -
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. LikeGamePiece.boundingBox()
, it assumes the position is (0,0) and must be translated to the actual location where the piece is being drawn. -
getPrototypeName
-
getEditor
Description copied from interface:EditablePiece
Get the configurer for this trait- Specified by:
getEditor
in interfaceEditablePiece
- Overrides:
getEditor
in classDecorator
-
getComponentName
- Specified by:
getComponentName
in interfaceRecursionLimiter.Loopable
-
getComponentTypeName
- Specified by:
getComponentTypeName
in interfaceRecursionLimiter.Loopable
-