Package VASSAL.counters
Class FreeRotator
java.lang.Object
VASSAL.counters.Decorator
VASSAL.counters.FreeRotator
- All Implemented Interfaces:
MouseListener
,MouseMotionListener
,EventListener
,Drawable
,PropertyNameSource
,PropertySource
,EditablePiece
,GamePiece
,PropertyExporter
,StateMergeable
,TranslatablePiece
,PersistentPropertyContainer
public class FreeRotator extends Decorator implements EditablePiece, MouseListener, MouseMotionListener, Drawable, TranslatablePiece
A Decorator that rotates a GamePiece to an arbitrary angle
-
Field Summary
Fields Modifier and Type Field Description protected int
angleIndex
protected Map<Double,Rectangle>
bounds
protected KeyCommand[]
commands
static String
DEGREES
protected boolean
drawGhost
static String
FACING
protected GamePieceOp
gpOp
static String
ID
protected Map<Double,Image>
images
Deprecated, for removal: This API element is subject to removal in a future version.protected String
name
static double
PI_180
protected Point
pivot
protected KeyCommand
rotateCCWCommand
protected NamedKeyStroke
rotateCCWKey
protected String
rotateCCWText
protected KeyCommand
rotateCWCommand
protected NamedKeyStroke
rotateCWKey
protected String
rotateCWText
protected KeyCommand
rotateRNDCommand
protected NamedKeyStroke
rotateRNDKey
protected String
rotateRNDText
protected Map<Double,RotateScaleOp>
rotOp
protected KeyCommand
setAngleCommand
protected NamedKeyStroke
setAngleKey
protected String
setAngleText
protected double
startAngle
protected Map
startMap
protected Point
startPosition
protected double
tempAngle
protected PieceImage
unrotated
Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
useUnrotatedShape
protected double[]
validAngles
Fields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAME
Fields inherited from interface VASSAL.i18n.TranslatablePiece
PREFIX
-
Constructor Summary
Constructors Constructor Description FreeRotator()
FreeRotator(String type, GamePiece inner)
-
Method Summary
Modifier and Type Method Description void
beginInteractiveRotate()
Rectangle
boundingBox()
The area which this GamePiece occupies when drawn at the point (0,0)void
draw(Graphics g, int x, int y, Component obs, double zoom)
Draw this GamePiecevoid
draw(Graphics g, Map map)
boolean
drawAboveCounters()
void
endInteractiveRotate()
double
getAngle()
double
getAngleInRadians()
double
getCumulativeAngle()
double
getCumulativeAngleInRadians()
String
getDescription()
A plain-English description of this type of piecePieceEditor
getEditor()
Get the configurer for this traitprotected GamePieceOp
getGpOp()
HelpFile
getHelpFile()
PieceI18nData
getI18nData()
Return I18n data for this pieceObject
getLocalizedProperty(Object key)
String
getName()
The plain English name for this pieceObject
getProperty(Object key)
List<String>
getPropertyNames()
Return Property names exposed by this traitRectangle
getRotatedBounds()
Deprecated, for removal: This API element is subject to removal in a future version.Image
getRotatedImage(double angle, Component obs)
Deprecated, for removal: This API element is subject to removal in a future version.Use aGamePieceOp
if you need this Image.Shape
getShape()
The shape of the piece from the user's viewpoint.boolean
hasPieceMoved()
Has the piece been moved by a Global key command since interactive rotate mode was turned on?void
mouseClicked(MouseEvent e)
void
mouseDragged(MouseEvent e)
void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
void
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
KeyCommand[]
myGetKeyCommands()
String
myGetState()
String
myGetType()
Command
myKeyEvent(KeyStroke stroke)
The response of this trait alone to the given KeyStrokevoid
mySetState(String state)
Set just the state of this traitvoid
mySetType(String type)
Set the type information for this piece.void
setAngle(double angle)
void
setInner(GamePiece p)
Set the inner GamePiecevoid
setPivot(int x, int y)
The point around which the piece will pivot while rotating interactivelyvoid
setProperty(Object key, Object val)
Other properties, possibly game-specific, can be associated with a piece.Methods inherited from class VASSAL.counters.Decorator
getCommandDescription, getDecorator, getI18nData, getI18nData, getId, getInner, getInnermost, getKeyCommands, getLocalizedName, getMap, getOuter, getOutermost, getParent, getPersistentProperty, getPosition, getProperties, getState, getTranslation, getType, isSelected, keyEvent, mergeState, putOldProperties, repack, reportDataError, reportDataError, reportDataError, setId, setMap, setOldProperties, setOldProperties, setParent, setPersistentProperty, setPosition, 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, getState, getType, keyEvent, setId, setMap, setParent, setPosition, setState
Methods inherited from interface VASSAL.counters.PropertyExporter
getProperties
-
Field Details
-
ID
- See Also:
- Constant Field Values
-
FACING
- See Also:
- Constant Field Values
-
DEGREES
- See Also:
- Constant Field Values
-
PI_180
public static final double PI_180- See Also:
- Constant Field Values
-
setAngleCommand
-
rotateCWCommand
-
rotateCCWCommand
-
commands
-
setAngleKey
-
setAngleText
-
rotateCWKey
-
rotateCWText
-
rotateCCWKey
-
rotateCCWText
-
name
-
rotateRNDCommand
-
rotateRNDText
-
rotateRNDKey
-
useUnrotatedShape
protected boolean useUnrotatedShape -
validAngles
protected double[] validAngles -
angleIndex
protected int angleIndex -
images
Deprecated, for removal: This API element is subject to removal in a future version. -
bounds
-
unrotated
Deprecated, for removal: This API element is subject to removal in a future version. -
gpOp
-
rotOp
-
tempAngle
protected double tempAngle -
startAngle
protected double startAngle -
pivot
-
drawGhost
protected boolean drawGhost -
startMap
-
startPosition
-
-
Constructor Details
-
FreeRotator
public FreeRotator() -
FreeRotator
-
-
Method Details
-
getName
Description copied from interface:GamePiece
The plain English name for this piece -
setInner
Description copied from class:Decorator
Set the inner GamePiece -
boundingBox
Description copied from interface:GamePiece
The area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBox
in interfaceGamePiece
-
getGpOp
-
getAngle
public double getAngle() -
getCumulativeAngle
public double getCumulativeAngle() -
getCumulativeAngleInRadians
public double getCumulativeAngleInRadians() -
setAngle
public void setAngle(double angle) -
getRotatedBounds
Deprecated, for removal: This API element is subject to removal in a future version.UseboundingBox()
instead. -
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. -
getAngleInRadians
public double getAngleInRadians() -
mySetType
Description copied from interface:EditablePiece
Set the type information for this piece. SeeDecorator.myGetType()
- Specified by:
mySetType
in interfaceEditablePiece
-
draw
Description copied from interface:GamePiece
Draw this GamePiece -
draw
-
drawAboveCounters
public boolean drawAboveCounters()- Specified by:
drawAboveCounters
in interfaceDrawable
-
myGetType
- Specified by:
myGetType
in classDecorator
- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
myGetState
- Specified by:
myGetState
in classDecorator
- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
mySetState
Description copied from class:Decorator
Set just the state of this trait- Specified by:
mySetState
in classDecorator
- See Also:
Decorator.myGetState()
-
myGetKeyCommands
- Specified by:
myGetKeyCommands
in classDecorator
- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
-
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)
-
beginInteractiveRotate
public void beginInteractiveRotate() -
endInteractiveRotate
public void endInteractiveRotate() -
hasPieceMoved
public boolean hasPieceMoved()Has the piece been moved by a Global key command since interactive rotate mode was turned on? -
setPivot
public void setPivot(int x, int y)The point around which the piece will pivot while rotating interactively -
mouseClicked
- Specified by:
mouseClicked
in interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleased
in interfaceMouseListener
-
setProperty
Description copied from interface:GamePiece
Other properties, possibly game-specific, can be associated with a piece. The properties may or may not need to be encoded in the piece'sGamePiece.getState()
method.- Specified by:
setProperty
in interfaceGamePiece
- Overrides:
setProperty
in classDecorator
-
getLocalizedProperty
- Specified by:
getLocalizedProperty
in interfacePropertySource
- Overrides:
getLocalizedProperty
in classDecorator
-
getProperty
- Specified by:
getProperty
in interfaceGamePiece
- Specified by:
getProperty
in interfacePropertySource
- Overrides:
getProperty
in classDecorator
-
mouseDragged
- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
getRotatedImage
@Deprecated(since="2020-08-06", forRemoval=true) public Image getRotatedImage(double angle, Component obs)Deprecated, for removal: This API element is subject to removal in a future version.Use aGamePieceOp
if you need this Image.Return a full-scale cached image of this piece, rotated to the appropriate angle.- Parameters:
angle
- Rotation angleobs
- Component observer- Returns:
- Rotated Image
-
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
-
getEditor
Description copied from interface:EditablePiece
Get the configurer for this trait- Specified by:
getEditor
in interfaceEditablePiece
- Overrides:
getEditor
in classDecorator
-
getI18nData
Description copied from class:Decorator
Return I18n data for this piece- Specified by:
getI18nData
in interfaceTranslatablePiece
- Overrides:
getI18nData
in classDecorator
- Returns:
- I18n data
-
getPropertyNames
Return Property names exposed by this trait- Specified by:
getPropertyNames
in interfacePropertyNameSource
- Overrides:
getPropertyNames
in classDecorator
-
boundingBox()
instead.