Package net.sf.gridarta.model.mapmanager
Class AbstractMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.mapmanager.AbstractMapManager<G,A,R>
-
- All Implemented Interfaces:
MapManager<G,A,R>
- Direct Known Subclasses:
DefaultMapManager,DefaultPickmapManager
public abstract class AbstractMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements MapManager<G,A,R>
Abstract base class forMapManagerimplementations.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractMapManager(@NotNull MapReaderFactory<G,A> mapReaderFactory, @NotNull ProjectSettings projectSettings, @NotNull FaceObjectProviders faceObjectProviders, @NotNull PathManager pathManager)Creates a instance.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddMapManagerListener(@NotNull MapManagerListener<G,A,R> listener)Adds aMapManagerListenerto be notified.voidcloseMap(@NotNull MapControl<G,A,R> mapControl)Closes the given map, ignoring modified status.protected abstract @NotNull MapControl<G,A,R>createMapControl(@Nullable java.util.List<G> objects, A mapArchObject, @Nullable MapFile mapFile)Creates a newMapControlinstance.@Nullable MapControl<G,A,R>getCurrentMap()Returns the current top map we are working with.java.io.FilegetLocalMapDir()Returns a guess for a script directory to use.@NotNull java.util.List<MapControl<G,A,R>>getOpenedMaps()Returns all opened maps.@Nullable MapControl<G,A,R>getOpenMap()Returns one open map.@NotNull MapControl<G,A,R>newMap(@Nullable java.util.List<G> objects, A mapArchObject, @Nullable MapFile mapFile, boolean interactive)Creates a new map control without view.@NotNull MapControl<G,A,R>openMapFile(@NotNull java.io.File file, boolean interactive)Loads a map file.@NotNull MapControl<G,A,R>openMapFile(@NotNull MapFile mapFile, boolean interactive)Loads a map file.voidrelease(@NotNull MapControl<G,A,R> mapControl)Releases aMapControlinstance.voidremoveMapManagerListener(@NotNull MapManagerListener<G,A,R> listener)Removes aMapManagerListenerto be notified.voidrevert(@NotNull MapControl<G,A,R> mapControl)Reverts one map.voidsetCurrentMap(@Nullable MapControl<G,A,R> mapControl)Sets the given map as the current one.voidsetFileControl(@NotNull FileControl<G,A,R> fileControl)Deprecated.
-
-
-
Constructor Detail
-
AbstractMapManager
protected AbstractMapManager(@NotNull @NotNull MapReaderFactory<G,A> mapReaderFactory, @NotNull @NotNull ProjectSettings projectSettings, @NotNull @NotNull FaceObjectProviders faceObjectProviders, @NotNull @NotNull PathManager pathManager)Creates a instance.- Parameters:
mapReaderFactory- the map reader factory instanceprojectSettings- the project settings instancefaceObjectProviders- the face object providerspathManager- the path manager for converting file instances
-
-
Method Detail
-
setFileControl
@Deprecated public void setFileControl(@NotNull @NotNull FileControl<G,A,R> fileControl)Deprecated.
-
newMap
@NotNull public @NotNull MapControl<G,A,R> newMap(@Nullable @Nullable java.util.List<G> objects, @NotNull A mapArchObject, @Nullable @Nullable MapFile mapFile, boolean interactive)
Description copied from interface:MapManagerCreates a new map control without view. The returned instance must be freed withMapManager.release(MapControl)when not needed anymore.- Specified by:
newMapin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
objects- the game objects to insert; may benullmapArchObject- the map arch object for the new mapmapFile- the map file, ornullif the map was not yet savedinteractive- if set, the new map becomes the current map- Returns:
- the newly created map control
-
createMapControl
@NotNull protected abstract @NotNull MapControl<G,A,R> createMapControl(@Nullable @Nullable java.util.List<G> objects, @NotNull A mapArchObject, @Nullable @Nullable MapFile mapFile)
Creates a newMapControlinstance.- Parameters:
objects- the objects to insert into the new mapmapArchObject- the map arch object to use for the new mapmapFile- the associated map file- Returns:
- the new map control instance
-
getOpenMap
@Nullable public @Nullable MapControl<G,A,R> getOpenMap()
Description copied from interface:MapManagerReturns one open map.- Specified by:
getOpenMapin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the map or
nullif no open maps exist
-
closeMap
public void closeMap(@NotNull @NotNull MapControl<G,A,R> mapControl)Description copied from interface:MapManagerCloses the given map, ignoring modified status.- Specified by:
closeMapin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map to close
-
openMapFile
@NotNull public @NotNull MapControl<G,A,R> openMapFile(@NotNull @NotNull MapFile mapFile, boolean interactive) throws java.io.IOException
Description copied from interface:MapManagerLoads a map file. The returned instance must be freed withMapManager.release(MapControl)when not needed anymore.- Specified by:
openMapFilein interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapFile- the map file to loadinteractive- if set, may ask to delete undefined archetypes; if unset, keep undefined archetypes- Returns:
- the map control
- Throws:
java.io.IOException- if an I/O error occurs
-
openMapFile
@NotNull public @NotNull MapControl<G,A,R> openMapFile(@NotNull @NotNull java.io.File file, boolean interactive) throws java.io.IOException
Description copied from interface:MapManagerLoads a map file. The returned instance must be freed withMapManager.release(MapControl)when not needed anymore.- Specified by:
openMapFilein interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
file- the map file to loadinteractive- if set, may ask to delete undefined archetypes; if unset, keep undefined archetypes- Returns:
- the map control
- Throws:
java.io.IOException- if an I/O error occurs
-
setCurrentMap
public void setCurrentMap(@Nullable @Nullable MapControl<G,A,R> mapControl)Description copied from interface:MapManagerSets the given map as the current one.- Specified by:
setCurrentMapin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- theMapControlof the new current map
-
getOpenedMaps
@NotNull public @NotNull java.util.List<MapControl<G,A,R>> getOpenedMaps()
Description copied from interface:MapManagerReturns all opened maps.- Specified by:
getOpenedMapsin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the opened maps
-
getCurrentMap
@Nullable public @Nullable MapControl<G,A,R> getCurrentMap()
Returns the current top map we are working with.- Specified by:
getCurrentMapin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the current top map we are working with, or
nullif no map is open
-
addMapManagerListener
public void addMapManagerListener(@NotNull @NotNull MapManagerListener<G,A,R> listener)Description copied from interface:MapManagerAdds aMapManagerListenerto be notified.- Specified by:
addMapManagerListenerin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- the listener to add
-
removeMapManagerListener
public void removeMapManagerListener(@NotNull @NotNull MapManagerListener<G,A,R> listener)Description copied from interface:MapManagerRemoves aMapManagerListenerto be notified.- Specified by:
removeMapManagerListenerin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- the listener to remove
-
revert
public void revert(@NotNull @NotNull MapControl<G,A,R> mapControl) throws java.io.IOExceptionDescription copied from interface:MapManagerReverts one map.- Specified by:
revertin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map to revert- Throws:
java.io.IOException- if an I/O error occurs
-
getLocalMapDir
public java.io.File getLocalMapDir()
Description copied from interface:MapManagerReturns a guess for a script directory to use.- Specified by:
getLocalMapDirin interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the directory
-
release
public void release(@NotNull @NotNull MapControl<G,A,R> mapControl)Description copied from interface:MapManagerReleases aMapControlinstance.- Specified by:
releasein interfaceMapManager<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapControl- the map control instance
-
-