From: <aki...@us...> - 2008-07-24 18:08:13
|
Revision: 4416 http://gridarta.svn.sourceforge.net/gridarta/?rev=4416&view=rev Author: akirschbaum Date: 2008-07-24 18:08:20 +0000 (Thu, 24 Jul 2008) Log Message: ----------- Extract code into AttributeListUtils.removeAttribute(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java trunk/src/test/net/sf/gridarta/gameobject/ trunk/src/test/net/sf/gridarta/gameobject/AttributeListUtilsTest.java Added: trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java 2008-07-24 18:08:20 UTC (rev 4416) @@ -0,0 +1,67 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gameobject; + +import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class for archetype attribute related functions. + * @author Andreas Kirschbaum + */ +public class AttributeListUtils { + + /** + * The pattern for splitting attribute lines. + */ + private static final Pattern patternEndOfLine = Pattern.compile("\\s*\n"); + + /** + * Private constructor to prevent instantiation. + */ + private AttributeListUtils() { + } + + /** + * Removes an attribute from an attribute list. + * @param attributeList the attribute list to modify + * @param key the attribute key to remove + * @return the attribute list with the given key removed + */ + public static String removeAttribute(@NotNull final String attributeList, @NotNull final String key) { + if (attributeList.length() <= 0) { + return attributeList; + } + + final String prefix = key + " "; + + final String[] lines = patternEndOfLine.split(attributeList, -1); + + final StringBuilder sb = new StringBuilder(); + for (final String line : lines) { + if (line.length() > 0 && !line.startsWith(prefix)) { + sb.append(line); + sb.append('\n'); + } + } + return sb.toString(); + } + +} // class AttributeListUtils Property changes on: trunk/src/app/net/sf/gridarta/gameobject/AttributeListUtils.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-24 10:48:57 UTC (rev 4415) +++ trunk/src/app/net/sf/gridarta/gui/GameObjectAttributesPanel.java 2008-07-24 18:08:20 UTC (rev 4416) @@ -852,7 +852,7 @@ } private void applyDirectionChanges(final G gameObject, final int dir) { - gameObjectTextEditor.applyDirectionChanges(gameObject, dir, gameObject.getArchetype().getDirection()); + gameObjectTextEditor.applyDirectionChanges(dir, gameObject.getArchetype().getDirection()); applyArchPanelChanges(gameObject); setSelectedGameObject(gameObject); } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2008-07-24 10:48:57 UTC (rev 4415) +++ trunk/src/app/net/sf/gridarta/gui/gameobjecttexteditor/GameObjectTextEditor.java 2008-07-24 18:08:20 UTC (rev 4416) @@ -28,6 +28,7 @@ import javax.swing.text.Style; import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; +import net.sf.gridarta.gameobject.AttributeListUtils; import net.sf.gridarta.gameobject.GameObject; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -87,32 +88,15 @@ archEdit.setCaretPosition(0); } - public void applyDirectionChanges(@NotNull final GameObject<?, ?, ?> gameObject, final int dir, final int archDir) { - final StringBuilder newText = new StringBuilder(); - final String text = archEdit.getText(); - final int len = text.length(); - - // exlude all possible previous direction command - int start = 0; - for (int i = 0; i < len; i++) { - if (text.charAt(i) == '\n') { - if (i - start > 0) { - if (!text.regionMatches(start, "direction", 0, 9)) { - newText.append(text.substring(start, i)).append('\n'); - } - } - start = i + 1; - } - } - - // add our direction - // direction 0 is a special case: the server default value - // of a new gameObject is direction 0. So, a server defarch has direction 0 + public void applyDirectionChanges(final int dir, final int archDir) { + final String archEditText = AttributeListUtils.removeAttribute(archEdit.getText(), "direction"); + // direction 0 is a special case: the server default value of a new + // game object is direction 0. So, a server defarch has direction 0 // even without a direction command in the archetype. if (dir == 0 && archDir == 0) { - archEdit.setText(newText.toString()); + archEdit.setText(archEditText); } else { - archEdit.setText(newText.append("direction ").append(dir).append('\n').toString()); + archEdit.setText(archEditText + "direction " + dir + "\n"); } } Added: trunk/src/test/net/sf/gridarta/gameobject/AttributeListUtilsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gameobject/AttributeListUtilsTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/gameobject/AttributeListUtilsTest.java 2008-07-24 18:08:20 UTC (rev 4416) @@ -0,0 +1,59 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package test.net.sf.gridarta.gameobject; + +import net.sf.gridarta.gameobject.AttributeListUtils; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link AttributeListUtils}. + * @author Andreas Kirschbaum + */ +@SuppressWarnings({"FeatureEnvy"}) +// This is a test. It has feature envy by definition. +public class AttributeListUtilsTest { + + /** Test case for {@link AttributeListUtils#removeAttribute(String, String)}. */ + @Test + public void testRemoveAttribute() { + checkRemoveAttribute("", "abc", ""); + + checkRemoveAttribute("abc def\n", "abc", ""); + checkRemoveAttribute("abc def\n", "ab", "abc def\n"); + checkRemoveAttribute("abc def\n", "abcd", "abc def\n"); + + checkRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "abc", "ghi jkl\nmno pqr\n"); + checkRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "def", "abc def\nghi jkl\nmno pqr\n"); + checkRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "ghi", "abc def\nmno pqr\n"); + checkRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "mno", "abc def\nghi jkl\n"); + + checkRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "Abc", "abc def\nghi jkl\nmno pqr\n"); + + checkRemoveAttribute("abc def\n\nghi jkl\n\n", "xyz", "abc def\nghi jkl\n"); + checkRemoveAttribute("\n\nabc def\n\n", "ghi", "abc def\n"); + checkRemoveAttribute("\n\nabc def\n\n", "abc", ""); + } + + private static void checkRemoveAttribute(final String attributeList, final String key, final String expectedResult) { + Assert.assertEquals(expectedResult, AttributeListUtils.removeAttribute(attributeList, key)); + } + +} // class AttributeListUtilsTest Property changes on: trunk/src/test/net/sf/gridarta/gameobject/AttributeListUtilsTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-26 08:17:34
|
Revision: 4470 http://gridarta.svn.sourceforge.net/gridarta/?rev=4470&view=rev Author: akirschbaum Date: 2008-07-26 08:17:41 +0000 (Sat, 26 Jul 2008) Log Message: ----------- Move WrappingStringBuilder to net.sf.gridarta.utils. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/utils/WrappingStringBuilder.java trunk/src/test/net/sf/gridarta/utils/WrappingStringBuilderTest.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/WrappingStringBuilder.java trunk/src/test/net/sf/gridarta/WrappingStringBuilderTest.java Deleted: trunk/src/app/net/sf/gridarta/WrappingStringBuilder.java =================================================================== --- trunk/src/app/net/sf/gridarta/WrappingStringBuilder.java 2008-07-26 08:13:56 UTC (rev 4469) +++ trunk/src/app/net/sf/gridarta/WrappingStringBuilder.java 2008-07-26 08:17:41 UTC (rev 4470) @@ -1,85 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta; - -/** - * The class <code>WrappingStringBuilder</code> implements a string buffer that - * separates words by "," and wraps lines at a given margin. - * @author Andreas Kirschbaum - */ -public class WrappingStringBuilder { - - /** The {@link StringBuilder} holding the string data. */ - private final StringBuilder sb = new StringBuilder(); - - /** The maximum line length. */ - private final int maxLineLength; - - /** Set if no word was added yet, unset if at least one word was added. */ - private boolean firstWord = true; - - /** The length of the last line in {@link #sb}. */ - private int thisLineLength = 0; - - /** - * Create a new instance. - * @param maxLineLength the maximum line length - */ - public WrappingStringBuilder(final int maxLineLength) { - this.maxLineLength = maxLineLength; - } - - /** - * Append a word. - * @param str the word to append - */ - public void append(final String str) { - if (!firstWord) { - if (thisLineLength + str.length() + 1 > maxLineLength) { - sb.append(",\n"); - thisLineLength = 0; - } else { - sb.append(", "); - thisLineLength += 2; - } - } - sb.append(str); - thisLineLength += str.length(); - firstWord = false; - } - - /** - * Append an integer value. - * @param value the integer value to append - */ - public void append(final int value) { - append(Integer.toString(value)); - } - - /** - * Return the concatenated words as a string. - * @return the concatenated words - */ - @Override - public String toString() { - return sb.toString(); - } - -} // class WrappingStringBuilder Modified: trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-07-26 08:13:56 UTC (rev 4469) +++ trunk/src/app/net/sf/gridarta/archtype/CAttribBitmask.java 2008-07-26 08:17:41 UTC (rev 4470) @@ -31,8 +31,8 @@ import javax.swing.JPanel; import javax.xml.xpath.XPath; import javax.xml.xpath.XPathExpressionException; -import net.sf.gridarta.WrappingStringBuilder; import net.sf.gridarta.gui.gameobjectattributesdialog.BitmaskAttrib; +import net.sf.gridarta.utils.WrappingStringBuilder; import net.sf.japi.xml.NodeListIterator; import org.apache.log4j.Logger; import org.jetbrains.annotations.Nullable; Copied: trunk/src/app/net/sf/gridarta/utils/WrappingStringBuilder.java (from rev 4468, trunk/src/app/net/sf/gridarta/WrappingStringBuilder.java) =================================================================== --- trunk/src/app/net/sf/gridarta/utils/WrappingStringBuilder.java (rev 0) +++ trunk/src/app/net/sf/gridarta/utils/WrappingStringBuilder.java 2008-07-26 08:17:41 UTC (rev 4470) @@ -0,0 +1,85 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.utils; + +/** + * The class <code>WrappingStringBuilder</code> implements a string buffer that + * separates words by "," and wraps lines at a given margin. + * @author Andreas Kirschbaum + */ +public class WrappingStringBuilder { + + /** The {@link StringBuilder} holding the string data. */ + private final StringBuilder sb = new StringBuilder(); + + /** The maximum line length. */ + private final int maxLineLength; + + /** Set if no word was added yet, unset if at least one word was added. */ + private boolean firstWord = true; + + /** The length of the last line in {@link #sb}. */ + private int thisLineLength = 0; + + /** + * Create a new instance. + * @param maxLineLength the maximum line length + */ + public WrappingStringBuilder(final int maxLineLength) { + this.maxLineLength = maxLineLength; + } + + /** + * Append a word. + * @param str the word to append + */ + public void append(final String str) { + if (!firstWord) { + if (thisLineLength + str.length() + 1 > maxLineLength) { + sb.append(",\n"); + thisLineLength = 0; + } else { + sb.append(", "); + thisLineLength += 2; + } + } + sb.append(str); + thisLineLength += str.length(); + firstWord = false; + } + + /** + * Append an integer value. + * @param value the integer value to append + */ + public void append(final int value) { + append(Integer.toString(value)); + } + + /** + * Return the concatenated words as a string. + * @return the concatenated words + */ + @Override + public String toString() { + return sb.toString(); + } + +} // class WrappingStringBuilder Property changes on: trunk/src/app/net/sf/gridarta/utils/WrappingStringBuilder.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Deleted: trunk/src/test/net/sf/gridarta/WrappingStringBuilderTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/WrappingStringBuilderTest.java 2008-07-26 08:13:56 UTC (rev 4469) +++ trunk/src/test/net/sf/gridarta/WrappingStringBuilderTest.java 2008-07-26 08:17:41 UTC (rev 4470) @@ -1,27 +0,0 @@ -package test.net.sf.gridarta; - -import net.sf.gridarta.WrappingStringBuilder; -import static org.junit.Assert.assertEquals; -import org.junit.Test; - -/** - * Test for {@link WrappingStringBuilder}. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -@SuppressWarnings({"FeatureEnvy"}) -public class WrappingStringBuilderTest { - - /** Test for {@link WrappingStringBuilder#append(String)}. */ - @Test - public void testAppend() { - final WrappingStringBuilder sb = new WrappingStringBuilder(16); - sb.append("hello"); - sb.append("foo"); - sb.append("bar"); - sb.append("buzz"); - assertEquals("hello, foo, bar,\nbuzz", sb.toString()); - sb.append(10); - assertEquals("hello, foo, bar,\nbuzz, 10", sb.toString()); - } - -} // class WrappingStringBuilderTest Copied: trunk/src/test/net/sf/gridarta/utils/WrappingStringBuilderTest.java (from rev 4454, trunk/src/test/net/sf/gridarta/WrappingStringBuilderTest.java) =================================================================== --- trunk/src/test/net/sf/gridarta/utils/WrappingStringBuilderTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/utils/WrappingStringBuilderTest.java 2008-07-26 08:17:41 UTC (rev 4470) @@ -0,0 +1,27 @@ +package test.net.sf.gridarta.utils; + +import net.sf.gridarta.utils.WrappingStringBuilder; +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Test for {@link WrappingStringBuilder}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +@SuppressWarnings({"FeatureEnvy"}) +public class WrappingStringBuilderTest { + + /** Test for {@link WrappingStringBuilder#append(String)}. */ + @Test + public void testAppend() { + final WrappingStringBuilder sb = new WrappingStringBuilder(16); + sb.append("hello"); + sb.append("foo"); + sb.append("bar"); + sb.append("buzz"); + assertEquals("hello, foo, bar,\nbuzz", sb.toString()); + sb.append(10); + assertEquals("hello, foo, bar,\nbuzz, 10", sb.toString()); + } + +} // class WrappingStringBuilderTest Property changes on: trunk/src/test/net/sf/gridarta/utils/WrappingStringBuilderTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-28 21:24:30
|
Revision: 4554 http://gridarta.svn.sourceforge.net/gridarta/?rev=4554&view=rev Author: akirschbaum Date: 2008-07-28 21:24:38 +0000 (Mon, 28 Jul 2008) Log Message: ----------- Remove dependency MapImageCache -> MainControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/MapImageCache.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 21:15:32 UTC (rev 4553) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-28 21:24:38 UTC (rev 4554) @@ -147,7 +147,7 @@ * can be created for a map. */ protected void createMapImageCache(@Nullable final File baseDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { - mapImageCache = new MapImageCache<G, A, R, V>(this, mapManager, baseDir, defaultIcon, defaultPreview); + mapImageCache = new MapImageCache<G, A, R, V>(getMainView().getStatusBar(), mapManager, baseDir, defaultIcon, defaultPreview); mapPreviewAccessory = new MapPreviewAccessory(mapImageCache); } Modified: trunk/src/app/net/sf/gridarta/MapImageCache.java =================================================================== --- trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-07-28 21:15:32 UTC (rev 4553) +++ trunk/src/app/net/sf/gridarta/MapImageCache.java 2008-07-28 21:24:38 UTC (rev 4554) @@ -31,6 +31,7 @@ import javax.swing.ImageIcon; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.StatusBar; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; @@ -52,9 +53,9 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); - /** The main control to open map files. */ - @NotNull - private final MainControl<G, A, R, V> mainControl; + /** The status bar instance. */ + @Nullable + private final StatusBar<G, A, R, V> statusBar; /** The map manager. */ @NotNull @@ -81,7 +82,7 @@ /** * Create a new instance. - * @param mainControl Reference to CMainControl. + * @param statusBar the status bar instance * @param mapManager the map manager * @param cacheDir the directory to store cached images file; if * <code>null</code> store the image files next to the map files @@ -90,8 +91,8 @@ * @param defaultPreview the default preview image to return if no preview * can be created for a map */ - public MapImageCache(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final MapManager<G, A, R, V> mapManager, @Nullable final File cacheDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { - this.mainControl = mainControl; + public MapImageCache(@Nullable final StatusBar<G, A, R, V> statusBar, @NotNull final MapManager<G, A, R, V> mapManager, @Nullable final File cacheDir, @NotNull final ImageIcon defaultIcon, @NotNull final ImageIcon defaultPreview) { + this.statusBar = statusBar; this.mapManager = mapManager; this.cacheDir = cacheDir; defaultImages.put(Type.ICON, defaultIcon); @@ -302,7 +303,9 @@ result[0] = new ImageIcon(image.getScaledInstance(48, 23, Image.SCALE_SMOOTH)); result[1] = new ImageIcon(image.getScaledInstance(image.getWidth(null) / 8, image.getHeight(null) / 8, Image.SCALE_SMOOTH)); } catch (final OutOfMemoryError e) { - mainControl.getMainView().getStatusBar().setStatusText(ACTION_FACTORY.getString("mapImagesOutOfMemory")); + if (statusBar != null) { + statusBar.setStatusText(ACTION_FACTORY.getString("mapImagesOutOfMemory")); + } result[0] = defaultImages.get(Type.ICON); result[1] = defaultImages.get(Type.PREVIEW); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-28 21:15:32 UTC (rev 4553) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-28 21:24:38 UTC (rev 4554) @@ -387,7 +387,7 @@ final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, archetypeSet, false); final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test"); - final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, mapManager, null, new ImageIcon(), new ImageIcon()); + final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, mainControl, mapImageCache, null, mapArchObject, false, null, archetypeChooserControl, mapActions); mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(mainControl, mapControl, null, mapArchObject, null, archetypeChooserControl, mapActions); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-07-31 22:20:48
|
Revision: 4639 http://gridarta.svn.sourceforge.net/gridarta/?rev=4639&view=rev Author: akirschbaum Date: 2008-07-31 22:20:56 +0000 (Thu, 31 Jul 2008) Log Message: ----------- Remove call to MainControl.getEditTypes(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-31 22:12:44 UTC (rev 4638) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-07-31 22:20:56 UTC (rev 4639) @@ -103,8 +103,10 @@ * @param key The action factory key */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key) { - mapManager = new DefaultMapManager<G, A, R, V>(this, key); - editTypes = new EditTypes(mapManager); + DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key); + editTypes = new EditTypes(tmpMapManager); + tmpMapManager.setEditTypes(editTypes); + mapManager = tmpMapManager; copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes); this.gridartaObjectsFactory = gridartaObjectsFactory; instance = this; Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-07-31 22:12:44 UTC (rev 4638) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-07-31 22:20:56 UTC (rev 4639) @@ -57,6 +57,10 @@ @NotNull private final MainControl<G, A, R, V> mainControl; + /** The edit types. */ + @NotNull + private EditTypes<G, A, R, V> editTypes = null; + /** The recent manager. */ private RecentManager recentManager = null; @@ -79,6 +83,14 @@ this.mainControl = mainControl; } + /** + * Sets the edit types instance to use. + * @param editTypes + */ + public void setEditTypes(@NotNull final EditTypes<G, A, R, V> editTypes) { + this.editTypes = editTypes; + } + /** {@inheritDoc} */ public void addEditType(final int newType) { for (final MapControl<G, A, R, V> mapControl : levels) { @@ -198,7 +210,7 @@ } final MapView<G, A, R, V> mapView = newMapWithView(decoder.getGameObjects(), decoder.getMapArchObject(), viewPosition, file, file.getPath()); - mapView.getMapControl().setActiveEditType(mainControl.getEditTypes().getEditType()); + mapView.getMapControl().setActiveEditType(editTypes.getEditType()); mapView.getMapControl().resetModified(); recentManager.addRecent(currentMap.getMapModel().getMapArchObject().getMapDisplayName(), file.toString()); Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 22:12:44 UTC (rev 4638) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-07-31 22:20:56 UTC (rev 4639) @@ -387,6 +387,7 @@ final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, archetypeSet, false); final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test"); + final EditTypes editTypes = new EditTypes(mapManager); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, mainControl, mapImageCache, null, mapArchObject, false, null, archetypeChooserControl, mapActions); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-01 22:24:30
|
Revision: 4677 http://gridarta.svn.sourceforge.net/gridarta/?rev=4677&view=rev Author: akirschbaum Date: 2008-08-01 22:24:37 +0000 (Fri, 01 Aug 2008) Log Message: ----------- Remove call to MainControl.getGridartaObjectsFactory(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:21:01 UTC (rev 4676) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-01 22:24:37 UTC (rev 4677) @@ -111,7 +111,7 @@ */ protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings) { this.globalSettings = globalSettings; - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory); editTypes = new EditTypes(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-01 22:21:01 UTC (rev 4676) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-01 22:24:37 UTC (rev 4677) @@ -57,6 +57,12 @@ @NotNull private final MainControl<G, A, R, V> mainControl; + /** + * The gridarta objects factory instance. + */ + @NotNull + private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** The edit types. */ @NotNull private EditTypes<G, A, R, V> editTypes = null; @@ -77,10 +83,12 @@ * Create a new map manager. * @param mainControl the main control * @param key The action factory key. + * @param gridartaObjectsFactory the gridarta objects factory instance */ - public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key) { + public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory) { actionFactory = ActionFactory.getFactory(key); this.mainControl = mainControl; + this.gridartaObjectsFactory = gridartaObjectsFactory; } /** @@ -262,7 +270,7 @@ public MapReader<G, A> decodeMapFile(@NotNull final File file, final boolean isInteractive) { final MapReader<G, A> decoder; try { - decoder = mainControl.getGridartaObjectsFactory().newMapReader(file); + decoder = gridartaObjectsFactory.newMapReader(file); decoder.decodeMapFile(isInteractive); } catch (final IOException e) { if (isInteractive) { Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-01 22:21:01 UTC (rev 4676) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-01 22:24:37 UTC (rev 4677) @@ -389,7 +389,7 @@ final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, archetypeSet, false); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test"); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-08-03 14:00:17
|
Revision: 4723 http://gridarta.svn.sourceforge.net/gridarta/?rev=4723&view=rev Author: akirschbaum Date: 2008-08-03 14:00:25 +0000 (Sun, 03 Aug 2008) Log Message: ----------- Add missing serialVersionUID fields. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-08-03 13:57:15 UTC (rev 4722) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-08-03 14:00:25 UTC (rev 4723) @@ -86,6 +86,11 @@ */ public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(GameObjectAttributesDialog.class); Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-03 13:57:15 UTC (rev 4722) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-03 14:00:25 UTC (rev 4723) @@ -701,6 +701,11 @@ private static class TestMapViewBasic extends MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> { /** + * The serial version UID. + */ + private static final long serialVersionUID = 1; + + /** * Creates a new instance. * @param mapControl the map control * @param initial the initial view position This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-04 12:49:57
|
Revision: 5438 http://gridarta.svn.sourceforge.net/gridarta/?rev=5438&view=rev Author: akirschbaum Date: 2008-10-04 12:49:55 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Fix some regression test issues. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/utils/GUIUtils.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/gui/utils/GUIUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/GUIUtils.java 2008-10-04 11:11:13 UTC (rev 5437) +++ trunk/src/app/net/sf/gridarta/gui/utils/GUIUtils.java 2008-10-04 12:49:55 UTC (rev 5438) @@ -26,6 +26,7 @@ import javax.swing.ImageIcon; import net.sf.gridarta.gui.GUIConstants; import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -126,4 +127,13 @@ return getResourceIcon(GUIConstants.SYSTEM_DIR, strIconName); } + /** + * Add an image to the cache. + * @param name the name + * @param imageIcon the image icon + */ + public static void addToCache(@NotNull final String name, @NotNull final ImageIcon imageIcon) { + imageCache.put(name, imageIcon); + } + } // class GUIUtils Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-04 11:11:13 UTC (rev 5437) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-04 12:49:55 UTC (rev 5438) @@ -22,6 +22,7 @@ import java.awt.Component; import java.awt.Frame; import java.awt.Point; +import java.awt.image.BufferedImage; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -65,6 +66,7 @@ import net.sf.gridarta.gameobject.face.DuplicateFaceException; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; @@ -80,6 +82,7 @@ import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefsModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.io.AbstractGameObjectParser; import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; @@ -407,6 +410,25 @@ */ @Before public void setUp() { + final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); + for (final String iconName : new String[] { + GUIConstants.TILE_SEL_TILE, + GUIConstants.TILE_SEL_TILE_NORTH, + GUIConstants.TILE_SEL_TILE_EAST, + GUIConstants.TILE_SEL_TILE_SOUTH, + GUIConstants.TILE_SEL_TILE_WEST, + GUIConstants.TILE_PRESEL_TILE, + GUIConstants.TILE_CURSOR, + GUIConstants.TILE_EMPTY, + GUIConstants.TILE_UNKNOWN, + GUIConstants.TILE_NOFACE, + GUIConstants.TILE_NOARCH, + GUIConstants.DEFAULT_ICON, + GUIConstants.DEFAULT_PREVIEW, + GUIConstants.TILE_WARNING, + }) { + GUIUtils.addToCache(iconName, imageIcon); + } final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory = new TestMapArchObjectFactory(); final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory = new TestGameObjectParserFactory(); @@ -508,7 +530,7 @@ @NotNull @Override protected ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> newArchetypeFactory() { - throw new AssertionError(); + return new TestArchetypeFactory(); } /** {@inheritDoc} */ @@ -529,21 +551,21 @@ @NotNull @Override protected GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { - throw new AssertionError(); + return new TestGameObjectParserFactory(); } /** {@inheritDoc} */ @NotNull @Override protected MapArchObjectParserFactory<TestMapArchObject> newMapArchObjectParserFactory() { - throw new AssertionError(); + return new TestMapArchObjectParserFactory(); } /** {@inheritDoc} */ @NotNull @Override protected MapArchObjectFactory<TestMapArchObject> newMapArchObjectFactory() { - throw new AssertionError(); + return new TestMapArchObjectFactory(); } /** {@inheritDoc} */ @@ -564,7 +586,7 @@ @NotNull @Override protected GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectFactory() { - throw new AssertionError(); + return new TestGameObjectFactory(); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-04 13:10:46
|
Revision: 5440 http://gridarta.svn.sourceforge.net/gridarta/?rev=5440&view=rev Author: akirschbaum Date: 2008-10-04 13:10:42 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Remove AbstractMainControl.saveLevelAsWanted(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-04 12:55:32 UTC (rev 5439) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-04 13:10:42 UTC (rev 5440) @@ -335,7 +335,7 @@ final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); mapControlFactory.setMapReaderFactory(mapReaderFactory); - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, mapReaderFactory, mapControlFactory, globalSettings); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); final EditTypes<G, A, R, V> editTypes = new EditTypes<G, A, R, V>(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); tmpMapManager.setEditTypes(editTypes); @@ -364,7 +364,7 @@ tmpMapManager.setMainView(mainView); mapReaderFactory.setMainView(mainView); tmpMapManager.setParent(mainView); - new MapFileActions<G, A, R, V>(this, mainView, mapManager, mapViewManager, null); + final MapFileActions<G, A, R, V> mapFileActions = new MapFileActions<G, A, R, V>(this, mainView, mapManager, mapViewManager, null); newMapDialogFactory.setParent(mainView); pickmapChooserControl.setParent(mainView); final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R, V>(archetypeTypeSet, archetypeSet, mapManager, mainView); @@ -502,6 +502,8 @@ recentManager.initRecent(); new AutoValidator<G, A, R, V>(validators, mapManager, autoValidatorDefault); fileControl = new FileControl<G, A, R, V>(globalSettings, archetypeSet, mapPreviewAccessory, mapManager, mainView, mapFileFilter, scriptFileFilter, newMapDialogFactory, scriptExtension); + mapFileActions.setFileControl(fileControl); + tmpMapManager.setFileControl(fileControl); } @NotNull @@ -821,11 +823,6 @@ } /** {@inheritDoc} */ - public boolean saveLevelAsWanted(@NotNull final MapControl<G, A, R, V> mapControl) { - return fileControl.saveLevelAsWanted(mapControl); - } - - /** {@inheritDoc} */ public void handleThrowable(final Throwable t) { mainView.handleThrowable(t); } Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-04 12:55:32 UTC (rev 5439) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-04 13:10:42 UTC (rev 5440) @@ -59,7 +59,7 @@ /** The main control. */ @NotNull - private final MainControl<G, A, R, V> mainControl; + private FileControl<G, A, R, V> fileControl; /** The parent component for dialog windows. */ @NotNull @@ -105,16 +105,14 @@ /** * Create a new map manager. - * @param mainControl the main control * @param key The action factory key. * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance */ - public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings) { + public DefaultMapManager(@NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings) { this.globalSettings = globalSettings; actionFactory = ActionFactory.getFactory(key); - this.mainControl = mainControl; this.mapReaderFactory = mapReaderFactory; this.mapControlFactory = mapControlFactory; } @@ -124,6 +122,11 @@ this.mainView = mainView; } + @Deprecated + public void setFileControl(@NotNull final FileControl<G, A, R, V> fileControl) { + this.fileControl = fileControl; + } + /** * Sets the edit types instance to use. * @param editTypes the edit types @@ -476,7 +479,7 @@ mapControl.save(); return true; } else { - return mainControl.saveLevelAsWanted(mapControl); + return fileControl.saveLevelAsWanted(mapControl); } } Modified: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2008-10-04 12:55:32 UTC (rev 5439) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2008-10-04 13:10:42 UTC (rev 5440) @@ -25,7 +25,6 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -47,14 +46,6 @@ MainView<G, A, R, V> getMainView(); /** - * Invoked when user wants to save a map to certain file. - * @param mapControl the map to be saved - * @return <code>true</code> if the user confirmed saving the map and the - * map was saved successfully, otherwise <code>false</code> - */ - boolean saveLevelAsWanted(@NotNull MapControl<G, A, R, V> mapControl); - - /** * Create an image of a map and save it as a file. In this method, a * filechooser is opened to let the user select an output file name/path for * the png image. Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-10-04 12:55:32 UTC (rev 5439) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2008-10-04 13:10:42 UTC (rev 5440) @@ -22,6 +22,7 @@ import java.awt.Component; import javax.swing.Action; import net.sf.gridarta.CurrentMapListener; +import net.sf.gridarta.FileControl; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.Archetype; @@ -47,6 +48,10 @@ @NotNull private final MainControl<G, A, R, V> mainControl; + /** The file control to forward actions to. */ + @NotNull + private FileControl<G, A, R, V> fileControl; + /** The parent component for dialog windows. */ @NotNull private final Component parent; @@ -107,6 +112,11 @@ updateActions(); } + @Deprecated + public void setFileControl(@NotNull final FileControl<G, A, R, V> fileControl) { + this.fileControl = fileControl; + } + /** * Unregister all registered listeners. Must be called when this instance is * freed. @@ -194,7 +204,7 @@ public void saveAs() { final MapControl<G, A, R, V> mapControl = getSaveAsEnabled(); if (mapControl != null) { - mainControl.saveLevelAsWanted(mapControl); + fileControl.saveLevelAsWanted(mapControl); } } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-04 12:55:32 UTC (rev 5439) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-04 13:10:42 UTC (rev 5440) @@ -24,33 +24,20 @@ import java.awt.Point; import java.awt.image.BufferedImage; import java.io.File; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.Reader; -import java.util.Iterator; import java.util.List; -import java.util.Map; import java.util.SortedSet; import java.util.TreeSet; import javax.swing.ImageIcon; -import javax.swing.JComboBox; import javax.swing.JList; import javax.swing.JPanel; -import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.DefaultMapManager; -import net.sf.gridarta.EditTypes; import net.sf.gridarta.GlobalSettings; import net.sf.gridarta.GlobalSettingsImpl; -import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.MapManager; import net.sf.gridarta.Size2D; -import net.sf.gridarta.archtype.ArchetypeTypeSet; import net.sf.gridarta.autojoin.AutojoinLists; -import net.sf.gridarta.data.NamedTreeNode; -import net.sf.gridarta.filter.FilterControl; -import net.sf.gridarta.gameobject.AbstractArchetypeParser; import net.sf.gridarta.gameobject.AbstractArchetypeSet; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeFactory; @@ -58,18 +45,8 @@ import net.sf.gridarta.gameobject.FaceSource; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.GameObjectFactory; -import net.sf.gridarta.gameobject.anim.AnimationObject; -import net.sf.gridarta.gameobject.anim.AnimationObjects; -import net.sf.gridarta.gameobject.anim.AnimationParseException; -import net.sf.gridarta.gameobject.anim.DuplicateAnimationException; -import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.gridarta.gameobject.face.DuplicateFaceException; -import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.MainView; -import net.sf.gridarta.gui.MapViewManager; -import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserControl; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.gameobjectattributespanel.ScriptTab; import net.sf.gridarta.gui.map.LevelRenderer; @@ -78,9 +55,6 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.RendererFactory; -import net.sf.gridarta.gui.map.tools.ToolPalette; -import net.sf.gridarta.gui.newmap.NewMapDialogFactory; -import net.sf.gridarta.gui.prefs.AppPrefsModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.io.AbstractGameObjectParser; @@ -103,11 +77,7 @@ import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; -import net.sf.gridarta.map.validation.DelegatingMapValidator; -import net.sf.gridarta.treasurelist.CFTreasureListTree; -import net.sf.gridarta.treasurelist.TreasureTreeNode; import net.sf.japi.swing.misc.Progress; -import net.sf.japi.swing.prefs.PreferencesGroup; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; @@ -436,15 +406,12 @@ final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); - final AnimationObjects<AnimationObject> animationObjects = new TestAnimationObjects(); - final FaceObjects faceObjects = new TestFaceObjects(); final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); - final TestMainControl mainControl = new TestMainControl(rendererFactory, "test", globalSettings, animationObjects, faceObjects); final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", mapReaderFactory, mapControlFactory, globalSettings); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(); @@ -459,182 +426,6 @@ } /** - * A {@link MainControl} implementation for testing purposes. - */ - private static class TestMainControl extends AbstractMainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> { - - /** - * Creates a new instance. - * @param rendererFactory the renderer factory to use - * @param key the action factory key to use - * @param globalSettings the global settings instance to use - * @param animationObjects the animation objects instance to use - * @param faceObjects the face objects instance to use - */ - protected TestMainControl(@NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { - super(rendererFactory, key, globalSettings, animationObjects, faceObjects, true, null, null, "test.jar", new TestFileFilter(), ".script", "Script", 0, null, -1, false, 0, new int[] { 13, }, false, "scripts"); - } - - /** {@inheritDoc} */ - public void reloadFaces() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected NewMapDialogFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newNewMapDialogFactory(@NotNull final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory) { - return new NewMapDialogFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapManager, mapArchObjectFactory, 1, 1, 0, false, false, 1, 1); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory) { - return new TestArchetypeSet(archetypeFactory); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected PreferencesGroup createPreferencesGroup(@NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<TestGameObject, TestMapArchObject, TestArchetype> validators, @NotNull final AppPrefsModel appPrefsModel) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @Override - protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> newArchetypeParser(final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, final ArchetypeChooserControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { - return null; - } - - /** {@inheritDoc} */ - @Override - protected void createActions() { - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected JComboBox createEventTypeBox() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected CFTreasureListTree<TestGameObject, TestMapArchObject, TestArchetype> createTreasureListTree(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final Map<String, TreasureTreeNode> specialTreasureLists) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> newArchetypeFactory() { - return new TestArchetypeFactory(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final FilterControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> filterControl) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapReaderFactory<TestGameObject, TestMapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { - return new TestGameObjectParserFactory(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapArchObjectParserFactory<TestMapArchObject> newMapArchObjectParserFactory() { - return new TestMapArchObjectParserFactory(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapArchObjectFactory<TestMapArchObject> newMapArchObjectFactory() { - return new TestMapArchObjectFactory(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected AppPrefsModel createAppPrefsModel() { - return new AppPrefsModel("server", "client", "vim"); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newMapControlFactory() { - return new TestMapControlFactory(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectFactory() { - return new TestGameObjectFactory(); - } - - /** {@inheritDoc} */ - @Override - protected void init4(@NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @Override - protected void deleteLibraries() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected MapActions init1(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager, @NotNull final MapViewManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewManager, @NotNull final ArchetypeTypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeTypeSet, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull - @Override - protected DelegatingMapValidator<TestGameObject, TestMapArchObject, TestArchetype> createMapValidators(@NotNull final GlobalSettings globalSettings) { - throw new AssertionError(); - } - - } - - /** - * A {@link FileFilter} implementation for testing purposes. - */ - private static class TestFileFilter extends FileFilter { - - /** {@inheritDoc} */ - public boolean accept(final File f) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public String getDescription() { - throw new AssertionError(); - } - - } - - /** * A {@link MapArchObject} implementation for testing purposes. */ private static class TestMapArchObject implements MapArchObject<TestMapArchObject> { @@ -1080,95 +871,6 @@ } /** - * An {@link AnimationObjects} implementation for testing purposes. - */ - private static class TestAnimationObjects implements AnimationObjects<AnimationObject> { - - /** {@inheritDoc} */ - public void addAnimationObject(final String animName, final String list) throws DuplicateAnimationException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void addAnimPath(final String name, final String path) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void loadAnims(final File animFile, @NotNull final String startKey, final boolean ignoreOtherText) throws FileNotFoundException, IOException, AnimationParseException, DuplicateAnimationException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void loadAnims(final Reader reader, @NotNull final String startKey, final boolean ignoreOtherText, @Nullable final String path) throws IOException, AnimationParseException, DuplicateAnimationException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void loadAnimTree(final File animTreeFile) throws FileNotFoundException, IOException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public NamedTreeNode<AnimationObject> getTreeRoot() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public int size() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public AnimationObject get(final String objectName) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public boolean containsKey(final String name) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public Iterator<AnimationObject> iterator() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public String showNodeChooserDialog(final Component parentComponent, final String initial) { - throw new AssertionError(); - } - - } - - /** - * A {@link FaceObjects} implementation for testing purposes. - */ - private static class TestFaceObjects extends AbstractFaceObjects { - - /** {@inheritDoc} */ - protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - protected String getPngFile() { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - throw new AssertionError(); - } - - } - - /** * A {@link RendererFactory} implementation for testing purposes. */ private static class TestRendererFactory implements RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-11-09 11:27:49
|
Revision: 5680 http://gridarta.svn.sourceforge.net/gridarta/?rev=5680&view=rev Author: akirschbaum Date: 2008-11-09 11:27:45 +0000 (Sun, 09 Nov 2008) Log Message: ----------- Remove DefaultMapReaderFactory.setArchetypeSet(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 11:19:27 UTC (rev 5679) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-11-09 11:27:45 UTC (rev 5680) @@ -339,7 +339,7 @@ globalSettings.readGlobalSettings(); final ArchetypeFactory<G, A, R> archetypeFactory = newArchetypeFactory(); final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, archetypeFactory); - final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); mapManager = tmpMapManager; @@ -347,7 +347,6 @@ mapReaderFactory.setEditTypes(editTypes); mapControlFactory.setEditTypes(editTypes); ScriptedEventEditor.setGlobalSettings(globalSettings); - mapReaderFactory.setArchetypeSet(archetypeSet); AbstractScriptedEvent.init(archetypeSet); PathManager.setGlobalSettings(globalSettings); newMapDialogFactory = newNewMapDialogFactory(mapManager, mapArchObjectFactory); Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2008-11-09 11:19:27 UTC (rev 5679) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2008-11-09 11:27:45 UTC (rev 5680) @@ -51,7 +51,7 @@ /** The {@link ArchetypeSet} instance. */ @NotNull - private ArchetypeSet<G, A, R> archetypeSet; + private final ArchetypeSet<G, A, R> archetypeSet; /** The {@link MainView} instance to use. */ @NotNull @@ -67,11 +67,13 @@ * @param mapArchObjectParserFactory the map arch object parser factory * instance * @param gameObjectParserFactory the game object parser factory instance + * @param archetypeSet the archetype set instance */ - public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory) { + public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { this.mapArchObjectFactory = mapArchObjectFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.gameObjectParserFactory = gameObjectParserFactory; + this.archetypeSet = archetypeSet; } /** @@ -85,15 +87,6 @@ /** * Finishes object creation. - * @param archetypeSet the archetype set instance - */ - @Deprecated - public void setArchetypeSet(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { - this.archetypeSet = archetypeSet; - } - - /** - * Finishes object creation. * @param mainView the main view instance */ @Deprecated Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-09 11:19:27 UTC (rev 5679) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-11-09 11:27:45 UTC (rev 5680) @@ -404,13 +404,13 @@ final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory = new TestMapArchObjectFactory(); final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory = new TestGameObjectParserFactory(); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); + final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(mapReaderFactory); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); - final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); final TestMapArchObject mapArchObject = new TestMapArchObject(); - final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-01-26 21:08:01
|
Revision: 5887 http://gridarta.svn.sourceforge.net/gridarta/?rev=5887&view=rev Author: akirschbaum Date: 2009-01-26 21:07:58 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Remove dependency EditTypes -> MapManager. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/edittypes/EditTypes.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/edittypes/EditTypesListener.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-01-26 20:49:36 UTC (rev 5886) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-01-26 21:07:58 UTC (rev 5887) @@ -339,9 +339,9 @@ final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, archetypeFactory); final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); + final EditTypes editTypes = new EditTypes(); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings, editTypes); mapManager = tmpMapManager; - final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); mapControlFactory.setEditTypes(editTypes); ScriptedEventEditor.setGlobalSettings(globalSettings); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2009-01-26 20:49:36 UTC (rev 5886) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2009-01-26 21:07:58 UTC (rev 5887) @@ -29,6 +29,8 @@ import java.util.List; import javax.swing.JOptionPane; import javax.swing.event.EventListenerList; +import net.sf.gridarta.edittypes.EditTypes; +import net.sf.gridarta.edittypes.EditTypesListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MainView; @@ -101,17 +103,33 @@ private MainView<G, A, R, V> mainView; /** + * The listener tracking edit types changes to repaint map views after + * changes. + */ + private final EditTypesListener editTypesListener = new EditTypesListener() { + + /** {@inheritDoc} */ + @Override + public void editTypeChanged(final int editType) { + addEditType(editType); + } + + }; + + /** * Create a new map manager. * @param key The action builder key. * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance + * @param editTypes the edit types instance */ - public DefaultMapManager(@NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings) { + public DefaultMapManager(@NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes) { this.globalSettings = globalSettings; actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder(key); this.mapReaderFactory = mapReaderFactory; this.mapControlFactory = mapControlFactory; + editTypes.addEditTypesListener(editTypesListener); } @Deprecated Modified: trunk/src/app/net/sf/gridarta/edittypes/EditTypes.java =================================================================== --- trunk/src/app/net/sf/gridarta/edittypes/EditTypes.java 2009-01-26 20:49:36 UTC (rev 5886) +++ trunk/src/app/net/sf/gridarta/edittypes/EditTypes.java 2009-01-26 21:07:58 UTC (rev 5887) @@ -19,23 +19,21 @@ package net.sf.gridarta.edittypes; -import net.sf.gridarta.MapManager; +import javax.swing.event.EventListenerList; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.GUIConstants; import org.jetbrains.annotations.NotNull; public class EditTypes { - /** The map manager. */ - private final MapManager<?, ?, ?, ?> mapManager; + /** + * The {@link EditTypesListener}s to inform about changes. + */ + private final EventListenerList listenerList = new EventListenerList(); /** Bit field of edit types to show only. */ private int editType = 0; - public EditTypes(@NotNull final MapManager<?, ?, ?, ?> mapManager) { - this.mapManager = mapManager; - } - /** * Returns the currently set edit type. * @return the currently set edit type. @@ -55,8 +53,7 @@ } this.editType |= editType; - - mapManager.addEditType(editType); + fireEditTypeChanged(); } /** @@ -70,7 +67,7 @@ } this.editType &= ~editType; - mapManager.refreshAllMaps(); + fireEditTypeChanged(); } /** @@ -116,4 +113,29 @@ } } + /** + * Adds an {@link EditTypesListener} to be notified. + * @param listener the listener to add + */ + public void addEditTypesListener(@NotNull final EditTypesListener listener) { + listenerList.add(EditTypesListener.class, listener); + } + + /** + * Removes an {@link EditTypesListener} to be notified. + * @param listener the listener to remove + */ + public void removeEditTypesListener(@NotNull final EditTypesListener listener) { + listenerList.remove(EditTypesListener.class, listener); + } + + /** + * Notify all listeners about changed {@link #editType}. + */ + private void fireEditTypeChanged() { + for (final EditTypesListener listener : listenerList.getListeners(EditTypesListener.class)) { + listener.editTypeChanged(editType); + } + } + } // class EditTypes Added: trunk/src/app/net/sf/gridarta/edittypes/EditTypesListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/edittypes/EditTypesListener.java (rev 0) +++ trunk/src/app/net/sf/gridarta/edittypes/EditTypesListener.java 2009-01-26 21:07:58 UTC (rev 5887) @@ -0,0 +1,36 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.edittypes; + +import java.util.EventListener; + +/** + * Interface for listeners interested in {@link EditTypes} events. + * @author Andreas Kirschbaum + */ +public interface EditTypesListener extends EventListener { + + /** + * The edit types value has changed. + * @param editType the new edit types value + */ + void editTypeChanged(int editType); + +} // interface EditTypesListener Property changes on: trunk/src/app/net/sf/gridarta/edittypes/EditTypesListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-01-26 20:49:36 UTC (rev 5886) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-01-26 21:07:58 UTC (rev 5887) @@ -411,7 +411,8 @@ final TestMapArchObject mapArchObject = new TestMapArchObject(); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings); + final EditTypes editTypes = new EditTypes(); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings, editTypes); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-01-26 23:22:08
|
Revision: 5892 http://gridarta.svn.sourceforge.net/gridarta/?rev=5892&view=rev Author: akirschbaum Date: 2009-01-26 22:07:07 +0000 (Mon, 26 Jan 2009) Log Message: ----------- Remove dependency MapViewSettings -> MapManager. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/gui/map/mapviewsettings/MapViewSettings.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-01-26 21:55:31 UTC (rev 5891) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-01-26 22:07:07 UTC (rev 5892) @@ -340,7 +340,8 @@ final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final EditTypes editTypes = new EditTypes(); - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings, editTypes); + final MapViewSettings mapViewSettings = new MapViewSettings(); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings, editTypes, mapViewSettings); mapManager = tmpMapManager; mapReaderFactory.setEditTypes(editTypes); mapControlFactory.setEditTypes(editTypes); @@ -428,7 +429,6 @@ throw new AssertionError(); } final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); - final MapViewSettings mapViewSettings = new MapViewSettings(mapManager); final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareView, exitMatcher); final ErrorViewCollector treasureListsErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), "TreasureLists.xml")); Map<String, TreasureTreeNode> specialTreasureLists; Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2009-01-26 21:55:31 UTC (rev 5891) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2009-01-26 22:07:07 UTC (rev 5892) @@ -37,6 +37,8 @@ import net.sf.gridarta.gui.RecentManager; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; +import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.MapArchObject; @@ -117,19 +119,48 @@ }; /** + * The listener tracking alpha types changes to repaint map views after + * changes. + */ + private final MapViewSettingsListener mapViewSettingsListener = new MapViewSettingsListener() { + + /** {@inheritDoc} */ + @Override + public void gridVisibleChanged(final boolean gridVisible) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void doubleFacesChanged(final boolean doubleFaces) { + // ignore + } + + /** {@inheritDoc} */ + @Override + public void alphaTypeChanged(final int alphaType) { + // XXX THIS IS A BAD HACK + addEditType(alphaType); + } + + }; + + /** * Create a new map manager. * @param key The action builder key. * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance * @param editTypes the edit types instance + * @param mapViewSettings the map view settings instance */ - public DefaultMapManager(@NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes) { + public DefaultMapManager(@NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final MapViewSettings mapViewSettings) { this.globalSettings = globalSettings; actionBuilder = ActionBuilderFactory.getInstance().getActionBuilder(key); this.mapReaderFactory = mapReaderFactory; this.mapControlFactory = mapControlFactory; editTypes.addEditTypesListener(editTypesListener); + mapViewSettings.addMapViewSettingsListener(mapViewSettingsListener); } @Deprecated Modified: trunk/src/app/net/sf/gridarta/gui/map/mapviewsettings/MapViewSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapviewsettings/MapViewSettings.java 2009-01-26 21:55:31 UTC (rev 5891) +++ trunk/src/app/net/sf/gridarta/gui/map/mapviewsettings/MapViewSettings.java 2009-01-26 22:07:07 UTC (rev 5892) @@ -20,7 +20,6 @@ package net.sf.gridarta.gui.map.mapviewsettings; import javax.swing.event.EventListenerList; -import net.sf.gridarta.MapManager; import net.sf.gridarta.gameobject.match.ViewGameObjectMatcherManager; /** @@ -30,9 +29,6 @@ */ public class MapViewSettings { - /** The map manager. */ - private final MapManager<?, ?, ?, ?> mapManager; - /** The visibility of the grid. */ private boolean gridVisible; @@ -54,13 +50,6 @@ private final EventListenerList listenerList = new EventListenerList(); /** - * Creates a new instance. - * @param mapManager the map manager to use - */ - public MapViewSettings(final MapManager<?, ?, ?, ?> mapManager) { - this.mapManager = mapManager; - } - /** * Register a MapViewSettingsListener. * @param listener MapViewSettingsListener to register */ @@ -168,8 +157,6 @@ public void setAlphaType(final int v, final boolean state) { if (state) { alphaType |= v; - // XXX THIS IS A BAD HACK - mapManager.addEditType(v); } else { alphaType &= ~v; } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-01-26 21:55:31 UTC (rev 5891) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-01-26 22:07:07 UTC (rev 5892) @@ -55,6 +55,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.io.AbstractGameObjectParser; @@ -412,7 +413,8 @@ final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); final EditTypes editTypes = new EditTypes(); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings, editTypes); + final MapViewSettings mapViewSettings = new MapViewSettings(); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings, editTypes, mapViewSettings); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-02-25 08:23:04
|
Revision: 5962 http://gridarta.svn.sourceforge.net/gridarta/?rev=5962&view=rev Author: akirschbaum Date: 2009-02-25 08:23:00 +0000 (Wed, 25 Feb 2009) Log Message: ----------- Add @NotNull/@Nullable annotations. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2009-02-24 20:58:58 UTC (rev 5961) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2009-02-25 08:23:00 UTC (rev 5962) @@ -41,6 +41,7 @@ * Create a new GameObject from this Archetype. * @return New GameObject based on this Archetype. */ + @NotNull G createGameObject(); /** @@ -58,6 +59,7 @@ * @see #getAttributeLong(String) * @see #getAttributeDouble(String) */ + @NotNull String getAttributeString(@NotNull String attributeName); /** @@ -214,6 +216,7 @@ * Returns the editor folder. * @return the editor folder */ + @Nullable String getEditorFolder(); /** Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2009-02-24 20:58:58 UTC (rev 5961) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2009-02-25 08:23:00 UTC (rev 5962) @@ -173,6 +173,7 @@ private int editType; /** The location in the archetype selector. */ + @Nullable private String editorFolder; /** @@ -1016,6 +1017,7 @@ * be based on the Archetype only. * @return new GameObject */ + @NotNull @Override public abstract G createGameObject(); @@ -1422,6 +1424,7 @@ * Return the editor folder. * @return the editor folder */ + @Nullable @Override public String getEditorFolder() { return editorFolder; @@ -1431,7 +1434,7 @@ * Set the editor folder. * @param editorFolder the editor folder */ - public void setEditorFolder(final String editorFolder) { + public void setEditorFolder(@Nullable final String editorFolder) { this.editorFolder = editorFolder; } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-02-24 20:58:58 UTC (rev 5961) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-02-25 08:23:00 UTC (rev 5962) @@ -707,6 +707,7 @@ } /** {@inheritDoc} */ + @NotNull @Override public TestGameObject createGameObject() { throw new AssertionError(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-02-27 11:18:47
|
Revision: 5979 http://gridarta.svn.sourceforge.net/gridarta/?rev=5979&view=rev Author: akirschbaum Date: 2009-02-27 11:18:37 +0000 (Fri, 27 Feb 2009) Log Message: ----------- Add StringUtils.removeAttribute(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/utils/StringUtils.java trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java Modified: trunk/src/app/net/sf/gridarta/utils/StringUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2009-02-27 10:31:46 UTC (rev 5978) +++ trunk/src/app/net/sf/gridarta/utils/StringUtils.java 2009-02-27 11:18:37 UTC (rev 5979) @@ -20,6 +20,7 @@ package net.sf.gridarta.utils; import java.util.regex.Pattern; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -107,4 +108,40 @@ return null; } + /** + * Removes an attribute lines from a set of attribute definitions. If the + * set contains more than one instance of <code>attributeName</code>, only + * the first instance is removed. + * @param attributes the attribute set to search/modify + * @param attributeName the attribute name to search for + * @param attributeValue must contain at least one element which will + * return the attribute value of the removed attribute definition; set to + * <code>null</code> if no attribute definition was found + * @return the set of attribute definitions without the removed attribute + */ + @NotNull + public static String removeAttribute(@NotNull final String attributes, @NotNull final String attributeName, @NotNull final String[] attributeValue) { + final String str = attributeName + " "; + final StringBuilder result = new StringBuilder(); + final String[] attributeLines = patternEndOfLine.split(attributes, 0); + for (int i = 0; i < attributeLines.length; i++) { + final String line = attributeLines[i]; + if (line.startsWith(str)) { + for (int j = i + 1; j < attributeLines.length; j++) { + result.append(attributeLines[j]); + result.append('\n'); + } + + attributeValue[0] = line.substring(str.length()); + return result.toString(); + } + + result.append(line); + result.append('\n'); + } + + attributeValue[0] = null; + return attributes; + } + } // class StringUtils Modified: trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java 2009-02-27 10:31:46 UTC (rev 5978) +++ trunk/src/test/net/sf/gridarta/utils/StringUtilsTest.java 2009-02-27 11:18:37 UTC (rev 5979) @@ -20,6 +20,8 @@ package test.net.sf.gridarta.utils; import net.sf.gridarta.utils.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import org.junit.Assert; import org.junit.Test; @@ -119,4 +121,33 @@ Assert.assertEquals(expectedTrue, StringUtils.diffTextString(base, str, true)); } + /** Test case for {@link StringUtils#removeAttribute(String, String, + * String[])}. */ + @Test + public void testRemoveAttribute() { + testRemoveAttribute("", "abc", "", null); + testRemoveAttribute("abc def", "abc", "", "def"); + testRemoveAttribute("abc def", "ab", "abc def", null); + testRemoveAttribute("abc def", "def", "abc def", null); + testRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "abc", "ghi jkl\nmno pqr\n", "def"); + testRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "ghi", "abc def\nmno pqr\n", "jkl"); + testRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "mno", "abc def\nghi jkl\n", "pqr"); + testRemoveAttribute("abc def\nghi jkl\nmno pqr\n", "xxx", "abc def\nghi jkl\nmno pqr\n", null); + } + + /** + * Checks that {@link StringUtils#removeAttribute(String, String, + * String[])} does work. + * @param attributes the attributes to search/modify + * @param attributeName the attribute name to search for + * @param expectedAttributes the modified attributes + * @param expectedAttributeValue the found attribute value + */ + private static void testRemoveAttribute(@NotNull final String attributes, @NotNull final String attributeName, @NotNull final String expectedAttributes, @Nullable final String expectedAttributeValue) { + final String[] attributeValue = new String[1]; + final String modifiedAttributes = StringUtils.removeAttribute(attributes, attributeName, attributeValue); + Assert.assertEquals(expectedAttributes, modifiedAttributes); + Assert.assertEquals(expectedAttributeValue, attributeValue[0]); + } + } // class StringUtilsTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-02-28 14:42:56
|
Revision: 5988 http://gridarta.svn.sourceforge.net/gridarta/?rev=5988&view=rev Author: akirschbaum Date: 2009-02-28 14:42:44 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Remove DefaultMapReaderFactory.setMapViewSettings(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-02-28 14:35:32 UTC (rev 5987) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-02-28 14:42:44 UTC (rev 5988) @@ -348,12 +348,11 @@ globalSettings.readGlobalSettings(); final ArchetypeFactory<G, A, R> archetypeFactory = newArchetypeFactory(); final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, archetypeFactory); - final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); - final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final MapViewSettings mapViewSettings = new MapViewSettings(); + final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); + final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings, mapViewSettings); mapManager = tmpMapManager; - mapReaderFactory.setMapViewSettings(mapViewSettings); mapControlFactory.setMapViewSettings(mapViewSettings); ScriptedEventEditor.setGlobalSettings(globalSettings); AbstractScriptedEvent.init(archetypeSet); Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2009-02-28 14:35:32 UTC (rev 5987) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2009-02-28 14:42:44 UTC (rev 5988) @@ -68,20 +68,13 @@ * instance * @param gameObjectParserFactory the game object parser factory instance * @param archetypeSet the archetype set instance + * @param mapViewSettings the map view settings instance */ - public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapViewSettings mapViewSettings) { this.mapArchObjectFactory = mapArchObjectFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.gameObjectParserFactory = gameObjectParserFactory; this.archetypeSet = archetypeSet; - } - - /** - * Finishes object creation. - * @param mapViewSettings the map view settings instance - */ - @Deprecated - public void setMapViewSettings(@NotNull final MapViewSettings mapViewSettings) { this.mapViewSettings = mapViewSettings; } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-02-28 14:35:32 UTC (rev 5987) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-02-28 14:42:44 UTC (rev 5988) @@ -404,14 +404,14 @@ final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory = new TestGameObjectParserFactory(); final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet); + final MapViewSettings mapViewSettings = new MapViewSettings(); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(mapReaderFactory); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); final TestMapArchObject mapArchObject = new TestMapArchObject(); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final MapViewSettings mapViewSettings = new MapViewSettings(); final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>("test", mapReaderFactory, mapControlFactory, globalSettings, mapViewSettings); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-03-28 19:07:43
|
Revision: 6178 http://gridarta.svn.sourceforge.net/gridarta/?rev=6178&view=rev Author: akirschbaum Date: 2009-03-28 19:07:37 +0000 (Sat, 28 Mar 2009) Log Message: ----------- Remove dependency ArchetypeAttributeTreasure constructor -> CFTreasureListTree. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpellOptional.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeList.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeLong.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeMapPath.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeScriptFile.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeSpell.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTreasure.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeZSpell.java trunk/src/app/net/sf/gridarta/archtype/DefaultArchetypeAttributeFactory.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java trunk/src/test/net/sf/gridarta/archtype/ArchetypeTypeSetParserTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -429,7 +429,8 @@ newMapDialogFactory.setParent(mainView); pickmapChooserControl = new PickmapChooserControl<G, A, R, V>(newMapDialogFactory, mapControlFactory, mapFolderTree, mapManager, mainView); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); - final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, mainView); + final CFTreasureListTree<G, A, R> treasureListTree = new CFTreasureListTree<G, A, R>(treasureTree, mainView, archetypeSet); + final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(archetypeTypeSet, mainView, treasureListTree); final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl = new ArchetypeChooserControl<G, A, R, V>(archetypeChooserModel, createDirectionPane); final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl); newMapDialogFactory.setObjectChooser(objectChooser); @@ -465,8 +466,7 @@ } final ScriptArchUtils scriptArchUtils = newScriptArchUtils(); final MapActions mapActions = init1(mapViewSettings, mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, mapViewManager, selectedSquareModel, exitMatcher, mainView); - final CFTreasureListTree<G, A, R> treasureListTree = new CFTreasureListTree<G, A, R>(treasureTree, mainView, archetypeSet); - final ArchetypeAttributeFactory<G, A, R> archetypeAttributeFactory = new DefaultArchetypeAttributeFactory<G, A, R>(animationObjects, typeNoEventConnector, archetypeTypeSet, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, globalSettings, mapFileFilter, scriptFileFilter, treasureListTree, treasureTree); + final ArchetypeAttributeFactory<G, A, R> archetypeAttributeFactory = new DefaultArchetypeAttributeFactory<G, A, R>(animationObjects, typeNoEventConnector, archetypeTypeSet, faceObjects, gameObjectSpells, numberSpells, undefinedSpellIndex, globalSettings, mapFileFilter, scriptFileFilter, treasureTree); final ArchetypeAttributeParser<G, A, R> archetypeAttributeParser = new ArchetypeAttributeParser<G, A, R>(archetypeAttributeFactory); final ArchetypeTypeParser<G, A, R> archetypeTypeParser = new ArchetypeTypeParser<G, A, R>(archetypeAttributeParser); final ArchetypeTypeSetParser<G, A, R> archetypeTypeSetParser = new ArchetypeTypeSetParser<G, A, R>(xmlHelper.getDocumentBuilder(), xmlHelper.getXPath(), archetypeTypeSet, archetypeTypeParser); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttribute.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -26,6 +26,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.InvalidCheckException; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -173,10 +174,11 @@ * @param type the archetype type * @param background the background color * @param parent the parent component + * @param treasureListTree the treasure list tree to display * @return the GUI elements */ @NotNull - public abstract GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent); + public abstract GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree); /** * Adds attribute range checks for all defined attributes. Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.TreeChooseAction; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -70,7 +71,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JTextField input = new JTextField(gameObject.getAttributeString(getArchetypeAttributeName()), TEXTFIELD_COLUMNS); final JButton cLabel = new JButton(new TreeChooseAction(getAttributeName() + ": ", input, animationObjects)); return new GuiInfo<G, A, R>(new DialogAttribAnimName<G, A, R>(this, input, typeNoEventConnector), cLabel, input, null, null, false); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBitmask.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -32,6 +32,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.InvalidCheckException; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -72,7 +73,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JTextArea input = new JTextArea(); final DialogAttribBitmask<G, A, R> tmpAttr = new DialogAttribBitmask<G, A, R>(this, input); final JTextArea cComp; Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBool.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -28,6 +28,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.InvalidCheckException; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -52,7 +53,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JCheckBox input = new JCheckBox(getAttributeName(), gameObject.getAttributeInt(getArchetypeAttributeName()) == 1); return new GuiInfo<G, A, R>(new DialogAttribBool<G, A, R>(this, input), null, null, input, null, false); } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeBoolSpec.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -27,6 +27,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribBoolSpec; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -68,7 +69,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final String attrString = gameObject.getAttributeString(getArchetypeAttributeName()); final boolean defaultValue; if (trueValue.equals("0")) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeDoubleList.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -31,6 +31,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribDoubleList; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; @@ -79,7 +80,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JPanel compo = new JPanel(new BorderLayout()); final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.TreeChooseAction; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -69,7 +70,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final String defaultText; final String attributeName = getArchetypeAttributeName(); if (attributeName.equals("face")) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFixed.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -25,6 +25,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -49,7 +50,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { throw new AssertionError(); } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFloat.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -31,6 +31,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribFloat; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; @@ -56,7 +57,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.FLOAT_COLOR); final int fieldLength = getInputLength() == 0 ? TEXTFIELD_COLUMNS : getInputLength(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInt.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -32,6 +32,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.InvalidCheckException; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; @@ -85,7 +86,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); final int fieldLength = getInputLength() == 0 ? TEXTFIELD_COLUMNS : getInputLength(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpell.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +66,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); // create ComboBox with parsed selection Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpellOptional.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpellOptional.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeInvSpellOptional.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -65,7 +66,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); // create ComboBox with parsed selection Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeList.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeList.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeList.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -29,6 +29,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribList; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -71,7 +72,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); // create ComboBox with parsed selection Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeLong.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeLong.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeLong.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -31,6 +31,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribLong; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; @@ -56,7 +57,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); final int fieldLength = getInputLength() == 0 ? TEXTFIELD_COLUMNS : getInputLength(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeMapPath.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeMapPath.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeMapPath.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -32,6 +32,7 @@ import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.settings.GlobalSettings; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -72,7 +73,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final MapSquare<G,A,R> mapSquare = gameObject.getMapSquare(); File relativeReference = mapSquare == null ? null : mapSquare.getMapModel().getMapControl().getMapFile(); if (relativeReference == null) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeScriptFile.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeScriptFile.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeScriptFile.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -31,6 +31,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.settings.GlobalSettings; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -71,7 +72,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); final TilePanel tilePanel = new TilePanel(scriptFileFilter); tilePanel.setAbsoluteReference(globalSettings.getMapDir()); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeSpell.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeSpell.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeSpell.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -72,7 +73,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); // create ComboBox with parsed selection Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -28,6 +28,7 @@ import net.sf.gridarta.gui.gameobjectattributesdialog.DialogAttribString; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; /** @@ -59,7 +60,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final String defaultText = getDefaultText(gameObject, archetype, type); final JTextField input = new JTextField(defaultText, TEXTFIELD_COLUMNS); final JLabel cLabel = new JLabel(getAttributeName() + ": "); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeText.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.textedit.textarea.JEditTextArea; import net.sf.gridarta.textedit.textarea.SyntaxDocument; import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -70,7 +71,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { String text = ""; if (getArchetypeAttributeName().equals("msg")) { final String archetypeMsgText = archetype.getMsgText(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTreasure.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTreasure.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeTreasure.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -41,12 +41,6 @@ public class ArchetypeAttributeTreasure<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends ArchetypeAttribute<G, A, R> { /** - * The treasurelist tree to display. - */ - @NotNull - private final CFTreasureListTree<G, A, R> treasureListTree; - - /** * The {@link TreasureTree} to use. */ @NotNull @@ -59,19 +53,17 @@ * @param description the attribute's description * @param inputLength the input length in characters for text input fields * @param sectionName the section name for the new attribute - * @param treasureListTree the treasurelist tree to display * @param treasureTree the treasure tree to use */ - public ArchetypeAttributeTreasure(@NotNull final String archetypeAttributeName, @NotNull final String attributeName, @NotNull final String description, final int inputLength, @NotNull final String sectionName, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final TreasureTree treasureTree) { + public ArchetypeAttributeTreasure(@NotNull final String archetypeAttributeName, @NotNull final String attributeName, @NotNull final String description, final int inputLength, @NotNull final String sectionName, @NotNull final TreasureTree treasureTree) { super(archetypeAttributeName, attributeName, description, inputLength, sectionName); - this.treasureListTree = treasureListTree; this.treasureTree = treasureTree; } /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { // textfield (no direct input, text is set by the treasurelist dialog) String treasureName = gameObject.getAttributeString(getArchetypeAttributeName()); if (treasureName.trim().length() == 0 || treasureName.trim().equalsIgnoreCase("none")) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeZSpell.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeZSpell.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeZSpell.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -30,6 +30,7 @@ import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -72,7 +73,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<G, A, R> createGui(@NotNull final G gameObject, @NotNull final R archetype, @NotNull final ArchetypeType<G, A, R> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { final JLabel cLabel = new JLabel(getAttributeName() + ": "); cLabel.setForeground(CommonConstants.INT_COLOR); // create ComboBox with parsed selection Modified: trunk/src/app/net/sf/gridarta/archtype/DefaultArchetypeAttributeFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/DefaultArchetypeAttributeFactory.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/archtype/DefaultArchetypeAttributeFactory.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -10,7 +10,6 @@ import net.sf.gridarta.spells.GameObjectSpell; import net.sf.gridarta.spells.NumberSpell; import net.sf.gridarta.spells.Spells; -import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.treasurelist.TreasureTree; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -81,12 +80,6 @@ private final FileFilter scriptFileFilter; /** - * The treasurelist tree to display. - */ - @NotNull - private final CFTreasureListTree<G, A, R> treasureListTree; - - /** * The {@link TreasureTree} to use. */ @NotNull @@ -105,10 +98,9 @@ * @param globalSettings the global settings instance * @param mapFileFilter the file filter to use * @param scriptFileFilter the file filter to use - * @param treasureListTree the treasurelist tree to display * @param treasureTree the treasure tree to use */ - public DefaultArchetypeAttributeFactory(@NotNull final AnimationObjects animationObjects, final int typeNoEventConnector, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final CFTreasureListTree<G, A, R> treasureListTree, @NotNull final TreasureTree treasureTree) { + public DefaultArchetypeAttributeFactory(@NotNull final AnimationObjects animationObjects, final int typeNoEventConnector, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final FaceObjects faceObjects, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final Spells<NumberSpell> numberSpells, final int undefinedSpellIndex, @NotNull final GlobalSettings globalSettings, @NotNull final FileFilter mapFileFilter, @NotNull final FileFilter scriptFileFilter, @NotNull final TreasureTree treasureTree) { this.animationObjects = animationObjects; this.typeNoEventConnector = typeNoEventConnector; this.archetypeTypeSet = archetypeTypeSet; @@ -119,7 +111,6 @@ this.globalSettings = globalSettings; this.mapFileFilter = mapFileFilter; this.scriptFileFilter = scriptFileFilter; - this.treasureListTree = treasureListTree; this.treasureTree = treasureTree; } @@ -253,7 +244,7 @@ @NotNull @Override public ArchetypeAttribute<G, A, R> newArchetypeAttributeTreasure(@NotNull final String archetypeAttributeName, @NotNull final String attributeName, @NotNull final String description, final int inputLength, @NotNull final String sectionName) { - return new ArchetypeAttributeTreasure<G, A, R>(archetypeAttributeName, attributeName, description, inputLength, sectionName, treasureListTree, treasureTree); + return new ArchetypeAttributeTreasure<G, A, R>(archetypeAttributeName, attributeName, description, inputLength, sectionName, treasureTree); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -74,6 +74,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapSquare; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -112,6 +113,12 @@ */ private final JFrame parent; + /** + * The {@link CFTreasureListTree} to use. + */ + @NotNull + private final CFTreasureListTree<G, A, R> treasureListTree; + private final List<DialogAttrib<G, A, R>> dialogAttribs = new ArrayList<DialogAttrib<G, A, R>>(); /** @@ -201,12 +208,14 @@ * @param archetypeTypeSet Reference to the list of archetype types. * @param gameObject GameObject to show dialog for. * @param parent the parent frame for showing dialog boxes + * @param treasureListTree the treasure list tree to display */ - public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final G gameObject, @NotNull final JFrame parent) { + public GameObjectAttributesDialog(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final G gameObject, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.archetypeTypeSet = archetypeTypeSet; this.gameObject = gameObject; this.parent = parent; + this.treasureListTree = treasureListTree; archetype = gameObject.getArchetype(); archetypeType = archetypeTypeSet.getArchetypeType(gameObject); @@ -477,7 +486,7 @@ panel.add(helpButton, helpGbc); helpButton.addFocusListener(focusListener); - final GuiInfo<G, A, R> guiInfo = archetypeAttribute.createGui(gameObject, archetype, archetypeType, getBackground(), this); + final GuiInfo<G, A, R> guiInfo = archetypeAttribute.createGui(gameObject, archetype, archetypeType, getBackground(), this, treasureListTree); dialogAttribs.add(guiInfo.newAttr); helpButton.addActionListener(new HelpActionListener(guiInfo.newAttr.getRef(), this)); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialogFactory.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -27,6 +27,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -55,13 +56,21 @@ private final JFrame parent; /** + * The {@link CFTreasureListTree} to display. + */ + @NotNull + private final CFTreasureListTree<G, A, R> treasureListTree; + + /** * Creates a new instance. * @param archetypeTypeSet the list of CF type-data * @param parent the parent frame for dialog boxes + * @param treasureListTree the treasure list tree to display */ - public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final JFrame parent) { + public GameObjectAttributesDialogFactory(@NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final JFrame parent, @NotNull final CFTreasureListTree<G, A, R> treasureListTree) { this.archetypeTypeSet = archetypeTypeSet; this.parent = parent; + this.treasureListTree = treasureListTree; } /** @@ -87,7 +96,7 @@ if (dialogs.containsKey(head)) { dialogs.get(head).toFront(); } else { - final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, head, parent); + final GameObjectAttributesDialog<G, A, R> pane = new GameObjectAttributesDialog<G, A, R>(this, archetypeTypeSet, head, parent, treasureListTree); final JDialog dialog = pane.createDialog(); dialogs.put(head, dialog); } Modified: trunk/src/test/net/sf/gridarta/archtype/ArchetypeTypeSetParserTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/archtype/ArchetypeTypeSetParserTest.java 2009-03-28 19:02:16 UTC (rev 6177) +++ trunk/src/test/net/sf/gridarta/archtype/ArchetypeTypeSetParserTest.java 2009-03-28 19:07:37 UTC (rev 6178) @@ -34,6 +34,7 @@ import net.sf.gridarta.map.TestMapArchObject; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.map.validation.checks.InvalidCheckException; +import net.sf.gridarta.treasurelist.CFTreasureListTree; import net.sf.gridarta.utils.XmlHelper; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -607,7 +608,7 @@ /** {@inheritDoc} */ @NotNull @Override - public GuiInfo<TestGameObject, TestMapArchObject, TestArchetype> createGui(@NotNull final TestGameObject gameObject, @NotNull final TestArchetype archetype, @NotNull final ArchetypeType<TestGameObject, TestMapArchObject, TestArchetype> type, @NotNull final Color background, @NotNull final Component parent) { + public GuiInfo<TestGameObject, TestMapArchObject, TestArchetype> createGui(@NotNull final TestGameObject gameObject, @NotNull final TestArchetype archetype, @NotNull final ArchetypeType<TestGameObject, TestMapArchObject, TestArchetype> type, @NotNull final Color background, @NotNull final Component parent, @NotNull final CFTreasureListTree<TestGameObject, TestMapArchObject, TestArchetype> treasureListTree) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-03-28 21:21:40
|
Revision: 6186 http://gridarta.svn.sourceforge.net/gridarta/?rev=6186&view=rev Author: akirschbaum Date: 2009-03-28 21:21:33 +0000 (Sat, 28 Mar 2009) Log Message: ----------- Remove unused type parameters. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-03-28 21:17:39 UTC (rev 6185) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-03-28 21:21:33 UTC (rev 6186) @@ -358,7 +358,7 @@ final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, archetypeFactory, gameObjectParser); final MapViewSettings mapViewSettings = new MapViewSettings(); - final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); + final DefaultMapReaderFactory<G, A, R> mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel = new ArchetypeChooserModel<G, A, R, V>(); final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, archetypeChooserModel, autojoinLists, mapViewSettings); final CopyBuffer<G, A, R, V> copyBuffer = new CopyBuffer<G, A, R, V>(mapViewSettings, mapControlFactory, mapArchObjectFactory.newMapArchObject(false)); Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2009-03-28 21:17:39 UTC (rev 6185) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2009-03-28 21:21:33 UTC (rev 6186) @@ -24,7 +24,6 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapArchObjectFactory; @@ -34,7 +33,7 @@ * Default implementation of {@link MapReaderFactory}. * @author Andreas Kirschbaum */ -public class DefaultMapReaderFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> implements MapReaderFactory<G, A> { +public class DefaultMapReaderFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapReaderFactory<G, A> { /** The {@link MapArchObjectFactory} instance. */ @NotNull Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-03-28 21:17:39 UTC (rev 6185) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-03-28 21:21:33 UTC (rev 6186) @@ -393,7 +393,7 @@ final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(archetypeFactory); final MapViewSettings mapViewSettings = new MapViewSettings(); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, archetypeSet, mapViewSettings); final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(mapReaderFactory); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-08 07:17:32
|
Revision: 6328 http://gridarta.svn.sourceforge.net/gridarta/?rev=6328&view=rev Author: akirschbaum Date: 2009-04-08 07:17:29 +0000 (Wed, 08 Apr 2009) Log Message: ----------- Remove dependency DefaultMapModel -> MapControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2009-04-08 07:13:07 UTC (rev 6327) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2009-04-08 07:17:29 UTC (rev 6328) @@ -184,7 +184,7 @@ this.mapImageCache = mapImageCache; this.isPickmap = isPickmap; // we create model (= data) - mapModel = new DefaultMapModel<G, A, R>(autojoinLists, this, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, activeEditType); + mapModel = new DefaultMapModel<G, A, R>(autojoinLists, objects, mapArchObject, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions, activeEditType); mapModel.addMapModelListener(mapModelListener); } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2009-04-08 07:13:07 UTC (rev 6327) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2009-04-08 07:17:29 UTC (rev 6328) @@ -61,16 +61,6 @@ /** Sync Lock Object. */ private final transient Object syncLock = new Object(); - /** - * The MapControl that controls this MapModel. - * @todo care about Serialization if this field remains - * @deprecated it's not a good idea to require the MapModel implementation - * to know such a heavy-weight strongly UI-related glue class - * like {@link MapControl}. - */ - @Deprecated - private final MapControl<G, A, R, ?> mapControl; - /** The MapArchObject associated with this model. */ @NotNull private final A mapArchObject; @@ -154,7 +144,6 @@ /** * Create an DefaultMapModel. * @param autojoinLists the autojoin lists instance to use - * @param mapControl MapControl to associate with this model. * @param objects the <code>GameObject</code> list of this map or * <code>null</code> for an empty map * @param mapArchObject The MapArchObject to associate with this model. @@ -163,8 +152,7 @@ * @param mapActions the map actions to use * @param activeEditType the active edit types */ - public DefaultMapModel(@NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapControl<G, A, R, ?> mapControl, @Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, ?> archetypeChooserModel, @NotNull final MapActions mapActions, final int activeEditType) { - this.mapControl = mapControl; + public DefaultMapModel(@NotNull final AutojoinLists<G, A, R> autojoinLists, @Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, ?> archetypeChooserModel, @NotNull final MapActions mapActions, final int activeEditType) { this.mapArchObject = mapArchObject; this.autojoinLists = autojoinLists; this.archetypeChooserModel = archetypeChooserModel; @@ -183,12 +171,6 @@ } /** {@inheritDoc} */ - @Override - public MapControl<G, A, R, ?> getMapControl() { - return mapControl; - } - - /** {@inheritDoc} */ @NotNull @Override public A getMapArchObject() { Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2009-04-08 07:13:07 UTC (rev 6327) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2009-04-08 07:17:29 UTC (rev 6328) @@ -408,14 +408,6 @@ void deleteMapArch(@NotNull G gameObject, boolean join); /** - * Returns the MapControl that controls this MapModel. - * @return the MapControl that controls this MapModel - * @deprecated a MapModel should never know it's MapControl - */ - @Deprecated - MapControl<G, A, R, ?> getMapControl(); - - /** * Sets the errors in this map. * @param errors the errors */ Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-04-08 07:13:07 UTC (rev 6327) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-04-08 07:17:29 UTC (rev 6328) @@ -406,7 +406,7 @@ final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory); final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewFactory = new TestMapViewFactory(); final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl = new DefaultMapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapViewFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions, 0); - mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions, 0); + mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, null, mapArchObject, null, archetypeChooserModel, mapActions, 0); result.setLength(0); mapModel.addMapModelListener(mapModelListener); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-12 12:07:45
|
Revision: 6419 http://gridarta.svn.sourceforge.net/gridarta/?rev=6419&view=rev Author: akirschbaum Date: 2009-04-12 12:07:42 +0000 (Sun, 12 Apr 2009) Log Message: ----------- Order import statements. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-04-12 11:53:23 UTC (rev 6418) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2009-04-12 12:07:42 UTC (rev 6419) @@ -84,7 +84,6 @@ import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.prefs.AppPrefsModel; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.DefaultMapWriter; @@ -93,11 +92,9 @@ import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapWriter; import net.sf.gridarta.io.PathManager; -import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControlFactory; -import net.sf.gridarta.map.normalizer.MapPathNormalizer; import net.sf.gridarta.map.validation.DelegatingMapValidator; import net.sf.gridarta.map.validation.checks.AttributeRangeChecker; import net.sf.gridarta.mapimagecache.MapImageCache; Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-04-12 11:53:23 UTC (rev 6418) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2009-04-12 12:07:42 UTC (rev 6419) @@ -26,23 +26,23 @@ import java.util.TreeSet; import javax.swing.ImageIcon; import net.sf.gridarta.autojoin.AutojoinLists; +import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.TestArchetype; import net.sf.gridarta.gameobject.TestGameObject; import net.sf.gridarta.gui.GUIConstants; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.gui.map.AbstractLevelRenderer; import net.sf.gridarta.gui.map.MapActions; +import net.sf.gridarta.gui.map.MapGrid; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.TestMapActions; -import net.sf.gridarta.gui.map.AbstractLevelRenderer; -import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.map.tools.ToolPalette; -import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.filter.FilterControl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.junit.Assert; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-15 07:13:17
|
Revision: 6450 http://gridarta.svn.sourceforge.net/gridarta/?rev=6450&view=rev Author: akirschbaum Date: 2009-04-15 07:13:15 +0000 (Wed, 15 Apr 2009) Log Message: ----------- Do not fail regression tests due to user configuration. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/preferences/FilePreferencesFactory.java trunk/src/app/net/sf/gridarta/preferences/Storage.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Modified: trunk/src/app/net/sf/gridarta/preferences/FilePreferencesFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/FilePreferencesFactory.java 2009-04-15 07:06:51 UTC (rev 6449) +++ trunk/src/app/net/sf/gridarta/preferences/FilePreferencesFactory.java 2009-04-15 07:13:15 UTC (rev 6450) @@ -23,6 +23,7 @@ import java.util.prefs.Preferences; import java.util.prefs.PreferencesFactory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * A {@link PreferencesFactory} which creates {@link FilePreferences} @@ -41,9 +42,10 @@ * Initialize the module. This function must be called before an instance is * used. * @param defaultName The default key name for loading/saving values. - * @param file The file for loading/saving values. + * @param file the file for loading/saving values or <code>null</code> to + * not use a backing file */ - public static void initialize(@NotNull final String defaultName, @NotNull final File file) { + public static void initialize(@NotNull final String defaultName, @Nullable final File file) { final Storage storage = new Storage(defaultName, file); userRoot = new FilePreferencesRoot(NodeType.USER, storage); systemRoot = new FilePreferencesRoot(NodeType.SYSTEM, storage); Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2009-04-15 07:06:51 UTC (rev 6449) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2009-04-15 07:13:15 UTC (rev 6450) @@ -57,7 +57,7 @@ private final String defaultPath; /** The file for loading/saving values. */ - @NotNull + @Nullable private final File file; /** If set, do not save changes into {@link #file}. */ @@ -72,9 +72,10 @@ /** * Create a new instance. * @param defaultPath The default key name for loading/saving values. - * @param file The file for loading/saving values. + * @param file the file for loading/saving values or <code>null</code> to + * not use a backing file */ - public Storage(@NotNull final String defaultPath, @NotNull final File file) { + public Storage(@NotNull final String defaultPath, @Nullable final File file) { if (log.isDebugEnabled()) { log.debug("new"); } @@ -244,6 +245,10 @@ /** Load the values from the backing file. */ private void loadValues() { + if (file == null) { + return; + } + if (log.isDebugEnabled()) { log.debug("loadValues: " + file); } @@ -305,6 +310,10 @@ * @throws IOException if the values cannot be saved */ private void saveValues() throws IOException { + if (file == null) { + return; + } + if (log.isDebugEnabled()) { log.debug("saveValues: " + file); } Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-15 07:06:51 UTC (rev 6449) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-15 07:13:15 UTC (rev 6450) @@ -60,6 +60,7 @@ import net.sf.gridarta.mapmanager.DefaultMapManager; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.mapmanager.TestFileControl; +import net.sf.gridarta.preferences.FilePreferencesFactory; import net.sf.gridarta.settings.GlobalSettings; import net.sf.gridarta.settings.TestGlobalSettings; import net.sf.gridarta.utils.Size2D; @@ -67,6 +68,7 @@ import org.jetbrains.annotations.Nullable; import org.junit.Assert; import org.junit.Before; +import org.junit.BeforeClass; import org.junit.Test; /** @@ -353,12 +355,18 @@ checkExit(mapModel, pointFrom, 0, expectedExitPath, pointTo); } + @BeforeClass + public static void setUpClass() { + System.setProperty("java.util.prefs.PreferencesFactory", "net.sf.gridarta.preferences.FilePreferencesFactory"); + FilePreferencesFactory.initialize("user_net_sf_gridarta", null); + } + /** * Initializes the test case. * @throws DuplicateArchetypeException if the test case fails */ @Before - public void setUpClass() throws DuplicateArchetypeException { + public void setUp() throws DuplicateArchetypeException { final GameObjectMatcher exitGameObjectMatcher = new TypeNrsGameObjectMatcher(EXIT_TYPE); exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-15 07:30:01
|
Revision: 6452 http://gridarta.svn.sourceforge.net/gridarta/?rev=6452&view=rev Author: akirschbaum Date: 2009-04-15 07:29:59 +0000 (Wed, 15 Apr 2009) Log Message: ----------- Move file I/O out of FileControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java Modified: trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/app/net/sf/gridarta/gui/MapManagerActions.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -76,7 +76,9 @@ for (final MapControl<G, A, R, V> mapControl : mapManager.getOpenedMaps()) { if (mapControl.getMapModel().isModified()) { try { - mapManager.save(mapControl); + if (!mapManager.save(mapControl)) { + return; + } } catch (final IOException e) { ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapControl.getMapModel().getMapFile(), e.getMessage()); return; Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui.map; import java.awt.Component; +import java.io.File; import java.io.IOException; import javax.swing.Action; import net.sf.gridarta.CurrentMapListener; @@ -200,13 +201,20 @@ /** Invoked when the user wants to save the map to a file. */ public void saveAs() { final MapControl<G, A, R, V> mapControl = getSaveAsEnabled(); - if (mapControl != null) { - try { - fileControl.saveLevelAsWanted(mapControl); - } catch (final IOException e) { - ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapControl.getMapModel().getMapFile(), e.getMessage()); - } + if (mapControl == null) { + return; } + + final File file = fileControl.saveLevelAs(mapControl); + if (file == null) { + return; + } + + try { + mapControl.saveAs(file); + } catch (final IOException e) { + ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapControl.getMapModel().getMapFile(), e.getMessage()); + } } /** Invoked when the user wants to create an image file of the map. */ Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -470,9 +470,15 @@ if (mapControl.getMapModel().isPlainSaveEnabled()) { mapControl.save(); return true; - } else { - return fileControl.saveLevelAsWanted(mapControl); } + + final File file = fileControl.saveLevelAs(mapControl); + if (file != null) { + mapControl.saveAs(file); + return true; + } + + return false; } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -21,7 +21,6 @@ import java.awt.Component; import java.io.File; -import java.io.IOException; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; @@ -38,6 +37,7 @@ import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public class DefaultFileControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> implements FileControl<G, A, R, V> { @@ -164,8 +164,9 @@ } /** {@inheritDoc} */ + @Nullable @Override - public boolean saveLevelAsWanted(@NotNull final MapControl<G, A, R, V> mapControl) throws IOException { + public File saveLevelAs(@NotNull final MapControl<G, A, R, V> mapControl) { final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Save Map Or Script As"); fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); @@ -191,17 +192,16 @@ final int returnVal = fileChooser.showSaveDialog(parent); if (returnVal != JFileChooser.APPROVE_OPTION) { - return false; + return null; } globalSettings.setChangedDir(true); // user has chosen an active dir final File file = fileChooser.getSelectedFile(); - if (!file.exists() || ACTION_BUILDER.showConfirmDialog(parent, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) == JOptionPane.OK_OPTION) { - mapControl.saveAs(file); + if (file.exists() && ACTION_BUILDER.showConfirmDialog(parent, JOptionPane.WARNING_MESSAGE, JOptionPane.OK_CANCEL_OPTION, "overwriteOtherFile", file.getName()) != JOptionPane.OK_OPTION) { + return null; + } - globalSettings.setCurrentDirectory(fileChooser.getCurrentDirectory()); - } - return true; + return file; } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -20,13 +20,13 @@ package net.sf.gridarta.mapmanager; import java.io.File; -import java.io.IOException; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; public interface FileControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { @@ -41,11 +41,10 @@ /** * Invoked when user wants to save a map to certain file. * @param mapControl the map to be saved - * @return <code>true</code> if the user confirmed saving the map and the - * map was saved successfully, otherwise <code>false</code> - * @throws IOException if saving failed + * @return the file to save to or <code>null</code> if the user cancelled */ - boolean saveLevelAsWanted(@NotNull MapControl<G, A, R, V> mapControl) throws IOException; + @Nullable + File saveLevelAs(@NotNull MapControl<G, A, R, V> mapControl); int confirmSaveChanges(@NotNull String mapName); Modified: trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-15 07:14:12 UTC (rev 6451) +++ trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-15 07:29:59 UTC (rev 6452) @@ -20,7 +20,6 @@ package net.sf.gridarta.mapmanager; import java.io.File; -import java.io.IOException; import net.sf.gridarta.gameobject.TestArchetype; import net.sf.gridarta.gameobject.TestGameObject; import net.sf.gridarta.gui.map.TestMapViewBasic; @@ -48,7 +47,7 @@ /** {@inheritDoc} */ @Override - public boolean saveLevelAsWanted(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl) throws IOException { + public File saveLevelAs(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-19 17:20:02
|
Revision: 6486 http://gridarta.svn.sourceforge.net/gridarta/?rev=6486&view=rev Author: akirschbaum Date: 2009-04-19 17:19:59 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Rename method names. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/GUIMainControl.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/Actions.java trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java Modified: trunk/src/app/net/sf/gridarta/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -484,7 +484,7 @@ } globalSettings.setImageDirectory(imageFile.getParentFile()); if (!imageFile.exists() || ACTION_BUILDER.showConfirmDialog(mainView, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, "overwriteOtherFile", imageFile) == JOptionPane.YES_OPTION) { - createImageWanted(mapView, imageFile); + createImage(mapView, imageFile); } } } @@ -493,13 +493,13 @@ * Invoked when user wants to begin editing a new (empty) map. * @param filename desired filename for the new map, null if not specified */ - public void newLevelWanted(final String filename) { + public void newLevel(final String filename) { newMapDialogFactory.showNewMapDialog(filename); } /** Invoked when user wants to begin editing a new (empty) map. */ public void createNew() { - newLevelWanted(null); + newLevel(null); } /** @@ -541,7 +541,7 @@ * @param mapView the map view of the map to save * @param file the png image file to create */ - public void createImageWanted(@NotNull final MapView<G, A, R> mapView, final File file) { + public void createImage(@NotNull final MapView<G, A, R> mapView, final File file) { final File tmpFile = new File(file.getPath() + ".tmp"); try { mapView.getMapViewBasic().getRenderer().printFullImage(tmpFile); @@ -574,7 +574,7 @@ /** Edit an existing script. */ @ActionMethod public void editScript() { - fileControl.openFileWanted(false); + fileControl.openFile(false); } /** @@ -597,7 +597,7 @@ /** Invoked when user wants to open a file. */ public void open() { - fileControl.openFileWanted(true); + fileControl.openFile(true); } public void options() { @@ -686,7 +686,7 @@ // TODO: pass filename scriptEditControl.openScriptNew(); } else { - newLevelWanted(file.getName()); + newLevel(file.getName()); } } // If neither branch matches, it's a directory - what to do with directories? @@ -760,7 +760,7 @@ if (in.canRead()) { final MapView<G, A, R> mapView = mapManager.openMapFileWithView(in, null); if (mapView != null) { - createImageWanted(mapView, out); + createImage(mapView, out); mapManager.closeView(mapView); } } @@ -801,7 +801,7 @@ public void createImageFile(@NotNull final File infile, @NotNull final File outfile) { final MapView<G, A, R> mapView = openFile(infile); if (mapView != null) { - createImageWanted(mapView, outfile); + createImage(mapView, outfile); } } @@ -850,7 +850,7 @@ @ActionMethod public void collectSpells() { if (spellUtils != null) { - spellUtils.importSpellsWanted(globalSettings.getConfigurationDirectory(), mainView); + spellUtils.importSpells(globalSettings.getConfigurationDirectory(), mainView); } } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -531,7 +531,7 @@ public void fillAuto() { final MapView<G, A, R> mapView = getFillAutoEnabled(); if (mapView != null) { - fillWanted(mapView, InsertionMode.AUTO); + fill(mapView, InsertionMode.AUTO); } } @@ -539,7 +539,7 @@ public void fillAbove() { final MapView<G, A, R> mapView = getFillAboveEnabled(); if (mapView != null) { - fillWanted(mapView, InsertionMode.TOPMOST); + fill(mapView, InsertionMode.TOPMOST); } } @@ -547,7 +547,7 @@ public void fillBelow() { final MapView<G, A, R> mapView = getFillBelowEnabled(); if (mapView != null) { - fillWanted(mapView, InsertionMode.BOTTOMMOST); + fill(mapView, InsertionMode.BOTTOMMOST); } } @@ -556,7 +556,7 @@ * @param mapView the map view to fill * @param insertionMode the insertion mode to use */ - private void fillWanted(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) { + private void fill(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) { FillUtils.fill(mapView, insertionMode, objectChooser.getSelections(), -1); } @@ -564,7 +564,7 @@ public void randFillAuto() { final MapView<G, A, R> mapView = getRandFillAutoEnabled(); if (mapView != null) { - fillRandomWanted(mapView, InsertionMode.AUTO); + fillRandom(mapView, InsertionMode.AUTO); } } @@ -572,7 +572,7 @@ public void randFillAbove() { final MapView<G, A, R> mapView = getRandFillAboveEnabled(); if (mapView != null) { - fillRandomWanted(mapView, InsertionMode.TOPMOST); + fillRandom(mapView, InsertionMode.TOPMOST); } } @@ -580,7 +580,7 @@ public void randFillBelow() { final MapView<G, A, R> mapView = getRandFillBelowEnabled(); if (mapView != null) { - fillRandomWanted(mapView, InsertionMode.BOTTOMMOST); + fillRandom(mapView, InsertionMode.BOTTOMMOST); } } @@ -589,7 +589,7 @@ * @param mapView the map view to fill * @param insertionMode the insertion mode to use */ - private void fillRandomWanted(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) { + private void fillRandom(@NotNull final MapView<G, A, R> mapView, @NotNull final InsertionMode insertionMode) { final int rand = getFillDensity("Random fill"); if (rand >= 0) { FillUtils.fill(mapView, insertionMode, objectChooser.getSelections(), rand); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/EventsTab.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -33,7 +33,7 @@ */ public class EventsTab<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractGameObjectAttributesTab<G, A, R> { - // constants for the 'task' parameter in editEventWanted() + // constants for the 'task' parameter in editEvent() public static final int EVENT_OPEN = 0; public static final int EVENT_EDIT_PATH = 1; @@ -172,29 +172,29 @@ /** Action method for creating a new event. */ @ActionMethod public void eventAddNew() { - addNewEventWanted(); + addNewEvent(); } /** Action method for editing the data of an existing event. */ @ActionMethod public void eventEditData() { - editEventWanted(EVENT_EDIT_PATH); + editEvent(EVENT_EDIT_PATH); } /** Action method for editing an existing event. */ @ActionMethod public void eventEdit() { - editEventWanted(EVENT_OPEN); + editEvent(EVENT_OPEN); } /** Action method for removing an existing event. */ @ActionMethod public void eventRemove() { - editEventWanted(EVENT_REMOVE); + editEvent(EVENT_REMOVE); } /** This method is invoked when the user pressed the "new event" button. */ - public void addNewEventWanted() { + public void addNewEvent() { if (selectedGameObject != null) { final G selectedHead = selectedGameObject.getHead(); final MapSquare<G, A, R> mapSquare = selectedHead.getMapSquare(); @@ -223,7 +223,7 @@ * triggered. * @param task event type to edit (?). */ - public void editEventWanted(final int task) { + public void editEvent(final int task) { if (selectedGameObject == null) { return; } Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -148,7 +148,7 @@ /** {@inheritDoc} */ @Override - public void openFileWanted(final boolean mapFilter) { + public void openFile(final boolean mapFilter) { if (fileChooser == null) { createFileChooser(); } Modified: trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -35,7 +35,7 @@ * @param mapFilter set to <code>true</code> if the user probably wants to * open a map, <code>false</code> otherwise */ - void openFileWanted(boolean mapFilter); + void openFile(boolean mapFilter); /** * Invoked when user wants to save a map to certain file. Modified: trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/spells/SpellsUtils.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -75,7 +75,7 @@ * @param dir the directory to use * @param parent Component the parent component for dialog boxes */ - public void importSpellsWanted(@NotNull final File dir, @NotNull final Component parent) { + public void importSpells(@NotNull final File dir, @NotNull final Component parent) { // open a file chooser window final JFileChooser fileChooser = new JFileChooser(); fileChooser.setDialogTitle("Open CF Spellist File"); Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/Actions.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/Actions.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/Actions.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -91,7 +91,7 @@ /** Action for "open". */ public void scriptEditOpen() { - control.openUserWanted(); + control.openUser(); } /** Action for "save as". */ Modified: trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -135,7 +135,7 @@ } /** Open a file which is chosen by the user. */ - public void openUserWanted() { + public void openUser() { openFileChooser.setDialogTitle("Open Script File"); final int returnVal = openFileChooser.showOpenDialog(view); Modified: trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-19 17:09:58 UTC (rev 6485) +++ trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-19 17:19:59 UTC (rev 6486) @@ -40,7 +40,7 @@ /** {@inheritDoc} */ @Override - public void openFileWanted(final boolean mapFilter) { + public void openFile(final boolean mapFilter) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-22 10:51:31
|
Revision: 6518 http://gridarta.svn.sourceforge.net/gridarta/?rev=6518&view=rev Author: akirschbaum Date: 2009-04-22 10:51:26 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Move MapCursor and related classes to separate package. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/GUIMainControl.java trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/StatusBar.java trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java trunk/src/app/net/sf/gridarta/gui/map/grid/MapGrid.java trunk/src/app/net/sf/gridarta/gui/map/package-info.java trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/gui/objectchoicedisplay/ObjectChoiceDisplay.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/cursor/ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorEvent.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorListener.java trunk/src/test/net/sf/gridarta/gui/map/cursor/ trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorEvent.java trunk/src/app/net/sf/gridarta/gui/map/MapCursorListener.java trunk/src/test/net/sf/gridarta/gui/map/MapCursorTest.java Modified: trunk/src/app/net/sf/gridarta/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -83,7 +83,6 @@ import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesControl; import net.sf.gridarta.gui.gameobjectattributespanel.GameObjectAttributesModel; import net.sf.gridarta.gui.map.DefaultMapActions; -import net.sf.gridarta.gui.map.MapCursorActions; import net.sf.gridarta.gui.map.MapFileActions; import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapPropertiesDialogFactory; @@ -91,6 +90,7 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.gui.map.cursor.MapCursorActions; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.map.tools.DeletionTool; import net.sf.gridarta.gui.map.tools.ToolPalette; Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -25,8 +25,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorController.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorController.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -24,9 +24,9 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.MapViewManagerListener; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.cursor.MapCursorEvent; +import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.map.MapArchObject; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -34,9 +34,9 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gui.map.FillUtils; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.cursor.MapCursorEvent; +import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.gui.map.grid.MapGridEvent; import net.sf.gridarta.gui.map.grid.MapGridListener; Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -25,8 +25,8 @@ import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.map.MapCursor; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.map.InsertionMode; Modified: trunk/src/app/net/sf/gridarta/gui/StatusBar.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/StatusBar.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -37,10 +37,10 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.map.LevelRenderer; -import net.sf.gridarta.gui.map.MapCursor; -import net.sf.gridarta.gui.map.MapCursorEvent; -import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.cursor.MapCursor; +import net.sf.gridarta.gui.map.cursor.MapCursorEvent; +import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; Modified: trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -34,6 +34,9 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MapViewManager; import net.sf.gridarta.gui.MapViewManagerListener; +import net.sf.gridarta.gui.map.cursor.MapCursor; +import net.sf.gridarta.gui.map.cursor.MapCursorEvent; +import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; Deleted: trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -1,413 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map; - -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import javax.swing.event.EventListenerList; -import net.sf.gridarta.gui.map.grid.MapGrid; -import net.sf.gridarta.gui.map.grid.MapGridEvent; -import net.sf.gridarta.gui.map.grid.MapGridListener; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * MapCursor provides methods to move and drag on map. The MapCursor is bound to - * a {@link MapGrid} which will change it flags depending on MapCursor - * movement/selection. - * <p/> - * There are three different states for MapCursor: <ul> <li>Deactivated</li> - * <li>On the map</li> <li>Dragging</li> </ul> When coordinates or state of - * MapCursor changes a {@link MapCursorEvent} is fired. - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - */ -public class MapCursor implements MapGridListener { - - /** - * Current cursor position. When cursor is active it is highlighted on the - * MapGrid. - */ - private final Point pos = new Point(); - - /** Position where dragging has started. */ - private final Point dragStart = new Point(); - - /** Offset of dragging. (0, 0) when drag is on the starting position. */ - private final Dimension dragOffset = new Dimension(); - - /** Whether the cursor is currently on map. */ - private boolean onMap; - - /** Gets set to <code>true</code> when in drag mode. */ - private boolean dragging; - - /** Grid where cursor is bound to. */ - private final MapGrid mapGrid; - - /** Used to test if coordinates are on the map. Created by MapGrid. */ - private final Rectangle mapRec; - - /** Relative coordinates of directions. */ - public static final int[][] direction = { - {0, -1}, // N - {1, 0}, // E - {0, 1}, // S - {-1, 0}, // W - {1, -1}, // NE - {1, 1}, // SE - {-1, 1}, // SW - {-1, -1} // NW - }; - - /** - * Temporary point used in some methods. Placed as instance var to prevent - * creation of temporary objects. - */ - private final Point tmpPoint = new Point(); - - /** The MapCursorListeners to inform of changes. */ - private final EventListenerList listenerList = new EventListenerList(); - - /** - * Construct a MapCursor. The cursor will be deactivated after - * construction. - * @param mapGrid Cursor is bound to this grid - */ - public MapCursor(final MapGrid mapGrid) { - this.mapGrid = mapGrid; - mapRec = mapGrid.getMapRec(); - mapGrid.addMapGridListener(this); - deactivate(); - } - - /** - * Get position of cursor. - * @return coordinates of cursor or <code>null</code> if cursor is not - * active - */ - @Nullable - public Point getLocation() { - return onMap ? pos : null; - } - - /** - * Move cursor to a new location. If new location is not on map, cursor gets - * disabled. - * @param p New location. If <code>p == null</code> cursor gets disabled - * @return <code>true</code> if cursor position changed or if it gets - * disabled - */ - public boolean setLocation(@Nullable final Point p) { - mapGrid.beginTransaction(); - try { - final boolean hasChanged; - if (p != null && mapRec.contains(p)) { - if (onMap) { - if (pos.equals(p)) { - hasChanged = false; - } else { - mapGrid.unSetCursor(pos); - pos.setLocation(p); - mapGrid.setCursor(pos); - fireMapCursorChangedPosEvent(); - hasChanged = true; - } - } else { - pos.setLocation(p); - mapGrid.setCursor(pos); - onMap = true; - fireMapCursorChangedModeEvent(); - fireMapCursorChangedPosEvent(); - hasChanged = true; - } - } else if (onMap) { - deactivate(); - hasChanged = true; - } else { - hasChanged = false; - } - return hasChanged; - } finally { - mapGrid.endTransaction(); - } - } - - /** - * Move cursor to a new location. If new location is not on map, cursor does - * not change. - * @param p New location. If <code>p == null</code> nothing happens - * @return <code>true</code> if cursor position changed - */ - public boolean setLocationSafe(@Nullable final Point p) { - mapGrid.beginTransaction(); - final boolean hasChanged; - try { - if (p != null && mapRec.contains(p)) { - if (onMap) { - if (pos.equals(p)) { - hasChanged = false; - } else { - mapGrid.unSetCursor(pos); - pos.setLocation(p); - mapGrid.setCursor(pos); - hasChanged = true; - } - } else { - pos.setLocation(p); - onMap = true; - fireMapCursorChangedModeEvent(); - hasChanged = true; - } - } else { - hasChanged = false; - } - } finally { - mapGrid.endTransaction(); - } - if (hasChanged) { - fireMapCursorChangedPosEvent(); - } - return hasChanged; - } - - /** Set cursor to drag mode when it is active. */ - public void dragStart() { - if (onMap && !dragging) { - mapGrid.beginTransaction(); - try { - dragStart.setLocation(pos); - mapGrid.preSelect(dragStart, pos); - dragging = true; - dragOffset.setSize(0, 0); - } finally { - mapGrid.endTransaction(); - } - fireMapCursorChangedModeEvent(); - } - } - - /** - * When in drag mode and the point is on the map cursor is moved to this - * position. {@link MapGrid} changes preselection accordingly. - * @param p new coordinates - * @return <code>true</code> when dragging position changed successfully - */ - public boolean dragTo(@Nullable final Point p) { - if (p != null && mapRec.contains(p) && dragging && !pos.equals(p)) { - mapGrid.beginTransaction(); - try { - final Point oldPos = new Point(pos); - mapGrid.unSetCursor(pos); - pos.setLocation(p); - mapGrid.updatePreSelect(dragStart, oldPos, pos); - mapGrid.setCursor(pos); - dragOffset.setSize(pos.x - dragStart.x, pos.y - dragStart.y); - } finally { - mapGrid.endTransaction(); - } - fireMapCursorChangedPosEvent(); - return true; - } - return false; - } - - /** Leave drag mode and undo preselection. */ - public void dragRelease() { - if (dragging) { - mapGrid.beginTransaction(); - try { - mapGrid.unPreSelect(dragStart, pos); - dragging = false; - } finally { - mapGrid.endTransaction(); - } - fireMapCursorChangedModeEvent(); - } - } - - /** - * Leave drag mode and select preselection using selectionMode. - * @param selectionMode Mode how to change selection state - * @see MapGrid.SelectionMode - */ - public void dragSelect(final MapGrid.SelectionMode selectionMode) { - if (dragging) { - mapGrid.beginTransaction(); - try { - dragRelease(); - mapGrid.select(dragStart, pos, selectionMode); - } finally { - mapGrid.endTransaction(); - } - } - } - - /** Cursor gets deactivated. All selections get lost. */ - public void deactivate() { - final boolean hasChanged = onMap; - mapGrid.beginTransaction(); - try { - onMap = false; - dragging = false; - mapGrid.unSetCursor(pos); - mapGrid.unSelect(); - } finally { - mapGrid.endTransaction(); - } - if (hasChanged) { - fireMapCursorChangedModeEvent(); - fireMapCursorChangedPosEvent(); - } - } - - /** - * Get cursor state. - * @return <code>true</code> if cursor is on the map - */ - public boolean isActive() { - return onMap; - } - - /** - * Get offset from start position of dragging. - * @return offset or <code>null</code> when not in drag mode - */ - @Nullable - public Dimension getDragOffset() { - return dragging ? dragOffset : null; - } - - /** - * Check if point is on grid. - * @param p Coordinates of point - * @return <code>true</code> if <code>p != null</code> and point is on grid - */ - public boolean isOnGrid(@Nullable final Point p) { - return p != null && mapRec.contains(p); - } - - /** - * Moves the cursor 1 tile relative to current position. - * @param dir Index of {@link #direction} - * @return <code>true</code> if cursor really moved - */ - public boolean goTo(final int dir) { - assert dir >= 0 && dir < 8; - if (onMap) { - tmpPoint.setLocation(pos.x + direction[dir][0], pos.y + direction[dir][1]); - if (dragging) { - return dragTo(tmpPoint); - } else { - return setLocationSafe(tmpPoint); - } - } - return false; - } - - /** - * Returns whether the cursor is currently being dragged. - * @return <code>true</code> if dragging is active, otherwise - * <code>false</code>. - */ - public boolean isDragging() { - return dragging; - } - - /** - * Register a MapCursorListener. - * @param listener MapCursorListener to register - */ - public void addMapCursorListener(final MapCursorListener listener) { - listenerList.add(MapCursorListener.class, listener); - } - - /** - * Remove a MapCursorListener. - * @param listener MapCursorListener to remove - */ - public void removeMapCursorListener(final MapCursorListener listener) { - listenerList.remove(MapCursorListener.class, listener); - } - - /** Inform all registered listeners that the MapCursor's mode has changed. */ - private void fireMapCursorChangedModeEvent() { - final MapCursorEvent e = new MapCursorEvent(this); - for (final MapCursorListener listener : listenerList.getListeners(MapCursorListener.class)) { - listener.mapCursorChangedMode(e); - } - } - - /** - * Inform all registered listeners that the MapCursor's position has - * changed. - */ - private void fireMapCursorChangedPosEvent() { - final MapCursorEvent e = new MapCursorEvent(this); - for (final MapCursorListener listener : listenerList.getListeners(MapCursorListener.class)) { - listener.mapCursorChangedPos(e); - } - } - - /** {@inheritDoc} */ - @Override - public void mapGridChanged(@NotNull final MapGridEvent e) { - // We can ignore this event. Normally this MapCursor has caused it. - } - - /** {@inheritDoc} */ - @Override - public void mapGridResized(@NotNull final MapGridEvent e) { - // Test if drag start point is outside map -> move inside - if (dragging && !mapRec.contains(dragStart)) { - dragStart.x = Math.min(dragStart.x, mapRec.width - 1); - dragStart.y = Math.min(dragStart.y, mapRec.height - 1); - } - // Test if cursor position is outside map -> move inside - if (onMap && !mapRec.contains(pos)) { - pos.x = Math.min(pos.x, mapRec.width - 1); - pos.y = Math.min(pos.y, mapRec.height - 1); - mapGrid.setCursor(pos); - fireMapCursorChangedPosEvent(); - } - } - - /** - * Start a new transaction. Transactions may be nested. Transactions serve - * the purpose of firing events to the views when more changes are known to - * come before the view is really required to update. Each invocation of - * {@link #beginTransaction()} requires its own invocation of {@link - * #endTransaction()}. - */ - public void beginTransaction() { - mapGrid.beginTransaction(); - } - - /** - * End a transaction. Invoking this method will reduce the transaction depth - * by 1. - * <p/> - * If the last transaction is ended, the changes are committed. - */ - public void endTransaction() { - mapGrid.endTransaction(); - } - -} // class MapCursor Deleted: trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorActions.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -1,511 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map; - -import java.awt.Point; -import javax.swing.Action; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gui.MapViewManager; -import net.sf.gridarta.gui.MapViewManagerListener; -import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.map.grid.MapGrid; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; -import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; -import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.utils.CommonConstants; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Cursor related actions. - * @author Andreas Kirschbaum - */ -public class MapCursorActions<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** Action Builder to create Actions. */ - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** Directions for cursor movement. */ - private final String[] directionsGo = {"goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest"}; - - /** Action for "go location". */ - private final Action aGoLocation; - - /** Action for "select tile". */ - private final Action aSelectTile; - - /** Action for "add to selection". */ - private final Action aAddToSelection; - - /** Action for "remove from selection". */ - private final Action aSubFromSelection; - - /** Action for "stop stop drag". */ - private final Action aStartStopDrag; - - /** Action for "release drag". */ - private final Action aReleaseDrag; - - /** Action for "insert arch". */ - private final Action aInsertArch; - - /** Action for "delete arch". */ - private final Action aDeleteArch; - - /** Action for "select arch above". */ - private final Action aSelectArchAbove; - - /** Action for "select arch below". */ - private final Action aSelectArchBelow; - - /** Action for "arch attributes". */ - private final Action aArchAttributes; - - /** - * The factory for creating game object attributes dialog instances. - */ - private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; - - /** The selected square control. */ - private final SelectedSquareControl<G, A, R> selectedSquareControl; - - /** The selected square model. */ - private final SelectedSquareModel<G, A, R> selectedSquareModel; - - /** - * The {@link GoLocationDialogManager} to track go location dialog - * instances. - */ - private final GoLocationDialogManager<G, A, R> goLocationDialogManager; - - /** The active map view, or <code>null</code> if no map view exists. */ - @Nullable - private MapView<G, A, R> currentMapView; - - /** The map view manager listener used to detect changed current maps. */ - private final MapViewManagerListener<G, A, R> mapViewManagerListener = new MapViewManagerListener<G, A, R>() { - - /** {@inheritDoc} */ - @Override - public void currentMapViewChanged(@Nullable final MapView<G, A, R> mapView) { - currentMapView = mapView; - refreshActions(); - } - - /** {@inheritDoc} */ - @Override - public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().addMapCursorListener(mapCursorListener); - } - - /** {@inheritDoc} */ - @Override - public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { - mapView.getMapViewBasic().getMapCursor().removeMapCursorListener(mapCursorListener); - } - - }; - - /** - * The map cursor listener used to detect cursor state changes in {@link - * #currentMapView}. - */ - private final MapCursorListener mapCursorListener = new MapCursorListener() { - - /** {@inheritDoc} */ - @Override - public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { - // ignore - } - - /** {@inheritDoc} */ - @Override - public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { - refreshActions(); - } - - }; - - /** - * Create a new instance. - * @param gameObjectAttributesDialogFactory the factory for creating game - * object attributes dialog instances - * @param mapViewManager the map view manager - * @param selectedSquareControl the selected square control - * @param selectedSquareModel the selected square model - */ - public MapCursorActions(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final SelectedSquareControl<G, A, R> selectedSquareControl, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel) { - this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; - this.selectedSquareControl = selectedSquareControl; - this.selectedSquareModel = selectedSquareModel; - goLocationDialogManager = new GoLocationDialogManager<G, A, R>(mapViewManager); - ACTION_BUILDER.createActions(true, this, directionsGo); - aGoLocation = ACTION_BUILDER.createAction(true, "goLocation", this); - aSelectTile = ACTION_BUILDER.createAction(true, "selectTile", this); - aAddToSelection = ACTION_BUILDER.createAction(true, "addToSelection", this); - aSubFromSelection = ACTION_BUILDER.createAction(true, "subFromSelection", this); - aStartStopDrag = ACTION_BUILDER.createAction(true, "startStopDrag", this); - aReleaseDrag = ACTION_BUILDER.createAction(true, "releaseDrag", this); - aInsertArch = ACTION_BUILDER.createAction(true, "insertArch", this); - aDeleteArch = ACTION_BUILDER.createAction(true, "deleteArch", this); - aSelectArchAbove = ACTION_BUILDER.createAction(true, "selectArchAbove", this); - aSelectArchBelow = ACTION_BUILDER.createAction(true, "selectArchBelow", this); - aArchAttributes = ACTION_BUILDER.createAction(true, "archAttributes", this); - mapViewManager.addMapViewManagerListener(mapViewManagerListener); - currentMapView = mapViewManager.getCurrentMapView(); - refreshActions(); - } - - /** Action method for "cursor north". */ - public void goNorth() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.NORTH); - } - } - - /** Action method for "cursor south". */ - public void goSouth() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.SOUTH); - } - } - - /** Action method for "cursor east". */ - public void goEast() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.EAST); - } - } - - /** Action method for "cursor west". */ - public void goWest() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.WEST); - } - } - - /** Action method for "cursor north east". */ - public void goNorthEast() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.NORTH_EAST); - } - } - - /** Action method for "cursor north west". */ - public void goNorthWest() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.NORTH_WEST); - } - } - - /** Action method for "cursor south east". */ - public void goSouthEast() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.SOUTH_EAST); - } - } - - /** Action method for "cursor south west". */ - public void goSouthWest() { - final MapCursor mapCursor = getGoEnabled(); - if (mapCursor != null) { - mapCursor.goTo(CommonConstants.SOUTH_WEST); - } - } - - /** Action method for "go location". */ - public void goLocation() { - final MapView<G, A, R> mapView = getGoLocationEnabled(); - if (mapView != null) { - goLocationDialogManager.showDialog(mapView); - } - } - - /** Action method for "select tile". */ - public void selectTile() { - final MapCursor mapCursor = getSelectTileEnabled(); - if (mapCursor != null) { - selectTile(mapCursor, MapGrid.SelectionMode.FLIP); - } - } - - /** Action method for "add to selection". */ - public void addToSelection() { - final MapCursor mapCursor = getAddToSelectionEnabled(); - if (mapCursor != null) { - selectTile(mapCursor, MapGrid.SelectionMode.ADD); - } - } - - /** Action method for "remove from selection". */ - public void subFromSelection() { - final MapCursor mapCursor = getSubFromSelectionEnabled(); - if (mapCursor != null) { - selectTile(mapCursor, MapGrid.SelectionMode.SUB); - } - } - - /** Action method for "start stop drag". */ - public void startStopDrag() { - final MapCursor mapCursor = getStartStopDragEnabled(); - if (mapCursor != null) { - startStopDrag(mapCursor); - } - } - - /** Action method for "release drag". */ - public void releaseDrag() { - final MapCursor mapCursor = getReleaseDragEnabled(); - if (mapCursor != null) { - releaseDrag(mapCursor); - } - } - - /** Action method for "insert arch". */ - public void insertArch() { - final MapView<G, A, R> mapView = getInsertArchEnabled(); - if (mapView != null) { - selectedSquareControl.insertGameObjectFromObjectChooser(mapView); - } - } - - /** Action method for "delete arch". */ - public void deleteArch() { - final MapView<G, A, R> mapView = getDeleteArchEnabled(); - if (mapView != null) { - selectedSquareControl.deleteSelection(mapView); - } - } - - /** Action method for "select arch above". */ - public void selectArchAbove() { - final MapCursor mapCursor = getSelectArchAboveEnabled(); - if (mapCursor != null) { - selectedSquareControl.selectArch(true); - } - } - - /** Action method for "select arch below". */ - public void selectArchBelow() { - final MapCursor mapCursor = getSelectArchBelowEnabled(); - if (mapCursor != null) { - selectedSquareControl.selectArch(false); - } - } - - /** Action method for "arch attributes". */ - public void archAttributes() { - final G gameObject = getArchAttributesEnabled(); - if (gameObject != null) { - gameObjectAttributesDialogFactory.showAttribDialog(gameObject); - } - } - - /** - * Return the map cursor to use for "move cursor". - * @return the map cursor, or <code>null</code> if "move cursor" is - * disabled - */ - @Nullable - private MapCursor getGoEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map view to use for "go location". - * @return the map view, or <code>null</code> if "go location" is disabled - */ - @Nullable - private MapView<G, A, R> getGoLocationEnabled() { - return currentMapView; - } - - /** - * Return the map cursor to use for "select tile". - * @return the map cursor, or <code>null</code> if "select tile" is - * disabled - */ - @Nullable - private MapCursor getSelectTileEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map cursor to use for "add to selection". - * @return the map cursor, or <code>null</code> if "add to selection" is - * disabled - */ - @Nullable - private MapCursor getAddToSelectionEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map cursor to use for "remove from selection". - * @return the map cursor, or <code>null</code> if "remove from selection" - * is disabled - */ - @Nullable - private MapCursor getSubFromSelectionEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map cursor to use for "start stop drag". - * @return the map cursor, or <code>null</code> if "start stop drag" is - * disabled - */ - @Nullable - private MapCursor getStartStopDragEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map cursor to use for "release drag". - * @return the map cursor, or <code>null</code> if "release drag" is - * disabled - */ - @Nullable - private MapCursor getReleaseDragEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map to use for "insert arch". - * @return the map, or <code>null</code> if "insert arch" is disabled - */ - @Nullable - private MapView<G, A, R> getInsertArchEnabled() { - return getActiveMapCursor() != null ? currentMapView : null; - } - - /** - * Return the map to use for "delete arch". - * @return the map, or <code>null</code> if "delete arch" is disabled - */ - @Nullable - private MapView<G, A, R> getDeleteArchEnabled() { - return getActiveMapCursor() != null ? currentMapView : null; - } - - /** - * Return the map cursor to use for "select arch above". - * @return the map cursor, or <code>null</code> if "select arch above" is - * disabled - */ - @Nullable - private MapCursor getSelectArchAboveEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the map cursor to use for "select arch below". - * @return the map cursor, or <code>null</code> if "select arch below" is - * disabled - */ - @Nullable - private MapCursor getSelectArchBelowEnabled() { - return getActiveMapCursor(); - } - - /** - * Return the game object to use for "arch attributes". - * @return the game object, or <code>null</code> if "arch attributes" is - * disabled - */ - @Nullable - private G getArchAttributesEnabled() { - final MapCursor mapCursor = getActiveMapCursor(); - return mapCursor != null ? selectedSquareModel.getSelectedGameObject() : null; - } - - /** - * Return the map cursor of the current map view if it is active. - * @return the map cursor, or <code>null</code> if the cursor is not active, - * or if no map view exists - */ - @Nullable - private MapCursor getActiveMapCursor() { - final MapCursor mapCursor = getMapCursor(); - return mapCursor != null && mapCursor.isActive() ? mapCursor : null; - } - - /** - * Return the map cursor of the current map view. - * @return the map cursor, or <code>null</code> if no map view exists - */ - @Nullable - private MapCursor getMapCursor() { - return currentMapView != null ? currentMapView.getMapViewBasic().getMapCursor() : null; - } - - /** Enable/disable menu entries based on the current cursor state. */ - private void refreshActions() { - final boolean goEnabled = getGoEnabled() != null; - for (final String aDirectionsGo : directionsGo) { - ACTION_BUILDER.getAction(aDirectionsGo).setEnabled(goEnabled); - } - aGoLocation.setEnabled(getGoLocationEnabled() != null); - aSelectTile.setEnabled(getSelectTileEnabled() != null); - aAddToSelection.setEnabled(getAddToSelectionEnabled() != null); - aSubFromSelection.setEnabled(getSubFromSelectionEnabled() != null); - aStartStopDrag.setEnabled(getStartStopDragEnabled() != null); - aReleaseDrag.setEnabled(getReleaseDragEnabled() != null); - aInsertArch.setEnabled(getInsertArchEnabled() != null); - aDeleteArch.setEnabled(getDeleteArchEnabled() != null); - aSelectArchAbove.setEnabled(getSelectArchAboveEnabled() != null); - aSelectArchBelow.setEnabled(getSelectArchBelowEnabled() != null); - aArchAttributes.setEnabled(getArchAttributesEnabled() != null); - } - - private static void selectTile(@NotNull final MapCursor mapCursor, final MapGrid.SelectionMode mode) { - mapCursor.dragStart(); - mapCursor.dragSelect(mode); - } - - private static void startStopDrag(@NotNull final MapCursor mapCursor) { - if (mapCursor.isDragging()) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); - } else { - mapCursor.dragStart(); - } - } - - private static void releaseDrag(@NotNull final MapCursor mapCursor) { - if (mapCursor.isDragging()) { - mapCursor.dragRelease(); - } else { - final Point p = mapCursor.getLocation(); - mapCursor.deactivate(); - mapCursor.setLocation(p); - } - } - -} // class MapCursorActions Deleted: trunk/src/app/net/sf/gridarta/gui/map/MapCursorEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorEvent.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorEvent.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -1,50 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map; - -import java.util.EventObject; -import org.jetbrains.annotations.NotNull; - -/** - * This Event is created by {@link MapCursor}. - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - */ -public class MapCursorEvent extends EventObject { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** - * Constructs a MapCursorEvent. - * @param source The object on which the Event initially occurred. - * @throws IllegalArgumentException if source is null. - */ - public MapCursorEvent(@NotNull final MapCursor source) { - super(source); - } - - /** {@inheritDoc} */ - @Override - @NotNull - public MapCursor getSource() { - return (MapCursor) super.getSource(); - } - -} // class MapCursorEvent Deleted: trunk/src/app/net/sf/gridarta/gui/map/MapCursorListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapCursorListener.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/MapCursorListener.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -1,45 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map; - -import java.util.EventListener; -import org.jetbrains.annotations.NotNull; - -/** - * Interface for listeners listening to {@link MapCursorEvent}s. - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - */ -public interface MapCursorListener extends EventListener { - - /** - * This event handler is called when {@link MapCursor} has moved, appeared - * or disappeared. - * @param e MapCursorEvent - */ - void mapCursorChangedPos(@NotNull MapCursorEvent e); - - /** - * This event handler is called when {@link MapCursor} changes mode (drag, - * select). - * @param e MapCursorEvent - */ - void mapCursorChangedMode(@NotNull MapCursorEvent e); - -} // interface MapCursorListener Modified: trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2009-04-22 10:41:24 UTC (rev 6517) +++ trunk/src/app/net/sf/gridarta/gui/map/MapViewBasic.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -30,6 +30,9 @@ import javax.swing.JViewport; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.cursor.MapCursor; +import net.sf.gridarta.gui.map.cursor.MapCursorEvent; +import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; Copied: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java (from rev 6517, trunk/src/app/net/sf/gridarta/gui/map/MapCursor.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2009-04-22 10:51:26 UTC (rev 6518) @@ -0,0 +1,413 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.cursor; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import javax.swing.event.EventListenerList; +import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.MapGridEvent; +import net.sf.gridarta.gui.map.grid.MapGridListener; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * MapCursor provides methods to move and drag on map. The MapCursor is bound to + * a {@link MapGrid} which will change it flags depending on MapCursor + * movement/selection. + * <p/> + * There are three different states for MapCursor: <ul> <li>Deactivated</li> + * <li>On the map</li> <li>Dragging</li> </ul> When coordinates or state of + * MapCursor changes a {@link MapCursorEvent} is fired. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public class MapCursor implements MapGridListener { + + /** + * Current cursor position. When cursor is active it is highlighted on the + * MapGrid. + */ + private final Point pos = new Point(); + + /** Position where dragging has started. */ + private final Point dragStart = new Point(); + + /** Offset of dragging. (0, 0) when drag is on the starting position. */ + private final Dimension dragOffset = new Dimension(); + + /** Whether the cursor is currently on map. */ + private boolean onMap; + + /** Gets set to <code>true</code> when in drag mode. */ + private boolean dragging; + + /** Grid where cursor is bound to. */ + private final MapGrid mapGrid; + + /** Used to test if coordinates are on the map. Created by MapGrid. */ + private final Rectangle mapRec; + + /** Relative coordinates of directions. */ + public static final int[][] direction = { + {0, -1}, // N + {1, 0}, // E + {0, 1}, // S + {-1, 0}, // W + {1, -1}, // NE + {1, 1}, // SE + {-1, 1}, // SW + {-1, -1} // NW + }; + + /** + * Temporary point used in some methods. Placed as instance var to prevent + * creation of temporary objects. + */ + private final Point tmpPoint = new Point(); + + /** The MapCursorListeners to inform of changes. */ + private final EventListenerList listenerList = new EventListenerList(); + + /** + * Construct a MapCursor. The cursor will be deactivated after + * construction. + * @param mapGrid Cursor is bound to this grid + */ + public MapCursor(final MapGrid mapGrid) { + this.mapGrid = mapGrid; + mapRec = mapGrid.getMapRec(); + mapGrid.addMapGridListener(this); + deactivate(); + } + + /** + * Get position of cursor. + * @return coordinates of cursor or <code>null</code> if cursor is not + * active + */ + @Nullable + public Point getLocation() { + return onMap ? pos : null; + } + + /** + * Move cursor to a new location. If new location is not on map, cursor gets + * disabled. + * @param p New location. If <code>p == null</code> cursor gets disabled + * @return <code>true</code> if cursor position changed or if it gets + * disabled + */ + public boolean setLocation(@Nullable final Point p) { + mapGrid.beginTransaction(); + try { + final boolean hasChanged; + if (p != null && mapRec.contains(p)) { + if (onMap) { + if (pos.equals(p)) { + hasChanged = false; + } else { + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.setCursor(pos); + fireMapCursorChangedPosEvent(); + hasChanged = true; + } + } else { + pos.setLocation(p); + mapGrid.setCursor(pos); + onMap = true; + fireMapCursorChangedModeEvent(); + fireMapCursorChangedPosEvent(); + hasChanged = true; + } + } else if (onMap) { + deactivate(); + hasChanged = true; + } else { + hasChanged = false; + } + return hasChanged; + } finally { + mapGrid.endTransaction(); + } + } + + /** + * Move cursor to a new location. If new location is not on map, cursor does + * not change. + * @param p New location. If <code>p == null</code> nothing happens + * @return <code>true</code> if cursor position changed + */ + public boolean setLocationSafe(@Nullable final Point p) { + mapGrid.beginTransaction(); + final boolean hasChanged; + try { + if (p != null && mapRec.contains(p)) { + if (onMap) { + if (pos.equals(p)) { + hasChanged = false; + } else { + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.setCursor(pos); + hasChanged = true; + } + } else { + pos.setLocation(p); + onMap = true; + fireMapCursorChangedModeEvent(); + hasChanged = true; + } + } else { + hasChanged = false; + } + } finally { + mapGrid.endTransaction(); + } + if (hasChanged) { + fireMapCursorChangedPosEvent(); + } + return hasChanged; + } + + /** Set cursor to drag mode when it is active. */ + public void dragStart() { + if (onMap && !dragging) { + mapGrid.beginTransaction(); + try { + dragStart.setLocation(pos); + mapGrid.preSelect(dragStart, pos); + dragging = true; + dragOffset.setSize(0, 0); + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedModeEvent(); + } + } + + /** + * When in drag mode and the point is on the map cursor is moved to this + * position. {@link MapGrid} changes preselection accordingly. + * @param p new coordinates + * @return <code>true</code> when dragging position changed successfully + */ + public boolean dragTo(@Nullable final Point p) { + if (p != null && mapRec.contains(p) && dragging && !pos.equals(p)) { + mapGrid.beginTransaction(); + try { + final Point oldPos = new Point(pos); + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.updatePreSelect(dragStart, oldPos, pos); + mapGrid.setCursor(pos); + dragOffset.setSize(pos.x - dragStart.x, pos.y - dragStart.y); + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedPosEvent(); + return true; + } + return false; + } + + /** Leave drag mode and undo preselection. */ + public void dragRelease() { + if (dragging) { + mapGrid.beginTransaction(); + try { + mapGrid.unPreSelect(dragStart, pos); + dragging = false; + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedModeEvent(); + } + } + + /** + * Leave drag mode and select preselection using selectionMode. + * @param selectionMode Mode how to change selection state + * @see MapGrid.SelectionMode + */ + public void dragSelect(final MapGrid.SelectionMode selectionMode) { + if (dragging) { + mapGrid.beginTransaction(); + try { + dragRelease(); + mapGrid.select(dragStart, pos, selectionMode); + } finally { + mapGrid.endTransaction(); + } + } + } + + /** Cursor gets deactivated. All selections get lost. */ + public void deactivate() { + final boolean hasChanged = onMap; + mapGrid.beginTransaction(); + try { + onMap = false; + dragging = false; + mapGrid.unSetCursor(pos); + mapGrid.unSelect(); + } finally { + mapGrid.endTransaction(); + } + if (hasChanged) { + fireMapCursorChangedModeEvent(); + fireMapCursorChangedPosEvent(); + } + } + + /** + * Get cursor state. + * @return <code>true</code> if cursor is on the map + */ + public boolean isActive() { + return onMap; + } + + /** + * Get offset from start position of dragging. + * @return offset or <code>null</code> when not in drag mode + */ + @Nullable + public Dimension getDragOffset() { + return dragging ? dragOffset : null; + } + + /** + * Check if point is on grid. + * @param p Coordinates of point + * @return <code>true</code> if <code>p != null</code> and point is on grid + */ + public boolean isOnGrid(@Nullable final Point p) { + return p != null && mapRec.contains(p); + } + + /** + * Moves the cursor 1 tile relative to current position. + * @param dir Index of {@link #direction} + * @return <code>true</code> if cursor really moved + */ + public boolean goTo(final int dir) { + assert dir >= 0 && dir < 8; + if (onMap) { + tmpPoint.setLocation(pos.x + direction[dir][0], pos.y + direction[dir][1]); + if (dragging) { + return dragTo(tmpPoint); + } else { + return setLocationSafe(tmpPoint); + } + } + return false; + } + + /** + * Returns whether the cursor is currently being dragged. + * @return <code>true</code> if dragging is active, otherwise + * <code>false</code>. + */ + public boolean isDragging() { + return dragging; + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + listenerList.add(MapCursorListener.class, listener); + } + + /** + * Remove a MapCursorListener. + * @param listener MapCursorListener to remove + */ + public void removeMapCursorListener(final MapCursorListener listener) { + listenerList.remove(MapCursorListener.class, listener); + } + + /** Inform all registered listeners that the MapCursor's mode has changed. */ + private void fireMapCursorChangedModeEvent() { + final MapCursorEvent e = new MapCursorEvent(this); + for (final MapCursorListener listener : listenerList.getListeners(MapCursorListener.class)) { + listener.mapCursorChangedMode(e); + } + } + + /** + * Inform all registered listeners that the MapCursor's position has + * changed. + */ + private void fireMapCursorChangedPosEvent() { + final MapCursorEvent e = new MapCursorEvent(this); + for (final MapCursorListener listener : listenerList.getListeners(MapCursorListener.class)) { + listener.mapCursorChangedPos(e); + } + } + + /** {@inheritDoc} */ + @Override + public void mapGridChanged(@NotNull final MapGridEvent e) { + // We can ignore this event. Normally this MapCursor has caused it. + } + + /** {@inheritDoc} */ + @Override + public void mapGridResized(@NotNull final MapGridEvent e) { + // Test if drag start point is outside map -> move inside + if (dragging && !mapRec.contains(dragStart)) { + dragStart.x = Math.min(dragStart.x, mapRec.width - 1); + dragStart.y = Math.min(dragStart.y, mapRec.height - 1); + } + // Test if cursor position is outside map -> move inside + if (onMap && !mapRec.contains(pos)) { + pos.x = Math.min(pos.x, mapRec.width - 1); + pos.y = Math.min(pos.y, mapRec.height - 1); + mapGrid.setCursor(pos); + fireMapCursorChangedPosEvent(); + } + } + + /** + * Start a new transaction. Transactions may be nested. Transactions serve + * the purpose of firing events to the views when more changes are known to + * come before the view is really required to update. Each invocation of + * {@link #beginTransaction()} requires its own invocation of {@link + * #endTransaction()}. + */ + public void beginTransaction() { + mapGrid.beginTransaction(); + } + + /** + * End a transaction. Invoking this method will reduce the t... [truncated message content] |
From: <aki...@us...> - 2009-04-22 18:20:29
|
Revision: 6528 http://gridarta.svn.sourceforge.net/gridarta/?rev=6528&view=rev Author: akirschbaum Date: 2009-04-22 18:20:18 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Move InsertionMode to mapmodel package. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/GUIMainControl.java trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserTab.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/map/mapmodel/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/mapmodel/MapModel.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java trunk/src/test/net/sf/gridarta/map/mapmodel/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/map/mapmodel/InsertionMode.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/map/InsertionMode.java Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -27,8 +27,8 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.map.mapmodel.MapModelListener; import net.sf.gridarta.map.mapmodel.MapSquare; Modified: trunk/src/app/net/sf/gridarta/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -112,11 +112,11 @@ import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.ExitMatcher; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapcontrol.MapControlFactory; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.map.mapmodel.MapSquare; import net.sf.gridarta.map.normalizer.MapPathNormalizer; Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -28,9 +28,9 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.map.ExitMatcher; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.mapmanager.MapManager; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java =================================================================== --- trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/floodfill/Floodfill.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -23,8 +23,8 @@ import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.utils.RandomUtils; import net.sf.gridarta.utils.Size2D; Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -42,9 +42,9 @@ import net.sf.gridarta.gui.map.grid.MapGridListener; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.map.mapmodel.MapModelListener; import net.sf.gridarta.map.mapmodel.MapSquare; Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -45,9 +45,9 @@ import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.objectchooser.ObjectChooser; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.map.mapmodel.MapSquare; import net.sf.gridarta.utils.RandomUtils; Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -29,8 +29,8 @@ import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserControl.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -30,8 +30,8 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.objectchooser.ObjectChooserTab; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; Modified: trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/map/FillUtils.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -24,8 +24,8 @@ import net.sf.gridarta.floodfill.Floodfill; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.utils.RandomUtils; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -34,9 +34,9 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.undo.SwingUtils; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -34,8 +34,8 @@ import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.undo.SwingUtils; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ToggleAction; Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -31,8 +31,8 @@ import javax.swing.event.ChangeListener; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooser.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -23,8 +23,8 @@ import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserTab.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/ObjectChooserTab.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -24,8 +24,8 @@ import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -40,12 +40,12 @@ import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.ObjectChooserTab; import net.sf.gridarta.io.MapReaderFactory; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.map.mapcontrol.DefaultMapControl; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapcontrol.MapControlListener; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.map.mapmodel.MapModelListener; import net.sf.gridarta.map.mapmodel.MapSquare; Deleted: trunk/src/app/net/sf/gridarta/map/InsertionMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/InsertionMode.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/map/InsertionMode.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -1,244 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.map; - -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.map.maparchobject.MapArchObject; -import net.sf.gridarta.map.mapmodel.MapSquare; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Insertion modes. - * @todo make replacement of multi-part objects work - * @author Andreas Kirschbaum - */ -public enum InsertionMode { - - /** - * Automatically guess the insertion position. May replace rather than - * insert the object. - */ - AUTO { - - /** {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { - if (floorGameObjectMatcher != null && floorGameObjectMatcher.isMatching(gameObject)) { - replaceFloor(gameObject, mapSquare, mapSquare.getLast(floorGameObjectMatcher)); - } else if (wallGameObjectMatcher != null && wallGameObjectMatcher.isMatching(gameObject)) { - replaceWall(gameObject, mapSquare, mapSquare.getLast(wallGameObjectMatcher)); - } else if (belowFloorGameObjectMatcher != null && belowFloorGameObjectMatcher.isMatching(gameObject)) { - mapSquare.addFirst(gameObject); - } else { - mapSquare.addLast(gameObject); - } - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "auto"; - } - - }, - - /** - * Insert topmost. - */ - TOPMOST { - - /** {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { - mapSquare.addLast(gameObject); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "topmost"; - } - - }, - - /** - * Insert right above the topmost floor tile. Inserts bottommost if no - * floor tile exists. - */ - ABOVE_FLOOR { - - /** {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { - if (floorGameObjectMatcher == null) { - mapSquare.addFirst(gameObject); - return; - } - - final G lastFloor = mapSquare.getLast(floorGameObjectMatcher); - if (lastFloor == null) { - mapSquare.addFirst(gameObject); - return; - } - - mapSquare.insertBefore(gameObject, lastFloor); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "above floor"; - } - - }, - - /** - * Insert right below the bottommost floor tile. Inserts bottommost if no - * floor tile exists. - */ - BELOW_FLOOR { - - /** {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { - if (floorGameObjectMatcher == null) { - mapSquare.addFirst(gameObject); - return; - } - final G firstFloor = mapSquare.getFirst(floorGameObjectMatcher); - if (firstFloor == null) { - mapSquare.addFirst(gameObject); - return; - } - - mapSquare.insertAfter(firstFloor, gameObject); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "below floor"; - } - - }, - - /** - * Insert bottommost. - */ - BOTTOMMOST { - - /** {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { - mapSquare.addFirst(gameObject); - } - - /** {@inheritDoc} */ - @Override - public String toString() { - return "bottommost"; - } - - }; - - /** - * A {@link GameObjectMatcher} matching floor game objects. - */ - @Nullable - private static GameObjectMatcher floorGameObjectMatcher = null; - - /** - * A {@link GameObjectMatcher} matching wall game objects. - */ - @Nullable - private static GameObjectMatcher wallGameObjectMatcher = null; - - /** - * A {@link GameObjectMatcher} matching monster game objects. - */ - @Nullable - private static GameObjectMatcher belowFloorGameObjectMatcher = null; - - /** - * Initializes the class. - * @param floorGameObjectMatcher the floor matcher to use - * @param wallGameObjectMatcher the wall matcher to use - * @param belowFloorGameObjectMatcher the game object to insert below the - * floor - */ - public static void init(@Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher belowFloorGameObjectMatcher) { - InsertionMode.floorGameObjectMatcher = floorGameObjectMatcher; - InsertionMode.wallGameObjectMatcher = wallGameObjectMatcher; - InsertionMode.belowFloorGameObjectMatcher = belowFloorGameObjectMatcher; - } - - /** - * Inserts a {@link GameObject} into a {@link MapSquare}. - * @param gameObject the game object to insert - * @param mapSquare the map square to modify - */ - public abstract <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare); - - /** - * Replace a floor game object. - * @param gameObject the game object to insert with - * @param mapSquare the map square to modify - * @param lastFloor the last floor game object within - * <code>mapSquare</code> - */ - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void replaceFloor(final G gameObject, final MapSquare<G, A, R> mapSquare, final G lastFloor) { - // floor exists ==> replace it - if (lastFloor != null && !lastFloor.isMulti()) { - mapSquare.replace(lastFloor, gameObject); - return; - } - - // "below floor" objects exist ==> insert afterwards - if (belowFloorGameObjectMatcher != null) { - final G lastBelowFloor = mapSquare.getLastOfLeadingSpan(belowFloorGameObjectMatcher); - if (lastBelowFloor != null) { - mapSquare.insertAfter(lastBelowFloor, gameObject); - return; - } - } - - // fallback ==> insert bottommost - mapSquare.addFirst(gameObject); - } - - /** - * Replace a wall game object. - * @param gameObject the game object to insert with - * @param mapSquare the map square to modify - * @param lastWall the last wall game object within - * <code>mapSquare</code> - */ - private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void replaceWall(final G gameObject, final MapSquare<G, A, R> mapSquare, final G lastWall) { - if (lastWall != null && !lastWall.isMulti()) { - mapSquare.replace(lastWall, gameObject); - } else { - mapSquare.addLast(gameObject); - } - } - -} // enum InsertionMode Modified: trunk/src/app/net/sf/gridarta/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/mapmodel/DefaultMapModel.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/map/mapmodel/DefaultMapModel.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -35,7 +35,6 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.maparchobject.MapArchObjectListener; import net.sf.gridarta.map.validation.DefaultErrorCollector; Copied: trunk/src/app/net/sf/gridarta/map/mapmodel/InsertionMode.java (from rev 6526, trunk/src/app/net/sf/gridarta/map/InsertionMode.java) =================================================================== --- trunk/src/app/net/sf/gridarta/map/mapmodel/InsertionMode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/mapmodel/InsertionMode.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -0,0 +1,243 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.map.mapmodel; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.map.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Insertion modes. + * @todo make replacement of multi-part objects work + * @author Andreas Kirschbaum + */ +public enum InsertionMode { + + /** + * Automatically guess the insertion position. May replace rather than + * insert the object. + */ + AUTO { + + /** {@inheritDoc} */ + @Override + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { + if (floorGameObjectMatcher != null && floorGameObjectMatcher.isMatching(gameObject)) { + replaceFloor(gameObject, mapSquare, mapSquare.getLast(floorGameObjectMatcher)); + } else if (wallGameObjectMatcher != null && wallGameObjectMatcher.isMatching(gameObject)) { + replaceWall(gameObject, mapSquare, mapSquare.getLast(wallGameObjectMatcher)); + } else if (belowFloorGameObjectMatcher != null && belowFloorGameObjectMatcher.isMatching(gameObject)) { + mapSquare.addFirst(gameObject); + } else { + mapSquare.addLast(gameObject); + } + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "auto"; + } + + }, + + /** + * Insert topmost. + */ + TOPMOST { + + /** {@inheritDoc} */ + @Override + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { + mapSquare.addLast(gameObject); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "topmost"; + } + + }, + + /** + * Insert right above the topmost floor tile. Inserts bottommost if no + * floor tile exists. + */ + ABOVE_FLOOR { + + /** {@inheritDoc} */ + @Override + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { + if (floorGameObjectMatcher == null) { + mapSquare.addFirst(gameObject); + return; + } + + final G lastFloor = mapSquare.getLast(floorGameObjectMatcher); + if (lastFloor == null) { + mapSquare.addFirst(gameObject); + return; + } + + mapSquare.insertBefore(gameObject, lastFloor); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "above floor"; + } + + }, + + /** + * Insert right below the bottommost floor tile. Inserts bottommost if no + * floor tile exists. + */ + BELOW_FLOOR { + + /** {@inheritDoc} */ + @Override + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { + if (floorGameObjectMatcher == null) { + mapSquare.addFirst(gameObject); + return; + } + final G firstFloor = mapSquare.getFirst(floorGameObjectMatcher); + if (firstFloor == null) { + mapSquare.addFirst(gameObject); + return; + } + + mapSquare.insertAfter(firstFloor, gameObject); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "below floor"; + } + + }, + + /** + * Insert bottommost. + */ + BOTTOMMOST { + + /** {@inheritDoc} */ + @Override + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare) { + mapSquare.addFirst(gameObject); + } + + /** {@inheritDoc} */ + @Override + public String toString() { + return "bottommost"; + } + + }; + + /** + * A {@link GameObjectMatcher} matching floor game objects. + */ + @Nullable + private static GameObjectMatcher floorGameObjectMatcher = null; + + /** + * A {@link GameObjectMatcher} matching wall game objects. + */ + @Nullable + private static GameObjectMatcher wallGameObjectMatcher = null; + + /** + * A {@link GameObjectMatcher} matching monster game objects. + */ + @Nullable + private static GameObjectMatcher belowFloorGameObjectMatcher = null; + + /** + * Initializes the class. + * @param floorGameObjectMatcher the floor matcher to use + * @param wallGameObjectMatcher the wall matcher to use + * @param belowFloorGameObjectMatcher the game object to insert below the + * floor + */ + public static void init(@Nullable final GameObjectMatcher floorGameObjectMatcher, @Nullable final GameObjectMatcher wallGameObjectMatcher, @Nullable final GameObjectMatcher belowFloorGameObjectMatcher) { + InsertionMode.floorGameObjectMatcher = floorGameObjectMatcher; + InsertionMode.wallGameObjectMatcher = wallGameObjectMatcher; + InsertionMode.belowFloorGameObjectMatcher = belowFloorGameObjectMatcher; + } + + /** + * Inserts a {@link GameObject} into a {@link MapSquare}. + * @param gameObject the game object to insert + * @param mapSquare the map square to modify + */ + public abstract <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void insert(@NotNull final G gameObject, @NotNull final MapSquare<G, A, R> mapSquare); + + /** + * Replace a floor game object. + * @param gameObject the game object to insert with + * @param mapSquare the map square to modify + * @param lastFloor the last floor game object within + * <code>mapSquare</code> + */ + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void replaceFloor(final G gameObject, final MapSquare<G, A, R> mapSquare, final G lastFloor) { + // floor exists ==> replace it + if (lastFloor != null && !lastFloor.isMulti()) { + mapSquare.replace(lastFloor, gameObject); + return; + } + + // "below floor" objects exist ==> insert afterwards + if (belowFloorGameObjectMatcher != null) { + final G lastBelowFloor = mapSquare.getLastOfLeadingSpan(belowFloorGameObjectMatcher); + if (lastBelowFloor != null) { + mapSquare.insertAfter(lastBelowFloor, gameObject); + return; + } + } + + // fallback ==> insert bottommost + mapSquare.addFirst(gameObject); + } + + /** + * Replace a wall game object. + * @param gameObject the game object to insert with + * @param mapSquare the map square to modify + * @param lastWall the last wall game object within + * <code>mapSquare</code> + */ + private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void replaceWall(final G gameObject, final MapSquare<G, A, R> mapSquare, final G lastWall) { + if (lastWall != null && !lastWall.isMulti()) { + mapSquare.replace(lastWall, gameObject); + } else { + mapSquare.addLast(gameObject); + } + } + +} // enum InsertionMode Property changes on: trunk/src/app/net/sf/gridarta/map/mapmodel/InsertionMode.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/mapmodel/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/mapmodel/MapModel.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/app/net/sf/gridarta/map/mapmodel/MapModel.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -26,7 +26,6 @@ import net.sf.gridarta.autojoin.AutojoinList; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.utils.Size2D; Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -47,11 +47,11 @@ import net.sf.gridarta.io.TestMapReaderFactory; import net.sf.gridarta.io.TestMapWriter; import net.sf.gridarta.map.ExitMatcher; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.TestMapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapcontrol.MapControlFactory; import net.sf.gridarta.map.mapcontrol.TestMapControlFactory; +import net.sf.gridarta.map.mapmodel.InsertionMode; import net.sf.gridarta.map.mapmodel.MapModel; import net.sf.gridarta.mapmanager.AbstractMapManager; import net.sf.gridarta.mapmanager.DefaultMapManager; Modified: trunk/src/test/net/sf/gridarta/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/mapmodel/DefaultMapModelTest.java 2009-04-22 18:17:23 UTC (rev 6527) +++ trunk/src/test/net/sf/gridarta/map/mapmodel/DefaultMapModelTest.java 2009-04-22 18:20:18 UTC (rev 6528) @@ -33,7 +33,6 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.gui.utils.GUIUtils; -import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.maparchobject.TestMapArchObject; import net.sf.gridarta.map.validation.ErrorCollector; import net.sf.gridarta.utils.Size2D; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-22 18:26:42
|
Revision: 6530 http://gridarta.svn.sourceforge.net/gridarta/?rev=6530&view=rev Author: akirschbaum Date: 2009-04-22 18:26:32 +0000 (Wed, 22 Apr 2009) Log Message: ----------- Move ExitMatcher to exitconnector package. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/GUIMainControl.java trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/exitconnector/ExitMatcher.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/map/ExitMatcher.java Modified: trunk/src/app/net/sf/gridarta/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 18:20:50 UTC (rev 6529) +++ trunk/src/app/net/sf/gridarta/GUIMainControl.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -44,6 +44,7 @@ import net.sf.gridarta.exitconnector.ExitConnectorActions; import net.sf.gridarta.exitconnector.ExitConnectorController; import net.sf.gridarta.exitconnector.ExitConnectorModel; +import net.sf.gridarta.exitconnector.ExitMatcher; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.filter.NamedFilterList; import net.sf.gridarta.gameobject.AnimationValidator; @@ -111,7 +112,6 @@ import net.sf.gridarta.help.Help; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReaderFactory; -import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.map.mapcontrol.MapControl; Modified: trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 18:20:50 UTC (rev 6529) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitConnectorActions.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -27,7 +27,6 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.cursor.MapCursor; -import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapmodel.InsertionMode; Copied: trunk/src/app/net/sf/gridarta/exitconnector/ExitMatcher.java (from rev 6525, trunk/src/app/net/sf/gridarta/map/ExitMatcher.java) =================================================================== --- trunk/src/app/net/sf/gridarta/exitconnector/ExitMatcher.java (rev 0) +++ trunk/src/app/net/sf/gridarta/exitconnector/ExitMatcher.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -0,0 +1,130 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.exitconnector; + +import java.awt.Point; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gameobject.match.GameObjectMatcher; +import net.sf.gridarta.map.maparchobject.MapArchObject; +import net.sf.gridarta.map.mapmodel.MapModel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Selects valid exit game objects from maps. + * @author Andreas Kirschbaum + */ +public class ExitMatcher<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The matcher for selecting exit objects. + */ + @NotNull + private final GameObjectMatcher exitMatcher; + + /** + * Creates a new instance. + * @param exitMatcher the matcher for selecting exit objects + */ + public ExitMatcher(@NotNull final GameObjectMatcher exitMatcher) { + this.exitMatcher = exitMatcher; + } + + /** + * Returns an exit game object on a given map tile having exit information. + * @param mapModel the map model to check + * @param point the map tile to check + * @return the head of the exit game object or <code>null</code> if none + * was found + */ + @Nullable + public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { + if (point == null || !mapModel.isPointValid(point)) { + return null; + } + for (final G part : mapModel.getMapSquare(point)) { + final G head = part.getHead(); + if (exitMatcher.isMatching(head) && head.getAttributeString("slaying").length() > 0) { + return head; + } + } + return null; + } + + /** + * Returns whether the given game object is an exit game object having exit + * information. + * @param exit the game object to check + * @return the game object's head if it is an exit game object or else + * <code>null</code> + */ + @Nullable + public G getValidExit(@Nullable final G exit) { + if (exit == null) { + return null; + } + final G head = exit.getHead(); + if (!exitMatcher.isMatching(head) || head.getAttributeString("slaying").length() <= 0) { + return null; + } + return head; + } + + /** + * Returns an exit game object on a given map tile. + * @param mapModel the map model to check + * @param point the map tile to check + * @return the head of the exit game object or <code>null</code> if none + * was found + */ + @Nullable + public G getExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { + if (point == null || !mapModel.isPointValid(point)) { + return null; + } + for (final G part : mapModel.getMapSquare(point)) { + final G head = part.getHead(); + if (exitMatcher.isMatching(head)) { + return head; + } + } + return null; + } + + /** + * Returns whether the given game object is an exit game object. + * @param exit the game object to check + * @return the game object's head if it is an exit game object or else + * <code>null</code> + */ + @Nullable + public G getExit(@Nullable final G exit) { + if (exit == null) { + return null; + } + final G head = exit.getHead(); + if (!exitMatcher.isMatching(head)) { + return null; + } + return head; + } + +} // class ExitMatcher Property changes on: trunk/src/app/net/sf/gridarta/exitconnector/ExitMatcher.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java 2009-04-22 18:20:50 UTC (rev 6529) +++ trunk/src/app/net/sf/gridarta/gui/map/DefaultMapActions.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -30,6 +30,7 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.filechooser.FileFilter; +import net.sf.gridarta.exitconnector.ExitMatcher; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.MapViewManager; @@ -42,7 +43,6 @@ import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.shrinkmapsizedialog.ShrinkMapSizeDialogManager; -import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.maparchobject.MapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapmodel.MapModel; Deleted: trunk/src/app/net/sf/gridarta/map/ExitMatcher.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/ExitMatcher.java 2009-04-22 18:20:50 UTC (rev 6529) +++ trunk/src/app/net/sf/gridarta/map/ExitMatcher.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -1,130 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.map; - -import java.awt.Point; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.match.GameObjectMatcher; -import net.sf.gridarta.map.maparchobject.MapArchObject; -import net.sf.gridarta.map.mapmodel.MapModel; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Selects valid exit game objects from maps. - * @author Andreas Kirschbaum - */ -public class ExitMatcher<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * The matcher for selecting exit objects. - */ - @NotNull - private final GameObjectMatcher exitMatcher; - - /** - * Creates a new instance. - * @param exitMatcher the matcher for selecting exit objects - */ - public ExitMatcher(@NotNull final GameObjectMatcher exitMatcher) { - this.exitMatcher = exitMatcher; - } - - /** - * Returns an exit game object on a given map tile having exit information. - * @param mapModel the map model to check - * @param point the map tile to check - * @return the head of the exit game object or <code>null</code> if none - * was found - */ - @Nullable - public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { - return null; - } - for (final G part : mapModel.getMapSquare(point)) { - final G head = part.getHead(); - if (exitMatcher.isMatching(head) && head.getAttributeString("slaying").length() > 0) { - return head; - } - } - return null; - } - - /** - * Returns whether the given game object is an exit game object having exit - * information. - * @param exit the game object to check - * @return the game object's head if it is an exit game object or else - * <code>null</code> - */ - @Nullable - public G getValidExit(@Nullable final G exit) { - if (exit == null) { - return null; - } - final G head = exit.getHead(); - if (!exitMatcher.isMatching(head) || head.getAttributeString("slaying").length() <= 0) { - return null; - } - return head; - } - - /** - * Returns an exit game object on a given map tile. - * @param mapModel the map model to check - * @param point the map tile to check - * @return the head of the exit game object or <code>null</code> if none - * was found - */ - @Nullable - public G getExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { - return null; - } - for (final G part : mapModel.getMapSquare(point)) { - final G head = part.getHead(); - if (exitMatcher.isMatching(head)) { - return head; - } - } - return null; - } - - /** - * Returns whether the given game object is an exit game object. - * @param exit the game object to check - * @return the game object's head if it is an exit game object or else - * <code>null</code> - */ - @Nullable - public G getExit(@Nullable final G exit) { - if (exit == null) { - return null; - } - final G head = exit.getHead(); - if (!exitMatcher.isMatching(head)) { - return null; - } - return head; - } - -} // class ExitMatcher Modified: trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-22 18:20:50 UTC (rev 6529) +++ trunk/src/test/net/sf/gridarta/exitconnector/ExitConnectorActionsTest.java 2009-04-22 18:26:32 UTC (rev 6530) @@ -46,7 +46,6 @@ import net.sf.gridarta.io.PathManager; import net.sf.gridarta.io.TestMapReaderFactory; import net.sf.gridarta.io.TestMapWriter; -import net.sf.gridarta.map.ExitMatcher; import net.sf.gridarta.map.maparchobject.TestMapArchObject; import net.sf.gridarta.map.mapcontrol.MapControl; import net.sf.gridarta.map.mapcontrol.MapControlFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2009-04-26 18:39:02
|
Revision: 6558 http://gridarta.svn.sourceforge.net/gridarta/?rev=6558&view=rev Author: akirschbaum Date: 2009-04-26 18:38:52 +0000 (Sun, 26 Apr 2009) Log Message: ----------- Remove dependency MapFileActions -> MainView. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2009-04-26 18:29:59 UTC (rev 6557) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2009-04-26 18:38:52 UTC (rev 6558) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.map; -import java.awt.Component; import java.io.File; import java.io.IOException; import java.util.Set; @@ -63,10 +62,6 @@ @NotNull private FileControl<G, A, R> fileControl; - /** The parent component for dialog windows. */ - @NotNull - private final Component parent; - /** The map manager. */ @NotNull private final MapManager<G, A, R> mapManager; @@ -210,13 +205,11 @@ /** * Create a new instance that tracks the map state. * @param guiMainControl the GUI main control to forward actions - * @param parent the parent component for dialog windows * @param mapManager the map manager * @param mapViewManager the map view manager */ - public MapFileActions(@NotNull final GUIMainControl<G, A, R> guiMainControl, @NotNull final Component parent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager) { + public MapFileActions(@NotNull final GUIMainControl<G, A, R> guiMainControl, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager) { this.guiMainControl = guiMainControl; - this.parent = parent; this.mapManager = mapManager; mapManager.addMapManagerListener(mapManagerListener); currentMapControl = mapManager.getCurrentMapControl(); @@ -313,7 +306,7 @@ try { mapManager.save(mapControl); } catch (final IOException e) { - ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapControl.getMapModel().getMapFile(), e.getMessage()); + fileControl.reportSaveError(mapControl.getMapModel().getMapFile(), e.getMessage()); } } } @@ -333,7 +326,7 @@ try { mapControl.saveAs(file); } catch (final IOException e) { - ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapControl.getMapModel().getMapFile(), e.getMessage()); + fileControl.reportSaveError(mapControl.getMapModel().getMapFile(), e.getMessage()); } } @@ -354,7 +347,7 @@ if (mapControl == null) { return; } - if (!ACTION_BUILDER.showQuestionDialog(parent, "confirmRevertMap", mapControl.getMapModel().getMapFileName())) { + if (!fileControl.confirmRevertMap(mapControl.getMapModel().getMapFileName())) { return; } Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2009-04-26 18:29:59 UTC (rev 6557) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2009-04-26 18:38:52 UTC (rev 6558) @@ -323,12 +323,12 @@ final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(statusBar, mapManager, mapImageCacheDir, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), rendererFactory); final MapPreviewAccessory mapPreviewAccessory = new MapPreviewAccessory(mapImageCache); final MapDesktop<G, A, R> mapDesktop = new MapDesktop<G, A, R>(mapViewManager, mapManager, mapImageCache); - mainView = new MainView<G, A, R>(exitAction, statusBar, getBuildNumberAsString(), mapDesktop); final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, mapManager); final MapManagerActions<G, A, R> mapManagerActions = new MapManagerActions<G, A, R>(mapManager); final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(globalSettings.getPickmapDir()); final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings); - final MapFileActions<G, A, R> mapFileActions = new MapFileActions<G, A, R>(this, mainView, mapManager, mapViewManager); + mainView = new MainView<G, A, R>(exitAction, statusBar, getBuildNumberAsString(), mapDesktop); + final MapFileActions<G, A, R> mapFileActions = new MapFileActions<G, A, R>(this, mapManager, mapViewManager); newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapManager, mapArchObjectFactory, mainView); final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); Modified: trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-26 18:29:59 UTC (rev 6557) +++ trunk/src/app/net/sf/gridarta/mapmanager/DefaultFileControl.java 2009-04-26 18:38:52 UTC (rev 6558) @@ -219,6 +219,12 @@ /** {@inheritDoc} */ @Override + public boolean confirmRevertMap(@NotNull final String mapName) { + return ACTION_BUILDER.showQuestionDialog(parent, "confirmRevertMap", mapName); + } + + /** {@inheritDoc} */ + @Override public void reportSaveError(@NotNull final File mapFile, @NotNull final String message) { ACTION_BUILDER.showMessageDialog(parent, "encodeMapFile", mapFile, message); } Modified: trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-26 18:29:59 UTC (rev 6557) +++ trunk/src/app/net/sf/gridarta/mapmanager/FileControl.java 2009-04-26 18:38:52 UTC (rev 6558) @@ -47,6 +47,13 @@ int confirmSaveChanges(@NotNull String mapName); + /** + * Asks the user whether reverting the map is ok. + * @param mapName the map name + * @return whether reverting is ok + */ + boolean confirmRevertMap(@NotNull String mapName); + void reportSaveError(@NotNull File mapFile, @NotNull String message); void reportLoadError(@NotNull File file, @NotNull String message); Modified: trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-26 18:29:59 UTC (rev 6557) +++ trunk/src/test/net/sf/gridarta/mapmanager/TestFileControl.java 2009-04-26 18:38:52 UTC (rev 6558) @@ -58,6 +58,12 @@ /** {@inheritDoc} */ @Override + public boolean confirmRevertMap(@NotNull final String mapName) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @Override public void reportSaveError(@NotNull final File mapFile, @NotNull final String message) { sb.append("reportSaveError: "); sb.append(mapFile); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |