Package VASSAL.build.module
Class Map
- All Implemented Interfaces:
DropTargetListener,MouseListener,MouseMotionListener,PropertyChangeListener,EventListener,AutoConfigurable,Buildable,Configurable,GameComponent,PlayerRoster.SideChangeListener,MutablePropertiesContainer,PropertyNameSource,PropertySource,ComponentDescription,ValidityChecker,Translatable,Auditable,ImageSearchTarget,SearchTarget,ToolBarComponent,UniqueIdManager.Identifyable
- Direct Known Subclasses:
PrivateMap,WidgetMap
public class Map
extends AbstractToolbarItem
implements GameComponent, MouseListener, MouseMotionListener, DropTargetListener, Configurable, UniqueIdManager.Identifyable, ToolBarComponent, MutablePropertiesContainer, PropertySource, PlayerRoster.SideChangeListener, ComponentDescription
The Map is the main component for displaying and containing
GamePieces during play. Pieces are displayed on
the map's Board(s) 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.
To a map's Board subcomponent(s), various forms of grid can be added: (ZonedGrid (aka Multi-zone Grid),
HexGrid, SquareGrid (aka Rectangular Grid), and RegionGrid (aka Irregular Grid). These can be used
to determine where pieces are allowed to move, and also for filling properties (e.g. LocationName, CurrentZone, CurrentBoard,
CurrentMap) to allow the module to keep track of pieces and react to their movements.
A Map may contain many different Buildable subcomponents. Components which are addable uniquely to a Map are
contained in the VASSAL.build.module.map package. Some of the most common Map subcomponents include
Zoomer for Zoom Capability, CounterDetailViewer aka Mouse-over Stack Viewer, HidePiecesButton,
and SelectionHighlighters.
Map also contain several critical subcomponents which are automatically added and are not configurable at the module level.
These include PieceMover which handles dragging and dropping of pieces, KeyBufferer which tracks which pieces
are currently "selected" and forwards key commands to them, MenuDisplayer which listens for "right clicks" and provides
"context menu" services, and StackMetrics which handles the "stacking" of game pieces.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classReport format configurer for "modified on map"static classReport format configurer for "created on map"static classAutoconfigurer for map's icon used on its launch buttonstatic classstatic classstatic classReport format configurer for "moved to map"static classReport format configurer for "moved within map"static classAutoconfigurer for mark-unmoved iconstatic classReport format configurer for clear movement historystatic classThe (JPanel-extending) component that represents the map itselfNested classes/interfaces inherited from class VASSAL.build.AbstractToolbarItem
AbstractToolbarItem.FormattedStringConfigNested classes/interfaces inherited from interface VASSAL.build.AutoConfigurable
AutoConfigurable.UtilNested classes/interfaces inherited from interface VASSAL.build.module.properties.MutablePropertiesContainer
MutablePropertiesContainer.Impl -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Mapstatic final Stringprotected booleanstatic final Stringprotected Colorprotected int[][]protected int[][]static final Stringstatic final Stringprotected Stringprotected static booleanprotected booleanstatic final Stringprotected Stringprotected static final Stringprotected static final Stringprotected static final Stringprotected Stringstatic final Stringprotected DragGestureListenerprotected intprotected intstatic final Stringstatic doublestatic final Stringprotected Dimensionstatic final Stringprotected booleanprotected NamedKeyStrokeListenerstatic final Stringstatic final Stringprotected Highlighterprotected ArrayList<Highlighter>static final Stringstatic final Stringprotected static final UniqueIdManagerprotected KeyBuffererprotected LaunchButtonDeprecated, for removal: This API element is subject to removal in a future version.use launch from the superclassprotected JLayeredPanestatic final Stringprotected ComponentSplitter.SplitPaneDeprecated, for removal: This API element is subject to removal in a future version.static final Stringprotected Stringprotected Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected Stringprotected NamedKeyStrokeprotected Stringprotected Stringprotected Stringprotected Stringstatic final Stringprotected StackMetricsprotected ArrayList<MouseListener>static final Stringstatic final Stringstatic final Stringprotected NamedKeyStrokeprotected Stringprotected Stringstatic final Stringprotected MouseListenerstatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected booleanprotected BoardPickerstatic final Stringprotected PieceMoverprotected floatprotected PieceCollectionstatic final Stringstatic final intstatic final Stringstatic final doubleThe rate at which things scrollstatic final intThe width of the hot zone for triggering autoscrolling.static final Stringprotected Pointprotected MutablePropertiesContainerprotected PropertyChangeListenerprotected KeyListener[]protected JScrollPanestatic intprotected org.jdesktop.animation.timing.AnimatorThe animator which controls autoscrolling.static final Stringprotected NamedKeyStrokeListenerprotected SplitPanestatic final Stringprotected intThe horizontal component of the autoscrolling vector, -1, 0, or 1.protected intThe vertical component of the autoscrolling vector, -1, 0, or 1.protected JPanelprotected JToolBarprotected Stringstatic final Stringstatic final Stringprotected booleanprotected booleanprotected VisibilityConditionprotected ZoomerFields inherited from class VASSAL.build.AbstractToolbarItem
BUTTON_TEXT, CAN_DISABLE, canDisable, DISABLED_ICON, disabledIconConfig, HIDE_WHEN_DISABLED, hideWhenDisabled, launch, property, PROPERTY_GATE, propertyGate, showDisabledOptionsFields 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 -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDrawComponent(Drawable theComponent) Registers aDrawablecomponent to this map.voidvoidIn case reports use HTML and refer to any image filesvoidBecause MouseEvents are received in Component coordinates, it is inconvenient for MouseListeners on the map to have to translate to Map coordinates.voidBecause MouseEvents are received in Component coordinates, it is inconvenient for MouseListeners on the map to have to translate to Map coordinates.voidaddMutableProperty(String key, MutableProperty p) Adds a new Global Property to this map.voidAdds a GamePiece to this map's list of pieces.voidRegisters this Map as a child of another buildable component, usually theGameModule.voidDeprecated, for removal: This API element is subject to removal in a future version.useupdateTitleBar()apply(PieceVisitorDispatcher commandFactory) Attempts to apply the providedPieceVisitorDispatcherto all pieces on this map, until it finds one that returns a non-null Command.voidBuilds the map's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new map" hierarchy.voidCenter the map at given map coordinates within its JScrollPane containervoidCenter the map at the given map coordinates, if the point is not already within (dx,dy) of the center.static voidRepaints the current ActiveMap (seesetActiveMap(VASSAL.build.module.Map)) and unmarks it.protected voidClears the map border region, if any.Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.intcomponentToDrawing(int c, double os_scale) Converts an integer value from Component coordinates system to Drawing coordinates for rendering.componentToDrawing(Point p, double os_scale) Converts a Point from Component coordinates to Drawing coordinates for rendering.componentToDrawing(Rectangle r, double os_scale) Converts a Rectangle from Component coordinates to Drawing coordinates for rendering.intcomponentToMap(int c) Converts an integer value from swing Component coordinates to the Map's coordinate system.Converts a Point from swing Component coordinates to the Map's coordinate system.Converts a Rectangle from swing Component coordinates to the Map's coordinate system.protected WindowCreates the top-level window for this map.voidRestore the previously disabled KeyListenersvoiddragEnter(DropTargetDragEvent dtde) voiddragExit(DropTargetEvent dte) voiddragOver(DropTargetDragEvent dtde) Handles scrolling when dragging an gamepiece to the edge of the windowvoiddrawBoards(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) For each Board overlapping the given region, update the appropriate section of the board image.voiddrawBoardsInRegion(Graphics g, Rectangle visibleRect, Component c) For each Board overlapping the given region, update the appropriate section of the board image.voiddrawDrawable(Graphics g, boolean aboveCounters) Draws all of our "Drawable" components.intdrawingToComponent(int c, double os_scale) Converts an integer value from Drawing coordinates to swing Component coordinates.drawingToComponent(Point p, double os_scale) Converts a Point from Drawing coordinates to swing Component coordinates.drawingToComponent(Rectangle r, double os_scale) Converts a Rectangle from Drawing coordinates to swing Component coordinates.intdrawingToMap(int c, double os_scale) Converts an integer value from Drawing coordinates to the Map's coordinate system.drawingToMap(Point p, double os_scale) Converts a Point from Drawing coordinates to the Map's coordinate system.drawingToMap(Rectangle r, double os_scale) Converts a Rectangle from Drawing coordinates to the Map's coordinate system.voiddrawPieces(Graphics g, int xOffset, int yOffset) Draws the map pieces at a given offsetvoiddrawPiecesInRegion(Graphics g, Rectangle visibleRect) Draws all pieces visible in a rectangular area of the mapvoiddrawPiecesInRegion(Graphics g, Rectangle visibleRect, Component c) Draws all pieces visible in a rectangular area of the mapvoiddrop(DropTargetDropEvent dtde) We put the "drop" in drag-n-drop!voidvoidSave all current Key Listeners and remove them from the map.voidEnsure that the given region (in map coordinates) is visible.findAnyPiece(Point pt, PieceFinder finder) Use the providedPieceFinderinstance to locate any piece at the given location, regardless of whether it is visible or not.findPiece(Point pt, PieceFinder finder) Use the providedPieceFinderinstance to locate a visible piece at the given locationfindRegion(String name) Search on all boards for a Region (location on an Irregular Grid) with the given nameSearch on all boards for a Zone with the given nameClass<?>[]List of subcomponents which can be added to a Map.String[]This getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.String[]Lists all the buildFile (XML) attribute names for this component.Class<?>[]This getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well.Classes extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.getAttributeVisibility(String name) By default, all attributes are visiblegetBoardByName(String name) Searches our list of boards for one with the given nameintEvery map must include aBoardPickeras one of its build components.getChangeFormat(boolean noSuppress) The component to be added to the control window toolbarstatic StringGets the generic name for this type of class across all instances of it.Return the name of theDeckwhose position is precisely pprotected StringgetId()Each Map must have a unique String idMake a best guess for a unique identifier for the target.Return the localized name of theDeckwhose position is precisely pGets the value of map-level global property, or a module-level one if a map-level one is not found.protected PointgetLocation(int column, int row, double zoom) Finds the location of a board (in Map space) at a particular column and row, based on passed zoom factorgetLocation(Board b, double zoom) Gets the location of a board in Map space, based on a passed zoom factorprotected Point2DgetLocation2D(int column, int row, double zoom) getLocation2D(Board b, double zoom) static MapgetMapById(String id) Find the map that corresponds to a known unique idUtility method to return aListof all map components (on all maps!) in the module.intReturn the apply-on-move key.Return a unique Id for the containergetMutableProperty(String name) Find a contained Global Property (variable) by name.floatgetProperty(Object key) Gets the value of a map-level global property.Override this method to provide a list of properties to be exposed for use by expressions in the module.As aGameComponent, Map does not have any action inherently needing to be taken for "restoring" itself for load/save and network play purposes (the locations of pieces, etc, are stored in the pieces, and are restored fromGameStatein itsGameState.getRestorePiecesCommand()method, which creates an AddPiece command for each piece).Every map must include a singleStackMetricsobject as one of its build components, which governs the visuals of stacking of GamePieces on the mapEvery map window has a toolbar, and this method returns swing toolbar component for this map.getView()doublegetZoom()If the map has aZoomer(seesetZoomer(VASSAL.build.module.map.Zoomer)), then returns the Zoomer's current zoom factor.A map may include aZoomeras one of its build components.voidhideMap()intReturns the index of a piece.booleanstatic booleanbooleanbooleanbooleanbooleanbooleanisNotPieceDrag(Transferable trans) booleanbooleanbooleanIs this map visible to all players?Deprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.mapSize()intmapToComponent(int c) Converts an integer value from the Map's coordinate system to Component coordinates used for interactions between swing components.Converts a Point from the Map's coordinate system to Component coordinates used for interactions between swing components.Converts a Rectangle from the Map's coordinate system to Component coordinates used for interactions between swing components.intmapToDrawing(int c, double os_scale) Converts an integer value from the Map's coordinate system to Drawing coordinates for rendering.mapToDrawing(Point p, double os_scale) Converts a point from the Map's coordinate system to Drawing coordinates for rendering.mapToDrawing(Rectangle r, double os_scale) Converts a rectangle from the Map's coordinate system to Drawing coordinates for rendering.voidMouse events are first translated into map coordinates.voidMouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack.voidvoidvoidMouse motion events are not forwarded to LocalMouseListeners or to listeners on the stackvoidMouse events are first translated into map coordinates.voidMouse events are first translated into map coordinates.voidpaintRegion(Graphics g, Rectangle visibleRect) Paints a specific region of the map, denoted by a Rectangle.voidpaintRegion(Graphics g, Rectangle visibleRect, Component c) Paints a specific region of the map, denoted by a Rectangle.Place a piece at the destination point.placeOrMerge(GamePiece p, Point pt) Move a piece to the destination point.voidMouseListeners on a map may be pushed and popped onto a stack.voidRemove the most recently pushed mouse listener only if it is the supplied listenervoidMouseListeners on a map may be pushed and popped onto a stack.voidremoveDrawComponent(Drawable theComponent) Unregister aDrawablecomponent from this mapvoidUnregisters this Map from itsBuildableparent (usually aGameModule), reversing the process ofaddTo(VASSAL.build.Buildable).voidvoidBecause MouseEvents are received in Component coordinates, it is inconvenient for MouseListeners on the map to have to translate to Map coordinates.Removes a new Global Property from this map.voidRemoves a piece from the mapvoidrepaint()Repaints the map.voidrepaint(boolean cf) Repaints the map.voidRepaint the given area, specified in map coordinatesprotected intscale(int c, double zoom) Scales an integer value to a zoom factorprotected PointScales a point to a zoom factorprotected RectangleScales a Rectangle to a zoom factorvoidscroll(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.static voidsetActiveMap(Map m) Marks an ActiveMap for certain drag and drop operations, so that the map can be repainted when the operation is complete.voidsetAnyMouseoverDrawn(boolean flag) voidsetAttribute(String key, Object value) Sets a buildFile (XML) attribute value for this component.protected voidAdjusts the bounds() rectangle to account for the Board's relative position to other boards.voidsetBoardPicker(BoardPicker picker) Every map must include a singleBoardPickeras one of its build components.voidsetBoards(Collection<Board> c) Set the boards for this map.static voidsetChangeReportingEnabled(boolean b) Global Change Reporting control - used by Global Key Commands (seeGlobalCommand) to temporarily disable reporting while they run, if their "Suppress individual reports" option is selected.voidsetDragGestureListener(DragGestureListener dragGestureListener) This listener will be notified when a drag event is initiated, assuming that no MouseListeners are on the stack.voidsetDrawingMouseOver(boolean flag) voidvoidEach Map must have a unique String id Sets our unique ID (among Maps), so that e.g.voidRegisters the keyBufferer for this map (old way of scanning through components to find one is silly)voidsetMapName(String s) voidsetPieceCollection(PieceCollection pieces) voidsetPieceMover(PieceMover mover) Every map must include a singlePieceMovercomponent as one of its build components, which handles drag-and-drop behavior for the map.voidsetPieceOpacity(float pieceOpacity) voidsetPiecesVisible(boolean show) voidEvery map must include a singleStackMetricsas one of its build components, which governs the visuals of stacking of GamePieces on the map.voidsetup(boolean show) When a game is started, create a top-level window, if none exists.voidCommon view setup code for Map and PrivateMap, which confusingly have different View classes that sharing the same namevoidA map may include a singleZoomeras one of its build components.booleanIf this map shows with its own special button, it does not dock into the main window.voidshowMap()voidsideChanged(String oldSide, String newSide) Takes action when the local player has switched sides.Because MouseEvents are received in Component coordinates, it is inconvenient for MouseListeners on the map to have to translate to Map coordinates.voidAccepts the current actual center of the map as the new "preferred center" (e.g.voidUpdates the title bar of the current windowMethods inherited from class VASSAL.build.AbstractToolbarItem
addPropertyGateListener, addPropertyGateListener, checkDisabled, disableIfTrue, getLaunchButton, getNameKey, getPropertyList, isShowDisabledOptions, makeLaunchButton, propertyChange, removePropertyGateListener, setButtonTextKey, setHotKeyKey, setIconKey, setLaunchButton, setNameKey, setNamePrompt, setShowDisabledOptions, setTooltipKeyMethods inherited from class VASSAL.build.AbstractConfigurable
add, addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, getExpressionList, getI18nData, getI18nPrefix, getLocalizedConfigureName, getTypeName, remove, removePropertyChangeListener, setAllAttributesUntranslatable, setAttributeTranslatable, setConfigureNameMethods inherited from class VASSAL.build.AbstractBuildable
addImageNamesRecursively, buildString, getAllDescendantComponentsOf, getAncestor, getBuildables, getBuildComponents, getBuildElement, getComponents, getComponentsOf, getNonFolderAncestor, setAncestor, validateMethods inherited from class VASSAL.search.AbstractImageFinder
getAllImageNames, getLocalImageNamesMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface VASSAL.script.expression.Auditable
getComponentName, getComponentTypeNameMethods inherited from interface VASSAL.build.Buildable
add, getBuildElementMethods inherited from interface VASSAL.build.Configurable
addPropertyChangeListener, getConfigureComponents, getConfigureName, getConfigurer, removeMethods inherited from interface VASSAL.tools.ToolBarComponent
updateToolbarButtonsMethods inherited from interface VASSAL.i18n.Translatable
getI18nDataMethods inherited from interface VASSAL.tools.UniqueIdManager.Identifyable
getConfigureName
-
Field Details
-
changeReportingEnabled
protected static boolean changeReportingEnabled -
mapID
-
mapName
-
idMgr
-
theMap
-
drawComponents
-
layeredPane
-
scroll
-
mainWindowDock
@Deprecated(since="2020-11-05", forRemoval=true) protected ComponentSplitter.SplitPane mainWindowDockDeprecated, for removal: This API element is subject to removal in a future version. -
splitPane
-
picker
-
toolBar
-
zoom
-
metrics
-
edgeBuffer
-
bgColor
-
launchButton
Deprecated, for removal: This API element is subject to removal in a future version.use launch from the superclass -
useLaunchButton
protected boolean useLaunchButton -
useLaunchButtonEdit
protected boolean useLaunchButtonEdit -
markMovedOption
-
markUnmovedIcon
-
markUnmovedText
-
markUnmovedTooltip
-
markUnmovedHotkey
-
markUnmovedReport
-
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
-
onlyReportChangedLocation
protected boolean onlyReportChangedLocation -
moveWithinFormat
-
moveToFormat
-
createFormat
-
changeFormat
-
moveKey
-
tooltip
-
propsContainer
-
repaintOnPropertyChange
-
pieceMover
-
keyBufferer
-
saveKeyListeners
-
showKeyListener
-
hideKeyListener
-
description
-
preferredCenter
-
NAME
- See Also:
-
DESCRIPTION
- See Also:
-
MARK_MOVED
- See Also:
-
MARK_UNMOVED_ICON
- See Also:
-
MARK_UNMOVED_TEXT
- See Also:
-
MARK_UNMOVED_TOOLTIP
- See Also:
-
MARK_UNMOVED_HOTKEY
- See Also:
-
MARK_UNMOVED_REPORT
- See Also:
-
EDGE_WIDTH
- See Also:
-
EDGE_HEIGHT
- See Also:
-
BACKGROUND_COLOR
- See Also:
-
HIGHLIGHT_COLOR
- See Also:
-
HIGHLIGHT_THICKNESS
- See Also:
-
ALLOW_MULTIPLE
- See Also:
-
USE_LAUNCH_BUTTON
- See Also:
-
BUTTON_NAME
- See Also:
-
TOOLTIP
- See Also:
-
ICON
- See Also:
-
HOTKEY
- See Also:
-
SUPPRESS_AUTO
- See Also:
-
ONLY_REPORT_CHANGED_LOCATION
- See Also:
-
MOVE_WITHIN_FORMAT
- See Also:
-
MOVE_TO_FORMAT
- See Also:
-
CREATE_FORMAT
- See Also:
-
CHANGE_FORMAT
- See Also:
-
MOVE_KEY
- See Also:
-
MOVING_STACKS_PICKUP_UNITS
- See Also:
-
SHOW_KEY
- See Also:
-
HIDE_KEY
- See Also:
-
activeMap
-
DEFAULT_EDGE_SCROLL_DELAY_PROPERTY
- See Also:
-
DEFAULT_EDGE_SCROLL_ZONE_PROPERTY
- See Also:
-
DEFAULT_EDGE_SCROLL_RATE_PROPERTY
- See Also:
-
PREFERRED_EDGE_SCROLL_DELAY
public static final int PREFERRED_EDGE_SCROLL_DELAY- See Also:
-
PREFERRED_EDGE_DELAY
- See Also:
-
PREFERRED_EDGE_SCROLL_ZONE_STANDARD_DEFAULT
public static final int PREFERRED_EDGE_SCROLL_ZONE_STANDARD_DEFAULTThe width of the hot zone for triggering autoscrolling.- See Also:
-
SCROLL_ZONE
public static int SCROLL_ZONE -
PREFERRED_SCROLL_ZONE
- See Also:
-
PREFERRED_EDGE_SCROLL_RATE_STANDARD_DEFAULT
public static final double PREFERRED_EDGE_SCROLL_RATE_STANDARD_DEFAULTThe rate at which things scroll- See Also:
-
EDGE_SCROLL_RATE
public static double EDGE_SCROLL_RATE -
PREFERRED_EDGE_SCROLL_RATE
- See Also:
-
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:
-
OLD_LOCATION
- See Also:
-
OLD_MAP
- See Also:
-
MAP_NAME
- See Also:
-
PIECE_NAME
- See Also:
-
MESSAGE
- See Also:
-
-
Constructor Details
-
Map
public Map()
-
-
Method Details
-
isAnyMouseoverDrawn
public boolean isAnyMouseoverDrawn() -
setAnyMouseoverDrawn
public void setAnyMouseoverDrawn(boolean flag) -
isDrawingMouseOver
public boolean isDrawingMouseOver() -
setDrawingMouseOver
public void setDrawingMouseOver(boolean flag) -
showMap
public void showMap() -
hideMap
public void hideMap() -
getComponent
Description copied from class:AbstractToolbarItemThe component to be added to the control window toolbar- Overrides:
getComponentin classAbstractToolbarItem- Returns:
- Map's main visual interface swing component (its JPanel)
-
isMarkMoved
public boolean isMarkMoved()- Returns:
- true if the map marks pieces as moved
-
isOnlyReportChangedLocation
public boolean isOnlyReportChangedLocation()- Returns:
- true if auto-reporting moves should only happen if location changed
-
setChangeReportingEnabled
public static void setChangeReportingEnabled(boolean b) Global Change Reporting control - used by Global Key Commands (seeGlobalCommand) to temporarily disable reporting while they run, if their "Suppress individual reports" option is selected.- Parameters:
b- true to turn global change reporting on, false to turn it off.
-
isChangeReportingEnabled
public static boolean isChangeReportingEnabled()- Returns:
- true if change reporting is currently enabled, false if it is presently being suppressed by a Global Key Command.
-
setAttribute
Sets a buildFile (XML) attribute value for this component.- Specified by:
setAttributein interfaceAutoConfigurable- Specified by:
setAttributein interfaceTranslatable- Overrides:
setAttributein classAbstractToolbarItem- Parameters:
key- the name of the attribute. Will be one of those listed ingetAttributeNames()value- If thevalueparameter is a String, it will be the value returned bygetAttributeValueString(java.lang.String)for the samekey. Since Map extendsAbstractConfigurable, thenvaluecan also be an instance of the corresponding Class listed ingetAttributeTypes().
-
getAttributeValueString
Description copied from class:AbstractToolbarItemClasses extending AbstractToolbarItem can call this as a super() method after checking for their own keys, to avoid needing to deal with the nitty gritty of the toolbar button.- Specified by:
getAttributeValueStringin interfaceAutoConfigurable- Specified by:
getAttributeValueStringin interfaceTranslatable- Overrides:
getAttributeValueStringin classAbstractToolbarItem- Parameters:
key- the name of the attribute. Will be one of those listed ingetAttributeNames()- Returns:
- a String representation of the XML buildFile attribute with the given name. When initializing a module,
this String value will loaded from the XML and passed to
setAttribute(java.lang.String, java.lang.Object). It is also frequently used for checking the current value of an attribute.
-
build
Builds the map's component hierarchy from a given XML element, or a null one is given initializes a brand new default "new map" hierarchy.- Specified by:
buildin interfaceBuildable- Overrides:
buildin classAbstractBuildable- Parameters:
e- XML element to build from, or null to build the default hierarchy for a brand new Map
-
setBoardPicker
Every map must include a singleBoardPickeras one of its build components. This will contain the map'sBoard(or Boards), which will in turn contain any grids, zones, and location information.- Parameters:
picker- BoardPicker to register to the map. This method unregisters any previous BoardPicker.
-
getBoardPicker
Every map must include aBoardPickeras one of its build components. This contains the map'sBoard(or Boards), which will in turn contain any grids, zones, and location information.- Returns:
- the BoardPicker for this map (if none exist, this method will add one and return it)
-
setZoomer
A map may include a singleZoomeras one of its build components. This adds zoom in/out capability to the map.- Parameters:
z-Zoomerto register
-
getZoomer
A map may include aZoomeras one of its build components. This adds zoom in/out capability to the map.- Returns:
- the Zoomer for this map, if one is registered, or null if none.
-
getZoom
public double getZoom()If the map has aZoomer(seesetZoomer(VASSAL.build.module.map.Zoomer)), then returns the Zoomer's current zoom factor. If no Zoomer exists, returns 1.0 as the zoom factor.- Returns:
- the current zoom factor for the map
-
setStackMetrics
Every map must include a singleStackMetricsas one of its build components, which governs the visuals of stacking of GamePieces on the map.- Parameters:
sm-StackMetricscomponent to register
-
getStackMetrics
Every map must include a singleStackMetricsobject as one of its build components, which governs the visuals of stacking of GamePieces on the map- Returns:
- the StackMetrics for this map
-
setPieceMover
Every map must include a singlePieceMovercomponent as one of its build components, which handles drag-and-drop behavior for the map.- Parameters:
mover-PieceMovercomponent to register
-
getPieceMover
- Returns:
- Our pieceMover
-
getToolBar
Every map window has a toolbar, and this method returns swing toolbar component for this map.- Specified by:
getToolBarin interfaceToolBarComponent- Returns:
- the swing toolbar component (
JToolBarfor this map's window.
-
addDrawComponent
Registers aDrawablecomponent to this map. Components can implement theDrawableinterface (and register themselves here) if they have a graphical component that should be drawn whenever the Map is drawn. Standard examples includeCounterDetailViewers (aka Mouse-over Stack Viewers),GlobalMaps (aka Overview Maps),LOS_Threads,MapShaders, and theKeyBufferer(to show which pieces are selected). -
removeDrawComponent
Unregister aDrawablecomponent from this map -
getKeyBufferer
- Returns:
- KeyBufferer (if any) for this map.
-
setKeyBufferer
Registers the keyBufferer for this map (old way of scanning through components to find one is silly)- Parameters:
kb- KeyBufferer
-
getDescription
- Specified by:
getDescriptionin interfaceComponentDescription- Returns:
- Map's description field
-
addTo
Registers this Map as a child of another buildable component, usually theGameModule. Determines a unique id for this Map. Registers itself asKeyStrokeSource. Registers itself as aGameComponent. Registers itself as a drop target and drag source. If the map is to be removed or otherwise shutdown, it can be deregistered, reversing this process, byremoveFrom(VASSAL.build.Buildable)- Specified by:
addToin interfaceBuildable- Overrides:
addToin classAbstractToolbarItem- Parameters:
b- parent Buildable to add this component to as a subcomponent.- See Also:
-
removeFrom
Unregisters this Map from itsBuildableparent (usually aGameModule), reversing the process ofaddTo(VASSAL.build.Buildable).- Specified by:
removeFromin interfaceConfigurable- Overrides:
removeFromin classAbstractToolbarItem- Parameters:
b- parentBuildableto deregister from
-
sideChanged
Takes action when the local player has switched sides. Because Map implementsPlayerRoster.SideChangeListener, this method will automatically be called whenever the local player switches sides.- Specified by:
sideChangedin interfacePlayerRoster.SideChangeListener- Parameters:
oldSide- side the local player is switching away fromnewSide- side the local player is switching to
-
setBoards
Set the boards for this map. Each map may contain more than oneBoard.- Parameters:
c- Collection of Boards to be used.
-
findBoard
Since a map can have multiple boards in use at once (laid out above and beside each other), this method accepts aPointin the map's coordinate space and will return theBoardwhich contains that point, or null if none.- Returns:
- the
Boardon this map containing the argument point
-
findZone
If the given point in the map's coordinate space is within aZoneon a board with aZonedGrid(aka Multi-zoned Grid), returns the Zone. Otherwise returns null.- 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, or null if not found
-
findRegion
Search on all boards for a Region (location on an Irregular Grid) with the given name- Parameters:
name- Region name- Returns:
- Located region, or null if none
-
getMaxPixelsPerRangeUnit
-
getBoardByName
Searches our list of boards for one with the given name- Parameters:
name- Board Name- Returns:
- located board, or null if no such board found
-
getPreferredSize
- Returns:
- Dimension for map window's "preferred size"
-
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
-
snapTo
-
snapTo
-
getEdgeBuffer
- Returns:
- 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:
-
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:
-
componentRectangle
Deprecated, for removal: This API element is subject to removal in a future version. -
scale
protected int scale(int c, double zoom) Scales an integer value to a zoom factor- Parameters:
c- value to be scaledzoom- zoom factor- Returns:
- scaled value result
-
scale
Scales a point to a zoom factor- Parameters:
p- point to be scaledzoom- zoom factor- Returns:
- scaled point result
-
scale
Scales a Rectangle to a zoom factor- Parameters:
r- Rectangle to be zoomedzoom- zoom factor- Returns:
- scaled Rectangle result
-
mapToDrawing
public int mapToDrawing(int c, double os_scale) Converts an integer value from the Map's coordinate system to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Drawing a line between two points on a map (seeLOS_Thread.draw(java.awt.Graphics, VASSAL.build.module.Map). Drawing a piece on the map (seeStackMetrics.draw(VASSAL.counters.Stack, java.awt.Graphics, int, int, java.awt.Component, double).- Parameters:
c- value in Map coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration().getDefaultTransform().getScaleX())- Returns:
- scaled value in Drawing coordinate space
-
mapToDrawing
Converts a point from the Map's coordinate system to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Drawing a line between two points on a map (seeLOS_Thread.draw(java.awt.Graphics, VASSAL.build.module.Map). Drawing a piece on the map (seeStackMetrics.draw(VASSAL.counters.Stack, java.awt.Graphics, int, int, java.awt.Component, double).- Parameters:
p- point in Map coordinates to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled point in Drawing coordinates
-
mapToDrawing
Converts a rectangle from the Map's coordinate system to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Drawing a line between two points on a map (seeLOS_Thread.draw(java.awt.Graphics, VASSAL.build.module.Map). Drawing a piece on the map (seeStackMetrics.draw(VASSAL.counters.Stack, java.awt.Graphics, int, int, java.awt.Component, double).- Parameters:
r- rectangle in Map coordinates to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* * .getDefaultTransform()* * .getScaleX())- Returns:
- scaled rectangle in Drawing coordinates
-
mapToComponent
public int mapToComponent(int c) Converts an integer value from the Map's coordinate system to Component coordinates used for interactions between swing components. Basically this scales by the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: activating a popup menu at a piece's location on a map (see MenuDisplayer#maybePopup). Drag and drop operations (see dragGestureRecognizedPrep inPieceMover).- Parameters:
c- value in Map coordinate system to scale- Returns:
- scaled value in Component coordinate system
-
mapToComponent
Converts a Point from the Map's coordinate system to Component coordinates used for interactions between swing components. Basically this scales by the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: activating a popup menu at a piece's location on a map (see MenuDisplayer#maybePopup). Drag and drop operations (see dragGestureRecognizedPrep inPieceMover).- Parameters:
p- Point in Map coordinates to scale- Returns:
- scaled Point in Component coordinates
-
mapToComponent
Converts a Rectangle from the Map's coordinate system to Component coordinates used for interactions between swing components. Basically this scales by the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: activating a popup menu at a piece's location on a map (see MenuDisplayer#maybePopup). Drag and drop operations (see dragGestureRecognizedPrep inPieceMover).- Parameters:
r- Rectangle in Map coordinates to scale- Returns:
- scaled Rectangle in Component coordinates
-
componentToDrawing
public int componentToDrawing(int c, double os_scale) Converts an integer value from Component coordinates system to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not. Examples: seeFootprint.draw(java.awt.Graphics, int, int, java.awt.Component, double)- checking a map component's "visible" clipping rect, and using it in the context of drawing move trails.- Parameters:
c- value in Component coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled value in Drawing coordinate space
-
componentToDrawing
Converts a Point from Component coordinates to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not. Examples: seeFootprint.draw(java.awt.Graphics, int, int, java.awt.Component, double)- checking a map component's "visible" clipping rect, and using it in the context of drawing move trails.- Parameters:
p- Point in Component coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled Point in Drawing coordinate space
-
componentToDrawing
Converts a Rectangle from Component coordinates to Drawing coordinates for rendering. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not. Examples: seeFootprint.draw(java.awt.Graphics, int, int, java.awt.Component, double)- checking a map component's "visible" clipping rect, and using it in the context of drawing move trails.- Parameters:
r- Rectangle in Component coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled Rectangle in Drawing coordinate space
-
componentToMap
public int componentToMap(int c) Converts an integer value from swing Component coordinates to the Map's coordinate system. Basically this scales by the inverse of the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Checking if the mouse is currently overlapping a game pieceKeyBufferer.mouseReleased(MouseEvent), CounterDetailViewer#getDisplayablePieces.- Parameters:
c- value in Component coordinates to scale- Returns:
- scaled value in Map coordinates
-
componentToMap
Converts a Point from swing Component coordinates to the Map's coordinate system. Basically this scales by the inverse of the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Checking if the mouse is currently overlapping a game pieceKeyBufferer.mouseReleased(MouseEvent), CounterDetailViewer#getDisplayablePieces.- Parameters:
p- Point in Component coordinates to scale- Returns:
- scaled Point in Map coordinates
-
componentToMap
Converts a Rectangle from swing Component coordinates to the Map's coordinate system. Basically this scales by the inverse of the map's zoom factor. Note that although drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not. Examples: Checking if the mouse is currently overlapping a game pieceKeyBufferer.mouseReleased(MouseEvent), CounterDetailViewer#getDisplayablePieces.- Parameters:
r- Rectangle in Component coordinates to scale- Returns:
- scaled Rectangle in Map coordinates
-
drawingToMap
public int drawingToMap(int c, double os_scale) Converts an integer value from Drawing coordinates to the Map's coordinate system. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor, scaling by the inverse of both of these scale factors. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not.- Parameters:
c- value in Drawing coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled value in Map coordinates
-
drawingToMap
Converts a Point from Drawing coordinates to the Map's coordinate system. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor, scaling by the inverse of both of these scale factors. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not.- Parameters:
p- Point in Drawing coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled point in Map coordinates
-
drawingToMap
Converts a Rectangle from Drawing coordinates to the Map's coordinate system. Takes into account the operating system's scale factor (needed to deal with HiDPI monitors) as well as the Map's zoom factor, scaling by the inverse of both of these scale factors. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with component coordinates, on HiDPI monitors it will not.- Parameters:
r- Rectangle in Drawing coordinate space to be scaledos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled Rectangle in Map coordinates
-
drawingToComponent
public int drawingToComponent(int c, double os_scale) Converts an integer value from Drawing coordinates to swing Component coordinates. Takes into account the inverse of the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not.- Parameters:
c- value in Drawing coordinatesos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled value in Component coordinates
-
drawingToComponent
Converts a Point from Drawing coordinates to swing Component coordinates. Takes into account the inverse of the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not.- Parameters:
p- Point in Drawing coordinatesos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled Point in Component coordinates
-
drawingToComponent
Converts a Rectangle from Drawing coordinates to swing Component coordinates. Takes into account the inverse of the operating system's scale factor (needed to deal with HiDPI monitors), which accounts entirely for the difference in these two coordinate systems. Although Drawing coordinates may sometimes have the traditional 1-to-1 relationship with Component coordinates, on HiDPI monitors it will not.- Parameters:
r- Rectangle in Drawing coordinatesos_scale- Operating system's scale factor, (obtained fromgetDeviceConfiguration()* .getDefaultTransform()* .getScaleX())- Returns:
- scaled Rectangle in Component coordinates
-
locationName
-
localizedLocationName
-
isVisibleToAll
public boolean isVisibleToAll()Is this map visible to all players?- Returns:
- true if this map either (a) isn't a
PrivateMapor (b) does have its visible-to-all flag set
-
getDeckNameContaining
- Returns:
- the name of the
Deckwhose bounding box contains point p
-
getDeckNameAt
Return the name of theDeckwhose position is precisely p- Parameters:
p- Point to look for Deck- Returns:
- Name of
Deckwhose position is precisely p
-
getLocalizedDeckNameAt
Return the localized name of theDeckwhose position is precisely p- Parameters:
p- Point to look for Deck- Returns:
- Name of
Deckwhose position is precisely p
-
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.- Parameters:
l- MouseListener to add
-
addLocalMouseListenerFirst
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.- Parameters:
l- MouseListener to add
-
removeLocalMouseListener
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.- Parameters:
l- MouseListener to add
-
pushMouseListener
MouseListeners on a map may be pushed and popped onto a stack. Only the top listener on the stack receives mouse events.- Parameters:
l- MouseListener to push onto stack.
-
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. The pop method removes the most recently pushed mouse listener. -
popMouseListener
Remove the most recently pushed mouse listener only if it is the supplied listener- Parameters:
l- Listener
-
mouseEntered
- Specified by:
mouseEnteredin interfaceMouseListener- Parameters:
e- MouseEvent
-
mouseExited
- Specified by:
mouseExitedin interfaceMouseListener- Parameters:
e- MouseEvent
-
translateEvent
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.- Parameters:
e- MouseEvent in Component coordinates- Returns:
- MouseEvent translated into Map coordinates
-
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- Parameters:
e- MouseEvent from system- See Also:
-
setActiveMap
Marks an ActiveMap for certain drag and drop operations, so that the map can be repainted when the operation is complete.- Parameters:
m- Map to be considered active.
-
clearActiveMap
public static void clearActiveMap()Repaints the current ActiveMap (seesetActiveMap(VASSAL.build.module.Map)) and unmarks it. -
mousePressed
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:
mousePressedin interfaceMouseListener- Parameters:
e- MouseEvent from system- See Also:
-
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- Parameters:
e- MouseEvent from system- See Also:
-
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:
-
getDragGestureListener
- Returns:
- current dragGestureListener that handles normal drag events (assuming no MouseListeners are on the stack)
- See Also:
-
dragEnter
- Specified by:
dragEnterin interfaceDropTargetListener- Parameters:
dtde- DropTargetDragEvent
-
isNotPieceDrag
-
dragOver
Handles scrolling when dragging an gamepiece to the edge of the window- Specified by:
dragOverin interfaceDropTargetListener- Parameters:
dtde- DropTargetDragEvent
-
dropActionChanged
- Specified by:
dropActionChangedin interfaceDropTargetListener- Parameters:
dtde- DropTargetDragEvent
-
dragExit
- Specified by:
dragExitin interfaceDropTargetListener
-
drop
We put the "drop" in drag-n-drop!- Specified by:
dropin interfaceDropTargetListener- Parameters:
dtde- DropTargetDragEvent
-
mouseMoved
Mouse motion events are not forwarded to LocalMouseListeners or to listeners on the stack- Specified by:
mouseMovedin interfaceMouseMotionListener- Parameters:
e- MouseEvent from system
-
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- Parameters:
e- MouseEvent from system
-
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) Repaints the map. Accepts parameter about whether to clear the display first.- Parameters:
cf- true if display should be cleared before drawing the map
-
repaint
public void repaint()Repaints the map. -
paintRegion
Paints a specific region of the map, denoted by a Rectangle.- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaint
-
paintRegion
Paints a specific region of the map, denoted by a Rectangle.- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaintc- observer component
-
drawBoardsInRegion
For each Board overlapping the given region, update the appropriate section of the board image.- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaintc- observer component
-
drawBoardsInRegion
For each Board overlapping the given region, update the appropriate section of the board image.- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaint
-
drawPiecesInRegion
Draws all pieces visible in a rectangular area of the map- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaintc- observer component
-
drawPiecesInRegion
Draws all pieces visible in a rectangular area of the map- Parameters:
g- Graphics object where map should be paintedvisibleRect- region of map to repaint
-
drawPieces
Draws the map pieces at a given offset- Parameters:
g- Target graphics objectxOffset- x offsetyOffset- y offset
-
drawDrawable
Draws all of our "Drawable" components. Standard examples includeCounterDetailViewers (aka Mouse-over Stack Viewers),GlobalMaps (aka Overview Maps),LOS_Threads,MapShaders, and theKeyBufferer(to show which pieces are selected).- Parameters:
g- target graphics objectaboveCounters- true means we should draw only the drawables that go above the counters; false means we should draw only the ones that go below
-
getHighlighter
- Returns:
- Current selection highlighter
-
setHighlighter
- Parameters:
h- selection highlighter to set active
-
addHighlighter
- Parameters:
h- selection highlighter to add to our list
-
removeHighlighter
- Parameters:
h- selection highlighter to remove from our list
-
getHighlighters
- Returns:
- an Iterator for all of our highlighters
-
getBoards
- Returns:
- a Collection of all
Boards on the Map
-
getBoardCount
public int getBoardCount()- Returns:
- number of Boards on this map
-
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:
-
selectionBoundsOf
- Returns:
- the selection bounding box of a GamePiece accounting for the offset of a piece within a stack
- See Also:
-
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, subject to visibility, and sorted in order of visual layers. This is a read-only copy. Altering the array does not alter the pieces on the map.
-
getAllPieces
- Returns:
- an array of all GamePieces on the map, regardless of visibility, and sorted in order of visual layer. This is a read-only copy. Altering the array does not alter the pieces on the map.
-
setPieceCollection
- Parameters:
pieces- Sets the PieceCollection for this map (usually a LayeredPieceCollection a/k/a "Game Piece Layer Control"), which keeps the pieces/stacks/decks sorted by visual layer, and within each layer by back-to-front draw order
-
getPieceCollection
- Returns:
- piece collection for this map (a/k/a its LayeredPieceCollection or "Game Piece Layer Control"), which maintains a list of all the pieces/stacks/decks on the map sorted by visual layer, and within each layer by back-to-front draw order
-
clearMapBorder
Clears the map border region, if any. If theclearFirstflag is set, wipe the map image too.- Parameters:
g- target graphics object
-
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
Gets the location of a board in Map space, based on a passed zoom factor- Parameters:
b- Board to find locationzoom- zoom factor to use- Returns:
- Relative position of the board at given scale
-
getLocation
Finds the location of a board (in Map space) at a particular column and row, based on passed zoom factor- Parameters:
column- number of board to findrow- number of board to findzoom- zoom factor to use- Returns:
- location of the board in Map space
-
getLocation2D
-
getLocation2D
-
drawBoards
Draw the boards of the map at the given point and zoom factor onto the given Graphics object- Parameters:
g- target Graphics objectxoffset- x offset to draw atyoffset- y offset to draw atzoom- zoom factor for drawing the boardsobs- observer Component
-
repaint
Repaint the given area, specified in map coordinates- Parameters:
r- Rectangle specifying region to repaint in map coordinates
-
setPiecesVisible
public void setPiecesVisible(boolean show) -
isPiecesVisible
public boolean isPiecesVisible()- Returns:
- true if
GamePieces should be drawn when painting the map
-
getPieceOpacity
public float getPieceOpacity()- Returns:
- current pieceOpacity for drawing
-
setPieceOpacity
public void setPieceOpacity(float pieceOpacity) - Parameters:
pieceOpacity- sets opacity for piece drawing, 0 to 1.0
-
getProperty
Gets the value of a map-level global property. If a "Global Property" entry is not found at the map level, then module-level properties are checked, which includes identification information for the local player.- Specified by:
getPropertyin interfacePropertySource- Parameters:
key- identifies the global property to be returned- Returns:
- value of designated global property
-
getLocalizedProperty
Gets the value of map-level global property, or a module-level one if a map-level one is not found. The localized aspect presently only applies to permanent module-level objects which can be localized (e.g. player sides)- Specified by:
getLocalizedPropertyin interfacePropertySource- Parameters:
key- Name of the property to get the value of- Returns:
- Localized/translated name of the named property, if one is available, otherwise returns the non-localized name
-
getPropertyNames
Description copied from class:AbstractBuildableOverride this method to provide a list of properties to be exposed for use by expressions in the module.- Specified by:
getPropertyNamesin interfacePropertyNameSource- Overrides:
getPropertyNamesin classAbstractBuildable- Returns:
- Default implementation of PropertyNameSource - No properties exposed
-
getMoveKey
Return the apply-on-move key. It may be named, so just return the allocated KeyStroke.- Returns:
- apply-on-move keystroke
-
createParentFrame
Creates the top-level window for this map. Could be a JDialog or a JFrame depending on whether we are set to use a single window or have our own window.- Returns:
- the top-level window containing this map
-
isFirstMap
public boolean isFirstMap() -
shouldDockIntoMainWindow
public boolean shouldDockIntoMainWindow()If this map shows with its own special button, it does not dock into the main window. Likewise if we have no combined window setting. Otherwise the *first* non-button-launched map we find will be the one we dock.- Returns:
- whether this map should dock into the main window
-
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- Overrides:
setupin classAbstractToolbarItem- Parameters:
show- true if a game is starting, false if a game is ending- See Also:
-
getRestoreCommand
As aGameComponent, Map does not have any action inherently needing to be taken for "restoring" itself for load/save and network play purposes (the locations of pieces, etc, are stored in the pieces, and are restored fromGameStatein itsGameState.getRestorePiecesCommand()method, which creates an AddPiece command for each piece). Map's interest in GameComponent is entirely for game start/stop purposes (seesetup(boolean), above).- Specified by:
getRestoreCommandin interfaceGameComponent- Overrides:
getRestoreCommandin classAbstractToolbarItem- Returns:
- null since no restore command needed.
-
appendToTitle
Deprecated, for removal: This API element is subject to removal in a future version.useupdateTitleBar()- Parameters:
s- String to append to title
-
updateTitleBar
public void updateTitleBar()Updates the title bar of the current window -
getDefaultWindowTitle
- Returns:
- The correct current default window title
-
findPiece
Use the providedPieceFinderinstance to locate a visible piece at the given location- Parameters:
pt- Point at which to find visible piecesfinder- PieceFinder to use- Returns:
- a visible piece at the given location, or null if none.
-
findAnyPiece
Use the providedPieceFinderinstance to locate any piece at the given location, regardless of whether it is visible or not.- Parameters:
pt- Point at which to find piecesfinder- PieceFinder to use- Returns:
- a piece at the given location, regardless of visibility, or null if none.
-
placeAt
Place a piece at the destination point. If necessary, remove the piece from its parent Stack or Map- Parameters:
piece- GamePiece to placept- location to place the piece- Returns:
- a
Commandthat reproduces this action
-
apply
Attempts to apply the providedPieceVisitorDispatcherto all pieces on this map, until it finds one that returns a non-null Command.- Parameters:
commandFactory- The PieceVisitorDispatcher to apply- Returns:
- the first non-null
Commandreturned bycommandFactory
-
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 into aStackwith the piece by forwarding toStackMetrics.merge(VASSAL.counters.GamePiece, VASSAL.counters.GamePiece). Otherwise, place by forwarding to placeAt()- Parameters:
p- GamePiece to place/mergept- Point location on the map to place/merge the piece.- Returns:
- a
Commandthat will duplicate this action on other clients - See Also:
-
addPiece
Adds a GamePiece to this map's list of pieces. Removes the piece from its parent Stack and from its current map, if different from this map.- Parameters:
p- Game Piece to add
-
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- Parameters:
s- GamePiece to find the index of- Returns:
- index of the piece on the map, or -1 if the piece is not on this map
-
removePiece
Removes a piece from the map- Parameters:
p- GamePiece to remove from map
-
updateCenter
public void updateCenter()Accepts the current actual center of the map as the new "preferred center" (e.g. if we scroll) Just not if suppressed after a zoom level change (we don't want zoom level changes to cause us to lose track of the user's preferred ceter point) -
getPreferredCenter
- Returns:
- last location the player has requested to be the center of the map (eg by manually clicking or scrolling)
-
centerAt
Center the map at given map coordinates within its JScrollPane container- Parameters:
p- Point to center
-
centerAt
Center the map at the given map coordinates, if the point is not already within (dx,dy) of the center.- Parameters:
p- point to centerdx- x tolerance for nearness to centerdy- y tolerance for nearness to center
-
getVisibleRect
- Returns:
- the current visible rect of our map
-
getCenter
- Returns:
- the point our map's view is currently centered on
-
ensureVisible
Ensure that the given region (in map coordinates) is visible. Uses player preference to determine how sensitive to be about when to re-center.- Parameters:
r- Rectangle demarking region to ensure 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
Gets the generic name for this type of class across all instances of it. Appears in the Editor window in [..] as e.g. [Map], [Prototype], etc.- Returns:
- The generic name for this kind of component, i.e. the part appearing [In Brackets] in the Editor's
ConfigureTree.
-
getMapName
- Returns:
- the name of this map, for internal purposes
-
getLocalizedMapName
- Returns:
- the localized name of this map, for display purposes
-
setMapName
- Parameters:
s- Sets the name of the map.
-
getHelpFile
- Specified by:
getHelpFilein interfaceConfigurable- Returns:
- a HelpFile describing how to use and configure this component
-
getAttributeDescriptions
Description copied from class:AbstractToolbarItemThis getAttributeDescriptions() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeDescriptions(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeDescriptionsin interfaceAutoConfigurable- Overrides:
getAttributeDescriptionsin classAbstractToolbarItem- 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() - See Also:
-
getAttributeNames
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:
getAttributeNamesin interfaceAutoConfigurable- Overrides:
getAttributeNamesin classAbstractToolbarItem- Returns:
- a list of all buildFile (XML) attribute names for this component
- See Also:
-
getAttributeTypes
Description copied from class:AbstractToolbarItemThis getAttributeTypes() will return the items specific to the Toolbar Button - classes extending this should add their own items as well. If the "nameKey" is blank, then no "name" configure entry will be generated. Extending classes can use ArrayUtils.addAll(super.getAttributeTypes(), key1, ..., keyN), or supply their own order from scratch.- Specified by:
getAttributeTypesin interfaceAutoConfigurable- Overrides:
getAttributeTypesin classAbstractToolbarItem- Returns:
- 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 of
AutoConfigurerwill 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() - See Also:
-
getCreateFormat
- Returns:
- "created on map" format string
-
getChangeFormat
- Returns:
- "changed on map" format string
-
getChangeFormat
- Returns:
- "changed on map" format string
-
getMoveToFormat
- Returns:
- "moved to map" format string
-
getMoveWithinFormat
- Returns:
- "moved within map" format string
-
getAllowableConfigureComponents
List of subcomponents which can be added to a Map.- Specified by:
getAllowableConfigureComponentsin interfaceConfigurable- Returns:
- 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 Editor's
ConfigureTreewindow by right-clicking on the component and selecting the appropriate "Add" option. - See Also:
-
getAttributeVisibility
Description copied from class:AbstractConfigurableBy default, all attributes are visible- Specified by:
getAttributeVisibilityin interfaceAutoConfigurable- Overrides:
getAttributeVisibilityin classAbstractToolbarItem- Parameters:
name- Name (key) of one of this component's attributes- Returns:
- Visibility condition for the corresponding component
-
setId
Each Map must have a unique String id Sets our unique ID (among Maps), so that e.g. commands sent to different maps don't inadvertently get confused when we send commands to other clients.- Specified by:
setIdin interfaceUniqueIdManager.Identifyable- Parameters:
id- Sets our unique ID
-
getId
Each Map must have a unique String id- Specified by:
getIdin interfaceUniqueIdManager.Identifyable- Returns:
- the id for this map
-
getMapById
Find the map that corresponds to a known unique id- Parameters:
id- unique id of the map to find- Returns:
- Map object corresponding to that unique id
-
getMapList
Utility method to return aListof all map components (on all maps!) in the module.- Returns:
- the list of
Maps components
-
getMutableProperty
Find a contained Global Property (variable) by name. Does NOT search at the Module level.- Specified by:
getMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
name- Name of Global Property to find- Returns:
- Mutable property corresponding to the name given
-
addMutableProperty
Adds a new Global Property to this map.- Specified by:
addMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
key- Name of the new propertyp- The property object to add
-
removeMutableProperty
Removes a new Global Property from this map.- Specified by:
removeMutablePropertyin interfaceMutablePropertiesContainer- Parameters:
key- Name of the property to be removed- Returns:
- the object just removed
-
getMutablePropertiesContainerId
Description copied from interface:MutablePropertiesContainerReturn a unique Id for the container- Specified by:
getMutablePropertiesContainerIdin interfaceMutablePropertiesContainer- Returns:
- The container ID for map-level Global Properties on this object (just uses the map name)
-
getIdentifier
Make a best guess for a unique identifier for the target. UseUniqueIdManager.Identifyable.getConfigureName()if non-null, otherwise useUniqueIdManager.Identifyable.getId()- Returns:
- Unique Identifier
-
setUpView
public void setUpView()Common view setup code for Map and PrivateMap, which confusingly have different View classes that sharing the same name -
getView
- Returns:
- the Swing component representing the map
-
getLayeredPane
- Returns:
- the JLayeredPane holding map insets
-
getFormattedStringList
- Specified by:
getFormattedStringListin interfaceSearchTarget- Overrides:
getFormattedStringListin classAbstractConfigurable- Returns:
- a list of any Message Format strings referenced in the Configurable, if any (for search)
-
getMenuTextList
- Specified by:
getMenuTextListin interfaceSearchTarget- Overrides:
getMenuTextListin classAbstractToolbarItem- Returns:
- a list of any Menu/Button/Tooltip Text strings referenced in the Configurable, if any (for search)
-
getNamedKeyStrokeList
- Specified by:
getNamedKeyStrokeListin interfaceSearchTarget- Overrides:
getNamedKeyStrokeListin classAbstractToolbarItem- Returns:
- a list of any Named KeyStrokes referenced in the Configurable, if any (for search)
-
addLocalImageNames
In case reports use HTML and refer to any image files- Specified by:
addLocalImageNamesin interfaceImageSearchTarget- Overrides:
addLocalImageNamesin classAbstractToolbarItem- Parameters:
s- Collection to add image names to
-