 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.model.index;
23 import java.io.IOException;
24 import java.util.Collection;
25 import java.util.Iterator;
26 import java.util.concurrent.atomic.AtomicInteger;
35 import org.jetbrains.annotations.NotNull;
36 import org.junit.Assert;
37 import org.junit.Test;
51 public void test1() throws InterruptedException, IOException {
54 final File mapsDirectory = mapControlCreator.
createMapsDirectory(
"map1:Map1",
"path/map2:Map Name2");
76 public void test2() throws InterruptedException, IOException {
78 final File mapsDirectory = mapControlCreator.
createMapsDirectory(
"map1:Map1",
"path/map2:Map Name2");
81 final AtomicInteger indexingFinished =
new AtomicInteger();
85 public void valueAdded(@NotNull
final MapFile value) {
89 public void valueRemoved(@NotNull
final MapFile value) {
93 public void nameChanged() {
97 public void pendingChanged() {
101 public void indexingFinished() {
102 indexingFinished.incrementAndGet();
110 Assert.assertEquals(1, indexingFinished.getAndSet(0));
116 Assert.assertEquals(0, indexingFinished.getAndSet(0));
121 Assert.assertEquals(1, indexingFinished.getAndSet(0));
139 private static void assertEquals(@NotNull
final Collection<MapFile> mapPaths, @NotNull
final File mapsDirectory, @NotNull
final String mapPath) {
140 Assert.assertEquals(1, mapPaths.size());
141 final Iterator<MapFile>
it = mapPaths.iterator();
143 Assert.assertEquals(mapsDirectory, mapFile.
getMapsDir());
An Archetype implementation for testing purposes.
File createMapsDirectory(@NotNull final String... specs)
Creates a maps directory consisting of a set of maps.
MapManager< TestGameObject, TestMapArchObject, TestArchetype > getMapManager()
Returns the MapManager.
String getPath()
Returns the map path information.
Base package of all Gridarta classes.
A GameObject implementation for testing purposes.
static void assertEquals(@NotNull final Collection< MapFile > mapPaths, @NotNull final File mapsDirectory, @NotNull final String mapPath)
Checks that a Collection of Files contains exactly one expected value.
void addIndexListener(@NotNull final IndexListener< V > listener)
Adds an IndexListener to be notified of changes.
static void deleteTempDir(@NotNull final File dir)
Deletes a temporary directory.
AbsoluteMapPath getMapPath()
Returns the map path within getMapsDir().
PathManager getPathManager()
Returns the PathManager.
void start()
Starts indexing.
Helper class for creating MapControl instances for regression tests.
GameObjects are the objects based on Archetypes found on maps.
void stop()
Stops indexing.
File getMapsDir()
Returns the base directory this map file is part of.
MapFile getMapFile(@NotNull final AbsoluteMapPath mapPath)
Returns a MapFile instance from an AbsoluteMapPath.
Maintains a MapsIndex for the maps directory.
void save()
Saves the map to a file.
The location of a map file with a map directory.
Settings that apply to a project.
void waitForIdle()
Blocks the calling thread until all pending maps have been indexed.
Regression tests for MapsIndexer.
ProjectSettings getProjectSettings()
Returns the ProjectSettings.
Collection< V > findPartialName(@NotNull final String name)
Returns all matching values for a (possibly partial) key name.
Interface for listeners interested in Index related events.
MapControl< TestGameObject, TestMapArchObject, TestArchetype > newMapControl(@Nullable final MapFile mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize)
Creates a new map control.
Currently nothing more than a marker interface for unification.
Indexes maps by map name.
A MapArchObject implementation for testing purposes.
File getMapsDirectory()
Returns the default maps directory.
void test2()
Checks that IndexListener#finalize() is called once after indexing has completed.
void test1()
Checks that basic indexing works as expected.
The class Size2D represents a 2d rectangular area.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it