20 package net.sf.gridarta.gui.panel.pickmapchooser;
23 import java.util.ArrayList;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.HashMap;
27 import java.util.Iterator;
28 import java.util.LinkedList;
29 import java.util.List;
44 import org.jetbrains.annotations.NotNull;
45 import org.jetbrains.annotations.Nullable;
57 private final List<PickmapState<G, A, R>>
pickmapStates =
new ArrayList<>();
63 private final Collection<PickmapChooserModelListener<G, A, R>>
listeners =
new LinkedList<>();
78 final int index = tmp >= 0 ? tmp : -tmp - 1;
79 pickmapStates.add(index, pickmapState);
90 final int index = pickmapStates.indexOf(pickmapState);
95 pickmapStates.remove(index);
106 final int index = pickmapStates.indexOf(pickmapState);
124 if (pickmapState.getFile().equals(file)) {
136 return pickmapStates.isEmpty();
145 return pickmapStates.indexOf(pickmapState);
150 public Iterator<PickmapState<G, A, R>>
iterator() {
151 return Collections.unmodifiableList(pickmapStates).iterator();
161 return pickmapStates.get(index);
170 pickmapState.freePickmap();
172 pickmapStates.clear();
180 listeners.add(pickmapChooserModelListener);
189 listener.pickmapReverted(pickmapState);
199 listener.activePickmapChanged(pickmapState);
210 listener.pickmapModifiedChanged(index, pickmapState);
223 mapModelListeners.put(mapControl, mapModelListener);
233 assert mapModelListener != null;
234 mapControl.getMapModel().removeMapModelListener(mapModelListener);
267 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
285 if (pickmapState.getPickmap().getMapModel() ==
mapModel) {
int removeMapFile(@NotNull final PickmapState< G, A, R > pickmapState)
Removes a map file.
static final Comparator< PickmapState<?, ?, ?> > INSTANCE
A Comparator that compares PickmapState instances by name.
A MapModel reflects the data of a map.
PickmapState< G, A, R > getPickmap(@NotNull final File file)
Returns the pickmap by file name.
void errorsChanged(@NotNull final ErrorCollector< G, A, R > errors)
The errors of a map model have changed.
void mapFileChanged(@Nullable final MapFile oldMapFile)
The map file has changed.
Graphical User Interface of Gridarta.
final Collection< PickmapChooserModelListener< G, A, R > > listeners
The listeners to notify.
Maintains the state of a pickmap file.
void firePickmapModifiedChanged(final int index, @NotNull final PickmapState< G, A, R > pickmapState)
Notifies all listeners that a pickmap has been modified.
This package contains the framework for validating maps.
void removeMapModelListener(@NotNull final MapControl< G, A, R > mapControl)
Stops tracking a MapControl instance for changes.
A Comparator for comparing MapFiles by pickmap name.
void addMapModelListener(@NotNull final MapControl< G, A, R > mapControl)
Tracks a MapControl instance for changes.
boolean isEmpty()
Returns whether no pickmaps exist in the current folder.
Interface for listeners listening on MapModel events.
int indexOf(@NotNull final PickmapState< G, A, R > pickmapState)
Returns the index of a map file.
PickmapChooserMapModelListener(@NotNull final MapModel< G, A, R > mapModel)
Creates a new instance.
void clear()
Removes all map files.
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
final List< PickmapState< G, A, R > > pickmapStates
All open pickmaps.
void mapObjectsChanged(@NotNull final Set< G > gameObjects, @NotNull final Set< G > transientGameObjects)
One or more GameObjects on a map have changed.
final MapModel< G, A, R > mapModel
The tracked MapModel.
Iterator< PickmapState< G, A, R > > iterator()
Base package of all Gridarta classes.
void modifiedChanged()
The modified flag has changed.
Reflects a game object (object on a map).
void addPickmapChooserListener(@NotNull final PickmapChooserModelListener< G, A, R > pickmapChooserModelListener)
Adds a PickmapChooserModelListener to be notified.
A MapModelListener which tracks a pickmap for modifications.
GameObjects are the objects based on Archetypes found on maps.
Maintains loaded PickmapState instances.
final Map< MapControl< G, A, R >, MapModelListener< G, A, R > > mapModelListeners
Maps MapControl instance to attached MapModelListener.
void mapSquaresChanged(@NotNull final Set< MapSquare< G, A, R >> mapSquares)
Squares of a map have changed.
void fireActivePickmapChanged(@Nullable final PickmapState< G, A, R > pickmapState)
Notifies all listeners that the active pickmap has changes.
Currently nothing more than a marker interface for unification.
An interface for classes that collect errors.
int addMapFile(@NotNull final PickmapState< G, A, R > pickmapState)
Adds a map file.
void mapSizeChanged(@NotNull final Size2D newSize)
The size of a map has changed.
void firePickmapReverted(@NotNull final PickmapState< G, A, R > pickmapState)
Notifies all listeners that the a pickmap has been reverted.
The location of a map file with a map directory.
int revertMapFile(@NotNull final MapControl< G, A, R > oldPickmap, @NotNull final PickmapState< G, A, R > pickmapState)
Reverts a map file.
Interface for MapArchObjects.
The class Size2D represents a 2d rectangular area.