Package VASSAL.build.module
Class Map
java.lang.Object
VASSAL.build.AbstractBuildable
VASSAL.build.AbstractConfigurable
VASSAL.build.module.Map
- All Implemented Interfaces:
DropTargetListener
,MouseListener
,MouseMotionListener
,EventListener
,AutoConfigurable
,Buildable
,Configurable
,GameComponent
,PlayerRoster.SideChangeListener
,MutablePropertiesContainer
,PropertyNameSource
,PropertySource
,ValidityChecker
,Translatable
,ToolBarComponent
,UniqueIdManager.Identifyable
- Direct Known Subclasses:
PrivateMap
,WidgetMap
public class Map extends AbstractConfigurable implements GameComponent, MouseListener, MouseMotionListener, DropTargetListener, Configurable, UniqueIdManager.Identifyable, ToolBarComponent, MutablePropertiesContainer, PropertySource, PlayerRoster.SideChangeListener
The Map is the main component for displaying and containing
GamePiece
s during play. Pieces are displayed on
a Map and moved by clicking and dragging. Keyboard events are forwarded to selected pieces. Multiple map windows are
supported in a single game, with dragging between windows allowed.
A Map may contain many different Buildable
subcomponents. Components which are added directly to a Map are
contained in the VASSAL.build.module.map
package-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Map.ChangeFormatConfig
static class
Map.CreateFormatConfig
static class
Map.IconConfig
static class
Map.InsetLayout
static class
Map.Merger
static class
Map.MoveToFormatConfig
static class
Map.MoveWithinFormatConfig
static class
Map.UnmovedIconConfig
static class
Map.View
The component that represents the map itselfNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.Util
Nested classes/interfaces inherited from interface VASSAL.build.module.properties.MutablePropertiesContainer
MutablePropertiesContainer.Impl
-
Field Summary
Fields inherited from class VASSAL.build.AbstractConfigurable
changeSupport, config, localizedName, myI18nData, name
Fields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validator
Fields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY
-
Constructor Summary
Constructors Constructor Description Map()
-
Method Summary
Modifier and Type Method Description void
addDrawComponent(Drawable theComponent)
Add aDrawable
component to this mapvoid
addHighlighter(Highlighter h)
void
addLocalMouseListener(MouseListener l)
Because MouseEvents are received in component coordinates, it is inconvenient for MouseListeners on the map to have to translate to map coordinates.void
addLocalMouseListenerFirst(MouseListener l)
void
addMutableProperty(String key, MutableProperty p)
Add a property under the given keyvoid
addPiece(GamePiece p)
Adds a GamePiece to this map.void
addTo(Buildable b)
Expects to be added to aGameModule
.void
appendToTitle(String s)
Command
apply(PieceVisitorDispatcher commandFactory)
Apply the providedPieceVisitorDispatcher
to all pieces on this map.Rectangle
boundingBoxOf(GamePiece p)
Returns the boundingBox of a GamePiece accounting for the offset of a piece within its parent stack.void
build(Element e)
Build this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
with the String value of the attributevoid
centerAt(Point p)
Center the map at given map coordinates within its JScrollPane containervoid
centerAt(Point p, int dx, int dy)
Center the map at the given map coordinates, if the point is not already within (dx,dy) of the center.static void
clearActiveMap()
protected void
clearMapBorder(Graphics g)
Point
componentCoordinates(Point p)
Deprecated, for removal: This API element is subject to removal in a future version.Rectangle
componentRectangle(Rectangle r)
Deprecated, for removal: This API element is subject to removal in a future version.int
componentToDrawing(int c, double os_scale)
Point
componentToDrawing(Point p, double os_scale)
Rectangle
componentToDrawing(Rectangle r, double os_scale)
int
componentToMap(int c)
Point
componentToMap(Point p)
Rectangle
componentToMap(Rectangle r)
protected Window
createParentFrame()
void
disableKeyListeners()
Restore the previously disabled KeyListenersvoid
dragEnter(DropTargetDragEvent dtde)
void
dragExit(DropTargetEvent dte)
void
dragOver(DropTargetDragEvent dtde)
void
drawBoards(Graphics g, int xoffset, int yoffset, double zoom, Component obs)
Draw the boards of the map at the given point and zoom factor onto the given Graphics objectvoid
drawBoardsInRegion(Graphics g, Rectangle visibleRect)
void
drawBoardsInRegion(Graphics g, Rectangle visibleRect, Component c)
void
drawDrawable(Graphics g, boolean aboveCounters)
int
drawingToComponent(int c, double os_scale)
Point
drawingToComponent(Point p, double os_scale)
Rectangle
drawingToComponent(Rectangle r, double os_scale)
int
drawingToMap(int c, double os_scale)
Point
drawingToMap(Point p, double os_scale)
Rectangle
drawingToMap(Rectangle r, double os_scale)
void
drawPieces(Graphics g, int xOffset, int yOffset)
void
drawPiecesInRegion(Graphics g, Rectangle visibleRect)
void
drawPiecesInRegion(Graphics g, Rectangle visibleRect, Component c)
void
drop(DropTargetDropEvent dtde)
void
dropActionChanged(DropTargetDragEvent dtde)
void
enableKeyListeners()
Save all current Key Listeners and remove them from the map.void
ensureVisible(Rectangle r)
Ensure that the given region (in map coordinates) is visibleGamePiece
findAnyPiece(Point pt, PieceFinder finder)
Use the providedPieceFinder
instance to locate any piece at the given location, regardless of whether it is visible or notBoard
findBoard(Point p)
GamePiece
findPiece(Point pt, PieceFinder finder)
Use the providedPieceFinder
instance to locate a visible piece at the given locationRegion
findRegion(String name)
Search on all boards for a Region with the given nameZone
findZone(Point p)
Zone
findZone(String name)
Search on all boards for a Zone with the given nameEnumeration<Board>
getAllBoards()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetBoards()
instead.static Iterator<Map>
getAllMaps()
Deprecated, for removal: This API element is subject to removal in a future version.UsegetMapList()
instead.Class<?>[]
getAllowableConfigureComponents()
Return a list of valid sub-component Classes.GamePiece[]
getAllPieces()
String[]
getAttributeDescriptions()
Return an array of Strings describing the attributes of this object.String[]
getAttributeNames()
Lists all the buildFile (XML) attribute names for this component.Class<?>[]
getAttributeTypes()
Return the Class for the buildFile (XML) attributes of this component.String
getAttributeValueString(String key)
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML elementVisibilityCondition
getAttributeVisibility(String name)
By default, all attributes are visibleBoard
getBoardByName(String name)
Return the board with the given nameint
getBoardCount()
BoardPicker
getBoardPicker()
Every map must include aBoardPicker
as one of its build componentsCollection<Board>
getBoards()
String
getChangeFormat()
Component
getComponent()
static String
getConfigureTypeName()
String
getCreateFormat()
String
getDeckNameAt(Point p)
Return the name of the deck whose position is pString
getDeckNameContaining(Point p)
Return the name of the deck whose bounding box contains pprotected String
getDefaultWindowTitle()
DragGestureListener
getDragGestureListener()
Dimension
getEdgeBuffer()
The buffer of empty space around the boards in the Map window, in component coordinates at 100% zoomHelpFile
getHelpFile()
Highlighter
getHighlighter()
Iterator<Highlighter>
getHighlighters()
String
getId()
Each Map must have a unique String idString
getIdentifier()
Make a best gues for a unique identifier for the target.JLayeredPane
getLayeredPane()
String
getLocalizedDeckNameAt(Point p)
String
getLocalizedMapName()
Object
getLocalizedProperty(Object key)
protected Point
getLocation(int column, int row, double zoom)
protected Point
getLocation(Board b, double zoom)
static Map
getMapById(String id)
static List<Map>
getMapList()
Utility method to return aList
of all map components in the module.String
getMapName()
KeyStroke
getMoveKey()
Return the auto-move key.String
getMoveToFormat()
String
getMoveWithinFormat()
String
getMutablePropertiesContainerId()
Return a unique Id for the containerMutableProperty
getMutableProperty(String name)
Find a contained Global Variable by namePieceCollection
getPieceCollection()
float
getPieceOpacity()
GamePiece[]
getPieces()
Dimension
getPreferredSize()
Object
getProperty(Object key)
Command
getRestoreCommand()
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullStackMetrics
getStackMetrics()
Every map must include aStackMetrics
as one of its build components, which governs the stacking behavior of GamePieces on the mapJToolBar
getToolBar()
JComponent
getView()
double
getZoom()
Zoomer
getZoomer()
A map may include aZoomer
as one of its build componentsint
indexOf(GamePiece s)
Returns the index of a piece.static boolean
isChangeReportingEnabled()
boolean
isLocationRestricted(Point p)
boolean
isPiecesVisible()
boolean
isVisibleToAll()
Is this map visible to all playersString
localizedLocationName(Point p)
String
locationName(Point p)
Point
mapCoordinates(Point p)
Deprecated, for removal: This API element is subject to removal in a future version.Rectangle
mapRectangle(Rectangle r)
Deprecated, for removal: This API element is subject to removal in a future version.Dimension
mapSize()
int
mapToComponent(int c)
Point
mapToComponent(Point p)
Rectangle
mapToComponent(Rectangle r)
int
mapToDrawing(int c, double os_scale)
Point
mapToDrawing(Point p, double os_scale)
Rectangle
mapToDrawing(Rectangle r, double os_scale)
void
mouseClicked(MouseEvent e)
Mouse events are first translated into map coordinates.void
mouseDragged(MouseEvent e)
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack.void
mouseEntered(MouseEvent e)
void
mouseExited(MouseEvent e)
void
mouseMoved(MouseEvent e)
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stackvoid
mousePressed(MouseEvent e)
void
mouseReleased(MouseEvent e)
Mouse events are first translated into map coordinates.void
paintRegion(Graphics g, Rectangle visibleRect)
void
paintRegion(Graphics g, Rectangle visibleRect, Component c)
Command
placeAt(GamePiece piece, Point pt)
Place a piece at the destination point.Command
placeOrMerge(GamePiece p, Point pt)
Move a piece to the destination point.void
popMouseListener()
MouseListeners on a map may be pushed and popped onto a stack.Point
positionOf(GamePiece p)
Returns the position of a GamePiece accounting for the offset within a parent stack, if anyvoid
pushMouseListener(MouseListener l)
MouseListeners on a map may be pushed and popped onto a stack.void
removeDrawComponent(Drawable theComponent)
Remove aDrawable
component from this mapvoid
removeFrom(Buildable b)
Remove this component from its parentvoid
removeHighlighter(Highlighter h)
void
removeLocalMouseListener(MouseListener l)
MutableProperty
removeMutableProperty(String key)
Remove the property with the given keyvoid
removePiece(GamePiece p)
Removes a piece from the mapvoid
repaint()
void
repaint(boolean cf)
void
repaint(Rectangle r)
Repaint the given area, specified in map coordinatesvoid
reposition(GamePiece s, int pos)
Deprecated, for removal: This API element is subject to removal in a future version.protected int
scale(int c, double zoom)
protected Point
scale(Point p, double zoom)
protected Rectangle
scale(Rectangle r, double zoom)
void
scroll(int dx, int dy)
Scrolls the map in the containing JScrollPane.void
scrollAtEdge(Point evtPt, int dist)
Begin autoscrolling the map if the given point is within the given distance from a viewport edge.Rectangle
selectionBoundsOf(GamePiece p)
Returns the selection bounding box of a GamePiece accounting for the offset of a piece within a stackstatic void
setActiveMap(Map m)
void
setAttribute(String key, Object value)
Sets a buildFile (XML) attribute value for this component.protected void
setBoardBoundaries()
Adjusts the bounds() rectangle to account for the Board's relative position to other boards.void
setBoardPicker(BoardPicker picker)
Every map must include aBoardPicker
as one of its build componentsvoid
setBoards(Collection<Board> c)
Set the boards for this map.void
setBoards(Enumeration<Board> boardList)
Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)
instead.static void
setChangeReportingEnabled(boolean b)
void
setDragGestureListener(DragGestureListener dragGestureListener)
This listener will be notified when a drag event is initiated, assuming that no MouseListeners are on the stack.void
setHighlighter(Highlighter h)
void
setId(String id)
Each Map must have a unique String idvoid
setMapName(String s)
void
setPieceCollection(PieceCollection pieces)
void
setPieceMover(PieceMover mover)
void
setPieceOpacity(float pieceOpacity)
void
setPiecesVisible(boolean show)
void
setStackMetrics(StackMetrics sm)
Every map must include aStackMetrics
as one of its build components, which governs the stacking behavior of GamePieces on the mapvoid
setup(boolean show)
When a game is started, create a top-level window, if none exists.void
setZoomer(Zoomer z)
A map may include aZoomer
as one of its build componentsboolean
shouldDockIntoMainWindow()
void
sideChanged(String oldSide, String newSide)
Point
snapTo(Point p)
MouseEvent
translateEvent(MouseEvent e)
Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureName
Methods inherited from class VASSAL.build.AbstractBuildable
getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validate
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface VASSAL.build.Buildable
add, getBuildElement
Methods inherited from interface VASSAL.build.Configurable
addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, remove
Methods inherited from interface VASSAL.i18n.Translatable
getI18nData
Methods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
changeReportingEnabled
protected static boolean changeReportingEnabled -
mapID
-
mapName
-
MAIN_WINDOW_HEIGHT
- See Also:
- Constant Field Values
-
idMgr
-
theMap
-
drawComponents
-
layeredPane
-
scroll
-
mainWindowDock
-
picker
-
toolBar
-
zoom
-
metrics
-
edgeBuffer
-
bgColor
-
launchButton
-
useLaunchButton
protected boolean useLaunchButton -
useLaunchButtonEdit
protected boolean useLaunchButtonEdit -
markMovedOption
-
markUnmovedIcon
-
markUnmovedText
-
markUnmovedTooltip
-
multicaster
-
mouseListenerStack
-
boards
-
boardWidths
protected int[][] boardWidths -
boardHeights
protected int[][] boardHeights -
pieces
-
highlighter
-
highlighters
-
clearFirst
protected boolean clearFirst -
hideCounters
protected boolean hideCounters -
pieceOpacity
protected float pieceOpacity -
allowMultiple
protected boolean allowMultiple -
visibilityCondition
-
dragGestureListener
-
moveWithinFormat
-
moveToFormat
-
createFormat
-
changeFormat
-
moveKey
-
tooltip
-
propsContainer
-
repaintOnPropertyChange
-
pieceMover
-
saveKeyListeners
-
NAME
- See Also:
- Constant Field Values
-
MARK_MOVED
- See Also:
- Constant Field Values
-
MARK_UNMOVED_ICON
- See Also:
- Constant Field Values
-
MARK_UNMOVED_TEXT
- See Also:
- Constant Field Values
-
MARK_UNMOVED_TOOLTIP
- See Also:
- Constant Field Values
-
EDGE_WIDTH
- See Also:
- Constant Field Values
-
EDGE_HEIGHT
- See Also:
- Constant Field Values
-
BACKGROUND_COLOR
- See Also:
- Constant Field Values
-
HIGHLIGHT_COLOR
- See Also:
- Constant Field Values
-
HIGHLIGHT_THICKNESS
- See Also:
- Constant Field Values
-
ALLOW_MULTIPLE
- See Also:
- Constant Field Values
-
USE_LAUNCH_BUTTON
- See Also:
- Constant Field Values
-
BUTTON_NAME
- See Also:
- Constant Field Values
-
TOOLTIP
- See Also:
- Constant Field Values
-
ICON
- See Also:
- Constant Field Values
-
HOTKEY
- See Also:
- Constant Field Values
-
SUPPRESS_AUTO
- See Also:
- Constant Field Values
-
MOVE_WITHIN_FORMAT
- See Also:
- Constant Field Values
-
MOVE_TO_FORMAT
- See Also:
- Constant Field Values
-
CREATE_FORMAT
- See Also:
- Constant Field Values
-
CHANGE_FORMAT
- See Also:
- Constant Field Values
-
MOVE_KEY
- See Also:
- Constant Field Values
-
MOVING_STACKS_PICKUP_UNITS
- See Also:
- Constant Field Values
-
activeMap
Mouse events are first translated into map coordinates. Then the event is forwarded to the top MouseListener in the stack, if any, otherwise forwarded to all LocalMouseListeners -
PREFERRED_EDGE_SCROLL_DELAY
public static final int PREFERRED_EDGE_SCROLL_DELAY- See Also:
- Constant Field Values
-
PREFERRED_EDGE_DELAY
- See Also:
- Constant Field Values
-
SCROLL_ZONE
public static final int SCROLL_ZONEThe width of the hot zone for triggering autoscrolling.- See Also:
- Constant Field Values
-
sx
protected int sxThe horizontal component of the autoscrolling vector, -1, 0, or 1. -
sy
protected int syThe vertical component of the autoscrolling vector, -1, 0, or 1. -
dx
protected int dx -
dy
protected int dy -
scroller
protected org.jdesktop.animation.timing.Animator scrollerThe animator which controls autoscrolling. -
LOCATION
- See Also:
- Constant Field Values
-
OLD_LOCATION
- See Also:
- Constant Field Values
-
OLD_MAP
- See Also:
- Constant Field Values
-
MAP_NAME
- See Also:
- Constant Field Values
-
PIECE_NAME
- See Also:
- Constant Field Values
-
MESSAGE
- See Also:
- Constant Field Values
-
-
Constructor Details
-
Map
public Map()
-
-
Method Details
-
getComponent
-
setChangeReportingEnabled
public static void setChangeReportingEnabled(boolean b) -
isChangeReportingEnabled
public static boolean isChangeReportingEnabled() -
setAttribute
Description copied from class:AbstractBuildable
Sets a buildFile (XML) attribute value for this component. Thekey
parameter will be one of those listed inAbstractBuildable.getAttributeNames()
. If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
will be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
- Specified by:
setAttribute
in interfaceAutoConfigurable
- Specified by:
setAttribute
in interfaceTranslatable
- Specified by:
setAttribute
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
value
- If thevalue
parameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)
for the samekey
. If the implementing class extendsAbstractConfigurable
, thenvalue
can also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getAttributeValueString
Description copied from interface:AutoConfigurable
Called by theBuildable.getBuildElement(org.w3c.dom.Document)
method to write the attributes into an XML element- Specified by:
getAttributeValueString
in interfaceAutoConfigurable
- Specified by:
getAttributeValueString
in interfaceTranslatable
- Specified by:
getAttributeValueString
in classAbstractBuildable
- Parameters:
key
- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()
- Returns:
- a String representation of the attribute with the given name. When initializing a module, this String value will be passed to
AbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
.
-
build
Description copied from class:AbstractBuildable
Build this component by getting all XML attributes of the XML element and callingAbstractBuildable.setAttribute(java.lang.String, java.lang.Object)
with the String value of the attribute- Specified by:
build
in interfaceBuildable
- Overrides:
build
in classAbstractBuildable
- Parameters:
e
- the XML element containing the object data
-
setBoardPicker
Every map must include aBoardPicker
as one of its build components -
getBoardPicker
Every map must include aBoardPicker
as one of its build components- Returns:
- the BoardPicker for this map
-
setZoomer
A map may include aZoomer
as one of its build components -
getZoomer
A map may include aZoomer
as one of its build components- Returns:
- the Zoomer for this map
-
setStackMetrics
Every map must include aStackMetrics
as one of its build components, which governs the stacking behavior of GamePieces on the map -
getStackMetrics
Every map must include aStackMetrics
as one of its build components, which governs the stacking behavior of GamePieces on the map- Returns:
- the StackMetrics for this map
-
getZoom
public double getZoom()- Returns:
- the current zoom factor for the map
-
getToolBar
- Specified by:
getToolBar
in interfaceToolBarComponent
- Returns:
- the toolbar for this map's window
-
addDrawComponent
Add aDrawable
component to this map -
removeDrawComponent
Remove aDrawable
component from this map -
addTo
Expects to be added to aGameModule
. Determines a unique id for this Map. Registers itself asKeyStrokeSource
. Registers itself as aGameComponent
. Registers itself as a drop target and drag source.- Specified by:
addTo
in interfaceBuildable
- See Also:
getId()
,DragBuffer
-
setPieceMover
-
removeFrom
Description copied from interface:Configurable
Remove this component from its parent- Specified by:
removeFrom
in interfaceConfigurable
-
sideChanged
- Specified by:
sideChanged
in interfacePlayerRoster.SideChangeListener
-
setBoards
Set the boards for this map. Each map may contain more than oneBoard
. -
setBoards
@Deprecated(since="2020-08-05", forRemoval=true) public void setBoards(Enumeration<Board> boardList)Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)
instead.Set the boards for this map. Each map may contain more than oneBoard
. -
getRestoreCommand
Description copied from interface:GameComponent
When saving a game, each GameComponent should return aCommand
that, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommand
in interfaceGameComponent
-
findBoard
- Returns:
- the
Board
on this map containing the argument point
-
findZone
- Returns:
- the
Zone
on this map containing the argument point
-
findZone
Search on all boards for a Zone with the given name- Parameters:
name
- Zone Name- Returns:
- Located zone
-
findRegion
Search on all boards for a Region with the given name- Parameters:
name
- Region name- Returns:
- Located region
-
getBoardByName
Return the board with the given name- Parameters:
name
- Board Name- Returns:
- null if no such board found
-
getPreferredSize
-
mapSize
- Returns:
- the size of the map in pixels at 100% zoom, including the edge buffer
-
isLocationRestricted
- Returns:
- true if the given point may not be a legal location. I.e., if this grid will attempt to snap it to the nearest grid location
-
snapTo
- Returns:
- the nearest allowable point according to the
MapGrid
on theBoard
at this point - See Also:
Board.snapTo(java.awt.Point)
,MapGrid.snapTo(java.awt.Point)
-
getEdgeBuffer
The buffer of empty space around the boards in the Map window, in component coordinates at 100% zoom -
mapCoordinates
Deprecated, for removal: This API element is subject to removal in a future version.Translate a point from component coordinates (i.e., x,y position on the JPanel) to map coordinates (i.e., accounting for zoom factor).- See Also:
componentCoordinates(java.awt.Point)
-
mapRectangle
Deprecated, for removal: This API element is subject to removal in a future version. -
componentCoordinates
Deprecated, for removal: This API element is subject to removal in a future version.Translate a point from map coordinates to component coordinates- See Also:
mapCoordinates(java.awt.Point)
-
componentRectangle
Deprecated, for removal: This API element is subject to removal in a future version. -
scale
protected int scale(int c, double zoom) -
scale
-
scale
-
mapToDrawing
public int mapToDrawing(int c, double os_scale) -
mapToDrawing
-
mapToDrawing
-
mapToComponent
public int mapToComponent(int c) -
mapToComponent
-
mapToComponent
-
componentToDrawing
public int componentToDrawing(int c, double os_scale) -
componentToDrawing
-
componentToDrawing
-
componentToMap
public int componentToMap(int c) -
componentToMap
-
componentToMap
-
drawingToMap
public int drawingToMap(int c, double os_scale) -
drawingToMap
-
drawingToMap
-
drawingToComponent
public int drawingToComponent(int c, double os_scale) -
drawingToComponent
-
drawingToComponent
-
locationName
- Returns:
- a String name for the given location on the map
- See Also:
Board.locationName(java.awt.Point)
-
localizedLocationName
-
isVisibleToAll
public boolean isVisibleToAll()Is this map visible to all players -
getDeckNameContaining
Return the name of the deck whose bounding box contains p -
getDeckNameAt
Return the name of the deck whose position is p- Parameters:
p
- Point to look for Deck- Returns:
- Name of Deck
-
getLocalizedDeckNameAt
-
addLocalMouseListener
Because MouseEvents are received in component coordinates, it is inconvenient for MouseListeners on the map to have to translate to map coordinates. MouseListeners added with this method will receive mouse events with points already translated into map coordinates. addLocalMouseListenerFirst inserts the new listener at the start of the chain. -
addLocalMouseListenerFirst
-
removeLocalMouseListener
-
pushMouseListener
MouseListeners on a map may be pushed and popped onto a stack. Only the top listener on the stack receives mouse events. -
popMouseListener
public void popMouseListener()MouseListeners on a map may be pushed and popped onto a stack. Only the top listener on the stack receives mouse events -
mouseEntered
- Specified by:
mouseEntered
in interfaceMouseListener
-
mouseExited
- Specified by:
mouseExited
in interfaceMouseListener
-
translateEvent
-
mouseClicked
Mouse events are first translated into map coordinates. Then the event is forwarded to the top MouseListener in the stack, if any, otherwise forwarded to all LocalMouseListeners- Specified by:
mouseClicked
in interfaceMouseListener
- See Also:
pushMouseListener(java.awt.event.MouseListener)
,popMouseListener()
,addLocalMouseListener(java.awt.event.MouseListener)
-
setActiveMap
-
clearActiveMap
public static void clearActiveMap() -
mousePressed
- Specified by:
mousePressed
in interfaceMouseListener
-
mouseReleased
Mouse events are first translated into map coordinates. Then the event is forwarded to the top MouseListener in the stack, if any, otherwise forwarded to all LocalMouseListeners.- Specified by:
mouseReleased
in interfaceMouseListener
- See Also:
pushMouseListener(java.awt.event.MouseListener)
,popMouseListener()
,addLocalMouseListener(java.awt.event.MouseListener)
-
enableKeyListeners
public void enableKeyListeners()Save all current Key Listeners and remove them from the map. Used by Traits that need to prevent Key Commands at certain times. -
disableKeyListeners
public void disableKeyListeners()Restore the previously disabled KeyListeners -
setDragGestureListener
This listener will be notified when a drag event is initiated, assuming that no MouseListeners are on the stack.- Parameters:
dragGestureListener
- Listener- See Also:
pushMouseListener(java.awt.event.MouseListener)
-
getDragGestureListener
-
dragEnter
- Specified by:
dragEnter
in interfaceDropTargetListener
-
dragOver
- Specified by:
dragOver
in interfaceDropTargetListener
-
dropActionChanged
- Specified by:
dropActionChanged
in interfaceDropTargetListener
-
dragExit
- Specified by:
dragExit
in interfaceDropTargetListener
-
drop
- Specified by:
drop
in interfaceDropTargetListener
-
mouseMoved
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack- Specified by:
mouseMoved
in interfaceMouseMotionListener
-
mouseDragged
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack. The map scrolls when dragging the mouse near the edge.- Specified by:
mouseDragged
in interfaceMouseMotionListener
-
scrollAtEdge
Begin autoscrolling the map if the given point is within the given distance from a viewport edge.- Parameters:
evtPt
- Point to checkdist
- Distance to check
-
repaint
public void repaint(boolean cf) -
paintRegion
-
paintRegion
-
drawBoardsInRegion
-
drawBoardsInRegion
-
repaint
public void repaint() -
drawPiecesInRegion
-
drawPiecesInRegion
-
drawPieces
-
drawDrawable
-
getHighlighter
-
setHighlighter
-
addHighlighter
-
removeHighlighter
-
getHighlighters
-
getBoards
- Returns:
- a Collection of all
Board
s on the Map
-
getAllBoards
Deprecated, for removal: This API element is subject to removal in a future version.UsegetBoards()
instead.- Returns:
- an Enumeration of all
Board
s on the map
-
getBoardCount
public int getBoardCount() -
boundingBoxOf
Returns the boundingBox of a GamePiece accounting for the offset of a piece within its parent stack. Return null if this piece is not on the map- See Also:
GamePiece.boundingBox()
-
selectionBoundsOf
Returns the selection bounding box of a GamePiece accounting for the offset of a piece within a stack- See Also:
GamePiece.getShape()
-
positionOf
Returns the position of a GamePiece accounting for the offset within a parent stack, if any -
getPieces
- Returns:
- an array of all GamePieces on the map. This is a read-only copy. Altering the array does not alter the pieces on the map.
-
getAllPieces
-
setPieceCollection
-
getPieceCollection
-
clearMapBorder
-
setBoardBoundaries
protected void setBoardBoundaries()Adjusts the bounds() rectangle to account for the Board's relative position to other boards. In other words, if Board A is N pixels wide and Board B is to the right of Board A, then the origin of Board B will be adjusted N pixels to the right. -
getLocation
-
getLocation
-
drawBoards
Draw the boards of the map at the given point and zoom factor onto the given Graphics object -
repaint
Repaint the given area, specified in map coordinates -
setPiecesVisible
public void setPiecesVisible(boolean show)- Parameters:
show
- if true, enable drawing of GamePiece. If false, don't draw GamePiece when painting the map
-
isPiecesVisible
public boolean isPiecesVisible() -
getPieceOpacity
public float getPieceOpacity() -
setPieceOpacity
public void setPieceOpacity(float pieceOpacity) -
getProperty
- Specified by:
getProperty
in interfacePropertySource
-
getLocalizedProperty
- Specified by:
getLocalizedProperty
in interfacePropertySource
-
getMoveKey
Return the auto-move key. It may be named, so just return the allocated KeyStroke.- Returns:
- auto move keystroke
-
createParentFrame
- Returns:
- the top-level window containing this map
-
shouldDockIntoMainWindow
public boolean shouldDockIntoMainWindow() -
setup
public void setup(boolean show)When a game is started, create a top-level window, if none exists. When a game is ended, remove all boards from the map.- Specified by:
setup
in interfaceGameComponent
- Parameters:
show
- if true, a game is starting. If false, then a game is ending- See Also:
GameComponent
-
appendToTitle
-
getDefaultWindowTitle
-
findPiece
Use the providedPieceFinder
instance to locate a visible piece at the given location -
findAnyPiece
Use the providedPieceFinder
instance to locate any piece at the given location, regardless of whether it is visible or not -
placeAt
Place a piece at the destination point. If necessary, remove the piece from its parent Stack or Map- Returns:
- a
Command
that reproduces this action
-
apply
Apply the providedPieceVisitorDispatcher
to all pieces on this map. Returns the first non-nullCommand
returned bycommandFactory
- Parameters:
commandFactory
- Command Factory
-
placeOrMerge
Move a piece to the destination point. If a piece is at the point (i.e. has a location exactly equal to it), merge with the piece by forwarding toStackMetrics.merge(VASSAL.counters.GamePiece, VASSAL.counters.GamePiece)
. Otherwise, place by forwarding to placeAt() -
addPiece
Adds a GamePiece to this map. Removes the piece from its parent Stack and from its current map, if different from this map -
reposition
Deprecated, for removal: This API element is subject to removal in a future version.Reorder the argument GamePiece to the new index. When painting the map, pieces are drawn in order of index -
indexOf
Returns the index of a piece. When painting the map, pieces are drawn in order of index Return -1 if the piece is not on this map -
removePiece
Removes a piece from the map -
centerAt
Center the map at given map coordinates within its JScrollPane container -
centerAt
Center the map at the given map coordinates, if the point is not already within (dx,dy) of the center. -
ensureVisible
Ensure that the given region (in map coordinates) is visible -
scroll
public void scroll(int dx, int dy)Scrolls the map in the containing JScrollPane.- Parameters:
dx
- number of pixels to scroll horizontallydy
- number of pixels to scroll vertically
-
getConfigureTypeName
-
getMapName
-
getLocalizedMapName
-
setMapName
-
getHelpFile
- Specified by:
getHelpFile
in interfaceConfigurable
- Returns:
- a HelpFilte describing how to use and configure this component
-
getAttributeDescriptions
Description copied from interface:AutoConfigurable
Return an array of Strings describing the attributes of this object. These strings are used as prompts in the Properties window for this object.- Specified by:
getAttributeDescriptions
in interfaceAutoConfigurable
- Specified by:
getAttributeDescriptions
in classAbstractConfigurable
- Returns:
- an array of Strings describing the buildFile (XML) attributes of this component. These strings are used as prompts in the
Properties window for this object, when the component is configured in the Editor. The order of descriptions should
be the same as the order of names in
AbstractBuildable.getAttributeNames()
-
getAttributeNames
Description copied from class:AbstractBuildable
Lists all the buildFile (XML) attribute names for this component. If this component is ALSO anAbstractConfigurable
, then this list of attributes determines the appropriate attribute order forAbstractConfigurable.getAttributeDescriptions()
andAbstractConfigurable.getAttributeTypes()
.- Specified by:
getAttributeNames
in interfaceAutoConfigurable
- Specified by:
getAttributeNames
in classAbstractBuildable
- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractConfigurable
Return the Class for the buildFile (XML) attributes of this component. Valid classes include: String, Integer, Double, Boolean, Image, Color, and KeyStroke, along with any class for which a Configurer exists in VASSAL.configure. The class determines, among other things, which type ofAutoConfigurer
will be used to configure the attribute when the object is configured in the Editor. The order of classes should be the same as the order of names inAbstractBuildable.getAttributeNames()
- Specified by:
getAttributeTypes
in interfaceAutoConfigurable
- Specified by:
getAttributeTypes
in classAbstractConfigurable
-
getCreateFormat
-
getChangeFormat
-
getMoveToFormat
-
getMoveWithinFormat
-
getAllowableConfigureComponents
Description copied from interface:Configurable
Return a list of valid sub-component Classes. If a Class appears in this list, then instances of that class may be added to this component from the Configuration Window.- Specified by:
getAllowableConfigureComponents
in interfaceConfigurable
-
getAttributeVisibility
Description copied from class:AbstractConfigurable
By default, all attributes are visible- Specified by:
getAttributeVisibility
in interfaceAutoConfigurable
- Overrides:
getAttributeVisibility
in classAbstractConfigurable
- Parameters:
name
- Name (key) of one of this component's attributes- Returns:
- a
VisibilityCondition
for this attribute, or null if attribute should always be visible.
-
setId
Each Map must have a unique String id- Specified by:
setId
in interfaceUniqueIdManager.Identifyable
-
getMapById
-
getMapList
Utility method to return aList
of all map components in the module.- Returns:
- the list of
Map
s
-
getAllMaps
Deprecated, for removal: This API element is subject to removal in a future version.UsegetMapList()
instead.Utility method to return a list of all map components in the module- Returns:
- Iterator over all maps
-
getMutableProperty
Find a contained Global Variable by name- Specified by:
getMutableProperty
in interfaceMutablePropertiesContainer
-
addMutableProperty
Description copied from interface:MutablePropertiesContainer
Add a property under the given key- Specified by:
addMutableProperty
in interfaceMutablePropertiesContainer
-
removeMutableProperty
Description copied from interface:MutablePropertiesContainer
Remove the property with the given key- Specified by:
removeMutableProperty
in interfaceMutablePropertiesContainer
-
getMutablePropertiesContainerId
Description copied from interface:MutablePropertiesContainer
Return a unique Id for the container- Specified by:
getMutablePropertiesContainerId
in interfaceMutablePropertiesContainer
-
getId
Each Map must have a unique String id- Specified by:
getId
in interfaceUniqueIdManager.Identifyable
- Returns:
- the id for this map
-
getIdentifier
Make a best gues for a unique identifier for the target. UseUniqueIdManager.Identifyable.getConfigureName()
if non-null, otherwise useUniqueIdManager.Identifyable.getId()
- Returns:
- Unique Identifier
-
getView
- Returns:
- the Swing component representing the map
-
getLayeredPane
- Returns:
- the JLayeredPane holding map insets
-
mapToComponent(Point)