20 package net.sf.gridarta.gui.mapcursor;
22 import java.awt.Point;
24 import javax.swing.Action;
41 import net.
sf.japi.swing.action.ActionMethod;
42 import org.jetbrains.annotations.NotNull;
43 import org.jetbrains.annotations.Nullable;
49 public class MapCursorActions<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>> implements
EditorAction,
MapCursorListener<G, A, R>,
MapViewManagerListener<G, A, R> {
86 public void mapSizeChanged(@NotNull
final Size2D newSize) {
96 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
106 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
111 public void modifiedChanged() {
122 aMoveCursor =
new Action[DIRECTIONS.length];
194 for (
final Direction direction : DIRECTIONS) {
195 final Action action = aMoveCursor[direction.ordinal()];
196 if (action != null) {
210 if (mapView == null) {
215 if (!mapCursor.
goTo(performAction, direction)) {
216 if (!mapActions.
doEnterMap(performAction, direction)) {
219 }
else if (performAction) {
222 location.translate(BORDER * direction.getDx(), BORDER * direction.getDy());
230 public void setAction(@NotNull
final Action action, @NotNull
final String name) {
231 if (name.startsWith(
"moveCursor")) {
232 boolean found =
false;
233 for (
final Direction direction : DIRECTIONS) {
234 if (name.equals(
"moveCursor" + direction.getId())) {
235 aMoveCursor[direction.ordinal()] = action;
241 throw new IllegalArgumentException();
244 throw new IllegalArgumentException();
251 currentMapView = mapView;
257 mapView.getMapControl().getMapModel().addMapModelListener(mapModelListener);
262 mapView.getMapControl().getMapModel().removeMapModelListener(mapModelListener);
void mapCursorChangedMode()
This event handler is called when MapCursor changes mode (drag, select).
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
Rectangle getSquareBounds(@NotNull Point p)
Returns coordinates, length and width of map square.
void moveCursorNorth()
Action method for "move cursor north".
Graphical User Interface of Gridarta.
boolean doMoveCursor(final boolean performAction, @NotNull final Direction direction)
Executes the "move cursor" action.
This package contains the framework for validating maps.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
boolean doEnterMap(final boolean performAction, @NotNull final Direction direction)
Executes the "enter map" action.
Interface for listeners listening on MapModel events.
MapCursor provides methods to move and drag on map.
void mapCursorChangedGameObject(@Nullable final MapSquare< G, A, R > mapSquare, @Nullable final G gameObject)
Called whenever the selected game object has changed.
void mapViewClosing(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view is to be closed.
MapView< G, A, R > currentMapView
The active map view, or.
Point getLocation()
Get position of cursor.
final MapActions< G, A, R > mapActions
Base package of all Gridarta classes.
Reflects a game object (object on a map).
static final Direction [] DIRECTIONS
All Directions.
void moveCursorNorthEast()
Action method for "move cursor north east".
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view was created.
GameObjects are the objects based on Archetypes found on maps.
MapRenderer getRenderer()
Returns the MapRenderer for this view.
void mapCursorChangedSize()
Called whenever the map cursor's map grid size has changed.
Interface for listeners interested in events related to MapViewManager instances. ...
void moveCursorSouth()
Action method for "move cursor south".
void refreshActions()
Enable/disable menu entries based on the current cursor state.
void moveCursorSouthWest()
Action method for "move cursor south west".
Manages actions in the "map" menu.
Base classes for rendering maps.
void mapCursorChangedPos(@NotNull final Point location)
This event handler is called when MapCursor has moved.
void moveCursorEast()
Action method for "move cursor east".
final MapModelListener< G, A, R > mapModelListener
The map model listener used to detect map size changes in currentMapView.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
void moveCursorSouthEast()
Action method for "move cursor south east".
static final int BORDER
The visible border around the cursor.
void moveCursorNorthWest()
Action method for "move cursor north west".
A map view consists of a map grid and a map cursor, and is attached to a map control.
boolean goTo(final boolean performAction, @NotNull final Direction dir)
Moves the cursor one square relative to current position.
An interface for classes that collect errors.
Common interface for renderers of map control instances.
Interface for listeners listening to MapCursor related events.
void moveCursorWest()
Action method for "move cursor west".
final Action [] aMoveCursor
Actions for "move cursor".
The location of a map file with a map directory.
void scrollRectToVisible(@NotNull Rectangle aRect)
Ensures that a rectangular area is visible.
Interface for MapArchObjects.
The class Size2D represents a 2d rectangular area.
MapCursorActions(@NotNull final MapActions< G, A, R > mapActions)
Creates a new instance.