Package VASSAL.counters
Class Translate
java.lang.Object
VASSAL.counters.Decorator
VASSAL.counters.Translate
- All Implemented Interfaces:
PropertyNameSource,PropertySource,EditablePiece,GamePiece,PropertyExporter,StateMergeable,TranslatablePiece,PersistentPropertyContainer
public class Translate extends Decorator implements TranslatablePiece
Give a piece a command that moves it a fixed amount in a particular
direction, optionally tracking the current rotation of the piece.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classTranslate.Editorstatic classTranslate.MoveExecuterBatches up all the movement commands resulting from a single KeyEvent and executes them at once. -
Field Summary
Fields Modifier and Type Field Description protected StringcommandNameprotected KeyCommand[]commandsprotected Stringdescriptionstatic StringIDprotected NamedKeyStrokekeyCommandprotected KeyCommandmoveCommandprotected static Translate.MoveExecutermoverprotected booleanmoveStackprotected FormattedStringxDistprotected FormattedStringxIndexprotected FormattedStringxOffsetprotected FormattedStringyDistprotected FormattedStringyIndexprotected FormattedStringyOffsetFields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAMEFields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX -
Constructor Summary
-
Method Summary
Modifier and Type Method Description RectangleboundingBox()The area which this GamePiece occupies when drawn at the point (0,0)protected CommandclassicTranslate(KeyStroke stroke)Classic Translate code.voiddraw(Graphics g, int x, int y, Component obs, double zoom)Draw this GamePieceprotected GamePiecefindTarget(KeyStroke stroke)StringgetDescription()A plain-English description of this type of piecePieceEditorgetEditor()Get the configurer for this traitHelpFilegetHelpFile()PieceI18nDatagetI18nData()Return I18n data for this pieceStringgetName()The plain English name for this pieceShapegetShape()The shape of the piece from the user's viewpoint.CommandkeyEvent(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 CommandmovePiece(GamePiece gp, Point dest)protected CommandmoveTarget(GamePiece target)protected KeyCommand[]myGetKeyCommands()StringmyGetState()StringmyGetType()CommandmyKeyEvent(KeyStroke stroke)The response of this trait alone to the given KeyStrokevoidmySetState(String newState)Set just the state of this traitvoidmySetType(String type)Set the type information for this piece.protected CommandnewTranslate(KeyStroke stroke)protected voidtranslate(Point p)Methods inherited from class VASSAL.counters.Decorator
getCommandDescription, getDecorator, getI18nData, getI18nData, getId, getInner, getInnermost, getKeyCommands, getLocalizedName, getLocalizedProperty, getMap, getOuter, getOutermost, getParent, getPersistentProperty, getPosition, getProperties, getProperty, getPropertyNames, getState, getTranslation, getType, isSelected, mergeState, putOldProperties, repack, reportDataError, reportDataError, reportDataError, setId, setInner, setMap, setOldProperties, setOldProperties, setParent, setPersistentProperty, setPosition, setProperty, setSelected, setState, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface VASSAL.counters.GamePiece
getId, getLocalizedName, getMap, getParent, getPosition, getProperty, getState, getType, setId, setMap, setParent, setPosition, setProperty, setStateMethods inherited from interface VASSAL.counters.PropertyExporter
getPropertiesMethods inherited from interface VASSAL.build.module.properties.PropertySource
getLocalizedProperty
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
commands
-
commandName
-
keyCommand
-
xDist
-
xIndex
-
xOffset
-
yDist
-
yIndex
-
yOffset
-
description
-
moveStack
protected boolean moveStack -
moveCommand
-
mover
-
-
Constructor Details
-
Translate
public Translate() -
Translate
-
-
Method Details
-
getDescription
Description copied from interface:EditablePieceA plain-English description of this type of piece- Specified by:
getDescriptionin interfaceEditablePiece
-
mySetType
Description copied from interface:EditablePieceSet the type information for this piece. SeeDecorator.myGetType()- Specified by:
mySetTypein interfaceEditablePiece
-
myGetKeyCommands
- Specified by:
myGetKeyCommandsin classDecorator- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
-
myGetState
- Specified by:
myGetStatein classDecorator- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
myGetType
- Specified by:
myGetTypein classDecorator- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
keyEvent
Description copied from class:DecoratorAppend the command returned byDecorator.myKeyEvent(javax.swing.KeyStroke)with the command returned by the inner piece'sGamePiece.keyEvent(javax.swing.KeyStroke)method.- Specified by:
keyEventin interfaceGamePiece- Overrides:
keyEventin classDecorator- Parameters:
stroke- Stroke to apply- Returns:
- Generated Command or null if no effect
- See Also:
ForwardToKeyBuffer
-
myKeyEvent
Description copied from class:DecoratorThe response of this trait alone to the given KeyStroke- Specified by:
myKeyEventin classDecorator- Parameters:
stroke- Stroke to apply- Returns:
- Generated Command or null if no effect
- See Also:
Decorator.keyEvent(javax.swing.KeyStroke)
-
newTranslate
-
movePiece
-
classicTranslate
Classic Translate code. The original Move Fixed Distance code does not work properly in Triggers, creates additional Null actions and does not undo properly. Some modules may depend on this behaviour. Now depends on a Module level preference being turned on to use it. -
moveTarget
-
translate
-
findTarget
-
mySetState
Description copied from class:DecoratorSet just the state of this trait- Specified by:
mySetStatein classDecorator- See Also:
Decorator.myGetState()
-
boundingBox
Description copied from interface:GamePieceThe area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBoxin interfaceGamePiece
-
draw
Description copied from interface:GamePieceDraw this GamePiece -
getName
Description copied from interface:GamePieceThe plain English name for this piece -
getShape
Description copied from interface:GamePieceThe 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. -
getEditor
Description copied from interface:EditablePieceGet the configurer for this trait- Specified by:
getEditorin interfaceEditablePiece- Overrides:
getEditorin classDecorator
-
getHelpFile
- Specified by:
getHelpFilein interfaceEditablePiece
-
getI18nData
Description copied from class:DecoratorReturn I18n data for this piece- Specified by:
getI18nDatain interfaceTranslatablePiece- Overrides:
getI18nDatain classDecorator- Returns:
- I18n data
-