Package net.sf.gridarta.model.mapcontrol
Class DefaultMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.mapcontrol.DefaultMapControl<G,A,R>
-
- All Implemented Interfaces:
MapControl<G,A,R>
public class DefaultMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends java.lang.Object implements MapControl<G,A,R>
Implements map models.
-
-
Constructor Summary
Constructors Constructor Description DefaultMapControl(@NotNull MapModel<G,A,R> mapModel, boolean isPickmap, @NotNull MapWriter<G,A,R> mapWriter, @NotNull ProjectSettings projectSettings)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidacquire()Increases the use counter.voidaddMapControlListener(@NotNull MapControlListener<G,A,R> listener)Registers aMapControlListener.@NotNull MapModel<G,A,R>getMapModel()Returns the map model.intgetUseCounter()Returns the use counter.booleanisPickmap()Return flag that indicates whether this is a pickmap or not.voidrelease()Decreases the use counter and possibly frees the map control.voidremoveMapControlListener(@NotNull MapControlListener<G,A,R> listener)Unregisters aMapControlListener.voidsave()Saves the map to a file.voidsaveAs(@NotNull MapFile mapFile)Saves the file with the given map file.
-
-
-
Constructor Detail
-
DefaultMapControl
public DefaultMapControl(@NotNull @NotNull MapModel<G,A,R> mapModel, boolean isPickmap, @NotNull @NotNull MapWriter<G,A,R> mapWriter, @NotNull @NotNull ProjectSettings projectSettings)Creates a new instance.- Parameters:
mapModel- the map model to useisPickmap- true if this is a pickmapmapWriter- the map writer for saving map control instancesprojectSettings- the project settings to use
-
-
Method Detail
-
addMapControlListener
public void addMapControlListener(@NotNull @NotNull MapControlListener<G,A,R> listener)Description copied from interface:MapControlRegisters aMapControlListener.- Specified by:
addMapControlListenerin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- the listener to register
-
removeMapControlListener
public void removeMapControlListener(@NotNull @NotNull MapControlListener<G,A,R> listener)Description copied from interface:MapControlUnregisters aMapControlListener.- Specified by:
removeMapControlListenerin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
listener- the listener to unregister
-
acquire
public void acquire()
Description copied from interface:MapControlIncreases the use counter.- Specified by:
acquirein interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
release
public void release()
Description copied from interface:MapControlDecreases the use counter and possibly frees the map control.- Specified by:
releasein interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
getUseCounter
public int getUseCounter()
Description copied from interface:MapControlReturns the use counter.- Specified by:
getUseCounterin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the use counter
-
isPickmap
public boolean isPickmap()
Description copied from interface:MapControlReturn flag that indicates whether this is a pickmap or not.- Specified by:
isPickmapin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- flag that indicates whether this is a pickmap or not
-
save
public void save() throws java.io.IOExceptionDescription copied from interface:MapControlSaves the map to a file.- Specified by:
savein interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Throws:
java.io.IOException- if saving fails
-
saveAs
public void saveAs(@NotNull @NotNull MapFile mapFile) throws java.io.IOExceptionDescription copied from interface:MapControlSaves the file with the given map file. This implicitly sets the map file and resets the modified state.- Specified by:
saveAsin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
mapFile- the map file to be saved to- Throws:
java.io.IOException- if saving fails; in this case the modified flag is not reset
-
getMapModel
@NotNull public @NotNull MapModel<G,A,R> getMapModel()
Description copied from interface:MapControlReturns the map model.- Specified by:
getMapModelin interfaceMapControl<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the map model
-
-