Gridarta Editor
AbstractMapCursorAction.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.action;
21 
22 import java.awt.Point;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
33 
38 public abstract class AbstractMapCursorAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapCursorListener<G, A, R>, MapViewManagerListener<G, A, R> {
39 
43  @Nullable
45 
51  @Nullable
53  final MapView<G, A, R> mapView = currentMapView;
54  return mapView == null ? null : mapView.getMapCursor();
55  }
56 
61  @Nullable
63  return currentMapView;
64  }
65 
69  protected abstract void updateAction();
70 
71  @Override
72  public void activeMapViewChanged(@Nullable final MapView<G, A, R> mapView) {
73  currentMapView = mapView;
74  updateAction();
75  }
76 
80  @Override
81  public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) {
82  // ignore
83  }
84 
88  @Override
89  public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) {
90  // ignore
91  }
92 
93  @Override
94  public void mapCursorChangedPos(@NotNull final Point location) {
95  updateAction();
96  }
97 
98  @Override
99  public void mapCursorChangedMode() {
100  updateAction();
101  }
102 
106  @Override
107  public void mapCursorChangedGameObject(@Nullable final MapSquare<G, A, R> mapSquare, @Nullable final G gameObject) {
108  // ignore
109  }
110 
114  @Override
115  public void mapCursorChangedSize() {
116  // ignore
117  }
118 
119 }
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapmodel.MapSquare
A single Map Square.
Definition: MapSquare.java:45
net.sf
net.sf.gridarta.action.AbstractMapCursorAction.mapViewCreated
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
@noinspection NoopMethodInAbstractClass
Definition: AbstractMapCursorAction.java:81
http
daimonin editor devlib README txt This directory contains some files and libraries for development similar to indent for C http
Definition: README.txt:16
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.gui.map.mapview.MapViewManagerListener
Interface for listeners interested in events related to {} instances.
Definition: MapViewManagerListener.java:33
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.action.AbstractMapCursorAction.activeMapViewChanged
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
Definition: AbstractMapCursorAction.java:72
net.sf.gridarta.action.AbstractMapCursorAction.mapCursorChangedGameObject
void mapCursorChangedGameObject(@Nullable final MapSquare< G, A, R > mapSquare, @Nullable final G gameObject)
@noinspection NoopMethodInAbstractClass
Definition: AbstractMapCursorAction.java:107
net.sf.gridarta.model.mapcursor.MapCursorListener
Interface for listeners listening to MapCursor related events.
Definition: MapCursorListener.java:36
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.gui.map.mapview.MapView.getMapCursor
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
net.sf.gridarta.action.AbstractMapCursorAction.getActiveMapView
MapView< G, A, R > getActiveMapView()
Return the current map view.
Definition: AbstractMapCursorAction.java:62
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.action.AbstractMapCursorAction.mapCursorChangedSize
void mapCursorChangedSize()
@noinspection NoopMethodInAbstractClass
Definition: AbstractMapCursorAction.java:115
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.gui.map.mapview
Definition: AbstractMapView.java:20
net.sf.gridarta.gui.map.mapview.MapView
A map view consists of a map grid and a map cursor, and is attached to a map control.
Definition: MapView.java:43
net.sf.gridarta.action.AbstractMapCursorAction.updateAction
abstract void updateAction()
Called whenever the current map cursor has changed.
net.sf.gridarta.model.mapcursor.MapCursor
MapCursor provides methods to move and drag on map.
Definition: MapCursor.java:58
net.sf.gridarta.action.AbstractMapCursorAction
Abstract base class for actions that have to track the current map cursor.
Definition: AbstractMapCursorAction.java:38
net.sf.gridarta.action.AbstractMapCursorAction.getActiveMapCursor
MapCursor< G, A, R > getActiveMapCursor()
Return the map cursor of the current map view if it is active.
Definition: AbstractMapCursorAction.java:52
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.gui.map
Base classes for rendering maps.
Definition: AbstractPerMapDialogManager.java:20
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.mapcursor
Definition: MapCursor.java:20
net.sf.gridarta.action.AbstractMapCursorAction.currentMapView
MapView< G, A, R > currentMapView
The active map view, or.
Definition: AbstractMapCursorAction.java:44
net.sf.gridarta.action.AbstractMapCursorAction.mapCursorChangedPos
void mapCursorChangedPos(@NotNull final Point location)
This event handler is called when MapCursor has moved.
Definition: AbstractMapCursorAction.java:94
net.sf.gridarta.action.AbstractMapCursorAction.mapViewClosing
void mapViewClosing(@NotNull final MapView< G, A, R > mapView)
@noinspection NoopMethodInAbstractClass
Definition: AbstractMapCursorAction.java:89
net.sf.gridarta.action.AbstractMapCursorAction.mapCursorChangedMode
void mapCursorChangedMode()
This event handler is called when MapCursor changes mode (drag, select).
Definition: AbstractMapCursorAction.java:99