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;
37 import org.jetbrains.annotations.NotNull;
96 listenerList.
add(listener);
101 listenerList.
remove(listener);
111 assert useCounter > 0;
131 final File dir = file.getParentFile();
132 if (dir != null && !dir.exists() && !dir.mkdirs()) {
133 throw new IOException(
"cannot create directory: " + dir);
135 try (OutputStream outputStream =
new FileOutputStream(file)) {
143 public void save() throws IOException {
145 if (mapFile == null) {
146 throw new IllegalStateException();
163 private void save(@NotNull
final MapFile mapFile)
throws IOException {
170 listener.saved(
this);
A MapModel reflects the data of a map.
T [] getListeners()
Returns an array of all the listeners.
Reading and writing of maps, handling of paths.
final EventListenerList2< MapControlListener< G, A, R > > listenerList
The registered event listeners.
Settings that apply to a project.
Interface for classes that write map files.
static final String MAP_ENCODING
Encoding to use for maps and other data.
final MapWriter< G, A, R > mapWriter
The MapWriter for saving this map.
boolean isModified()
Return whether the map has been modified from the on-disk state.
void save(@NotNull final MapFile mapFile)
Updates the maps "Updated:" flag, saves it into the given MapFile, resets its modified and notifies a...
final ProjectSettings projectSettings
The ProjectSettings to use.
int useCounter
The use counter.
void saveAs(@NotNull final MapFile mapFile)
Base package of all Gridarta classes.
final boolean isPickmap
Flag that indicates whether this is a pickmap or not.
Reflects a game object (object on a map).
Utility-class for Gridarta's I/O.
void remove(@NotNull final T listener)
Removes a listener.
Interface for listeners listening on changes in MapControl instances.
String getUserName()
Returns the user name.
GameObjects are the objects based on Archetypes found on maps.
final MapModel< G, A, R > mapModel
The MapModel.
void add(@NotNull final T listener)
Adds a listener.
void addMapControlListener(@NotNull final MapControlListener< G, A, R > listener)
Type-safe version of EventListenerList.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
Currently nothing more than a marker interface for unification.
void resetModified()
Resets the modified flag to false.
MapFile getMapFile()
Returns the map file.
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.
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.
The location of a map file with a map directory.
Interface for MapArchObjects.
void removeMapControlListener(@NotNull final MapControlListener< G, A, R > listener)
MapModel< G, A, R > getMapModel()
void encodeMapFile(@NotNull final File file)
Saves the map.