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
GamePieces 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 classMap.ChangeFormatConfigstatic classMap.CreateFormatConfigstatic classMap.IconConfigstatic classMap.InsetLayoutstatic classMap.Mergerstatic classMap.MoveToFormatConfigstatic classMap.MoveWithinFormatConfigstatic classMap.UnmovedIconConfigstatic classMap.ViewThe component that represents the map itselfNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.UtilNested 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, nameFields inherited from class VASSAL.build.AbstractBuildable
buildComponents, validatorFields inherited from interface VASSAL.build.Configurable
NAME_PROPERTY -
Constructor Summary
Constructors Constructor Description Map() -
Method Summary
Modifier and Type Method Description voidaddDrawComponent(Drawable theComponent)Add aDrawablecomponent to this mapvoidaddHighlighter(Highlighter h)voidaddLocalMouseListener(MouseListener l)Because MouseEvents are received in component coordinates, it is inconvenient for MouseListeners on the map to have to translate to map coordinates.voidaddLocalMouseListenerFirst(MouseListener l)voidaddMutableProperty(String key, MutableProperty p)Add a property under the given keyvoidaddPiece(GamePiece p)Adds a GamePiece to this map.voidaddTo(Buildable b)Expects to be added to aGameModule.voidappendToTitle(String s)Commandapply(PieceVisitorDispatcher commandFactory)Apply the providedPieceVisitorDispatcherto all pieces on this map.RectangleboundingBoxOf(GamePiece p)Returns the boundingBox of a GamePiece accounting for the offset of a piece within its parent stack.voidbuild(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 attributevoidcenterAt(Point p)Center the map at given map coordinates within its JScrollPane containervoidcenterAt(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 voidclearActiveMap()protected voidclearMapBorder(Graphics g)PointcomponentCoordinates(Point p)Deprecated, for removal: This API element is subject to removal in a future version.RectanglecomponentRectangle(Rectangle r)Deprecated, for removal: This API element is subject to removal in a future version.intcomponentToDrawing(int c, double os_scale)PointcomponentToDrawing(Point p, double os_scale)RectanglecomponentToDrawing(Rectangle r, double os_scale)intcomponentToMap(int c)PointcomponentToMap(Point p)RectanglecomponentToMap(Rectangle r)protected WindowcreateParentFrame()voiddisableKeyListeners()Restore the previously disabled KeyListenersvoiddragEnter(DropTargetDragEvent dtde)voiddragExit(DropTargetEvent dte)voiddragOver(DropTargetDragEvent dtde)voiddrawBoards(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 objectvoiddrawBoardsInRegion(Graphics g, Rectangle visibleRect)voiddrawBoardsInRegion(Graphics g, Rectangle visibleRect, Component c)voiddrawDrawable(Graphics g, boolean aboveCounters)intdrawingToComponent(int c, double os_scale)PointdrawingToComponent(Point p, double os_scale)RectangledrawingToComponent(Rectangle r, double os_scale)intdrawingToMap(int c, double os_scale)PointdrawingToMap(Point p, double os_scale)RectangledrawingToMap(Rectangle r, double os_scale)voiddrawPieces(Graphics g, int xOffset, int yOffset)voiddrawPiecesInRegion(Graphics g, Rectangle visibleRect)voiddrawPiecesInRegion(Graphics g, Rectangle visibleRect, Component c)voiddrop(DropTargetDropEvent dtde)voiddropActionChanged(DropTargetDragEvent dtde)voidenableKeyListeners()Save all current Key Listeners and remove them from the map.voidensureVisible(Rectangle r)Ensure that the given region (in map coordinates) is visibleGamePiecefindAnyPiece(Point pt, PieceFinder finder)Use the providedPieceFinderinstance to locate any piece at the given location, regardless of whether it is visible or notBoardfindBoard(Point p)GamePiecefindPiece(Point pt, PieceFinder finder)Use the providedPieceFinderinstance to locate a visible piece at the given locationRegionfindRegion(String name)Search on all boards for a Region with the given nameZonefindZone(Point p)ZonefindZone(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.StringgetAttributeValueString(String key)Called by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML elementVisibilityConditiongetAttributeVisibility(String name)By default, all attributes are visibleBoardgetBoardByName(String name)Return the board with the given nameintgetBoardCount()BoardPickergetBoardPicker()Every map must include aBoardPickeras one of its build componentsCollection<Board>getBoards()StringgetChangeFormat()ComponentgetComponent()static StringgetConfigureTypeName()StringgetCreateFormat()StringgetDeckNameAt(Point p)Return the name of the deck whose position is pStringgetDeckNameContaining(Point p)Return the name of the deck whose bounding box contains pprotected StringgetDefaultWindowTitle()DragGestureListenergetDragGestureListener()DimensiongetEdgeBuffer()The buffer of empty space around the boards in the Map window, in component coordinates at 100% zoomHelpFilegetHelpFile()HighlightergetHighlighter()Iterator<Highlighter>getHighlighters()StringgetId()Each Map must have a unique String idStringgetIdentifier()Make a best gues for a unique identifier for the target.JLayeredPanegetLayeredPane()StringgetLocalizedDeckNameAt(Point p)StringgetLocalizedMapName()ObjectgetLocalizedProperty(Object key)protected PointgetLocation(int column, int row, double zoom)protected PointgetLocation(Board b, double zoom)static MapgetMapById(String id)static List<Map>getMapList()Utility method to return aListof all map components in the module.StringgetMapName()KeyStrokegetMoveKey()Return the auto-move key.StringgetMoveToFormat()StringgetMoveWithinFormat()StringgetMutablePropertiesContainerId()Return a unique Id for the containerMutablePropertygetMutableProperty(String name)Find a contained Global Variable by namePieceCollectiongetPieceCollection()floatgetPieceOpacity()GamePiece[]getPieces()DimensiongetPreferredSize()ObjectgetProperty(Object key)CommandgetRestoreCommand()When saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return nullStackMetricsgetStackMetrics()Every map must include aStackMetricsas one of its build components, which governs the stacking behavior of GamePieces on the mapJToolBargetToolBar()JComponentgetView()doublegetZoom()ZoomergetZoomer()A map may include aZoomeras one of its build componentsintindexOf(GamePiece s)Returns the index of a piece.static booleanisChangeReportingEnabled()booleanisLocationRestricted(Point p)booleanisPiecesVisible()booleanisVisibleToAll()Is this map visible to all playersStringlocalizedLocationName(Point p)StringlocationName(Point p)PointmapCoordinates(Point p)Deprecated, for removal: This API element is subject to removal in a future version.RectanglemapRectangle(Rectangle r)Deprecated, for removal: This API element is subject to removal in a future version.DimensionmapSize()intmapToComponent(int c)PointmapToComponent(Point p)RectanglemapToComponent(Rectangle r)intmapToDrawing(int c, double os_scale)PointmapToDrawing(Point p, double os_scale)RectanglemapToDrawing(Rectangle r, double os_scale)voidmouseClicked(MouseEvent e)Mouse events are first translated into map coordinates.voidmouseDragged(MouseEvent e)Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack.voidmouseEntered(MouseEvent e)voidmouseExited(MouseEvent e)voidmouseMoved(MouseEvent e)Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stackvoidmousePressed(MouseEvent e)voidmouseReleased(MouseEvent e)Mouse events are first translated into map coordinates.voidpaintRegion(Graphics g, Rectangle visibleRect)voidpaintRegion(Graphics g, Rectangle visibleRect, Component c)CommandplaceAt(GamePiece piece, Point pt)Place a piece at the destination point.CommandplaceOrMerge(GamePiece p, Point pt)Move a piece to the destination point.voidpopMouseListener()MouseListeners on a map may be pushed and popped onto a stack.PointpositionOf(GamePiece p)Returns the position of a GamePiece accounting for the offset within a parent stack, if anyvoidpushMouseListener(MouseListener l)MouseListeners on a map may be pushed and popped onto a stack.voidremoveDrawComponent(Drawable theComponent)Remove aDrawablecomponent from this mapvoidremoveFrom(Buildable b)Remove this component from its parentvoidremoveHighlighter(Highlighter h)voidremoveLocalMouseListener(MouseListener l)MutablePropertyremoveMutableProperty(String key)Remove the property with the given keyvoidremovePiece(GamePiece p)Removes a piece from the mapvoidrepaint()voidrepaint(boolean cf)voidrepaint(Rectangle r)Repaint the given area, specified in map coordinatesvoidreposition(GamePiece s, int pos)Deprecated, for removal: This API element is subject to removal in a future version.protected intscale(int c, double zoom)protected Pointscale(Point p, double zoom)protected Rectanglescale(Rectangle r, double zoom)voidscroll(int dx, int dy)Scrolls the map in the containing JScrollPane.voidscrollAtEdge(Point evtPt, int dist)Begin autoscrolling the map if the given point is within the given distance from a viewport edge.RectangleselectionBoundsOf(GamePiece p)Returns the selection bounding box of a GamePiece accounting for the offset of a piece within a stackstatic voidsetActiveMap(Map m)voidsetAttribute(String key, Object value)Sets a buildFile (XML) attribute value for this component.protected voidsetBoardBoundaries()Adjusts the bounds() rectangle to account for the Board's relative position to other boards.voidsetBoardPicker(BoardPicker picker)Every map must include aBoardPickeras one of its build componentsvoidsetBoards(Collection<Board> c)Set the boards for this map.voidsetBoards(Enumeration<Board> boardList)Deprecated, for removal: This API element is subject to removal in a future version.UsesetBoards(Collection)instead.static voidsetChangeReportingEnabled(boolean b)voidsetDragGestureListener(DragGestureListener dragGestureListener)This listener will be notified when a drag event is initiated, assuming that no MouseListeners are on the stack.voidsetHighlighter(Highlighter h)voidsetId(String id)Each Map must have a unique String idvoidsetMapName(String s)voidsetPieceCollection(PieceCollection pieces)voidsetPieceMover(PieceMover mover)voidsetPieceOpacity(float pieceOpacity)voidsetPiecesVisible(boolean show)voidsetStackMetrics(StackMetrics sm)Every map must include aStackMetricsas one of its build components, which governs the stacking behavior of GamePieces on the mapvoidsetup(boolean show)When a game is started, create a top-level window, if none exists.voidsetZoomer(Zoomer z)A map may include aZoomeras one of its build componentsbooleanshouldDockIntoMainWindow()voidsideChanged(String oldSide, String newSide)PointsnapTo(Point p)MouseEventtranslateEvent(MouseEvent e)Methods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getI18nData, getI18nPrefix, getLocalizedConfigureName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
getAllDescendantComponents, getAllDescendantComponentsOf, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getPropertyNames, validateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.build.Buildable
add, getBuildElementMethods inherited from interface VASSAL.build.Configurable
addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, removeMethods inherited from interface VASSAL.i18n.Translatable
getI18nDataMethods 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:AbstractBuildableSets a buildFile (XML) attribute value for this component. Thekeyparameter will be one of those listed inAbstractBuildable.getAttributeNames(). If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluewill be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()- Specified by:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Specified by:
setAttributein classAbstractBuildable- Parameters:
key- the name of the attribute. Will be one of those listed inAbstractBuildable.getAttributeNames()value- If thevalueparameter is a String, it will be the value returned byAbstractBuildable.getAttributeValueString(java.lang.String)for the samekey. If the implementing class extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed inAbstractConfigurable.getAttributeTypes()
-
getAttributeValueString
Description copied from interface:AutoConfigurableCalled by theBuildable.getBuildElement(org.w3c.dom.Document)method to write the attributes into an XML element- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Specified by:
getAttributeValueStringin 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:AbstractBuildableBuild 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:
buildin interfaceBuildable- Overrides:
buildin classAbstractBuildable- Parameters:
e- the XML element containing the object data
-
setBoardPicker
Every map must include aBoardPickeras one of its build components -
getBoardPicker
Every map must include aBoardPickeras one of its build components- Returns:
- the BoardPicker for this map
-
setZoomer
A map may include aZoomeras one of its build components -
getZoomer
A map may include aZoomeras one of its build components- Returns:
- the Zoomer for this map
-
setStackMetrics
Every map must include aStackMetricsas one of its build components, which governs the stacking behavior of GamePieces on the map -
getStackMetrics
Every map must include aStackMetricsas 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:
getToolBarin interfaceToolBarComponent- Returns:
- the toolbar for this map's window
-
addDrawComponent
Add aDrawablecomponent to this map -
removeDrawComponent
Remove aDrawablecomponent 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:
addToin interfaceBuildable- See Also:
getId(),DragBuffer
-
setPieceMover
-
removeFrom
Description copied from interface:ConfigurableRemove this component from its parent- Specified by:
removeFromin interfaceConfigurable
-
sideChanged
- Specified by:
sideChangedin 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:GameComponentWhen saving a game, each GameComponent should return aCommandthat, when executed, restores the GameComponent to its state when the game was saved If this component has no persistent state, return null- Specified by:
getRestoreCommandin interfaceGameComponent
-
findBoard
- Returns:
- the
Boardon this map containing the argument point
-
findZone
- Returns:
- the
Zoneon 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
MapGridon theBoardat 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:
mouseEnteredin interfaceMouseListener
-
mouseExited
- Specified by:
mouseExitedin 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:
mouseClickedin interfaceMouseListener- See Also:
pushMouseListener(java.awt.event.MouseListener),popMouseListener(),addLocalMouseListener(java.awt.event.MouseListener)
-
setActiveMap
-
clearActiveMap
public static void clearActiveMap() -
mousePressed
- Specified by:
mousePressedin 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:
mouseReleasedin 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:
dragEnterin interfaceDropTargetListener
-
dragOver
- Specified by:
dragOverin interfaceDropTargetListener
-
dropActionChanged
- Specified by:
dropActionChangedin interfaceDropTargetListener
-
dragExit
- Specified by:
dragExitin interfaceDropTargetListener
-
drop
- Specified by:
dropin interfaceDropTargetListener
-
mouseMoved
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack- Specified by:
mouseMovedin 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:
mouseDraggedin 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
Boards 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
Boards 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:
getPropertyin interfacePropertySource
-
getLocalizedProperty
- Specified by:
getLocalizedPropertyin 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:
setupin interfaceGameComponent- Parameters:
show- if true, a game is starting. If false, then a game is ending- See Also:
GameComponent
-
appendToTitle
-
getDefaultWindowTitle
-
findPiece
Use the providedPieceFinderinstance to locate a visible piece at the given location -
findAnyPiece
Use the providedPieceFinderinstance 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
Commandthat reproduces this action
-
apply
Apply the providedPieceVisitorDispatcherto all pieces on this map. Returns the first non-nullCommandreturned 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:
getHelpFilein interfaceConfigurable- Returns:
- a HelpFilte describing how to use and configure this component
-
getAttributeDescriptions
Description copied from interface:AutoConfigurableReturn 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:
getAttributeDescriptionsin interfaceAutoConfigurable- Specified by:
getAttributeDescriptionsin 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:AbstractBuildableLists 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:
getAttributeNamesin interfaceAutoConfigurable- Specified by:
getAttributeNamesin classAbstractBuildable- Returns:
- a list of all buildFile (XML) attribute names for this component
-
getAttributeTypes
Description copied from class:AbstractConfigurableReturn 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 ofAutoConfigurerwill 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:
getAttributeTypesin interfaceAutoConfigurable- Specified by:
getAttributeTypesin classAbstractConfigurable
-
getCreateFormat
-
getChangeFormat
-
getMoveToFormat
-
getMoveWithinFormat
-
getAllowableConfigureComponents
Description copied from interface:ConfigurableReturn 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:
getAllowableConfigureComponentsin interfaceConfigurable
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classAbstractConfigurable- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- a
VisibilityConditionfor this attribute, or null if attribute should always be visible.
-
setId
Each Map must have a unique String id- Specified by:
setIdin interfaceUniqueIdManager.Identifyable
-
getMapById
-
getMapList
Utility method to return aListof all map components in the module.- Returns:
- the list of
Maps
-
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:
getMutablePropertyin interfaceMutablePropertiesContainer
-
addMutableProperty
Description copied from interface:MutablePropertiesContainerAdd a property under the given key- Specified by:
addMutablePropertyin interfaceMutablePropertiesContainer
-
removeMutableProperty
Description copied from interface:MutablePropertiesContainerRemove the property with the given key- Specified by:
removeMutablePropertyin interfaceMutablePropertiesContainer
-
getMutablePropertiesContainerId
Description copied from interface:MutablePropertiesContainerReturn a unique Id for the container- Specified by:
getMutablePropertiesContainerIdin interfaceMutablePropertiesContainer
-
getId
Each Map must have a unique String id- Specified by:
getIdin 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)