From: <aki...@us...> - 2010-06-06 23:44:40
|
Revision: 8254 http://gridarta.svn.sourceforge.net/gridarta/?rev=8254&view=rev Author: akirschbaum Date: 2010-06-06 23:44:34 +0000 (Sun, 06 Jun 2010) Log Message: ----------- Add final modifiers. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java trunk/src/app/net/sf/gridarta/gui/map/viewaction/ViewAction.java trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/utils/DirectionComponent.java trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java trunk/src/app/net/sf/gridarta/textedit/textarea/TextAreaPainter.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/scripts/DefaultScriptedEvent.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -196,7 +196,7 @@ * {@inheritDoc} */ @Override - protected void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { + protected final void setEventData(@NotNull final String pluginName, @NotNull final String scriptPath, @NotNull final String options) { final int eventType = getEventType(); event.setObjectText(""); event.setAttributeString(subtypeAttribute, Integer.toString(eventType)); Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -281,7 +281,7 @@ * Selects an archetype panel. Does nothing if the panel does not exist. * @param selectedPanel the archetype panel to show */ - public void setSelectedPanel(@NotNull final ArchetypePanel<G, A, R> selectedPanel) { + public final void setSelectedPanel(@NotNull final ArchetypePanel<G, A, R> selectedPanel) { final int selectedIndex = tabDesktop.indexOfComponent(selectedPanel); if (selectedIndex == -1 || selectedIndex == tabDesktop.getSelectedIndex()) { return; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -1021,7 +1021,7 @@ * return null. */ @Nullable - Component buildAttribute() { + private Component buildAttribute() { boolean initialCall = false; if (tabbedPane == null) { Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -281,7 +281,7 @@ /** * Cursor gets deactivated. All selections get lost. */ - public void deactivate() { + public final void deactivate() { final boolean hasChanged = onMap; mapGrid.beginTransaction(); try { Modified: trunk/src/app/net/sf/gridarta/gui/map/viewaction/ViewAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/viewaction/ViewAction.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/map/viewaction/ViewAction.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -95,7 +95,7 @@ /** * Update the action's state to match the current edit type settings. */ - public void updateAction() { + public final void updateAction() { checkBoxMenuItem.setSelected(mapViewSettings.isEditType(editType)); } Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -177,7 +177,7 @@ * Accelerator to use. * @param index index (with 1 for first entry) */ - public void setIndex(final int index) { + public final void setIndex(final int index) { this.index = index; if (0 <= index && index <= 10) { putValue(MNEMONIC_KEY, KeyStroke.getKeyStroke(Integer.toString(index % 10)).getKeyCode()); Modified: trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -286,7 +286,7 @@ * {@inheritDoc} */ @Override - public boolean isPickmapActive() { + public final boolean isPickmapActive() { return activeTab == pickmapChooserControl; } @@ -346,7 +346,7 @@ */ @Nullable @Override - public BaseObject<G, A, R, ?> getSelection() { + public final BaseObject<G, A, R, ?> getSelection() { return activeTab == null ? null : activeTab.getSelection(); } Modified: trunk/src/app/net/sf/gridarta/gui/utils/DirectionComponent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/DirectionComponent.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/gui/utils/DirectionComponent.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -118,7 +118,7 @@ * Enables/disables the direction buttons for a given archetype. * @param enableButtons whether the buttons are enabled */ - protected void updateEnabled(final boolean enableButtons) { + protected final void updateEnabled(final boolean enableButtons) { this.enableButtons = enableButtons; updateEnabled(); } @@ -127,7 +127,7 @@ * Sets the selected direction. * @param direction the direction */ - public void updateDirection(@Nullable final Integer direction) { + public final void updateDirection(@Nullable final Integer direction) { final AbstractButton selectedButton = directions.get(direction); if (selectedButton != null) { selectedButton.setSelected(true); Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/JEditTextArea.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -735,7 +735,7 @@ * Sets the document this text area is editing. * @param document the document */ - public void setDocument(@Nullable final SyntaxDocument document) { + public final void setDocument(@Nullable final SyntaxDocument document) { if (this.document == document) { return; } Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/TextAreaPainter.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/TextAreaPainter.java 2010-06-06 23:40:46 UTC (rev 8253) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/TextAreaPainter.java 2010-06-06 23:44:34 UTC (rev 8254) @@ -324,7 +324,7 @@ * {@inheritDoc} */ @Override - public void setFont(@NotNull final Font font) { + public final void setFont(@NotNull final Font font) { super.setFont(font); fontMetrics = getFontMetrics(font); textArea.recalculateVisibleLines(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-07 18:53:10
|
Revision: 8263 http://gridarta.svn.sourceforge.net/gridarta/?rev=8263&view=rev Author: akirschbaum Date: 2010-06-07 18:53:04 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Retain settings (except for view filters) of "View" menu across editor restarts. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java trunk/src/app/net/sf/gridarta/model/mapviewsettings/DefaultMapViewSettings.java trunk/src/test/net/sf/gridarta/model/mapviewsettings/TestMapViewSettings.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/atrinik/ChangeLog 2010-06-07 18:53:04 UTC (rev 8263) @@ -1,3 +1,7 @@ +2010-06-07 Andreas Kirschbaum + + * Retain settings (except for view filters) of "View" menu across editor restarts. + 2010-06-06 Andreas Kirschbaum * Drop recent menu entries for maps with non-existent map files. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/crossfire/ChangeLog 2010-06-07 18:53:04 UTC (rev 8263) @@ -1,3 +1,7 @@ +2010-06-07 Andreas Kirschbaum + + * Retain settings (except for view filters) of "View" menu across editor restarts. + 2010-06-06 Andreas Kirschbaum * Drop recent menu entries for maps with non-existent map files. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/daimonin/ChangeLog 2010-06-07 18:53:04 UTC (rev 8263) @@ -1,3 +1,7 @@ +2010-06-07 Andreas Kirschbaum + + * Retain settings (except for view filters) of "View" menu across editor restarts. + 2010-06-06 Andreas Kirschbaum * Drop recent menu entries for maps with non-existent map files. Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/src/app/net/sf/gridarta/messages.properties 2010-06-07 18:53:04 UTC (rev 8263) @@ -1099,7 +1099,6 @@ prefs.archDirectory=Archetype directory. prefs.archetypeChooserDisplayMode=The display mode of the archetype chooser: 0=game object names, 1=archetype names, 2=icons only. prefs.autoGeneratePreviews=If set, automatically generate map preview images. -prefs.autojoin=Whether autojoining is enabled. prefs.autoValidate=Whether the map validator is run automatically after each change. prefs.bookmarkFilename=Bookmark filename. prefs.bookmarkNum=Number of used bookmark entries. @@ -1123,6 +1122,11 @@ prefs.mapDirectory=Maps directory. prefs.MapSquareBottom=true=display Game Object Attribute Dialog at bottom, false=display at right side. prefs.MapValidator.All=Whether the map validator is enabled. +prefs.mapViewSettings.gridVisible=Whether the map grid is visible. +prefs.mapViewSettings.smoothing=Whether smoothing is active. +prefs.mapViewSettings.doubleFaces=Whether double faces are shown. +prefs.mapViewSettings.alphaType=The settings for alpha faces. +prefs.mapViewSettings.autojoin=Whether autojoining is enabled. prefs.NewMapDialog.difficulty=Last selected map difficulty in New Map Dialog. prefs.NewMapDialog.mapHeight=Last selected map width in New Map Dialog. prefs.NewMapDialog.mapWidth=Last selected map height in New Map Dialog. Modified: trunk/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/src/app/net/sf/gridarta/model/mapviewsettings/AbstractMapViewSettings.java 2010-06-07 18:53:04 UTC (rev 8263) @@ -35,27 +35,27 @@ /** * The visibility of the grid. */ - private boolean gridVisible = false; + private boolean gridVisible = loadGridVisible(); /** * Whether smoothing display is active. */ - private boolean smoothing = false; + private boolean smoothing = loadSmoothing(); /** * Whether double faces should be drawn double height. */ - private boolean doubleFaces = false; + private boolean doubleFaces = loadDoubleFaces(); /** * Bit field of edit types to show transparent. */ - private int alphaType = 0; + private int alphaType = loadAlphaType(); /** * Bit field of edit types to show only. */ - private int editType = 0; + private int editType = loadEditType(); /** * Whether autojoining is on/off. @@ -120,6 +120,7 @@ } this.gridVisible = gridVisible; + saveGridVisible(gridVisible); fireGridVisibleChanged(); } @@ -143,6 +144,7 @@ } this.smoothing = smoothing; + saveSmoothing(smoothing); fireSmoothingChanged(); } @@ -167,6 +169,7 @@ } this.doubleFaces = doubleFaces; + saveDoubleFaces(doubleFaces); fireDoubleFacesChanged(); } @@ -194,6 +197,7 @@ } else { alphaType &= ~v; } + saveAlphaType(alphaType); fireAlphaTypeChanged(); } @@ -203,6 +207,7 @@ @Override public void clearAlpha() { alphaType = 0; + saveAlphaType(alphaType); fireAlphaTypeChanged(); } @@ -226,6 +231,7 @@ } this.editType |= editType; + saveEditType(this.editType); fireEditTypeChanged(); } @@ -241,6 +247,7 @@ } this.editType &= ~editType; + saveEditType(this.editType); fireEditTypeChanged(); } @@ -371,6 +378,66 @@ } /** + * Loads the default value for {@link #gridVisible}. + * @return the default value + */ + protected abstract boolean loadGridVisible(); + + /** + * Saves the {@link #gridVisible} value. + * @param gridVisible the grid visible value + */ + protected abstract void saveGridVisible(final boolean gridVisible); + + /** + * Loads the default value for {@link #smoothing}. + * @return the default value + */ + protected abstract boolean loadSmoothing(); + + /** + * Saves the {@link #smoothing} value. + * @param smoothing the smoothing value + */ + protected abstract void saveSmoothing(final boolean smoothing); + + /** + * Loads the default value for {@link #doubleFaces}. + * @return the default value + */ + protected abstract boolean loadDoubleFaces(); + + /** + * Saves the {@link #doubleFaces} value. + * @param doubleFaces the double faces value + */ + protected abstract void saveDoubleFaces(final boolean doubleFaces); + + /** + * Loads the default value for {@link #alphaType}. + * @return the default value + */ + protected abstract int loadAlphaType(); + + /** + * Saves the {@link #alphaType} value. + * @param alphaType the alpha type value + */ + protected abstract void saveAlphaType(final int alphaType); + + /** + * Loads the default value for {@link #editType}. + * @return the default value + */ + protected abstract int loadEditType(); + + /** + * Saves the {@link #editType} }value. + * @param editType the edit type value + */ + protected abstract void saveEditType(final int editType); + + /** * Loads the default value for {@link #autojoin}. * @return the default value */ Modified: trunk/src/app/net/sf/gridarta/model/mapviewsettings/DefaultMapViewSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/mapviewsettings/DefaultMapViewSettings.java 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/src/app/net/sf/gridarta/model/mapviewsettings/DefaultMapViewSettings.java 2010-06-07 18:53:04 UTC (rev 8263) @@ -32,10 +32,34 @@ public class DefaultMapViewSettings extends AbstractMapViewSettings { /** + * Key for saving {@link #gridVisible} state in preferences. + */ + @NotNull + private static final String GRID_VISIBLE_KEY = "mapViewSettings.gridVisible"; + + /** + * Key for saving {@link #smoothing} state in preferences. + */ + @NotNull + private static final String SMOOTHING_KEY = "mapViewSettings.smoothing"; + + /** + * Key for saving {@link #doubleFaces} state in preferences. + */ + @NotNull + private static final String DOUBLE_FACES_KEY = "mapViewSettings.doubleFaces"; + + /** + * Key for saving {@link #alphaType} state in preferences. + */ + @NotNull + private static final String ALPHA_TYPE_KEY = "mapViewSettings.alphaType"; + + /** * Key for saving {@link #autojoin} state in preferences. */ @NotNull - private static final String AUTOJOIN_KEY = "autojoin"; + private static final String AUTOJOIN_KEY = "mapViewSettings.autojoin"; /** * Preferences. @@ -47,6 +71,86 @@ * {@inheritDoc} */ @Override + protected boolean loadGridVisible() { + return preferences.getBoolean(GRID_VISIBLE_KEY, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveGridVisible(final boolean gridVisible) { + preferences.putBoolean(GRID_VISIBLE_KEY, gridVisible); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadSmoothing() { + return preferences.getBoolean(SMOOTHING_KEY, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveSmoothing(final boolean smoothing) { + preferences.putBoolean(SMOOTHING_KEY, smoothing); + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadDoubleFaces() { + return preferences.getBoolean(DOUBLE_FACES_KEY, false); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveDoubleFaces(final boolean doubleFaces) { + preferences.putBoolean(DOUBLE_FACES_KEY, doubleFaces); + } + + /** + * {@inheritDoc} + */ + @Override + protected int loadAlphaType() { + return preferences.getInt(ALPHA_TYPE_KEY, 0); + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveAlphaType(final int alphaType) { + preferences.putInt(ALPHA_TYPE_KEY, alphaType); + } + + /** + * {@inheritDoc} + */ + @Override + protected int loadEditType() { + return 0; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveEditType(final int editType) { + // ignore: retaining edit types would be confusing for the user + } + + /** + * {@inheritDoc} + */ + @Override protected boolean loadAutojoin() { return preferences.getBoolean(AUTOJOIN_KEY, false); } Modified: trunk/src/test/net/sf/gridarta/model/mapviewsettings/TestMapViewSettings.java =================================================================== --- trunk/src/test/net/sf/gridarta/model/mapviewsettings/TestMapViewSettings.java 2010-06-07 18:30:34 UTC (rev 8262) +++ trunk/src/test/net/sf/gridarta/model/mapviewsettings/TestMapViewSettings.java 2010-06-07 18:53:04 UTC (rev 8263) @@ -30,6 +30,86 @@ * {@inheritDoc} */ @Override + protected boolean loadGridVisible() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveGridVisible(final boolean gridVisible) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadSmoothing() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveSmoothing(final boolean smoothing) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + protected boolean loadDoubleFaces() { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveDoubleFaces(final boolean doubleFaces) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + protected int loadAlphaType() { + return 0; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveAlphaType(final int alphaType) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override + protected int loadEditType() { + return 0; + } + + /** + * {@inheritDoc} + */ + @Override + protected void saveEditType(final int editType) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override protected boolean loadAutojoin() { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-07 19:38:22
|
Revision: 8266 http://gridarta.svn.sourceforge.net/gridarta/?rev=8266&view=rev Author: akirschbaum Date: 2010-06-07 19:38:16 +0000 (Mon, 07 Jun 2010) Log Message: ----------- Remove tooltips from archetype chooser. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/utils/ArchetypeToolTipProvider.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-07 19:06:57 UTC (rev 8265) +++ trunk/atrinik/ChangeLog 2010-06-07 19:38:16 UTC (rev 8266) @@ -1,5 +1,7 @@ 2010-06-07 Andreas Kirschbaum + * Remove tooltips from archetype chooser. + * Retain settings (except for view filters) of "View" menu across editor restarts. 2010-06-06 Andreas Kirschbaum Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-07 19:06:57 UTC (rev 8265) +++ trunk/crossfire/ChangeLog 2010-06-07 19:38:16 UTC (rev 8266) @@ -1,5 +1,7 @@ 2010-06-07 Andreas Kirschbaum + * Remove tooltips from archetype chooser. + * Retain settings (except for view filters) of "View" menu across editor restarts. 2010-06-06 Andreas Kirschbaum Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-07 19:06:57 UTC (rev 8265) +++ trunk/daimonin/ChangeLog 2010-06-07 19:38:16 UTC (rev 8266) @@ -1,5 +1,7 @@ 2010-06-07 Andreas Kirschbaum + * Remove tooltips from archetype chooser. + * Retain settings (except for view filters) of "View" menu across editor restarts. 2010-06-06 Andreas Kirschbaum Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2010-06-07 19:06:57 UTC (rev 8265) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypePanel.java 2010-06-07 19:38:16 UTC (rev 8266) @@ -35,7 +35,6 @@ import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.utils.ArchetypeToolTipProvider; import net.sf.gridarta.gui.utils.GList; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.archetypechooser.ArchetypeChooserFolder; @@ -151,7 +150,6 @@ public ArchetypePanel(@NotNull final ArchetypeChooserView<G, A, R> archetypeChooserView, @NotNull final ArchetypeChooserPanel<G, A, R> archetypeChooserPanel) { super(new BorderLayout()); this.archetypeChooserPanel = archetypeChooserPanel; - archetypeList.setToolTipProvider(new ArchetypeToolTipProvider<R>()); archetypeList.setFocusable(false); archetypeList.setBackground(CommonConstants.BG_COLOR); archetypeList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); Deleted: trunk/src/app/net/sf/gridarta/gui/utils/ArchetypeToolTipProvider.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/ArchetypeToolTipProvider.java 2010-06-07 19:06:57 UTC (rev 8265) +++ trunk/src/app/net/sf/gridarta/gui/utils/ArchetypeToolTipProvider.java 2010-06-07 19:38:16 UTC (rev 8266) @@ -1,48 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.utils; - -import net.sf.gridarta.model.archetype.Archetype; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A {@link ToolTipProvider} for {@link Archetype}s. - * @author Andreas Kirschbaum - */ -public class ArchetypeToolTipProvider<R extends Archetype<?, ?, R>> implements ToolTipProvider<R> { - - /** - * {@inheritDoc} - */ - @Nullable - @Override - public String getToolTipText(@NotNull final R element) { - final StringBuilder sb = new StringBuilder(); - sb.append("<html>Archetype "); - sb.append(element.getArchetypeName()); - sb.append("<br>"); - sb.append(element.getBestName()); - sb.append("<br>"); - sb.append(element.getObjectText().replaceAll("\n$", "").replaceAll("\n", "<br>")); - return sb.toString(); - } - -} // class ArchetypeToolTipProvider This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 16:45:39
|
Revision: 8267 http://gridarta.svn.sourceforge.net/gridarta/?rev=8267&view=rev Author: akirschbaum Date: 2010-06-08 16:45:31 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Make regression tests independent on editor settings. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/validation/checks/NonAbsoluteExitPathChecker.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/validation/AbstractValidator.java trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/AttributeRangeChecker.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedSpawnPointChecker.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/ConnectedInsideContainerChecker.java trunk/src/app/net/sf/gridarta/validation/checks/ConnectedPickableChecker.java trunk/src/app/net/sf/gridarta/validation/checks/ConnectionChecker.java trunk/src/app/net/sf/gridarta/validation/checks/CustomTypeChecker.java trunk/src/app/net/sf/gridarta/validation/checks/DoubleLayerChecker.java trunk/src/app/net/sf/gridarta/validation/checks/DoubleTypeChecker.java trunk/src/app/net/sf/gridarta/validation/checks/EmptySpawnPointChecker.java trunk/src/app/net/sf/gridarta/validation/checks/ExitChecker.java trunk/src/app/net/sf/gridarta/validation/checks/MapDifficultyChecker.java trunk/src/app/net/sf/gridarta/validation/checks/MobOutsideSpawnPointChecker.java trunk/src/app/net/sf/gridarta/validation/checks/PaidItemShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/ShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/SlayingChecker.java trunk/src/app/net/sf/gridarta/validation/checks/SquareWithoutFloorChecker.java trunk/src/app/net/sf/gridarta/validation/checks/SysObjectNotOnLayerZeroChecker.java trunk/src/app/net/sf/gridarta/validation/checks/TilePathsChecker.java trunk/src/app/net/sf/gridarta/validation/checks/UndefinedArchetypeChecker.java trunk/src/app/net/sf/gridarta/validation/checks/UndefinedFaceChecker.java trunk/src/app/net/sf/gridarta/validation/checks/UnsetSlayingChecker.java trunk/src/test/net/sf/gridarta/validation/AbstractValidatorTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/validation/DefaultValidatorPreferences.java trunk/src/app/net/sf/gridarta/validation/ValidatorPreferences.java trunk/src/test/net/sf/gridarta/validation/TestValidatorPreferences.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -103,6 +103,7 @@ import net.sf.gridarta.utils.StringUtils; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker; import net.sf.gridarta.validation.checks.BlockedSpawnPointChecker; @@ -208,8 +209,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); } /** @@ -312,7 +313,7 @@ * {@inheritDoc} */ @Override - public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker) { + public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final ValidatorPreferences validatorPreferences) { final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster_only", "system_monster", "monster"); if (monsterMatcher != null) { addAttributeRangeChecker(attributeRangeChecker, monsterMatcher, "level", "level", 0, 125); @@ -380,14 +381,14 @@ addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_paralyze", "paralyze (effect)", Integer.MIN_VALUE, 100); addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_snare", "snare (effect)", Integer.MIN_VALUE, 100); } - final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(); + final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); customTypeChecker.addIgnore(Archetype.TYPE_MOB, Archetype.TYPE_SPAWN_POINT_MOB, Archetype.TYPE_SPAWN_POINT); - final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(Pattern.compile("^[a-zA-Z_0-9/.]*$")); + final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Pattern.compile("^[a-zA-Z_0-9/.]*$")); final GameObjectMatcher environmentSensorMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_environment_sensor"); if (environmentSensorMatcher != null) { slayingChecker.addMatcher(environmentSensorMatcher, Pattern.compile("|([0-1][0-9]|2[0-3]):[0-5][0-9]-([0-1][0-9]|2[0-3]):[0-5][0-9]")); } - mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_MOB), new BlockedSquareChecker<GameObject, MapArchObject, Archetype>(), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(), attributeRangeChecker, customTypeChecker, new DoubleTypeChecker<GameObject, MapArchObject, Archetype>(), new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_MOB), new SquareWithoutFloorChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_FLOOR, Archetype.TYPE_SHOP_FLOOR), slayingChecker, new TilePathsChecker<GameObject, MapArchObject, Archetype>(globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); + mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new BlockedSquareChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), attributeRangeChecker, customTypeChecker, new DoubleTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new SquareWithoutFloorChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_FLOOR, Archetype.TYPE_SHOP_FLOOR), slayingChecker, new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); } private static void addAttributeRangeChecker(@NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final GameObjectMatcher matcher, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -30,8 +30,8 @@ import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.mappropertiesdialog.MapPropertiesDialogFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; +import net.sf.gridarta.gui.prefs.AppPreferences; import net.sf.gridarta.gui.prefs.AppPreferencesModel; -import net.sf.gridarta.gui.prefs.AppPreferences; import net.sf.gridarta.gui.prefs.DevPreferences; import net.sf.gridarta.gui.prefs.GUIPreferences; import net.sf.gridarta.gui.prefs.MapValidatorPreferences; @@ -94,6 +94,7 @@ import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.gridarta.validation.checks.ConnectedInsideContainerChecker; import net.sf.gridarta.validation.checks.ConnectedPickableChecker; @@ -158,8 +159,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, IGUIConstants.SCRIPTS_DIR, errorView, this, false, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.pythonFileFilter, ".py", "Python", Archetype.TYPE_SPELL, null, IGUIConstants.SCRIPTS_DIR, errorView, this, false, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); } /** @@ -266,7 +267,7 @@ * {@inheritDoc} */ @Override - public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker) { + public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final ValidatorPreferences validatorPreferences) { final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster"); if (monsterMatcher != null) { try { @@ -275,15 +276,15 @@ log.warn(ex.getMessage() + " for monster checker"); } } - final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(); + final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); customTypeChecker.addIgnore(Archetype.TYPE_MISC, Archetype.TYPE_WALL); customTypeChecker.addIgnore(Archetype.TYPE_MISC, Archetype.TYPE_FLOOR); - final UnsetSlayingChecker<GameObject, MapArchObject, Archetype> unsetSlayingChecker = new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); + final UnsetSlayingChecker<GameObject, MapArchObject, Archetype> unsetSlayingChecker = new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER); unsetSlayingChecker.addAllowedValue("player"); - mapValidators.addValidators(attributeRangeChecker, new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(), customTypeChecker, new ExitChecker<GameObject, MapArchObject, Archetype>(globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(), new TilePathsChecker<GameObject, MapArchObject, Archetype>(globalSettings, 4), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(), unsetSlayingChecker); + mapValidators.addValidators(attributeRangeChecker, new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), customTypeChecker, new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 4), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), unsetSlayingChecker); final GameObjectMatcher exitMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_exit"); if (exitMatcher != null) { - mapValidators.addValidator(new NonAbsoluteExitPathChecker(exitMatcher)); + mapValidators.addValidator(new NonAbsoluteExitPathChecker(validatorPreferences, exitMatcher)); } } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/validation/checks/NonAbsoluteExitPathChecker.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/validation/checks/NonAbsoluteExitPathChecker.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/validation/checks/NonAbsoluteExitPathChecker.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -27,6 +27,7 @@ import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.validation.AbstractValidator; import net.sf.gridarta.validation.GameObjectValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.NonAbsoluteExitPathError; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; @@ -49,10 +50,12 @@ /** * Creates a new instance. + * @param validatorPreferences the validator preferences to use * @param exitGameObjectMatcher the game object matcher for matching exit * objects */ - public NonAbsoluteExitPathChecker(@NotNull final GameObjectMatcher exitGameObjectMatcher) { + public NonAbsoluteExitPathChecker(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final GameObjectMatcher exitGameObjectMatcher) { + super(validatorPreferences); this.exitGameObjectMatcher = exitGameObjectMatcher; } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -103,6 +103,7 @@ import net.sf.gridarta.utils.StringUtils; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.gridarta.validation.checks.BlockedMobOrSpawnPointChecker; import net.sf.gridarta.validation.checks.BlockedSpawnPointChecker; @@ -209,8 +210,8 @@ */ @NotNull @Override - public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + public DefaultMainControl<GameObject, MapArchObject, Archetype> newMainControl(final boolean forceReadFromFiles, @NotNull final ErrorView errorView, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { + return new DefaultMainControl<GameObject, MapArchObject, Archetype>(FileFilters.luaFileFilter, ".lua", "Lua", 0, IGUIConstants.SPELL_FILE, IGUIConstants.SCRIPTS_DIR, errorView, this, forceReadFromFiles, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); } /** @@ -313,7 +314,7 @@ * {@inheritDoc} */ @Override - public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker) { + public void initMapValidators(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final GlobalSettings globalSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final ValidatorPreferences validatorPreferences) { final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster_only", "system_monster", "monster"); if (monsterMatcher != null) { addAttributeRangeChecker(attributeRangeChecker, monsterMatcher, "level", "level", 0, 125); @@ -381,14 +382,14 @@ addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_paralyze", "paralyze (effect)", Integer.MIN_VALUE, 100); addAttributeRangeChecker(attributeRangeChecker, combatValuesObjectsMatcher, "resist_snare", "snare (effect)", Integer.MIN_VALUE, 100); } - final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(); + final CustomTypeChecker<GameObject, MapArchObject, Archetype> customTypeChecker = new CustomTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); customTypeChecker.addIgnore(Archetype.TYPE_MOB, Archetype.TYPE_SPAWN_POINT_MOB, Archetype.TYPE_SPAWN_POINT); - final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(Pattern.compile("^[a-zA-Z_0-9/.]*$")); + final SlayingChecker<GameObject, MapArchObject, Archetype> slayingChecker = new SlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Pattern.compile("^[a-zA-Z_0-9/.]*$")); final GameObjectMatcher environmentSensorMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_environment_sensor"); if (environmentSensorMatcher != null) { slayingChecker.addMatcher(environmentSensorMatcher, Pattern.compile("|([0-1][0-9]|2[0-3]):[0-5][0-9]-([0-1][0-9]|2[0-3]):[0-5][0-9]")); } - mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_MOB), new BlockedSquareChecker<GameObject, MapArchObject, Archetype>(), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(), attributeRangeChecker, customTypeChecker, new DoubleTypeChecker<GameObject, MapArchObject, Archetype>(), new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_MOB), new SquareWithoutFloorChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_FLOOR, Archetype.TYPE_SHOP_FLOOR), slayingChecker, new SysObjectNotOnLayerZeroChecker<GameObject, MapArchObject, Archetype>(), new TilePathsChecker<GameObject, MapArchObject, Archetype>(globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); + mapValidators.addValidators(new BlockedSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new BlockedMobOrSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new BlockedSquareChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedInsideContainerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new ConnectedPickableChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), attributeRangeChecker, customTypeChecker, new DoubleTypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new DoubleLayerChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new EmptySpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_SPAWN_POINT), new ExitChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, Archetype.TYPE_EXIT), new MapDifficultyChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new MobOutsideSpawnPointChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_MOB), new SquareWithoutFloorChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_FLOOR, Archetype.TYPE_SHOP_FLOOR), slayingChecker, new SysObjectNotOnLayerZeroChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new TilePathsChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, globalSettings, 8), new UndefinedArchetypeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UndefinedFaceChecker<GameObject, MapArchObject, Archetype>(validatorPreferences), new UnsetSlayingChecker<GameObject, MapArchObject, Archetype>(validatorPreferences, Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_DETECTOR, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER)); } private static void addAttributeRangeChecker(@NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final GameObjectMatcher matcher, @NotNull final String name, @NotNull final String displayName, final int minValue, final int maxValue) { Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -97,6 +97,7 @@ import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.utils.XmlHelper; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.gridarta.validation.checks.ConnectionChecker; import net.sf.gridarta.validation.checks.PaidItemShopSquareChecker; @@ -168,8 +169,9 @@ * @param gameObjectSpells the game object spells to use * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use + * @param validatorPreferences the validator preferences to use */ - public DefaultMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, @NotNull final String scriptsDir, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory) { + public DefaultMainControl(@NotNull final FileFilter scriptFileFilter, @NotNull final String scriptExtension, @NotNull final String scriptName, final int spellType, @Nullable final String spellFile, @NotNull final String scriptsDir, final ErrorView errorView, @NotNull final EditorFactory<G, A, R> editorFactory, final boolean forceReadFromFiles, @NotNull final GlobalSettings globalSettings, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final PathManager pathManager, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final AbstractMapManager<G, A, R> mapManager, @NotNull final ScriptModel<G, A, R> scriptModel, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final AbstractResources<G, A, R> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull final AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences) { final XmlHelper xmlHelper; try { xmlHelper = new XmlHelper(); @@ -185,14 +187,14 @@ } catch (final IOException ex) { gameObjectMatchersErrorViewCollector.addWarning(ErrorViewCategory.GAMEOBJECTMATCHERS_FILE_INVALID, ex.getMessage()); } - editorFactory.initMapValidators(validators, gameObjectMatchersErrorViewCollector, globalSettings, gameObjectMatchers, attributeRangeChecker); + editorFactory.initMapValidators(validators, gameObjectMatchersErrorViewCollector, globalSettings, gameObjectMatchers, attributeRangeChecker, validatorPreferences); final GameObjectMatcher connectionSourceMatcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_source"); if (connectionSourceMatcher != null) { final GameObjectMatcher connectionSinkMatcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_sink"); if (connectionSinkMatcher != null) { final GameObjectMatcher connectionSink2Matcher = gameObjectMatchers.getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_connection_sink2"); if (connectionSink2Matcher != null) { - validators.addValidator(new ConnectionChecker<G, A, R>(connectionSourceMatcher, connectionSinkMatcher, connectionSink2Matcher)); + validators.addValidator(new ConnectionChecker<G, A, R>(validatorPreferences, connectionSourceMatcher, connectionSinkMatcher, connectionSink2Matcher)); } } } @@ -203,12 +205,12 @@ if (shopSquareMatcher != null) { final GameObjectMatcher noSpellsMatcher = gameObjectMatchers.getMatcher("system_no_spells", "no_spells"); if (noSpellsMatcher != null) { - validators.addValidator(new ShopSquareChecker<G, A, R>(shopSquareMatcher, noSpellsMatcher)); + validators.addValidator(new ShopSquareChecker<G, A, R>(validatorPreferences, shopSquareMatcher, noSpellsMatcher)); } final GameObjectMatcher paidItemMatcher = gameObjectMatchers.getMatcher("system_paid_item"); if (paidItemMatcher != null) { - validators.addValidator(new PaidItemShopSquareChecker<G, A, R>(shopSquareMatcher, paidItemMatcher)); + validators.addValidator(new PaidItemShopSquareChecker<G, A, R>(validatorPreferences, shopSquareMatcher, paidItemMatcher)); } } Map<String, TreasureTreeNode> specialTreasureLists; Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -77,6 +77,7 @@ import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.japi.swing.prefs.PreferencesGroup; import org.jetbrains.annotations.NotNull; @@ -110,10 +111,11 @@ * @param gameObjectSpells the game object spells to use * @param attributeRangeChecker the attribute range checker to use * @param pluginParameterFactory the plugin parameter factory to use + * @param validatorPreferences the validator preferences to use * @return the new instance */ @NotNull - DefaultMainControl<G, A, R> newMainControl(boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull GlobalSettings globalSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory); + DefaultMainControl<G, A, R> newMainControl(boolean forceReadFromFiles, @NotNull ErrorView errorView, @NotNull GlobalSettings globalSettings, @NotNull ConfigSourceFactory configSourceFactory, @NotNull PathManager pathManager, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull GameObjectFactory<G, A, R> gameObjectFactory, @NotNull ArchetypeTypeSet archetypeTypeSet, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull AbstractMapManager<G, A, R> mapManager, @NotNull ScriptModel<G, A, R> scriptModel, @NotNull DelegatingMapValidator<G, A, R> validators, @NotNull ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull AbstractResources<G, A, R> resources, @NotNull Spells<NumberSpell> numberSpells, @NotNull Spells<GameObjectSpell<G, A, R>> gameObjectSpells, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull PluginParameterFactory<G, A, R> pluginParameterFactory, @NotNull final ValidatorPreferences validatorPreferences); /** * Returns the offset for drawing double faces. @@ -222,8 +224,9 @@ * @param globalSettings the global settings instance * @param gameObjectMatchers the defined game object matchers * @param attributeRangeChecker the attribute range checker to use + * @param validatorPreferences the validator preferences to use */ - void initMapValidators(@NotNull DelegatingMapValidator<G, A, R> mapValidators, @NotNull ErrorViewCollector errorViewCollector, @NotNull GlobalSettings globalSettings, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker); + void initMapValidators(@NotNull DelegatingMapValidator<G, A, R> mapValidators, @NotNull ErrorViewCollector errorViewCollector, @NotNull GlobalSettings globalSettings, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull AttributeRangeChecker<G, A, R> attributeRangeChecker, @NotNull final ValidatorPreferences validatorPreferences); /** * Creates a new {@link AbstractArchetypeParser} instance. Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -95,7 +95,9 @@ import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SyntaxErrorException; import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.validation.DefaultValidatorPreferences; import net.sf.gridarta.validation.DelegatingMapValidator; +import net.sf.gridarta.validation.ValidatorPreferences; import net.sf.gridarta.validation.checks.AttributeRangeChecker; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -247,7 +249,8 @@ final AbstractMapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); final MapManager<G, A, R> pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, globalSettings, faceObjectProviders); final ScriptModel<G, A, R> scriptModel = new ScriptModel<G, A, R>(); - final DelegatingMapValidator<G, A, R> validators = new DelegatingMapValidator<G, A, R>(); + final ValidatorPreferences validatorPreferences = new DefaultValidatorPreferences(); + final DelegatingMapValidator<G, A, R> validators = new DelegatingMapValidator<G, A, R>(validatorPreferences); final ScriptedEventEditor<G, A, R> scriptedEventEditor = new ScriptedEventEditor<G, A, R>(globalSettings); final NamedFilter defaultFilterList = new NamedFilter(Collections.<NamedGameObjectMatcher>emptyList()); final AbstractArchetypeParser<G, A, R, ?> archetypeParser = editorFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, globalSettings); @@ -255,10 +258,10 @@ final DefaultMainControl<G, A, R> mainControl; final Spells<NumberSpell> numberSpells = new Spells<NumberSpell>(); final Spells<GameObjectSpell<G, A, R>> gameObjectSpells = new Spells<GameObjectSpell<G, A, R>>(); - final AttributeRangeChecker<G, A, R> attributeRangeChecker = new AttributeRangeChecker<G, A, R>(); + final AttributeRangeChecker<G, A, R> attributeRangeChecker = new AttributeRangeChecker<G, A, R>(validatorPreferences); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(archetypeSet, mapManager, defaultFilterList); try { - mainControl = editorFactory.newMainControl(mode == Mode.COLLECT_ARCHES, errorView, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory); + mainControl = editorFactory.newMainControl(mode == Mode.COLLECT_ARCHES, errorView, globalSettings, configSourceFactory, pathManager, gameObjectMatchers, gameObjectFactory, archetypeTypeSet, archetypeSet, archetypeChooserModel, autojoinLists, mapManager, scriptModel, validators, scriptedEventEditor, resources, numberSpells, gameObjectSpells, attributeRangeChecker, pluginParameterFactory, validatorPreferences); } catch (final RuntimeException ex) { log.fatal(ex.getMessage(), ex); if (doExit) { Modified: trunk/src/app/net/sf/gridarta/validation/AbstractValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/AbstractValidator.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/src/app/net/sf/gridarta/validation/AbstractValidator.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -19,8 +19,6 @@ package net.sf.gridarta.validation; -import java.util.prefs.Preferences; -import net.sf.gridarta.MainControl; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -47,10 +45,10 @@ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** - * Preferences. + * The {@link ValidatorPreferences} to use. */ @NotNull - private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); + private final ValidatorPreferences validatorPreferences; /** * Key. @@ -71,10 +69,12 @@ /** * Create an AbstractMapValidator. The key is generated from the validator's * name, which must end on "Checker". + * @param validatorPreferences the validator preferences to use * @throws IllegalArgumentException in case the validator's name does not * end on "Checker". */ - protected AbstractValidator() throws IllegalArgumentException { + protected AbstractValidator(@NotNull final ValidatorPreferences validatorPreferences) throws IllegalArgumentException { + this.validatorPreferences = validatorPreferences; final String name = getClass().getSimpleName(); if (!name.endsWith("Checker")) { throw new IllegalArgumentException("Class name must end with \"Checker\""); @@ -82,18 +82,20 @@ key = VALIDATOR_PREFIX + name.substring(0, name.indexOf("Checker")); final String defaultEnabledString = ACTION_BUILDER.getString(key + ".default"); defaultEnabled = Boolean.parseBoolean(defaultEnabledString); - enabled = preferences.getBoolean(key, defaultEnabled); + enabled = validatorPreferences.loadEnabled(key, defaultEnabled); } /** * Create an AbstractMapValidator. + * @param validatorPreferences the validator preferences to use * @param key Key */ - protected AbstractValidator(@NotNull final String key) { + protected AbstractValidator(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final String key) { + this.validatorPreferences = validatorPreferences; this.key = key; final String defaultEnabledString = ACTION_BUILDER.getString(key + ".default"); defaultEnabled = Boolean.parseBoolean(defaultEnabledString); - enabled = preferences.getBoolean(key, defaultEnabled); + enabled = validatorPreferences.loadEnabled(key, defaultEnabled); } /** @@ -110,8 +112,12 @@ */ @Override public void setEnabled(final boolean enabled) { + if (this.enabled == enabled) { + return; + } + this.enabled = enabled; - preferences.putBoolean(key, enabled); + validatorPreferences.saveEnabled(key, enabled); } /** Added: trunk/src/app/net/sf/gridarta/validation/DefaultValidatorPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/DefaultValidatorPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/validation/DefaultValidatorPreferences.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -0,0 +1,55 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.validation; + +import java.util.prefs.Preferences; +import net.sf.gridarta.MainControl; +import org.jetbrains.annotations.NotNull; + +/** + * Default {@link ValidatorPreferences} implementations. Stores settings in + * preferences. + * @author Andreas Kirschbaum + */ +public class DefaultValidatorPreferences implements ValidatorPreferences { + + /** + * Preferences. + */ + @NotNull + private static final Preferences preferences = Preferences.userNodeForPackage(MainControl.class); + + /** + * {@inheritDoc} + */ + @Override + public boolean loadEnabled(@NotNull final String key, final boolean defaultEnabled) { + return preferences.getBoolean(key, defaultEnabled); + } + + /** + * {@inheritDoc} + */ + @Override + public void saveEnabled(@NotNull final String key, final boolean enabled) { + preferences.putBoolean(key, enabled); + } + +} // class DefaultValidatorPreferences Property changes on: trunk/src/app/net/sf/gridarta/validation/DefaultValidatorPreferences.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java 2010-06-07 19:38:16 UTC (rev 8266) +++ trunk/src/app/net/sf/gridarta/validation/DelegatingMapValidator.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -51,17 +51,19 @@ /** * Create a DelegatingMapValidator for the default key. + * @param validatorPreferences the validator preferences to use */ - public DelegatingMapValidator() { - this(DEFAULT_KEY); + public DelegatingMapValidator(@NotNull final ValidatorPreferences validatorPreferences) { + this(validatorPreferences, DEFAULT_KEY); } /** * Create a DelegatingMapValidator for a specific key. + * @param validatorPreferences the validator preferences to use * @param key key */ - private DelegatingMapValidator(@NotNull final String key) { - super(key); + private DelegatingMapValidator(@NotNull final ValidatorPreferences validatorPreferences, @NotNull final String key) { + super(validatorPreferences, key); } /** Added: trunk/src/app/net/sf/gridarta/validation/ValidatorPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/ValidatorPreferences.java (rev 0) +++ trunk/src/app/net/sf/gridarta/validation/ValidatorPreferences.java 2010-06-08 16:45:31 UTC (rev 8267) @@ -0,0 +1,45 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.validation; + +import org.jetbrains.annotations.NotNull; + +/** + * Configuration parameters for {@link Vali... [truncated message content] |
From: <aki...@us...> - 2010-06-08 16:52:58
|
Revision: 8268 http://gridarta.svn.sourceforge.net/gridarta/?rev=8268&view=rev Author: akirschbaum Date: 2010-06-08 16:52:52 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Remove dependency to resources from regression tests. Modified Paths: -------------- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObjectTest.java trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObjectTest.java Removed Paths: ------------- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/noAttributes.testdata trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/noAttributes.testdata Modified: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObjectTest.java =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObjectTest.java 2010-06-08 16:45:31 UTC (rev 8267) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/MapArchObjectTest.java 2010-06-08 16:52:52 UTC (rev 8268) @@ -21,8 +21,7 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.StringReader; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.model.map.maparchobject.AbstractMapArchObject; import net.sf.gridarta.utils.Size2D; @@ -45,7 +44,8 @@ public void testParseMapArchNoAttributes() throws IOException { final MapArchObject mao = new MapArchObject(); final AbstractMapArchObjectParser<MapArchObject> mapArchObjectParser = new MapArchObjectParser(); - final BufferedReader in = openTestDataReader("noAttributes.testdata"); + final StringReader stringReader = new StringReader("arch map\n" + "end\n"); + final BufferedReader in = new BufferedReader(stringReader); try { mapArchObjectParser.load(in, mao); } finally { @@ -55,18 +55,4 @@ Assert.assertEquals(Size2D.ONE, mao.getMapSize()); } - /** - * Reads test data. - * @param testDataName Name of the test data to open - * @return BufferedReader for reading from testDataName. - */ - private BufferedReader openTestDataReader(final String testDataName) { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - final InputStream in = contextClassLoader.getResourceAsStream(getClass().getPackage().getName().replace('.', '/') + "/" + testDataName); - if (in == null) { - Assert.fail("resource " + testDataName + " not found"); - } - return new BufferedReader(new InputStreamReader(in)); - } - } // class MapArchObjectTest Deleted: trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/noAttributes.testdata =================================================================== --- trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/noAttributes.testdata 2010-06-08 16:45:31 UTC (rev 8267) +++ trunk/atrinik/src/test/net/sf/gridarta/var/atrinik/model/maparchobject/noAttributes.testdata 2010-06-08 16:52:52 UTC (rev 8268) @@ -1,2 +0,0 @@ -arch map -end \ No newline at end of file Modified: trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObjectTest.java =================================================================== --- trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObjectTest.java 2010-06-08 16:45:31 UTC (rev 8267) +++ trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/MapArchObjectTest.java 2010-06-08 16:52:52 UTC (rev 8268) @@ -21,8 +21,7 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; +import java.io.StringReader; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.model.map.maparchobject.AbstractMapArchObject; import net.sf.gridarta.utils.Size2D; @@ -45,7 +44,8 @@ public void testParseMapArchNoAttributes() throws IOException { final MapArchObject mao = new MapArchObject(); final AbstractMapArchObjectParser<MapArchObject> maop = new MapArchObjectParser(); - final BufferedReader in = openTestDataReader("noAttributes.testdata"); + final StringReader stringReader = new StringReader("arch map\n" + "end\n"); + final BufferedReader in = new BufferedReader(stringReader); try { maop.load(in, mao); } finally { @@ -55,18 +55,4 @@ Assert.assertEquals(Size2D.ONE, mao.getMapSize()); } - /** - * Reads test data. - * @param testDataName Name of the test data to open - * @return BufferedReader for reading from testDataName. - */ - private BufferedReader openTestDataReader(final String testDataName) { - final ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); - final InputStream in = contextClassLoader.getResourceAsStream(getClass().getPackage().getName().replace('.', '/') + "/" + testDataName); - if (in == null) { - Assert.fail("resource " + testDataName + " not found"); - } - return new BufferedReader(new InputStreamReader(in)); - } - } // class MapArchObjectTest Deleted: trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/noAttributes.testdata =================================================================== --- trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/noAttributes.testdata 2010-06-08 16:45:31 UTC (rev 8267) +++ trunk/daimonin/src/test/net/sf/gridarta/var/daimonin/model/maparchobject/noAttributes.testdata 2010-06-08 16:52:52 UTC (rev 8268) @@ -1,2 +0,0 @@ -arch map -end \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 20:35:06
|
Revision: 8269 http://gridarta.svn.sourceforge.net/gridarta/?rev=8269&view=rev Author: akirschbaum Date: 2010-06-08 20:34:57 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move classes into different packages. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/CollectedConfigSource.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/DefaultGlobalSettings.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/FilesConfigSource.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/AbstractResourcesReader.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/DefaultResources.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/CollectedConfigSource.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/DefaultGlobalSettings.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/FilesConfigSource.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/AbstractResourcesReader.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/DefaultResources.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/CollectedConfigSource.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/DefaultGlobalSettings.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/FilesConfigSource.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/AbstractResourcesReader.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/DefaultResources.java trunk/src/app/net/sf/gridarta/commands/CollectArchesCommand.java trunk/src/app/net/sf/gridarta/commands/Collector.java trunk/src/app/net/sf/gridarta/gui/prefs/ResPreferences.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/app/net/sf/gridarta/model/resource/AbstractResources.java trunk/src/app/net/sf/gridarta/model/resource/AbstractResourcesReader.java trunk/src/app/net/sf/gridarta/model/resource/CollectedResourcesWriter.java trunk/src/app/net/sf/gridarta/model/treasurelist/TreasureLoader.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/model/configsource/ trunk/src/app/net/sf/gridarta/model/configsource/AbstractConfigSource.java trunk/src/app/net/sf/gridarta/model/configsource/ConfigSource.java trunk/src/app/net/sf/gridarta/model/configsource/ConfigSourceFactory.java trunk/src/app/net/sf/gridarta/model/configsource/DefaultConfigSourceFactory.java trunk/src/app/net/sf/gridarta/model/resource/ trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettingsListener.java trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/ConfigSource.java trunk/src/app/net/sf/gridarta/model/settings/ConfigSourceFactory.java trunk/src/app/net/sf/gridarta/model/settings/DefaultConfigSourceFactory.java trunk/src/app/net/sf/gridarta/model/settings/DefaultGlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettings.java trunk/src/app/net/sf/gridarta/model/settings/GlobalSettingsListener.java trunk/src/app/net/sf/gridarta/resource/ trunk/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -59,6 +59,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -83,16 +84,15 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.DefaultScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/CollectedConfigSource.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/CollectedConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/CollectedConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.atrinik.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/DefaultGlobalSettings.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/DefaultGlobalSettings.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.atrinik.model.settings; import java.io.File; -import net.sf.gridarta.model.settings.ConfigSourceFactory; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.var.atrinik.IGUIConstants; import org.jetbrains.annotations.NotNull; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/FilesConfigSource.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/FilesConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/settings/FilesConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.atrinik.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/AbstractResourcesReader.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/AbstractResourcesReader.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/AbstractResourcesReader.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -34,7 +34,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public abstract class AbstractResourcesReader extends net.sf.gridarta.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { +public abstract class AbstractResourcesReader extends net.sf.gridarta.model.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { /** * Creates a new instance. Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/DefaultResources.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/DefaultResources.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/DefaultResources.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -32,9 +32,9 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.resource.AbstractResources; +import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; -import net.sf.gridarta.resource.CollectedResourcesWriter; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.model.archetype.Archetype; import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -54,6 +54,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; @@ -75,16 +76,15 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.DefaultScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/CollectedConfigSource.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/CollectedConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/CollectedConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.crossfire.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/DefaultGlobalSettings.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/DefaultGlobalSettings.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.crossfire.model.settings; import java.io.File; -import net.sf.gridarta.model.settings.ConfigSourceFactory; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.var.crossfire.IGUIConstants; import org.jetbrains.annotations.NotNull; Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/FilesConfigSource.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/FilesConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/settings/FilesConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.crossfire.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/AbstractResourcesReader.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/AbstractResourcesReader.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/AbstractResourcesReader.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -35,7 +35,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public abstract class AbstractResourcesReader extends net.sf.gridarta.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { +public abstract class AbstractResourcesReader extends net.sf.gridarta.model.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { /** * The archetype set to update. Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/DefaultResources.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/DefaultResources.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/DefaultResources.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -31,9 +31,9 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.resource.AbstractResources; +import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; -import net.sf.gridarta.resource.CollectedResourcesWriter; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -59,6 +59,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -83,16 +84,15 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.DefaultScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/CollectedConfigSource.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/CollectedConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/CollectedConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.daimonin.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/DefaultGlobalSettings.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/DefaultGlobalSettings.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/DefaultGlobalSettings.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.daimonin.model.settings; import java.io.File; -import net.sf.gridarta.model.settings.ConfigSourceFactory; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.var.daimonin.IGUIConstants; import org.jetbrains.annotations.NotNull; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/FilesConfigSource.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/FilesConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/settings/FilesConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -20,12 +20,12 @@ package net.sf.gridarta.var.daimonin.model.settings; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.configsource.AbstractConfigSource; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.settings.AbstractConfigSource; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import org.jetbrains.annotations.NotNull; /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/AbstractResourcesReader.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/AbstractResourcesReader.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/AbstractResourcesReader.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -34,7 +34,7 @@ * @author <a href="mailto:ch...@ri...">Christian Hujer</a> * @author Andreas Kirschbaum */ -public abstract class AbstractResourcesReader extends net.sf.gridarta.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { +public abstract class AbstractResourcesReader extends net.sf.gridarta.model.resource.AbstractResourcesReader<GameObject, MapArchObject, Archetype> { /** * Creates a new instance. Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/DefaultResources.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/DefaultResources.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/DefaultResources.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -32,9 +32,9 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.resource.AbstractResources; +import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; -import net.sf.gridarta.resource.CollectedResourcesWriter; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.model.archetype.Archetype; import net.sf.gridarta.var.daimonin.model.gameobject.GameObject; Modified: trunk/src/app/net/sf/gridarta/commands/CollectArchesCommand.java =================================================================== --- trunk/src/app/net/sf/gridarta/commands/CollectArchesCommand.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/commands/CollectArchesCommand.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -19,8 +19,8 @@ package net.sf.gridarta.commands; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import net.sf.japi.swing.misc.ConsoleProgress; import org.apache.log4j.Category; import org.apache.log4j.Logger; Modified: trunk/src/app/net/sf/gridarta/commands/Collector.java =================================================================== --- trunk/src/app/net/sf/gridarta/commands/Collector.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/commands/Collector.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -21,7 +21,7 @@ import java.io.File; import java.io.IOException; -import net.sf.gridarta.resource.AbstractResources; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.misc.Progress; Modified: trunk/src/app/net/sf/gridarta/gui/prefs/ResPreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/ResPreferences.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/gui/prefs/ResPreferences.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -36,9 +36,9 @@ import javax.swing.border.CompoundBorder; import javax.swing.border.TitledBorder; import net.sf.gridarta.gui.utils.GUIConstants; +import net.sf.gridarta.model.configsource.ConfigSource; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.io.PathManager; -import net.sf.gridarta.model.settings.ConfigSource; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.action.ActionBuilder; Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -64,8 +64,8 @@ import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.Exiter; import net.sf.gridarta.utils.ExiterListener; Modified: trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -53,6 +53,8 @@ import net.sf.gridarta.model.archetypetype.DefaultArchetypeAttributeFactory; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.autojoin.AutojoinListsParser; +import net.sf.gridarta.model.configsource.ConfigSource; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -70,11 +72,10 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.settings.ConfigSource; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.ArchetypeSetSpellLoader; import net.sf.gridarta.model.spells.GameObjectSpell; @@ -85,7 +86,6 @@ import net.sf.gridarta.model.treasurelist.TreasureLoader; import net.sf.gridarta.model.treasurelist.TreasureTree; import net.sf.gridarta.model.treasurelist.TreasureTreeNode; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptModelLoader; Modified: trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/maincontrol/EditorFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -40,6 +40,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeList; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; @@ -61,15 +62,14 @@ import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -128,6 +128,7 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.baseobject.GameObjectContainer; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.DefaultExitConnectorModel; @@ -152,15 +153,14 @@ import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.scripts.ScriptArchData; import net.sf.gridarta.model.scripts.ScriptArchUtils; -import net.sf.gridarta.model.settings.ConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; import net.sf.gridarta.model.treasurelist.TreasureTree; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/maincontrol/GridartaEditor.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -58,6 +58,8 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.configsource.DefaultConfigSourceFactory; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.face.ArchFaceProvider; import net.sf.gridarta.model.face.FaceObjectProviders; @@ -81,13 +83,11 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.NamedGameObjectMatcher; -import net.sf.gridarta.model.settings.ConfigSourceFactory; -import net.sf.gridarta.model.settings.DefaultConfigSourceFactory; +import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.model.spells.GameObjectSpell; import net.sf.gridarta.model.spells.NumberSpell; import net.sf.gridarta.model.spells.Spells; -import net.sf.gridarta.resource.AbstractResources; import net.sf.gridarta.script.ScriptExecutor; import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; Modified: trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -34,6 +34,8 @@ import net.sf.gridarta.model.archetypechooser.ArchetypeChooserModel; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; +import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.configsource.DefaultConfigSourceFactory; import net.sf.gridarta.model.face.ArchFaceProvider; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; @@ -56,8 +58,6 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.NamedGameObjectMatcher; -import net.sf.gridarta.model.settings.ConfigSourceFactory; -import net.sf.gridarta.model.settings.DefaultConfigSourceFactory; import net.sf.gridarta.model.settings.GlobalSettings; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; Added: trunk/src/app/net/sf/gridarta/model/configsource/AbstractConfigSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/configsource/AbstractConfigSource.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/configsource/AbstractConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -0,0 +1,89 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.configsource; + +import java.io.File; +import java.io.IOException; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import net.sf.gridarta.model.settings.GlobalSettings; +import net.sf.gridarta.utils.IOUtils; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Abstract base class for {@link ConfigSource} implementations. + * @author Andreas Kirschbaum + */ +public abstract class AbstractConfigSource implements ConfigSource { + + /** + * The {@link ActionBuilder}. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String toString() { + final String result = ACTION_BUILDER.getString("optionsConfigSource_" + getName()); + return result == null ? getName() : result; + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public File getFile(@NotNull final GlobalSettings globalSettings, @NotNull final String type, final int index) throws IOException { + final String key = "configSource." + getName() + "." + type + "." + index; + final String spec = ACTION_BUILDER.getString(key); + if (spec == null) { + return null; + } + + final Pattern pattern = Pattern.compile("\\$\\{([a-zA-Z]+)}"); + final Matcher matcher = pattern.matcher(spec); + final StringBuffer sb = new StringBuffer(); + while (matcher.find()) { + final String group = matcher.group(1); + final String replacement; + if (group.equals("COLLECTED")) { + replacement = globalSettings.getCollectedDirectory().getPath(); + } else if (group.equals("ARCH")) { + replacement = globalSettings.getArchDirectory().getPath(); + } else if (group.equals("MAPS")) { + replacement = globalSettings.getMapsDirectory().getPath(); + } else { + throw new IOException("unknown variable '${" + group + "} in '" + key + "=" + spec + "'"); + } + matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement)); + } + matcher.appendTail(sb); + final String result = sb.toString(); + return IOUtils.getFile(null, result); + } + +} // class AbstractConfigSource Property changes on: trunk/src/app/net/sf/gridarta/model/configsource/AbstractConfigSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/model/configsource/ConfigSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/configsource/ConfigSource.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/configsource/ConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -0,0 +1,79 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.configsource; + +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.errorview.ErrorView; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.resource.AbstractResources; +import net.sf.gridarta.model.settings.GlobalSettings; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Possible source locations for configuration files. + * @author Andreas Kirschbaum + */ +public interface ConfigSource { + + /** + * Returns the internal name. + * @return the internal name + */ + @NotNull + String getName(); + + /** + * {@inheritDoc} + */ + @NotNull + @Override + String toString(); + + /** + * Reads config files. + * @param globalSettings the global settings to use + * @param resources the resources to update + * @param errorView the error view for reporting errors + */ + <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void read(@NotNull GlobalSettings globalSettings, @NotNull AbstractResources<G, A, R> resources, @NotNull ErrorView errorView); + + /** + * Whether the "archetype directory" input field in the settings dialog + * should be enabled. + * @return whether the input field should be enabled + */ + boolean isArchDirectoryInputFieldEnabled(); + + /** + * Returns a config file. + * @param globalSettings the global settings to use + * @param type the file type + * @param index the file index, starting with <code>0</code> + * @return the file or <code>null</code> if no more files are available + * @throws IOException if an error occurs + */ + @Nullable + File getFile(@NotNull GlobalSettings globalSettings, @NotNull String type, int index) throws IOException; + +} // interface ConfigSource Property changes on: trunk/src/app/net/sf/gridarta/model/configsource/ConfigSource.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/model/configsource/ConfigSourceFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/configsource/ConfigSourceFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/configsource/ConfigSourceFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -0,0 +1,61 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.configsource; + +import org.jetbrains.annotations.NotNull; + +/** + * A factory for creating {@link ConfigSource}s. + * @author Andreas Kirschbaum + */ +public interface ConfigSourceFactory { + + /** + * Returns all defined configuration sources. The returned array may be + * modified. + * @return the defined configuration sources + */ + @NotNull + ConfigSource[] getConfigSources(); + + /** + * Returns a {@link ConfigSource} by name. + * @param name the name + * @return the configuration source of a default configuration source if the + * name does not exist + */ + @NotNull + ConfigSource getConfigSource(@NotNull String name); + + /** + * Returns the {@link ConfigSource} that reads individual files. + * @return the configuration source that reads individual files + */ + @NotNull + ConfigSource getFilesConfigSource(); + + /** + * Returns the default {@link ConfigSource}. + * @return the default configuration source + */ + @NotNull + ConfigSource getDefaultConfigSource(); + +} // interface ConfigSourceFactory Property changes on: trunk/src/app/net/sf/gridarta/model/configsource/ConfigSourceFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/model/configsource/DefaultConfigSourceFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/configsource/DefaultConfigSourceFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/configsource/DefaultConfigSourceFactory.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -0,0 +1,135 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.configsource; + +import java.util.ArrayList; +import java.util.MissingResourceException; +import net.sf.japi.swing.action.ActionBuilder; +import net.sf.japi.swing.action.ActionBuilderFactory; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link ConfigSourceFactory} that is configured through action keys. + * @author Andreas Kirschbaum + */ +public class DefaultConfigSourceFactory implements ConfigSourceFactory { + + /** + * The action key for configuration source class names. The class names are + * separated by spaces. + */ + @NotNull + private static final String CONFIG_SOURCES_KEY = "configSources"; + + /** + * The {@link ActionBuilder}. + */ + @NotNull + private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); + + /** + * The defined configuration sources. The list is never empty; the first + * entry is the default configuration source. + */ + @NotNull + private final ArrayList<ConfigSource> configSources = new ArrayList<ConfigSource>(); + + /** + * Creates a new instance. + */ + public DefaultConfigSourceFactory() { + final String configSourceClassNames = ACTION_BUILDER.getString(CONFIG_SOURCES_KEY); + if (configSourceClassNames == null) { + throw new MissingResourceException("No configuration sources defined", "net.sf.gridarta", CONFIG_SOURCES_KEY); + } + + for (final String configSourceClassName : configSourceClassNames.split(" ", -1)) { + final Class<?> configSourceClass; + try { + configSourceClass = Class.forName(configSourceClassName); + } catch (final ClassNotFoundException ex) { + throw new MissingResourceException("Class does not exist: " + configSourceClassName + ": " + ex.getMessage(), "net.sf.gridarta", CONFIG_SOURCES_KEY); + } + + final Class<? extends ConfigSource> configSourceClass2; + try { + configSourceClass2 = configSourceClass.asSubclass(ConfigSource.class); + } catch (final ClassCastException ex) { + throw new MissingResourceException("Class does not implement ConfigSource: " + configSourceClassName + ": " + ex.getMessage(), "net.sf.gridarta", CONFIG_SOURCES_KEY); + } + + final ConfigSource configSource; + try { + configSource = configSourceClass2.newInstance(); + } catch (final InstantiationException ex) { + throw new MissingResourceException("Class cannot be instantiated: " + configSourceClassName + ": " + ex.getMessage(), "net.sf.gridarta", CONFIG_SOURCES_KEY); + } catch (final IllegalAccessException ex) { + throw new MissingResourceException("Class cannot be instantiated: " + configSourceClassName + ": " + ex.getMessage(), "net.sf.gridarta", CONFIG_SOURCES_KEY); + } + + configSources.add(configSource); + } + + configSources.trimToSize(); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public ConfigSource[] getConfigSources() { + return configSources.toArray(new ConfigSource[configSources.size()]); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public ConfigSource getConfigSource(@NotNull final String name) { + for (final ConfigSource configSource : configSources) { + if (configSource.getName().equals(name)) { + return configSource; + } + } + + return configSources.get(0); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public ConfigSource getFilesConfigSource() { + return getConfigSource("ARCH_DIRECTORY"); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public ConfigSource getDefaultConfigSource() { + return configSources.get(0); + } + +} // class DefaultConfigSourceFactory Property changes on: trunk/src/app/net/sf/gridarta/model/configsource/DefaultConfigSourceFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/model/resource/AbstractResources.java =================================================================== --- trunk/src/app/net/sf/gridarta/resource/AbstractResources.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/resource/AbstractResources.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -package net.sf.gridarta.resource; +package net.sf.gridarta.model.resource; import java.io.File; import java.io.IOException; Modified: trunk/src/app/net/sf/gridarta/model/resource/AbstractResourcesReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/resource/AbstractResourcesReader.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/resource/AbstractResourcesReader.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -package net.sf.gridarta.resource; +package net.sf.gridarta.model.resource; import java.io.BufferedReader; import java.io.File; Modified: trunk/src/app/net/sf/gridarta/model/resource/CollectedResourcesWriter.java =================================================================== --- trunk/src/app/net/sf/gridarta/resource/CollectedResourcesWriter.java 2010-06-06 18:43:50 UTC (rev 8183) +++ trunk/src/app/net/sf/gridarta/model/resource/CollectedResourcesWriter.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -17,7 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -package net.sf.gridarta.resource; +package net.sf.gridarta.model.resource; import java.io.File; import java.io.IOException; Deleted: trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractConfigSource.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -1,88 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.model.settings; - -import java.io.File; -import java.io.IOException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import net.sf.gridarta.utils.IOUtils; -import net.sf.japi.swing.action.ActionBuilder; -import net.sf.japi.swing.action.ActionBuilderFactory; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Abstract base class for {@link ConfigSource} implementations. - * @author Andreas Kirschbaum - */ -public abstract class AbstractConfigSource implements ConfigSource { - - /** - * The {@link ActionBuilder}. - */ - @NotNull - private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String toString() { - final String result = ACTION_BUILDER.getString("optionsConfigSource_" + getName()); - return result == null ? getName() : result; - } - - /** - * {@inheritDoc} - */ - @Nullable - @Override - public File getFile(@NotNull final GlobalSettings globalSettings, @NotNull final String type, final int index) throws IOException { - final String key = "configSource." + getName() + "." + type + "." + index; - final String spec = ACTION_BUILDER.getString(key); - if (spec == null) { - return null; - } - - final Pattern pattern = Pattern.compile("\\$\\{([a-zA-Z]+)}"); - final Matcher matcher = pattern.matcher(spec); - final StringBuffer sb = new StringBuffer(); - while (matcher.find()) { - final String group = matcher.group(1); - final String replacement; - if (group.equals("COLLECTED")) { - replacement = globalSettings.getCollectedDirectory().getPath(); - } else if (group.equals("ARCH")) { - replacement = globalSettings.getArchDirectory().getPath(); - } else if (group.equals("MAPS")) { - replacement = globalSettings.getMapsDirectory().getPath(); - } else { - throw new IOException("unknown variable '${" + group + "} in '" + key + "=" + spec + "'"); - } - matcher.appendReplacement(sb, Matcher.quoteReplacement(replacement)); - } - matcher.appendTail(sb); - final String result = sb.toString(); - return IOUtils.getFile(null, result); - } - -} // class AbstractConfigSource Deleted: trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java 2010-06-08 16:52:52 UTC (rev 8268) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -1,63 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.model.settings; - -import net.sf.gridarta.utils.EventListenerList2; -import org.jetbrains.annotations.NotNull; - -/** - * Abstract base class for {@link GlobalSettings} implementations. - * @author Andreas Kirschbaum - */ -public abstract class AbstractGlobalSettings implements GlobalSettings { - - /** - * The {@link GlobalSettingsListener}s to inform of changes. - */ - @NotNull - private final EventListenerList2<GlobalSettingsListener> listenerList = new EventListenerList2<GlobalSettingsListener>(GlobalSettingsListener.class); - - /** - * {@inheritDoc} - */ - @Override - public void addGlobalSettingsListener(@NotNull final GlobalSettingsListener listener) { - listenerList.add(listener); - } - - /** - * {@inheritDoc} - */ - @Override - public void removeGlobalSettingsListener(@NotNull final GlobalSettingsListener listener) { - listenerList.remove(listener); - } - - /** - * Notifies all listeners about a changed visibility of the main toolbar. - */ - protected void fireShowMainToolbarChanged() { - final boolean visible = isShowMainToolbar(); - for (final GlobalSettingsListener listener : listenerList.getListeners()) { - listener.showMainToolbarChanged(visible); - } - } - -} // class AbstractGlobalSettings Added: trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java =================================================================== --- trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java (rev 0) +++ trunk/src/app/net/sf/gridarta/model/settings/AbstractGlobalSettings.java 2010-06-08 20:34:57 UTC (rev 8269) @@ -0,0 +1,63 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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... [truncated message content] |
From: <aki...@us...> - 2010-06-08 21:00:18
|
Revision: 8270 http://gridarta.svn.sourceforge.net/gridarta/?rev=8270&view=rev Author: akirschbaum Date: 2010-06-08 21:00:12 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move textedit sources out of main source directory. Modified Paths: -------------- trunk/atrinik/build.xml trunk/build.xml trunk/crossfire/build.xml trunk/daimonin/build.xml trunk/textedit.iml Added Paths: ----------- trunk/textedit/ trunk/textedit/src/ trunk/textedit/src/app/ trunk/textedit/src/app/net/ trunk/textedit/src/app/net/sf/ trunk/textedit/src/app/net/sf/gridarta/ trunk/textedit/src/app/net/sf/gridarta/textedit/ Removed Paths: ------------- trunk/src/app/net/sf/gridarta/textedit/ Modified: trunk/atrinik/build.xml =================================================================== --- trunk/atrinik/build.xml 2010-06-08 20:34:57 UTC (rev 8269) +++ trunk/atrinik/build.xml 2010-06-08 21:00:12 UTC (rev 8270) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -116,6 +116,7 @@ </copy> <copy todir="${build.dir.production}"> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-06-08 20:34:57 UTC (rev 8269) +++ trunk/build.xml 2010-06-08 21:00:12 UTC (rev 8270) @@ -89,7 +89,7 @@ <target name="compile" description="Compiles the Gridarta sources."> <mkdir dir="dest/app"/> - <javac srcdir="src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> + <javac srcdir="src/app:textedit/src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> <classpath> <fileset dir="lib" includes="annotations.jar"/> <fileset dir="lib" includes="bsh-classgen-2.0b4.jar"/> @@ -182,11 +182,13 @@ <sourcepath> <pathelement path="${user.javadoc.javasrc}"/> <pathelement path="src/app"/> + <pathelement path="textedit/src/app"/> <pathelement path="atrinik/src/app"/> <pathelement path="crossfire/src/app"/> <pathelement path="daimonin/src/app"/> </sourcepath> <packageset dir="src/app" defaultexcludes="yes"/> + <packageset dir="textedit/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> <packageset dir="daimonin/src/app" defaultexcludes="yes"/> @@ -367,6 +369,7 @@ <formatter type="plain"/> <fileset dir="src/app" includes="**/*.java"/> <fileset dir="src/test" includes="**/*.java"/> + <fileset dir="textedit/src/app" includes="**/*.java"/> <fileset dir="atrinik/src/app" includes="**/*.java"/> <fileset dir="atrinik/src/test" includes="**/*.java"/> <fileset dir="crossfire/src/app" includes="**/*.java"/> @@ -404,6 +407,7 @@ <pathelement path="${user.javadoc.javasrc}"/> <pathelement path="src/app"/> <pathelement path="src/test"/> + <pathelement path="textedit/src/app"/> <pathelement path="atrinik/src/app"/> <pathelement path="atrinik/src/test"/> <pathelement path="crossfire/src/app"/> @@ -413,6 +417,7 @@ </sourcepath> <packageset dir="src/app" defaultexcludes="yes"/> <packageset dir="src/test" defaultexcludes="yes"/> + <packageset dir="textedit/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/test" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> @@ -479,6 +484,7 @@ <fileset dir="resource" includes="**/*.properties,**/*.dtd"/> <fileset dir="src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="src/app" includes="**/*.properties,**/*.testdata"/> + <fileset dir="textedit/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2010-06-08 20:34:57 UTC (rev 8269) +++ trunk/crossfire/build.xml 2010-06-08 21:00:12 UTC (rev 8270) @@ -90,7 +90,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -127,6 +127,7 @@ <include name="${resource.dir}/conf/**"/> </fileset> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../resource"> <include name="icons/**"/> <include name="log4j.properties"/> @@ -176,6 +177,9 @@ <packageset dir="../src/app" defaultexcludes="yes"> <include name="**"/> </packageset> + <packageset dir="../textedit/src/app" defaultexcludes="yes"> + <include name="**"/> + </packageset> <tag name="todo" description="Todo:"/> <tag name="used" description="Manually marked as used." enabled="false"/> <tag name="fixme" description="Fixme:"/> Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2010-06-08 20:34:57 UTC (rev 8269) +++ trunk/daimonin/build.xml 2010-06-08 21:00:12 UTC (rev 8270) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -116,6 +116,7 @@ </copy> <copy todir="${build.dir.production}"> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Modified: trunk/textedit.iml =================================================================== --- trunk/textedit.iml 2010-06-08 20:34:57 UTC (rev 8269) +++ trunk/textedit.iml 2010-06-08 21:00:12 UTC (rev 8270) @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8"?> <module relativePaths="true" type="JAVA_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> - <content url="file://$MODULE_DIR$/src/app/net/sf/gridarta/textedit"> - <sourceFolder url="file://$MODULE_DIR$/src/app/net/sf/gridarta/textedit" isTestSource="false" packagePrefix="net.sf.gridarta.textedit" /> + <content url="file://$MODULE_DIR$/textedit"> + <sourceFolder url="file://$MODULE_DIR$/textedit/src/app" isTestSource="false" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 21:07:54
|
Revision: 8271 http://gridarta.svn.sourceforge.net/gridarta/?rev=8271&view=rev Author: akirschbaum Date: 2010-06-08 21:07:47 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move utils sources out of main source directory. Modified Paths: -------------- trunk/atrinik/build.xml trunk/build.xml trunk/crossfire/build.xml trunk/daimonin/build.xml trunk/utils.iml Added Paths: ----------- trunk/utils/ trunk/utils/src/ trunk/utils/src/app/ trunk/utils/src/app/net/ trunk/utils/src/app/net/sf/ trunk/utils/src/app/net/sf/gridarta/ trunk/utils/src/app/net/sf/gridarta/MainControl.java trunk/utils/src/app/net/sf/gridarta/utils/ trunk/utils/src/test/ trunk/utils/src/test/net/ trunk/utils/src/test/net/sf/ trunk/utils/src/test/net/sf/gridarta/ trunk/utils/src/test/net/sf/gridarta/utils/ Removed Paths: ------------- trunk/src/app/net/sf/gridarta/MainControl.java trunk/src/app/net/sf/gridarta/utils/ trunk/src/test/net/sf/gridarta/utils/ Modified: trunk/atrinik/build.xml =================================================================== --- trunk/atrinik/build.xml 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/atrinik/build.xml 2010-06-08 21:07:47 UTC (rev 8271) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -117,6 +117,7 @@ <copy todir="${build.dir.production}"> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/build.xml 2010-06-08 21:07:47 UTC (rev 8271) @@ -89,7 +89,7 @@ <target name="compile" description="Compiles the Gridarta sources."> <mkdir dir="dest/app"/> - <javac srcdir="src/app:textedit/src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> + <javac srcdir="src/app:textedit/src/app:utils/src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> <classpath> <fileset dir="lib" includes="annotations.jar"/> <fileset dir="lib" includes="bsh-classgen-2.0b4.jar"/> @@ -183,12 +183,14 @@ <pathelement path="${user.javadoc.javasrc}"/> <pathelement path="src/app"/> <pathelement path="textedit/src/app"/> + <pathelement path="utils/src/app"/> <pathelement path="atrinik/src/app"/> <pathelement path="crossfire/src/app"/> <pathelement path="daimonin/src/app"/> </sourcepath> <packageset dir="src/app" defaultexcludes="yes"/> <packageset dir="textedit/src/app" defaultexcludes="yes"/> + <packageset dir="utils/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> <packageset dir="daimonin/src/app" defaultexcludes="yes"/> @@ -370,6 +372,8 @@ <fileset dir="src/app" includes="**/*.java"/> <fileset dir="src/test" includes="**/*.java"/> <fileset dir="textedit/src/app" includes="**/*.java"/> + <fileset dir="utils/src/app" includes="**/*.java"/> + <fileset dir="utils/src/test" includes="**/*.java"/> <fileset dir="atrinik/src/app" includes="**/*.java"/> <fileset dir="atrinik/src/test" includes="**/*.java"/> <fileset dir="crossfire/src/app" includes="**/*.java"/> @@ -408,6 +412,8 @@ <pathelement path="src/app"/> <pathelement path="src/test"/> <pathelement path="textedit/src/app"/> + <pathelement path="utils/src/app"/> + <pathelement path="utils/src/test"/> <pathelement path="atrinik/src/app"/> <pathelement path="atrinik/src/test"/> <pathelement path="crossfire/src/app"/> @@ -418,6 +424,8 @@ <packageset dir="src/app" defaultexcludes="yes"/> <packageset dir="src/test" defaultexcludes="yes"/> <packageset dir="textedit/src/app" defaultexcludes="yes"/> + <packageset dir="utils/src/app" defaultexcludes="yes"/> + <packageset dir="utils/src/test" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/test" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> @@ -485,6 +493,8 @@ <fileset dir="src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="textedit/src/app" includes="**/*.properties,**/*.testdata"/> + <fileset dir="utils/src/app" includes="**/*.properties,**/*.testdata"/> + <fileset dir="utils/src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/crossfire/build.xml 2010-06-08 21:07:47 UTC (rev 8271) @@ -90,7 +90,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -128,6 +128,7 @@ </fileset> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../resource"> <include name="icons/**"/> <include name="log4j.properties"/> @@ -180,6 +181,9 @@ <packageset dir="../textedit/src/app" defaultexcludes="yes"> <include name="**"/> </packageset> + <packageset dir="../utils/src/app" defaultexcludes="yes"> + <include name="**"/> + </packageset> <tag name="todo" description="Todo:"/> <tag name="used" description="Manually marked as used." enabled="false"/> <tag name="fixme" description="Fixme:"/> Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/daimonin/build.xml 2010-06-08 21:07:47 UTC (rev 8271) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -117,6 +117,7 @@ <copy todir="${build.dir.production}"> <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Deleted: trunk/src/app/net/sf/gridarta/MainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/MainControl.java 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/src/app/net/sf/gridarta/MainControl.java 2010-06-08 21:07:47 UTC (rev 8271) @@ -1,29 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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; - -/** - * Interface used as preferences location. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @noinspection InterfaceNeverImplemented,MarkerInterface - */ -public interface MainControl { - -} // interface MainControl Copied: trunk/utils/src/app/net/sf/gridarta/MainControl.java (from rev 8269, trunk/src/app/net/sf/gridarta/MainControl.java) =================================================================== --- trunk/utils/src/app/net/sf/gridarta/MainControl.java (rev 0) +++ trunk/utils/src/app/net/sf/gridarta/MainControl.java 2010-06-08 21:07:47 UTC (rev 8271) @@ -0,0 +1,29 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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; + +/** + * Interface used as preferences location. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @noinspection InterfaceNeverImplemented,MarkerInterface + */ +public interface MainControl { + +} // interface MainControl Property changes on: trunk/utils/src/app/net/sf/gridarta/MainControl.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/utils.iml =================================================================== --- trunk/utils.iml 2010-06-08 21:00:12 UTC (rev 8270) +++ trunk/utils.iml 2010-06-08 21:07:47 UTC (rev 8271) @@ -1,12 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <module relativePaths="true" type="JAVA_MODULE" version="4"> <component name="NewModuleRootManager" inherit-compiler-output="true"> - <content url="file://$MODULE_DIR$/src/app/net/sf/gridarta/utils"> - <sourceFolder url="file://$MODULE_DIR$/src/app/net/sf/gridarta/utils" isTestSource="false" packagePrefix="net.sf.gridarta.utils" /> + <content url="file://$MODULE_DIR$/utils"> + <sourceFolder url="file://$MODULE_DIR$/utils/src/app" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/utils/src/test" isTestSource="false" /> </content> - <content url="file://$MODULE_DIR$/src/test/net/sf/gridarta/utils"> - <sourceFolder url="file://$MODULE_DIR$/src/test/net/sf/gridarta/utils" isTestSource="true" packagePrefix="net.sf.gridarta.utils" /> - </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="module-library"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 21:39:19
|
Revision: 8272 http://gridarta.svn.sourceforge.net/gridarta/?rev=8272&view=rev Author: akirschbaum Date: 2010-06-08 21:39:12 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move model sources out of main source directory. Modified Paths: -------------- trunk/atrinik/build.xml trunk/atrinik.iml trunk/build.xml trunk/crossfire/build.xml trunk/crossfire.iml trunk/daimonin/build.xml trunk/daimonin.iml trunk/gridarta.iml trunk/gridarta.ipr Added Paths: ----------- trunk/model/ trunk/model/src/ trunk/model/src/app/ trunk/model/src/app/net/ trunk/model/src/app/net/sf/ trunk/model/src/app/net/sf/gridarta/ trunk/model/src/app/net/sf/gridarta/model/ trunk/model/src/test/ trunk/model/src/test/net/ trunk/model/src/test/net/sf/ trunk/model/src/test/net/sf/gridarta/ trunk/model/src/test/net/sf/gridarta/model/ trunk/model.iml trunk/src/test/model/ trunk/src/test/model/gameobject/ trunk/src/test/model/gameobject/GameObjectFactoryTest.java trunk/utils/src/app/net/sf/gridarta/gui/ trunk/utils/src/app/net/sf/gridarta/gui/utils/ trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/utils/GUIConstants.java trunk/src/app/net/sf/gridarta/model/ trunk/src/test/net/sf/gridarta/model/ Modified: trunk/atrinik/build.xml =================================================================== --- trunk/atrinik/build.xml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/atrinik/build.xml 2010-06-08 21:39:12 UTC (rev 8272) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app:../model/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -118,6 +118,7 @@ <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../model/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Modified: trunk/atrinik.iml =================================================================== --- trunk/atrinik.iml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/atrinik.iml 2010-06-08 21:39:12 UTC (rev 8272) @@ -85,6 +85,7 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="model" /> </component> </module> Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/build.xml 2010-06-08 21:39:12 UTC (rev 8272) @@ -89,7 +89,7 @@ <target name="compile" description="Compiles the Gridarta sources."> <mkdir dir="dest/app"/> - <javac srcdir="src/app:textedit/src/app:utils/src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> + <javac srcdir="src/app:textedit/src/app:utils/src/app:model/src/app:atrinik/src/app:crossfire/src/app:daimonin/src/app" destdir="dest/app" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="${debug}"> <classpath> <fileset dir="lib" includes="annotations.jar"/> <fileset dir="lib" includes="bsh-classgen-2.0b4.jar"/> @@ -184,6 +184,7 @@ <pathelement path="src/app"/> <pathelement path="textedit/src/app"/> <pathelement path="utils/src/app"/> + <pathelement path="model/src/app"/> <pathelement path="atrinik/src/app"/> <pathelement path="crossfire/src/app"/> <pathelement path="daimonin/src/app"/> @@ -191,6 +192,7 @@ <packageset dir="src/app" defaultexcludes="yes"/> <packageset dir="textedit/src/app" defaultexcludes="yes"/> <packageset dir="utils/src/app" defaultexcludes="yes"/> + <packageset dir="model/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> <packageset dir="daimonin/src/app" defaultexcludes="yes"/> @@ -374,6 +376,8 @@ <fileset dir="textedit/src/app" includes="**/*.java"/> <fileset dir="utils/src/app" includes="**/*.java"/> <fileset dir="utils/src/test" includes="**/*.java"/> + <fileset dir="model/src/app" includes="**/*.java"/> + <fileset dir="model/src/test" includes="**/*.java"/> <fileset dir="atrinik/src/app" includes="**/*.java"/> <fileset dir="atrinik/src/test" includes="**/*.java"/> <fileset dir="crossfire/src/app" includes="**/*.java"/> @@ -414,6 +418,8 @@ <pathelement path="textedit/src/app"/> <pathelement path="utils/src/app"/> <pathelement path="utils/src/test"/> + <pathelement path="model/src/app"/> + <pathelement path="model/src/test"/> <pathelement path="atrinik/src/app"/> <pathelement path="atrinik/src/test"/> <pathelement path="crossfire/src/app"/> @@ -426,6 +432,8 @@ <packageset dir="textedit/src/app" defaultexcludes="yes"/> <packageset dir="utils/src/app" defaultexcludes="yes"/> <packageset dir="utils/src/test" defaultexcludes="yes"/> + <packageset dir="model/src/app" defaultexcludes="yes"/> + <packageset dir="model/src/test" defaultexcludes="yes"/> <packageset dir="atrinik/src/app" defaultexcludes="yes"/> <packageset dir="atrinik/src/test" defaultexcludes="yes"/> <packageset dir="crossfire/src/app" defaultexcludes="yes"/> @@ -463,7 +471,7 @@ <target name="test" description="executes the junit tests." depends="compile"> <mkdir dir="classes/test"/> <mkdir dir="docs/test"/> - <javac srcdir="src/test:atrinik/src/test:crossfire/src/test:daimonin/src/test" destdir="classes/test" encoding="utf-8" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="yes"> + <javac srcdir="src/test:model/src/test:utils/src/test:atrinik/src/test:crossfire/src/test:daimonin/src/test" destdir="classes/test" encoding="utf-8" source="${build.source.version}" target="${build.target.version}" includeantruntime="false" debug="yes"> <classpath> <fileset dir="lib" includes="annotations.jar"/> <fileset dir="lib" includes="bsh-classgen-2.0b4.jar"/> @@ -495,6 +503,8 @@ <fileset dir="textedit/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="utils/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="utils/src/test" includes="**/*.properties,**/*.testdata"/> + <fileset dir="model/src/app" includes="**/*.properties,**/*.testdata"/> + <fileset dir="model/src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/test" includes="**/*.properties,**/*.testdata"/> <fileset dir="atrinik/src/app" includes="**/*.properties,**/*.testdata"/> <fileset dir="crossfire/src/test" includes="**/*.properties,**/*.testdata"/> Modified: trunk/crossfire/build.xml =================================================================== --- trunk/crossfire/build.xml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/crossfire/build.xml 2010-06-08 21:39:12 UTC (rev 8272) @@ -90,7 +90,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app:../model/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -129,6 +129,7 @@ <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../model/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../resource"> <include name="icons/**"/> <include name="log4j.properties"/> @@ -184,6 +185,9 @@ <packageset dir="../utils/src/app" defaultexcludes="yes"> <include name="**"/> </packageset> + <packageset dir="../model/src/app" defaultexcludes="yes"> + <include name="**"/> + </packageset> <tag name="todo" description="Todo:"/> <tag name="used" description="Manually marked as used." enabled="false"/> <tag name="fixme" description="Fixme:"/> Modified: trunk/crossfire.iml =================================================================== --- trunk/crossfire.iml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/crossfire.iml 2010-06-08 21:39:12 UTC (rev 8272) @@ -122,6 +122,7 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="model" /> </component> </module> Modified: trunk/daimonin/build.xml =================================================================== --- trunk/daimonin/build.xml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/daimonin/build.xml 2010-06-08 21:39:12 UTC (rev 8272) @@ -92,7 +92,7 @@ <!-- compiling all Java classes --> <target name="compile" depends="init,clean,ctags" description="compiles source."> - <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> + <javac srcdir="${src.dir}:../src/app:../textedit/src/app:../utils/src/app:../model/src/app" destdir="${build.dir.production}" encoding="${build.source.encoding}" source="${build.source.version}" target="${build.target.version}" debug="${debug}" excludes="test/**/*.java" fork="${javac.fork}" includeantruntime="false"> <classpath> <fileset dir="${lib.dir}" includes="*.jar"/> <fileset dir="../lib/" includes="*.jar"/> @@ -118,6 +118,7 @@ <fileset dir="../src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../textedit/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> <fileset dir="../utils/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> + <fileset dir="../model/src/app" excludes="**/*.java,**/package.html,**/overview.html"/> </copy> <copy todir="${build.dir.production}"> <fileset dir="${src.dir}" includes="**/*.properties"/> Modified: trunk/daimonin.iml =================================================================== --- trunk/daimonin.iml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/daimonin.iml 2010-06-08 21:39:12 UTC (rev 8272) @@ -84,6 +84,7 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="model" /> </component> </module> Modified: trunk/gridarta.iml =================================================================== --- trunk/gridarta.iml 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/gridarta.iml 2010-06-08 21:39:12 UTC (rev 8272) @@ -185,6 +185,7 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="model" /> </component> </module> Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/gridarta.ipr 2010-06-08 21:39:12 UTC (rev 8272) @@ -1364,6 +1364,7 @@ <module fileurl="file://$PROJECT_DIR$/crossfire.iml" filepath="$PROJECT_DIR$/crossfire.iml" /> <module fileurl="file://$PROJECT_DIR$/daimonin.iml" filepath="$PROJECT_DIR$/daimonin.iml" /> <module fileurl="file://$PROJECT_DIR$/gridarta.iml" filepath="$PROJECT_DIR$/gridarta.iml" /> + <module fileurl="file://$PROJECT_DIR$/model.iml" filepath="$PROJECT_DIR$/model.iml" /> <module fileurl="file://$PROJECT_DIR$/preferences.iml" filepath="$PROJECT_DIR$/preferences.iml" /> <module fileurl="file://$PROJECT_DIR$/textedit.iml" filepath="$PROJECT_DIR$/textedit.iml" /> <module fileurl="file://$PROJECT_DIR$/utils.iml" filepath="$PROJECT_DIR$/utils.iml" /> Added: trunk/model.iml =================================================================== --- trunk/model.iml (rev 0) +++ trunk/model.iml 2010-06-08 21:39:12 UTC (rev 8272) @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module type="JAVA_MODULE" version="4"> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$/model"> + <sourceFolder url="file://$MODULE_DIR$/model/src/app" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/model/src/test" isTestSource="true" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="utils" /> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/annotations.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/japi-lib-swing-action-0.1.0.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/japi-lib-swing-misc-trunk-1398.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/log4j-1.2.13.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/japi-lib-util-trunk-1379.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/jdom.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/japi-lib-xml-0.1.0.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + <orderEntry type="module-library"> + <library> + <CLASSES> + <root url="jar://$MODULE_DIR$/lib/junit-4.2.jar!/" /> + </CLASSES> + <JAVADOC /> + <SOURCES /> + </library> + </orderEntry> + </component> +</module> + Property changes on: trunk/model.iml ___________________________________________________________________ Added: svn:mime-type + text/xml Added: svn:eol-style + LF Deleted: trunk/src/app/net/sf/gridarta/gui/utils/GUIConstants.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/utils/GUIConstants.java 2010-06-08 21:07:47 UTC (rev 8271) +++ trunk/src/app/net/sf/gridarta/gui/utils/GUIConstants.java 2010-06-08 21:39:12 UTC (rev 8272) @@ -1,41 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.utils; - -import java.awt.Insets; -import javax.swing.border.Border; -import javax.swing.border.EmptyBorder; - -/** - * Defines common UI constants used in different dialogs. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author Andreas Kirschbaum - */ -public interface GUIConstants { - - /** - * The Border object to be used when creating dialogs. - */ - Border DIALOG_BORDER = new EmptyBorder(new Insets(4, 4, 4, 4)); - - int EDIT_TYPE_NONE = 0x10000; // special case - -} // interface GUIConstants Added: trunk/src/test/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/src/test/model/gameobject/GameObjectFactoryTest.java (rev 0) +++ trunk/src/test/model/gameobject/GameObjectFactoryTest.java 2010-06-08 21:39:12 UTC (rev 8272) @@ -0,0 +1,73 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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 model.gameobject; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link GameObjectFactory}. + * @author Andreas Kirschbaum + * XXX: should be in model module + */ +public class GameObjectFactoryTest { + + /** + * Checks that {@link + * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} + * correctly updates the container. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + + final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); + + Assert.assertNotSame(ob1, ob1Clone); + Assert.assertEquals(1, ob1Clone.countInvObjects()); + final TestGameObject ob2Clone = ob1Clone.getFirst(); + Assert.assertNotNull(ob2Clone); + Assert.assertNotSame(ob2, ob2Clone); + + Assert.assertSame(ob1, ob2.getContainer()); + Assert.assertSame(ob1Clone, ob2Clone.getContainer()); + } + +} // class GameObjectFactoryTest Property changes on: trunk/src/test/model/gameobject/GameObjectFactoryTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java (from rev 8271, trunk/src/app/net/sf/gridarta/gui/utils/GUIConstants.java) =================================================================== --- trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java (rev 0) +++ trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java 2010-06-08 21:39:12 UTC (rev 8272) @@ -0,0 +1,41 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.utils; + +import java.awt.Insets; +import javax.swing.border.Border; +import javax.swing.border.EmptyBorder; + +/** + * Defines common UI constants used in different dialogs. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author Andreas Kirschbaum + */ +public interface GUIConstants { + + /** + * The Border object to be used when creating dialogs. + */ + Border DIALOG_BORDER = new EmptyBorder(new Insets(4, 4, 4, 4)); + + int EDIT_TYPE_NONE = 0x10000; // special case + +} // interface GUIConstants Property changes on: trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.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...> - 2010-06-08 22:06:16
|
Revision: 8273 http://gridarta.svn.sourceforge.net/gridarta/?rev=8273&view=rev Author: akirschbaum Date: 2010-06-08 22:06:10 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Make project compilable. Added Paths: ----------- trunk/src/test/net/sf/gridarta/model/ trunk/src/test/net/sf/gridarta/model/gameobject/ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java Removed Paths: ------------- trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java Deleted: trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-08 21:39:12 UTC (rev 8272) +++ trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-08 22:06:10 UTC (rev 8273) @@ -1,69 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.model.gameobject; - -import java.awt.Point; -import java.io.File; -import net.sf.gridarta.gui.map.test.TestMapControlCreator; -import net.sf.gridarta.model.archetype.DuplicateArchetypeException; -import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.map.mapcontrol.MapControl; -import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.utils.Size2D; -import org.junit.Assert; -import org.junit.Test; - -/** - * Regression tests for {@link GameObjectFactory}. - * @author Andreas Kirschbaum - */ -public class GameObjectFactoryTest { - - /** - * Checks that {@link - * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} - * correctly updates the container. - * @throws DuplicateArchetypeException if the test fails - */ - @Test - public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { - final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); - final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); - - final Point point = new Point(0, 0); - final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); - mapModel.beginTransaction("TEST"); - final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); - final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); - - final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); - - Assert.assertNotSame(ob1, ob1Clone); - Assert.assertEquals(1, ob1Clone.countInvObjects()); - final TestGameObject ob2Clone = ob1Clone.getFirst(); - Assert.assertNotNull(ob2Clone); - Assert.assertNotSame(ob2, ob2Clone); - - Assert.assertSame(ob1, ob2.getContainer()); - Assert.assertSame(ob1Clone, ob2Clone.getContainer()); - } - -} // class GameObjectFactoryTest Copied: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (from rev 8272, trunk/model/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java) =================================================================== --- trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.java 2010-06-08 22:06:10 UTC (rev 8273) @@ -0,0 +1,69 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.gameobject; + +import java.awt.Point; +import java.io.File; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Assert; +import org.junit.Test; + +/** + * Regression tests for {@link GameObjectFactory}. + * @author Andreas Kirschbaum + */ +public class GameObjectFactoryTest { + + /** + * Checks that {@link + * net.sf.gridarta.model.gameobject.GameObjectFactory#cloneGameObject(GameObject)} + * correctly updates the container. + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testDoMoveSquareTopSingle() throws DuplicateArchetypeException { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(new File("file"), "name", new Size2D(1, 1)); + + final Point point = new Point(0, 0); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("TEST"); + final TestGameObject ob1 = testMapControlCreator.insertFloor(mapModel, point); + final TestGameObject ob2 = testMapControlCreator.insertExit(ob1); + + final TestGameObject ob1Clone = testMapControlCreator.getGameObjectFactory().cloneGameObject(ob1); + + Assert.assertNotSame(ob1, ob1Clone); + Assert.assertEquals(1, ob1Clone.countInvObjects()); + final TestGameObject ob2Clone = ob1Clone.getFirst(); + Assert.assertNotNull(ob2Clone); + Assert.assertNotSame(ob2, ob2Clone); + + Assert.assertSame(ob1, ob2.getContainer()); + Assert.assertSame(ob1Clone, ob2Clone.getContainer()); + } + +} // class GameObjectFactoryTest Property changes on: trunk/src/test/net/sf/gridarta/model/gameobject/GameObjectFactoryTest.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...> - 2010-06-08 22:33:26
|
Revision: 8290 http://gridarta.svn.sourceforge.net/gridarta/?rev=8290&view=rev Author: akirschbaum Date: 2010-06-08 22:33:20 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -213,7 +213,7 @@ break; } fireDisplayObjectNamesChangedEvent(); - tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); + tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKMAP_ARCHETYPE_TOP, 0, 0, 0)); add(tabDesktop); if (createDirectionPane) { add(new DirectionPane<G, A, R>(archetypeChooserModel, true), BorderLayout.SOUTH); Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -172,7 +172,7 @@ this.pickmapChooserModel = pickmapChooserModel; this.mapFolderTree = mapFolderTree; pickmapChooserModel.addPickmapChooserListener(pickmapChooserModelListener); - pickmapPanel.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); + pickmapPanel.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKMAP_ARCHETYPE_TOP, 0, 0, 0)); mapFolderTree.addModelListener(mapFolderTreeListener); synchronized (mapFolderTree) { mapFolderTreeListener.activeMapFolderChanged(mapFolderTree.getActiveMapFolder()); Modified: trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -58,7 +58,7 @@ * The height of rigid area between the two tab-panes on the pickmap- and * arch-panel. */ - public static final int SPACE_PICKARCH_TOP = 10; + public static final int SPACE_PICKMAP_ARCHETYPE_TOP = 10; /** * Default file name for new maps. Modified: trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -43,8 +43,8 @@ /** * Return the filename to use when dealing with this application's and * current users' home directory. For example, if called like this - * <code>CResourceLoader.getHomeFile("myfile");</code> will return something - * like /home/someuser/.gridarta/myfile under Linux. + * <code>CResourceLoader.getHomeFile("file");</code> will return something + * like /home/user/.gridarta/file under Linux. * @param filename the name of requested file. * @return the full to user home directory, appended with application * directory and the filename. Modified: trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -137,10 +137,10 @@ private ImageIcon warningSquareIcon = null; @Nullable - private ImageIcon nofaceSquareIcon = null; + private ImageIcon noFaceSquareIcon = null; @Nullable - private ImageIcon noarchSquareIcon = null; + private ImageIcon noArchSquareIcon = null; /** * The default icon {@link Image} for map previews. @@ -232,18 +232,18 @@ @NotNull public ImageIcon getNoFaceSquareIcon() { - if (nofaceSquareIcon == null) { - nofaceSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_FACE); + if (noFaceSquareIcon == null) { + noFaceSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_FACE); } - return nofaceSquareIcon; + return noFaceSquareIcon; } @NotNull public ImageIcon getNoArchSquareIcon() { - if (noarchSquareIcon == null) { - noarchSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_ARCH); + if (noArchSquareIcon == null) { + noArchSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_ARCH); } - return noarchSquareIcon; + return noArchSquareIcon; } @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:44:13
|
Revision: 8291 http://gridarta.svn.sourceforge.net/gridarta/?rev=8291&view=rev Author: akirschbaum Date: 2010-06-08 22:44:06 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Rename icon file names. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java Added Paths: ----------- trunk/atrinik/resource/icons/app_icon.gif trunk/atrinik/resource/system/no_arch.png trunk/atrinik/resource/system/no_face.png trunk/atrinik/resource/system/pre_selected_square.png trunk/atrinik/resource/system/selected_square.png trunk/atrinik/resource/system/selected_square_e.png trunk/atrinik/resource/system/selected_square_n.png trunk/atrinik/resource/system/selected_square_s.png trunk/atrinik/resource/system/selected_square_w.png trunk/crossfire/resource/icons/app_icon.gif trunk/crossfire/resource/system/no_arch.png trunk/crossfire/resource/system/no_face.png trunk/crossfire/resource/system/pre_selected_square.png trunk/crossfire/resource/system/selected_square.png trunk/crossfire/resource/system/selected_square_e.png trunk/crossfire/resource/system/selected_square_n.png trunk/crossfire/resource/system/selected_square_s.png trunk/crossfire/resource/system/selected_square_w.png trunk/daimonin/resource/icons/app_icon.gif trunk/daimonin/resource/system/no_arch.png trunk/daimonin/resource/system/no_face.png trunk/daimonin/resource/system/pre_selected_square.png trunk/daimonin/resource/system/selected_square.png trunk/daimonin/resource/system/selected_square_e.png trunk/daimonin/resource/system/selected_square_n.png trunk/daimonin/resource/system/selected_square_s.png trunk/daimonin/resource/system/selected_square_w.png trunk/resource/icons/auto_run_small_icon.gif trunk/resource/icons/close_tab_small_icon.gif trunk/resource/icons/filte_small_icon.gif trunk/resource/icons/run_plugin_small_icon.gif Removed Paths: ------------- trunk/atrinik/resource/icons/CFIcon.gif trunk/atrinik/resource/system/noarch.png trunk/atrinik/resource/system/noface.png trunk/atrinik/resource/system/preseltile.png trunk/atrinik/resource/system/seltile.png trunk/atrinik/resource/system/seltile_e.png trunk/atrinik/resource/system/seltile_n.png trunk/atrinik/resource/system/seltile_s.png trunk/atrinik/resource/system/seltile_w.png trunk/crossfire/resource/icons/CFIcon.gif trunk/crossfire/resource/system/noarch.png trunk/crossfire/resource/system/noface.png trunk/crossfire/resource/system/preseltile.png trunk/crossfire/resource/system/seltile.png trunk/crossfire/resource/system/seltile_e.png trunk/crossfire/resource/system/seltile_n.png trunk/crossfire/resource/system/seltile_s.png trunk/crossfire/resource/system/seltile_w.png trunk/daimonin/resource/icons/CFIcon.gif trunk/daimonin/resource/system/noarch.png trunk/daimonin/resource/system/noface.png trunk/daimonin/resource/system/preseltile.png trunk/daimonin/resource/system/seltile.png trunk/daimonin/resource/system/seltile_e.png trunk/daimonin/resource/system/seltile_n.png trunk/daimonin/resource/system/seltile_s.png trunk/daimonin/resource/system/seltile_w.png trunk/resource/icons/AutorunSmallIcon.gif trunk/resource/icons/CloseTabSmallIcon.gif trunk/resource/icons/FilterSmallIcon.gif trunk/resource/icons/RunPluginSmallIcon.gif Deleted: trunk/atrinik/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/icons/app_icon.gif (from rev 8272, trunk/atrinik/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/no_arch.png (from rev 8272, trunk/atrinik/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/no_face.png (from rev 8272, trunk/atrinik/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/pre_selected_square.png (from rev 8272, trunk/atrinik/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square.png (from rev 8272, trunk/atrinik/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_e.png (from rev 8272, trunk/atrinik/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_n.png (from rev 8272, trunk/atrinik/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_s.png (from rev 8272, trunk/atrinik/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_w.png (from rev 8272, trunk/atrinik/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/icons/app_icon.gif (from rev 8272, trunk/crossfire/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/no_arch.png (from rev 8272, trunk/crossfire/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/no_face.png (from rev 8272, trunk/crossfire/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/pre_selected_square.png (from rev 8272, trunk/crossfire/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square.png (from rev 8272, trunk/crossfire/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_e.png (from rev 8272, trunk/crossfire/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_n.png (from rev 8272, trunk/crossfire/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_s.png (from rev 8272, trunk/crossfire/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_w.png (from rev 8272, trunk/crossfire/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/icons/app_icon.gif (from rev 8272, trunk/daimonin/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/no_arch.png (from rev 8272, trunk/daimonin/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/no_face.png (from rev 8272, trunk/daimonin/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/pre_selected_square.png (from rev 8272, trunk/daimonin/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square.png (from rev 8272, trunk/daimonin/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_e.png (from rev 8272, trunk/daimonin/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_n.png (from rev 8272, trunk/daimonin/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_s.png (from rev 8272, trunk/daimonin/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_w.png (from rev 8272, trunk/daimonin/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/resource/icons/AutorunSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/CloseTabSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/FilterSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/RunPluginSmallIcon.gif =================================================================== (Binary files differ) Copied: trunk/resource/icons/auto_run_small_icon.gif (from rev 8272, trunk/resource/icons/AutorunSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/close_tab_small_icon.gif (from rev 8272, trunk/resource/icons/CloseTabSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/filte_small_icon.gif (from rev 8272, trunk/resource/icons/FilterSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/run_plugin_small_icon.gif (from rev 8272, trunk/resource/icons/RunPluginSmallIcon.gif) =================================================================== (Binary files differ) Modified: trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:33:20 UTC (rev 8290) +++ trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:44:06 UTC (rev 8291) @@ -45,17 +45,17 @@ */ public static final String SYSTEM_DIR = "system/"; - public static final String SQUARE_SELECTED_SQUARE = SYSTEM_DIR + "seltile.png"; + public static final String SQUARE_SELECTED_SQUARE = SYSTEM_DIR + "selected_square.png"; - public static final String SQUARE_SELECTED_SQUARE_NORTH = SYSTEM_DIR + "seltile_n.png"; + public static final String SQUARE_SELECTED_SQUARE_NORTH = SYSTEM_DIR + "selected_square_n.png"; - public static final String SQUARE_SELECTED_SQUARE_EAST = SYSTEM_DIR + "seltile_e.png"; + public static final String SQUARE_SELECTED_SQUARE_EAST = SYSTEM_DIR + "selected_square_e.png"; - public static final String SQUARE_SELECTED_SQUARE_SOUTH = SYSTEM_DIR + "seltile_s.png"; + public static final String SQUARE_SELECTED_SQUARE_SOUTH = SYSTEM_DIR + "selected_square_s.png"; - public static final String SQUARE_SELECTED_SQUARE_WEST = SYSTEM_DIR + "seltile_w.png"; + public static final String SQUARE_SELECTED_SQUARE_WEST = SYSTEM_DIR + "selected_square_w.png"; - public static final String SQUARE_PRE_SELECTED_SQUARE = SYSTEM_DIR + "preseltile.png"; + public static final String SQUARE_PRE_SELECTED_SQUARE = SYSTEM_DIR + "pre_selected_square.png"; public static final String SQUARE_CURSOR = SYSTEM_DIR + "cursor.png"; @@ -65,9 +65,9 @@ public static final String SQUARE_WARNING = SYSTEM_DIR + "warning.png"; - public static final String SQUARE_NO_FACE = SYSTEM_DIR + "noface.png"; + public static final String SQUARE_NO_FACE = SYSTEM_DIR + "no_face.png"; - public static final String SQUARE_NO_ARCH = SYSTEM_DIR + "noarch.png"; + public static final String SQUARE_NO_ARCH = SYSTEM_DIR + "no_arch.png"; private static final String TREASURE_LIST = SYSTEM_DIR + "treasure_list.png"; @@ -87,18 +87,18 @@ */ public static final String DEFAULT_PREVIEW = SYSTEM_DIR + "default_preview.png"; - private static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "CloseTabSmallIcon.gif"; + private static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "close_tab_small_icon.gif"; - private static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "AutorunSmallIcon.gif"; + private static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "auto_run_small_icon.gif"; - private static final String FILTER_SMALL_ICON = ICON_DIR + "FilterSmallIcon.gif"; + private static final String FILTER_SMALL_ICON = ICON_DIR + "filter_small_icon.gif"; - private static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "RunPluginSmallIcon.gif"; + private static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "run_plugin_small_icon.gif"; /** * Application icon definitions (icon-dir). */ - private static final String APP_ICON = ICON_DIR + "CFIcon.gif"; + private static final String APP_ICON = ICON_DIR + "app_icon.gif"; /** * The {@link GUIUtils} for creating icons. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:51:06
|
Revision: 8292 http://gridarta.svn.sourceforge.net/gridarta/?rev=8292&view=rev Author: akirschbaum Date: 2010-06-08 22:51:00 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move constants to correct class. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-08 22:44:06 UTC (rev 8291) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-08 22:51:00 UTC (rev 8292) @@ -132,7 +132,6 @@ import net.sf.gridarta.textedit.textarea.SyntaxDocument; import net.sf.gridarta.textedit.textarea.TextAreaDefaults; import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.action.ActionBuilder; @@ -150,6 +149,18 @@ public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { /** + * Color for float values. + */ + @NotNull + public static final Color FLOAT_COLOR = new Color(19, 134, 0); + + /** + * Color for int values. + */ + @NotNull + public static final Color INT_COLOR = new Color(74, 70, 156); + + /** * The serial version UID. */ private static final long serialVersionUID = 1L; @@ -481,7 +492,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeFloat archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.FLOAT_COLOR); + cLabel.setForeground(FLOAT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final DecimalFormat format = new DecimalFormat("#0.0#"); format.setMaximumFractionDigits(10); @@ -500,7 +511,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeInt archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final NumberFormat format = NumberFormat.getIntegerInstance(); format.setGroupingUsed(false); @@ -517,7 +528,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, gameObject, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), cLabel, input, null, null, false); @@ -527,7 +538,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection final JComponent cComp; @Nullable final JComboBox input; @@ -548,7 +559,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeLong archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final NumberFormat format = NumberFormat.getIntegerInstance(); format.setGroupingUsed(false); @@ -587,7 +598,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, false, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), cLabel, input, null, null, false); @@ -644,7 +655,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, true, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), cLabel, input, null, null, false); Modified: trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:44:06 UTC (rev 8291) +++ trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:51:00 UTC (rev 8292) @@ -38,13 +38,6 @@ public static final Color BG_COLOR = new Color(100, 219, 169); /** - * Color for float/int values (AttributeDialog). - */ - public static final Color FLOAT_COLOR = new Color(19, 134, 0); - - public static final Color INT_COLOR = new Color(74, 70, 156); - - /** * Name of the file that contains the type definitions. */ public static final String TYPEDEF_FILE = "types.xml"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:36:53
|
Revision: 8293 http://gridarta.svn.sourceforge.net/gridarta/?rev=8293&view=rev Author: akirschbaum Date: 2010-06-08 23:36:45 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Replace int constants with enum. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java 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/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeDialog.java trunk/src/app/net/sf/gridarta/gui/utils/DirectionLayout.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/validation/checks/TilePathsChecker.java trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/direction/ trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.atrinik; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.SystemIcons; /** @@ -37,13 +36,6 @@ int DEF_MAPDIFFICULTY = 1; /** - * All tile paths in an array, e.g. for iterations. This doesn't make sense - * at first sight, but this way iterating code is independent of the - * definition of the tile path values. - */ - int[] ALL_TILE_PATHS = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Default map size (both height and width). */ int DEF_MAPSIZE = 24; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -60,6 +60,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -97,7 +98,6 @@ import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; import net.sf.gridarta.script.parameter.PluginParameterFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; @@ -539,7 +539,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; @@ -103,9 +104,9 @@ if (mapArchObject.isPlugins()) { appendable.append("plugins 1\n"); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.getTilesetId() != 0) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -55,6 +55,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; @@ -406,7 +407,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new int[] { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; @@ -133,9 +134,9 @@ if (mapArchObject.getSky() != 0) { format.format("sky %d\n", mapArchObject.getSky()); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.isNoSmooth()) { Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.daimonin; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.SystemIcons; /** @@ -37,13 +36,6 @@ int DEF_MAPDIFFICULTY = 1; /** - * All tile paths in an array, e.g. for iterations. This doesn't make sense - * at first sight, but this way iterating code is independent of the - * definition of the tile path values. - */ - int[] ALL_TILE_PATHS = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Default map size (both height and width). */ int DEF_MAPSIZE = 24; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -60,6 +60,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -97,7 +98,6 @@ import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; import net.sf.gridarta.script.parameter.PluginParameterFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; @@ -540,7 +540,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; @@ -100,9 +101,9 @@ if (mapArchObject.isPvp()) { appendable.append("pvp 1\n"); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.getTilesetId() != 0) { Added: trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -0,0 +1,104 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.direction; + +/** + * A direction. + * @author Andreas Kirschbaum + */ +public enum Direction { + + /** + * North. + */ + NORTH(0, -1), + + /** + * East. + */ + EAST(1, 0), + + /** + * South. + */ + SOUTH(0, 1), + + /** + * West. + */ + WEST(-1 , 0), + + /** + * North east. + */ + NORTH_EAST(1, -1), + + /** + * South east. + */ + SOUTH_EAST(1, 1), + + /** + * South west. + */ + SOUTH_WEST(-1, 1), + + /** + * North west. + */ + NORTH_WEST(-1, -1); + + /** + * The relative x direction. + */ + private final int dx; + + /** + * The relative y direction. + */ + private final int dy; + + /** + * Creates a new instance. + * @param dx the relative x direction + * @param dy the relative y direction + */ + Direction(final int dx, final int dy) { + this.dx = dx; + this.dy = dy; + } + + /** + * Returns the relative x direction. + * @return the relative x direction + */ + public int getDx() { + return dx; + } + + /** + * Returns the relative y direction. + * @return the relative y direction + */ + public int getDy() { + return dy; + } + +} // enum Direction Property changes on: trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.BufferedReader; import java.io.IOException; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; @@ -105,8 +106,8 @@ // get tile path try { final int i = Integer.valueOf(line.substring(10, 11)); - if (i > 0 && i <= mapArchObject.getTilePaths() && line.length() >= 12 && line.charAt(11) == ' ') { - mapArchObject.setTilePath(i - 1, line.substring(12)); + if (i > 0 && i <= Direction.values().length && line.length() >= 12 && line.charAt(11) == ' ') { + mapArchObject.setTilePath(Direction.values()[i - 1], line.substring(12)); } else { throw new InvalidMapFormatException("unexpected map attribute: '" + line + "'"); } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -124,7 +125,7 @@ * The map tile paths used for map tiling. 0 = north, 1 = east, 2 = south, 3 * = west. 4 = northeast, 5 = southeast, 6 = southwest, 7 = northwest */ - private String[] tilePaths = new String[8]; + private String[] tilePaths = new String[Direction.values().length]; /** * The registered event listeners. @@ -393,20 +394,20 @@ */ @NotNull @Override - public String getTilePath(final int direction) { - return tilePaths[direction]; + public String getTilePath(@NotNull final Direction direction) { + return tilePaths[direction.ordinal()]; } /** * {@inheritDoc} */ @Override - public void setTilePath(final int direction, @NotNull final String tilePath) { - if (tilePaths[direction].equals(tilePath)) { + public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { + if (tilePaths[direction.ordinal()].equals(tilePath)) { return; } - tilePaths[direction] = tilePath; + tilePaths[direction.ordinal()] = tilePath; setModified(); } @@ -427,8 +428,8 @@ setDifficulty(abstractMapArchObject.difficulty); setFixedReset(abstractMapArchObject.fixedReset); setDarkness(abstractMapArchObject.darkness); - for (int i = 0; i < tilePaths.length; i++) { - setTilePath(i, abstractMapArchObject.tilePaths[i]); + for (final Direction direction : Direction.values()) { + setTilePath(direction, abstractMapArchObject.tilePaths[direction.ordinal()]); } } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.awt.Point; import java.io.Serializable; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -184,14 +185,14 @@ * @return The tile path. */ @NotNull - String getTilePath(int direction); + String getTilePath(@NotNull Direction direction); /** * Set a tile path. * @param direction The tile path direction. * @param tilePath The new tile path. */ - void setTilePath(int direction, @NotNull String tilePath); + void setTilePath(@NotNull Direction direction, @NotNull String tilePath); /** * Create a copy of this object. Modified: trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -19,25 +19,32 @@ package net.sf.gridarta.model.map.tiles; +import net.sf.gridarta.model.direction.Direction; +import org.jetbrains.annotations.NotNull; + /** * @author Andreas Kirschbaum */ public class MapLink { - private final int mapDirection; + @NotNull + private final Direction mapDirection; - private final int linkDirection; + @NotNull + private final Direction linkDirection; - public MapLink(final int mapDirection, final int linkDirection) { + public MapLink(@NotNull final Direction mapDirection, @NotNull final Direction linkDirection) { this.mapDirection = mapDirection; this.linkDirection = linkDirection; } - public int getMapDirection() { + @NotNull + public Direction getMapDirection() { return mapDirection; } - public int getLinkDirection() { + @NotNull + public Direction getLinkDirection() { return linkDirection; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.map.tiles; +import net.sf.gridarta.model.direction.Direction; import org.jetbrains.annotations.NotNull; /** @@ -35,13 +36,14 @@ /** * Direction for reverse map linking. */ - private final int revLink; + @NotNull + private final Direction revLink; /** * Creates a new instance. * @param revLink direction for reverse map linking */ - public TileLink(@NotNull final String name, @NotNull final MapLink[] mapLinks, final int revLink) { + public TileLink(@NotNull final String name, @NotNull final MapLink[] mapLinks, @NotNull final Direction revLink) { this.name = name; this.mapLinks = mapLinks; this.revLink = revLink; @@ -61,7 +63,8 @@ * Returns the index for reverse map linking. * @return the index */ - public int getRevLink() { + @NotNull + public Direction getRevLink() { return revLink; } Modified: trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,6 +20,7 @@ package net.sf.gridarta.model.map.maparchobject; import java.awt.Point; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -236,7 +237,7 @@ */ @NotNull @Override - public String getTilePath(final int direction) { + public String getTilePath(@NotNull final Direction direction) { throw new AssertionError(); } @@ -244,7 +245,7 @@ * {@inheritDoc} */ @Override - public void setTilePath(final int direction, @NotNull final String tilePath) { + public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { throw new AssertionError(); } Modified: trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java =================================================================== --- trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -24,6 +24,7 @@ import java.util.regex.Matcher; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; @@ -182,12 +183,12 @@ final TileLink tileLink = tileLinks[i]; final MapLink[] mapLinks = tileLink.getMapLinks(); for (final MapLink mapLink : mapLinks) { - final int index = mapLink.getMapDirection(); - if (mapControls[index] == null) { + final Direction direction = mapLink.getMapDirection(); + if (mapControls[direction.ordinal()] == null) { final String tilePath = mapControl.getMapModel().getMapArchObject().getTilePath(mapLink.getLinkDirection()); if (tilePath.length() > 0) { try { - mapControls[index] = loadMapControl(mapControl.getMapModel(), tilePath); + mapControls[direction.ordinal()] = loadMapControl(mapControl.getMapModel(), tilePath); repeatFlag = true; } catch (final IOException ex) { throw new CannotLoadMapFileException(tilePath, ex); Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -22,6 +22,7 @@ import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.map.grid.MapGrid; import net.sf.gridarta.model.map.grid.MapGridEvent; import net.sf.gridarta.model.map.grid.MapGridListener; @@ -77,19 +78,6 @@ 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. */ @@ -326,13 +314,13 @@ /** * Moves the cursor one square relative to current position. - * @param dir Index of {@link #direction} + * @param dir the direction * @return <code>true</code> if cursor really moved + * @noinspection TypeMayBeWeakened */ - public boolean goTo(final int dir) { - assert dir >= 0 && dir < 8; + public boolean goTo(@NotNull final Direction dir) { if (onMap) { - tmpPoint.setLocation(pos.x + direction[dir][0], pos.y + direction[dir][1]); + tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); if (dragging) { return dragTo(tmpPoint); } else { Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -31,11 +31,11 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.grid.SelectionMode; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.ActionUtils; -import net.sf.gridarta.utils.CommonConstants; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -221,7 +221,7 @@ */ @ActionMethod public void goNorth() { - doGo(true, CommonConstants.NORTH); + doGo(true, Direction.NORTH); } /** @@ -229,7 +229,7 @@ */ @ActionMethod public void goSouth() { - doGo(true, CommonConstants.SOUTH); + doGo(true, Direction.SOUTH); } /** @@ -237,7 +237,7 @@ */ @ActionMethod public void goEast() { - doGo(true, CommonConstants.EAST); + doGo(true, Direction.EAST); } /** @@ -245,7 +245,7 @@ */ @ActionMethod public void goWest() { - doGo(true, CommonConstants.WEST); + doGo(true, Direction.WEST); } /** @@ -253,7 +253,7 @@ */ @ActionMethod public void goNorthEast() { - doGo(true, CommonConstants.NORTH_EAST); + doGo(true, Direction.NORTH_EAST); } /** @@ -261,7 +261,7 @@ */ @ActionMethod public void goNorthWest() { - doGo(true, CommonConstants.NORTH_WEST); + doGo(true, Direction.NORTH_WEST); } /** @@ -269,7 +269,7 @@ */ @ActionMethod public void goSouthEast() { - doGo(true, CommonConstants.SOUTH_EAST); + doGo(true, Direction.SOUTH_EAST); } /** @@ -277,7 +277,7 @@ */ @ActionMethod public void goSouthWest() { - doGo(true, CommonConstants.SOUTH_WEST); + doGo(true, Direction.SOUTH_WEST); } /** @@ -395,7 +395,7 @@ * Enable/disable menu entries based on the current cursor state. */ private void refreshActions() { - final boolean goEnabled = doGo(false, CommonConstants.NORTH); + final boolean goEnabled = doGo(false, Direction.NORTH); for (final Action action : aGo) { action.setEnabled(goEnabled); } @@ -423,7 +423,7 @@ * @param direction the direction to go * @return whether the action was or can be performed */ - private boolean doGo(final boolean performAction, final int direction) { + private boolean doGo(final boolean performAction, @NotNull final Direction direction) { final MapCursor mapCursor = getActiveMapCursor(); if (mapCursor == null) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -46,6 +46,7 @@ import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.mapmanager.MapManagerListener; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.exitconnector.ExitMatcher; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -59,7 +60,6 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.ActionUtils; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -86,12 +86,6 @@ private final String[] directionsMap = { "enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterNorthEastMap", "enterSouthEastMap", "enterSouthWestMap", "enterNorthWestMap" }; /** - * Possible directions for "enter xxx map". - */ - @NotNull - private final int[] directionsDir = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Action for "grid visible". */ @NotNull @@ -215,7 +209,7 @@ * Maps map relative direction to map window direction. */ @NotNull - private final int[] directionMap; + private final Direction[] directionMap; /** * Whether exit paths may point to random maps. @@ -405,7 +399,7 @@ * @param mapViewsManager the map views * @param fileControl the file control */ - public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final int[] directionMap, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapPathNormalizer mapPathNormalizer, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final FileControl<G, A, R> fileControl) { + public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final Direction[] directionMap, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapPathNormalizer mapPathNormalizer, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final FileControl<G, A, R> fileControl) { this.parent = parent; this.helpParent = helpParent; this.exitMatcher = exitMatcher; @@ -633,7 +627,7 @@ */ @ActionMethod public void enterNorthMap() { - doEnterMap(true, CommonConstants.NORTH); + doEnterMap(true, Direction.NORTH); } /** @@ -641,7 +635,7 @@ */ @ActionMethod public void enterNorthEastMap() { - doEnterMap(true, CommonConstants.NORTH_EAST); + doEnterMap(true, Direction.NORTH_EAST); } /** @@ -649,7 +643,7 @@ */ @ActionMethod public void enterEastMap() { - doEnterMap(true, CommonConstants.EAST); + doEnterMap(true, Direction.EAST); } /** @@ -657,7 +651,7 @@ */ @ActionMethod public void enterSouthEastMap() { - doEnterMap(true, CommonConstants.SOUTH_EAST); + doEnterMap(true, Direction.SOUTH_EAST); } /** @@ -665,7 +659,7 @@ */ @ActionMethod public void enterSouthMap() { - doEnterMap(true, CommonConstants.SOUTH); + doEnterMap(true, Direction.SOUTH); } /** @@ -673,7 +667,7 @@ */ @ActionMethod public void enterSouthWestMap() { - doEnterMap(true, CommonConstants.SOUTH_WEST); + doEnterMap(true, Direction.SOUTH_WEST); } /** @@ -681,7 +675,7 @@ */ @ActionMethod public void enterWestMap() { - doEnterMap(true, CommonConstants.WEST); + doEnterMap(true, Direction.WEST); } /** @@ -689,7 +683,7 @@ */ @ActionMethod public void enterNorthWestMap() { - doEnterMap(true, CommonConstants.NORTH_WEST); + doEnterMap(true, Direction.NORTH_WEST); } /** @@ -709,7 +703,7 @@ * 0|0 if unknown, and note that the point gets modified) * @return whether the destination map has been entered */ - private boolean enterMap(@NotNull final MapView<G, A, R> currentMapView, @NotNull final String path, final int direction, @Nullable final Point destinationPoint) { + private boolean enterMap(@NotNull final MapView<G, A, R> currentMapView, @NotNull final String path, @NotNull final Direction direction, @Nullable final Point destinationPoint) { final File canonicalNewFile; try { canonicalNewFile = mapPathNormalizer.normalizeMapPath(currentMapView.getMapControl().getMapModel(), path); @@ -787,8 +781,8 @@ aNextExit.setEnabled(doNextExit(false)); aPrevExit.setEnabled(doPrevExit(false)); aDeleteUnknownObjects.setEnabled(doDeleteUnknownObjects(false)); - for (int i = 0; i < directionsDir.length; i++) { - aDirections[i].setEnabled(doEnterMap(false, directionsDir[i])); + for (final Direction direction : Direction.values()) { + aDirections[direction.ordinal()].setEnabled(doEnterMap(false, direction)); } aShrinkMapSize.setEnabled(doShrinkMapSize(false)); } @@ -801,41 +795,41 @@ * @return the new view position */ @NotNull - private Point calculateNewViewPosition(@NotNull final JScrollPane oldMapView, @NotNull final JScrollPane newMapView, final int direction) { + private Point calculateNewViewPosition(@NotNull final JScrollPane oldMapView, @NotNull final JScrollPane newMapView, @NotNull final Direction direction) { final Dimension newViewSize = newMapView.getViewport().getViewSize(); final Rectangle oldViewRectangle = oldMapView.getViewport().getViewRect(); final Rectangle scrollTo; - switch (directionMap[direction]) { - case CommonConstants.SOUTH: + switch (directionMap[direction.ordinal()]) { + case SOUTH: scrollTo = new Rectangle(oldViewRectangle.x, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH: + case NORTH: scrollTo = new Rectangle(oldViewRectangle.x, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.EAST: + case EAST: scrollTo = new Rectangle(0, oldViewRectangle.y, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.WEST: + case WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, oldViewRectangle.y, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH_EAST: + case NORTH_EAST: scrollTo = new Rectangle(0, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.SOUTH_EAST: + case SOUTH_EAST: scrollTo = new Rectangle(0, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.SOUTH_WEST: + case SOUTH_WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH_WEST: + case NORTH_WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; @@ -1002,7 +996,7 @@ return false; } - if (!enterMap(mapView, mapLocation.getMapPath(), 0, mapLocation.getMapCoordinate())) { + if (!enterMap(mapView, mapLocation.getMapPath(), Direction.NORTH, mapLocation.getMapCoordinate())) { return false; } } @@ -1102,7 +1096,7 @@ * @param direction the direction to enter * @return whether the action was or can be performed */ - private boolean doEnterMap(final boolean performAction, final int direction) { + private boolean doEnterMap(final boolean performAction, @NotNull final Direction direction) { final MapView<G, A, R> mapView = currentMapView; if (mapView == null) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -38,6 +38,7 @@ import net.sf.gridarta.gui.utils.GUIConstants; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; @@ -45,7 +46,6 @@ import net.sf.gridarta.model.map.tiles.MapLink; import net.sf.gridarta.model.map.tiles.TileLink; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.utils.CommonConstants; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -142,7 +142,7 @@ this.nextFocus = nextFocus; this.mapFileFilter = mapFileFilter; assert tileLink.length == 8; - tileLinks = new TileLink[] { newTileLink("mapNorth", tileLink[0], CommonConstants.SOUTH), newTileLink("mapEast", tileLink[1], CommonConstants.WEST), newTileLink("mapSouth", tileLink[2], CommonConstants.NORTH), newTileLink("mapWest", tileLink[3], CommonConstants.EAST), newTileLink("mapNorthEast", tileLink[4], CommonConstants.SOUTH_WEST), newTileLink("mapSouthEast", tileLink[5], CommonConstants.NORTH_WEST), newTileLink("mapSouthWest", tileLink[6], CommonConstants.NORTH_EAST), newTileLink("mapNorthWest", tileLink[7], CommonConstants.SOUTH_EAST), }; + tileLinks = new TileLink[] { newTileLink("mapNorth", tileLink[0], Direction.SOUTH), newTileLink("mapEast", tileLink[1], Direction.WEST), newTileLink("mapSouth", tileLink[2], Direction.NORTH), newTileLink("mapWest", tileLink[3], Direction.EAST), newTileLink("mapNorthEast", tileLink[4], Direction.SOUTH_WEST), newTileLink("mapSouthEast", tileLink[5], Direction.NORTH_WEST), newTileLink("mapSouthWest", tileLink[6], Direction.NORTH_EAST), newTileLink("mapNorthWest", tileLink[7], Direction.SOUTH_EAST), }; attachTiledMaps = new AttachTiledMaps<G, A, R>(mapManager, tileLinks, mapPathNormalizer); canAttachMaps = tileLink[0].length + tileLink[1].length + tileLink[2].length + tileLink[3].length + tileLink[4].length + tileLink[5].length + tileLink[6].length + tileLink[7].length > 0; mapArchObject = mapModel.getMapArchObject(); @@ -156,7 +156,7 @@ * @return the new instance */ @NotNull - private static TileLink newTileLink(@NotNull final String key, @NotNull final MapLink[] mapLinks, final int revLink) { + private static TileLink newTileLink(@NotNull final String key, @NotNull final MapLink[] mapLinks, @NotNull final Direction revLink) { final String name = ACTION_BUILDER.getString(key); if (name == null) { throw new IllegalArgumentException("resource key '" + key + "' does not exist"); @@ -192,7 +192,7 @@ for (int index = 0; index < tilePanels.length; index++) { final File mapDir = globalSettings.getMapsDirectory(); final File mapFile = mapModel.getMapFile(); - final TilePanel tilePanel = new TilePanel(mapFileFilter, mapArchObject.getTilePath(index), mapFile, mapDir); + final TilePanel tilePanel = new TilePanel(mapFileFilter, mapArchObject.getTilePath(Direction.values()[index]), mapFile, mapDir); tilePanels[index] = new MapTilePanel(index, nextFocus, tilePanel, tileLinks[index].getName()); } return tilePanels; @@ -283,7 +283,7 @@ */ public void modifyMapProperties() { for (int i = 0; i < tilePaths.length; i++) { - mapArchObject.setTilePath(i, tilePaths[i].getTilePanel().getText()); + mapArchObject.setTilePath(Direction.values()[i], tilePaths[i].getTilePanel().getText()); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -23,13 +23,13 @@ import net.sf.gridarta.gui.utils.DirectionLayout; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridar... [truncated message content] |
From: <aki...@us...> - 2010-06-09 08:07:30
|
Revision: 8299 http://gridarta.svn.sourceforge.net/gridarta/?rev=8299&view=rev Author: akirschbaum Date: 2010-06-09 08:07:22 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Move MapCursor and related classes to different packages or modules. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.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/mapcursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/mapcursor/ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java trunk/model/src/test/net/sf/gridarta/model/mapcursor/ trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java trunk/src/app/net/sf/gridarta/gui/mapcursor/ trunk/src/test/net/sf/gridarta/gui/mapcursor/ Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/map/cursor/ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorEvent.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorListener.java trunk/src/test/net/sf/gridarta/gui/map/cursor/ trunk/src/test/net/sf/gridarta/gui/mapcursor/MapCursorTest.java Modified: trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -29,7 +29,7 @@ /** * 2D-Grid containing flags for selection, pre-selection, cursor, warnings and * errors. This class provides methods to modify these flags. Normally a {@link - * net.sf.gridarta.gui.map.cursor.MapCursor} is used to access them. Selection + * net.sf.gridarta.gui.mapcursor.MapCursor} is used to access them. Selection * flags are not changed directly. First pre-selection flags have to be set with * {@link #preSelect(Point, Point)}, then {@link #select(Point, Point, * SelectionMode)} will change the selection flags according to {@link Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,424 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.mapcursor; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.grid.MapGrid; +import net.sf.gridarta.model.map.grid.MapGridEvent; +import net.sf.gridarta.model.map.grid.MapGridListener; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.utils.EventListenerList2; +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; + + /** + * 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 EventListenerList2<MapCursorListener> listenerList = new EventListenerList2<MapCursorListener>(MapCursorListener.class); + + /** + * 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 pre-selection 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 pre-selection. + */ + public void dragRelease() { + if (dragging) { + mapGrid.beginTransaction(); + try { + mapGrid.unPreSelect(dragStart, pos); + dragging = false; + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedModeEvent(); + } + } + + /** + * Leave drag mode and select pre-selection using selectionMode. + * @param selectionMode Mode how to change selection state + * @see SelectionMode + */ + public void dragSelect(final SelectionMode selectionMode) { + if (dragging) { + mapGrid.beginTransaction(); + try { + dragRelease(); + mapGrid.select(dragStart, pos, selectionMode); + } finally { + mapGrid.endTransaction(); + } + } + } + + /** + * Cursor gets deactivated. All selections get lost. + */ + public final 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 one square relative to current position. + * @param dir the direction + * @return <code>true</code> if cursor really moved + * @noinspection TypeMayBeWeakened + */ + public boolean goTo(@NotNull final Direction dir) { + if (onMap) { + tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); + 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(listener); + } + + /** + * Remove a MapCursorListener. + * @param listener MapCursorListener to remove + */ + public void removeMapCursorListener(final MapCursorListener listener) { + listenerList.remove(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()) { + 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()) { + 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 + * this function 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 Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorEvent.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,54 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.mapcursor; + +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 = 1L; + + /** + * 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 Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorListener.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,45 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.mapcursor; + +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 Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java (from rev 8297, trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,503 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.mapcursor; + +import java.awt.Dimension; +import java.awt.Point; +import junit.framework.JUnit4TestAdapter; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.grid.MapGrid; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit test for {@link MapCursor}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + * @author Andreas Kirschbaum + */ +public class MapCursorTest { + + /** + * The size of the map grid for the tested cursor. + */ + @NotNull + private static final Size2D gridSize = new Size2D(6, 7); + + /** + * A {@link MapCursorListener} that counts the number of callbacks. + */ + @NotNull + private static final TestMapCursorListener listener = new TestMapCursorListener(); + + /** + * Creates a new {@link MapCursor} instance. No more than one instance may + * exist concurrently. + * @param grid the underlying map grid + * @return the new map cursor instance + */ + @NotNull + public static MapCursor createCursor(@NotNull final MapGrid grid) { + final MapCursor cursor = new MapCursor(grid); + cursor.addMapCursorListener(listener); + Assert.assertFalse("MapCursor has to be disabled when created.", cursor.isActive()); + listener.changedPosCounter = 0; + listener.changedModeCounter = 0; + return cursor; + } + + /** + * Checks that settings the cursor outside of the grid behaves as expected. + */ + @Test + public void setOutside() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(); + for (int i = -2; i < gridSize.getWidth() + 2; i++) { + p.setLocation(i, -1); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + p.setLocation(i, gridSize.getHeight()); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + } + for (int i = -2; i < gridSize.getHeight() + 2; i++) { + p.setLocation(-1, i); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + p.setLocation(gridSize.getWidth(), i); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + } + } + + /** + * Checks that settings the cursor within the map grid behaves as expected. + */ + @Test + public void setInside() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + boolean first = true; + final Point p = new Point(); + for (int j = 0; j < gridSize.getHeight(); j++) { + for (int i = 0; i < gridSize.getWidth(); i++) { + p.setLocation(i, j); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + if (first) { + // Only the first after activation should fire a change mode event + testEvents(1, 1); + first = false; + } else { + testEvents(1, 0); + } + Assert.assertTrue("MapCursor should be active after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + final Point res = cursor.getLocation(); + testEvents(0, 0); + Assert.assertEquals("getLocation()", p, res); + } + } + } + + /** + * Checks that settings the cursor to the same location does not generate + * excess events. + */ + @Test + public void setSameLocation() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(-1, -1); + Assert.assertFalse("setLocation(null) should return false", cursor.setLocation(null)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + p.setLocation(3, 4); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + testEvents(1, 1); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + p.setLocation(-1, -1); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + testEvents(1, 1); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + } + + /** + * Checks {@link MapCursor#setLocationSafe(Point)}. + */ + @Test + public void setLocationSafe() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(-1, -1); + Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + p.setLocation(3, 4); + Assert.assertTrue("setLocationSafe(" + p + ") should return true", cursor.setLocationSafe(p)); + testEvents(1, 1); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + p.setLocation(-1, -1); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + } + + /** + * Checks {@link MapCursor#isOnGrid(Point)}. + */ + @Test + public void testIsOnGrid() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(); + for (int j = -2; j < gridSize.getHeight() + 2; j++) { + for (int i = -2; i < gridSize.getWidth() + 2; i++) { + p.setLocation(i, j); + if (i >= 0 && i < gridSize.getWidth() && j >= 0 && j < gridSize.getHeight()) { + Assert.assertTrue(p + " should be on the grid.", cursor.isOnGrid(p)); + } else { + Assert.assertFalse(p + " should not be on the grid.", cursor.isOnGrid(p)); + } + } + } + Assert.assertFalse("Null should not be on the grid.", cursor.isOnGrid(null)); + } + + /** + * Checks {@link MapCursor#goTo(Direction)}. + */ + @Test + public void testGoTo() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + for (final Direction dir : Direction.values()) { + Assert.assertFalse("go(" + dir + ") should return false.", cursor.goTo(dir)); + testEvents(0, 0); + } + final Point pStart = new Point(2, 3); + final Point p = new Point(pStart); + cursor.setLocation(p); + testEvents(1, 1); + for (final Direction dir : Direction.values()) { + Assert.assertTrue("go(" + dir + ") should return true. (Maybe the grid was too small.)", cursor.goTo(dir)); + testEvents(1, 0); + p.x += dir.getDx(); + p.y += dir.getDy(); + Assert.assertEquals("Moving cursor.", p, cursor.getLocation()); + } + Assert.assertEquals("Moving in a circle.", pStart, cursor.getLocation()); + } + + /** + * Checks the dragging related functions of {@link MapCursor}. + */ + @Test + public void dragging() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + cursor.dragStart(); + testEvents(0, 0); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); + final Point dragStart = new Point(3, 4); + final Point p = new Point(dragStart); + final Dimension offset = new Dimension(0, 0); + cursor.setLocation(dragStart); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + cursor.deactivate(); + testEvents(1, 1); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); + cursor.setLocation(dragStart); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + dragTo(cursor, grid, Direction.WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.EAST, dragStart, p, offset); + dragTo(cursor, grid, Direction.EAST, dragStart, p, offset); + dragTo(cursor, grid, Direction.NORTH_WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.SOUTH, dragStart, p, offset); + dragTo(cursor, grid, Direction.SOUTH, dragStart, p, offset); + dragTo(cursor, grid, Direction.WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.NORTH_EAST, dragStart, p, offset); + } + + /** + * Calls {@link MapCursor#dragTo(Point)} and checks for expected results. + * @param cursor the map cursor to affect + * @param grid the associated map grid + * @param dir the direction to drag + * @param start the starting location + * @param p the destination location + * @param offset the expected dragging offset + */ + private static void dragTo(@NotNull final MapCursor cursor, @NotNull final MapGrid grid, @NotNull final Direction dir, @NotNull final Point start, @NotNull final Point p, @NotNull final Dimension offset) { + final Point d = new Point(dir.getDx(), dir.getDy()); + p.x += d.x; + p.y += d.y; + Assert.assertTrue("dragTo(" + p + ")", cursor.dragTo(p)); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + Assert.assertEquals("Wrong position", p, cursor.getLocation()); + offset.width = p.x - start.x; + offset.height = p.y - start.y; + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + assertPreSelection(grid, start, p); + } + + /** + * Checks that a {@link MapGrid} includes a rectangle of {@link + * MapGrid#GRID_FLAG_SELECTING}. + * @param grid the map grid to check + * @param start one corner of the rectangle + * @param end the diagonally opposite corner of the rectangle + */ + private static void assertPreSelection(@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + final int height = gridSize.getHeight(); + final int width = gridSize.getWidth(); + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + if (i < minX || i > maxX || j < minY || j > maxY) { + //Not preselected + Assert.assertFalse("Pre-selection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); + } else { + //Preselected + Assert.assertTrue("Pre-selection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); + } + } + + } + } + + /** + * Checks that a {@link MapGrid} includes a rectangle of {@link + * MapGrid#GRID_FLAG_SELECTION}. Squares outside the rectangle are not + * checked. + * @param grid the map grid to check + * @param start one corner of the rectangle + * @param end the diagonally opposite corner of the rectangle + * @param flag the expected selection state + */ + private static void assertSelection(@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end, final boolean flag) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + for (int j = minY; j <= maxY; j++) { + for (int i = minX; i <= maxX; i++) { + Assert.assertSame("Selection", flag, (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTION) > 0); + } + } + } + + /** + * Checks for correct behavior of {@link MapGrid#GRID_FLAG_SELECTING} flags + * during selecting. + */ + @Test + public void selecting() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point start = new Point(2, 3); + final Point end = new Point(4, 5); + final Point gridMaxIndex = new Point(gridSize.getWidth() - 1, gridSize.getHeight() - 1); + cursor.dragRelease(); + testEvents(0, 0); + cursor.setLocation(start); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + cursor.dragRelease(); + testEvents(0, 1); + Assert.assertFalse("MapCursor should not be in drag mode.", cursor.isDragging()); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + cursor.setLocation(null); + testEvents(1, 1); + Assert.assertFalse("MapCursor should not be in drag mode.", cursor.isDragging()); + cursor.setLocation(start); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + cursor.dragSelect(SelectionMode.ADD); + testEvents(0, 1); + assertSelection(grid, start, end, true); + //Check if nothing is preselected + assertPreSelection(grid, new Point(-1, -1), new Point(-1, -1)); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.SUB); + testEvents(0, 1); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.FLIP); + testEvents(0, 1); + assertSelection(grid, start, end, true); + start.setLocation(3, 4); + end.setLocation(5, 1); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.FLIP); + testEvents(0, 1); + assertSelection(grid, start, new Point(4, 4), false); + assertSelection(grid, new Point(3, 2), end, true); + assertSelection(grid, new Point(5, 3), new Point(5, 4), true); + cursor.deactivate(); + testEvents(1, 1); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + } + + /** + * Checks if the number of events fired is correct. + * @param nPos the expected number of position events + * @param nMode the expected number of mode events + */ + private static void testEvents(final int nPos, final int nMode) { + Assert.assertEquals("Position change event", nPos, listener.changedPosCounter); + listener.changedPosCounter = 0; + Assert.assertEquals("Mode change event", nMode, listener.changedModeCounter); + listener.changedModeCounter = 0; + } + + /** + * Returns a new test suite containing this test. + * @return the new test suite + */ + @NotNull + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(MapCursorTest.class); + } + + /** + * A {@link MapCursorListener} that counts the number of event callbacks. + */ + private static class TestMapCursorListener implements MapCursorListener { + + /** + * The number of calls to {@link #mapCursorChangedPos(MapCursorEvent)}. + */ + private int changedPosCounter = 0; + + /** + * The number of calls to {@link #mapCursorChangedMode(MapCursorEvent)}. + */ + private int changedModeCounter = 0; + + /** + * {@inheritDoc} + */ + @Override + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + changedPosCounter++; + } + + /** + * {@inheritDoc} + */ + @Override + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + changedModeCounter++; + } + + } // class TestMapCursorListener + +} // class MapCursorTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -22,9 +22,6 @@ import java.awt.Point; import javax.swing.Action; import net.sf.gridarta.exitconnector.ExitConnectorActions; -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.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewManager; @@ -35,6 +32,9 @@ import net.sf.gridarta.model.exitconnector.ExitLocation; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorEvent; +import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.utils.ActionUtils; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -37,7 +37,6 @@ import javax.swing.JSplitPane; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -53,6 +52,7 @@ import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.map.validation.errors.ValidationError; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -21,12 +21,12 @@ import java.awt.Point; import java.util.EventObject; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -32,9 +32,6 @@ import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.filechooser.FileFilter; -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.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; @@ -57,6 +54,9 @@ import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; import net.sf.gridarta.model.map.normalizer.RelativePathOnUnsavedMapException; import net.sf.gridarta.model.map.normalizer.SameMapException; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorEvent; +import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.ActionUtils; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -29,9 +29,6 @@ import java.util.Set; import javax.swing.JScrollPane; import javax.swing.JViewport; -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.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.gui.map.renderer.RendererFactory; @@ -45,6 +42,9 @@ import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.map.validation.errors.ValidationError; +import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapcursor.MapCursorEvent; +import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -28,7 +28,6 @@ import java.util.HashSet; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; @@ -39,6 +38,7 @@ import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.japi.swing.action.ActionBuilder; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -26,7 +26,6 @@ import java.awt.Point; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; @@ -41,6 +40,7 @@ import net.sf.gridarta.model.map.mapmodel.InsertionMode; import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -27,7 +27,6 @@ import java.awt.event.InputEvent; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.objectchooser.ObjectChooser; @@ -39,6 +38,7 @@ import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.InsertionMode; import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; Deleted: trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 23:45:41 UTC (rev 8297) +++ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -1,424 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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 net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.model.map.grid.MapGrid; -import net.sf.gridarta.model.map.grid.MapGridEvent; -import net.sf.gridarta.model.map.grid.MapGridListener; -import net.sf.gridarta.model.map.grid.SelectionMode; -import net.sf.gridarta.utils.EventListenerList2; -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; - - /** - * 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 EventListenerList2<MapCursorListener> listenerList = new EventListenerList2<MapCursorListener>(MapCursorListener.class); - - /** - * 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 { - ... [truncated message content] |
From: <aki...@us...> - 2010-06-09 08:33:18
|
Revision: 8300 http://gridarta.svn.sourceforge.net/gridarta/?rev=8300&view=rev Author: akirschbaum Date: 2010-06-09 08:33:11 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -28,7 +28,6 @@ import java.io.File; import java.util.Collection; import java.util.HashSet; -import java.util.Map; import java.util.Set; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; @@ -40,7 +39,6 @@ import net.sf.gridarta.model.map.mapmodel.MapModelListener; import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.Size2D; @@ -582,12 +580,4 @@ */ protected abstract void updateAll(); - /** - * {@inheritDoc} - */ - @Override - public void setErroneousArchObjects(@NotNull final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { - //XXX: save erroneousArchObjects - } - } // class AbstractFlatMapRenderer Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -24,12 +24,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; @@ -175,13 +173,6 @@ * {@inheritDoc} */ @Override - public void setErroneousArchObjects(@NotNull final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ - @Override public void closeNotify() { } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -91,7 +91,7 @@ * The erroneous {@link GameObject}s. */ @NotNull - private final Map<G, ValidationError<G, A, R>> erroneousArchObjects = new HashMap<G, ValidationError<G, A, R>>(); + private final Map<G, ValidationError<G, A, R>> erroneousGameObjects = new HashMap<G, ValidationError<G, A, R>>(); /** * The {@link AbstractMapRenderer} for rendering {@link #mapModel}. @@ -209,7 +209,6 @@ mapModel.addMapModelListener(mapModelListener); renderer.setErroneousMapSquares(erroneousMapSquares); - renderer.setErroneousArchObjects(erroneousArchObjects); renderer.setFocusable(true); setFocusable(true); } @@ -300,16 +299,16 @@ */ private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { erroneousMapSquares.clear(); - erroneousArchObjects.clear(); + erroneousGameObjects.clear(); mapGrid.clearErrors(); for (final ValidationError<G, A, R> validationError : errors.getErrors()) { for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { erroneousMapSquares.put(mapSquare, validationError); mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); } - for (final G archObject : validationError.getGameObjects()) { - erroneousArchObjects.put(archObject, validationError); - final BaseObject<G, A, R, ?> topContainer = archObject.getTopContainer(); + for (final G gameObject : validationError.getGameObjects()) { + erroneousGameObjects.put(gameObject, validationError); + final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -27,7 +27,6 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; -import java.util.Map; import java.util.Set; import javax.swing.Icon; import net.sf.gridarta.model.archetype.Archetype; @@ -44,7 +43,6 @@ import net.sf.gridarta.model.map.mapmodel.MapModelListener; import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.Size2D; @@ -649,14 +647,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects) { - //XXX: save erroneousArchObjects - } - - /** * Refreshes the data in the view from the model. */ private void resizeFromModel() { Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -94,13 +94,6 @@ } /** - * Sets the ArchObjects that are known to contain errors. - * @param erroneousArchObjects the ArchObjects that are known to contain - * errors - */ - public abstract void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects); - - /** * Sets the MapSquares that are known to contain errors. * @param erroneousMapSquares the MapSquares that are known to contain * errors Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -25,7 +25,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; @@ -33,7 +32,6 @@ import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -183,13 +181,6 @@ /** * {@inheritDoc} */ - @Override - public void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ @NotNull @Override public Rectangle getSquareBounds(@NotNull final Point p) { Modified: trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -22,12 +22,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -80,13 +78,6 @@ * {@inheritDoc} */ @Override - public void setErroneousArchObjects(@NotNull final Map<TestGameObject, ValidationError<TestGameObject, TestMapArchObject, TestArchetype>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ - @Override public void closeNotify() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:23:11
|
Revision: 8303 http://gridarta.svn.sourceforge.net/gridarta/?rev=8303&view=rev Author: akirschbaum Date: 2010-06-09 10:23:00 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Do not crash when reverting a resized map. Properly revert attributes from map property dialog. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/gridarta.ipr trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java Removed Paths: ------------- trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/atrinik/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/crossfire/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/daimonin/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/gridarta.ipr 2010-06-09 10:23:00 UTC (rev 8303) @@ -1277,6 +1277,7 @@ <w>resized</w> <w>resizes</w> <w>rethrown</w> + <w>revertable</w> <w>revivable</w> <w>riedquat</w> <w>rsync</w> Added: trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,58 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.io; + +import java.util.LinkedHashMap; +import java.util.Map; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.match.GameObjectMatchers; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link GameObjectParser} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestGameObjectParser extends AbstractGameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> { + + /** + * Create a new instance. + * @param gameObjectFactory the game object factory for creating new game + * object instances + * @param gameObjectMatchers the game object matchers to use + */ + public TestGameObjectParser(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers) { + super(gameObjectFactory, gameObjectMatchers); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Map<String, String> getModifiedFields(@NotNull final TestGameObject gameObject) { + final Map<String, String> fields = new LinkedHashMap<String, String>(); + addModifiedFields(gameObject, fields); + return fields; + } + +} // class TestGameObjectParser Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,89 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.io; + +import java.io.IOException; +import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectParser} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectParser extends AbstractMapArchObjectParser<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @Override + protected boolean parseLine(@NotNull final String line, @NotNull final TestMapArchObject mapArchObject) { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public void save(@NotNull final Appendable appendable, @NotNull final TestMapArchObject mapArchObject) throws IOException { + final Formatter format = new Formatter(appendable); + appendable.append("arch map\n"); + if (mapArchObject.getMapName().length() > 0) { + format.format("name %s\n", mapArchObject.getMapName()); + } + if (mapArchObject.getSwapTime() != 0) { + format.format("swap_time %d\n", mapArchObject.getSwapTime()); + } + if (mapArchObject.getResetTimeout() != 0) { + format.format("reset_timeout %d\n", mapArchObject.getResetTimeout()); + } + if (mapArchObject.isFixedReset()) { + appendable.append("fixed_resettime 1\n"); + } + if (mapArchObject.getDifficulty() != 0) { + format.format("difficulty %d\n", mapArchObject.getDifficulty()); + } + if (mapArchObject.getDarkness() != 0) { + format.format("darkness %d\n", mapArchObject.getDarkness()); + } + format.format("width %d\n", mapArchObject.getMapSize().getWidth()); + format.format("height %d\n", mapArchObject.getMapSize().getHeight()); + if (mapArchObject.getEnterX() != 0) { + format.format("enter_x %d\n", mapArchObject.getEnterX()); + } + if (mapArchObject.getEnterY() != 0) { + format.format("enter_y %d\n", mapArchObject.getEnterY()); + } + if (mapArchObject.getText().trim().length() > 0) { + format.format("msg\n" + "%s\n" + "endmsg\n", mapArchObject.getText().trim()); + } + if (mapArchObject.isOutdoor()) { + appendable.append("outdoor 1\n"); + } + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); + } + } + appendable.append("end\n"); + } + +} // class TestMapArchObjectParser Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,40 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.model.io; + +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectParserFactory} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectParserFactory implements MapArchObjectParserFactory<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapArchObjectParser<TestMapArchObject> newMapArchObjectParser() { + return new TestMapArchObjectParser(); + } + +} // class TestMapArchObjectParserFactory Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -21,8 +21,12 @@ import java.io.File; import java.io.IOException; +import net.sf.gridarta.model.archetype.ArchetypeSet; +import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -32,12 +36,59 @@ public class TestMapReaderFactory implements MapReaderFactory<TestGameObject, TestMapArchObject> { /** + * The {@link MapArchObjectParserFactory} instance. + */ + @NotNull + private final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory; + + /** + * The {@link MapArchObjectFactory} instance. + */ + @NotNull + private final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory; + + /** + * The {@link GameObjectParser} instance. + */ + @NotNull + private final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser; + + /** + * The {@link ArchetypeSet} instance. + */ + @NotNull + private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; + + /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * Creates a new instance. + * @param mapArchObjectParserFactory the map arch object parser factory + * instance + * @param mapArchObjectFactory the map arch object factory instance + * @param gameObjectParser the game object parser instance + * @param archetypeSet the archetype set + * @param mapViewSettings the map view settings instance + */ + public TestMapReaderFactory(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final MapViewSettings mapViewSettings) { + this.mapArchObjectParserFactory = mapArchObjectParserFactory; + this.mapArchObjectFactory = mapArchObjectFactory; + this.gameObjectParser = gameObjectParser; + this.archetypeSet = archetypeSet; + this.mapViewSettings = mapViewSettings; + } + + /** * {@inheritDoc} */ @NotNull @Override public MapReader<TestGameObject, TestMapArchObject> newMapReader(@NotNull final File file) throws IOException { - throw new AssertionError(); + return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, archetypeSet, mapViewSettings, file); } } // class TestMapReaderFactory Deleted: trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,43 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 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.model.io; - -import java.io.IOException; -import java.io.Writer; -import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.map.mapmodel.MapModel; -import org.jetbrains.annotations.NotNull; - -/** - * An {@link MapWriter} implementation for testing purposes. - * @author Andreas Kirschbaum - */ -public class TestMapWriter implements MapWriter<TestGameObject, TestMapArchObject, TestArchetype> { - - /** - * {@inheritDoc} - */ - @Override - public void encodeMapFile(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Writer writer) throws IOException { - } - -} // class TestMapWriter Modified: trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -19,16 +19,13 @@ package net.sf.gridarta.model.map.maparchobject; -import java.awt.Point; -import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; /** * A {@link MapArchObject} implementation for testing purposes. * @author Andreas Kirschbaum */ -public class TestMapArchObject implements MapArchObject<TestMapArchObject> { +public class TestMapArchObject extends AbstractMapArchObject<TestMapArchObject> { /** * The serial version UID. @@ -36,302 +33,20 @@ private static final long serialVersionUID = 1L; /** - * The current map size. - */ - private Size2D mapSize = Size2D.ONE; - - /** - * The map name. - */ - private String mapName = "*unset map name*"; - - /** * {@inheritDoc} */ - @Override - public void setState(@NotNull final TestMapArchObject mapArchObject) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMapSize(@NotNull final Size2D mapSize) { - this.mapSize = mapSize; - } - - /** - * {@inheritDoc} - */ @NotNull @Override - public Size2D getMapSize() { - return mapSize; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getMapName() { - return mapName; - } - - /** - * {@inheritDoc} - */ - @Override - public void setMapName(@NotNull final String name) { - mapName = name; - } - - /** - * {@inheritDoc} - */ - @Override - public int getEnterX() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEnterX(final int enterX) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getEnterY() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEnterY(final int enterY) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public Point getEnter() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOutdoor() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setOutdoor(final boolean outdoor) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getResetTimeout() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setResetTimeout(final int resetTimeout) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getSwapTime() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setSwapTime(final int swapTime) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getDifficulty() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDifficulty(final int difficulty) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isFixedReset() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setFixedReset(final boolean fixedReset) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getDarkness() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDarkness(final int darkness) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getTilePaths() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getTilePath(@NotNull final Direction direction) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public TestMapArchObject clone() { - try { - return (TestMapArchObject) super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } + return super.clone(); } /** * {@inheritDoc} */ @Override - public void addMapArchObjectListener(@NotNull final MapArchObjectListener<TestMapArchObject> listener) { - // ignore + protected TestMapArchObject getThis() { + return this; } - /** - * {@inheritDoc} - */ - @Override - public void removeMapArchObjectListener(@NotNull final MapArchObjectListener<TestMapArchObject> listener) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void beginTransaction() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void endTransaction() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void endTransaction(final boolean fireEvent) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void addText(@NotNull final String text) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setText(final String text) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getText() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void updateModifiedAttribute(@NotNull final String userName) { - } - } // class TestMapArchObject Modified: trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -278,7 +278,7 @@ @NotNull @Override public String getUserName() { - throw new AssertionError(); + return "user"; } /** Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -351,10 +351,10 @@ final A mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("revert"); try { - mapModel.resizeMap(mapArchObject.getMapSize()); + mapModel.resizeMap(decoder.getMapArchObject().getMapSize()); mapArchObject.beginTransaction(); try { - mapArchObject.setState(mapArchObject); + mapArchObject.setState(decoder.getMapArchObject()); } finally { mapArchObject.endTransaction(); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -60,11 +60,15 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.io.CacheFiles; +import net.sf.gridarta.model.io.DefaultMapWriter; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.io.MapArchObjectParserFactory; import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.io.PathManager; +import net.sf.gridarta.model.io.TestGameObjectParser; +import net.sf.gridarta.model.io.TestMapArchObjectParserFactory; import net.sf.gridarta.model.io.TestMapReaderFactory; -import net.sf.gridarta.model.io.TestMapWriter; import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObjectFactory; @@ -232,15 +236,17 @@ final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); + final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); + mapViewSettings = new TestMapViewSettings(); + gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); + final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory, gameObjectMatchers); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, archetypeSet, mapViewSettings); globalSettings = new TestGlobalSettings(); - mapViewSettings = new TestMapViewSettings(); - final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); + final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(globalSettings); - gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); Added: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,93 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 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.mapmanager; + +import java.awt.Point; +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Test; + +/** + * Regression tests for {@link DefaultMapManager}. + * @author Andreas Kirschbaum + */ +public class DefaultMapManagerTest { + + /** + * A map that has been resized must still be revertable. + * @throws IOException if an I/O error occurs + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testRevertResizedMap() throws DuplicateArchetypeException, IOException { + final File file = File.createTempFile("gridarta", null); + try { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final Size2D originalSize = new Size2D(2, 1); + final Size2D newSize = new Size2D(1, 2); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(file, "test", originalSize); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype> mapManager = testMapControlCreator.getMapManager(); + + mapModel.beginTransaction("test"); + try { + testMapControlCreator.insertFloor(mapModel, new Point(1, 0)); + } finally { + mapModel.endTransaction(); + } + mapControl.save(); + TestMapControlCreator.checkMapContents(mapModel, "|floor"); + + mapModel.beginTransaction("test"); + try { + mapModel.resizeMap(newSize); + } finally { + mapModel.endTransaction(); + } + mapModel.beginTransaction("test"); + try { + testMapControlCreator.insertFloor(mapModel, new Point(0, 1)); + } finally { + mapModel.endTransaction(); + } + TestMapControlCreator.checkMapContents(mapModel, "", "floor"); + + mapModel.beginTransaction("test"); + try { + mapManager.revert(mapControl); + } finally { + mapModel.endTransaction(); + } + TestMapControlCreator.checkMapContents(mapModel, "|floor"); + } finally { + //noinspection ResultOfMethodCallIgnored + file.delete(); + } + } + +} // class DefaultMapManagerTest Property changes on: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.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...> - 2010-06-09 10:30:41
|
Revision: 8304 http://gridarta.svn.sourceforge.net/gridarta/?rev=8304&view=rev Author: akirschbaum Date: 2010-06-09 10:30:30 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Merge duplicated fields AbstractMapArchObject.mapSize and DefaultMapModel.mapSize. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -250,6 +250,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<GameObject, MapArchObject, Archetype> errors) { // ignore } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -21,9 +21,14 @@ import java.awt.Point; import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -179,6 +184,9 @@ this.mapSize = mapSize; setModified(); + for (final MapArchObjectListener<A> listener : listenerList.getListeners()) { + listener.mapSizeChanged(mapSize); + } } /** @@ -606,6 +614,43 @@ /** * {@inheritDoc} */ + @Override + public boolean isPointValid(@Nullable final Point pos) { + return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + } + + /** + * {@inheritDoc} + */ + @Override + public <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidMapSquares(@NotNull final Collection<MapSquare<G, A, R>> mapSquares) { + final Iterator<MapSquare<G, A, R>> it = mapSquares.iterator(); + while (it.hasNext()) { + final MapSquare<G, A, R> mapSquare = it.next(); + if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { + it.remove(); + } + } + } + + /** + * {@inheritDoc} + */ + @Override + public <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidGameObjects(@NotNull final Collection<G> gameObjects) { + final Iterator<G> it2 = gameObjects.iterator(); + while (it2.hasNext()) { + final GameObject<G, A, R> gameObject = it2.next(); + final G topGameObject = gameObject.getTopContainer(); + if (topGameObject.getContainer() == null || topGameObject.getMapX() >= mapSize.getWidth() || topGameObject.getMapY() >= mapSize.getHeight()) { + it2.remove(); + } + } + } + + /** + * {@inheritDoc} + */ @NotNull @Override @SuppressWarnings({ "unchecked" }) Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -21,9 +21,14 @@ import java.awt.Point; import java.io.Serializable; +import java.util.Collection; +import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Interface for MapArchObjects. <h4>Enter coordinates</h4> Enter coordinates @@ -281,4 +286,25 @@ */ void updateModifiedAttribute(@NotNull String userName); + /** + * Check whether the given coordinate is within map bounds. + * @param pos the coordinates to check + * @return <code>true</code> if the given coordinates are on the map, + * otherwise <code>false</code> (also returns <code>false</code> if + * <code><var>pos</var> == null</code>) + */ + boolean isPointValid(@Nullable Point pos); + + /** + * Discards map squares that are out of map bounds. + * @param mapSquares the map squares to check + */ + <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidMapSquares(@NotNull Collection<MapSquare<G, A, R>> mapSquares); + + /** + * Discards game objects that are out of map bounds. + * @param gameObjects the game objects to check + */ + <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidGameObjects(@NotNull Collection<G> gameObjects); + } // interface MapArchObject Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -20,6 +20,8 @@ package net.sf.gridarta.model.map.maparchobject; import java.util.EventListener; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; /** * Interface for listeners listening on map arch object changes. @@ -32,4 +34,10 @@ */ void mapMetaChanged(); + /** + * The map size has changed. This callback ignores active map transactions. + * @param mapSize the new map size + */ + void mapSizeChanged(@NotNull Size2D mapSize); + } // interface MapArchObjectListener Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -92,12 +92,6 @@ private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; /** - * Size of this map. - */ - @NotNull - private Size2D mapSize; - - /** * The map, containing all arches grid-wise. Index: [width][height] */ @NotNull @@ -209,6 +203,14 @@ setModified(); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + resizeMapInt(mapSize); + } + }; /** @@ -231,9 +233,8 @@ this.gameObjectMatchers = gameObjectMatchers; this.topmostInsertionMode = topmostInsertionMode; savedSquares = new SavedSquares<G, A, R>(gameObjectFactory, gameObjectMatchers); - mapSize = mapArchObject.getMapSize(); mapArchObject.addMapArchObjectListener(mapArchObjectListener); - mapGrid = new MapSquareGrid<G, A, R>(this, mapSize); + mapGrid = new MapSquareGrid<G, A, R>(this, mapArchObject.getMapSize()); modified = false; } @@ -260,7 +261,7 @@ @NotNull @Override public Size2D getMapSize() { - return mapSize; + return mapArchObject.getMapSize(); } /** @@ -313,7 +314,7 @@ */ @Override public boolean isPointValid(@Nullable final Point pos) { - return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + return mapArchObject.isPointValid(pos); } /** @@ -321,6 +322,15 @@ */ @Override public void resizeMap(@NotNull final Size2D newSize) { + mapArchObject.setMapSize(newSize); + } + + /** + * Resizes the map grid after the map size has changed. + * @param newSize the new map size + */ + private void resizeMapInt(@NotNull final Size2D newSize) { + final Size2D mapSize = mapGrid.getMapSize(); if (newSize.equals(mapSize)) { return; } @@ -346,52 +356,16 @@ node.remove(); } - // Now the critical step: create an GameObject array of new dimension, - // copy all objects and set it to replace the current one. mapGrid.resize(newSize); + mapArchObject.discardInvalidMapSquares(changedSquares); + mapArchObject.discardInvalidGameObjects(changedGameObjects); + mapArchObject.discardInvalidGameObjects(transientChangedGameObjects); - // adjust the map and model attributes - mapSize = newSize; - mapArchObject.setMapSize(newSize); - - discardInvalidMapSquares(changedSquares); - discardInvalidGameObjects(changedGameObjects); - discardInvalidGameObjects(transientChangedGameObjects); - fireMapSizeChanged(newSize); } } /** - * Discards map squares that are out of map bounds. - * @param mapSquares the map squares to check - */ - private void discardInvalidMapSquares(@NotNull final Collection<MapSquare<G, A, R>> mapSquares) { - final Iterator<MapSquare<G, A, R>> it = mapSquares.iterator(); - while (it.hasNext()) { - final MapSquare<G, A, R> mapSquare = it.next(); - if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { - it.remove(); - } - } - } - - /** - * Discards game objects that are out of map bounds. - * @param gameObjects the game objects to check - */ - private void discardInvalidGameObjects(@NotNull final Collection<G> gameObjects) { - final Iterator<G> it2 = gameObjects.iterator(); - while (it2.hasNext()) { - final GameObject<G, A, R> gameObject = it2.next(); - final G topGameObject = gameObject.getTopContainer(); - if (topGameObject.getContainer() == null || topGameObject.getMapX() >= mapSize.getWidth() || topGameObject.getMapY() >= mapSize.getHeight()) { - it2.remove(); - } - } - } - - /** * {@inheritDoc} */ @Override @@ -870,7 +844,7 @@ @Override public void addGameObjectToMap(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final InsertionMode<G, A, R> insertionMode) { if (!isPointValid(pos)) { - log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapSize); + log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapArchObject.getMapSize()); return; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -76,6 +76,7 @@ * Return the map size of this map. * @return map size of this map */ + @Deprecated @NotNull Size2D getMapSize(); @@ -98,6 +99,7 @@ * attached to right and bottom. * @param newSize new map size */ + @Deprecated void resizeMap(@NotNull Size2D newSize); /** @@ -107,6 +109,7 @@ * otherwise <code>false</code> (also returns <code>false</code> if * <code><var>pos</var> == null</code>) */ + @Deprecated boolean isPointValid(@Nullable Point pos); /** Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -169,4 +169,13 @@ } } + /** + * Returns the size of this map grid in map squares. + * @return the size + */ + @NotNull + public Size2D getMapSize() { + return mapSize; + } + } // class MapSquareGrid Modified: trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -138,6 +138,14 @@ result.append("mapMetaChanged"); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -372,6 +372,14 @@ scheduleMapModel(mapModel); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + } } // class DelayedMapModelListenerManager Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -718,6 +718,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -187,6 +187,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -244,6 +244,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -183,6 +183,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -117,6 +117,14 @@ updateTitle(); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -166,6 +166,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -246,6 +246,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -154,6 +154,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -282,6 +282,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -270,6 +270,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -115,6 +115,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -150,6 +150,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -571,6 +571,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:42:25
|
Revision: 8305 http://gridarta.svn.sourceforge.net/gridarta/?rev=8305&view=rev Author: akirschbaum Date: 2010-06-09 10:42:13 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.getMapSize(). Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -467,14 +467,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapSize().getWidth()); + mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapSize().getHeight()); + mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -321,7 +321,7 @@ this.mapViewSettings = mapViewSettings; this.mapModel = mapModel; this.gridMapSquarePainter = gridMapSquarePainter; - mapSize = this.mapModel.getMapSize(); + mapSize = this.mapModel.getMapArchObject().getMapSize(); this.mapGrid = mapGrid; mapViewSettings.addMapViewSettingsListener(mapViewSettingsListener); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -102,7 +102,7 @@ @NotNull @Override public BufferedImage getFullImage() { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int viewWidth = mapSize.getWidth() * IGUIConstants.SQUARE_WIDTH; final int viewHeight = mapSize.getHeight() * IGUIConstants.SQUARE_HEIGHT; final BufferedImage image = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); @@ -123,7 +123,7 @@ */ @Override protected void paintComponent(@NotNull final Graphics g) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); g.setColor(Color.white); g.fillRect(0, 0, mapSize.getWidth() * IGUIConstants.SQUARE_WIDTH, mapSize.getHeight() * IGUIConstants.SQUARE_HEIGHT); final Point point = new Point(); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -430,7 +430,7 @@ @NotNull private Component createMapPanel(@NotNull final MapArchObject map) { final Container panel = new JPanel(new GridBagLayout()); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); addInputFieldLine(panel, mapName, 16, map.getMapName(), "mapName"); addInputFieldLine(panel, mapRegion, 16, map.getRegion(), "mapRegion"); addInputFieldLine(panel, mapWidthField, 10, String.valueOf(mapSize.getWidth()), "mapWidth"); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -459,14 +459,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapSize().getWidth()); + mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapSize().getHeight()); + mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -71,7 +71,7 @@ * @param insertionModeSet the insertion mode set to use */ public void floodFill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point start, @NotNull final List<? extends BaseObject<G, A, R, ?>> archList, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[start.x][start.y] = BORDER; mapModel.beginTransaction("Flood Fill"); // TODO: I18N/L10N Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -258,16 +258,7 @@ /** * {@inheritDoc} */ - @NotNull @Override - public Size2D getMapSize() { - return mapArchObject.getMapSize(); - } - - /** - * {@inheritDoc} - */ - @Override public Iterator<MapSquare<G, A, R>> iterator() { return new MapSquareIterator<G, A, R>(this); } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -73,14 +73,6 @@ void mapClosed(); /** - * Return the map size of this map. - * @return map size of this map - */ - @Deprecated - @NotNull - Size2D getMapSize(); - - /** * Clears this map completely. After invoking this method, no objects will * remain on this map. */ Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -64,7 +64,7 @@ */ MapSquareIterator(@NotNull final MapModel<G, A, R> mapModel) { this.mapModel = mapModel; - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); mapWidth = mapSize.getWidth(); mapHeight = mapSize.getHeight(); } Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -219,7 +219,7 @@ final Point sourcePoint = new Point(); final Point destinationPoint = new Point(); final MapModel<G, A, R> mapModel2 = mapView.getMapControl().getMapModel(); - final Size2D mapModelSize = mapModel.getMapSize(); + final Size2D mapModelSize = mapModel.getMapArchObject().getMapSize(); mapModel2.beginTransaction("Paste"); // TODO: I18N/L10N try { for (final MapSquare<G, A, R> destinationMapSquare : selectedSquares) { Modified: trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -45,6 +45,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -210,10 +211,11 @@ * the coordinates were wrong */ private boolean goLocation() { + final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); final Point point = new Point(); try { - point.x = parseCoordinate(xCoordinateField, mapView.getMapControl().getMapModel().getMapSize().getWidth()); - point.y = parseCoordinate(yCoordinateField, mapView.getMapControl().getMapModel().getMapSize().getHeight()); + point.x = parseCoordinate(xCoordinateField, mapSize.getWidth()); + point.y = parseCoordinate(yCoordinateField, mapSize.getHeight()); } catch (final IllegalArgumentException ignored) { return false; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -585,7 +585,7 @@ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int width = mapSize.getWidth(); final int height = mapSize.getHeight(); final Point point = new Point(xStart, yStart); @@ -1043,7 +1043,7 @@ final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); if (cursorLocation == null) { - final Size2D mapSize = mapView.getMapControl().getMapModel().getMapSize(); + final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); selectExit(mapView, mapSize.getWidth(), mapSize.getHeight() - 1, -1); } else { selectExit(mapView, cursorLocation.x, cursorLocation.y, -1); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -189,7 +189,7 @@ public MapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory) { super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapModel = mapModel; - mapGrid = new MapGrid(this.mapModel.getMapSize()); + mapGrid = new MapGrid(this.mapModel.getMapArchObject().getMapSize()); mapCursor = new MapCursor(mapGrid); if (isPickmap) { setBackground(CommonConstants.BG_COLOR); Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -328,7 +328,7 @@ this.gridMapSquarePainter = gridMapSquarePainter; borderOffset = new Point(borderOffsetX, borderOffsetY); this.mapModel = mapModel; - mapSize = this.mapModel.getMapSize(); + mapSize = this.mapModel.getMapArchObject().getMapSize(); this.mapGrid = mapGrid; this.unknownSquareIcon = unknownSquareIcon; Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -84,7 +84,7 @@ * @param graphics The graphics context to paint to. */ protected void paintComponent2(@NotNull final Graphics2D graphics) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final Rectangle rec = new Rectangle(0, 0, mapSize.getWidth(), mapSize.getHeight()); final Point pos = new Point(); final Point endPos = rec.getLocation(); @@ -125,7 +125,7 @@ * calculated. On non-pickmaps there is an extra border. */ protected void calculateOrigin() { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); origin.setLocation(mapSize.getHeight() * isoMapSquareInfo.getXLen2(), 0); } @@ -146,7 +146,7 @@ public BufferedImage getFullImage() { // set map dimensions for iso view calculateOrigin(); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int sum = mapSize.getWidth() + mapSize.getHeight(); final int viewWidth = sum * isoMapSquareInfo.getXLen2(); final int viewHeight = sum * isoMapSquareInfo.getYLen2(); Modified: trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -51,7 +51,7 @@ * @param shrinkFlags the borders to modify */ public static void shrinkMap(@NotNull final MapModel<?, ?, ?> mapModel, final int shrinkFlags) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); int filledWidth = mapSize.getWidth(); int filledHeight = mapSize.getHeight(); if ((shrinkFlags & SHRINK_EAST) != 0) { @@ -78,7 +78,7 @@ * @return the borders having empty squares */ public static int getShrinkFlags(@NotNull final MapModel<?, ?, ?> mapModel) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); int shrinkFlags = 0; Modified: trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -56,7 +56,7 @@ */ @NotNull protected boolean[][] findMatchingSquares(@NotNull final MapModel<G, A, R> mapModel, @NotNull final GameObjectMatcher matcher) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); final boolean[][] matchingSquares = new boolean[mapWidth][mapHeight]; Modified: trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; /** @@ -45,8 +46,9 @@ * @param mapModel the map model to operate on */ public BlockedMatrix(@NotNull final MapModel<G, A, R> mapModel) { - final int width = mapModel.getMapSize().getWidth(); - final int height = mapModel.getMapSize().getHeight(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + final int width = mapSize.getWidth(); + final int height = mapSize.getHeight(); blocked = new boolean[width][height]; final Point pos = new Point(); for (pos.y = 0; pos.y < height; pos.y++) { Modified: trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -67,7 +67,7 @@ * @return list with all completely blocked squares */ public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> Iterable<MapSquare<G, A, R>> findCompletelyBlockedSquares(@NotNull final MapModel<G, A, R> mapModel) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); // The blockedMatrix is 1 row larger than the map on each border to ease two things: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:53:23
|
Revision: 8308 http://gridarta.svn.sourceforge.net/gridarta/?rev=8308&view=rev Author: akirschbaum Date: 2010-06-09 10:53:11 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.resizeMap(). Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java trunk/src/app/net/sf/gridarta/actions/UndoActions.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -655,7 +655,7 @@ final MapArchObject mapArchObject = mapModel.getMapArchObject(); mapArchObject.beginTransaction(); try { - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setMapName(mapName.getText()); mapArchObject.setRegion(mapRegion.getText()); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -701,7 +701,7 @@ mapArchObject.beginTransaction(); try { final String mapNameString = mapName.getText(); - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setLore(mapLore.getText()); mapArchObject.setMapName(mapNameString); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -646,7 +646,7 @@ final MapArchObject mapArchObject = mapModel.getMapArchObject(); mapArchObject.beginTransaction(); try { - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setMapName(mapName.getText()); mapArchObject.setBackgroundMusic(mapBackgroundMusic.getText()); Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -309,14 +309,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void resizeMap(@NotNull final Size2D newSize) { - mapArchObject.setMapSize(newSize); - } - - /** * Resizes the map grid after the map size has changed. * @param newSize the new map size */ Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -28,7 +28,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -86,15 +85,6 @@ boolean isEmpty(); /** - * Resize this map to the new size. If any bounds are smaller than before, - * the map gets cut on the right and bottom side. Accordingly, new space is - * attached to right and bottom. - * @param newSize new map size - */ - @Deprecated - void resizeMap(@NotNull Size2D newSize); - - /** * Check whether the given coordinate is within map bounds. * @param pos the coordinates to check * @return <code>true</code> if the given coordinates are on the map, Modified: trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -186,57 +186,61 @@ } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); Assert.assertEquals("", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap3() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); - mapModel.resizeMap(new Size2D(1, 2)); // cancels square changed event + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap4() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -246,7 +250,7 @@ gameObject.setAttributeString("key", "value"); } addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); - mapModel.resizeMap(new Size2D(1, 2)); // cancels square changed event + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } @@ -258,7 +262,7 @@ @Test public void testAddGameObjectToMap1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); @@ -275,7 +279,7 @@ @Test public void testAddGameObjectToMap2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); @@ -293,7 +297,7 @@ @Test public void testModifiedGameObject1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -312,7 +316,7 @@ @Test public void testModifiedGameObject2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -340,7 +344,7 @@ archetype.addTailPart(archetype2); mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(1, 2)); + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); final TestGameObject gameObject = mapModel.insertBaseObject(archetype, new Point(0, 0), true, false, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); Modified: trunk/src/app/net/sf/gridarta/actions/UndoActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/actions/UndoActions.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/actions/UndoActions.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -50,8 +50,8 @@ mapModel.beginTransaction(undoState.getName()); try { final A newMapArchObject = undoState.getMapArchObject(); - mapModel.resizeMap(newMapArchObject.getMapSize()); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.setMapSize(newMapArchObject.getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(newMapArchObject); @@ -78,8 +78,8 @@ mapModel.beginTransaction(undoState.getName()); try { final A newMapArchObject = undoState.getMapArchObject(); - mapModel.resizeMap(newMapArchObject.getMapSize()); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.setMapSize(newMapArchObject.getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(newMapArchObject); Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -67,7 +67,7 @@ /** {@inheritDoc} */ @Override public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void prepare(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D mapSize) { - mapModel.resizeMap(mapSize); + mapModel.getMapArchObject().setMapSize(mapSize); mapModel.clearMap(); } @@ -95,7 +95,7 @@ /** {@inheritDoc} */ @Override public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void prepare(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D mapSize) { - mapModel.resizeMap(mapSize); + mapModel.getMapArchObject().setMapSize(mapSize); mapModel.clearMap(); } Modified: trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -66,7 +66,7 @@ } mapModel.beginTransaction("Shrink Map Size"); try { - mapModel.resizeMap(new Size2D(filledWidth, filledHeight)); + mapModel.getMapArchObject().setMapSize(new Size2D(filledWidth, filledHeight)); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -351,7 +351,7 @@ final A mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("revert"); try { - mapModel.resizeMap(decoder.getMapArchObject().getMapSize()); + mapArchObject.setMapSize(decoder.getMapArchObject().getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(decoder.getMapArchObject()); Modified: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -65,7 +65,7 @@ mapModel.beginTransaction("test"); try { - mapModel.resizeMap(newSize); + mapModel.getMapArchObject().setMapSize(newSize); } finally { mapModel.endTransaction(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 11:00:50
|
Revision: 8309 http://gridarta.svn.sourceforge.net/gridarta/?rev=8309&view=rev Author: akirschbaum Date: 2010-06-09 11:00:38 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.isPointValid(). Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -225,10 +225,11 @@ */ private void getSquaresToRepaint(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> mapSquare, @NotNull final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint) { if (mapViewSettings.isSmoothing()) { + final MapArchObject mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); for (point.x = mapSquare.getMapX() - 1; point.x <= mapSquare.getMapX() + 1; point.x++) { for (point.y = mapSquare.getMapY() - 1; point.y <= mapSquare.getMapY() + 1; point.y++) { - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { toRepaint.add(mapModel.getMapSquare(point)); } } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -166,7 +166,7 @@ */ @Override protected void updateSquare(@NotNull final Point point) { - if (!mapModel.isPointValid(point)) { + if (!mapModel.getMapArchObject().isPointValid(point)) { return; } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -86,11 +86,12 @@ */ public void paintSmooth(@NotNull final Graphics graphics, final int x, final int y, final int level, final int layer, final boolean allLayers, @NotNull final Point borderOffset) { final net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[][] layerNode = { new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3], new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3], new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3] }; + final MapArchObject mapArchObject = mapModel.getMapArchObject(); boolean foundLayer = false; for (int deltaX = -1; deltaX <= 1; deltaX++) { for (int deltaY = -1; deltaY <= 1; deltaY++) { final Point where = new Point(x + deltaX, y + deltaY); - if (mapModel.isPointValid(where)) { + if (mapArchObject.isPointValid(where)) { int currentLayer = -1; for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> node : mapModel.getMapSquare(where)) { if (node.getAttributeInt("invisible", true) == 0) { Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -113,7 +113,7 @@ } private int joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir, final int reverseDir) { - if (!mapModel.isPointValid(new Point(point.x + dx, point.y + dy))) { + if (!mapModel.getMapArchObject().isPointValid(new Point(point.x + dx, point.y + dy))) { return 0; } @@ -156,7 +156,7 @@ } private void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir) { - if (!mapModel.isPointValid(new Point(point.x + dx, point.y + dy))) { + if (!mapModel.getMapArchObject().isPointValid(new Point(point.x + dx, point.y + dy))) { return; } Modified: trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -59,7 +59,7 @@ */ @Nullable public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { + if (point == null || !mapModel.getMapArchObject().isPointValid(point)) { return null; } for (final GameObject<G, A, R> part : mapModel.getMapSquare(point)) { @@ -99,7 +99,7 @@ */ @Nullable public BaseObject<G, A, R, ?> getExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { + if (point == null || !mapModel.getMapArchObject().isPointValid(point)) { return null; } for (final GameObject<G, A, R> part : mapModel.getMapSquare(point)) { Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -86,7 +86,7 @@ return; } - if (!mapModel.isPointValid(start) || !mapModel.getMapSquare(start).isEmpty()) { + if (!mapModel.getMapArchObject().isPointValid(start) || !mapModel.getMapSquare(start).isEmpty()) { return; } Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -71,7 +71,8 @@ * @param insertionModeSet the insertion mode set to use */ public void floodFill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point start, @NotNull final List<? extends BaseObject<G, A, R, ?>> archList, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { - final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + final Size2D mapSize = mapArchObject.getMapSize(); final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[start.x][start.y] = BORDER; mapModel.beginTransaction("Flood Fill"); // TODO: I18N/L10N @@ -83,7 +84,7 @@ for (p.y = 0; p.y < mapSize.getHeight(); p.y++) { if (area[p.x][p.y] == BORDER) { border--; - if (mapModel.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { + if (mapArchObject.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { area[p.x][p.y] = WAS_EMPTY; final BaseObject<G, A, R, ?> gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); mapModel.insertBaseObject(gameObject, p, false, false, insertionModeSet.getTopmostInsertionMode()); Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -301,14 +301,6 @@ } /** - * {@inheritDoc} - */ - @Override - public boolean isPointValid(@Nullable final Point pos) { - return mapArchObject.isPointValid(pos); - } - - /** * Resizes the map grid after the map size has changed. * @param newSize the new map size */ @@ -680,7 +672,7 @@ final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); // outside map - if (!isPointValid(point)) { + if (!mapArchObject.isPointValid(point)) { return false; } @@ -725,7 +717,7 @@ @Override public G insertArchToMap(@NotNull final BaseObject<G, A, R, ?> templateGameObject, @Nullable final G nextGameObject, @NotNull final Point pos, final boolean join) { // map coords must be valid - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { return null; } @@ -767,7 +759,7 @@ @Nullable @Override public G insertBaseObject(@NotNull final BaseObject<G, A, R, ?> baseObject, @NotNull final Point pos, final boolean allowMany, final boolean join, @NotNull final InsertionMode<G, A, R> insertionMode) { - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { return null; } @@ -826,7 +818,7 @@ */ @Override public void addGameObjectToMap(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final InsertionMode<G, A, R> insertionMode) { - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapArchObject.getMapSize()); return; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -85,16 +85,6 @@ boolean isEmpty(); /** - * Check whether the given coordinate is within map bounds. - * @param pos the coordinates to check - * @return <code>true</code> if the given coordinates are on the map, - * otherwise <code>false</code> (also returns <code>false</code> if - * <code><var>pos</var> == null</code>) - */ - @Deprecated - boolean isPointValid(@Nullable Point pos); - - /** * Returns the Map Arch Object with the meta information about the map. * @return the Map Arch Object with the meta information about the map */ Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -179,12 +179,13 @@ */ public void paste(@NotNull final MapView<G, A, R> mapView, @NotNull final Point startLocation) { final MapModel<G, A, R> mapModel2 = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel2.getMapArchObject(); mapModel2.beginTransaction("Paste"); // TODO: I18N/L10N try { final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapModel) { pos.setLocation(startLocation.x + square.getMapX(), startLocation.y + square.getMapY()); - if (mapModel2.isPointValid(pos)) { + if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (!gameObject.isMulti()) { mapModel2.insertBaseObject(gameObject, pos, true, false, insertionModeSet.getTopmostInsertionMode()); @@ -196,7 +197,7 @@ for (final MapSquare<G, A, R> square : mapModel) { pos.setLocation(startLocation); pos.translate(square.getMapX(), square.getMapY()); - if (mapModel2.isPointValid(pos)) { + if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (gameObject.isMulti()) { mapModel2.insertBaseObject(gameObject, pos, true, false, insertionModeSet.getTopmostInsertionMode()); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -753,7 +753,7 @@ */ private void showLocation(@NotNull final MapView<G, A, R> mapView, @NotNull final Point point) { final Point point2 = point.x == -1 && point.y == -1 ? mapView.getMapControl().getMapModel().getMapArchObject().getEnter() : point; - if (!mapView.getMapControl().getMapModel().isPointValid(point2)) { + if (!mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(point2)) { ACTION_BUILDER.showMessageDialog(parent, "enterExitOutside"); return; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -183,6 +183,7 @@ } final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("Insert Object"); try { @Nullable final G insertedObject; @@ -196,7 +197,7 @@ for (R part = head.getArchetype(); part != null; part = part.getMultiNext()) { point.x = p.x + part.getMultiX(); point.y = p.y + part.getMultiY(); - if (!mapModel.isPointValid(point) || !mapModel.getMapSquare(point).isEmpty()) { + if (!mapArchObject.isPointValid(point) || !mapModel.getMapSquare(point).isEmpty()) { return; } } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -119,7 +119,7 @@ return false; } - return !mapView.getMapControl().getMapModel().isPointValid(new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY())) && setMapSquare(null, null, 0); + return !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY())) && setMapSquare(null, null, 0); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -289,7 +289,7 @@ final MapControl<G, A, R> mapControl = mapView.getMapControl(); final Point cursorPos = e.getSource().getLocation(); - if (cursorPos == null || !mapControl.getMapModel().isPointValid(cursorPos)) { + if (cursorPos == null || !mapControl.getMapModel().getMapArchObject().isPointValid(cursorPos)) { if (selectedSquareModel.setSelectedMapSquare(null, null, 0)) { refresh(); } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -1300,6 +1300,7 @@ newSelection.put(mapSquare, null); } final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); while (!todo.isEmpty()) { final Map<MapSquare<G, A, R>, Void> tmp = new IdentityHashMap<MapSquare<G, A, R>, Void>(); @@ -1309,7 +1310,7 @@ for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { final MapSquare<G, A, R> newMapSquare = mapModel.getMapSquare(point); if (newMapSquare.isEmpty() && !newSelection.containsKey(newMapSquare)) { tmp.put(newMapSquare, null); @@ -1358,6 +1359,7 @@ if (performAction) { final MapGrid mapGrid = mapViewBasic.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); mapGrid.beginTransaction(); try { @@ -1366,7 +1368,7 @@ point.y = mapSquare.getMapY() + dy; for (int dx = -1; dx <= 1; dx++) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { mapGrid.select(point, point, SelectionMode.ADD); } } @@ -1400,6 +1402,7 @@ if (performAction) { final MapGrid mapGrid = mapViewBasic.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); final Map<MapSquare<G, A, R>, Void> mapSquaresToShrink = new IdentityHashMap<MapSquare<G, A, R>, Void>(); mapGrid.beginTransaction(); @@ -1411,7 +1414,7 @@ for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { + if (mapArchObject.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { mapSquaresToShrink.put(mapSquare, null); break LOOP; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 17:40:45
|
Revision: 8316 http://gridarta.svn.sourceforge.net/gridarta/?rev=8316&view=rev Author: akirschbaum Date: 2010-06-09 17:40:38 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Separate MapModelListener and MapArchObjectListener. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModelListener.java trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -243,22 +243,6 @@ * {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override public void errorsChanged(@NotNull final ErrorCollector<GameObject, MapArchObject, Archetype> errors) { // ignore } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -346,7 +346,6 @@ @Override public void addMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { mapModelListeners.add(listener); - mapArchObject.addMapArchObjectListener(listener); } /** @@ -355,7 +354,6 @@ @Override public void removeMapModelListener(@NotNull final MapModelListener<G, A, R> listener) { mapModelListeners.remove(listener); - mapArchObject.removeMapArchObjectListener(listener); } /** Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModelListener.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModelListener.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModelListener.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -20,11 +20,11 @@ package net.sf.gridarta.model.map.mapmodel; import java.io.File; +import java.util.EventListener; import java.util.Set; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; -import net.sf.gridarta.model.map.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -34,7 +34,7 @@ * Interface for listeners listening on {@link MapModel} events. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public interface MapModelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends MapArchObjectListener { +public interface MapModelListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends EventListener { /** * The size of a map has changed. Modified: trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -42,6 +42,7 @@ import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; @@ -129,7 +130,15 @@ public void modifiedChanged(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel) { // ignore } + }; + /** + * The {@link MapArchObjectListener} registered to {@link #mapModel} to + * record map changes. + */ + @NotNull + private final MapArchObjectListener mapArchObjectListener = new MapArchObjectListener() { + /** * {@inheritDoc} */ @@ -450,6 +459,7 @@ result.setLength(0); mapModel.addMapModelListener(mapModelListener); + mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); Assert.assertEquals("", result.toString()); } Modified: trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -30,6 +30,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.mapmodel.MapModelListener; @@ -75,6 +76,13 @@ private final Map<MapModel<G, A, R>, MapModelListenerImpl> mapModelListeners = new IdentityHashMap<MapModel<G, A, R>, MapModelListenerImpl>(); /** + * All known {@link MapModel} instances. Maps map model instance to attached + * {@link MapArchObjectListenerImpl} instance. + */ + @NotNull + private final Map<MapModel<G, A, R>, MapArchObjectListenerImpl> mapArchObjectListeners = new IdentityHashMap<MapModel<G, A, R>, MapArchObjectListenerImpl>(); + + /** * The timestamp when to deliver scheduled map models. Set to zero when not * active. */ @@ -118,6 +126,9 @@ final MapModelListenerImpl mapModelListener = new MapModelListenerImpl(mapModel); mapModel.addMapModelListener(mapModelListener); mapModelListeners.put(mapModel, mapModelListener); + final MapArchObjectListenerImpl mapArchObjectListener = new MapArchObjectListenerImpl(mapModel); + mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); + mapArchObjectListeners.put(mapModel, mapArchObjectListener); scheduleMapModel(mapModel); } @@ -135,6 +146,10 @@ if (mapModelListener != null) { mapModel.removeMapModelListener(mapModelListener); } + final MapArchObjectListener mapArchObjectListener = mapArchObjectListeners.remove(mapModel); + if (mapArchObjectListener != null) { + mapModel.getMapArchObject().removeMapArchObjectListener(mapArchObjectListener); + } synchronized (sync) { scheduledMapModels.remove(mapControl.getMapModel()); } @@ -364,7 +379,29 @@ // ignore } + } + + /** + * A {@link MapArchObjectListener} attached to all existing maps. It calls + * {@link DelayedMapModelListenerManager#scheduleMapModel(MapModel)} for all + * map changes. + */ + private class MapArchObjectListenerImpl implements MapArchObjectListener { + /** + * The tracked {@link MapModel} instance. + */ + private final MapModel<G, A, R> mapModel; + + /** + * Creates a new instance. + * @param mapModel the map model to track + */ + private MapArchObjectListenerImpl(@NotNull final MapModel<G, A, R> mapModel) { + this.mapModel = mapModel; + } + + /** * {@inheritDoc} */ @Override Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -712,20 +712,6 @@ // ignore } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -183,20 +183,6 @@ /** {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** {@inheritDoc} */ - @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -240,20 +240,6 @@ /** {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** {@inheritDoc} */ - @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -177,20 +177,6 @@ updateActions(); } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -33,6 +33,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.map.mapcontrol.DefaultMapControl; import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapcontrol.MapControlListener; @@ -113,36 +114,44 @@ /** {@inheritDoc} */ @Override - public void mapMetaChanged() { - updateTitle(); - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } /** {@inheritDoc} */ @Override - public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { - // ignore + public void mapFileChanged(@Nullable final File oldMapFile) { + updateTitle(); } /** {@inheritDoc} */ @Override - public void mapFileChanged(@Nullable final File oldMapFile) { + public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { updateTitle(); } + }; + + /** + * The {@link MapArchObjectListener} used to detect changes in the map model + * that should be reflected in the window title. + */ + private final MapArchObjectListener mapArchObjectListener = new MapArchObjectListener() { + /** {@inheritDoc} */ @Override - public void modifiedChanged(@NotNull final MapModel<G, A, R> mapModel) { + public void mapMetaChanged() { updateTitle(); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** @@ -172,7 +181,9 @@ this.number = number; this.mapViewBasic = mapViewBasic; this.pathManager = pathManager; - mapControl.getMapModel().addMapModelListener(mapModelListener); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.addMapModelListener(mapModelListener); + mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); mapControl.addMapControlListener(mapControlListener); getContentPane().setLayout(new BorderLayout()); getContentPane().add(mapViewBasic, BorderLayout.CENTER); @@ -187,7 +198,9 @@ getContentPane().remove(mapViewBasic); mapViewBasic.closeNotify(); mapControl.removeMapControlListener(mapControlListener); - mapControl.getMapModel().removeMapModelListener(mapModelListener); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.getMapArchObject().removeMapArchObjectListener(mapArchObjectListener); + mapModel.removeMapModelListener(mapModelListener); //mapFileActions.closeNotify(); MenuUtils.disposeMenuElement(getJMenuBar()); } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -160,20 +160,6 @@ // ignore } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -238,22 +238,6 @@ * {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -148,20 +148,6 @@ updateName(); } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -274,22 +274,6 @@ * {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -264,20 +264,6 @@ refresh(); } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -109,20 +109,6 @@ } } - /** {@inheritDoc} */ - @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - }; /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -146,20 +146,6 @@ /** {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** {@inheritDoc} */ - @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 16:50:25 UTC (rev 8315) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 17:40:38 UTC (rev 8316) @@ -567,20 +567,6 @@ /** {@inheritDoc} */ @Override - public void mapMetaChanged() { - // ignore - } - - /** - * {@inheritDoc} - */ - @Override - public void mapSizeChanged(@NotNull final Size2D mapSize) { - // ignore - } - - /** {@inheritDoc} */ - @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { // ignore } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 17:46:32
|
Revision: 8317 http://gridarta.svn.sourceforge.net/gridarta/?rev=8317&view=rev Author: akirschbaum Date: 2010-06-09 17:46:25 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Rewrite expressions. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/model/src/app/net/sf/gridarta/model/io/AnimationObjectsReader.java trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatcherParser.java trunk/textedit/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java trunk/textedit/src/app/net/sf/gridarta/textedit/textarea/actions/FunctionMenu.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -707,7 +707,7 @@ } final int r = Integer.parseInt(s); // trying to parse // negative values are not allowed - if (r < 0 && !"Darkness".equals(label)) { + if (r < 0 && !label.equals("Darkness")) { throw new IllegalArgumentException(label + ": '" + s + "' is negative."); } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -696,7 +696,7 @@ } final int r = Integer.parseInt(s); // trying to parse // negative values are not allowed - if (r < 0 && !"Darkness".equals(label)) { + if (r < 0 && !label.equals("Darkness")) { throw new IllegalArgumentException(label + ": '" + s + "' is negative."); } Modified: trunk/model/src/app/net/sf/gridarta/model/io/AnimationObjectsReader.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/io/AnimationObjectsReader.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/model/src/app/net/sf/gridarta/model/io/AnimationObjectsReader.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -160,7 +160,7 @@ /* ignore comment lines. */ } else if (line4.startsWith(startKey)) { throw new AnimationParseException("mina", line4, lineNumber); - } else if ("mina".equals(line4)) { + } else if (line4.equals("mina")) { processAnimationLine(animationObjects, errorViewCollector, path, animations, animName, animText.toString()); break; } else { Modified: trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatcherParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatcherParser.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/model/src/app/net/sf/gridarta/model/match/GameObjectMatcherParser.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -64,7 +64,7 @@ public NamedGameObjectMatcher parseMatcher(@NotNull final Element el, final int editType) throws ParsingException { final String currentLanguage = Locale.getDefault().getLanguage(); final String localName = el.getLocalName(); - if (!"GameObjectMatcher".equals(localName)) { + if (localName == null || !localName.equals("GameObjectMatcher")) { throw new ParsingException("wrong local element name: expected \"GameObjectMatcher\" but got \" + localName + \""); } final String id = el.getAttribute("id"); @@ -117,13 +117,15 @@ @NotNull private static GameObjectMatcher createMatcher(@NotNull final Element el) throws ParsingException { final String localName = el.getLocalName(); - if ("TypeNrs".equals(localName)) { + if (localName == null) { + // ignore + } else if (localName.equals("TypeNrs")) { return createTypeNrsArchObjectMatcher(el); - } else if ("Attrib".equals(localName)) { + } else if (localName.equals("Attrib")) { return createAttributeArchObjectMatcher(el); - } else if ("Or".equals(localName)) { + } else if (localName.equals("Or")) { return createOrMatcher(el); - } else if ("And".equals(localName)) { + } else if (localName.equals("And")) { return createAndMatcher(el); } throw new ParsingException("expected element node name to be one of \"TypeNrs\", \"Attrib\", \"Or\", \"And\"."); Modified: trunk/textedit/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java =================================================================== --- trunk/textedit/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/textedit/src/app/net/sf/gridarta/textedit/scripteditor/ScriptEditControl.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -340,7 +340,7 @@ // get stored path final String path = tabs.get(view.getSelectedIndex()); - if (path == null || path.length() == 0 || "<>".equals(path)) { + if (path == null || path.length() == 0 || path.equals("<>")) { return null; } else { return path; Modified: trunk/textedit/src/app/net/sf/gridarta/textedit/textarea/actions/FunctionMenu.java =================================================================== --- trunk/textedit/src/app/net/sf/gridarta/textedit/textarea/actions/FunctionMenu.java 2010-06-09 17:40:38 UTC (rev 8316) +++ trunk/textedit/src/app/net/sf/gridarta/textedit/textarea/actions/FunctionMenu.java 2010-06-09 17:46:25 UTC (rev 8317) @@ -58,7 +58,7 @@ if (caretPos >= 7 && cfPythonPopup.isInitialized()) { final String fileName = textArea.getDocument().getText(textArea.getCaretPosition() - 9, 8); - if ("cfpython".equalsIgnoreCase(fileName)) { + if (fileName.equalsIgnoreCase("cfpython")) { final int line = textArea.getCaretLine(); final int offset = textArea.getCaretPosition() - textArea.getLineStartOffset(line); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 18:41:47
|
Revision: 8319 http://gridarta.svn.sourceforge.net/gridarta/?rev=8319&view=rev Author: akirschbaum Date: 2010-06-09 18:41:40 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Select text field contents in map properties dialog when they gain focus. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:47:21 UTC (rev 8318) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 18:41:40 UTC (rev 8319) @@ -35,7 +35,6 @@ import javax.swing.JCheckBox; import javax.swing.JComponent; import javax.swing.JDialog; -import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -52,6 +51,7 @@ import net.sf.gridarta.gui.map.maptilepane.AbstractMapTilePane; import net.sf.gridarta.gui.map.maptilepane.IsoMapTilePane; import net.sf.gridarta.gui.utils.GUIConstants; +import net.sf.gridarta.gui.utils.TextComponentUtils; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; @@ -141,14 +141,14 @@ * @serial */ @NotNull - private final JFormattedTextField mapWidthField = new JFormattedTextField(); + private final JTextField mapWidthField = new JTextField(); /** * The height in squares. * @serial */ @NotNull - private final JFormattedTextField mapHeightField = new JFormattedTextField(); + private final JTextField mapHeightField = new JTextField(); /** * The outdoor attribute. @@ -162,42 +162,42 @@ * @serial */ @NotNull - private final JFormattedTextField fieldEnterX = new JFormattedTextField(); + private final JTextField fieldEnterX = new JTextField(); /** * The enter y attribute. * @serial */ @NotNull - private final JFormattedTextField fieldEnterY = new JFormattedTextField(); + private final JTextField fieldEnterY = new JTextField(); /** * The swap time attribute. * @serial */ @NotNull - private final JFormattedTextField fieldSwapTime = new JFormattedTextField(); + private final JTextField fieldSwapTime = new JTextField(); /** * The reset timeout attribute. * @serial */ @NotNull - private final JFormattedTextField fieldResetTimeout = new JFormattedTextField(); + private final JTextField fieldResetTimeout = new JTextField(); /** * The map difficulty attribute. * @serial */ @NotNull - private final JFormattedTextField fieldDifficulty = new JFormattedTextField(); + private final JTextField fieldDifficulty = new JTextField(); /** * The map darkness attribute. * @serial */ @NotNull - private final JFormattedTextField fieldDarkness = new JFormattedTextField(); + private final JTextField fieldDarkness = new JTextField(); /** * The fixed reset attribute. @@ -347,6 +347,19 @@ final Container layoutHack = new JPanel(new BorderLayout()); layoutHack.add(tabs); setMessage(layoutHack); + + TextComponentUtils.setAutoSelectOnFocus(mapDescription); + TextComponentUtils.setAutoSelectOnFocus(mapName); + TextComponentUtils.setAutoSelectOnFocus(mapRegion); + TextComponentUtils.setAutoSelectOnFocus(mapBackgroundMusic); + TextComponentUtils.setAutoSelectOnFocus(mapWidthField); + TextComponentUtils.setAutoSelectOnFocus(mapHeightField); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterX); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterY); + TextComponentUtils.setAutoSelectOnFocus(fieldSwapTime); + TextComponentUtils.setAutoSelectOnFocus(fieldResetTimeout); + TextComponentUtils.setAutoSelectOnFocus(fieldDifficulty); + TextComponentUtils.setAutoSelectOnFocus(fieldDarkness); } /** @@ -467,14 +480,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); + mapWidthField.setText(Integer.toString(mapModel.getMapArchObject().getMapSize().getWidth())); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); + mapHeightField.setText(Integer.toString(mapModel.getMapArchObject().getMapSize().getHeight())); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); @@ -573,18 +586,18 @@ * @return the created panel */ @NotNull - private static Component createPanelLine(@NotNull final JFormattedTextField textField, final int n, final int defaultValue, @NotNull final String labelKey) { + private static Component createPanelLine(@NotNull final JTextField textField, final int n, final int defaultValue, @NotNull final String labelKey) { final Container lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); lineLayout.add(new JLabel(ACTION_BUILDER.getString(labelKey))); textField.setColumns(n); - textField.setValue(defaultValue); + textField.setText(Integer.toString(defaultValue)); lineLayout.add(textField); return lineLayout; } /** * Creates a checkbox-line, similar to {@link - * #createPanelLine(JFormattedTextField, int, int, String)}. + * #createPanelLine(JTextField, int, int, String)}. * @param checkBox the checkbox * @param state the initial state * @param labelKey the (attribute-)label key Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:47:21 UTC (rev 8318) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 18:41:40 UTC (rev 8319) @@ -30,7 +30,6 @@ import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JDialog; -import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -44,6 +43,7 @@ import net.sf.gridarta.gui.help.Help; import net.sf.gridarta.gui.map.maptilepane.AbstractMapTilePane; import net.sf.gridarta.gui.map.maptilepane.FlatMapTilePane; +import net.sf.gridarta.gui.utils.TextComponentUtils; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; @@ -163,14 +163,14 @@ * @serial */ @NotNull - private final JTextField mapWidthField = new JFormattedTextField(); + private final JTextField mapWidthField = new JTextField(); /** * The height in squares. * @serial */ @NotNull - private final JTextField mapHeightField = new JFormattedTextField(); + private final JTextField mapHeightField = new JTextField(); /** * The unique attribute. @@ -198,49 +198,49 @@ * @serial */ @NotNull - private final JTextField fieldEnterX = new JFormattedTextField(); + private final JTextField fieldEnterX = new JTextField(); /** * The enter y attribute. * @serial */ @NotNull - private final JTextField fieldEnterY = new JFormattedTextField(); + private final JTextField fieldEnterY = new JTextField(); /** * The swap time. * @serial */ @NotNull - private final JTextField fieldSwapTime = new JFormattedTextField(); + private final JTextField fieldSwapTime = new JTextField(); /** * The reset timeout. * @serial */ @NotNull - private final JTextField fieldResetTimeout = new JFormattedTextField(); + private final JTextField fieldResetTimeout = new JTextField(); /** * The background music. * @serial */ @NotNull - private final JTextField fieldBackgroundMusic = new JFormattedTextField(); + private final JTextField fieldBackgroundMusic = new JTextField(); /** * The map difficulty. * @serial */ @NotNull - private final JTextField fieldDifficulty = new JFormattedTextField(); + private final JTextField fieldDifficulty = new JTextField(); /** * The map darkness. * @serial */ @NotNull - private final JTextField fieldDarkness = new JFormattedTextField(); + private final JTextField fieldDarkness = new JTextField(); /** * The fixed reset attribute. @@ -261,21 +261,21 @@ * @serial */ @NotNull - private final JTextField fieldShopgreed = new JFormattedTextField(); + private final JTextField fieldShopgreed = new JTextField(); /** * The shop maximum price. * @serial */ @NotNull - private final JTextField fieldShopMax = new JFormattedTextField(); + private final JTextField fieldShopMax = new JTextField(); /** * The shop minimum price. * @serial */ @NotNull - private final JTextField fieldShopMin = new JFormattedTextField(); + private final JTextField fieldShopMin = new JTextField(); /** * The shop's preferred race. @@ -289,42 +289,42 @@ * @serial */ @NotNull - private final JTextField fieldTemperature = new JFormattedTextField(); + private final JTextField fieldTemperature = new JTextField(); /** * The pressure. * @serial */ @NotNull - private final JTextField fieldPressure = new JFormattedTextField(); + private final JTextField fieldPressure = new JTextField(); /** * The humidity. * @serial */ @NotNull - private final JTextField fieldHumidity = new JFormattedTextField(); + private final JTextField fieldHumidity = new JTextField(); /** * The wind speed. * @serial */ @NotNull - private final JTextField fieldWindSpeed = new JFormattedTextField(); + private final JTextField fieldWindSpeed = new JTextField(); /** * The wind direction. * @serial */ @NotNull - private final JTextField fieldWindDirection = new JFormattedTextField(); + private final JTextField fieldWindDirection = new JTextField(); /** * The sky settings. * @serial */ @NotNull - private final JTextField fieldSkySetting = new JFormattedTextField(); + private final JTextField fieldSkySetting = new JTextField(); /** * The button for ok. @@ -420,6 +420,31 @@ final Container layoutHack = new JPanel(new BorderLayout()); layoutHack.add(tabs); setMessage(layoutHack); + + TextComponentUtils.setAutoSelectOnFocus(mapDescription); + TextComponentUtils.setAutoSelectOnFocus(mapLore); + TextComponentUtils.setAutoSelectOnFocus(mapName); + TextComponentUtils.setAutoSelectOnFocus(mapRegion); + TextComponentUtils.setAutoSelectOnFocus(mapWidthField); + TextComponentUtils.setAutoSelectOnFocus(mapHeightField); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterX); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterY); + TextComponentUtils.setAutoSelectOnFocus(fieldSwapTime); + TextComponentUtils.setAutoSelectOnFocus(fieldResetTimeout); + TextComponentUtils.setAutoSelectOnFocus(fieldBackgroundMusic); + TextComponentUtils.setAutoSelectOnFocus(fieldDifficulty); + TextComponentUtils.setAutoSelectOnFocus(fieldDarkness); + TextComponentUtils.setAutoSelectOnFocus(fieldShopItems); + TextComponentUtils.setAutoSelectOnFocus(fieldShopgreed); + TextComponentUtils.setAutoSelectOnFocus(fieldShopMax); + TextComponentUtils.setAutoSelectOnFocus(fieldShopMin); + TextComponentUtils.setAutoSelectOnFocus(fieldShopRace); + TextComponentUtils.setAutoSelectOnFocus(fieldTemperature); + TextComponentUtils.setAutoSelectOnFocus(fieldPressure); + TextComponentUtils.setAutoSelectOnFocus(fieldHumidity); + TextComponentUtils.setAutoSelectOnFocus(fieldWindSpeed); + TextComponentUtils.setAutoSelectOnFocus(fieldWindDirection); + TextComponentUtils.setAutoSelectOnFocus(fieldSkySetting); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 17:47:21 UTC (rev 8318) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 18:41:40 UTC (rev 8319) @@ -36,7 +36,6 @@ import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFileChooser; -import javax.swing.JFormattedTextField; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; @@ -53,6 +52,7 @@ import net.sf.gridarta.gui.map.maptilepane.AbstractMapTilePane; import net.sf.gridarta.gui.map.maptilepane.IsoMapTilePane; import net.sf.gridarta.gui.utils.GUIConstants; +import net.sf.gridarta.gui.utils.TextComponentUtils; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; @@ -142,14 +142,14 @@ * @serial */ @NotNull - private final JFormattedTextField mapWidthField = new JFormattedTextField(); + private final JTextField mapWidthField = new JTextField(); /** * The height in squares. * @serial */ @NotNull - private final JFormattedTextField mapHeightField = new JFormattedTextField(); + private final JTextField mapHeightField = new JTextField(); /** * The "outdoor" attribute. @@ -163,42 +163,42 @@ * @serial */ @NotNull - private final JFormattedTextField fieldEnterX = new JFormattedTextField(); + private final JTextField fieldEnterX = new JTextField(); /** * The enter y coordinate. * @serial */ @NotNull - private final JFormattedTextField fieldEnterY = new JFormattedTextField(); + private final JTextField fieldEnterY = new JTextField(); /** * The swap time. * @serial */ @NotNull - private final JFormattedTextField fieldSwapTime = new JFormattedTextField(); + private final JTextField fieldSwapTime = new JTextField(); /** * The reset timeout. * @serial */ @NotNull - private final JFormattedTextField fieldResetTimeout = new JFormattedTextField(); + private final JTextField fieldResetTimeout = new JTextField(); /** * The map difficulty. * @serial */ @NotNull - private final JFormattedTextField fieldDifficulty = new JFormattedTextField(); + private final JTextField fieldDifficulty = new JTextField(); /** * The map darkness. * @serial */ @NotNull - private final JFormattedTextField fieldDarkness = new JFormattedTextField(); + private final JTextField fieldDarkness = new JTextField(); /** * The fixed reset attribute. @@ -342,6 +342,18 @@ final Container layoutHack = new JPanel(new BorderLayout()); layoutHack.add(tabs); setMessage(layoutHack); + + TextComponentUtils.setAutoSelectOnFocus(mapDescription); + TextComponentUtils.setAutoSelectOnFocus(mapName); + TextComponentUtils.setAutoSelectOnFocus(mapBackgroundMusic); + TextComponentUtils.setAutoSelectOnFocus(mapWidthField); + TextComponentUtils.setAutoSelectOnFocus(mapHeightField); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterX); + TextComponentUtils.setAutoSelectOnFocus(fieldEnterY); + TextComponentUtils.setAutoSelectOnFocus(fieldSwapTime); + TextComponentUtils.setAutoSelectOnFocus(fieldResetTimeout); + TextComponentUtils.setAutoSelectOnFocus(fieldDifficulty); + TextComponentUtils.setAutoSelectOnFocus(fieldDarkness); } /** @@ -459,14 +471,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); + mapWidthField.setText(Integer.toString(mapModel.getMapArchObject().getMapSize().getWidth())); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); + mapHeightField.setText(Integer.toString(mapModel.getMapArchObject().getMapSize().getHeight())); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); @@ -565,11 +577,11 @@ * @return created panel */ @NotNull - private static Component createPanelLine(@NotNull final JFormattedTextField textField, final int n, final int defaultValue, @NotNull final String labelKey) { + private static Component createPanelLine(@NotNull final JTextField textField, final int n, final int defaultValue, @NotNull final String labelKey) { final Container lineLayout = new JPanel(new FlowLayout(FlowLayout.RIGHT)); lineLayout.add(new JLabel(ACTION_BUILDER.getString(labelKey))); textField.setColumns(n); - textField.setValue(defaultValue); + textField.setText(Integer.toString(defaultValue)); lineLayout.add(textField); return lineLayout; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-10 06:38:08
|
Revision: 8323 http://gridarta.svn.sourceforge.net/gridarta/?rev=8323&view=rev Author: akirschbaum Date: 2010-06-10 06:38:00 +0000 (Thu, 10 Jun 2010) Log Message: ----------- Unify comments. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/FilesResourcesReader.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/FilesResourcesReader.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/FilesResourcesReader.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/FilesResourcesReader.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/FilesResourcesReader.java 2010-06-10 06:33:51 UTC (rev 8322) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/resource/FilesResourcesReader.java 2010-06-10 06:38:00 UTC (rev 8323) @@ -60,7 +60,7 @@ private static final Category log = Logger.getLogger(FilesResourcesReader.class); /** - * The "arch" directory. + * The "arch" directory to read. */ @NotNull private final File archDirectory; @@ -78,7 +78,7 @@ private final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser; /** - * The {@link AnimationObjects} instance. + * The {@link AnimationObjects} to use. */ @NotNull private final AnimationObjects animationObjects; @@ -114,13 +114,13 @@ @NotNull @Override protected FaceProvider read(@NotNull final ErrorView errorView, @NotNull final List<GameObject> invObjects) { - archetypeSet.setLoadedFromArchive(false); // don't load from the collected files + archetypeSet.setLoadedFromArchive(false); final int animationObjectsSize = animationObjects.size(); final int archetypeCount = archetypeSet.getArchetypeCount(); final Collection<Pair<String, File>> animFiles = new ArrayList<Pair<String, File>>(); addPNGFace(new File(archDirectory, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", errorView, archFaceProvider); final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, archDirectory); - loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView, animFiles); // load arches & images from individual files + loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView, animFiles); loadAnimationsFromFiles(archDirectoryErrorViewCollector, animFiles); if (log.isInfoEnabled()) { log.info("Loaded " + (animationObjects.size() - animationObjectsSize) + " animations from '" + archDirectory + "'."); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/FilesResourcesReader.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/FilesResourcesReader.java 2010-06-10 06:33:51 UTC (rev 8322) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/resource/FilesResourcesReader.java 2010-06-10 06:38:00 UTC (rev 8323) @@ -47,7 +47,7 @@ import org.jetbrains.annotations.NotNull; /** - * Loaders for resources from individual files. + * Loads all resources from individual files. * @author Andreas Kirschbaum */ public class FilesResourcesReader extends AbstractResourcesReader { @@ -70,19 +70,19 @@ private final File archDirectory; /** - * The archetype set to update. + * The {@link ArchetypeSet} to update. */ @NotNull private final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet; /** - * The archetype parser to use. + * The {@link AbstractArchetypeParser} to use. */ @NotNull private final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser; /** - * The animation objects instance. + * The {@link AnimationObjects} to use. */ @NotNull private final AnimationObjects animationObjects; @@ -116,7 +116,7 @@ final int animationObjectsSize = animationObjects.size(); final int archetypeCount = archetypeSet.getArchetypeCount(); final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, archDirectory); - loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView); // load arches & images from individual files + loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView); if (log.isInfoEnabled()) { log.info("Loaded " + (animationObjects.size() - animationObjectsSize) + " animations from '" + archDirectory + "'."); } Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/FilesResourcesReader.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/FilesResourcesReader.java 2010-06-10 06:33:51 UTC (rev 8322) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/resource/FilesResourcesReader.java 2010-06-10 06:38:00 UTC (rev 8323) @@ -60,7 +60,7 @@ private static final Category log = Logger.getLogger(FilesResourcesReader.class); /** - * The "arch" directory. + * The "arch" directory to read. */ @NotNull private final File archDirectory; @@ -78,7 +78,7 @@ private final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser; /** - * The {@link AnimationObjects} instance. + * The {@link AnimationObjects} to use. */ @NotNull private final AnimationObjects animationObjects; @@ -91,7 +91,7 @@ /** * Creates a new instance. - * @param archDirectory the "arch" directory + * @param archDirectory the "arch" directory to read * @param collectedDirectory the collected directory * @param archetypeSet the archetype set to update * @param archetypeParser the archetype parser to use @@ -114,13 +114,13 @@ @NotNull @Override protected FaceProvider read(@NotNull final ErrorView errorView, @NotNull final List<GameObject> invObjects) { - archetypeSet.setLoadedFromArchive(false); // don't load from the collected files + archetypeSet.setLoadedFromArchive(false); final int animationObjectsSize = animationObjects.size(); final int archetypeCount = archetypeSet.getArchetypeCount(); final Collection<Pair<String, File>> animFiles = new ArrayList<Pair<String, File>>(); addPNGFace(new File(archDirectory, "dev/editor/bug.101.png").getAbsolutePath(), "/dev/editor", "bug.101.png", errorView, archFaceProvider); final ErrorViewCollector archDirectoryErrorViewCollector = new ErrorViewCollector(errorView, archDirectory); - loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView, animFiles); // load arches & images from individual files + loadArchetypesFromFiles(archDirectoryErrorViewCollector, archetypeParser, "", archDirectory, 0, "default", "default", false, invObjects, archFaceProvider, errorView, animFiles); loadAnimationsFromFiles(archDirectoryErrorViewCollector, animFiles); if (log.isInfoEnabled()) { log.info("Loaded " + (animationObjects.size() - animationObjectsSize) + " animations from '" + archDirectory + "'."); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |