Gridarta Editor
TestMapControlFactory.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.mapcontrol;
21 
22 import java.util.List;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
33 
38 public class TestMapControlFactory implements MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype> {
39 
43  @NotNull
45 
49  @NotNull
51 
55  @NotNull
57 
66  this.mapWriter = mapWriter;
67  this.projectSettings = projectSettings;
68  this.mapModelFactory = mapModelFactory;
69  }
70 
71  @NotNull
72  @Override
73  public MapControl<TestGameObject, TestMapArchObject, TestArchetype> newMapControl(@Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, @Nullable final MapFile mapFile) {
74  final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelFactory.newMapModel(mapArchObject);
75  if (objects != null) {
76  mapModel.beginTransaction("init");
77  try {
78  mapModel.addObjectListToMap(objects);
79  } finally {
80  mapModel.endTransaction();
81  }
82  mapModel.resetModified();
83  }
85  mapControl.getMapModel().setMapFile(mapFile);
86  return mapControl;
87  }
88 
89  @NotNull
90  @Override
91  public MapControl<TestGameObject, TestMapArchObject, TestArchetype> newPickmapControl(@Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, @Nullable final MapFile mapFile) {
92  throw new AssertionError();
93  }
94 
95 }
net.sf.gridarta.model.archetype.TestArchetype
An Archetype implementation for testing purposes.
Definition: TestArchetype.java:30
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.mapModelFactory
final MapModelFactory< TestGameObject, TestMapArchObject, TestArchetype > mapModelFactory
The MapModelFactory for creating MapModel instances.
Definition: TestMapControlFactory.java:56
net.sf.gridarta.model.mapmodel.MapModel
A MapModel reflects the data of a map.
Definition: MapModel.java:75
net.sf.gridarta.model.mapcontrol.MapControlFactory
Factory for creating MapControl instances.
Definition: MapControlFactory.java:34
net.sf.gridarta.model.mapmodel.MapModel.resetModified
void resetModified()
Resets the modified flag to false.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.mapcontrol.TestMapControlFactory
An MapControlFactory implementation for testing purposes.
Definition: TestMapControlFactory.java:38
net.sf.gridarta.model.mapmodel.MapModel.endTransaction
void endTransaction()
End a transaction.
net.sf.gridarta.model.gameobject.TestGameObject
A GameObject implementation for testing purposes.
Definition: TestGameObject.java:34
net.sf
net.sf.gridarta.model.mapmodel.MapModel.beginTransaction
void beginTransaction(@NotNull String name)
Starts a new transaction.
net.sf.gridarta.model.mapmodel
Definition: AboveFloorInsertionMode.java:20
net.sf.gridarta.model.mapmodel.MapModelFactory
A factory for creating MapModel instances.
Definition: MapModelFactory.java:35
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.newMapControl
MapControl< TestGameObject, TestMapArchObject, TestArchetype > newMapControl(@Nullable final List< TestGameObject > objects, @NotNull final TestMapArchObject mapArchObject, @Nullable final MapFile mapFile)
Definition: TestMapControlFactory.java:73
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.projectSettings
final ProjectSettings projectSettings
The ProjectSettings to use.
Definition: TestMapControlFactory.java:50
net.sf.gridarta.model.io.MapWriter
Interface for classes that write map files.
Definition: MapWriter.java:34
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.mapWriter
final MapWriter< TestGameObject, TestMapArchObject, TestArchetype > mapWriter
The MapWriter for saving MapControl instances.
Definition: TestMapControlFactory.java:44
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.TestMapControlFactory
TestMapControlFactory(@NotNull final MapWriter< TestGameObject, TestMapArchObject, TestArchetype > mapWriter, @NotNull final ProjectSettings projectSettings, @NotNull final MapModelFactory< TestGameObject, TestMapArchObject, TestArchetype > mapModelFactory)
Creates a new instance.
Definition: TestMapControlFactory.java:65
net.sf.gridarta.model.mapmodel.MapFile
The location of a map file with a map directory.
Definition: MapFile.java:31
net.sf.gridarta.model.io
Reading and writing of maps, handling of paths.
Definition: AbstractAnimationObjectsReader.java:20
net.sf.gridarta.model.settings.ProjectSettings
Settings that apply to a project.
Definition: ProjectSettings.java:29
net.sf.gridarta.model
net.sf.gridarta.model.mapmodel.MapModel.setMapFile
void setMapFile(@Nullable MapFile mapFile)
Sets the map file.
net.sf.gridarta.model.mapcontrol.MapControl
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
net.sf.gridarta.model.mapcontrol.MapControl.getMapModel
MapModel< G, A, R > getMapModel()
Returns the map model.
net.sf.gridarta.model.maparchobject.TestMapArchObject
A MapArchObject implementation for testing purposes.
Definition: TestMapArchObject.java:28
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.mapcontrol.DefaultMapControl
Implements map models.
Definition: DefaultMapControl.java:44
net.sf.gridarta.model.mapmodel.MapModel.addObjectListToMap
void addObjectListToMap(@NotNull Iterable< G > objects)
Adds a list of GameObjects to this map.
net.sf.gridarta.model.mapcontrol.TestMapControlFactory.newPickmapControl
MapControl< TestGameObject, TestMapArchObject, TestArchetype > newPickmapControl(@Nullable final List< TestGameObject > objects, @NotNull final TestMapArchObject mapArchObject, @Nullable final MapFile mapFile)
Definition: TestMapControlFactory.java:91
net.sf.gridarta.model.settings
Definition: AbstractDefaultProjectSettings.java:20