Package net.sf.gridarta.gui.mapfiles
Class PickmapState<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.gui.mapfiles.PickmapState<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.ObjectMaintains the state of a pickmap file. APickmapis part of aMapFolderwhich is part ofMapFolderTree. A pickmap has an underlying file from which aMapControlinstance may be created.
-
-
Constructor Summary
Constructors Constructor Description PickmapState(@NotNull MapFolder<G,A,R> mapFolder, @NotNull java.lang.String name, @NotNull MapReaderFactory<G,A> mapReaderFactory, @NotNull MapManager<G,A,R> pickmapManager, @NotNull MapViewsManager<G,A,R> mapViewsManager)Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfreePickmap()Unloads the map file.@NotNull java.io.FilegetFile()Returns the underlying map file.@Nullable MapView<G,A,R>getMapView()Returns theMapViewinstance for this pickmap.@Nullable MapControl<G,A,R>getPickmap()Returns theMapControlrepresenting this pickmap.voidgetUnsavedPickmaps(@NotNull java.util.Collection<MapControl<G,A,R>> unsavedPickmaps)Returns this pickmap if it has been loaded and is modified.static booleanisValidPickmapName(@NotNull java.lang.CharSequence name)Returns whether a pickmap name is valid.voidloadPickmap()Loads the pickmap from the underlying map file.voidremove(boolean deleteFile)Removes this pickmap from its folder.voidrevert()Reverts this pickmap to its underlying map file.voidsave()Saves this pickmap.
-
-
-
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 InvalidNameExceptionCreates a new instance.- Parameters:
mapFolder- the folder ths pickmap is part ofname- the underlying map file namemapReaderFactory- the map reader factory to usepickmapManager- the map manager for creating pickmapsmapViewsManager- the map views- Throws:
InvalidNameException- ifnameis 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 theMapControlrepresenting this pickmap. ReturnsnullunlessloadPickmap()was successfully called.- Returns:
- the
MapControlinstance, ornullif the map file has not been loaded
-
getMapView
@Nullable public @Nullable MapView<G,A,R> getMapView()
Returns theMapViewinstance for this pickmap. ReturnsnullunlessloadPickmap()was successfully called.- Returns:
- the
MapViewinstance, ornullif the map file has not been loaded
-
loadPickmap
public void loadPickmap() throws java.io.IOExceptionLoads 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 ofloadPickmap().
-
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 addthisto 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.IOExceptionSaves 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.IOExceptionReverts 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
-
-