20 package net.sf.gridarta.action;
22 import java.awt.Point;
23 import java.util.IdentityHashMap;
24 import java.util.List;
26 import javax.swing.Action;
39 import net.
sf.japi.swing.action.ActionMethod;
40 import org.jetbrains.annotations.NotNull;
41 import org.jetbrains.annotations.Nullable;
70 public void mapGridChanged(@NotNull
final MapGridEvent e) {
75 public void mapGridResized(@NotNull
final MapGridEvent e) {
90 public void setAction(@NotNull
final Action action, @NotNull
final String name) {
112 if (currentMapView == null) {
122 if (selectedSquares.isEmpty()) {
129 final Point point =
new Point();
130 final Map<MapSquare<G, A, R>, Void> mapSquaresToShrink =
new IdentityHashMap<>();
135 for (
int dy = -1; dy <= 1; dy++) {
136 for (
int dx = -1; dx <= 1; dx++) {
137 if (dx != 0 || dy != 0) {
138 mapSquare.getMapLocation(point, dx, dy);
140 mapSquaresToShrink.put(mapSquare, null);
148 mapSquare.getMapLocation(point);
161 if (currentMapView != null) {
162 currentMapView.
getMapGrid().removeMapGridListener(mapGridListener);
164 currentMapView = mapView;
165 if (currentMapView != null) {
166 currentMapView.
getMapGrid().addMapGridListener(mapGridListener);
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
Rectangle getSelectedRec()
Returns the smallest rectangle containing selection.
List< MapSquare< G, A, R > > getSelectedSquares()
Returns the selected squares.
boolean isPointValid(@Nullable Point pos)
Checks whether the given coordinate is within map bounds.
A MapModel reflects the data of a map.
An EditorAction that shrinks the current selection by one map square.
Graphical User Interface of Gridarta.
final MapGridListener mapGridListener
The MapGridListener attached to currentMapView.
MapGrid getMapGrid()
Returns the MapGrid of this view.
int getFlags(final int x, final int y)
Returns the flags of a square.
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view was created.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
void shrinkSelection()
Grows the current map selection by one map square.
MapModel< G, A, R > getMapModel()
Returns the map model.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Interface for listeners listening to MapGridEvents.
boolean doShrinkSelection(final boolean performAction)
Shrinks the current map selection by one map square.
GameObjects are the objects based on Archetypes found on maps.
Interface for listeners interested in events related to MapViewManager instances. ...
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Base classes for rendering maps.
void beginTransaction()
Starts a new transaction.
Action action
The action associated with this editor action.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
MapView< G, A, R > currentMapView
The active map view, or.
void select(@NotNull final Point pos, @NotNull final SelectionMode selectionMode)
Selects or deselects a single square.
void endTransaction()
Ends a transaction.
A map view consists of a map grid and a map cursor, and is attached to a map control.
void updateAction()
Updates the action's enabled state.
Modes that describe how squares get selected.
static final int GRID_FLAG_SELECTION
Selection - marks all selected squares.
SUB
All squares that are preselected get unselected.
void mapViewClosing(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view is to be closed.
Interface for MapArchObjects.
This event is created by MapGrid.