 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.mapcontrol;
23 import java.io.FileOutputStream;
24 import java.io.IOException;
25 import java.io.OutputStream;
26 import java.io.OutputStreamWriter;
27 import java.io.Writer;
28 import java.util.Collection;
29 import java.util.concurrent.CopyOnWriteArrayList;
38 import org.jetbrains.annotations.NotNull;
50 private final Collection<MapControlListener<G, A, R>>
listenerList =
new CopyOnWriteArrayList<>();
132 final File dir = file.getParentFile();
133 if (dir !=
null && !dir.exists() && !dir.mkdirs()) {
134 throw new IOException(
"cannot create directory: " + dir);
136 try (OutputStream outputStream =
new FileOutputStream(file)) {
144 public void save() throws IOException {
146 if (mapFile ==
null) {
147 throw new IllegalStateException(
"map file is unset");
164 private void save(@NotNull
final MapFile mapFile)
throws IOException {
171 listener.saved(
this);
final MapWriter< G, A, R > mapWriter
The MapWriter for saving this map.
A MapModel reflects the data of a map.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
void resetModified()
Resets the modified flag to false.
void addMapControlListener(@NotNull final MapControlListener< G, A, R > listener)
Base package of all Gridarta classes.
DefaultMapControl(@NotNull final MapModel< G, A, R > mapModel, final boolean isPickmap, @NotNull final MapWriter< G, A, R > mapWriter, @NotNull final ProjectSettings projectSettings)
Creates a new instance.
void saveAs(@NotNull final MapFile mapFile)
MapModel< G, A, R > getMapModel()
Reflects a game object (object on a map).
final MapModel< G, A, R > mapModel
The MapModel.
boolean isModified()
Return whether the map has been modified from the on-disk state.
void encodeMapFile(@NotNull final File file)
Saves the map.
GameObjects are the objects based on Archetypes found on maps.
String getUserName()
Returns the user name.
Interface for classes that write map files.
void removeMapControlListener(@NotNull final MapControlListener< G, A, R > listener)
Interface for MapArchObjects.
int useCounter
The use counter.
final ProjectSettings projectSettings
The ProjectSettings to use.
The location of a map file with a map directory.
Reading and writing of maps, handling of paths.
Settings that apply to a project.
void save(@NotNull final MapFile mapFile)
Updates the maps "Updated:" flag, saves it into the given {}, resets its modified and notifies all li...
void encodeMapFile(@NotNull MapModel< G, A, R > mapModel, @NotNull Writer writer)
Write the whole map-data into a file.
void setMapFile(@Nullable MapFile mapFile)
Sets the map file.
Utility-class for Gridarta's I/O.
Currently nothing more than a marker interface for unification.
MapFile getMapFile()
Returns the map file.
final Collection< MapControlListener< G, A, R > > listenerList
The registered event listeners.
final boolean isPickmap
Flag that indicates whether this is a pickmap or not.
static final String MAP_ENCODING
Encoding to use for maps and other data.