20 package net.sf.gridarta.model.mapmanager;
23 import java.io.IOException;
24 import java.util.Collection;
25 import java.util.Collections;
26 import java.util.Iterator;
27 import java.util.List;
28 import java.util.concurrent.CopyOnWriteArrayList;
41 import org.jetbrains.annotations.NotNull;
42 import org.jetbrains.annotations.Nullable;
82 private final List<MapControl<G, A, R>>
mapControls =
new CopyOnWriteArrayList<>();
87 private final Collection<MapManagerListener<G, A, R>>
listenerList =
new CopyOnWriteArrayList<>();
110 public void facesReloaded() {
117 faceObjectProviders.addFaceObjectProvidersListener(faceObjectProvidersListener);
131 listener.mapCreated(mapControl, interactive);
162 listener.mapClosing(mapControl);
164 assert mapControl.getUseCounter() <= 0;
170 listener.mapClosed(mapControl);
172 mapControl.getMapModel().mapClosed();
181 final MapFile tmpMapFile = mapControl.getMapModel().getMapFile();
182 if (tmpMapFile !=
null && tmpMapFile.
equals(mapFile)) {
183 mapControl.acquire();
213 }
catch (
final OutOfMemoryError ex) {
214 throw new IOException(
"out of memory", ex);
217 int outOfMapBoundsDeleted = 0;
218 final StringBuilder outOfMapBoundsObjects =
new StringBuilder();
222 while (it.hasNext()) {
225 final int minX = gameObject.
getHead().getMapX() + gameObject.
getMinX();
226 final int minY = gameObject.
getHead().getMapY() + gameObject.
getMinY();
227 final int maxX = gameObject.
getHead().getMapX() + gameObject.
getMaxX();
228 final int maxY = gameObject.
getHead().getMapY() + gameObject.
getMaxY();
229 if (minX < 0 || minY < 0 || maxX >= mapWidth || maxY >= mapHeight) {
231 if (gameObject.
isHead()) {
232 outOfMapBoundsDeleted++;
234 outOfMapBoundsObjects.append(
'\n');
235 outOfMapBoundsObjects.append(gameObject.
getBestName());
236 outOfMapBoundsObjects.append(
" at ");
237 outOfMapBoundsObjects.append(minX).append(
'/').append(minY);
238 if (minX != maxX || minY != maxY) {
239 outOfMapBoundsObjects.append(
"..");
240 outOfMapBoundsObjects.append(maxX).append(
'/').append(maxY);
243 outOfMapBoundsObjects.append(
"\n...");
249 if (interactive && outOfMapBoundsDeleted > 0) {
298 final MapFile mapFile = mapControl.getMapModel().getMapFile();
299 if (mapFile ==
null) {
309 mapArchObject.beginTransaction();
313 mapArchObject.endTransaction();
326 if (mapControl ==
null) {
331 if (mapFile ==
null) {
335 return mapFile.
getFile().getParentFile();
340 mapControl.release();
341 if (mapControl.getUseCounter() <= 0) {