20 package net.sf.gridarta.gui.map.mapview;
22 import java.awt.Point;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.List;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
77 final Point[] selectedMapSquares = mapGrid.
getSelection();
78 final List<MapSquare<G, A, R>> selection =
new ArrayList<>();
79 for (
final Point pos : selectedMapSquares) {
89 final List<G> objects =
new ArrayList<>();
90 for (
final Iterable<G> mapSquare : selectedMapSquares) {
92 objects.add(gameObject.getHead());
96 if (objects.isEmpty()) {
106 final int objectSize = objects.size();
107 if (objectSize == 0) {
110 if (objectSize == 1) {
111 return objects.get(0);
131 if (point.x >= mapSize.
getWidth()) {
133 }
else if (point.x < 0) {
138 }
else if (point.y < 0) {
A MapModel reflects the data of a map.
MapCursor< G, A, R > getMapCursor()
MapCursor provides methods to move and drag on map.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
Point [] getSelection()
Returns the selection.
final MapCursor< G, A, R > mapCursor
The MapCursor of this map view.
MapModel< G, A, R > getMapModel()
Returns the map model.
void setLocation(@NotNull final Point p)
Move cursor to a new location.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
AbstractMapView(@NotNull final MapModel< G, A, R > mapModel, @NotNull final MapGrid mapGrid, @NotNull final MapCursor< G, A, R > mapCursor)
Creates a new instance.
G getSelectedGameObject()
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
GameObjects are the objects based on Archetypes found on maps.
int getWidth()
Returns the width of the area.
final MapModel< G, A, R > mapModel
The MapModel of this map view.
static final Random RND
Global random number generator.
2D-Grid containing flags for selection, pre-selection, cursor, warnings and errors.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
final MapGrid mapGrid
The MapGrid of this map view.
Abstract base class for MapView implementations.
A map view consists of a map grid and a map cursor, and is attached to a map control.
void setCursorLocation(@NotNull final Point point)
List< MapSquare< G, A, R > > getSelectedSquares()
List< G > getAllGameObjects()
Returns all game objects.
int getHeight()
Returns the height of the area.
List< G > getSelectedGameObjects()
Interface for MapArchObjects.
The class Size2D represents a 2d rectangular area.