net.sf.gridarta.gui.mapfiles
public class MapFile<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends Object
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.Modifier and Type | Field and Description |
---|---|
private MapFolder<G,A,R> |
mapFolder
The folder this pickmap is part of.
|
private MapReaderFactory<G,A> |
mapReaderFactory
The
MapReaderFactory to use. |
private MapViewsManager<G,A,R> |
mapViewsManager
The
MapViewsManager . |
private String |
name
The underlying map file name.
|
private static Pattern |
PATTERN_VALID_PICKMAP_NAME
The
Pattern that matches valid pickmap names. |
private MapControl<G,A,R> |
pickmap
The
MapControl instance representing the map file, or
null if the map file is not loaded. |
private MapManager<G,A,R> |
pickmapManager
The
MapManager for creating new pickmaps. |
private MapView<G,A,R> |
pickmapView
|
private Object |
sync
The synchronization object for accessed to
pickmap and pickmapView . |
Constructor and Description |
---|
MapFile(MapFolder<G,A,R> mapFolder,
String name,
MapReaderFactory<G,A> mapReaderFactory,
MapManager<G,A,R> pickmapManager,
MapViewsManager<G,A,R> mapViewsManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
freePickmap()
Unloads the map file.
|
File |
getFile()
Returns the underlying map file.
|
MapView<G,A,R> |
getMapView()
Returns the
MapView instance for this pickmap. |
MapControl<G,A,R> |
getPickmap()
Returns the
MapControl representing this pickmap. |
void |
getUnsavedPickmaps(Collection<MapControl<G,A,R>> unsavedPickmaps)
Returns this pickmap if it has been loaded and is modified.
|
static boolean |
isValidPickmapName(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.
|
@NotNull private static final Pattern PATTERN_VALID_PICKMAP_NAME
Pattern
that matches valid pickmap names.@NotNull private final MapFolder<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> mapFolder
@NotNull private final MapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> pickmapManager
MapManager
for creating new pickmaps.@NotNull private final MapReaderFactory<G extends GameObject<G,A,R>,A extends MapArchObject<A>> mapReaderFactory
MapReaderFactory
to use.@Nullable private MapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> pickmap
MapControl
instance representing the map file, or
null
if the map file is not loaded.@Nullable private MapView<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> pickmapView
@NotNull private final MapViewsManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> mapViewsManager
MapViewsManager
.@NotNull private final Object sync
pickmap
and pickmapView
.public MapFile(@NotNull MapFolder<G,A,R> mapFolder, @NotNull String name, @NotNull MapReaderFactory<G,A> mapReaderFactory, @NotNull MapManager<G,A,R> pickmapManager, @NotNull MapViewsManager<G,A,R> mapViewsManager) throws InvalidNameException
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 viewsInvalidNameException
- if name
is not validpublic static boolean isValidPickmapName(@NotNull CharSequence name)
name
- the name to check@Nullable public MapControl<G,A,R> getPickmap()
MapControl
representing this pickmap. Returns
null
unless loadPickmap()
was successfully called.MapControl
instance, or null if the map
file has not been loaded
@Nullable public MapView<G,A,R> getMapView()
MapView
instance for this pickmap. Returns
null
unless loadPickmap()
was successfully called.MapView
instance, or null if the map file
has not been loaded
public void loadPickmap() throws IOException
IOException
- if the map file cannot be loadedpublic void freePickmap()
loadPickmap()
.public void getUnsavedPickmaps(@NotNull Collection<MapControl<G,A,R>> unsavedPickmaps)
unsavedPickmaps
- the collection to add this
to if
modifiedpublic void remove(boolean deleteFile)
deleteFile
- if set, delete the map file as wellpublic void save() throws IOException
IOException
- if saving failspublic void revert() throws IOException
IOException
- if the pickmap cannot be loadedFeedback: webmaster
© 2003-2010 The Gridarta Developers. All rights reserved.