20 package net.sf.gridarta.gui.map.mapview;
22 import java.util.ArrayList;
23 import java.util.Collection;
24 import java.util.Collections;
25 import java.util.Iterator;
26 import java.util.List;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
45 private final List<MapView<G, A, R>>
mapViewsList = Collections.synchronizedList(
new ArrayList<>());
57 private final Collection<MapViewManagerListener<G, A, R>>
listeners =
new ArrayList<>();
63 @SuppressWarnings(
"NullableProblems")
65 assert mapViewsList.contains(mapView);
66 mapViewsList.remove(mapView);
67 mapViewsList.add(0, mapView);
77 assert mapViewsList.contains(mapView);
78 if (!mapViewsList.contains(mapView)) {
82 mapViewsList.remove(mapView);
84 listener.mapViewClosing(mapView);
94 assert !mapViewsList.contains(mapView);
95 mapViewsList.add(0, mapView);
98 listener.mapViewCreated(mapView);
107 assert mapViewsList.contains(mapView);
108 if (mapViewsList.size() <= 1) {
112 mapViewsList.remove(mapView);
113 mapViewsList.add(mapView);
122 assert mapViewsList.contains(mapView);
123 mapViewsList.remove(mapView);
124 mapViewsList.add(0, mapView);
135 return Collections.unmodifiableList(mapViewsList).iterator();
142 final MapView<G, A, R> newActiveMapView = mapViewsList.isEmpty() ? null : mapViewsList.get(0);
143 if (activeMapView == newActiveMapView) {
147 activeMapView = newActiveMapView;
149 listener.activeMapViewChanged(activeMapView);
158 listeners.add(listener);
166 listeners.remove(listener);
185 if (mapViewsList.size() <= 1) {
192 mapViewsList.add(mapView);
205 final int size = mapViewsList.size();
213 mapViewsList.add(0, mapView);
boolean doNextWindow(final boolean performAction)
Executes the "next window" action.
void updateActiveMapView()
Updates the active map view and notifies all listeners of changes.
void addMapViewManagerListener(@NotNull final MapViewManagerListener< G, A, R > listener)
Adds a listener to be notified.
void addMapView(@NotNull final MapView< G, A, R > mapView)
Adds a map view.
boolean doPrevWindow(final boolean performAction)
Executes the "prev window" action.
void removeMapView(@NotNull final MapView< G, A, R > mapView)
Removes a map view.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
final Collection< MapViewManagerListener< G, A, R > > listeners
The registered MapViewManagerListeners.
Iterator< MapView< G, A, R > > iterator()
Returns all opened map views.
void deactivateMapView(@NotNull final MapView< G, A, R > mapView)
Deactivates a map view.
GameObjects are the objects based on Archetypes found on maps.
void setActiveMapView(@NotNull final MapView< G, A, R > mapView)
Sets the active map view.
MapView< G, A, R > getActiveMapView()
Returns the active top map view we are working with.
void removeMapViewManagerListener(@NotNull final MapViewManagerListener< G, A, R > listener)
Removes a listener to be notified.
MapView< G, A, R > activeMapView
The active map view.
Interface for MapArchObjects.
final List< MapView< G, A, R > > mapViewsList
All open map views as a list.
void activateMapView(@NotNull final MapView< G, A, R > mapView)
Activates a map view.