 |
Gridarta Editor
|
Go to the documentation of this file.
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() {
194 final Action action =
aMoveCursor[direction.ordinal()];
195 if (action !=
null) {
209 if (mapView ==
null) {
214 if (!mapCursor.
goTo(performAction, direction)) {
218 }
else if (performAction) {
221 location.translate(
BORDER * direction.getDx(),
BORDER * direction.getDy());
229 public void setAction(@NotNull
final Action action, @NotNull
final String
name) {
230 if (
name.startsWith(
"moveCursor")) {
231 boolean found =
false;
233 if (
name.equals(
"moveCursor" + direction.getId())) {
240 throw new IllegalArgumentException(
"unsupported action name: " +
name);
243 throw new IllegalArgumentException(
"unsupported action name: " +
name);
256 mapView.getMapControl().getMapModel().addMapModelListener(
mapModelListener);
261 mapView.getMapControl().getMapModel().removeMapModelListener(
mapModelListener);
void refreshActions()
Enable/disable menu entries based on the current cursor state.
void moveCursorNorthWest()
Action method for "move cursor north west".
void moveCursorWest()
Action method for "move cursor west".
Base package of all Gridarta classes.
void mapCursorChangedMode()
This event handler is called when MapCursor changes mode (drag, select).
boolean doMoveCursor(final boolean performAction, @NotNull final Direction direction)
Executes the "move cursor" action.
void mapViewCreated(@NotNull final MapView< G, A, R > mapView)
This event handler is called when a map view was created.
Interface for listeners interested in events related to {} instances.
void moveCursorEast()
Action method for "move cursor east".
Reflects a game object (object on a map).
MapRenderer getRenderer()
Returns the MapRenderer for this view.
void moveCursorNorth()
Action method for "move cursor north".
Interface for listeners listening to MapCursor related events.
void scrollRectToVisible(@NotNull Rectangle aRect)
Ensures that a rectangular area is visible.
void mapCursorChangedPos(@NotNull final Point location)
This event handler is called when MapCursor has moved.
Graphical User Interface of Gridarta.
void moveCursorSouthEast()
Action method for "move cursor south east".
void moveCursorSouth()
Action method for "move cursor south".
boolean doEnterMap(final boolean performAction, @NotNull final Direction direction)
Executes the "enter map" action.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
GameObjects are the objects based on Archetypes found on maps.
boolean goTo(final boolean performAction, @NotNull final Direction dir)
Moves the cursor one square relative to current position.
Interface for MapArchObjects.
final Action[] aMoveCursor
Actions for "move cursor".
void mapCursorChangedSize()
Called whenever the map cursor's map grid size has changed.
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.
An interface for classes that collect errors.
Point getLocation()
Get position of cursor.
A map view consists of a map grid and a map cursor, and is attached to a map control.
This package contains the framework for validating maps.
MapCursor provides methods to move and drag on map.
Manages actions in the "map" menu.
The location of a map file with a map directory.
final MapModelListener< G, A, R > mapModelListener
The map model listener used to detect map size changes in {}.
Interface for listeners listening on MapModel events.
Rectangle getSquareBounds(@NotNull Point p)
Returns coordinates, length and width of map square.
void moveCursorSouthWest()
Action method for "move cursor south west".
static final int BORDER
The visible border around the cursor.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
Base classes for rendering maps.
static final Direction[] DIRECTIONS
All Directions.
MapCursorActions(@NotNull final MapActions< G, A, R > mapActions)
Creates a new instance.
void activeMapViewChanged(@Nullable final MapView< G, A, R > mapView)
This event handler is called when the current map view has changed.
MapView< G, A, R > currentMapView
The active map view, or.
Common interface for renderers of map control instances.
final MapActions< G, A, R > mapActions
The class Size2D represents a 2d rectangular area.
void moveCursorNorthEast()
Action method for "move cursor north east".