20 package net.sf.gridarta.gui.mapfiles;
23 import java.io.IOException;
24 import java.util.Collection;
25 import java.util.regex.Pattern;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
102 private final Object
sync =
new Object();
113 public PickmapState(@NotNull
final MapFolder<G, A, R> mapFolder, @NotNull
final String name, @NotNull
final MapReaderFactory<G, A> mapReaderFactory, @NotNull
final MapManager<G, A, R> pickmapManager, @NotNull
final MapViewsManager<G, A, R> mapViewsManager)
throws InvalidNameException {
131 return PATTERN_VALID_PICKMAP_NAME.matcher(name).matches();
151 synchronized (
sync) {
164 synchronized (
sync) {
174 synchronized (
sync) {
175 if (pickmap != null) {
182 pickmapView = mapViewsManager.
newMapView(pickmap, null, null);
190 synchronized (
sync) {
191 if (pickmap != null) {
192 assert pickmapView != null;
194 assert pickmap != null;
195 pickmapManager.
release(pickmap);
206 synchronized (
sync) {
208 unsavedPickmaps.add(pickmap);
217 public void remove(
final boolean deleteFile) {
226 public void save() throws IOException {
238 public void revert() throws IOException {
240 if (oldPickmap != null) {
void save()
Saves the map to a file.
static final Pattern PATTERN_VALID_PICKMAP_NAME
The Pattern that matches valid pickmap names.
MapView< G, A, R > pickmapView
The MapView or pickmap, or.
A MapManager manages all opened maps.
void release(@NotNull MapControl< G, A, R > mapControl)
Releases a MapControl instance.
Graphical User Interface of Gridarta.
Reading and writing of maps, handling of paths.
void firePickmapReverted(@NotNull final PickmapState< G, A, R > pickmapState, @NotNull final MapControl< G, A, R > oldPickmap)
Notifies all listeners about a reverted pickmap.
MapControl< G, A, R > newMap(@Nullable List< G > objects, @NotNull A mapArchObject, @Nullable MapFile mapFile, boolean interactive)
Creates a new map control without view.
Maintains the state of a pickmap file.
final MapFolder< G, A, R > mapFolder
The folder this pickmap is part of.
MapReader< G, A > newMapReader(@NotNull File file)
Create a new MapReader instance.
A factory for creating MapReader instances.
MapView< G, A, R > newMapView(@NotNull final MapControl< G, A, R > mapControl, @Nullable final Point viewPosition, @Nullable final Point centerSquare)
Creates a new map view.
File getDir()
Returns the base directory.
void revert()
Reverts this pickmap to its underlying map file.
boolean isModified()
Return whether the map has been modified from the on-disk state.
Stores all existing MapViews.
static boolean isValidPickmapName(@NotNull final CharSequence name)
Returns whether a pickmap name is valid.
void save()
Saves this pickmap.
List< G > getGameObjects()
Return the decoded game objects.
MapModel< G, A, R > getMapModel()
Returns the map model.
void loadPickmap()
Loads the pickmap from the underlying map file.
final MapManager< G, A, R > pickmapManager
The MapManager for creating new pickmaps.
Base package of all Gridarta classes.
Interface for classes that read map files.
Reflects a game object (object on a map).
void removePickmap(@NotNull final PickmapState< G, A, R > pickmapState, final boolean deleteFile)
Removes a PickmapState from this folder.
final String name
The underlying map file name.
MapControl< G, A, R > getPickmap()
Returns the MapControl representing this pickmap.
GameObjects are the objects based on Archetypes found on maps.
PickmapState(@NotNull final MapFolder< G, A, R > mapFolder, @NotNull final String name, @NotNull final MapReaderFactory< G, A > mapReaderFactory, @NotNull final MapManager< G, A, R > pickmapManager, @NotNull final MapViewsManager< G, A, R > mapViewsManager)
Creates a new instance.
final MapViewsManager< G, A, R > mapViewsManager
The MapViewsManager.
Base classes for rendering maps.
MapView< G, A, R > getMapView()
Returns the MapView instance for this pickmap.
File getFile()
Returns the underlying map file.
MapControl< G, A, R > pickmap
The MapControl instance representing the map file, or.
Currently nothing more than a marker interface for unification.
A map view consists of a map grid and a map cursor, and is attached to a map control.
final Object sync
The synchronization object for accessed to pickmap and pickmapView.
final MapReaderFactory< G, A > mapReaderFactory
The MapReaderFactory to use.
void freePickmap()
Unloads the map file.
A getMapArchObject()
Returns the MapArchObject read from this MapFileDecode.
void closeView(@NotNull final MapView< G, A, R > mapView)
Closes a view of a MapControl.
void getUnsavedPickmaps(@NotNull final Collection< MapControl< G, A, R >> unsavedPickmaps)
Returns this pickmap if it has been loaded and is modified.
The location of a map file with a map directory.
Interface for MapArchObjects.
Indicates that a folder or pickmap name is invalid.