Go to the documentation of this file.
20 package net.sf.gridarta.model.mapcursor;
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;
40 import org.jetbrains.annotations.NotNull;
41 import org.jetbrains.annotations.Nullable;
65 private final Point
pos;
165 private final Collection<MapCursorListener<G, A, R>>
listenerList =
new CopyOnWriteArrayList<>();
179 pos =
fixPoint(
new Point(mapArchObject.getEnterX(), mapArchObject.getEnterY()));
183 public void mapGridChanged(@NotNull
final MapGridEvent e) {
188 public void mapGridResized(@NotNull
final MapGridEvent e) {
190 final int newWidth = newSize.
getWidth();
191 final int newHeight = newSize.
getHeight();
194 mapRec.setSize(newWidth, newHeight);
228 return new Point(
pos);
239 final Point effectivePoint =
fixPoint(p);
240 if (!
pos.equals(effectivePoint)) {
241 pos.setLocation(effectivePoint);
257 final boolean hasChanged;
259 if (p !=
null &&
mapRec.contains(p)) {
299 public boolean dragTo(@Nullable
final Point p) {
303 final Point oldPos =
new Point(
pos);
380 return p !=
null &&
mapRec.contains(p);
389 public boolean goTo(
final boolean performAction, @NotNull
final Direction dir) {
390 if (dir.getDx() == 0 && dir.getDy() == 0) {
450 this.gameObject =
null;
521 listener.mapCursorChangedMode();
529 if (changedGameObject) {
536 listener.mapCursorChangedSize();
552 }
catch (
final IndexOutOfBoundsException ignored) {
579 if (newGameObject ==
null) {
606 if (newGameObject ==
null) {
636 if (insertedGameObject !=
null) {
639 this.gameObject = insertedGameObject;
660 if (gameObject ==
null) {
665 if (mapSquare ==
null) {
674 if (nextGameObject ==
null) {
677 if (nextGameObject !=
null) {
679 final G invGameObject = nextGameObject.getFirst();
680 if (invGameObject ==
null) {
683 nextGameObject = invGameObject;
688 this.gameObject = nextGameObject;
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));
G insertArchToMap(@NotNull BaseObject< G, A, R, ?> templateBaseObject, @Nullable G nextGameObject, @NotNull Point pos, boolean join)
G getFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
G getLast(@NotNull final GameObjectMatcher gameObjectMatcher)
void setMapSquare(@Nullable final MapSquare< G, A, R > mapSquare)
MapModel< G, A, R > getMapModel()
void selectTopmostGameObject()
boolean setLocationSafe(@Nullable final Point p)
void dragSelect(@NotNull final SelectionMode selectionMode, final boolean forceSelect)
Dimension getDragOffset()
void setGameObject(@Nullable final G gameObject)
boolean deleteSelectedGameObject(final boolean performAction, final boolean autoJoin)
boolean isOnGrid(@Nullable final Point p)
final void endTransaction()
final Rectangle2D transactionMapRec
final void beginTransaction()
void beginTransaction(@NotNull String name)
boolean selectBelow(final boolean performAction)
void setCursor(@NotNull final Point pos)
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
void unSetCursor(@NotNull final Point pos)
boolean insertGameObject(final boolean performAction, @NotNull final BaseObject< G, A, R, ?> gameObject, final boolean insertAtEnd, final boolean join)
final Point transactionPos
boolean selectAbove(final boolean performAction)
void addMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
void removeGameObject(@NotNull G gameObject, boolean join)
boolean goTo(final boolean performAction, @NotNull final Direction dir)
MapSquare< G, A, R > transactionMapSquare
void selectArea(@NotNull final Point pos1, @NotNull final Point pos2, @NotNull final SelectionMode selectionMode)
Point fixPoint(@NotNull final Point p)
MapCursor(@NotNull final MapGrid mapGrid, @NotNull final MapModel< G, A, R > mapModel)
void preSelect(@NotNull final Point start, @NotNull final Point end)
MapSquare< G, A, R > mapSquare
final MapModel< G, A, R > mapModel
void updatePreSelect(@NotNull final Point start, @NotNull final Point oldEnd, @NotNull final Point newEnd)
final Collection< MapCursorListener< G, A, R > > listenerList
void setLocation(@NotNull final Point p)
void removeMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
void addMapGridListener(@NotNull final MapGridListener listener)
boolean dragTo(@Nullable final Point p)
boolean transactionDragging
void unPreSelect(@NotNull final Point start, @NotNull final Point end)
final Dimension dragOffset