Gridarta Editor
MapCursor.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.model.mapcursor;
21 
22 import java.awt.Dimension;
23 import java.awt.Point;
24 import java.awt.Rectangle;
25 import java.awt.geom.Rectangle2D;
26 import java.util.Collection;
27 import java.util.concurrent.CopyOnWriteArrayList;
39 import net.sf.gridarta.utils.Size2D;
40 import org.jetbrains.annotations.NotNull;
41 import org.jetbrains.annotations.Nullable;
42 
58 public class MapCursor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> {
59 
64  @NotNull
65  private final Point pos;
66 
70  @NotNull
71  private final Point dragStart = new Point();
72 
76  @NotNull
77  private final Dimension dragOffset = new Dimension();
78 
82  private boolean dragging;
83 
87  @NotNull
88  private final MapGrid mapGrid;
89 
93  @NotNull
94  private final MapModel<G, A, R> mapModel;
95 
99  @NotNull
100  private final Rectangle mapRec;
101 
106  @NotNull
107  private final Point tmpPoint = new Point();
108 
112  @Nullable
114 
118  @Nullable
119  private G gameObject;
120 
125  private int transactionDepth;
126 
131  @NotNull
132  private final Point transactionPos = new Point();
133 
138  private boolean transactionDragging;
139 
144  @Nullable
146 
151  @Nullable
153 
158  @NotNull
159  private final Rectangle2D transactionMapRec = new Rectangle();
160 
164  @NotNull
165  private final Collection<MapCursorListener<G, A, R>> listenerList = new CopyOnWriteArrayList<>();
166 
173  public MapCursor(@NotNull final MapGrid mapGrid, @NotNull final MapModel<G, A, R> mapModel) {
174  this.mapGrid = mapGrid;
175  this.mapModel = mapModel;
176  final Size2D gridSize = mapGrid.getGridSize();
177  mapRec = new Rectangle(0, 0, gridSize.getWidth(), gridSize.getHeight());
178  final A mapArchObject = mapModel.getMapArchObject();
179  pos = fixPoint(new Point(mapArchObject.getEnterX(), mapArchObject.getEnterY()));
180  final MapGridListener mapGridListener = new MapGridListener() {
181 
182  @Override
183  public void mapGridChanged(@NotNull final MapGridEvent e) {
184  // We can ignore this event. Normally this MapCursor has caused it.
185  }
186 
187  @Override
188  public void mapGridResized(@NotNull final MapGridEvent e) {
189  final Size2D newSize = mapGrid.getGridSize();
190  final int newWidth = newSize.getWidth();
191  final int newHeight = newSize.getHeight();
193  try {
194  mapRec.setSize(newWidth, newHeight);
195  // Test if drag start point is outside map -> move inside
196  if (dragging && !mapRec.contains(dragStart)) {
197  dragStart.x = Math.min(dragStart.x, mapRec.width - 1);
198  dragStart.y = Math.min(dragStart.y, mapRec.height - 1);
199  }
200  // Test if cursor position is outside map -> move inside
201  if (!mapRec.contains(pos)) {
202  pos.x = Math.min(pos.x, mapRec.width - 1);
203  pos.y = Math.min(pos.y, mapRec.height - 1);
204  selectMapSquare();
205  }
206  } finally {
207  endTransaction();
208  }
209  }
210 
211  };
212  mapGrid.addMapGridListener(mapGridListener);
215  try {
216  selectMapSquare();
217  } finally {
218  endTransaction();
219  }
220  }
221 
226  @NotNull
227  public Point getLocation() {
228  return new Point(pos);
229  }
230 
236  public void setLocation(@NotNull final Point p) {
238  try {
239  final Point effectivePoint = fixPoint(p);
240  if (!pos.equals(effectivePoint)) {
241  pos.setLocation(effectivePoint);
242  selectMapSquare();
243  }
244  } finally {
245  endTransaction();
246  }
247  }
248 
255  public boolean setLocationSafe(@Nullable final Point p) {
257  final boolean hasChanged;
258  try {
259  if (p != null && mapRec.contains(p)) {
260  if (pos.equals(p)) {
261  hasChanged = false;
262  } else {
263  pos.setLocation(p);
264  selectMapSquare();
265  hasChanged = true;
266  }
267  } else {
268  hasChanged = false;
269  }
270  } finally {
271  endTransaction();
272  }
273  return hasChanged;
274  }
275 
279  public void dragStart() {
280  if (!dragging) {
282  try {
283  dragStart.setLocation(pos);
285  dragging = true;
286  dragOffset.setSize(0, 0);
287  } finally {
288  endTransaction();
289  }
290  }
291  }
292 
299  public boolean dragTo(@Nullable final Point p) {
300  if (p != null && mapRec.contains(p) && dragging && !pos.equals(p)) {
302  try {
303  final Point oldPos = new Point(pos);
304  pos.setLocation(p);
305  selectMapSquare();
307  dragOffset.setSize(pos.x - dragStart.x, pos.y - dragStart.y);
308  } finally {
309  endTransaction();
310  }
311  return true;
312  }
313  return false;
314  }
315 
319  public void dragRelease() {
320  if (dragging) {
322  try {
324  dragging = false;
325  } finally {
326  endTransaction();
327  }
328  }
329  }
330 
338  public void dragSelect(@NotNull final SelectionMode selectionMode, final boolean forceSelect) {
339  if (dragging) {
341  try {
342  dragRelease();
343  if (forceSelect || !dragStart.equals(pos)) {
344  mapGrid.selectArea(dragStart, pos, selectionMode);
345  }
346  } finally {
347  endTransaction();
348  }
349  }
350  }
351 
355  public final void deactivate() {
357  try {
358  dragging = false;
359  mapGrid.unSelect();
360  } finally {
361  endTransaction();
362  }
363  }
364 
369  @Nullable
370  public Dimension getDragOffset() {
371  return dragging ? dragOffset : null;
372  }
373 
379  public boolean isOnGrid(@Nullable final Point p) {
380  return p != null && mapRec.contains(p);
381  }
382 
389  public boolean goTo(final boolean performAction, @NotNull final Direction dir) {
390  if (dir.getDx() == 0 && dir.getDy() == 0) {
391  return false;
392  }
393  tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy());
394  if (!mapRec.contains(tmpPoint)) {
395  return false;
396  }
397  if (performAction) {
398  if (dragging) {
399  dragTo(tmpPoint);
400  } else {
402  }
403  }
404  return true;
405  }
406 
411  public boolean isDragging() {
412  return dragging;
413  }
414 
419  public void addMapCursorListener(@NotNull final MapCursorListener<G, A, R> listener) {
420  listenerList.add(listener);
421  }
422 
427  public void removeMapCursorListener(@NotNull final MapCursorListener<G, A, R> listener) {
428  listenerList.remove(listener);
429  }
430 
436  @Nullable
437  public G getGameObject() {
438  return gameObject;
439  }
440 
446  public void setGameObject(@Nullable final G gameObject) {
448  try {
449  if (gameObject == null) {
450  this.gameObject = null;
451  } else {
452  final MapSquare<G, A, R> mapSquare = gameObject.getMapSquareOptional();
453  if (mapSquare != null && mapSquare.getMapModel() == mapModel) {
454  pos.setLocation(mapSquare.getMapX(), mapSquare.getMapY());
455  this.mapSquare = mapSquare;
456  this.gameObject = gameObject;
457  }
458  }
459  } finally {
460  endTransaction();
461  }
462  }
463 
469  public void setMapSquare(@Nullable final MapSquare<G, A, R> mapSquare) {
471  try {
472  if (mapSquare != null && mapSquare.getMapModel() == mapModel) {
473  pos.setLocation(mapSquare.getMapX(), mapSquare.getMapY());
474  this.mapSquare = mapSquare;
476  }
477  } finally {
478  endTransaction();
479  }
480  }
481 
488  public final void beginTransaction() {
489  if (transactionDepth == 0) {
490  transactionPos.setLocation(pos);
494  transactionMapRec.setRect(mapRec);
495  }
498  }
499 
506  public final void endTransaction() {
507  assert transactionDepth > 0;
509 
510  if (transactionDepth == 0) {
511  final boolean changedPos = !pos.equals(transactionPos) || mapSquare != transactionMapSquare;
512  final boolean changedMode = dragging != transactionDragging;
513  final boolean changedGameObject = mapSquare != transactionMapSquare || gameObject != transactionGameObject;
514  final boolean changedSize = !mapRec.equals(transactionMapRec);
515  if (!pos.equals(transactionPos)) {
518  }
519  if (changedMode) {
520  for (final MapCursorListener<G, A, R> listener : listenerList) {
521  listener.mapCursorChangedMode();
522  }
523  }
524  if (changedPos) {
525  for (final MapCursorListener<G, A, R> listener : listenerList) {
526  listener.mapCursorChangedPos(getLocation());
527  }
528  }
529  if (changedGameObject) {
530  for (final MapCursorListener<G, A, R> listener : listenerList) {
531  listener.mapCursorChangedGameObject(mapSquare, gameObject);
532  }
533  }
534  if (changedSize) {
535  for (final MapCursorListener<G, A, R> listener : listenerList) {
536  listener.mapCursorChangedSize();
537  }
538  }
539  }
540 
542  }
543 
548  private void selectMapSquare() {
549  assert transactionDepth > 0;
550  try {
552  } catch (final IndexOutOfBoundsException ignored) {
553  mapSquare = null;
554  }
556  }
557 
562  private void selectTopmostGameObject() {
563  assert transactionDepth > 0;
564  gameObject = mapSquare == null ? null : mapSquare.getLast();
565  }
566 
573  public boolean selectAbove(final boolean performAction) {
574  if (mapSquare == null || gameObject == null) {
575  return false;
576  }
577 
578  final G newGameObject = mapSquare.getPrev(gameObject);
579  if (newGameObject == null) {
580  return false;
581  }
582 
583  if (performAction) {
585  try {
586  gameObject = newGameObject;
587  } finally {
588  endTransaction();
589  }
590  }
591  return true;
592  }
593 
600  public boolean selectBelow(final boolean performAction) {
601  if (mapSquare == null || gameObject == null) {
602  return false;
603  }
604 
605  final G newGameObject = mapSquare.getNext(gameObject);
606  if (newGameObject == null) {
607  return false;
608  }
609 
610  if (performAction) {
612  try {
613  gameObject = newGameObject;
614  } finally {
615  endTransaction();
616  }
617  }
618  return true;
619  }
620 
631  public boolean insertGameObject(final boolean performAction, @NotNull final BaseObject<G, A, R, ?> gameObject, final boolean insertAtEnd, final boolean join) {
632  if (performAction) {
633  mapModel.beginTransaction("Insert"); // TODO; I18N/L10N
634  try {
635  final G insertedGameObject = mapModel.insertArchToMap(gameObject, insertAtEnd ? null : this.gameObject, pos, join);
636  if (insertedGameObject != null) {
638  try {
639  this.gameObject = insertedGameObject;
640  } finally {
641  endTransaction();
642  }
643  }
644  } finally {
646  }
647  }
648  return true;
649  }
650 
658  public boolean deleteSelectedGameObject(final boolean performAction, final boolean autoJoin) {
659  final G gameObject = this.gameObject;
660  if (gameObject == null) {
661  return false;
662  }
663 
665  if (mapSquare == null) {
666  return false;
667  }
668 
669  if (performAction) {
670  mapModel.beginTransaction("Delete"); // TODO; I18N/L10N
671  try {
672  G nextGameObject = mapSquare.getNext(gameObject);
674  if (nextGameObject == null) {
675  nextGameObject = mapSquare.getFirst();
676  }
677  if (nextGameObject != null) {
678  while (true) {
679  final G invGameObject = nextGameObject.getFirst();
680  if (invGameObject == null) {
681  break;
682  }
683  nextGameObject = invGameObject;
684  }
685  }
687  try {
688  this.gameObject = nextGameObject;
689  } finally {
690  endTransaction();
691  }
692  } finally {
694  }
695  }
696 
697  return true;
698  }
699 
705  @NotNull
706  private Point fixPoint(@NotNull final Point p) {
707  return mapRec.contains(p) ? p : new Point(Math.max(Math.min(p.x, mapRec.width - 1), 0), Math.max(Math.min(p.y, mapRec.height - 1), 0));
708  }
709 
710 }
net.sf.gridarta.model.mapmodel.MapModel.insertArchToMap
G insertArchToMap(@NotNull BaseObject< G, A, R, ?> templateBaseObject, @Nullable G nextGameObject, @NotNull Point pos, boolean join)
Insert a game object to the map at a specified position.
net.sf.gridarta.model.mapgrid.MapGrid.addMapGridListener
void addMapGridListener(@NotNull final MapGridListener listener)
Registers a MapGridListener.
Definition: MapGrid.java:190
net.sf.gridarta.model.mapmodel.MapSquare.getMapY
int getMapY()
Returns the y coordinate on the map.
Definition: MapSquare.java:115
net.sf.gridarta.utils.Size2D.getWidth
int getWidth()
Returns the width of the area.
Definition: Size2D.java:96
net.sf.gridarta.model.direction.Direction
A direction.
Definition: Direction.java:28
net.sf.gridarta.model.mapmodel.MapModel
A MapModel reflects the data of a map.
Definition: MapModel.java:75
net.sf.gridarta.model.mapcursor.MapCursor.mapModel
final MapModel< G, A, R > mapModel
The MapModel of this cursor.
Definition: MapCursor.java:94
net.sf.gridarta.model.mapcursor.MapCursor.tmpPoint
final Point tmpPoint
Temporary point used in some methods.
Definition: MapCursor.java:107
net.sf.gridarta.model.mapgrid.MapGrid.endTransaction
void endTransaction()
Ends a transaction.
Definition: MapGrid.java:776
net.sf.gridarta.model.mapmodel.MapModel.getMapArchObject
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
net.sf.gridarta.model.mapmodel.MapSquare.getLast
G getLast(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the last occurrence of a matching game object.
Definition: MapSquare.java:196
net.sf.gridarta.model.mapmodel.MapSquare.getMapX
int getMapX()
Returns the x coordinate on the map.
Definition: MapSquare.java:107
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapcursor.MapCursor.deactivate
final void deactivate()
Cursor gets deactivated.
Definition: MapCursor.java:355
net.sf.gridarta.model.mapmodel.MapSquare.getFirst
G getFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
Definition: MapSquare.java:230
net.sf.gridarta.model.mapmodel.MapSquare
A single Map Square.
Definition: MapSquare.java:45
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.model.mapcursor.MapCursor.dragSelect
void dragSelect(@NotNull final SelectionMode selectionMode, final boolean forceSelect)
Leave drag mode and select pre-selection using selectionMode.
Definition: MapCursor.java:338
net.sf.gridarta.model.mapcursor.MapCursor.mapRec
final Rectangle mapRec
Used to test if coordinates are on the map.
Definition: MapCursor.java:100
net.sf.gridarta.model.mapcursor.MapCursor.dragStart
final Point dragStart
Position where dragging has started.
Definition: MapCursor.java:71
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.model.mapgrid.MapGrid.updatePreSelect
void updatePreSelect(@NotNull final Point start, @NotNull final Point oldEnd, @NotNull final Point newEnd)
Update the pre-selection rectangle.
Definition: MapGrid.java:334
net.sf.gridarta.model.mapcursor.MapCursor.getGameObject
G getGameObject()
Returns the selected GameObject.
Definition: MapCursor.java:437
net.sf.gridarta.model.mapcursor.MapCursor.listenerList
final Collection< MapCursorListener< G, A, R > > listenerList
The MapCursorListeners to inform of changes.
Definition: MapCursor.java:165
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.model.mapcursor.MapCursor.mapSquare
MapSquare< G, A, R > mapSquare
The selected MapSquare.
Definition: MapCursor.java:113
net.sf.gridarta.model.mapcursor.MapCursor.transactionPos
final Point transactionPos
The value of pos at the start of the outermost map cursor transaction.
Definition: MapCursor.java:132
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.mapgrid.MapGrid.unSetCursor
void unSetCursor(@NotNull final Point pos)
Un-highlights the given cursor position.
Definition: MapGrid.java:276
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.mapcursor.MapCursorListener< G, A, R >
net.sf.gridarta.model.mapcursor.MapCursor.setGameObject
void setGameObject(@Nullable final G gameObject)
Sets the selected GameObject.
Definition: MapCursor.java:446
net.sf.gridarta.model.mapcursor.MapCursor.deleteSelectedGameObject
boolean deleteSelectedGameObject(final boolean performAction, final boolean autoJoin)
Deletes the selected game object.
Definition: MapCursor.java:658
net.sf.gridarta.model.mapcursor.MapCursor.gameObject
G gameObject
The selected GameObject.
Definition: MapCursor.java:119
net.sf.gridarta.model.mapcursor.MapCursor.transactionDragging
boolean transactionDragging
The value of dragging at the start of the outermost map cursor transaction.
Definition: MapCursor.java:138
net.sf.gridarta.model.mapcursor.MapCursor.setLocationSafe
boolean setLocationSafe(@Nullable final Point p)
Move cursor to a new location.
Definition: MapCursor.java:255
net.sf.gridarta.model.mapcursor.MapCursor.dragOffset
final Dimension dragOffset
Offset of dragging.
Definition: MapCursor.java:77
net.sf.gridarta.model.mapgrid.MapGrid.beginTransaction
void beginTransaction()
Starts a new transaction.
Definition: MapGrid.java:756
net.sf.gridarta.model.mapcursor.MapCursor.dragTo
boolean dragTo(@Nullable final Point p)
When in drag mode and the point is on the map cursor is moved to this position.
Definition: MapCursor.java:299
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.utils.Size2D.getHeight
int getHeight()
Returns the height of the area.
Definition: Size2D.java:104
net.sf.gridarta.model.mapcursor.MapCursor.goTo
boolean goTo(final boolean performAction, @NotNull final Direction dir)
Moves the cursor one square relative to current position.
Definition: MapCursor.java:389
net.sf.gridarta.model.mapcursor.MapCursor.transactionDepth
int transactionDepth
The nesting level of map cursor transactions.
Definition: MapCursor.java:125
net.sf.gridarta.model.mapcursor.MapCursor.fixPoint
Point fixPoint(@NotNull final Point p)
Returns a valid location that is on the map.
Definition: MapCursor.java:706
net.sf.gridarta.model.mapcursor.MapCursor.selectMapSquare
void selectMapSquare()
Selects the map square on the current map location.
Definition: MapCursor.java:548
net.sf.gridarta.model.mapcursor.MapCursor.isDragging
boolean isDragging()
Returns whether the cursor is currently being dragged.
Definition: MapCursor.java:411
net.sf.gridarta.model.mapcursor.MapCursor.selectTopmostGameObject
void selectTopmostGameObject()
Selects the last (top-most) GameObject on the current map square.
Definition: MapCursor.java:562
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.model.mapcursor.MapCursor.insertGameObject
boolean insertGameObject(final boolean performAction, @NotNull final BaseObject< G, A, R, ?> gameObject, final boolean insertAtEnd, final boolean join)
Inserts a GameObject before the selected game object.
Definition: MapCursor.java:631
net.sf.gridarta.model.mapmodel.MapModel.removeGameObject
void removeGameObject(@NotNull G gameObject, boolean join)
Delete an existing GameObject from the map.
net.sf.gridarta.model.mapcursor.MapCursor.selectAbove
boolean selectAbove(final boolean performAction)
Moves the selected GameObject.
Definition: MapCursor.java:573
net.sf.gridarta.model.mapcursor.MapCursor.MapCursor
MapCursor(@NotNull final MapGrid mapGrid, @NotNull final MapModel< G, A, R > mapModel)
Construct a MapCursor.
Definition: MapCursor.java:173
net.sf.gridarta.model.mapcursor.MapCursor.getLocation
Point getLocation()
Get position of cursor.
Definition: MapCursor.java:227
net.sf.gridarta.model.mapgrid.SelectionMode
Modes that describe how squares get selected.
Definition: SelectionMode.java:26
net.sf.gridarta.model.mapcursor.MapCursor.removeMapCursorListener
void removeMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Remove a MapCursorListener.
Definition: MapCursor.java:427
net.sf.gridarta.model.mapcursor.MapCursor
MapCursor provides methods to move and drag on map.
Definition: MapCursor.java:58
net.sf.gridarta.model.mapcursor.MapCursor.setLocation
void setLocation(@NotNull final Point p)
Move cursor to a new location.
Definition: MapCursor.java:236
net.sf.gridarta.model.mapcursor.MapCursor.isOnGrid
boolean isOnGrid(@Nullable final Point p)
Check if point is on grid.
Definition: MapCursor.java:379
net.sf.gridarta.model.baseobject.BaseObject
Definition: BaseObject.java:34
net.sf.gridarta.model.mapcursor.MapCursor.beginTransaction
final void beginTransaction()
Start a new transaction.
Definition: MapCursor.java:488
net.sf.gridarta.model.mapmodel.MapSquare.getMapModel
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
Definition: MapSquare.java:99
net.sf.gridarta.model.mapcursor.MapCursor.addMapCursorListener
void addMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Register a MapCursorListener.
Definition: MapCursor.java:419
net.sf.gridarta.model.mapgrid.MapGrid
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
Definition: MapGrid.java:46
net.sf.gridarta.model.mapmodel.MapModel.getMapSquare
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
net.sf.gridarta.model.mapgrid
Definition: MapGrid.java:20
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.model.baseobject
Definition: AbstractBaseObject.java:20
net.sf.gridarta.model.mapgrid.MapGrid.getGridSize
Size2D getGridSize()
Returns a Size2D with the dimension of this grid.
Definition: MapGrid.java:207
net.sf.gridarta.model.mapcursor.MapCursor.setMapSquare
void setMapSquare(@Nullable final MapSquare< G, A, R > mapSquare)
Sets the selected MapSquare.
Definition: MapCursor.java:469
net.sf.gridarta.model.mapcursor.MapCursor.dragging
boolean dragging
Gets set to.
Definition: MapCursor.java:82
net.sf.gridarta.model.mapcursor.MapCursor.dragStart
void dragStart()
Set cursor to drag mode when it is active.
Definition: MapCursor.java:279
net.sf.gridarta.model.mapcursor.MapCursor.selectBelow
boolean selectBelow(final boolean performAction)
Moves the selected GameObject.
Definition: MapCursor.java:600
net.sf.gridarta.model.mapgrid.MapGridListener
Interface for listeners listening to MapGridEvents.
Definition: MapGridListener.java:29
net.sf.gridarta.model.mapgrid.MapGrid.preSelect
void preSelect(@NotNull final Point start, @NotNull final Point end)
Rectangle defined by two points gets preselected.
Definition: MapGrid.java:313
net.sf.gridarta.model.mapgrid.MapGrid.unPreSelect
void unPreSelect(@NotNull final Point start, @NotNull final Point end)
Pre-selection of rectangle defined by points gets deleted.
Definition: MapGrid.java:393
net.sf.gridarta.model.mapcursor.MapCursor.transactionGameObject
G transactionGameObject
The value of gameObject at the start of the outermost map cursor transaction.
Definition: MapCursor.java:152
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.mapcursor.MapCursor.mapGrid
final MapGrid mapGrid
Grid where cursor is bound to.
Definition: MapCursor.java:88
net.sf.gridarta.model.mapgrid.MapGrid.selectArea
void selectArea(@NotNull final Point pos1, @NotNull final Point pos2, @NotNull final SelectionMode selectionMode)
Selects or deselects all squares in an area.
Definition: MapGrid.java:418
net.sf.gridarta.model.mapgrid.MapGrid.setCursor
void setCursor(@NotNull final Point pos)
Highlights the given cursor position.
Definition: MapGrid.java:296
net.sf.gridarta.model.mapgrid.MapGridEvent
This event is created by MapGrid.
Definition: MapGridEvent.java:29
net.sf.gridarta.model.mapcursor.MapCursor.pos
final Point pos
Current cursor position.
Definition: MapCursor.java:65
net.sf.gridarta.model.mapcursor.MapCursor.transactionMapSquare
MapSquare< G, A, R > transactionMapSquare
The value of mapSquare at the start of the outermost map cursor transaction.
Definition: MapCursor.java:145
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.model.mapgrid.MapGrid.unSelect
void unSelect()
Clears all selection and pre-selection flags from the grid.
Definition: MapGrid.java:263
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.model.mapcursor.MapCursor.getDragOffset
Dimension getDragOffset()
Get offset from start position of dragging.
Definition: MapCursor.java:370
net.sf.gridarta.model.direction
Definition: Direction.java:20
net.sf.gridarta.model.mapcursor.MapCursor.dragRelease
void dragRelease()
Leave drag mode and undo pre-selection.
Definition: MapCursor.java:319
net.sf.gridarta.model.mapcursor.MapCursor.transactionMapRec
final Rectangle2D transactionMapRec
The value of mapRec at the start of the outermost map cursor transaction.
Definition: MapCursor.java:159
net.sf.gridarta.model.mapcursor.MapCursor.endTransaction
final void endTransaction()
End a transaction.
Definition: MapCursor.java:506