Class PickmapState<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>


  • public class PickmapState<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>>
    extends java.lang.Object
    Maintains the state of a pickmap file. A Pickmap is part of a MapFolder which is part of MapFolderTree. A pickmap has an underlying file from which a MapControl instance may be created.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void freePickmap()
      Unloads the map file.
      @NotNull java.io.File getFile()
      Returns the underlying map file.
      @Nullable MapView<G,​A,​R> getMapView()
      Returns the MapView instance for this pickmap.
      @Nullable MapControl<G,​A,​R> getPickmap()
      Returns the MapControl representing this pickmap.
      void getUnsavedPickmaps​(@NotNull java.util.Collection<MapControl<G,​A,​R>> unsavedPickmaps)
      Returns this pickmap if it has been loaded and is modified.
      static boolean isValidPickmapName​(@NotNull java.lang.CharSequence name)
      Returns whether a pickmap name is valid.
      void loadPickmap()
      Loads the pickmap from the underlying map file.
      void remove​(boolean deleteFile)
      Removes this pickmap from its folder.
      void revert()
      Reverts this pickmap to its underlying map file.
      void save()
      Saves this pickmap.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PickmapState

        public PickmapState​(@NotNull
                            @NotNull MapFolder<G,​A,​R> mapFolder,
                            @NotNull
                            @NotNull java.lang.String name,
                            @NotNull
                            @NotNull MapReaderFactory<G,​A> mapReaderFactory,
                            @NotNull
                            @NotNull MapManager<G,​A,​R> pickmapManager,
                            @NotNull
                            @NotNull MapViewsManager<G,​A,​R> mapViewsManager)
                     throws InvalidNameException
        Creates a new instance.
        Parameters:
        mapFolder - the folder ths pickmap is part of
        name - the underlying map file name
        mapReaderFactory - the map reader factory to use
        pickmapManager - the map manager for creating pickmaps
        mapViewsManager - the map views
        Throws:
        InvalidNameException - if name is not valid
    • Method Detail

      • isValidPickmapName

        public static boolean isValidPickmapName​(@NotNull
                                                 @NotNull java.lang.CharSequence name)
        Returns whether a pickmap name is valid.
        Parameters:
        name - the name to check
        Returns:
        whether the name is valid
      • getFile

        @NotNull
        public @NotNull java.io.File getFile()
        Returns the underlying map file.
        Returns:
        the map file
      • getPickmap

        @Nullable
        public @Nullable MapControl<G,​A,​R> getPickmap()
        Returns the MapControl representing this pickmap. Returns null unless loadPickmap() was successfully called.
        Returns:
        the MapControl instance, or null if the map file has not been loaded
      • getMapView

        @Nullable
        public @Nullable MapView<G,​A,​R> getMapView()
        Returns the MapView instance for this pickmap. Returns null unless loadPickmap() was successfully called.
        Returns:
        the MapView instance, or null if the map file has not been loaded
      • loadPickmap

        public void loadPickmap()
                         throws java.io.IOException
        Loads the pickmap from the underlying map file.
        Throws:
        java.io.IOException - if the map file cannot be loaded
      • freePickmap

        public void freePickmap()
        Unloads the map file. Undoes the effect of loadPickmap().
      • getUnsavedPickmaps

        public void getUnsavedPickmaps​(@NotNull
                                       @NotNull java.util.Collection<MapControl<G,​A,​R>> unsavedPickmaps)
        Returns this pickmap if it has been loaded and is modified.
        Parameters:
        unsavedPickmaps - the collection to add this to if modified
      • remove

        public void remove​(boolean deleteFile)
        Removes this pickmap from its folder.
        Parameters:
        deleteFile - if set, delete the map file as well
      • save

        public void save()
                  throws java.io.IOException
        Saves this pickmap. Does nothing if the pickmap is not loaded or not modified.
        Throws:
        java.io.IOException - if saving fails
      • revert

        public void revert()
                    throws java.io.IOException
        Reverts this pickmap to its underlying map file. Does nothing if the pickmap is not loaded.
        Throws:
        java.io.IOException - if the pickmap cannot be loaded