 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.mapcontrol;
23 import java.io.IOException;
60 import org.jetbrains.annotations.NotNull;
61 import org.jetbrains.annotations.Nullable;
62 import org.junit.Assert;
180 return mapManager.newMap(
null, mapArchObject, mapFile,
true);
315 @Nullable File directoryToDelete = mapsDirectory;
318 directoryToDelete =
null;
320 if (directoryToDelete !=
null) {
324 return mapsDirectory;
332 private void createMaps(@NotNull
final String @NotNull [] specs)
throws IOException {
333 for (
final String spec : specs) {
335 if (tmp.length != 2) {
336 throw new IllegalArgumentException(
"syntax error: " + spec);
340 final String mapName = tmp[1];
342 final File file = mapFile.
getFile();
343 if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) {
344 throw new IOException(
"cannot create directory: " + file.getParentFile());
350 mapControl.
saveAs(mapFile);
363 private static File
createTempDir(@NotNull
final String prefix)
throws IOException {
364 final String tmpDir = System.getProperty(
"java.io.tmpdir");
365 if (tmpDir ==
null) {
366 throw new IOException(
"the system property 'java.io.tmpdir' does not exist");
369 final File tmpFile =
new File(tmpDir);
370 if (!tmpFile.exists() && !tmpFile.mkdirs()) {
371 throw new IOException(
"cannot create temporary directory " + tmpFile);
374 final File result = File.createTempFile(prefix,
null);
375 if (!result.delete()) {
376 throw new IOException(
"cannot delete temporary file " + result);
378 if (!result.mkdir()) {
379 throw new IOException(
"cannot create temporary directory " + result);
390 final File[]
files = dir.listFiles();
392 for (
final File file :
files) {
393 if (file.isDirectory()) {
395 }
else if (!file.delete()) {
396 Assert.fail(
"cannot delete file " + file);
401 Assert.fail(
"cannot delete directory " + dir);
An Archetype implementation for testing purposes.
InsertionModeSet< TestGameObject, TestMapArchObject, TestArchetype > getInsertionModeSet()
Returns the InsertionModeSet instance.
File createMapsDirectory(@NotNull final String... specs)
Creates a maps directory consisting of a set of maps.
MapManager< TestGameObject, TestMapArchObject, TestArchetype > getMapManager()
Returns the MapManager.
final PathManager pathManager
The PathManager instance.
A MapModel reflects the data of a map.
void saveAs(@NotNull MapFile mapFile)
Saves the file with the given map file.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
final MapArchObjectParserFactory< TestMapArchObject > mapArchObjectParserFactory
The MapArchObjectParserFactory instance.
A MapManager manages all opened maps.
TestMapModelHelper newTestMapModelHelper()
Creates a new TestMapModelHelper instance.
The view of the archetype chooser.
Base package of all Gridarta classes.
An MapControlFactory implementation for testing purposes.
Helper class for creating MapModel instances for regression tests.
static final Pattern PATTERN_COLON
The pattern that matches a single colon (":").
Standard Edition Runtime Environment README Import and export control rules on cryptographic software vary from country to country The Java Cryptography Java provides two different sets of cryptographic policy files
Abstract base class for MapManager implementations.
void setFileControl(@NotNull final FileControl< G, A, R > fileControl)
InsertionModeSet< TestGameObject, TestMapArchObject, TestArchetype > getInsertionModeSet()
Returns the InsertionModeSet.
A MapArchObjectFactory for regression tests.
A factory for creating MapReader instances.
A GameObject implementation for testing purposes.
final MapArchObjectFactory< TestMapArchObject > mapArchObjectFactory
The MapArchObjectFactory instance.
This class contains methods for converting relative map paths to absolute map paths and vice versa.
Factory for creating MapArchObjectParser instances.
final MapManager< TestGameObject, TestMapArchObject, TestArchetype > mapManager
The MapManager instance.
Helper class for regression tests to create MapModel instances.
Implements AutojoinList related functions.
void setMapName(@NotNull final String name)
A factory for creating MapModel instances.
static void deleteTempDir(@NotNull final File dir)
Deletes a temporary directory.
Interface for classes that match GameObjects.
final MapModelFactory< TestGameObject, TestMapArchObject, TestArchetype > mapModelFactory
The MapModelFactory instance.
Selects valid exit game objects from maps.
A FileControl implementation for testing purposes.
MapModelFactory< TestGameObject, TestMapArchObject, TestArchetype > getMapModelFactory()
Returns the MapModelFactory instance.
PathManager getPathManager()
Returns the PathManager.
void createMaps(@NotNull final String @NotNull[] specs)
Creates a set of map files in the maps directory.
AutojoinLists< TestGameObject, TestMapArchObject, TestArchetype > getAutojoinLists()
Returns the AutojoinLists instance.
void setMapSize(@NotNull final Size2D mapSize)
MapArchObjectFactory< TestMapArchObject > getMapArchObjectFactory()
Returns the MapArchObjectFactory instance.
static File createTempDir(@NotNull final String prefix)
Creates an empty directory in the default temporary directory using the given prefix.
ArchetypeSet< TestGameObject, TestMapArchObject, TestArchetype > getArchetypeSet()
Returns the ArchetypeSet.
Helper class for creating MapControl instances for regression tests.
final MapManager< TestGameObject, TestMapArchObject, TestArchetype > pickmapManager
The pickmap MapManager instance.
GameObjects are the objects based on Archetypes found on maps.
MapModel< TestGameObject, TestMapArchObject, TestArchetype > newMapModel(final int w, final int h)
Creates a new MapModel instance.
An GameObjectMatcher matching certain archetype types.
FaceObjectProviders getFaceObjectProviders()
Returns the FaceObjectProviders instance.
GameObjectFactory< TestGameObject, TestMapArchObject, TestArchetype > getGameObjectFactory()
Returns the GameObjectFactory instance.
Interface for classes that write map files.
Classes related to matching {GameObjects}, so called { net.sf.gridarta.model.match....
TestMapModelHelper newMapModelCreator()
Creates a new TestMapModelHelper instance.
A MapArchObjectParserFactory for regression tests.
ArchetypeSet< TestGameObject, TestMapArchObject, TestArchetype > getArchetypeSet()
Returns the ArchetypeSet.
Default implementation of MapWriter.
MapFile getMapFile(@NotNull final AbsoluteMapPath mapPath)
Returns a MapFile instance from an AbsoluteMapPath.
An ProjectSettings implementation for testing purposes.
File getFile()
Returns a File for this map file.
MapWriter< TestGameObject, TestMapArchObject, TestArchetype > getMapWriter()
Returns the MapWriter instance.
Interface that captures similarities between different ArchetypeSet implementations.
MapManager< TestGameObject, TestMapArchObject, TestArchetype > getPickmapManager()
Returns the pickmap manager instance.
void setMapsDirectory(@NotNull File mapsDirectory)
Sets the default maps directory.
DefaultMapReader< TestGameObject, TestMapArchObject, TestArchetype > newMapReader(@NotNull final File mapFile)
Creates a new instance.
GameObjectMatchers getGameObjectMatchers()
Returns the GameObjectMatchers instance.
Utility class for string manipulation.
The location of a map file with a map directory.
Reading and writing of maps, handling of paths.
Settings that apply to a project.
Default implementation of MapReader.
TestMapControlCreator()
Creates a new instance.
InsertionMode getTopmostInsertionMode()
Returns the "topmost" insertion mode.
ProjectSettings getProjectSettings()
Returns the ProjectSettings.
static final int EXIT_TYPE
The archetype type used for "exit" game objects.
final ExitMatcher< TestGameObject, TestMapArchObject, TestArchetype > exitMatcher
The ExitMatcher instance.
MapControl< TestGameObject, TestMapArchObject, TestArchetype > newMapControl(@Nullable final MapFile mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize)
Creates a new map control.
An Exception indicating that an Archetype name is not unique.
An MapReaderFactory implementation for testing purposes.
Currently nothing more than a marker interface for unification.
TestMapModelCreator getMapModelCreator()
Returns the TestMapModelCreator instance.
MapModel< G, A, R > getMapModel()
Returns the map model.
A MapArchObject implementation for testing purposes.
ExitMatcher< TestGameObject, TestMapArchObject, TestArchetype > getExitMatcher()
Returns the ExitMatcher.
File getMapsDirectory()
Returns the default maps directory.
Interface for classes that read or write GameObject instances.
final MapWriter< TestGameObject, TestMapArchObject, TestArchetype > mapWriter
The MapWriter instance.
A newMapArchObject(boolean addDefaultAttributes)
Creates a new MapArchObject instance.
The class Size2D represents a 2d rectangular area.
final GameObjectParser< TestGameObject, TestMapArchObject, TestArchetype > gameObjectParser
The GameObjectParser instance.
final ProjectSettings projectSettings
The ProjectSettings instance.
Factory for creating MapArchObject instances.
GameObjectParser< TestGameObject, TestMapArchObject, TestArchetype > newGameObjectParser()
Creates a new GameObjectParser instance.
AutojoinListsHelper newAutojoinListsHelper()
Returns a new AutojoinListsHelper instance.
final TestMapModelCreator mapModelCreator
The TestMapModelCreator instance.