public class MapCursor<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
extends java.lang.Object
MapGrid which will change it flags depending on MapCursor
movement/selection.
There are three different states for MapCursor:
| Constructor and Description |
|---|
MapCursor(@NotNull MapGrid mapGrid,
@NotNull MapModel<G,A,R> mapModel)
Construct a MapCursor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addMapCursorListener(@NotNull MapCursorListener<G,A,R> listener)
Register a MapCursorListener.
|
void |
beginTransaction()
Start a new transaction.
|
void |
deactivate()
Cursor gets deactivated.
|
boolean |
deleteSelectedGameObject(boolean performAction,
boolean autoJoin)
Deletes the selected game object.
|
void |
dragRelease()
Leave drag mode and undo pre-selection.
|
void |
dragSelect(@NotNull SelectionMode selectionMode,
boolean forceSelect)
Leave drag mode and select pre-selection using selectionMode.
|
void |
dragStart()
Set cursor to drag mode when it is active.
|
boolean |
dragTo(@Nullable java.awt.Point p)
When in drag mode and the point is on the map cursor is moved to this
position.
|
void |
endTransaction()
End a transaction.
|
@Nullable java.awt.Dimension |
getDragOffset()
Get offset from start position of dragging.
|
G |
getGameObject()
Returns the selected
GameObject. |
@NotNull java.awt.Point |
getLocation()
Get position of cursor.
|
boolean |
goTo(boolean performAction,
@NotNull Direction dir)
Moves the cursor one square relative to current position.
|
boolean |
insertGameObject(boolean performAction,
@NotNull BaseObject<G,A,R,?> gameObject,
boolean insertAtEnd,
boolean join)
Inserts a
GameObject before the selected game object. |
boolean |
isDragging()
Returns whether the cursor is currently being dragged.
|
boolean |
isOnGrid(@Nullable java.awt.Point p)
Check if point is on grid.
|
void |
removeMapCursorListener(@NotNull MapCursorListener<G,A,R> listener)
Remove a MapCursorListener.
|
boolean |
selectAbove(boolean performAction)
Moves the selected
GameObject. |
boolean |
selectBelow(boolean performAction)
Moves the selected
GameObject. |
void |
setGameObject(G gameObject)
Sets the selected
GameObject. |
void |
setLocation(@NotNull java.awt.Point p)
Move cursor to a new location.
|
boolean |
setLocationSafe(@Nullable java.awt.Point p)
Move cursor to a new location.
|
void |
setMapSquare(@Nullable MapSquare<G,A,R> mapSquare)
Sets the selected
MapSquare. |
@NotNull public @NotNull java.awt.Point getLocation()
public void setLocation(@NotNull
@NotNull java.awt.Point p)
p - the new locationpublic boolean setLocationSafe(@Nullable
@Nullable java.awt.Point p)
p - the new location; if p == null nothing happenstrue if cursor position changedpublic void dragStart()
public boolean dragTo(@Nullable
@Nullable java.awt.Point p)
MapGrid changes pre-selection accordingly.p - new coordinatestrue when dragging position changed successfullypublic void dragRelease()
public void dragSelect(@NotNull
@NotNull SelectionMode selectionMode,
boolean forceSelect)
selectionMode - Mode how to change selection stateforceSelect - whether to force selection, regardless of the selected
areaSelectionModepublic final void deactivate()
@Nullable public @Nullable java.awt.Dimension getDragOffset()
null when not in drag modepublic boolean isOnGrid(@Nullable
@Nullable java.awt.Point p)
p - Coordinates of pointtrue if p != null and point is on gridpublic boolean goTo(boolean performAction,
@NotNull
@NotNull Direction dir)
performAction - whether the action should be performeddir - the directiontrue if cursor really movedpublic boolean isDragging()
true if dragging is active, otherwise false.public void addMapCursorListener(@NotNull
@NotNull MapCursorListener<G,A,R> listener)
listener - MapCursorListener to registerpublic void removeMapCursorListener(@NotNull
@NotNull MapCursorListener<G,A,R> listener)
listener - MapCursorListener to remove@Nullable public G getGameObject()
GameObject.null if the map cursor is not
active or if the selected map square is emptypublic void setGameObject(@Nullable
G gameObject)
GameObject. If the game object is not on a map
or not on the map this cursor is attached to, the cursor is unchanged.gameObject - the selected game objectpublic void setMapSquare(@Nullable
@Nullable MapSquare<G,A,R> mapSquare)
MapSquare. If the map square does not belong to
the map this cursor is attached to, the cursor is unchanged.mapSquare - the selected map squarepublic final void beginTransaction()
endTransaction().public final void endTransaction()
If the last transaction is ended, the changes are committed.
public boolean selectAbove(boolean performAction)
GameObject. Does nothing if no game object is
selected.performAction - whether the action should be performedpublic boolean selectBelow(boolean performAction)
GameObject. Does nothing if no game object is
selected.performAction - whether the action should be performedpublic boolean insertGameObject(boolean performAction,
@NotNull
@NotNull BaseObject<G,A,R,?> gameObject,
boolean insertAtEnd,
boolean join)
GameObject before the selected game object. Does
nothing if no game object is selected.performAction - whether the action should be performedgameObject - the game object to insertinsertAtEnd - whether to ignore the selected game object and insert
at the endjoin - if set, auto-joining is supportedpublic boolean deleteSelectedGameObject(boolean performAction,
boolean autoJoin)
performAction - whether the action should be performedautoJoin - whether to preform auto-joining