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-2015 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 }
MapCursor< G, A, R > getActiveMapCursor()
Return the map cursor of the current map view if it is active.
MapView< G, A, R > currentMapView
The active map view, or.
Graphical User Interface of Gridarta.
void mapCursorChangedGameObject(@Nullable final MapSquare< G, A, R > mapSquare, @Nullable final G gameObject)
NoopMethodInAbstractClass
void mapCursorChangedMode()
This event handler is called when MapCursor changes mode (drag, select).
MapCursor provides methods to move and drag on map.
Definition: MapCursor.java:57
void mapViewClosing(@NotNull final MapView< G, A, R > mapView)
NoopMethodInAbstractClass
abstract void updateAction()
Called whenever the current map cursor has changed.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
NoopMethodInAbstractClass
void mapCursorChangedPos(@NotNull final Point location)
This event handler is called when MapCursor has moved.
GameObjects are the objects based on Archetypes found on maps.
Interface for listeners interested in events related to MapViewManager instances. ...
Base classes for rendering maps.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
A map view consists of a map grid and a map cursor, and is attached to a map control.
Definition: MapView.java:43
Abstract base class for actions that have to track the current map cursor.
Interface for listeners listening to MapCursor related events.
MapView< G, A, R > getActiveMapView()
Return the current map view.
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.