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 intangleIndexprotected Map<Double,Rectangle>boundsprotected KeyCommand[]commandsstatic StringDEGREESprotected booleandrawGhoststatic StringFACINGprotected GamePieceOpgpOpstatic StringIDprotected Map<Double,Image>imagesDeprecated, for removal: This API element is subject to removal in a future version.protected Stringnamestatic doublePI_180protected Pointpivotprotected KeyCommandrotateCCWCommandprotected NamedKeyStrokerotateCCWKeyprotected StringrotateCCWTextprotected KeyCommandrotateCWCommandprotected NamedKeyStrokerotateCWKeyprotected StringrotateCWTextprotected KeyCommandrotateRNDCommandprotected NamedKeyStrokerotateRNDKeyprotected StringrotateRNDTextprotected Map<Double,RotateScaleOp>rotOpprotected KeyCommandsetAngleCommandprotected NamedKeyStrokesetAngleKeyprotected StringsetAngleTextprotected doublestartAngleprotected MapstartMapprotected PointstartPositionprotected doubletempAngleprotected PieceImageunrotatedDeprecated, for removal: This API element is subject to removal in a future version.protected booleanuseUnrotatedShapeprotected double[]validAnglesFields inherited from interface VASSAL.counters.PropertyExporter
LOCALIZED_NAMEFields 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 voidbeginInteractiveRotate()RectangleboundingBox()The area which this GamePiece occupies when drawn at the point (0,0)voiddraw(Graphics g, int x, int y, Component obs, double zoom)Draw this GamePiecevoiddraw(Graphics g, Map map)booleandrawAboveCounters()voidendInteractiveRotate()doublegetAngle()doublegetAngleInRadians()doublegetCumulativeAngle()doublegetCumulativeAngleInRadians()StringgetDescription()A plain-English description of this type of piecePieceEditorgetEditor()Get the configurer for this traitprotected GamePieceOpgetGpOp()HelpFilegetHelpFile()PieceI18nDatagetI18nData()Return I18n data for this pieceObjectgetLocalizedProperty(Object key)StringgetName()The plain English name for this pieceObjectgetProperty(Object key)List<String>getPropertyNames()Return Property names exposed by this traitRectanglegetRotatedBounds()Deprecated, for removal: This API element is subject to removal in a future version.ImagegetRotatedImage(double angle, Component obs)Deprecated, for removal: This API element is subject to removal in a future version.Use aGamePieceOpif you need this Image.ShapegetShape()The shape of the piece from the user's viewpoint.booleanhasPieceMoved()Has the piece been moved by a Global key command since interactive rotate mode was turned on?voidmouseClicked(MouseEvent e)voidmouseDragged(MouseEvent e)voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)voidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent e)KeyCommand[]myGetKeyCommands()StringmyGetState()StringmyGetType()CommandmyKeyEvent(KeyStroke stroke)The response of this trait alone to the given KeyStrokevoidmySetState(String state)Set just the state of this traitvoidmySetType(String type)Set the type information for this piece.voidsetAngle(double angle)voidsetInner(GamePiece p)Set the inner GamePiecevoidsetPivot(int x, int y)The point around which the piece will pivot while rotating interactivelyvoidsetProperty(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, 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, getState, getType, keyEvent, setId, setMap, setParent, setPosition, setStateMethods 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:GamePieceThe plain English name for this piece -
setInner
Description copied from class:DecoratorSet the inner GamePiece -
boundingBox
Description copied from interface:GamePieceThe area which this GamePiece occupies when drawn at the point (0,0)- Specified by:
boundingBoxin 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: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. -
getAngleInRadians
public double getAngleInRadians() -
mySetType
Description copied from interface:EditablePieceSet the type information for this piece. SeeDecorator.myGetType()- Specified by:
mySetTypein interfaceEditablePiece
-
draw
Description copied from interface:GamePieceDraw this GamePiece -
draw
-
drawAboveCounters
public boolean drawAboveCounters()- Specified by:
drawAboveCountersin interfaceDrawable
-
myGetType
- Specified by:
myGetTypein classDecorator- Returns:
- the type of this trait alone
- See Also:
Decorator.getType()
-
myGetState
- Specified by:
myGetStatein classDecorator- Returns:
- the state of this trait alone
- See Also:
Decorator.getState()
-
mySetState
Description copied from class:DecoratorSet just the state of this trait- Specified by:
mySetStatein classDecorator- See Also:
Decorator.myGetState()
-
myGetKeyCommands
- Specified by:
myGetKeyCommandsin classDecorator- Returns:
- the commands for this trait alone
- See Also:
Decorator.getKeyCommands()
-
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)
-
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:
mouseClickedin interfaceMouseListener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener
-
mousePressed
- Specified by:
mousePressedin interfaceMouseListener
-
mouseReleased
- Specified by:
mouseReleasedin interfaceMouseListener
-
setProperty
Description copied from interface:GamePieceOther 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:
setPropertyin interfaceGamePiece- Overrides:
setPropertyin classDecorator
-
getLocalizedProperty
- Specified by:
getLocalizedPropertyin interfacePropertySource- Overrides:
getLocalizedPropertyin classDecorator
-
getProperty
- Specified by:
getPropertyin interfaceGamePiece- Specified by:
getPropertyin interfacePropertySource- Overrides:
getPropertyin classDecorator
-
mouseDragged
- Specified by:
mouseDraggedin interfaceMouseMotionListener
-
mouseMoved
- Specified by:
mouseMovedin 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 aGamePieceOpif 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:EditablePieceA plain-English description of this type of piece- Specified by:
getDescriptionin interfaceEditablePiece
-
getHelpFile
- Specified by:
getHelpFilein interfaceEditablePiece
-
getEditor
Description copied from interface:EditablePieceGet the configurer for this trait- Specified by:
getEditorin interfaceEditablePiece- Overrides:
getEditorin classDecorator
-
getI18nData
Description copied from class:DecoratorReturn I18n data for this piece- Specified by:
getI18nDatain interfaceTranslatablePiece- Overrides:
getI18nDatain classDecorator- Returns:
- I18n data
-
getPropertyNames
Return Property names exposed by this trait- Specified by:
getPropertyNamesin interfacePropertyNameSource- Overrides:
getPropertyNamesin classDecorator
-
boundingBox()instead.