From: <aki...@us...> - 2008-10-03 14:07:02
|
Revision: 5413 http://gridarta.svn.sourceforge.net/gridarta/?rev=5413&view=rev Author: akirschbaum Date: 2008-10-03 14:06:55 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Move NetPrefs to common code base. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/messages.properties trunk/daimonin/src/daieditor/messages_de.properties trunk/daimonin/src/daieditor/messages_fr.properties trunk/daimonin/src/daieditor/messages_sv.properties trunk/src/app/net/sf/gridarta/action.properties trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/prefs/NetPrefs.java Removed Paths: ------------- trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 14:06:55 UTC (rev 5413) @@ -31,7 +31,6 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.gui.map.DefaultMapPropertiesDialogFactory; import daieditor.gui.map.DefaultRendererFactory; -import daieditor.gui.prefs.NetPrefs; import daieditor.gui.prefs.ResPrefs; import daieditor.io.DefaultMapArchObjectParserFactory; import daieditor.map.DefaultMapArchObjectFactory; @@ -72,6 +71,7 @@ import net.sf.gridarta.gui.prefs.GUIPrefs; import net.sf.gridarta.gui.prefs.MapValidatorPrefs; import net.sf.gridarta.gui.prefs.MiscPrefs; +import net.sf.gridarta.gui.prefs.NetPrefs; import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; Deleted: trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java =================================================================== --- trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java 2008-10-03 14:06:55 UTC (rev 5413) @@ -1,174 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package daieditor.gui.prefs; - -import java.awt.Component; -import java.awt.event.ItemEvent; -import java.awt.event.ItemListener; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.util.EnumSet; -import java.util.prefs.Preferences; -import javax.swing.Box; -import javax.swing.JComboBox; -import javax.swing.JSpinner; -import javax.swing.JTextField; -import javax.swing.SpinnerNumberModel; -import javax.swing.border.Border; -import javax.swing.border.CompoundBorder; -import javax.swing.border.TitledBorder; -import net.sf.gridarta.MainControl; -import net.sf.gridarta.gui.GUIConstants; -import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.prefs.AbstractPrefs; - -/** - * Preferences Module for networking preferences. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @serial exclude - */ -public class NetPrefs extends AbstractPrefs implements ItemListener { - - /** The serial version UID. */ - private static final long serialVersionUID = 1; - - /** The preferences key for the type. */ - private static final String NET_PREFS_KEY_TYPE = "daieditor.proxy.type"; - - /** The preferences key for the type. */ - private static final String NET_PREFS_KEY_HOST = "daieditor.proxy.host"; - - /** The preferences key for the type. */ - private static final String NET_PREFS_KEY_PORT = "daieditor.proxy.port"; - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - - /** Preferences. */ - private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); - - /** JComboBox for selecting the proxy type. */ - private final JComboBox proxyType = createProxyType(); - - /** TextField for server executable. */ - private final JTextField proxyHost = new JTextField(PREFS.get(NET_PREFS_KEY_HOST, "")); - - /** TextField for client executable. */ - private final JSpinner proxyPort = new JSpinner(new SpinnerNumberModel(PREFS.getInt(NET_PREFS_KEY_PORT, 3128), 1, 65535, 1)); - - /** Create a NetPrefs pane. */ - public NetPrefs() { - setListLabelText(ACTION_FACTORY.getString("prefsNet.title")); - setListLabelIcon(ACTION_FACTORY.getIcon("prefsNet.icon")); - proxyType.addItemListener(this); - - add(createNetPanel()); - add(Box.createVerticalGlue()); - revert(); - } - - /** - * Create a titled border. - * @param titleKey Action Key for border title - * @return titled border - */ - private static Border createTitledBorder(final String titleKey) { - return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); - } - - /** {@inheritDoc} */ - public boolean isChanged() { - return !( - proxyType.getSelectedItem() == Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")) - && PREFS.get(NET_PREFS_KEY_HOST, "").equals(proxyHost.getText()) - && PREFS.getInt(NET_PREFS_KEY_PORT, 3128) == (Integer) proxyPort.getValue() - ); - - } - - /** {@inheritDoc} */ - public void defaults() { - PREFS.remove(NET_PREFS_KEY_TYPE); - PREFS.remove(NET_PREFS_KEY_HOST); - PREFS.remove(NET_PREFS_KEY_PORT); - revert(); - } - - /** {@inheritDoc} */ - public void revert() { - final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); - this.proxyType.setSelectedIndex(proxyType.ordinal()); - final boolean enableProxy = proxyType != Proxy.Type.DIRECT; - proxyHost.setEnabled(enableProxy); - proxyPort.setEnabled(enableProxy); - proxyHost.setText(PREFS.get(NET_PREFS_KEY_HOST, "")); - proxyPort.setValue(PREFS.getInt(NET_PREFS_KEY_PORT, 3128)); - } - - /** {@inheritDoc} */ - public void apply() { - PREFS.put(NET_PREFS_KEY_TYPE, ((Enum<Proxy.Type>) proxyType.getSelectedItem()).name()); - PREFS.put(NET_PREFS_KEY_HOST, proxyHost.getText()); - PREFS.putInt(NET_PREFS_KEY_PORT, (Integer) proxyPort.getValue()); - } - - /** - * Creates the subpanel with the external applications. - * @return subpanel - */ - private Component createNetPanel() { - final Box netPanel = Box.createVerticalBox(); - netPanel.setBorder(createTitledBorder("optionsNetProxy")); - netPanel.add(proxyType); - netPanel.add(proxyHost); - netPanel.add(proxyPort); - return netPanel; - } - - /** - * Create the JComboBox for selecting the proxy type. - * @return JComboBox for selecting the proxy type - */ - private static JComboBox createProxyType() { - final JComboBox proxyType = new JComboBox(EnumSet.allOf(Proxy.Type.class).toArray()); - return proxyType; - } - - /** - * Return the currently preferred proxy. - * @return currently preferred proxy - */ - public static Proxy getProxy() { - final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); - if (proxyType == Proxy.Type.DIRECT) { - return Proxy.NO_PROXY; - } - return new Proxy(proxyType, new InetSocketAddress(PREFS.get(NET_PREFS_KEY_HOST, "proxy"), PREFS.getInt(NET_PREFS_KEY_PORT, 3128))); - } - - /** {@inheritDoc} */ - public void itemStateChanged(final ItemEvent e) { - final Proxy.Type proxyType = (Proxy.Type) this.proxyType.getSelectedItem(); - final boolean enableProxy = proxyType != Proxy.Type.DIRECT; - proxyHost.setEnabled(enableProxy); - proxyPort.setEnabled(enableProxy); - } - -} // class NetPrefs Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/messages.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -240,8 +240,3 @@ nameOfAnimationObject=animation nameOfFaceObject=face chooseNamedObject.title=Choose a {0} - - -prefsNet.title=Network -prefsNet.icon=development/Server24 -optionsNetProxy=Proxy Settings Modified: trunk/daimonin/src/daieditor/messages_de.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_de.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/messages_de.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -188,7 +188,3 @@ #Validator.TilePaths.title= #Validator.TilePaths.msg= - - -prefsNet.title=Netzwerk -optionsNetProxy=Proxy-Einstellungen Modified: trunk/daimonin/src/daieditor/messages_fr.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_fr.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/messages_fr.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -190,7 +190,3 @@ #Validator.TilePaths.title= #Validator.TilePaths.msg= - - -#prefsNet.title= -#optionsNetProxy= Modified: trunk/daimonin/src/daieditor/messages_sv.properties =================================================================== --- trunk/daimonin/src/daieditor/messages_sv.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/daimonin/src/daieditor/messages_sv.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -190,7 +190,3 @@ #Validator.TilePaths.title= #Validator.TilePaths.msg= - - -#prefsNet.title= -#optionsNetProxy= Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/src/app/net/sf/gridarta/action.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -147,6 +147,7 @@ prefsUpdate.icon=general/Search24 prefsGUI.icon=development/Host24 prefsRes.icon=general/Save24 +prefsNet.icon=development/Server24 mapTileRevert.icon=general/Undo16 mapTileClear.icon=general/Remove16 Copied: trunk/src/app/net/sf/gridarta/gui/prefs/NetPrefs.java (from rev 5407, trunk/daimonin/src/daieditor/gui/prefs/NetPrefs.java) =================================================================== --- trunk/src/app/net/sf/gridarta/gui/prefs/NetPrefs.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/prefs/NetPrefs.java 2008-10-03 14:06:55 UTC (rev 5413) @@ -0,0 +1,174 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.prefs; + +import java.awt.Component; +import java.awt.event.ItemEvent; +import java.awt.event.ItemListener; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.util.EnumSet; +import java.util.prefs.Preferences; +import javax.swing.Box; +import javax.swing.JComboBox; +import javax.swing.JSpinner; +import javax.swing.JTextField; +import javax.swing.SpinnerNumberModel; +import javax.swing.border.Border; +import javax.swing.border.CompoundBorder; +import javax.swing.border.TitledBorder; +import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.GUIConstants; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.prefs.AbstractPrefs; + +/** + * Preferences Module for networking preferences. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @serial exclude + */ +public class NetPrefs extends AbstractPrefs implements ItemListener { + + /** The serial version UID. */ + private static final long serialVersionUID = 1; + + /** The preferences key for the type. */ + private static final String NET_PREFS_KEY_TYPE = "daieditor.proxy.type"; + + /** The preferences key for the type. */ + private static final String NET_PREFS_KEY_HOST = "daieditor.proxy.host"; + + /** The preferences key for the type. */ + private static final String NET_PREFS_KEY_PORT = "daieditor.proxy.port"; + + /** Action Factory. */ + private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); + + /** Preferences. */ + private static final Preferences PREFS = Preferences.userNodeForPackage(MainControl.class); + + /** JComboBox for selecting the proxy type. */ + private final JComboBox proxyType = createProxyType(); + + /** TextField for server executable. */ + private final JTextField proxyHost = new JTextField(PREFS.get(NET_PREFS_KEY_HOST, "")); + + /** TextField for client executable. */ + private final JSpinner proxyPort = new JSpinner(new SpinnerNumberModel(PREFS.getInt(NET_PREFS_KEY_PORT, 3128), 1, 65535, 1)); + + /** Create a NetPrefs pane. */ + public NetPrefs() { + setListLabelText(ACTION_FACTORY.getString("prefsNet.title")); + setListLabelIcon(ACTION_FACTORY.getIcon("prefsNet.icon")); + proxyType.addItemListener(this); + + add(createNetPanel()); + add(Box.createVerticalGlue()); + revert(); + } + + /** + * Create a titled border. + * @param titleKey Action Key for border title + * @return titled border + */ + private static Border createTitledBorder(final String titleKey) { + return new CompoundBorder(new TitledBorder(ACTION_FACTORY.getString(titleKey)), GUIConstants.DIALOG_BORDER); + } + + /** {@inheritDoc} */ + public boolean isChanged() { + return !( + proxyType.getSelectedItem() == Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")) + && PREFS.get(NET_PREFS_KEY_HOST, "").equals(proxyHost.getText()) + && PREFS.getInt(NET_PREFS_KEY_PORT, 3128) == (Integer) proxyPort.getValue() + ); + + } + + /** {@inheritDoc} */ + public void defaults() { + PREFS.remove(NET_PREFS_KEY_TYPE); + PREFS.remove(NET_PREFS_KEY_HOST); + PREFS.remove(NET_PREFS_KEY_PORT); + revert(); + } + + /** {@inheritDoc} */ + public void revert() { + final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); + this.proxyType.setSelectedIndex(proxyType.ordinal()); + final boolean enableProxy = proxyType != Proxy.Type.DIRECT; + proxyHost.setEnabled(enableProxy); + proxyPort.setEnabled(enableProxy); + proxyHost.setText(PREFS.get(NET_PREFS_KEY_HOST, "")); + proxyPort.setValue(PREFS.getInt(NET_PREFS_KEY_PORT, 3128)); + } + + /** {@inheritDoc} */ + public void apply() { + PREFS.put(NET_PREFS_KEY_TYPE, ((Enum<Proxy.Type>) proxyType.getSelectedItem()).name()); + PREFS.put(NET_PREFS_KEY_HOST, proxyHost.getText()); + PREFS.putInt(NET_PREFS_KEY_PORT, (Integer) proxyPort.getValue()); + } + + /** + * Creates the subpanel with the external applications. + * @return subpanel + */ + private Component createNetPanel() { + final Box netPanel = Box.createVerticalBox(); + netPanel.setBorder(createTitledBorder("optionsNetProxy")); + netPanel.add(proxyType); + netPanel.add(proxyHost); + netPanel.add(proxyPort); + return netPanel; + } + + /** + * Create the JComboBox for selecting the proxy type. + * @return JComboBox for selecting the proxy type + */ + private static JComboBox createProxyType() { + final JComboBox proxyType = new JComboBox(EnumSet.allOf(Proxy.Type.class).toArray()); + return proxyType; + } + + /** + * Return the currently preferred proxy. + * @return currently preferred proxy + */ + public static Proxy getProxy() { + final Proxy.Type proxyType = Proxy.Type.valueOf(PREFS.get(NET_PREFS_KEY_TYPE, "DIRECT")); + if (proxyType == Proxy.Type.DIRECT) { + return Proxy.NO_PROXY; + } + return new Proxy(proxyType, new InetSocketAddress(PREFS.get(NET_PREFS_KEY_HOST, "proxy"), PREFS.getInt(NET_PREFS_KEY_PORT, 3128))); + } + + /** {@inheritDoc} */ + public void itemStateChanged(final ItemEvent e) { + final Proxy.Type proxyType = (Proxy.Type) this.proxyType.getSelectedItem(); + final boolean enableProxy = proxyType != Proxy.Type.DIRECT; + proxyHost.setEnabled(enableProxy); + proxyPort.setEnabled(enableProxy); + } + +} // class NetPrefs Property changes on: trunk/src/app/net/sf/gridarta/gui/prefs/NetPrefs.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:mergeinfo + Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -827,6 +827,7 @@ prefsGUI.title=Appearance prefsDev.title=Developers prefsUpdate.title=Update +prefsNet.title=Network autoUpdate.text=Automatically check for updates on startup? prefsUpdateAuto0.text=Every startup @@ -862,6 +863,7 @@ optionsAppClient.shortdescription=The filename of the client executable to run in 'control client'. optionsAppEditor=Editor optionsAppEditor.shortdescription=The filename of the external editor to run. +optionsNetProxy=Proxy Settings archCollectErrorFileNotFound.title=Collect error archCollectErrorFileNotFound.message=Collect Error: Cannot open input file\n{0} Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -778,6 +778,7 @@ prefsGUI.title=Aussehen prefsDev.title=Entwickler prefsUpdate.title=Update +prefsNet.title=Netzwerk autoUpdate.text=Beim Programmstart automatisch auf Updates pr\xFCfen? prefsUpdateAuto0.text=Bei jedem Start @@ -813,6 +814,7 @@ optionsAppClient.shortdescription=Der Dateiname des Clients, der mit 'Client steuern' gestartet wird. optionsAppEditor=Editor optionsAppEditor.shortdescription=Der Dateiname des externen Editors. +optionsNetProxy=Proxy-Einstellungen archCollectErrorFileNotFound.title=Fehler beim Sammeln archCollectErrorFileNotFound.message=Kann Eingabedatei nicht \xF6ffnen:\n{0} Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -777,6 +777,7 @@ #prefsGUI.title= #prefsDev.title= #prefsUpdate.title= +#prefsNet.title= #autoUpdate.text= #prefsUpdateAuto0.text= @@ -812,6 +813,7 @@ #optionsAppClient.shortdescription= #optionsAppEditor= #optionsAppEditor.shortdescription= +#optionsNetProxy= #archCollectErrorFileNotFound.title= #archCollectErrorFileNotFound.message= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-03 13:52:20 UTC (rev 5412) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-03 14:06:55 UTC (rev 5413) @@ -782,6 +782,7 @@ prefsGUI.title=Utseende prefsDev.title=Utvecklare prefsUpdate.title=Uppdatering +#prefsNet.title= autoUpdate.text=Automatiskt leta efter uppdateringar vid uppstart? prefsUpdateAuto0.text=Varje uppstart @@ -817,6 +818,7 @@ #optionsAppClient.shortdescription= optionsAppEditor=Editor #optionsAppEditor.shortdescription= +#optionsNetProxy= archCollectErrorFileNotFound.title=Fel under sammanst\xE4llning archCollectErrorFileNotFound.message=Fel under sammanst\xE4llning: kan inte \xF6ppna fil\n{0} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-03 14:21:21
|
Revision: 5416 http://gridarta.svn.sourceforge.net/gridarta/?rev=5416&view=rev Author: akirschbaum Date: 2008-10-03 14:21:10 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Use network settings in updater. Modified Paths: -------------- trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/updater/Updater.java Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-10-03 14:13:05 UTC (rev 5415) +++ trunk/daimonin/ChangeLog 2008-10-03 14:21:10 UTC (rev 5416) @@ -1,3 +1,7 @@ +2008-10-03 Andreas Kirschbaum + + * Use network settings in updater. + 2008-10-02 Andreas Kirschbaum * Add plugin script interpreter. Modified: trunk/src/app/net/sf/gridarta/updater/Updater.java =================================================================== --- trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-10-03 14:13:05 UTC (rev 5415) +++ trunk/src/app/net/sf/gridarta/updater/Updater.java 2008-10-03 14:21:10 UTC (rev 5416) @@ -38,6 +38,7 @@ import javax.swing.ProgressMonitor; import javax.swing.ProgressMonitorInputStream; import net.sf.gridarta.MainControl; +import net.sf.gridarta.gui.prefs.NetPrefs; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; @@ -215,7 +216,8 @@ // The stream is closed by caller @SuppressWarnings({"IOResourceOpenedButNotSafelyClosed"}) private InputStream openStream(final String url) throws IOException { - final URLConnection con = new URL(url).openConnection(Proxy.NO_PROXY); + final Proxy proxy = NetPrefs.getProxy(); + final URLConnection con = new URL(url).openConnection(proxy); final ProgressMonitorInputStream stream = new ProgressMonitorInputStream(parentComponent, ACTION_FACTORY.getString("updateProgress.title"), con.getInputStream()); final ProgressMonitor monitor = stream.getProgressMonitor(); monitor.setMaximum(con.getContentLength()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-03 17:50:14
|
Revision: 5419 http://gridarta.svn.sourceforge.net/gridarta/?rev=5419&view=rev Author: akirschbaum Date: 2008-10-03 17:50:04 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Add AbstractScriptedEvent. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-03 14:27:53 UTC (rev 5418) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptedEvent.java 2008-10-03 17:50:04 UTC (rev 5419) @@ -25,6 +25,7 @@ import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeTypeException; +import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -32,7 +33,7 @@ * Class which stores information about one scripted event. * @author Andreas Kirschbaum */ -public final class ScriptedEvent extends net.sf.gridarta.gameobject.scripts.ScriptedEvent<GameObject> { +public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptedEvent.class); Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-03 14:27:53 UTC (rev 5418) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptedEvent.java 2008-10-03 17:50:04 UTC (rev 5419) @@ -21,6 +21,7 @@ import daieditor.gameobject.Archetype; import daieditor.gameobject.GameObject; +import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeException; import net.sf.gridarta.gameobject.scripts.UndefinedEventArchetypeNameException; @@ -31,7 +32,7 @@ * Class which stores information about one scripted event. * @author Andreas Kirschbaum */ -public final class ScriptedEvent extends net.sf.gridarta.gameobject.scripts.ScriptedEvent<GameObject> { +public final class ScriptedEvent extends AbstractScriptedEvent<GameObject> { /** The Logger for printing log messages. */ private static final Logger log = Logger.getLogger(ScriptedEvent.class); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 14:27:53 UTC (rev 5418) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 17:50:04 UTC (rev 5419) @@ -58,7 +58,7 @@ import net.sf.gridarta.gameobject.match.GameObjectMatchers; import net.sf.gridarta.gameobject.match.NamedGameObjectMatcher; import net.sf.gridarta.gameobject.scripts.AbstractScriptArchEditor; -import net.sf.gridarta.gameobject.scripts.ScriptedEvent; +import net.sf.gridarta.gameobject.scripts.AbstractScriptedEvent; import net.sf.gridarta.gameobject.scripts.ScriptedEventEditor; import net.sf.gridarta.gui.About; import net.sf.gridarta.gui.HideFileFilterProxy; @@ -332,7 +332,7 @@ globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); - ScriptedEvent.init(archetypeSet); + AbstractScriptedEvent.init(archetypeSet); PathManager.setGlobalSettings(globalSettings); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); newMapDialogFactory = newNewMapDialogFactory(mapManager, mapArchObjectFactory); Added: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java 2008-10-03 17:50:04 UTC (rev 5419) @@ -0,0 +1,46 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gameobject.scripts; + +import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.Nullable; + +/** + * Class which stores information about one scripted event. + * @author Andreas Kirschbaum + */ +public abstract class AbstractScriptedEvent<G extends GameObject<G, ?, ?>> implements ScriptedEvent<G>{ + + /** + * The archetype set to use. + */ + @Nullable + protected static ArchetypeSet<?, ?, ?> archetypeSet; + + /** + * Initializes the module. + * @param archetypeSet the archetype set to use + */ + public static void init(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet) { + AbstractScriptedEvent.archetypeSet = archetypeSet; + } + +} // class AbstractScriptedEvent Property changes on: trunk/src/app/net/sf/gridarta/gameobject/scripts/AbstractScriptedEvent.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-10-03 14:27:53 UTC (rev 5418) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptedEvent.java 2008-10-03 17:50:04 UTC (rev 5419) @@ -19,48 +19,32 @@ package net.sf.gridarta.gameobject.scripts; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import org.jetbrains.annotations.Nullable; /** * Class which stores information about one scripted event. * @author Andreas Kirschbaum */ -public abstract class ScriptedEvent<G extends GameObject<G, ?, ?>> { +public interface ScriptedEvent<G extends GameObject<G, ?, ?>> { /** - * The archetype set to use. - */ - @Nullable - protected static ArchetypeSet<?, ?, ?> archetypeSet; - - /** * Set event path and plugin name according to user input from popup * dialog. */ - public abstract void modifyEventPath(); + void modifyEventPath(); - public abstract String getPluginName(); + String getPluginName(); - public abstract String getScriptPath(); + String getScriptPath(); - public abstract String getOptions(); + String getOptions(); /** * Returns the underlying event game object. * @return the underlying event game object */ - public abstract G getEventArch(); + G getEventArch(); - public abstract int getEventType(); + int getEventType(); - /** - * Initializes the module. - * @param archetypeSet the archetype set to use - */ - public static void init(@Nullable final ArchetypeSet<?, ?, ?> archetypeSet) { - ScriptedEvent.archetypeSet = archetypeSet; - } - } // class ScriptedEvent This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-03 18:52:08
|
Revision: 5424 http://gridarta.svn.sourceforge.net/gridarta/?rev=5424&view=rev Author: akirschbaum Date: 2008-10-03 18:52:01 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Extract code into GameObjectParserFactory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/io/DefaultGameObjectParserFactory.java trunk/daimonin/src/daieditor/io/DefaultGameObjectParserFactory.java trunk/src/app/net/sf/gridarta/io/GameObjectParserFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -33,6 +33,7 @@ import cfeditor.gui.map.DefaultRendererFactory; import cfeditor.gui.prefs.ResPrefs; import cfeditor.io.DefaultGameObjectParser; +import cfeditor.io.DefaultGameObjectParserFactory; import cfeditor.io.DefaultMapArchObjectParserFactory; import cfeditor.map.DefaultMapArchObjectFactory; import cfeditor.map.DefaultMapControlFactory; @@ -69,6 +70,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.ConfigFileUtils; import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControlFactory; @@ -116,6 +118,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + return new DefaultGameObjectParserFactory(gameObjectFactory); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected DefaultMapArchObjectParserFactory newMapArchObjectParserFactory() { return new DefaultMapArchObjectParserFactory(); } @@ -152,14 +161,7 @@ } /** {@inheritDoc} */ - @NotNull @Override - protected GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { - return new DefaultGameObjectParser(gameObjectFactory); - } - - /** {@inheritDoc} */ - @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); } Modified: trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -23,7 +23,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.UndefinedArchetype; import cfeditor.gui.map.CMapViewBasic; -import cfeditor.io.DefaultGameObjectParser; import cfeditor.map.MapArchObject; import java.awt.Point; import java.io.File; @@ -34,13 +33,14 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; +import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObjectFactory; @@ -94,14 +94,14 @@ @NotNull private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; - /** The {@link GameObjectFactory} instance. */ + /** The {@link GameObjectParserFactory} instance. */ @NotNull - private GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; + private GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory; /** {@inheritDoc} */ @NotNull public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - final DefaultGameObjectParser gameObjectParser = new DefaultGameObjectParser(gameObjectFactory); + final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); return new DefaultMapReader<GameObject, MapArchObject, Archetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mainView, archetypeSet, editTypes, file); } @@ -118,7 +118,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; @@ -127,7 +127,7 @@ this.toolPalette = toolPalette; this.mapArchObjectFactory = mapArchObjectFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.gameObjectFactory = gameObjectFactory; + this.gameObjectParserFactory = gameObjectParserFactory; } /** {@inheritDoc} */ Added: trunk/crossfire/src/cfeditor/io/DefaultGameObjectParserFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/io/DefaultGameObjectParserFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/io/DefaultGameObjectParserFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -0,0 +1,53 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package cfeditor.io; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObjectFactory; +import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link GameObjectParserFactory} which creates Crossfire objects. + * @author Andreas Kirschbaum + */ +public class DefaultGameObjectParserFactory implements GameObjectParserFactory<GameObject, MapArchObject, Archetype> { + + /** The {@link GameObjectFactory} instance. */ + @NotNull + private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; + + /** + * Creates a new instance. + * @param gameObjectFactory the game object factory to use + */ + public DefaultGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + this.gameObjectFactory = gameObjectFactory; + } + + /** {@inheritDoc} */ + public GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser() { + return new DefaultGameObjectParser(gameObjectFactory); + } + +} // class DefaultGameObjectParserFactory Property changes on: trunk/crossfire/src/cfeditor/io/DefaultGameObjectParserFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -33,6 +33,7 @@ import daieditor.gui.map.DefaultRendererFactory; import daieditor.gui.prefs.ResPrefs; import daieditor.io.DefaultGameObjectParser; +import daieditor.io.DefaultGameObjectParserFactory; import daieditor.io.DefaultMapArchObjectParserFactory; import daieditor.map.DefaultMapArchObjectFactory; import daieditor.map.DefaultMapControlFactory; @@ -77,6 +78,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; @@ -163,6 +165,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + return new DefaultGameObjectParserFactory(gameObjectFactory); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected DefaultMapArchObjectParserFactory newMapArchObjectParserFactory() { return new DefaultMapArchObjectParserFactory(); } @@ -199,14 +208,7 @@ } /** {@inheritDoc} */ - @NotNull @Override - protected GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { - return new DefaultGameObjectParser(gameObjectFactory); - } - - /** {@inheritDoc} */ - @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype> newArchetypeParser(final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl, final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); } Modified: trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -23,7 +23,6 @@ import daieditor.gameobject.GameObject; import daieditor.gameobject.UndefinedArchetype; import daieditor.gui.map.CMapViewBasic; -import daieditor.io.DefaultGameObjectParser; import daieditor.map.MapArchObject; import java.awt.Point; import java.io.File; @@ -34,13 +33,14 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.ArchetypeSet; -import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.DefaultMapReader; +import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObjectFactory; @@ -101,14 +101,14 @@ @NotNull private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; - /** The {@link GameObjectFactory} instance. */ + /** The {@link GameObjectParserFactory} instance. */ @NotNull - private GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; + private GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory; /** {@inheritDoc} */ @NotNull public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - final DefaultGameObjectParser gameObjectParser = new DefaultGameObjectParser(gameObjectFactory); + final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); return new DefaultMapReader<GameObject, MapArchObject, Archetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mainView, archetypeSet, editTypes, file); } @@ -125,7 +125,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { this.faceObjects = faceObjects; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; @@ -136,7 +136,7 @@ this.toolPalette = toolPalette; this.mapArchObjectFactory = mapArchObjectFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.gameObjectFactory = gameObjectFactory; + this.gameObjectParserFactory = gameObjectParserFactory; } /** {@inheritDoc} */ Added: trunk/daimonin/src/daieditor/io/DefaultGameObjectParserFactory.java =================================================================== --- trunk/daimonin/src/daieditor/io/DefaultGameObjectParserFactory.java (rev 0) +++ trunk/daimonin/src/daieditor/io/DefaultGameObjectParserFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -0,0 +1,53 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package daieditor.io; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gameobject.GameObjectFactory; +import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link GameObjectParserFactory} which creates Crossfire objects. + * @author Andreas Kirschbaum + */ +public class DefaultGameObjectParserFactory implements GameObjectParserFactory<GameObject, MapArchObject, Archetype> { + + /** The {@link GameObjectFactory} instance. */ + @NotNull + private final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory; + + /** + * Creates a new instance. + * @param gameObjectFactory the game object factory to use + */ + public DefaultGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { + this.gameObjectFactory = gameObjectFactory; + } + + /** {@inheritDoc} */ + public GameObjectParser<GameObject, MapArchObject, Archetype> newGameObjectParser() { + return new DefaultGameObjectParser(gameObjectFactory); + } + +} // class DefaultGameObjectParserFactory Property changes on: trunk/daimonin/src/daieditor/io/DefaultGameObjectParserFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -99,6 +99,7 @@ import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.help.Help; import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.AutoValidator; @@ -452,10 +453,11 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) actionFactory.find(mainView.getJMenuBar(), "plugins")); final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); - final GameObjectParser<G, A, R> gameObjectParser = newGameObjectParser(gameObjectFactory); + final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); + final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); archetypeSet.init(gameObjectParser); final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); - gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, archetypeSet, toolPalette, mapArchObjectFactory, mapArchObjectParserFactory, gameObjectFactory); + gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, archetypeSet, toolPalette, mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); mapControlFactory.init(gridartaObjectsFactory, mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon()); @@ -493,6 +495,9 @@ } @NotNull + protected abstract GameObjectParserFactory<G, A, R> newGameObjectParserFactory(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory); + + @NotNull protected abstract MapArchObjectParserFactory<A> newMapArchObjectParserFactory(); @NotNull @@ -507,9 +512,6 @@ @NotNull protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); - @NotNull - protected abstract GameObjectParser<G, A, R> newGameObjectParser(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory); - protected abstract AbstractArchetypeParser<G, A, R> newArchetypeParser(final GameObjectParser<G, A, R> gameObjectParser, final ArchetypeChooserControl<G, A, R, V> archetypeChooserControl, final AnimationObjects<? extends AnimationObject> animationObjects, final ArchetypeSet<G, A, R> archetypeSet, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory); protected abstract void createActions(); Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -26,13 +26,13 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; -import net.sf.gridarta.gameobject.GameObjectFactory; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; @@ -88,9 +88,9 @@ * @param mapArchObjectFactory the map arch object factory instance * @param mapArchObjectParserFactory the map arch object parser factory * instance - * @param gameObjectFactory the game object factory instance + * @param gameObjectParserFactory the game object parser factory instance */ - void init(@NotNull FaceObjects faceObjects, @NotNull SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull GameObjectFactory<G, A, R> gameObjectFactory); + void init(@NotNull FaceObjects faceObjects, @NotNull SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull GameObjectParserFactory<G, A, R> gameObjectParserFactory); void setFilterControl(@NotNull FilterControl<G, A, R, V> filterControl); Added: trunk/src/app/net/sf/gridarta/io/GameObjectParserFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/GameObjectParserFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/GameObjectParserFactory.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -0,0 +1,38 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.io; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; + +/** + * A factory for creating {@link GameObjectParser} instances. + * @author Andreas Kirschbaum + */ +public interface GameObjectParserFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new {@link GameObjectParser} instance. + * @return the new instance + */ + GameObjectParser<G, A, R> newGameObjectParser(); + +} // interface GameObjectParserFactory Property changes on: trunk/src/app/net/sf/gridarta/io/GameObjectParserFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-03 18:32:24 UTC (rev 5423) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-03 18:52:01 UTC (rev 5424) @@ -80,6 +80,7 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.AbstractGameObjectParser; import net.sf.gridarta.io.GameObjectParser; +import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; import net.sf.gridarta.io.MapReader; @@ -500,6 +501,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected MapArchObjectParserFactory<TestMapArchObject> newMapArchObjectParserFactory() { throw new AssertionError(); } @@ -533,14 +541,7 @@ } /** {@inheritDoc} */ - @NotNull @Override - protected GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParser(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @Override protected void init4(@NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet) { throw new AssertionError(); } @@ -970,7 +971,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-03 19:56:30
|
Revision: 5425 http://gridarta.svn.sourceforge.net/gridarta/?rev=5425&view=rev Author: akirschbaum Date: 2008-10-03 19:56:12 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Extract MapReaderFactory from GridartaObjectsFactory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java trunk/src/app/net/sf/gridarta/io/MapReaderFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -32,7 +32,6 @@ import cfeditor.gui.map.DefaultMapPropertiesDialogFactory; import cfeditor.gui.map.DefaultRendererFactory; import cfeditor.gui.prefs.ResPrefs; -import cfeditor.io.DefaultGameObjectParser; import cfeditor.io.DefaultGameObjectParserFactory; import cfeditor.io.DefaultMapArchObjectParserFactory; import cfeditor.map.DefaultMapArchObjectFactory; @@ -69,9 +68,11 @@ import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.ConfigFileUtils; +import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.validation.DelegatingMapValidator; @@ -118,6 +119,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapReaderFactory<GameObject, MapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { + return new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new DefaultGameObjectParserFactory(gameObjectFactory); } @@ -149,8 +157,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - return new DefaultMapControlFactory(gridartaObjectsFactory); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory() { + return new DefaultMapControlFactory(); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/crossfire/src/cfeditor/DefaultGridartaObjectsFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -25,25 +25,16 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Point; -import java.io.File; -import java.io.FileNotFoundException; import net.sf.gridarta.EditTypes; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.io.DefaultMapReader; -import net.sf.gridarta.io.GameObjectParser; -import net.sf.gridarta.io.GameObjectParserFactory; -import net.sf.gridarta.io.MapArchObjectParserFactory; -import net.sf.gridarta.io.MapReader; -import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -74,10 +65,6 @@ @NotNull private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache = null; - /** The {@link ArchetypeSet} instance. */ - @NotNull - private ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; - /** The {@link FilterControl} instance. */ @NotNull private FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; @@ -86,27 +73,8 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; - /** The {@link MapArchObjectFactory} instance. */ - @NotNull - private MapArchObjectFactory<MapArchObject> mapArchObjectFactory; - - /** The {@link MapArchObjectParserFactory} instance. */ - @NotNull - private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; - - /** The {@link GameObjectParserFactory} instance. */ - @NotNull - private GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory; - /** {@inheritDoc} */ @NotNull - public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); - return new DefaultMapReader<GameObject, MapArchObject, Archetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mainView, archetypeSet, editTypes, file); - } - - /** {@inheritDoc} */ - @NotNull public Archetype newUndefinedArchetype(@NotNull final String archetypeName) { return new UndefinedArchetype(archetypeName); } @@ -118,16 +86,12 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; this.mapImageCache = mapImageCache; - this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - this.mapArchObjectFactory = mapArchObjectFactory; - this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.gameObjectParserFactory = gameObjectParserFactory; } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -109,14 +109,6 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; - /** - * Creates a new instance. - * @param gridartaObjectsFactory the gridarta objects factory - */ - public DefaultMapControlFactory(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory); - } - /** {@inheritDoc} */ public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.gridartaObjectsFactory = gridartaObjectsFactory; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -32,7 +32,6 @@ import daieditor.gui.map.DefaultMapPropertiesDialogFactory; import daieditor.gui.map.DefaultRendererFactory; import daieditor.gui.prefs.ResPrefs; -import daieditor.io.DefaultGameObjectParser; import daieditor.io.DefaultGameObjectParserFactory; import daieditor.io.DefaultMapArchObjectParserFactory; import daieditor.map.DefaultMapArchObjectFactory; @@ -77,9 +76,11 @@ import net.sf.gridarta.gui.prefs.UpdatePrefs; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.utils.GUIUtils; +import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlFactory; @@ -165,6 +166,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapReaderFactory<GameObject, MapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { + return new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected GameObjectParserFactory<GameObject, MapArchObject, Archetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory) { return new DefaultGameObjectParserFactory(gameObjectFactory); } @@ -196,8 +204,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - return new DefaultMapControlFactory(gridartaObjectsFactory); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory() { + return new DefaultMapControlFactory(); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/daimonin/src/daieditor/DefaultGridartaObjectsFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -25,25 +25,16 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import java.awt.Point; -import java.io.File; -import java.io.FileNotFoundException; import net.sf.gridarta.EditTypes; import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.MainControl; import net.sf.gridarta.MapImageCache; import net.sf.gridarta.filter.FilterControl; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.io.DefaultMapReader; -import net.sf.gridarta.io.GameObjectParser; -import net.sf.gridarta.io.GameObjectParserFactory; -import net.sf.gridarta.io.MapArchObjectParserFactory; -import net.sf.gridarta.io.MapReader; -import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; @@ -81,10 +72,6 @@ @NotNull private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache = null; - /** The {@link ArchetypeSet} instance. */ - @NotNull - private ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet = null; - /** The {@link FilterControl} instance. */ @NotNull private FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl; @@ -93,27 +80,8 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; - /** The {@link MapArchObjectFactory} instance. */ - @NotNull - private MapArchObjectFactory<MapArchObject> mapArchObjectFactory; - - /** The {@link MapArchObjectParserFactory} instance. */ - @NotNull - private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; - - /** The {@link GameObjectParserFactory} instance. */ - @NotNull - private GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory; - /** {@inheritDoc} */ @NotNull - public MapReader<GameObject, MapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); - return new DefaultMapReader<GameObject, MapArchObject, Archetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mainView, archetypeSet, editTypes, file); - } - - /** {@inheritDoc} */ - @NotNull public Archetype newUndefinedArchetype(@NotNull final String archetypeName) { return new UndefinedArchetype(archetypeName); } @@ -125,18 +93,14 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<GameObject, MapArchObject, Archetype> gameObjectParserFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette) { this.faceObjects = faceObjects; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; this.mainView = mainView; this.editTypes = editTypes; this.mapImageCache = mapImageCache; - this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - this.mapArchObjectFactory = mapArchObjectFactory; - this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.gameObjectParserFactory = gameObjectParserFactory; } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -109,14 +109,6 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; - /** - * Creates a new instance. - * @param gridartaObjectsFactory the gridarta objects factory - */ - public DefaultMapControlFactory(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory); - } - /** {@inheritDoc} */ public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.gridartaObjectsFactory = gridartaObjectsFactory; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -98,9 +98,11 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.undo.UndoControl; import net.sf.gridarta.help.Help; +import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.AutoValidator; import net.sf.gridarta.map.InsertionMode; @@ -324,18 +326,25 @@ this.scriptExtension = scriptExtension; this.globalSettings = globalSettings; appPrefsModel = createAppPrefsModel(); - final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(gridartaObjectsFactory); - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, mapControlFactory, globalSettings); + final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(); + final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); + final MapArchObjectParserFactory<A> mapArchObjectParserFactory = newMapArchObjectParserFactory(); + final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); + final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); + final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + mapControlFactory.setMapReaderFactory(mapReaderFactory); + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, mapReaderFactory, mapControlFactory, globalSettings); final EditTypes<G, A, R, V> editTypes = new EditTypes<G, A, R, V>(tmpMapManager); + mapReaderFactory.setEditTypes(editTypes); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; this.rendererFactory = rendererFactory; globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); + mapReaderFactory.setArchetypeSet(archetypeSet); AbstractScriptedEvent.init(archetypeSet); PathManager.setGlobalSettings(globalSettings); - final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); newMapDialogFactory = newNewMapDialogFactory(mapManager, mapArchObjectFactory); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final MapManagerActions<G, A, R, V> mapManagerActions = new MapManagerActions<G, A, R, V>(mapManager); @@ -349,6 +358,7 @@ createMapImageCache(mapImageCacheDir, SystemIcons.getDefaultIcon(), SystemIcons.getDefaultPreview(), new StatusBar<G, A, R, V>(mapManager, mapViewManager, archetypeSet, faceObjects)); final ActionFactory actionFactory = ActionFactory.getFactory(key); mainView = new MainView<G, A, R, V>(this, editTypes, mapManager, mapViewManager, actionFactory, mapManagerActions.getCloseAllAction(), statusBar, getBuildNumberAsString()); + mapReaderFactory.setMainView(mainView); tmpMapManager.setParent(mainView); new MapFileActions<G, A, R, V>(this, mainView, mapManager, mapViewManager, null); newMapDialogFactory.setParent(mainView); @@ -409,7 +419,6 @@ log.fatal("GameObjectMatcher 'exit' does not exist"); throw new MissingResourceException("GameObjectMatcher 'exit' does not exist", null, null); } - final MapArchObjectParserFactory<A> mapArchObjectParserFactory = newMapArchObjectParserFactory(); final MapActions mapActions = init1(mapArchObjectParserFactory, mapArchObjectFactory, globalSettings, mapManager, archetypeTypeSet, selectedSquareView, exitMatcher); Map<String, TreasureTreeNode> specialTreasureLists; try { @@ -452,12 +461,10 @@ mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, pickmapChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) actionFactory.find(mainView.getJMenuBar(), "plugins")); - final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); - final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); archetypeSet.init(gameObjectParser); final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); - gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, archetypeSet, toolPalette, mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + gridartaObjectsFactory.init(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, toolPalette); mapControlFactory.init(gridartaObjectsFactory, mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon()); @@ -495,6 +502,9 @@ } @NotNull + protected abstract MapReaderFactory<G, A> newMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory); + + @NotNull protected abstract GameObjectParserFactory<G, A, R> newGameObjectParserFactory(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory); @NotNull @@ -507,7 +517,7 @@ protected abstract AppPrefsModel createAppPrefsModel(); @NotNull - protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory); + protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(); @NotNull protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -35,6 +35,7 @@ import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.io.MapReader; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlFactory; @@ -73,7 +74,7 @@ * The gridarta objects factory instance. */ @NotNull - private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + private final MapReaderFactory<G, A> mapReaderFactory; /** * The map control factory instance. @@ -101,15 +102,15 @@ * Create a new map manager. * @param mainControl the main control * @param key The action factory key. - * @param gridartaObjectsFactory the gridarta objects factory instance + * @param mapReaderFactory the map reader factory instance * @param mapControlFactory the map control factory instance * @param globalSettings the global settings instance */ - public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings) { + public DefaultMapManager(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final String key, @NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final GlobalSettings globalSettings) { this.globalSettings = globalSettings; actionFactory = ActionFactory.getFactory(key); this.mainControl = mainControl; - this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapReaderFactory = mapReaderFactory; this.mapControlFactory = mapControlFactory; } @@ -117,6 +118,7 @@ * Sets the edit types instance to use. * @param editTypes the edit types */ + @Deprecated public void setEditTypes(@NotNull final EditTypes<G, A, R, V> editTypes) { this.editTypes = editTypes; } @@ -125,6 +127,7 @@ * Sets the parent component for dialog windows. * @param parent the parent component */ + @Deprecated public void setParent(@NotNull final Component parent) { this.parent = parent; } @@ -295,7 +298,7 @@ public MapReader<G, A> decodeMapFile(@NotNull final File file, final boolean isInteractive) { final MapReader<G, A> decoder; try { - decoder = gridartaObjectsFactory.newMapReader(file); + decoder = mapReaderFactory.newMapReader(file); decoder.decodeMapFile(isInteractive); } catch (final IOException e) { if (isInteractive) { Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -20,11 +20,8 @@ package net.sf.gridarta; import java.awt.Point; -import java.io.File; -import java.io.FileNotFoundException; import net.sf.gridarta.filter.FilterControl; import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gameobject.face.FaceObjects; import net.sf.gridarta.gui.MainView; @@ -32,11 +29,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; -import net.sf.gridarta.io.GameObjectParserFactory; -import net.sf.gridarta.io.MapArchObjectParserFactory; -import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapArchObjectFactory; import net.sf.gridarta.map.MapControl; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,15 +41,6 @@ public interface GridartaObjectsFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { /** - * Open a file for reading it as a map. - * @param file File to open. - * @return The new map reader. - * @throws FileNotFoundException in case the file was not found. - */ - @NotNull - MapReader<G, A> newMapReader(@NotNull File file) throws FileNotFoundException; - - /** * Create a new undefined archetype instance. * @param archetypeName The archetype name. * @return The new undefined archetype instance. @@ -83,14 +67,9 @@ * @param mainView the main view instance * @param editTypes the edit types instance * @param mapImageCache the map image cache instance - * @param archetypeSet the archetype set instance * @param toolPalette the tool palette instance - * @param mapArchObjectFactory the map arch object factory instance - * @param mapArchObjectParserFactory the map arch object parser factory - * instance - * @param gameObjectParserFactory the game object parser factory instance */ - void init(@NotNull FaceObjects faceObjects, @NotNull SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull GameObjectParserFactory<G, A, R> gameObjectParserFactory); + void init(@NotNull FaceObjects faceObjects, @NotNull SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull MainControl<G, A, R, V> mainControl, @NotNull MainView<G, A, R, V> mainView, @NotNull EditTypes<G, A, R, V> editTypes, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull ToolPalette<G, A, R, V> toolPalette); void setFilterControl(@NotNull FilterControl<G, A, R, V> filterControl); Added: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -0,0 +1,111 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.io; + +import java.io.File; +import java.io.FileNotFoundException; +import net.sf.gridarta.EditTypes; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.ArchetypeSet; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.MainView; +import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapArchObjectFactory; +import org.jetbrains.annotations.NotNull; + +/** + * Default implementation of {@link MapReaderFactory}. + * @author Andreas Kirschbaum + */ +public class DefaultMapReaderFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> implements MapReaderFactory<G, A> { + + /** The {@link MapArchObjectFactory} instance. */ + @NotNull + private final MapArchObjectFactory<A> mapArchObjectFactory; + + /** The {@link MapArchObjectParserFactory} instance. */ + @NotNull + private final MapArchObjectParserFactory<A> mapArchObjectParserFactory; + + /** The {@link GameObjectParserFactory} instance. */ + @NotNull + private final GameObjectParserFactory<G, A, R> gameObjectParserFactory; + + /** The {@link ArchetypeSet} instance. */ + @NotNull + private ArchetypeSet<G, A, R> archetypeSet; + + /** The {@link MainView} instance to use. */ + @NotNull + private MainView<G, A, R, V> mainView; + + /** The {@link EditTypes} instance to use. */ + @NotNull + private EditTypes<G, A, R, V> editTypes; + + /** + * Creates a new instance. + * @param mapArchObjectFactory the map arch object factory instance + * @param mapArchObjectParserFactory the map arch object parser factory + * instance + * @param gameObjectParserFactory the game object parser factory instance + */ + public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory) { + this.mapArchObjectFactory = mapArchObjectFactory; + this.mapArchObjectParserFactory = mapArchObjectParserFactory; + this.gameObjectParserFactory = gameObjectParserFactory; + } + + /** + * Finishes object creation. + * @param editTypes the edit types instance + */ + @Deprecated + public void setEditTypes(@NotNull final EditTypes<G, A, R, V> editTypes) { + this.editTypes = editTypes; + } + + /** + * Finishes object creation. + * @param archetypeSet the archetype set instance + */ + @Deprecated + public void setArchetypeSet(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** + * Finishes object creation. + * @param mainView the main view instance + */ + @Deprecated + public void setMainView(@NotNull final MainView<G, A, R, V> mainView) { + this.mainView = mainView; + } + + /** {@inheritDoc} */ + @NotNull + public MapReader<G, A> newMapReader(@NotNull final File file) throws FileNotFoundException { + final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); + return new DefaultMapReader<G, A, R>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mainView, archetypeSet, editTypes, file); + } + +} // class DefaultMapReaderFactory Property changes on: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/src/app/net/sf/gridarta/io/MapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/MapReaderFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/io/MapReaderFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -0,0 +1,42 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.io; + +import java.io.File; +import java.io.FileNotFoundException; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * A factory for creating {@link MapReader} instances. + * @author Andreas Kirschbaum + */ +public interface MapReaderFactory<G extends GameObject<G, A, ?>, A extends MapArchObject<A>> { + + /** + * Create a new {@link MapReader} instance. + * @param file the file to read + * @return the new instance + */ + @NotNull + MapReader<G, A> newMapReader(@NotNull File file) throws FileNotFoundException; + +} // interface MapReaderFactory Property changes on: trunk/src/app/net/sf/gridarta/io/MapReaderFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -22,11 +22,12 @@ import java.awt.Component; import java.io.File; import java.io.IOException; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.MapReader; +import net.sf.gridarta.io.MapReaderFactory; import org.jetbrains.annotations.NotNull; /** @@ -39,20 +40,23 @@ * The gridarta objects factory. */ @NotNull - private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + private MapReaderFactory<G, A> mapReaderFactory; /** * Creates a new instance. - * @param gridartaObjectsFactory the gridarta objects factory */ - protected AbstractMapControlFactory(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory) { - this.gridartaObjectsFactory = gridartaObjectsFactory; + protected AbstractMapControlFactory() { } /** {@inheritDoc} */ + public void setMapReaderFactory(@NotNull final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory) { + this.mapReaderFactory = mapReaderFactory; + } + + /** {@inheritDoc} */ @NotNull public MapControl<G, A, R, V> newPickmapControl(@NotNull final Component parent, @NotNull final File file) throws IOException { - final MapReader<G, A> decoder = gridartaObjectsFactory.newMapReader(file); + final MapReader<G, A> decoder = mapReaderFactory.newMapReader(file); try { decoder.decodeMapFile(false); } finally { Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -36,6 +36,7 @@ import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.DefaultMapReaderFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -105,4 +106,7 @@ @NotNull MapControl<G, A, R, V> newPickmapControl(@NotNull Component parent, @NotNull File file) throws IOException; + @Deprecated + void setMapReaderFactory(@NotNull DefaultMapReaderFactory<G, A, R, V> mapReaderFactory); + } // interface MapControlFactory Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-03 18:52:01 UTC (rev 5424) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-03 19:56:12 UTC (rev 5425) @@ -79,11 +79,12 @@ import net.sf.gridarta.gui.prefs.AppPrefsModel; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.AbstractGameObjectParser; +import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.GameObjectParserFactory; import net.sf.gridarta.io.MapArchObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; -import net.sf.gridarta.io.MapReader; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.DefaultMapModel; @@ -405,7 +406,11 @@ @Before public void setUp() { final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory = new TestGridartaObjectsFactory(); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(gridartaObjectsFactory); + final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory = new TestMapArchObjectFactory(); + final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); + final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory = new TestGameObjectParserFactory(); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); + final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); final AnimationObjects<AnimationObject> animationObjects = new TestAnimationObjects(); @@ -415,12 +420,11 @@ final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory, mapControlFactory, globalSettings); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", mapReaderFactory, mapControlFactory, globalSettings); final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache = new MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(null, mapManager, null, new ImageIcon(), new ImageIcon()); final MapActions mapActions = new TestMapActions(); final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory = new TestGameObjectFactory(); final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory); - final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, mapArchObjectParserFactory, gameObjectParser, rendererFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions); mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions); @@ -501,6 +505,13 @@ /** {@inheritDoc} */ @NotNull @Override + protected MapReaderFactory<TestGameObject, TestMapArchObject> newMapReaderFactory(@NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory) { + throw new AssertionError(); + } + + /** {@inheritDoc} */ + @NotNull + @Override protected GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParserFactory(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory) { throw new AssertionError(); } @@ -529,8 +540,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newMapControlFactory(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory) { - return new TestMapControlFactory(gridartaObjectsFactory); + protected MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newMapControlFactory() { + return new TestMapControlFactory(); } /** {@inheritDoc} */ @@ -954,12 +965,6 @@ /** {@inheritDoc} */ @NotNull - public MapReader<TestGameObject, TestMapArchObject> newMapReader(@NotNull final File file) throws FileNotFoundException { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull public TestArchetype newUndefinedArchetype(@NotNull final String archetypeName) { throw new AssertionError(); } @@ -971,7 +976,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory) { + public void init(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> selectedSquareView, @NotNull final MainControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainControl, @NotNull final MainView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mainView, @NotNull final EditTypes<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> editTypes, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette) { throw new AssertionError(); } @@ -1200,10 +1205,8 @@ /** * Creates a new instance. - * @param gridartaObjectsFactory the gridarta objects factory */ - protected TestMapControlFactory(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory) { - super(gridartaObjectsFactory); + protected TestMapControlFactory() { } /** {@inheritDoc} */ @@ -1277,4 +1280,31 @@ } } + + /** + * A {@link MapArchObjectFactory} implementation for testing purposes. + */ + private static class TestMapArchObjectFactory implements MapArchObjectFactory<TestMapArchObject> { + + /** {@inheritDoc} */ + @NotNull + public TestMapArchObject newMapArchObject(final boolean addDefaultAttributes) { + throw new AssertionError(); + } + + } + + /** + * A {@link GameObjectParserFactory} implementation for testing purposes. + */ + private static class TestGameObjectParserFactory implements GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> { + + /** {@inheritDoc} */ + @NotNull + public GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> newGameObjectParser() { + throw new AssertionError(); + } + + } + } // class DefaultMapModelTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-03 21:24:02
|
Revision: 5433 http://gridarta.svn.sourceforge.net/gridarta/?rev=5433&view=rev Author: akirschbaum Date: 2008-10-03 21:23:56 +0000 (Fri, 03 Oct 2008) Log Message: ----------- Make field private. Modified Paths: -------------- trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 21:19:22 UTC (rev 5432) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-03 21:23:56 UTC (rev 5433) @@ -117,7 +117,6 @@ import net.sf.japi.io.args.ArgParser; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; -import net.sf.japi.swing.misc.ConsoleProgress; import net.sf.japi.swing.prefs.PreferencesGroup; import net.sf.japi.util.filter.file.Factory; import net.sf.japi.util.filter.file.GlobFileFilter; @@ -534,26 +533,6 @@ return 0; } - /** - * Run in collect arches mode. - * @param args the argument strings that were not parsed away by {@link - * ArgParser}. - * @return return code suitable for passing to {@link System#exit(int)} - * (whether {@link System#exit(int)} is really invoked depends on - * the configuration of the {@link ArgParser}.) - * @throws Exception in case of problems during command execution. - * @todo allow arch collection to be configured (input directories, output - * directory) - */ - public int runCollectArches(@NotNull final List<String> args) throws Exception { - try { - mainActions.collectArches(new ConsoleProgress()); - } finally { - doExit(); - } - return 0; - } - /** {@inheritDoc} */ @NotNull @Override Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 21:19:22 UTC (rev 5432) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-03 21:23:56 UTC (rev 5433) @@ -132,6 +132,7 @@ import net.sf.gridarta.utils.XmlHelper; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; +import net.sf.japi.swing.misc.ConsoleProgress; import net.sf.japi.swing.prefs.PreferencesGroup; import net.sf.japi.swing.prefs.PreferencesPane; import net.sf.japi.swing.tod.TipOfTheDayManager; @@ -251,7 +252,7 @@ /** Actions used by this instance. */ @NotNull - protected final MainActions<G, A, R, V> mainActions; + private final MainActions<G, A, R, V> mainActions; /** * The Spells. @@ -901,4 +902,21 @@ scriptControl.executeScript(script, params); } + /** + * Run in collect arches mode. + * @param args the arguments + * @return return code suitable for passing to {@link System#exit(int)} + * @throws Exception in case of problems during command execution. + * @todo allow arch collection to be configured (input directories, output + * directory) + */ + public int runCollectArches(@NotNull final List<String> args) throws Exception { + try { + mainActions.collectArches(new ConsoleProgress()); + } finally { + doExit(); + } + return 0; + } + } // class AbstractMainControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-04 11:11:16
|
Revision: 5437 http://gridarta.svn.sourceforge.net/gridarta/?rev=5437&view=rev Author: akirschbaum Date: 2008-10-04 11:11:13 +0000 (Sat, 04 Oct 2008) Log Message: ----------- Rename identifiers. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/io/DefaultGameObjectParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/GameObject.java trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/daimonin/src/daieditor/io/DefaultGameObjectParser.java trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeType.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java trunk/src/app/net/sf/gridarta/gameobject/Archetype.java trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/match/TypeNrsGameObjectMatcher.java trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/validation/checks/AttributeRangeChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMobOrSpawnPointChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedSpawnPointChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/CustomTypeChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/EmptySpawnPointChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/SquareWithoutFloorChecker.java trunk/src/app/net/sf/gridarta/map/validation/checks/UnsetSlayingChecker.java trunk/src/app/net/sf/gridarta/spells/ArchetypeSetSpellLoader.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeParser.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -309,9 +309,9 @@ } } else if (thisLine.startsWith("type ")) { try { - final int i = Integer.parseInt(thisLine.substring(5)); - archetype.setArchTypNr(i); - if (i == 0) { + final int typeNo = Integer.parseInt(thisLine.substring(5)); + archetype.setTypeNo(typeNo); + if (typeNo == 0) { log.warn(ACTION_FACTORY.format("logDefArchWithZeroType", archetype.getArchetypeName())); } } catch (final NumberFormatException e) { Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -117,8 +117,8 @@ if (arch.getFaceName() != null) { out.append("face ").append(arch.getFaceName()).append('\n'); } - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); } out.append(arch.getObjectText()); @@ -133,8 +133,8 @@ if (arch.getFaceName() != null) { out.append("face ").append(arch.getFaceName()).append('\n'); } - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); } // special: add a string-attribute with the display-category @@ -165,8 +165,8 @@ if (tail.getFaceName() != null) { out.append("face ").append(tail.getFaceName()).append('\n'); } - if (tail.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(tail.getArchTypNr())).append('\n'); + if (tail.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); } out.append(tail.getObjectText()); Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -147,7 +147,7 @@ @Override public boolean isScripted() { for (final GameObject tmp : this) { - if (tmp.archType == TYPE_EVENT_CONNECTOR) { + if (tmp.typeNo == TYPE_EVENT_CONNECTOR) { return true; } } @@ -179,7 +179,7 @@ } final Archetype archetype = getArchetype(); - return archType == archetype.getArchTypNr(); + return typeNo == archetype.getTypeNo(); //XXX: && loreText.equals(archetype.getLoreText()) } @@ -189,7 +189,7 @@ return super.isEqual(gameObject) && gameObject.loreText.equals(loreText) // ignore "scriptArchData" - && gameObject.archType == archType; + && gameObject.typeNo == typeNo; } /** {@inheritDoc} */ @@ -218,8 +218,8 @@ } setRealFace(getFaceName()); // if the type is still unset, then we take the default one - if (getArchTypNr() == TYPE_UNSET) { - setArchTypNr(archetype.getArchTypNr()); + if (getTypeNo() == TYPE_NO_UNSET) { + setTypeNo(archetype.getTypeNo()); } setMultiX(archetype.getMultiX()); Modified: trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/gameobject/UndefinedArchetype.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -37,7 +37,7 @@ */ public UndefinedArchetype(@NotNull final String archetypeName) { setArchetypeName(archetypeName); - setArchTypNr(0); + setTypeNo(0); setIsArchetype(); setEditorFolder("intern"); } Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -58,7 +58,7 @@ /** * The object type for event objects. */ - private final int eventType; + private final int eventTypeNo; private boolean changed; @@ -66,19 +66,19 @@ * Create a ScriptArchData. * @param owner owner of this ScriptArchData * @param subtypeAttribute the attribute name for the subtype field - * @param eventType the object type for event objects + * @param eventTypeNo the object type for event objects */ - public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventType) { + public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { this.owner = owner; this.subtypeAttribute = subtypeAttribute; - this.eventType = eventType; + this.eventTypeNo = eventTypeNo; } /** {@inheritDoc} */ @Nullable public GameObject getScriptedEvent(final int eventSubtype) { for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { + if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { return tmp; } } @@ -91,7 +91,7 @@ final Iterator<GameObject> it = owner.iterator(); while (it.hasNext()) { final GameObject tmp = it.next(); - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { final ScriptedEvent se = new ScriptedEvent(tmp); // validate this event if (!se.isValid()) { @@ -112,7 +112,7 @@ //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType final Vector<String> content = new Vector<String>(); for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { content.add(" " + ScriptArchUtils.typeName(tmp.getAttributeInt(subtypeAttribute))); } } @@ -128,7 +128,7 @@ /* Find the event object */ for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { if (eventIndex == 0) { oldEvent = tmp; break; @@ -167,7 +167,7 @@ @Override public boolean isEmpty() { for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { return false; } } Modified: trunk/crossfire/src/cfeditor/io/DefaultGameObjectParser.java =================================================================== --- trunk/crossfire/src/cfeditor/io/DefaultGameObjectParser.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/crossfire/src/cfeditor/io/DefaultGameObjectParser.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -358,7 +358,7 @@ fields.put("msg", msgText + "endmsg"); } - if (gameObject.getArchTypNr() != archetype.getArchTypNr()) { + if (gameObject.getTypeNo() != archetype.getTypeNo()) { // this gameObject has special type if (gameObject.getObjectText().contains("type ")) { // oh oh - there might also be a type in the archtext which @@ -380,7 +380,7 @@ } // now append the type to the archtext - fields.put("type", Integer.toString(gameObject.getArchTypNr())); + fields.put("type", Integer.toString(gameObject.getTypeNo())); } final String objText = gameObject.getObjectText(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeParser.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -299,9 +299,9 @@ } } else if (thisLine.startsWith("type ")) { try { - final int i = Integer.parseInt(thisLine.substring(5)); - archetype.setArchTypNr(i); - if (i == 0) { + final int typeNo = Integer.parseInt(thisLine.substring(5)); + archetype.setTypeNo(typeNo); + if (typeNo == 0) { log.warn(ACTION_FACTORY.format("logDefArchWithZeroType", archetype.getArchetypeName())); } } catch (final NumberFormatException e) { Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -141,8 +141,8 @@ //if(arch.getFaceName() != null) { // out.append("face ").append(arch.getFaceNAme()).append('\n'); //} - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); } out.append(arch.getObjectText()); @@ -157,8 +157,8 @@ //if(arch.getFaceName() != null) { // out.append("face ").append(arch.getFaceName()).append('\n'); //} - if (arch.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(arch.getArchTypNr())).append('\n'); + if (arch.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(arch.getTypeNo())).append('\n'); } if (arch.getMultiShapeID() > 0) { out.append("mpart_id ").append(Integer.toString(arch.getMultiShapeID())).append('\n'); @@ -195,8 +195,8 @@ //if(arch.getFaceName() != null) { // out.append("face ").append(arch.getFaceName()).append('\n'); //} - if (tail.getArchTypNr() > 0) { - out.append("type ").append(Integer.toString(tail.getArchTypNr())).append('\n'); + if (tail.getTypeNo() > 0) { + out.append("type ").append(Integer.toString(tail.getTypeNo())).append('\n'); } if (tail.getMultiShapeID() > 0) { out.append("mpart_id ").append(Integer.toString(tail.getMultiShapeID())).append('\n'); Modified: trunk/daimonin/src/daieditor/gameobject/GameObject.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gameobject/GameObject.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -102,7 +102,7 @@ public void addLast(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this) != null && archetypeTypeSet.getTypeOfArch(this).getTypeNo() == TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == TYPE_MOB) { - gameObject.archType = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB + gameObject.typeNo = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB } super.addLast(gameObject); } @@ -112,7 +112,7 @@ public void addFirst(@NotNull final GameObject gameObject) { // force type change when a MONSTER is put in a spawn point if (archetypeTypeSet.getTypeOfArch(this).getTypeNo() == TYPE_SPAWN_POINT && archetypeTypeSet.getTypeOfArch(gameObject).getTypeNo() == TYPE_MOB) { - gameObject.archType = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB + gameObject.typeNo = TYPE_SPAWN_POINT_MOB; // change to SPAWN_POINT_MOB } super.addFirst(gameObject); } @@ -202,7 +202,7 @@ @Override public boolean isScripted() { for (final GameObject tmp : this) { - if (tmp.archType == TYPE_EVENT_OBJECT) { + if (tmp.typeNo == TYPE_EVENT_OBJECT) { return true; } } @@ -235,7 +235,7 @@ && gameObject.multiPartNr == multiPartNr && gameObject.isLowestPart == isLowestPart // ignore "scriptArchData" - && gameObject.archType == archType + && gameObject.typeNo == typeNo && gameObject.transFace == transFace; } @@ -269,8 +269,8 @@ } setRealFace(getFaceName()); // if the type is still unset, then we take the default one - if (getArchTypNr() == TYPE_UNSET) { - setArchTypNr(archetype.getArchTypNr()); + if (getTypeNo() == TYPE_NO_UNSET) { + setTypeNo(archetype.getTypeNo()); } // if the type is still unset, then we take the default one Modified: trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gameobject/UndefinedArchetype.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -37,7 +37,7 @@ */ public UndefinedArchetype(@NotNull final String archetypeName) { setArchetypeName(archetypeName); - setArchTypNr(0); + setTypeNo(0); setIsArchetype(); setEditorFolder("intern"); } Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -58,7 +58,7 @@ /** * The object type for event objects. */ - private final int eventType; + private final int eventTypeNo; private boolean changed; @@ -66,19 +66,19 @@ * Create a ScriptArchData. * @param owner owner of this ScriptArchData * @param subtypeAttribute the attribute name for the subtype field - * @param eventType the object type for event objects + * @param eventTypeNo the object type for event objects */ - public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventType) { + public ScriptArchData(final GameObject owner, @NotNull final String subtypeAttribute, final int eventTypeNo) { this.owner = owner; this.subtypeAttribute = subtypeAttribute; - this.eventType = eventType; + this.eventTypeNo = eventTypeNo; } /** {@inheritDoc} */ @Nullable public GameObject getScriptedEvent(final int eventSubtype) { for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { + if (tmp.getTypeNo() == eventTypeNo && tmp.getAttributeInt(subtypeAttribute) == eventSubtype) { return tmp; } } @@ -91,7 +91,7 @@ final Iterator<GameObject> it = owner.iterator(); while (it.hasNext()) { final GameObject tmp = it.next(); - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { final ScriptedEvent se = new ScriptedEvent(tmp); // validate this event if (!se.isValid()) { @@ -112,7 +112,7 @@ //noinspection CollectionDeclaredAsConcreteClass,UseOfObsoleteCollectionType final Vector<String> content = new Vector<String>(); for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { content.add(" " + ScriptArchUtils.typeName(tmp.getAttributeInt(subtypeAttribute))); } } @@ -128,7 +128,7 @@ /* Find the event object */ for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { if (eventIndex == 0) { oldEvent = tmp; break; @@ -167,7 +167,7 @@ @Override public boolean isEmpty() { for (final GameObject tmp : owner) { - if (tmp.getArchTypNr() == eventType) { + if (tmp.getTypeNo() == eventTypeNo) { return false; } } Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -364,7 +364,7 @@ if (tmpNode != null && tmpNode.isLowestPart() || node.isLowestPart()) { img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); } else - if (node.isInContainer() && ((GameObject) node.getContainer()).getArchTypNr() == Archetype.TYPE_SPAWN_POINT) { + if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); } } else { @@ -381,7 +381,7 @@ } } // Paint first object (most likely a mob) in spawn points. - if (node.getArchTypNr() == Archetype.TYPE_SPAWN_POINT) { + if (node.getTypeNo() == Archetype.TYPE_SPAWN_POINT) { final GameObject mob = node.getFirst(); if (mob != null) { paintGameObject(grfx, xstart, ystart, mob); Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -174,7 +174,7 @@ grfx.drawImage(img.getImage(), x, y, img.getImageObserver()); //img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); } else - if (node.isInContainer() && ((GameObject) node.getContainer()).getArchTypNr() == Archetype.TYPE_SPAWN_POINT) { + if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { final int x = xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()); final int y = ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()); grfx.drawImage(img.getImage(), x, y, img.getImageObserver()); @@ -189,7 +189,7 @@ grfx.drawImage(img.getImage(), xstart - xoff, ystart - yoff, img.getImageObserver()); } // Paint first object (most likely a mob) in spawn points. - if (node.getArchTypNr() == Archetype.TYPE_SPAWN_POINT) { + if (node.getTypeNo() == Archetype.TYPE_SPAWN_POINT) { final GameObject mob = node.getFirst(); if (mob != null) { paint(grfx, xstart, ystart, mob); Modified: trunk/daimonin/src/daieditor/io/DefaultGameObjectParser.java =================================================================== --- trunk/daimonin/src/daieditor/io/DefaultGameObjectParser.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/io/DefaultGameObjectParser.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -68,7 +68,7 @@ format.format("msg\n%sendmsg\n", msgText); } - if (gameObject.getArchTypNr() != archetype.getArchTypNr()) { + if (gameObject.getTypeNo() != archetype.getTypeNo()) { // this gameObject has special type if (gameObject.getObjectText().contains("type ")) { // oh oh - there might also be a type in the archtext which @@ -89,7 +89,7 @@ } // now append the type to the archtext - format.format("type %d\n", gameObject.getArchTypNr()); + format.format("type %d\n", gameObject.getTypeNo()); } final String objText = gameObject.getObjectText(); Modified: trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/map/validation/checks/ExitChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -48,7 +48,7 @@ /** {@inheritDoc} */ public void validate(final GameObject gameObject, final ErrorCollector<GameObject, MapArchObject, Archetype> errorCollector) { - if (gameObject.getArchTypNr() == Archetype.TYPE_EXIT) { + if (gameObject.getTypeNo() == Archetype.TYPE_EXIT) { final String path = gameObject.getAttributeString("slaying", false); if (path.length() > 0) { final File newfile; Modified: trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java =================================================================== --- trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/daimonin/src/daieditor/map/validation/checks/SlayingChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -39,7 +39,7 @@ /** {@inheritDoc} */ @Override public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - switch (gameObject.getArchTypNr()) { + switch (gameObject.getTypeNo()) { case daieditor.gameobject.Archetype.TYPE_ENVIRONMENT_SENSOR: final String slaying = gameObject.getAttributeString("slaying", true); if (!pattern.matcher(slaying).matches()) { Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeType.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeType.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeType.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -118,7 +118,7 @@ } public boolean matches(@NotNull final Archetype<?, ?, ?> archetype) { - if (typeNo != archetype.getArchTypNr()) { + if (typeNo != archetype.getTypeNo()) { return false; } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeSet.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -130,7 +130,7 @@ public ArchetypeType getTypeOfArch(final G object) { // check if the type of the object is present in the definitions for (final ArchetypeType tmp : archetypeTypeList) { - if (tmp.getTypeNo() == object.getArchTypNr()) { + if (tmp.getTypeNo() == object.getTypeNo()) { if (tmp.getTypeAttr() == null) { // no type-attributes, so we only compared type-numbers return tmp; Modified: trunk/src/app/net/sf/gridarta/gameobject/Archetype.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gameobject/Archetype.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -149,13 +149,13 @@ * Returns the type number of this Archetype. * @return The type number of this Archetype. */ - int getArchTypNr(); + int getTypeNo(); /** * Sets the type number of this Archetype. * @param typNr Type number of this Archetype. */ - void setArchTypNr(int typNr); + void setTypeNo(int typNr); /** * Returns the name of the face of this Archetype or GameObject. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -53,7 +53,7 @@ private static final long serialVersionUID = 1; /** Special constant that's used if a GameObject has no GameObject type set. */ - public static final int TYPE_UNSET = -666; + public static final int TYPE_NO_UNSET = -666; /** * The archetype set to use. @@ -190,7 +190,7 @@ private String faceName = null; /** The object type. */ - protected int archType = TYPE_UNSET; + protected int typeNo = TYPE_NO_UNSET; /** Object animation <code>animation <var>animName</var></code>. */ private String animName; @@ -228,17 +228,17 @@ } /** {@inheritDoc} */ - public int getArchTypNr() { - return archType; + public int getTypeNo() { + return typeNo; } /** {@inheritDoc} */ - public void setArchTypNr(final int typNr) { - if (archType == typNr) { + public void setTypeNo(final int typeNo) { + if (this.typeNo == typeNo) { return; } - archType = typNr; + this.typeNo = typeNo; gameObjectChanged(); } @@ -1511,8 +1511,8 @@ resetObjectText(); // if no type was set, zero is taken - if (archType == TYPE_UNSET) { - setArchTypNr(0); + if (typeNo == TYPE_NO_UNSET) { + setTypeNo(0); } boolean scriptflag = false; Modified: trunk/src/app/net/sf/gridarta/gameobject/match/TypeNrsGameObjectMatcher.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/match/TypeNrsGameObjectMatcher.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gameobject/match/TypeNrsGameObjectMatcher.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -45,7 +45,7 @@ /** {@inheritDoc} */ public boolean isMatching(final GameObject<?, ?, ?> arch) { - return Arrays.binarySearch(types, arch.getArchTypNr()) >= 0; + return Arrays.binarySearch(types, arch.getTypeNo()) >= 0; } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/LockedItemsView.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -70,7 +70,7 @@ * @param gameObject The game object to process. */ private void scanGameObject(@NotNull final G gameObject) { - if (typeNumbers.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { final String slayingSpec = gameObject.getAttributeString("slaying"); if (slayingSpec.length() > 0) { addConnection(slayingSpec, gameObject); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -654,7 +654,7 @@ // ### TODO: for changed types, copy fixed attributes over default arches ### if (type.getAttr()[i] instanceof ArchetypeAttributeFixed) { final String defaultValue = archetype.getAttributeString(type.getAttr()[i].getArchetypeAttributeName()); - if (defaultValue.length() == 0 || (gameObject.getArchTypNr() != archetype.getArchTypNr() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getAttributeName()))) { + if (defaultValue.length() == 0 || (gameObject.getTypeNo() != archetype.getTypeNo() && !defaultValue.equalsIgnoreCase(type.getAttr()[i].getAttributeName()))) { // usually, fixed attributes are only applied when *not* defined in the archetype. // the reason behind this is: if the default gameObject violates our fixed attribute, // we assume the default gameObject is "right" and we are "wrong". The typedefs aren't that trustworthy. @@ -678,7 +678,7 @@ // --- parsing succeeded, now we write it into the gameObject/map --- gameObject.setObjectText(newArchText.toString()); - //gameObject.setArchTypNr(); + //gameObject.setTypeNo(); if (newName[0] != null) { if (newName[0].length() == 0) { gameObject.setObjName(null); @@ -851,7 +851,7 @@ frame.type = newType; // set new type structure // change the gameObject to be of the new type: - gameObject.setArchTypNr(newType.getTypeNo()); + gameObject.setTypeNo(newType.getTypeNo()); dialogAttribs.clear(); listNr = frame.typesel.getSelectedIndex(); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -519,7 +519,7 @@ // we look for 'type' in the ArchText. In future maybe type should get // a separate text field if (selectedGameObject.getAttributeString("type", false).length() > 0) { - selectedGameObject.setArchTypNr(selectedGameObject.getAttributeInt("type", false)); // specified type + selectedGameObject.setTypeNo(selectedGameObject.getAttributeInt("type", false)); // specified type } selectedGameObject.updateEditType(selectedGameObject.getMapSquare().getMapModel().getMapControl().getActiveEditType()); Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -132,7 +132,7 @@ gameObject.setMapY(Integer.parseInt(thisLine.substring(2))); } else if (thisLine.startsWith("type ")) { // Arches in maps can override their default arch's type - gameObject.setArchTypNr(Integer.parseInt(thisLine.substring(5))); + gameObject.setTypeNo(Integer.parseInt(thisLine.substring(5))); // don't load it into the archtext! (why?) } else if (thisLine.startsWith("face ")) { gameObject.setFaceName(thisLine.substring(5).trim()); Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -794,7 +794,7 @@ if (!allowMany) { // check if there is already an arch of that kind for (final G t : getMapSquare(pos)) { - if (t.hasSameArchetype(gameObject) || t.getArchTypNr() == gameObject.getArchTypNr()) { + if (t.hasSameArchetype(gameObject) || t.getTypeNo() == gameObject.getTypeNo()) { // there's a match - don't insert a second one return null; } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/AttributeRangeChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/AttributeRangeChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/AttributeRangeChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -68,7 +68,7 @@ /** {@inheritDoc} */ public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - final Type<G, A, R> type = types.get(gameObject.getArchTypNr()); + final Type<G, A, R> type = types.get(gameObject.getTypeNo()); if (type == null) { return; } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMobOrSpawnPointChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedMobOrSpawnPointChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -46,20 +46,20 @@ private final List<G> mobsOrSpawnPoints = new ArrayList<G>(); /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public BlockedMobOrSpawnPointChecker(final Integer... types) { - this.types.addAll(Arrays.asList(types)); + public BlockedMobOrSpawnPointChecker(final Integer... typeNumbers) { + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** {@inheritDoc} */ public void validate(final MapSquare<G, A, R> mapSquare, final ErrorCollector<G, A, R> errorCollector) { for (final G gameObject : mapSquare) { - if (types.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { mobsOrSpawnPoints.add(gameObject); } else if (gameObject.getAttributeInt("no_pass", true) == 1) { blockers.add(gameObject); Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedSpawnPointChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedSpawnPointChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/BlockedSpawnPointChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -75,14 +75,14 @@ private BlockedMatrix<G, A, R> blocked = null; /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public BlockedSpawnPointChecker(final Integer... types) { - this.types.addAll(Arrays.asList(types)); + public BlockedSpawnPointChecker(final Integer... typeNumbers) { + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** {@inheritDoc} */ @@ -122,7 +122,7 @@ * @param errorCollector Where to add the errors to. */ private void checkSpawnPoint(final G gameObject, final Point pos, final ErrorCollector<G, A, R> errorCollector) { - if (!types.contains(gameObject.getArchTypNr())) { + if (!typeNumbers.contains(gameObject.getTypeNo())) { return; } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/ConnectionChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -42,13 +42,13 @@ public class ConnectionChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValidator implements MapValidator<G, A, R> { /** The type numbers of connected objects that are sources. */ - private final Set<Integer> sources = new HashSet<Integer>(); + private final Set<Integer> sourceTypeNumbers = new HashSet<Integer>(); /** The type numbers of connected objects that are sinks. */ - private final Set<Integer> sinks = new HashSet<Integer>(); + private final Set<Integer> sinkTypeNumbers = new HashSet<Integer>(); /** The type number for event objects. */ - private final int eventType; + private final int eventTypeNo; /** The attribute key for subtype numbers. */ private final String eventSubtypeKey; @@ -58,21 +58,21 @@ /** * Create a new instance. - * @param sources The type numbers of connected objects that are sources. - * @param sinks The type numbers of connected objects that are sinks. - * @param eventType The type number of event objects. + * @param sourceTypeNumbers The type numbers of connected objects that are sources. + * @param sinkTypeNumbers The type numbers of connected objects that are sinks. + * @param eventTypeNo The type number of event objects. * @param eventSubtypeKey The subtype attribute key of event objects. * @param eventSubtypes The subtype numbers of events objects that are * sinks. */ - public ConnectionChecker(@NotNull final int[] sources, @NotNull final int[] sinks, final int eventType, @NotNull final String eventSubtypeKey, @NotNull final int[] eventSubtypes) { - for (final int source : sources) { - this.sources.add(source); + public ConnectionChecker(@NotNull final int[] sourceTypeNumbers, @NotNull final int[] sinkTypeNumbers, final int eventTypeNo, @NotNull final String eventSubtypeKey, @NotNull final int[] eventSubtypes) { + for (final int source : sourceTypeNumbers) { + this.sourceTypeNumbers.add(source); } - for (final int sink : sinks) { - this.sinks.add(sink); + for (final int sink : sinkTypeNumbers) { + this.sinkTypeNumbers.add(sink); } - this.eventType = eventType; + this.eventTypeNo = eventTypeNo; this.eventSubtypeKey = eventSubtypeKey; for (final int eventSubtype : eventSubtypes) { this.eventSubtypes.add(eventSubtype); @@ -136,7 +136,7 @@ * @return whether the game object is a source */ private boolean isSource(@NotNull final G gameObject) { - return sources.contains(gameObject.getArchTypNr()); + return sourceTypeNumbers.contains(gameObject.getTypeNo()); } /** @@ -145,12 +145,12 @@ * @return whether the game object is a sink */ private boolean isSink(@NotNull final G gameObject) { - if (sinks.contains(gameObject.getArchTypNr())) { + if (sinkTypeNumbers.contains(gameObject.getTypeNo())) { return true; } for (final G inv : gameObject) { - if (inv.getArchTypNr() == eventType) { + if (inv.getTypeNo() == eventTypeNo) { final String subtypeSpec = inv.getAttributeString(eventSubtypeKey, true); try { final int subtype = Integer.parseInt(subtypeSpec); Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/CustomTypeChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/CustomTypeChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/CustomTypeChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -44,29 +44,29 @@ /** {@inheritDoc} */ public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - final int archetypeType = gameObject.getArchetype().getArchTypNr(); - final int gameObjectType = gameObject.getArchTypNr(); - if (gameObjectType != archetypeType && !isAllowedTypeChange(gameObject, archetypeType, gameObjectType)) { - errorCollector.collect(new CustomTypeError<G, A, R>(gameObject, archetypeType, gameObjectType)); + final int archetypeTypeNo = gameObject.getArchetype().getTypeNo(); + final int gameObjectTypeNo = gameObject.getTypeNo(); + if (gameObjectTypeNo != archetypeTypeNo && !isAllowedTypeChange(gameObject, archetypeTypeNo, gameObjectTypeNo)) { + errorCollector.collect(new CustomTypeError<G, A, R>(gameObject, archetypeTypeNo, gameObjectTypeNo)); } } /** * Return whether the given game's changed type is allowed. * @param gameObject The game object to check. - * @param archetypeType The old type. - * @param gameObjectType The new type. + * @param archetypeTypeNo The old type. + * @param gameObjectTypeNo The new type. * @return Whether the type change is allowed. */ - private boolean isAllowedTypeChange(final G gameObject, final int archetypeType, final int gameObjectType) { - final Map<Integer, Integer> entries = ignoreEntries.get(archetypeType); + private boolean isAllowedTypeChange(final G gameObject, final int archetypeTypeNo, final int gameObjectTypeNo) { + final Map<Integer, Integer> entries = ignoreEntries.get(archetypeTypeNo); if (entries == null) { return false; } - final Integer allowedEnvType = entries.get(gameObjectType); + final Integer allowedEnvType = entries.get(gameObjectTypeNo); if (allowedEnvType == null) { - return entries.containsKey(gameObjectType); + return entries.containsKey(gameObjectTypeNo); } final GameObjectContainer<G, A, R> env = gameObject.getContainer(); @@ -75,8 +75,8 @@ } final G envGameObject = (G) env; - final int envType = envGameObject.getArchTypNr(); - return envType == allowedEnvType; + final int envTypeNo = envGameObject.getTypeNo(); + return envTypeNo == allowedEnvType; } /** Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/DoubleTypeChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -39,21 +39,21 @@ /** {@inheritDoc} */ public void validate(final MapSquare<G, A, R> mapSquare, final ErrorCollector<G, A, R> errorCollector) { - final Map<Integer, Object> typeNums = new HashMap<Integer, Object>(); + final Map<Integer, Object> typeNumbers = new HashMap<Integer, Object>(); for (final G gameObject : mapSquare) { - final Integer typeNum = gameObject.getArchTypNr(); - if (typeNums.containsKey(typeNum)) { - final Object o = typeNums.get(typeNum); + final Integer typeNo = gameObject.getTypeNo(); + if (typeNumbers.containsKey(typeNo)) { + final Object o = typeNumbers.get(typeNo); if (o instanceof GameObject) { final DoubleTypeError<G, A, R> error = new DoubleTypeError<G, A, R>(mapSquare, (G) o); - typeNums.put(typeNum, error); + typeNumbers.put(typeNo, error); errorCollector.collect(error); } else { assert o instanceof DoubleTypeError; ((GameObjectsValidationError<G, A, R>) o).addGameObject(gameObject); } } else { - typeNums.put(typeNum, gameObject); + typeNumbers.put(typeNo, gameObject); } } } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/EmptySpawnPointChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/EmptySpawnPointChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/EmptySpawnPointChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -36,19 +36,19 @@ public class EmptySpawnPointChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValidator implements GameObjectValidator<G, A, R> { /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public EmptySpawnPointChecker(final Integer... types) { - this.types.addAll(Arrays.asList(types)); + public EmptySpawnPointChecker(final Integer... typeNumbers) { + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** {@inheritDoc} */ public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - if (types.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { if (gameObject.isEmpty()) { errorCollector.collect(new EmptySpawnPointError<G, A, R>(gameObject)); } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/MobOutsideSpawnPointChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -36,19 +36,19 @@ public class MobOutsideSpawnPointChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValidator implements GameObjectValidator<G, A, R> { /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public MobOutsideSpawnPointChecker(final Integer... types) { - this.types.addAll(Arrays.asList(types)); + public MobOutsideSpawnPointChecker(final Integer... typeNumbers) { + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** {@inheritDoc} */ public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - if (types.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { errorCollector.collect(new MobOutsideSpawnPointError<G, A, R>(gameObject)); } } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/SquareWithoutFloorChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/SquareWithoutFloorChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/SquareWithoutFloorChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -37,21 +37,21 @@ public class SquareWithoutFloorChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValidator implements SquareValidator<G, A, R> { /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public SquareWithoutFloorChecker(final Integer... types) { - this.types.addAll(Arrays.asList(types)); + public SquareWithoutFloorChecker(final Integer... typeNumbers) { + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** {@inheritDoc} */ public void validate(final MapSquare<G, A, R> mapSquare, final ErrorCollector<G, A, R> errorCollector) { boolean floorFound = false; for (final G gameObject : mapSquare) { - if (types.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { floorFound = true; break; } Modified: trunk/src/app/net/sf/gridarta/map/validation/checks/UnsetSlayingChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/validation/checks/UnsetSlayingChecker.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/map/validation/checks/UnsetSlayingChecker.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -36,18 +36,18 @@ public class UnsetSlayingChecker<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValidator implements GameObjectValidator<G, A, R> { /** The object types to check. */ - private final Set<Integer> types = new HashSet<Integer>(); + private final Set<Integer> typeNumbers = new HashSet<Integer>(); /** The values which do not trigger a warning. */ private final Set<String> allowedValues = new HashSet<String>(); /** * Create a new instance. - * @param types The object types to check. + * @param typeNumbers The object types to check. */ - public UnsetSlayingChecker(final Integer... types) { + public UnsetSlayingChecker(final Integer... typeNumbers) { allowedValues.add(""); - this.types.addAll(Arrays.asList(types)); + this.typeNumbers.addAll(Arrays.asList(typeNumbers)); } /** @@ -60,7 +60,7 @@ /** {@inheritDoc} */ public void validate(final G gameObject, final ErrorCollector<G, A, R> errorCollector) { - if (types.contains(gameObject.getArchTypNr())) { + if (typeNumbers.contains(gameObject.getTypeNo())) { final String slayingArchetype = gameObject.getArchetype().getAttributeString("slaying"); if (!allowedValues.contains(slayingArchetype)) { final String slayingObject = gameObject.getAttributeString("slaying"); Modified: trunk/src/app/net/sf/gridarta/spells/ArchetypeSetSpellLoader.java =================================================================== --- trunk/src/app/net/sf/gridarta/spells/ArchetypeSetSpellLoader.java 2008-10-04 09:41:13 UTC (rev 5436) +++ trunk/src/app/net/sf/gridarta/spells/ArchetypeSetSpellLoader.java 2008-10-04 11:11:13 UTC (rev 5437) @@ -39,13 +39,13 @@ * Find all game object that describe spells and add corresponding {@link * Spell} objects. * @param archetypeSet The archetype set to scan. - * @param archType The type number to search for. + * @param typeNo The type number to search for. * @param spells The <code>Spells</code> instance to add the spells to. */ - public void load(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final int archType, @NotNull final Spells<GameObjectSpell<G, A, R>> spells) { + public void load(@NotNull final ArchetypeSet<G, A, R> archetypeSet, final int typeNo, @NotNull final Spells<GameObjectSpell<G, A, R>> spells) { int numSpells = 0; for (final R archetype : archetypeSet.getArchetypes()) { - if (archetype.getArchTypNr() == archType) { + if (archetype.getTypeNo() == typeNo) { spells.add(new GameObjectSpell<G, A, R>(archetype)); numSpells++; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-05 10:26:30
|
Revision: 5445 http://gridarta.svn.sourceforge.net/gridarta/?rev=5445&view=rev Author: akirschbaum Date: 2008-10-05 10:23:47 +0000 (Sun, 05 Oct 2008) Log Message: ----------- Implement incremental undo stack. Increase undo stack to 100 edit operations. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/gameobject/GameObject.java trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gameobject/GameObject.java trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java trunk/src/app/net/sf/gridarta/map/MapModel.java trunk/src/app/net/sf/gridarta/map/MapSquare.java trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java trunk/src/app/net/sf/gridarta/undo/UndoModel.java trunk/src/app/net/sf/gridarta/undo/UndoState.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/map/SavedSquares.java trunk/src/app/net/sf/gridarta/undo/UndoType.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/map/MapState.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/crossfire/ChangeLog 2008-10-05 10:23:47 UTC (rev 5445) @@ -1,3 +1,9 @@ +2008-10-05 Andreas Kirschbaum + + * Implement incremental undo stack. Makes edit operations more + responsive and reduces memory consumption. Increase undo stack to + 100 edit operations. + 2008-10-04 Andreas Kirschbaum * Fix selection painting in pickmaps. Modified: trunk/crossfire/src/cfeditor/gameobject/GameObject.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/crossfire/src/cfeditor/gameobject/GameObject.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -79,8 +79,12 @@ return; } - this.loreText = trimmedLoreText.intern(); - gameObjectChanged(); + beginGameObjectChange(); + try { + this.loreText = trimmedLoreText.intern(); + } finally { + endGameObjectChange(); + } } /** {@inheritDoc} */ Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/daimonin/ChangeLog 2008-10-05 10:23:47 UTC (rev 5445) @@ -1,3 +1,9 @@ +2008-10-05 Andreas Kirschbaum + + * Implement incremental undo stack. Makes edit operations more + responsive and reduces memory consumption. Increase undo stack to + 100 edit operations. + 2008-10-03 Andreas Kirschbaum * Use network settings in updater. Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObject.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObject.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -238,8 +238,12 @@ return; } - this.typeNo = typeNo; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.typeNo = typeNo; + } finally { + endGameObjectChange(); + } } /** @@ -254,8 +258,12 @@ return; } - this.faceName = newFaceName; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.faceName = newFaceName; + } finally { + endGameObjectChange(); + } } /** {@inheritDoc} */ @@ -580,13 +588,22 @@ /** {@inheritDoc} */ @Override - protected void notifyChanged() { + protected void notifyBeginChange() { final MapSquare<G, A, R> mapSquare = getMapSquare(); if (mapSquare != null) { - mapSquare.getMapModel().gameObjectChanged((G) this); + mapSquare.getMapModel().beginGameObjectChange((G) this); } } + /** {@inheritDoc} */ + @Override + protected void notifyEndChange() { + final MapSquare<G, A, R> mapSquare = getMapSquare(); + if (mapSquare != null) { + mapSquare.getMapModel().endGameObjectChange((G) this); + } + } + /** Move this GameObject top. Does nothing if the object has no container. */ public void moveTop() { if (isArchetype()) { @@ -731,8 +748,12 @@ return; } - this.archetype = archetype; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.archetype = archetype; + } finally { + endGameObjectChange(); + } } /** Set that this GameObject is an Archetype. */ @@ -776,8 +797,12 @@ return; } - this.archetypeName = newArchetypeName; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.archetypeName = newArchetypeName; + } finally { + endGameObjectChange(); + } } /** {@inheritDoc} */ @@ -801,8 +826,12 @@ return; } - this.artifact = artifact; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.artifact = artifact; + } finally { + endGameObjectChange(); + } } /** @@ -865,8 +894,12 @@ return; } - this.editType = editType; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.editType = editType; + } finally { + endGameObjectChange(); + } } /** @@ -882,9 +915,13 @@ msgText = new StringBuilder(); } - msgText.append(StringUtils.removeTrailingWhitespace(text)); - msgText.append('\n'); - gameObjectChanged(); + beginGameObjectChange(); + try { + msgText.append(StringUtils.removeTrailingWhitespace(text)); + msgText.append('\n'); + } finally { + endGameObjectChange(); + } } /** @@ -906,15 +943,19 @@ return; } - if (trimmedMsgText == null) { - this.msgText = null; - } else if (this.msgText == null) { - this.msgText = new StringBuilder(trimmedMsgText); - } else { - this.msgText.setLength(0); - this.msgText.append(trimmedMsgText); + beginGameObjectChange(); + try { + if (trimmedMsgText == null) { + this.msgText = null; + } else if (this.msgText == null) { + this.msgText = new StringBuilder(trimmedMsgText); + } else { + this.msgText.setLength(0); + this.msgText.append(trimmedMsgText); + } + } finally { + endGameObjectChange(); } - gameObjectChanged(); } /** @@ -1121,8 +1162,12 @@ return; } - this.objName = newObjName; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.objName = newObjName; + } finally { + endGameObjectChange(); + } } /** @@ -1168,12 +1213,16 @@ * multiple lines. */ public final void addObjectText(final String line) { - objectText.append(line); - if (!line.endsWith("\n")) { - objectText.append('\n'); + beginGameObjectChange(); + try { + objectText.append(line); + if (!line.endsWith("\n")) { + objectText.append('\n'); + } + clearAttributeCache(); + } finally { + endGameObjectChange(); } - clearAttributeCache(); - gameObjectChanged(); } /** Clears the object text of this GameObject. */ @@ -1182,9 +1231,13 @@ return; } - objectText.setLength(0); - clearAttributeCache(); - gameObjectChanged(); + beginGameObjectChange(); + try { + objectText.setLength(0); + clearAttributeCache(); + } finally { + endGameObjectChange(); + } } /** @@ -1196,13 +1249,17 @@ return; } - resetObjectText(); - this.objectText.append(objectText); - if (!objectText.endsWith("\n")) { - this.objectText.append('\n'); + beginGameObjectChange(); + try { + resetObjectText(); + this.objectText.append(objectText); + if (!objectText.endsWith("\n")) { + this.objectText.append('\n'); + } + clearAttributeCache(); + } finally { + endGameObjectChange(); } - clearAttributeCache(); - gameObjectChanged(); } /** @@ -1427,8 +1484,13 @@ if (this.direction == direction) { return; } - this.direction = direction; - gameObjectChanged(); + + beginGameObjectChange(); + try { + this.direction = direction; + } finally { + endGameObjectChange(); + } } /** @@ -1498,10 +1560,17 @@ return retErrors; } + /** Records that this game object is about to change. */ + protected void beginGameObjectChange() { + for (G part = getHead(); part != null; part = part.getMultiNext()) { + part.notifyBeginChange(); + } + } + /** Records that this game object has changed. */ - protected void gameObjectChanged() { + protected void endGameObjectChange() { for (G part = getHead(); part != null; part = part.getMultiNext()) { - part.notifyChanged(); + part.notifyEndChange(); } } @@ -1606,8 +1675,12 @@ return; } - this.animName = newAnimName; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.animName = newAnimName; + } finally { + endGameObjectChange(); + } } /** {@inheritDoc} */ @@ -1638,8 +1711,12 @@ return; } - this.faceObjName = newFaceObjName; - gameObjectChanged(); + beginGameObjectChange(); + try { + this.faceObjName = newFaceObjName; + } finally { + endGameObjectChange(); + } } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/gameobject/GameObjectContainer.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -122,8 +122,12 @@ // keep this in sync with GameObjectContainer#remove(G) // we can't simply invoke GameObjectContainer#remove(current) because that would result in a ConcurrentModificationException. delegate.remove(); - current.setContainer(null); - notifyChanged(); + notifyBeginChange(); + try { + current.setContainer(null); + } finally { + notifyEndChange(); + } } }; } @@ -187,15 +191,19 @@ * @fixme this implementation does not take care of multi square objects. */ public final void remove(@NotNull final G gameObject) { - if (contents.size() >= 2 && contents.get(0) == gameObject) { - contents.get(1).propagateElevation(gameObject); + notifyBeginChange(); + try { + if (contents.size() >= 2 && contents.get(0) == gameObject) { + contents.get(1).propagateElevation(gameObject); + } + // keep this in sync with iterator() + if (!contents.remove(gameObject)) { + throw new NotInsideContainerException(this, gameObject); + } + gameObject.setContainer(null); + } finally { + notifyEndChange(); } - // keep this in sync with iterator() - if (!contents.remove(gameObject)) { - throw new NotInsideContainerException(this, gameObject); - } - gameObject.setContainer(null); - notifyChanged(); } /** @@ -207,11 +215,15 @@ return; } - for (final G gameObject : contents) { - gameObject.setContainer(null); + notifyBeginChange(); + try { + for (final G gameObject : contents) { + gameObject.setContainer(null); + } + contents.clear(); + } finally { + notifyEndChange(); } - contents.clear(); - notifyChanged(); } /** @@ -223,15 +235,19 @@ public final void moveTop(@NotNull final G gameObject) { final int oldIndex = contents.indexOf(gameObject); if (oldIndex != contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new NotInsideContainerException(this, gameObject); + notifyBeginChange(); + try { + if (!contents.remove(gameObject)) { + throw new NotInsideContainerException(this, gameObject); + } + if (oldIndex == 0) { + assert contents.size() >= 1; + contents.get(0).propagateElevation(gameObject); + } + contents.add(gameObject); + } finally { + notifyEndChange(); } - if (oldIndex == 0) { - assert contents.size() >= 1; - contents.get(0).propagateElevation(gameObject); - } - contents.add(gameObject); - notifyChanged(); } } @@ -244,15 +260,19 @@ public final void moveUp(@NotNull final G gameObject) { final int oldIndex = contents.indexOf(gameObject); if (oldIndex < contents.size() - 1) { - if (!contents.remove(gameObject)) { - throw new NotInsideContainerException(this, gameObject); + notifyBeginChange(); + try { + if (!contents.remove(gameObject)) { + throw new NotInsideContainerException(this, gameObject); + } + if (oldIndex == 0) { + assert contents.size() >= 1; + contents.get(0).propagateElevation(gameObject); + } + contents.add(oldIndex + 1, gameObject); + } finally { + notifyEndChange(); } - if (oldIndex == 0) { - assert contents.size() >= 1; - contents.get(0).propagateElevation(gameObject); - } - contents.add(oldIndex + 1, gameObject); - notifyChanged(); } } @@ -265,15 +285,19 @@ public final void moveDown(@NotNull final G gameObject) { final int oldIndex = contents.indexOf(gameObject); if (oldIndex > 0) { - if (!contents.remove(gameObject)) { - throw new NotInsideContainerException(this, gameObject); + notifyBeginChange(); + try { + if (!contents.remove(gameObject)) { + throw new NotInsideContainerException(this, gameObject); + } + if (oldIndex == 1) { + assert contents.size() >= 1; + gameObject.propagateElevation(contents.get(0)); + } + contents.add(oldIndex - 1, gameObject); + } finally { + notifyEndChange(); } - if (oldIndex == 1) { - assert contents.size() >= 1; - gameObject.propagateElevation(contents.get(0)); - } - contents.add(oldIndex - 1, gameObject); - notifyChanged(); } } @@ -286,13 +310,17 @@ public final void moveBottom(@NotNull final G gameObject) { final int oldIndex = contents.indexOf(gameObject); if (oldIndex != 0) { - if (!contents.remove(gameObject)) { - throw new NotInsideContainerException(this, gameObject); + notifyBeginChange(); + try { + if (!contents.remove(gameObject)) { + throw new NotInsideContainerException(this, gameObject); + } + assert contents.size() >= 1; + gameObject.propagateElevation(contents.get(0)); + contents.add(0, gameObject); + } finally { + notifyEndChange(); } - assert contents.size() >= 1; - gameObject.propagateElevation(contents.get(0)); - contents.add(0, gameObject); - notifyChanged(); } } @@ -319,9 +347,14 @@ if (gameObject.isInContainer()) { throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); } - contents.add(gameObject); - gameObject.setContainer(this); - notifyChanged(); + + notifyBeginChange(); + try { + contents.add(gameObject); + gameObject.setContainer(this); + } finally { + notifyEndChange(); + } } /** @@ -335,12 +368,17 @@ if (gameObject.isInContainer()) { throw new IllegalArgumentException("Can't add " + gameObject + " to " + this + " because it's already inside " + gameObject.getContainer()); } - if (!contents.isEmpty()) { - gameObject.propagateElevation(contents.get(0)); + + notifyBeginChange(); + try { + if (!contents.isEmpty()) { + gameObject.propagateElevation(contents.get(0)); + } + contents.add(0, gameObject); + gameObject.setContainer(this); + } finally { + notifyEndChange(); } - contents.add(0, gameObject); - gameObject.setContainer(this); - notifyChanged(); } /** @@ -355,13 +393,18 @@ if (newGameObject.isInContainer()) { throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); } - final int insertIndex = contents.indexOf(previousGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException("Can't insert " + newGameObject + " after " + previousGameObject + " because that isn't inside " + this); + + notifyBeginChange(); + try { + final int insertIndex = contents.indexOf(previousGameObject); + if (insertIndex == -1) { + throw new IllegalArgumentException("Can't insert " + newGameObject + " after " + previousGameObject + " because that isn't inside " + this); + } + contents.add(insertIndex, newGameObject); + newGameObject.setContainer(this); + } finally { + notifyEndChange(); } - contents.add(insertIndex, newGameObject); - newGameObject.setContainer(this); - notifyChanged(); } /** @@ -375,17 +418,22 @@ if (newGameObject.isInContainer()) { throw new IllegalArgumentException("Can't add " + newGameObject + " to " + this + " because it's already inside " + newGameObject.getContainer()); } - final int insertIndex = contents.indexOf(nextGameObject); - if (insertIndex == -1) { - throw new IllegalArgumentException("Can't insert " + newGameObject + " before " + nextGameObject + " because that isn't inside " + this); + + notifyBeginChange(); + try { + final int insertIndex = contents.indexOf(nextGameObject); + if (insertIndex == -1) { + throw new IllegalArgumentException("Can't insert " + newGameObject + " before " + nextGameObject + " because that isn't inside " + this); + } + if (insertIndex == 0) { + assert contents.size() >= 1; + newGameObject.propagateElevation(contents.get(0)); + } + contents.add(insertIndex + 1, newGameObject); + newGameObject.setContainer(this); + } finally { + notifyEndChange(); } - if (insertIndex == 0) { - assert contents.size() >= 1; - newGameObject.propagateElevation(contents.get(0)); - } - contents.add(insertIndex + 1, newGameObject); - newGameObject.setContainer(this); - notifyChanged(); } /** @@ -399,18 +447,23 @@ if (oldGameObject.isMulti()) { throw new IllegalArgumentException(); } - final int insertIndex = contents.indexOf(oldGameObject); - if (insertIndex == -1) { - throw new NotInsideContainerException(this, oldGameObject); + + notifyBeginChange(); + try { + final int insertIndex = contents.indexOf(oldGameObject); + if (insertIndex == -1) { + throw new NotInsideContainerException(this, oldGameObject); + } + if (insertIndex == 0) { + newGameObject.propagateElevation(oldGameObject); + } + contents.remove(oldGameObject); + oldGameObject.setContainer(null); + contents.add(insertIndex, newGameObject); + newGameObject.setContainer(this); + } finally { + notifyEndChange(); } - if (insertIndex == 0) { - newGameObject.propagateElevation(oldGameObject); - } - contents.remove(oldGameObject); - oldGameObject.setContainer(null); - contents.add(insertIndex, newGameObject); - newGameObject.setContainer(this); - notifyChanged(); } /** @@ -423,9 +476,14 @@ public abstract MapSquare<G, A, R> getMapSquare(); /** + * Notify the map model that this container is about to change. + */ + protected abstract void notifyBeginChange(); + + /** * Notify the map model that this container has changed. */ - protected abstract void notifyChanged(); + protected abstract void notifyEndChange(); /** * {@inheritDoc} Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -61,6 +61,7 @@ import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; import net.sf.gridarta.map.MapTransactionListener; +import net.sf.gridarta.map.SavedSquares; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -242,7 +243,7 @@ } /** {@inheritDoc} */ - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel) { + public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/gui/undo/UndoControl.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -31,6 +31,7 @@ import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapTransactionListener; +import net.sf.gridarta.map.SavedSquares; import net.sf.gridarta.undo.UndoModel; import net.sf.gridarta.undo.UndoState; import net.sf.japi.swing.ActionFactory; @@ -58,7 +59,7 @@ private MapModel<G, A, R> mapModel = null; /** The maximum number of undo states saved for each map. */ - private int maxUndoStates = 8; + private int maxUndoStates = 100; /** * Listener to be notified for map transactions. The same listener is @@ -91,26 +92,21 @@ /** {@inheritDoc} */ public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { undoModel = undoModels.get(mapModel); - undoState = undoModel.isEnabled() ? new UndoState<G, A, R>(name, mapModel) : null; + undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().createClone()); } /** {@inheritDoc} */ - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel) { - if (!undoModel.isEnabled()) { - assert undoState == null; - return; - } - + public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { assert undoState != null; - final UndoState<G, A, R> beginState = undoState; - undoState = null; - - final UndoState<G, A, R> endState = new UndoState<G, A, R>(beginState.getName(), mapModel); - if (beginState.equals(endState)) { + if(savedSquares.isEmpty() + && undoState.getMapArchObject().equals(mapModel.getMapArchObject())) { return; } - undoModel.addUndoState(beginState); + final SavedSquares<G, A, R> clonedSavedSquares = savedSquares.cloneAndClear(); + clonedSavedSquares.removeEmptySquares(undoState.getMapArchObject().getMapSize()); + undoState.setSavedSquares(clonedSavedSquares); + undoModel.finish(undoState); if (maxUndoStates > 0) { undoModel.trimToSize(maxUndoStates); } @@ -194,14 +190,25 @@ final UndoModel<G, A, R> undoModel = undoModels.get(localMapModel); assert undoModel != null; - final UndoState<G, A, R> undoState = undoModel.undo(localMapModel); - undoModel.setEnabled(false); + final UndoState<G, A, R> undoState = undoModel.undo(); try { - localMapModel.beginTransaction("UNDO"); - localMapModel.setState(undoState.getMapState()); - localMapModel.endTransaction(); + localMapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + localMapModel.resizeMap(newMapArchObject.getMapSize()); + final A mapArchObject = localMapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(localMapModel); + } finally { + localMapModel.endTransaction(); + } } finally { - undoModel.setEnabled(true); + undoModel.finish(); } refreshMenus(); } @@ -215,14 +222,25 @@ final UndoModel<G, A, R> undoModel = undoModels.get(localMapModel); assert undoModel != null; - final UndoState<G, A, R> undoState = undoModel.redo(localMapModel); - undoModel.setEnabled(false); + final UndoState<G, A, R> undoState = undoModel.redo(); try { - localMapModel.beginTransaction("REDO"); - localMapModel.setState(undoState.getMapState()); - localMapModel.endTransaction(); + localMapModel.beginTransaction(undoState.getName()); + try { + final A newMapArchObject = undoState.getMapArchObject(); + localMapModel.resizeMap(newMapArchObject.getMapSize()); + final A mapArchObject = localMapModel.getMapArchObject(); + mapArchObject.beginTransaction(); + try { + mapArchObject.setState(newMapArchObject); + } finally { + mapArchObject.endTransaction(); + } + undoState.getSavedSquares().applyChanges(localMapModel); + } finally { + localMapModel.endTransaction(); + } } finally { - undoModel.setEnabled(true); + undoModel.finish(); } refreshMenus(); } Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapModel.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -132,6 +132,13 @@ @NotNull private final Set<MapSquare<G, A, R>> changedSquares = new HashSet<MapSquare<G, A, R>>(); + /** + * Records unchanged square contents for all squares in {@link + * #changedSquares}. + */ + @NotNull + private SavedSquares<G, A, R> savedSquares = new SavedSquares<G, A, R>(); + /** The ArrayList with changed gameObjects. */ @NotNull private final Set<G> changedGameObjects = new HashSet<G>(); @@ -226,10 +233,15 @@ public void clearMap() { for (int x = 0; x < mapSize.getWidth(); x++) { for (int y = 0; y < mapSize.getHeight(); y++) { - final boolean changed = mapGrid[x][y] != null && !mapGrid[x][y].isEmpty(); - mapGrid[x][y] = new MapSquare<G, A, R>(this, x, y); - if (changed) { - squareChanged(mapGrid[x][y]); + if (mapGrid[x][y] == null) { + mapGrid[x][y] = new MapSquare<G, A, R>(this, x, y); + } else if (!mapGrid[x][y].isEmpty()) { + beginSquareChange(mapGrid[x][y]); + try { + mapGrid[x][y] = new MapSquare<G, A, R>(this, x, y); + } finally { + endSquareChange(mapGrid[x][y]); + } } } } @@ -363,9 +375,19 @@ } /** {@inheritDoc} */ - public void squareChanged(@NotNull final MapSquare<G, A, R> square) { + public void beginSquareChange(@NotNull final MapSquare<G, A, R> square) { if (transactionDepth == 0) { - log.error("squareChanged: square was changed outside a transaction"); + log.error("beginSquareChange: square is about to change outside a transaction"); + return; + } + + savedSquares.recordMapSquare(square); + } + + /** {@inheritDoc} */ + public void endSquareChange(@NotNull final MapSquare<G, A, R> square) { + if (transactionDepth == 0) { + log.error("endSquareChange: square was changed outside a transaction"); fireMapSquaresChangedEvent(square); } else { synchronized (changedSquares) { @@ -375,8 +397,21 @@ } /** {@inheritDoc} */ - public void gameObjectChanged(@NotNull final G gameObject) { + public void beginGameObjectChange(@NotNull final G gameObject) { if (transactionDepth == 0) { + log.error("beginGameObjectChange: game object is about to change outside a transaction"); + return; + } + + final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); + assert mapSquare != null; + savedSquares.recordMapSquare(mapSquare); + } + + /** {@inheritDoc} */ + public void endGameObjectChange(@NotNull final G gameObject) { + if (transactionDepth == 0) { + log.error("endGameObjectChange: game object was changed outside a transaction"); fireGameObjectsChangedEvent(gameObject); } else { synchronized (changedGameObjects) { @@ -515,6 +550,7 @@ * @param name the transaction name */ private void fireBeginTransaction(@NotNull final String name) { + savedSquares.clear(); for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { listener.beginTransaction(this, name); } @@ -523,8 +559,9 @@ /** Fire an end transaction event. */ private void fireEndTransaction() { for (final MapTransactionListener<G, A, R> listener : listenerList.getListeners(MapTransactionListener.class)) { - listener.endTransaction(this); + listener.endTransaction(this, savedSquares); } + savedSquares.clear(); } /** @@ -560,47 +597,6 @@ } /** {@inheritDoc} */ - @NotNull - public MapState<G, A, R> getState() { - return new MapState<G, A, R>(mapArchObject, mapGrid); - } - - /** {@inheritDoc} */ - public void setState(@NotNull final MapState<G, A, R> mapState) { - mapArchObject.beginTransaction(); - mapArchObject.setState(mapState.getMapArchObject()); - mapArchObject.endTransaction(); - - final Size2D newSize = mapState.getMapArchObject().getMapSize(); - resizeMap(newSize); - clearMap(); - final List<G>[][] oldMapGrid = mapState.getMapGrid(); - - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - for (final G content : oldMapGrid[x][y]) { - if (!content.isMulti()) { - mapGrid[x][y].addLast(content.createClone(x, y)); - } - } - } - } - - for (int x = 0; x < newSize.getWidth(); x++) { - for (int y = 0; y < newSize.getHeight(); y++) { - for (final G content : oldMapGrid[x][y]) { - if (content.isMulti()) { - for (G tmp = content.createMultiClone(x, y); tmp != null; tmp = tmp.getMultiNext()) { - tmp.setObjectFace(); - mapGrid[tmp.getMapX()][tmp.getMapY()].addLast(tmp); - } - } - } - } - } - } - - /** {@inheritDoc} */ @Nullable public G getExit(@Nullable final Point point) { if (exitTypeGameObjectMatcher == null || point == null || !isPointValid(point)) { Modified: trunk/src/app/net/sf/gridarta/map/MapModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/map/MapModel.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -132,22 +132,34 @@ void removeMapTransactionListener(@NotNull MapTransactionListener<G, A, R> listener); /** + * Method to notify the model that a map square is about to change. + * @param square MapSquare that is about to change + */ + void beginSquareChange(@NotNull MapSquare<G, A, R> square); + + /** * Method to notify the model that a map square was changed. A change to a * square is atomic if {@link #getTransactionDepth()} returns 0, otherwise * it is transactional. The model then notifies the registered listeners of * the changes. * @param square MapSquare that has changed */ - void squareChanged(@NotNull MapSquare<G, A, R> square); + void endSquareChange(@NotNull MapSquare<G, A, R> square); /** + * Method to notify the model that a game object is about to change. + * @param gameObject GameObject that is about to change + */ + void beginGameObjectChange(@NotNull G gameObject); + + /** * Method to notify the model that a game object was changed. A change to a * game object is atomic if {@link #getTransactionDepth()} returns 0, * otherwise it is transactional. The model then notifies the registered * listeners of the changes. * @param gameObject GameObject that has changed */ - void gameObjectChanged(@NotNull G gameObject); + void endGameObjectChange(@NotNull G gameObject); /** * Start a new transaction. Transactions may be nested. Transactions serve @@ -310,21 +322,6 @@ void addGameObjectToMap(@NotNull G gameObject, @NotNull InsertionMode insertionMode); /** - * Return the current state of this object. - * @return the state of this object - * @see #setState(MapState) - */ - @NotNull - MapState<G, A, R> getState(); - - /** - * Reset the state of this object. - * @param mapState the state to set - * @see #getState() - */ - void setState(@NotNull MapState<G, A, R> mapState); - - /** * Creates a game object from an archetype and adds it to the map. * @param archetype the archetype to insert * @param pos the insert-location on this map Modified: trunk/src/app/net/sf/gridarta/map/MapSquare.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapSquare.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/map/MapSquare.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -94,11 +94,17 @@ /** {@inheritDoc} */ @Override - protected void notifyChanged() { - mapModel.squareChanged(this); + protected void notifyBeginChange() { + mapModel.beginSquareChange(this); } /** {@inheritDoc} */ + @Override + protected void notifyEndChange() { + mapModel.endSquareChange(this); + } + + /** {@inheritDoc} */ @NotNull @Override protected MapSquare<G, A, R> clone() throws CloneNotSupportedException { Deleted: trunk/src/app/net/sf/gridarta/map/MapState.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapState.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/map/MapState.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -1,151 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2007 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.map; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import net.sf.gridarta.Size2D; -import net.sf.gridarta.gameobject.Archetype; -import net.sf.gridarta.gameobject.GameObject; -import org.jetbrains.annotations.NotNull; - -/** - * The class <code>MapState</code> holds the state of a {@link MapModel} as - * saved by {@link MapModel#getState()}. - * @author Andreas Kirschbaum - */ -public class MapState<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * The saved map arch object. This object is a copy of the map model's map - * arch object to be not affected by changes in the map model. - */ - @NotNull - private final A mapArchObject; - - /** - * The saved map grid. This object is a copy of the map model's map grid to - * be not affected by changes in the map model. - */ - @NotNull - private final ArrayList<G>[][] mapGrid; - - /** - * Create a new instance. - * @param mapArchObject the map arch object to copy - * @param mapGrid the map grid to copy - * @note All parameters are copied. - */ - public MapState(@NotNull final A mapArchObject, @NotNull final MapSquare<G, A, R>[][] mapGrid) { - this.mapArchObject = mapArchObject.createClone(); - - final Size2D mapSize = mapArchObject.getMapSize(); - this.mapGrid = new ArrayList[mapSize.getWidth()][mapSize.getHeight()]; - for (int x = 0; x < mapSize.getWidth(); x++) { - for (int y = 0; y < mapSize.getHeight(); y++) { - this.mapGrid[x][y] = new ArrayList<G>(); - for (final G content : mapGrid[x][y]) { - if (content.isHead()) { - this.mapGrid[x][y].add(content.createMultiClone(x, y)); - } - } - this.mapGrid[x][y].trimToSize(); - } - } - } - - /** - * Return the map arch object. - * @return the map arch object; the returned object must not be changed - */ - @NotNull - public A getMapArchObject() { - return mapArchObject; - } - - /** - * Return the map grid information. - * @return the map grid information; the returned object must not be - * changed - */ - @NotNull - public List<G>[][] getMapGrid() { - return mapGrid; - } - - /** {@inheritDoc} */ - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; - } - if (!(obj instanceof MapState)) { - return false; - } - - final MapState<G, A, R> mapState = (MapState<G, A, R>) obj; - if (!mapState.mapArchObject.equals(mapArchObject)) { - return false; - } - - if (mapState.mapGrid.length != mapGrid.length) { - return false; - } - - for (int i = 0; i < mapGrid.length; i++) { - for (int j = 0; j < mapGrid[i].length; j++) { - if (!listIsEqual(mapState.mapGrid[i][j], mapGrid[i][j])) { - return false; - } - } - } - - return true; - } - - /** - * Compare two lists of game objects. The comparision is done with {@link - * GameObject#isEqual(GameObject)}. - * @param list1 the first list to compare - * @param list2 the second list to compare - * @return <code>true</code> if both lists are equal - */ - private boolean listIsEqual(@NotNull final List<G> list1, @NotNull final List<G> list2) { - if (list1.size() != list2.size()) { - return false; - } - - for (int i = 0; i < list1.size(); i++) { - if (!list1.get(i).isEqual(list2.get(i))) { - return false; - } - } - - return true; - } - - /** {@inheritDoc} */ - @Override - public int hashCode() { - return mapArchObject.hashCode() + Arrays.hashCode(mapGrid); - } - -} // class MapState Modified: trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/map/MapTransactionListener.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -46,8 +46,9 @@ /** * A map transaction has ended. * @param mapModel the map model + * @param savedSquares the squares affected by the transaction */ - void endTransaction(@NotNull MapModel<G, A, R> mapModel); + void endTransaction(@NotNull MapModel<G, A, R> mapModel, @NotNull SavedSquares<G, A, R> savedSquares); /** * A map transaction has been finished. Added: trunk/src/app/net/sf/gridarta/map/SavedSquares.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/SavedSquares.java (rev 0) +++ trunk/src/app/net/sf/gridarta/map/SavedSquares.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -0,0 +1,220 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.map; + +import java.awt.Point; +import java.util.ArrayList; +import net.sf.gridarta.Size2D; +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import org.jetbrains.annotations.NotNull; + +/** + * Records a set of changed map squares. + * @author Andreas Kirschbaum + */ +public class SavedSquares<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * The saved squares. Maps x-coordinate to y-coordinate to map squares + * contents. Not saved map squares (or map columns) are null. + */ + @NotNull + private final ArrayList<ArrayList<ArrayList<G>>> savedSquares = new ArrayList<ArrayList<ArrayList<G>>>(); + + /** + * Records a map square as changed. Does nothing if the square already has + * been saved. + * @param mapSquare the map square to save + */ + public void recordMapSquare(@NotNull final MapSquare<G, A, R> mapSquare) { + final int x = mapSquare.getMapX(); + final int y = mapSquare.getMapY(); + final ArrayList<G> list = allocateMapSquare(x, y); + if (list == null) { + return; + } + + for (final G content : mapSquare) { + if (content.isHead()) { + list.add(content.createMultiClone(x, y)); + } + } + list.trimToSize(); + } + + /** + * Allocates a saved map square. + * @param x the x-coordinate + * @param y the y-coordinate + * @return the newly allocated map square or <code>null</code> if the map + * square already did exist + */ + private ArrayList<G> allocateMapSquare(final int x, final int y) { + final ArrayList<ArrayList<G>> col; + if (x >= savedSquares.size()) { + while (savedSquares.size() < x) { + savedSquares.add(null); + } + col = new ArrayList<ArrayList<G>>(); + savedSquares.add(col); + } else { + final ArrayList<ArrayList<G>> tmp = savedSquares.get(x); + if (tmp != null) { + col = tmp; + } else { + col = new ArrayList<ArrayList<G>>(); + savedSquares.set(x, col); + } + } + + final ArrayList<G> result; + if (y >= col.size()) { + while (col.size() < y) { + col.add(null); + } + result = new ArrayList<G>(); + col.add(result); + } else { + final ArrayList<G> tmp = col.get(y); + if (tmp != null) { + return null; + } + + result = new ArrayList<G>(); + col.set(y, result); + } + + return result; + } + + + /** + * Returns whether no saved squares exist. + * @return whether no saved squares exist + */ + public boolean isEmpty() { + return savedSquares.isEmpty(); + } + + /** + * Forgets all saved squares. + */ + public void clear() { + savedSquares.clear(); + } + + /** + * Creates a new {@link SavedSquares} instance having the same contents as + * this instance, then forgets all saves squares in this instance. + * @return the new instance + */ + @NotNull + public SavedSquares<G, A, R> cloneAndClear() { + final SavedSquares<G, A, R> clone = new SavedSquares<G, A, R>(); + clone.savedSquares.addAll(savedSquares); + savedSquares.clear(); + return clone; + } + + /** + * Applies the saved squares to the given map model. + * @param mapModel the map model to change + */ + public void applyChanges(@NotNull final MapModel<G, A, R> mapModel) { + final Point point = new Point(); + point.x = 0; + for (final ArrayList<ArrayList<G>> col : savedSquares) { + if (col != null) { + point.y = 0; + for (final ArrayList<G> square : col) { + if (square != null) { + final MapSquare<G, A, R> mapSquare = mapModel.getMapSquare(point); + mapSquare.removeAll(); + for (final G gameObject : square) { + mapSquare.addLast(gameObject); + } + } + point.y++; + } + } + point.x++; + } + } + + /** + * Removes empty squares outside a given area. + * @param size the area + */ + public void removeEmptySquares(final Size2D size) { + final int width = size.getWidth(); + final int height = size.getHeight(); + + if (!isOutsideEmpty(width, height)) { + throw new IllegalArgumentException(); + } + + for (int x = 0; x < width && x < savedSquares.size(); x++) { + final ArrayList<ArrayList<G>> col = savedSquares.get(x); + if (col != null) { + for (int y = col.size() - 1; y >= height; y--) { + col.remove(y); + } + } + } + for (int x = savedSquares.size() - 1; x >= width; x--) { + savedSquares.remove(x); + } + } + + /** + * Returns whether all squares outside a given area are empty or unchanged. + * @param width the width of the area + * @param height the height of the area + * @return whether no non-empty squares exist + */ + private boolean isOutsideEmpty(final int width, final int height) { + for (int x = 0; x < width && x < savedSquares.size(); x++) { + final ArrayList<ArrayList<G>> col = savedSquares.get(x); + if (col != null) { + for (int y = height; y < col.size(); y++) { + final ArrayList<G> square = col.get(y); + if (!square.isEmpty()) { + return false; + } + } + } + } + + for (int x = width; x < savedSquares.size(); x++) { + final ArrayList<ArrayList<G>> col = savedSquares.get(x); + if (col != null) { + for (final ArrayList<G> square : col) { + if (square != null && !square.isEmpty()) { + return false; + } + } + } + } + + return true; + } + +} // class SavedSquares Property changes on: trunk/src/app/net/sf/gridarta/map/SavedSquares.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/undo/UndoModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/undo/UndoModel.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/undo/UndoModel.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -25,6 +25,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapModel; +import net.sf.gridarta.map.SavedSquares; import org.jetbrains.annotations.NotNull; /** @@ -52,17 +53,16 @@ private int undoStackIndex = 0; /** - * If unset, do not record new undo information. It is used to temporarily - * disable undo recording while performing a undo or redo operation. + * The type for recording undo information. */ - private boolean enabled = true; + private UndoType type = UndoType.NORMAL; /** * Add a new undo state to the undo stack. This discards the existing "redo" * information (if present). * @param undoState the undo state to add */ - public void addUndoState(@NotNull final UndoState<G, A, R> undoState) { + private void addUndoState(@NotNull final UndoState<G, A, R> undoState) { discardAllRedo(); assert undoStackIndex == undoStack.size(); @@ -128,40 +128,88 @@ /** * Perform an "undo" operation. - * @param mapModel the current map contents * @return the undo state to apply; the returned object must not be modified * by the caller */ @NotNull - public UndoState<G, A, R> undo(@NotNull final MapModel<G, A, R> mapModel) { + public UndoState<G, A, R> undo() { if (undoStackIndex <= 0) { throw new IllegalStateException("undo stack is empty"); } undoStackIndex--; final UndoState<G, A, R> result = undoStack.get(undoStackIndex); - undoStack.set(undoStackIndex, new UndoState<G, A, R>(result.getName(), mapModel)); + type = UndoType.UNDO; return result; } /** * Perform a "redo" operation. - * @param mapModel the current map contents * @return the undo state to apply; the returned object must not be modified * by the caller */ @NotNull - public UndoState<G, A, R> redo(@NotNull final MapModel<G, A, R> mapModel) { + public UndoState<G, A, R> redo() { if (undoStackIndex >= undoStack.size()) { throw new IllegalStateException("redo stack is empty"); } final UndoState<G, A, R> result = undoStack.get(undoStackIndex); - undoStack.set(undoStackIndex, new UndoState<G, A, R>(result.getName(), mapModel)); undoStackIndex++; + type = UndoType.REDO; return result; } + /** + * Finishes an undo or redo operation. Does nothing if none is in progress. + * @param undoState the changes of the operation + */ + public void finish(@NotNull final UndoState<G, A, R> undoState) { + switch (type) { + case NORMAL: + addUndoState(undoState); + break; + + case UNDO: + undoStack.set(undoStackIndex, undoState); + type = UndoType.NORMAL; + break; + + case REDO: + undoStack.set(undoStackIndex - 1, undoState); + type = UndoType.NORMAL; + break; + } + } + + /** + * Finishes an undo or redo operation. Does nothing if none is in progress. + */ + public void finish() { + final int index; + switch (type) { + default: + case NORMAL: + return; + + case UNDO: + index = undoStackIndex; + break; + + case REDO: + index = undoStackIndex - 1; + break; + } + + final UndoState<G, A, R> prevUndoState = undoStack.get(index); + final String name = prevUndoState.getName(); + final A mapArchObject = prevUndoState.getMapArchObject(); + final UndoState<G, A, R> undoState = new UndoState<G, A, R>(name, mapArchObject); + undoState.setSavedSquares(new SavedSquares<G, A, R>()); + undoStack.set(index, undoState); + type = UndoType.NORMAL; + } + /** Discard all "redo" information. */ private void discardAllRedo() { while (undoStackIndex < undoStack.size()) { @@ -184,21 +232,4 @@ undoStackIndex--; } - /** - * Enable or disable the recording of new undo information. - * @param enabled if set, enable recording of new undo information - */ - public void setEnabled(final boolean enabled) { - this.enabled = enabled; - } - - /** - * Return whether undo operations should be recorded. - * @return <code>true</code> if new undo information should be recorded, - * <code>false</code> if new undo information should be discarded - */ - public boolean isEnabled() { - return enabled; - } - } // class UndoModel Modified: trunk/src/app/net/sf/gridarta/undo/UndoState.java =================================================================== --- trunk/src/app/net/sf/gridarta/undo/UndoState.java 2008-10-05 10:11:17 UTC (rev 5444) +++ trunk/src/app/net/sf/gridarta/undo/UndoState.java 2008-10-05 10:23:47 UTC (rev 5445) @@ -22,9 +22,9 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.map.MapArchObject; -import net.sf.gridarta.map.MapModel; -import net.sf.gridarta.map.MapState; +import net.sf.gridarta.map.SavedSquares; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * The class <code>UndoState</code> holds information to undo/redo one edit @@ -38,18 +38,28 @@ @NotNull private final String name; - /** The map state before this operation was executed. */ + /** + * The map arch object before the operation started. + */ @NotNull - private final MapState<G, A, R> mapState; + private final A mapArchObject; /** + * The affected map squares. The contents represent the state before the + * operation started. + */ + @Nullable + private SavedSquares<G, A, R> savedSquares = null; + + /** * Create a new instance. * @param name the name of the operation - * @param mapModel the map model before the operation was executed + * @param mapArchObject the map arch object to store; the value is + * <em>not</em> copied */ - public UndoState(@NotNull final String name, @NotNull final MapModel<G, A, R> mapModel) { + public UndoState(@NotNull final String name, @NotNull final A mapArchObject) { this.name = name; - mapState = mapModel.getState(); + this.mapArchObject = mapArchObject; } /** @@ -62,32 +72,39 @@ } /** - * Return the map state before the operation was executed. - * @return the map state before the operation was executed + * Records the affected map squares. + * @param savedSquares the map squares to record + * @throws IllegalStateException if changed map squares have been recorded + * before */ - @NotNull - public MapState<G, A, R> getMapState() { - return mapState; + public void setSavedSquares(@NotNull final SavedSquares<G, A, R> savedSquares) { + if (this.savedSquares != null) { + throw new IllegalStateException(); + } + + this.savedSquares = savedSquares; } - /** {@inheritDoc} */ - @Override - public boolean equals(final Object obj) { - if (obj == null) { - return false; + /** + * Returns the map squares that have changed in the operation. + * @return the changed map squares + * @throws IllegalStateException if no saved squares have been recorded + */ + @NotNull + public SavedSquares<G, A, R> getSavedSquares() { + if (savedSquares == null) { + throw new IllegalStateException(); } - if (!(obj instanceof UndoState)) { - return false; - } - - final UndoState<?, ?, ?> undoState = (UndoState<?, ?, ?>) obj; - return undoState.name.equa... [truncated message content] |
From: <aki...@us...> - 2008-10-06 17:55:19
|
Revision: 5446 http://gridarta.svn.sourceforge.net/gridarta/?rev=5446&view=rev Author: akirschbaum Date: 2008-10-06 17:50:56 +0000 (Mon, 06 Oct 2008) Log Message: ----------- Remove unneeded type parameters from EditTypes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java trunk/daimonin/src/daieditor/gui/map/MapRenderer.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/CopyBuffer.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/EditTypes.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/app/net/sf/gridarta/gui/MainView.java trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java trunk/src/app/net/sf/gridarta/io/GameObjectParser.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -132,7 +132,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { return new DefaultMapViewFactory((FaceObjects) faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); } @@ -242,7 +242,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), globalSettings.getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } @@ -346,7 +346,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { + protected net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { return new ArchetypeSet(((GlobalSettingsImpl) globalSettings).getImageSet(), archetypeFactory); } Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSetLoader.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -20,7 +20,6 @@ package cfeditor.gameobject; import cfeditor.IGUIConstants; -import cfeditor.gui.map.CMapViewBasic; import cfeditor.map.MapArchObject; import java.awt.Component; import java.io.BufferedReader; @@ -107,7 +106,7 @@ * The edit types instance. */ @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** * The face objects instance. @@ -134,7 +133,7 @@ * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { super(collectedDirectory, animationObjects, throwableHandler); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; Modified: trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/crossfire/src/cfeditor/gui/map/CMapViewBasic.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -125,7 +125,7 @@ * @param yScrollDistance the y distance when scrolling * @param selectedSquareView the selected square view */ - public CMapViewBasic(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, final boolean isPickmap, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public CMapViewBasic(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes editTypes, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, final boolean isPickmap, @Nullable final Point initial, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { super(mapModel, isPickmap, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); Modified: trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultMapViewFactory.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -57,7 +57,7 @@ /** The {@link EditTypes} instance to use. */ @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** The {@link MapImageCache} instance to use. */ @NotNull @@ -82,7 +82,7 @@ * @param toolPalette the tool palette instance * @param filterControl the filter control instance */ - public DefaultMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + public DefaultMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; Modified: trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/crossfire/src/cfeditor/gui/map/MapRenderer.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -75,7 +75,7 @@ private SoftReference<BufferedImage> backBufferRef = null; @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** * The filter state instace for this map renderer. @@ -90,7 +90,7 @@ * @param mapModel the map model to render * @param mapGrid Grid to render */ - public MapRenderer(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapModel<GameObject, MapArchObject, Archetype> mapModel, final MapGrid mapGrid) { + public MapRenderer(@NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes editTypes, final MapModel<GameObject, MapArchObject, Archetype> mapModel, final MapGrid mapGrid) { super(mapModel, mapGrid, 32); this.filterControl = filterControl; this.editTypes = editTypes; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -178,7 +178,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + protected MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapViewFactory(@NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final AbstractMainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { return new DefaultMapViewFactory((FaceObjects) faceObjects, selectedSquareView, mainControl, mainView, editTypes, mapImageCache, toolPalette, filterControl); } @@ -290,7 +290,7 @@ /** {@inheritDoc} */ @Override - protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { + protected void init4(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet) { MultiPositionData.init(globalSettings.getConfigurationDirectory()); new ArchetypeSetLoader(globalSettings, gameObjectParser, globalSettings.getCollectedDirectory(), globalSettings.getConfigurationDirectory(), archetypeSet, archetypeParser, editTypes, faceObjects, animationObjects, this).loadArchetypes(mainView); } @@ -536,7 +536,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { + protected ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { return new ArchetypeSet(archetypeFactory); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -20,7 +20,6 @@ package daieditor.gameobject; import daieditor.IGUIConstants; -import daieditor.gui.map.CMapViewBasic; import daieditor.map.MapArchObject; import java.awt.Component; import java.io.BufferedReader; @@ -109,7 +108,7 @@ * The edit types instance. */ @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** * The face objects instance. @@ -149,7 +148,7 @@ * @param animationObjects the animation objects instance * @param throwableHandler the throwable handler to use */ - public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { + public ArchetypeSetLoader(@NotNull final GlobalSettings globalSettings, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final String collectedDirectory, @NotNull final String configurationDirectory, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final ThrowableHandler<Throwable> throwableHandler) { super(collectedDirectory, animationObjects, throwableHandler); this.globalSettings = globalSettings; this.gameObjectParser = gameObjectParser; Modified: trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/daimonin/src/daieditor/gui/map/CMapViewBasic.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -131,7 +131,7 @@ * @param yScrollDistance the y distance when scrolling * @param selectedSquareView the selected square view */ - public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, final boolean isPickmap, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { + public CMapViewBasic(@NotNull final CMainControl mainControl, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes editTypes, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, final boolean isPickmap, @Nullable final Point initial, @NotNull final FaceObjects faceObjects, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, final int xScrollDistance, final int yScrollDistance, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView) { super(mapModel, isPickmap, xScrollDistance, yScrollDistance, selectedSquareView); getMapCursor().addMapCursorListener(mapCursorListener); Modified: trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/daimonin/src/daieditor/gui/map/DefaultMapViewFactory.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -66,7 +66,7 @@ /** The {@link EditTypes} instance to use. */ @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** The {@link MapImageCache} instance to use. */ @NotNull @@ -91,7 +91,7 @@ * @param toolPalette the tool palette instance * @param filterControl the filter control instance */ - public DefaultMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { + public DefaultMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<GameObject, MapArchObject, Archetype, CMapViewBasic> selectedSquareView, @NotNull final MainControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mainControl, @NotNull final MainView<GameObject, MapArchObject, Archetype, CMapViewBasic> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl) { this.faceObjects = faceObjects; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; Modified: trunk/daimonin/src/daieditor/gui/map/MapRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/daimonin/src/daieditor/gui/map/MapRenderer.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -59,7 +59,7 @@ private final ImageIcon emptyTileIcon = SystemIcons.getEmptyTileIcon(); @NotNull - private final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes; + private final EditTypes editTypes; /** * The filter state instace for this map renderer. @@ -86,7 +86,7 @@ * @param mapGrid Grid to render * @param faceObjects the FaceObjects instance to use */ - public MapRenderer(final CMainControl mainControl, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes<GameObject, MapArchObject, Archetype, CMapViewBasic> editTypes, final MapModel<GameObject, MapArchObject, Archetype> mapModel, final MapGrid mapGrid, @NotNull final FaceObjects faceObjects) { + public MapRenderer(final CMainControl mainControl, @NotNull final FilterControl<GameObject, MapArchObject, Archetype, CMapViewBasic> filterControl, @NotNull final EditTypes editTypes, final MapModel<GameObject, MapArchObject, Archetype> mapModel, final MapGrid mapGrid, @NotNull final FaceObjects faceObjects) { super(mainControl, mapModel, mapGrid, IGUIConstants.TILE_ISO_XLEN, 2 * IGUIConstants.TILE_ISO_YLEN, faceObjects); this.filterControl = filterControl; this.editTypes = editTypes; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -336,7 +336,7 @@ final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); mapControlFactory.setMapReaderFactory(mapReaderFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); - final EditTypes<G, A, R, V> editTypes = new EditTypes<G, A, R, V>(tmpMapManager); + final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; @@ -510,7 +510,7 @@ protected abstract ArchetypeFactory<G, A, R> newArchetypeFactory(); @NotNull - protected abstract MapViewFactory<G, A, R, V> newMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final AbstractMainControl<G, A, R, V> mainControl, @NotNull final MainView<G, A, R, V> mainView, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @NotNull final ToolPalette<G, A, R, V> toolPalette, @NotNull final FilterControl<G, A, R, V> filterControl); + protected abstract MapViewFactory<G, A, R, V> newMapViewFactory(@NotNull final FaceObjects faceObjects, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final AbstractMainControl<G, A, R, V> mainControl, @NotNull final MainView<G, A, R, V> mainView, @NotNull final EditTypes editTypes, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @NotNull final ToolPalette<G, A, R, V> toolPalette, @NotNull final FilterControl<G, A, R, V> filterControl); @NotNull protected abstract MapReaderFactory<G, A> newMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory); @@ -546,7 +546,7 @@ @NotNull protected abstract MapActions init1(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GlobalSettings globalSettings, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ArchetypeTypeSet<G, A, R> archetypeTypeSet, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final GameObjectMatcher exitMatcher); - protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); + protected abstract void init4(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final AbstractArchetypeParser<G, A, R> archetypeParser, @NotNull final EditTypes editTypes, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, final MainView<G, A, R, V> mainView, @NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeSet<G, A, R> archetypeSet); protected abstract void deleteLibraries(); @@ -577,7 +577,7 @@ * @return the archetype set instance */ @NotNull - protected abstract ArchetypeSet<G, A, R> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeFactory<G, A, R> archetypeFactory); + protected abstract ArchetypeSet<G, A, R> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeFactory<G, A, R> archetypeFactory); /** * Create the cache instance for map images. Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -64,7 +64,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<G, A, R, V> editTypes; + private final EditTypes editTypes; /** * The gridarta objects factory instance. @@ -80,7 +80,7 @@ * @param editTypes the edit types instance * @param mapControlFactory the gridarta objects factory instance */ - public CopyBuffer(@NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory) { + public CopyBuffer(@NotNull final EditTypes editTypes, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory) { this.editTypes = editTypes; this.mapControlFactory = mapControlFactory; } Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -85,7 +85,7 @@ /** The edit types. */ @NotNull - private EditTypes<G, A, R, V> editTypes = null; + private EditTypes editTypes = null; /** The recent manager. */ private RecentManager recentManager = null; @@ -132,7 +132,7 @@ * @param editTypes the edit types */ @Deprecated - public void setEditTypes(@NotNull final EditTypes<G, A, R, V> editTypes) { + public void setEditTypes(@NotNull final EditTypes editTypes) { this.editTypes = editTypes; } Modified: trunk/src/app/net/sf/gridarta/EditTypes.java =================================================================== --- trunk/src/app/net/sf/gridarta/EditTypes.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/EditTypes.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -19,22 +19,19 @@ package net.sf.gridarta; -import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.GUIConstants; -import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.map.MapArchObject; import org.jetbrains.annotations.NotNull; -public class EditTypes<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> { +public class EditTypes { /** The map manager. */ - private final MapManager<G, A, R, V> mapManager; + private final MapManager<?, ?, ?, ?> mapManager; /** Bit field of edit types to show only. */ private int editType = 0; - public EditTypes(@NotNull final MapManager<G, A, R, V> mapManager) { + public EditTypes(@NotNull final MapManager<?, ?, ?, ?> mapManager) { this.mapManager = mapManager; } @@ -92,7 +89,7 @@ * @param gameObject are tiles of this type displayed? * @return true if these tiles are currently displayed */ - public boolean isEditType(final G gameObject) { + public boolean isEditType(final GameObject<?, ?, ?> gameObject) { return editType == 0 || isEditType(gameObject.getEditType()); } Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -91,7 +91,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<G, A, R, V> editTypes; + private final EditTypes editTypes; /** The archetype set instance. */ private final ArchetypeSet<G, A, R> archetypeSet; @@ -337,7 +337,7 @@ * @param mapManager the map manager instance * @param mapViewManager the map view manager instance */ - public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { + public MainActions(@NotNull final ReplaceDialogManager<G, A, R, V> replaceDialogManager, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final JFrame parent, @NotNull final GlobalSettings globalSettings, @NotNull final DelegatingMapValidator<G, A, R> validators, @NotNull final EditTypes editTypes, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final AnimationObjects<?> animationObjects, @NotNull final ActionFactory actionFactory, @NotNull final FaceObjects faceObjects, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { this.replaceDialogManager = replaceDialogManager; this.mainControl = mainControl; this.parent = parent; Modified: trunk/src/app/net/sf/gridarta/gui/MainView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/MainView.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -243,7 +243,7 @@ * @param statusBar the status bar instance * @param buildNumber the application's build number */ - public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar, @NotNull final String buildNumber) { + public MainView(@NotNull final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final ActionFactory actionFactory, @NotNull final Action aCloseAll, @NotNull final Component statusBar, @NotNull final String buildNumber) { super(actionFactory.format("mainWindow.title", buildNumber)); this.mapManager = mapManager; this.mapViewManager = mapViewManager; Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -45,7 +45,7 @@ /** The main control. */ @NotNull - private final EditTypes<G, A, R, ?> editTypes; + private final EditTypes editTypes; /** The map view to operate on. */ @NotNull @@ -75,7 +75,7 @@ * @param mapView The map view to operate on. * @param mapModel The map model to operate on. */ - public ShiftProcessor(@NotNull final EditTypes<G, A, R, ?> editTypes, @NotNull final MapView<G, A, R, ?> mapView, @NotNull final MapModel<G, A, R> mapModel) { + public ShiftProcessor(@NotNull final EditTypes editTypes, @NotNull final MapView<G, A, R, ?> mapView, @NotNull final MapModel<G, A, R> mapModel) { this.editTypes = editTypes; this.mapView = mapView; this.mapModel = mapModel; Modified: trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/map/ViewActions.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -51,7 +51,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<G, A, R, V> editTypes; + private final EditTypes editTypes; /** The listener to check for current map changes. */ private final CurrentMapListener<G, A, R, V> currentMapListener; @@ -65,7 +65,7 @@ * @param mapManager the map manager * @param mapViewManager the map view manager */ - public ViewActions(@NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { + public ViewActions(@NotNull final EditTypes editTypes, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { this.editTypes = editTypes; ACTION_FACTORY.createActions(true, this, "resetView"); @@ -169,7 +169,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<?, ?, ?, ?> editTypes; + private final EditTypes editTypes; /** The name for sorting the menu entries. */ private final String name; @@ -185,7 +185,7 @@ * @param editTypes the edit types instance * @param matcher the matcher */ - public ViewAction(@NotNull final EditTypes<?, ?, ?, ?> editTypes, @NotNull final NamedGameObjectMatcher matcher) { + public ViewAction(@NotNull final EditTypes editTypes, @NotNull final NamedGameObjectMatcher matcher) { super(ACTION_FACTORY.format("show.text", matcher.getName())); this.editTypes = editTypes; name = matcher.getName(); Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -103,7 +103,7 @@ /** The main control. */ @NotNull - private final EditTypes<G, A, R, V> editTypes; + private final EditTypes editTypes; /** * A {@link GameObjectMatcher} matching floor game objects. @@ -179,7 +179,7 @@ * @param objectChooser the object chooser to use * @param pickmapChooserControl the pickmap chooser control to use */ - public DeletionTool(@NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { + public DeletionTool(@NotNull final EditTypes editTypes, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { super("deletion"); this.editTypes = editTypes; this.objectChooser = objectChooser; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -70,7 +70,7 @@ * @param objectChooser the object chooser to use * @param pickmapChooserControl the pickmap chooser control to use */ - public ToolPalette(@NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { + public ToolPalette(@NotNull final EditTypes editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { super(new BorderLayout()); lmbSelector = new ToolSelector<G, A, R, V>("selection", editTypes, selectedSquareView, objectChooser, pickmapChooserControl); mmbSelector = new ToolSelector<G, A, R, V>("deletion", editTypes, selectedSquareView, objectChooser, pickmapChooserControl); Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolSelector.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -92,7 +92,7 @@ * @param objectChooser the object chooser to use * @param pickmapChooserControl the pickmap chooser control to use */ - public ToolSelector(@NotNull final String defaultTool, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { + public ToolSelector(@NotNull final String defaultTool, @NotNull final EditTypes editTypes, @NotNull final SelectedSquareView<G, A, R, V> selectedSquareView, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final PickmapChooserControl<G, A, R, V> pickmapChooserControl) { createUI(); for (final Tool<G, A, R, V> toolToAdd : new Tool[] {new VoidTool<G, A, R, V>(), new SelectionTool<G, A, R, V>(objectChooser), new DeletionTool<G, A, R, V>(editTypes, objectChooser, pickmapChooserControl), new InsertionTool<G, A, R, V>(selectedSquareView, objectChooser, pickmapChooserControl)}) { add(toolToAdd, toolToAdd.getId().equals(defaultTool)); Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareControl.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -106,7 +106,7 @@ * of the list * @param archetypeSet the archetype set to use */ - public SelectedSquareControl(@NotNull final ActionFactory actionFactory, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final EditTypes<G, A, R, V> editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + public SelectedSquareControl(@NotNull final ActionFactory actionFactory, @NotNull final GameObjectAttributesDialogFactory<G, A, R, V> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final EditTypes editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; this.objectChooser = objectChooser; Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -80,7 +80,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<G, A, R, V> editTypes; + private final EditTypes editTypes; /** The controller for this view. */ @NotNull @@ -231,7 +231,7 @@ * of the list * @param archetypeSet the archetype set to use */ - public SelectedSquareView(@NotNull final ActionFactory actionFactory, @NotNull final SelectedSquareControl<G, A, R, V> control, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final EditTypes<G, A, R, V> editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { + public SelectedSquareView(@NotNull final ActionFactory actionFactory, @NotNull final SelectedSquareControl<G, A, R, V> control, @NotNull final MapManager<G, A, R, V> mapManager, @NotNull final MapViewManager<G, A, R, V> mapViewManager, @NotNull final EditTypes editTypes, final boolean mapTileListBottom, @Nullable final ImageIcon compassIcon, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { this.editTypes = editTypes; this.control = control; mapTileSelectionCache = new MapTileSelectionCache<G, A, R, V>(mapViewManager); Modified: trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/io/AbstractGameObjectParser.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -177,7 +177,7 @@ } /** {@inheritDoc} */ - public void collectTempList(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes<G, A, R, ?> editTypes, final List<G> objects, final String uri, final boolean isInteractive) { + public void collectTempList(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes editTypes, final List<G> objects, final String uri, final boolean isInteractive) { final List<G> tailList = new ArrayList<G>(); final Set<String> undefinedArchetypeNames = new TreeSet<String>(); Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReader.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -77,7 +77,7 @@ /** The edit types instance. */ @NotNull - private final EditTypes<G, A, R, ?> editTypes; + private final EditTypes editTypes; /** ArchObjects that are read from the map. */ @NotNull @@ -119,7 +119,7 @@ * @param file File to open. * @throws FileNotFoundException in case the file was not found. */ - public DefaultMapReader(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes<G, A, R, ?> editTypes, @NotNull final File file) throws FileNotFoundException { + public DefaultMapReader(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final EditTypes editTypes, @NotNull final File file) throws FileNotFoundException { this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.mapArchObjectFactory = mapArchObjectFactory; this.gameObjectParser = gameObjectParser; Modified: trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/io/DefaultMapReaderFactory.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -59,7 +59,7 @@ /** The {@link EditTypes} instance to use. */ @NotNull - private EditTypes<G, A, R, V> editTypes; + private EditTypes editTypes; /** * Creates a new instance. @@ -79,7 +79,7 @@ * @param editTypes the edit types instance */ @Deprecated - public void setEditTypes(@NotNull final EditTypes<G, A, R, V> editTypes) { + public void setEditTypes(@NotNull final EditTypes editTypes) { this.editTypes = editTypes; } Modified: trunk/src/app/net/sf/gridarta/io/GameObjectParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-10-05 10:23:47 UTC (rev 5445) +++ trunk/src/app/net/sf/gridarta/io/GameObjectParser.java 2008-10-06 17:50:56 UTC (rev 5446) @@ -85,6 +85,6 @@ * @param isInteractive if set, may ask to delete undefined archetypes; if * unset, keep undefined archetypes */ - void collectTempList(@NotNull Component parent, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull EditTypes<G, A, R, ?> editTypes, List<G> objects, String uri, boolean isInteractive); + void collectTempList(@NotNull Component parent, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull EditTypes editTypes, List<G> objects, String uri, boolean isInteractive); } // interface GameObjectParser This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-10 21:40:58
|
Revision: 5457 http://gridarta.svn.sourceforge.net/gridarta/?rev=5457&view=rev Author: akirschbaum Date: 2008-10-10 21:40:51 +0000 (Fri, 10 Oct 2008) Log Message: ----------- Make replace dialog work again; Close replace dialog when affected map view is closed. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/app/net/sf/gridarta/map/MapControl.java trunk/src/app/net/sf/gridarta/messages.properties trunk/src/app/net/sf/gridarta/messages_de.properties trunk/src/app/net/sf/gridarta/messages_fr.properties trunk/src/app/net/sf/gridarta/messages_sv.properties Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/crossfire/ChangeLog 2008-10-10 21:40:51 UTC (rev 5457) @@ -1,3 +1,9 @@ +2008-10-10 Andreas Kirschbaum + + * Make replace dialog work again. + + * Close replace dialog when affected map view is closed. + 2008-10-05 Andreas Kirschbaum * Implement incremental undo stack. Makes edit operations more Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/daimonin/ChangeLog 2008-10-10 21:40:51 UTC (rev 5457) @@ -1,3 +1,9 @@ +2008-10-10 Andreas Kirschbaum + + * Make replace dialog work again. + + * Close replace dialog when affected map view is closed. + 2008-10-05 Andreas Kirschbaum * Implement incremental undo stack. Makes edit operations more Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-10 21:40:51 UTC (rev 5457) @@ -376,7 +376,7 @@ new MapCursorActions<G, A, R, V>(key, gameObjectAttributesDialogFactory, mapViewManager, selectedSquareControl, selectedSquareView); validators = createMapValidators(globalSettings); final CopyBuffer<G, A, R, V> copyBuffer = new CopyBuffer<G, A, R, V>(editTypes, mapControlFactory); - final ReplaceDialogManager<G, A, R, V> replaceDialogManager = new ReplaceDialogManager<G, A, R, V>(mainView, archetypeSet, copyBuffer, objectChooser); + final ReplaceDialogManager<G, A, R, V> replaceDialogManager = new ReplaceDialogManager<G, A, R, V>(mainView, archetypeSet, copyBuffer, objectChooser, mapViewManager); mainActions = new MainActions<G, A, R, V>(replaceDialogManager, this, mainView, globalSettings, validators, editTypes, archetypeSet, copyBuffer, animationObjects, ACTION_FACTORY, faceObjects, objectChooser, mapManager, mapViewManager); new About(key, mainView); new UndoControl<G, A, R, V>(mapManager); Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialog.java 2008-10-10 21:40:51 UTC (rev 5457) @@ -490,11 +490,6 @@ final boolean deleteOnly = replaceWithBox.getSelectedIndex() == 3; final boolean entireMap = replaceEntireBox.getSelectedIndex() == 0; - if (mapView.getMapControl().isClosing()) { - dialog.setVisible(false); - ACTION_FACTORY.showMessageDialog(this, "replaceMapGone", mapView.getMapControl().getMapFileName()); - return true; - } else if (!entireMap && mapView.getMapViewBasic().getMapGrid().getSelectedRec() == null) { // user selected "replace highlighted" but nothing is highlighted ACTION_FACTORY.showMessageDialog(this, "replaceMapNoSelection", mapView.getMapControl().getMapFileName()); @@ -550,4 +545,14 @@ return isBuilt; } + /** + * Dispose the replace dialog. + * @param mapView the map view to dispose the dialog of; do nothing if no + */ + public void dispose(final MapView<G, A, R, V> mapView) { + if (mapView == this.mapView) { + dialog.setVisible(false); + } + } + } // class ReplaceDialog Modified: trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/gui/ReplaceDialogManager.java 2008-10-10 21:40:51 UTC (rev 5457) @@ -5,6 +5,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeSet; import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.map.MapArchObject; @@ -34,11 +35,32 @@ @NotNull private final ObjectChooser<G, A, R> objectChooser; - public ReplaceDialogManager(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser) { + /** The map view manager listener to detect closed map views. */ + private final MapViewManagerListener<G, A, R, V> mapViewManagerListener = new MapViewManagerListener<G, A, R, V>() { + + /** {@inheritDoc} */ + public void currentMapViewChanged(@Nullable final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewCreated(@NotNull final MapView<G, A, R, V> mapView) { + // ignore + } + + /** {@inheritDoc} */ + public void mapViewClosing(@NotNull final MapView<G, A, R, V> mapView) { + disposeDialog(mapView); + } + + }; + + public ReplaceDialogManager(@NotNull final Component parent, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final CopyBuffer<G, A, R, V> copyBuffer, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapViewManager<G, A, R, V> mapViewManager) { this.parent = parent; this.archetypeSet = archetypeSet; this.copyBuffer = copyBuffer; this.objectChooser = objectChooser; + mapViewManager.addMapViewManagerListener(mapViewManagerListener); } /** @@ -58,4 +80,15 @@ return instance; } + /** + * Dispose the replace dialog. + * @param mapView the map view to dispose the dialog of; do nothing if no + * dialog exists + */ + public void disposeDialog(final MapView<G, A, R, V> mapView) { + if (instance != null) { + instance.dispose(mapView); + } + } + } // class ReplaceDialogManager Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-10-10 21:40:51 UTC (rev 5457) @@ -126,9 +126,6 @@ */ private int activeEditType = 0; - /** Flag that indicates whether the level is closing or not. */ - private boolean levelClosing = false; - /** Reference to LevelRenderer, which is only used to get images. */ private SoftReference<LevelRenderer> levelRendererReference; @@ -198,15 +195,9 @@ /** {@inheritDoc} */ public void levelCloseNotify() { mapModel.removeMapModelListener(mapModelListener); - levelClosing = true; } /** {@inheritDoc} */ - public boolean isClosing() { - return levelClosing; - } - - /** {@inheritDoc} */ public boolean isModified() { return modified; } Modified: trunk/src/app/net/sf/gridarta/map/MapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/map/MapControl.java 2008-10-10 21:40:51 UTC (rev 5457) @@ -120,12 +120,6 @@ void fireIconChanged(); /** - * Returns whether this map has been closed. - * @return <code>true</code> when this map has been closed. - */ - boolean isClosing(); - - /** * Return all game objects. * @return All game objects. */ Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-10-10 21:40:51 UTC (rev 5457) @@ -462,8 +462,6 @@ replaceInvalidDensity.title=Invalid Value replaceInvalidDensity.message=Invalid replace density value.\nThe value must be between 1 and 100. -replaceMapGone.title=Error with Replace -replaceMapGone.message=Map {0} is no longer available.\n replaceMapNoSelection.title=No selection replaceMapNoSelection.message=You chose to replace on selected squares of\nmap "{0}", but there is no selected area. replacedZero.title=Replace failed Modified: trunk/src/app/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/messages_de.properties 2008-10-10 21:40:51 UTC (rev 5457) @@ -445,8 +445,6 @@ replaceInvalidDensity.title=Ung\xFCltiger Wert replaceInvalidDensity.message=Die Ersetzungsdichte ist ung\xFCltig.\nSie muss zwischen 1 und 100 liegen. -replaceMapGone.title=Karte nicht mehr verf\xFCgbar -replaceMapGone.message=Karte {0} ist nicht mehr verf\xFCgbar.\n replaceMapNoSelection.title=Keine Selektion replaceMapNoSelection.message=Ich kann ohne Selektion keine selektierten Felder\nauf der Karte "{0}" ersetzen. replacedZero.title=Ersetzung fehlgeschlagen Modified: trunk/src/app/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/messages_fr.properties 2008-10-10 21:40:51 UTC (rev 5457) @@ -444,8 +444,6 @@ #replaceInvalidDensity.title= #replaceInvalidDensity.message= -#replaceMapGone.title= -replaceMapGone.message=La carte {0} n'est plus disponible.\n #replaceMapNoSelection.title= replaceMapNoSelection.message=Vous avez choisi de remplacer les cases s\xE9lectionn\xE9es de la \ncarte \"{0}\", mais il n'y a pas de s\xE9lection. #replacedZero.title= Modified: trunk/src/app/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-10 21:08:41 UTC (rev 5456) +++ trunk/src/app/net/sf/gridarta/messages_sv.properties 2008-10-10 21:40:51 UTC (rev 5457) @@ -448,8 +448,6 @@ replaceInvalidDensity.title=Ogiltigt v\xE4rde #replacdInvalidDensity.message= -replaceMapGone.title=Fel under ers\xE4ttning -replaceMapGone.message=Kartan {0} is no longer available. replaceMapNoSelection.title=Ingen markering replaceMapNoSelection.message=Du valde att ers\xE4tta markerade rutor p\xE5 kartan \"{0}\",\n men det finns ingen markering. replacedZero.title=Ers\xE4ttning misslyckades This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-11 13:29:13
|
Revision: 5465 http://gridarta.svn.sourceforge.net/gridarta/?rev=5465&view=rev Author: akirschbaum Date: 2008-10-11 13:28:56 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Remove unused method parameters. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 13:26:01 UTC (rev 5464) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 13:28:56 UTC (rev 5465) @@ -346,7 +346,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { + protected net.sf.gridarta.gameobject.ArchetypeSet<GameObject, MapArchObject, Archetype> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { return new ArchetypeSet(((GlobalSettingsImpl) globalSettings).getImageSet(), archetypeFactory); } Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 13:26:01 UTC (rev 5464) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 13:28:56 UTC (rev 5465) @@ -536,7 +536,7 @@ /** {@inheritDoc} */ @NotNull @Override - protected ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final net.sf.gridarta.gameobject.anim.AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final net.sf.gridarta.gameobject.face.FaceObjects faceObjects, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { + protected ArchetypeSet newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<GameObject, MapArchObject, Archetype> archetypeFactory) { return new ArchetypeSet(archetypeFactory); } Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 13:26:01 UTC (rev 5464) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 13:28:56 UTC (rev 5465) @@ -344,7 +344,7 @@ globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); final ArchetypeFactory<G, A, R> archetypeFactory = newArchetypeFactory(); - final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, editTypes, animationObjects, faceObjects, archetypeFactory); + final ArchetypeSet<G, A, R> archetypeSet = newArchetypeSet(globalSettings, archetypeFactory); mapReaderFactory.setArchetypeSet(archetypeSet); AbstractScriptedEvent.init(archetypeSet); PathManager.setGlobalSettings(globalSettings); @@ -577,7 +577,7 @@ * @return the archetype set instance */ @NotNull - protected abstract ArchetypeSet<G, A, R> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final EditTypes editTypes, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeFactory<G, A, R> archetypeFactory); + protected abstract ArchetypeSet<G, A, R> newArchetypeSet(@NotNull final GlobalSettings globalSettings, @NotNull final ArchetypeFactory<G, A, R> archetypeFactory); /** * Create the cache instance for map images. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-11 13:42:52
|
Revision: 5467 http://gridarta.svn.sourceforge.net/gridarta/?rev=5467&view=rev Author: akirschbaum Date: 2008-10-11 13:42:29 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Remove unused return value. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-11 13:38:12 UTC (rev 5466) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchData.java 2008-10-11 13:42:29 UTC (rev 5467) @@ -159,8 +159,8 @@ } /** {@inheritDoc} */ - public boolean createNewEvent(final JDialog frame) { - return ScriptArchEditor.createNewEvent(frame, this); + public void createNewEvent(final JDialog frame) { + ScriptArchEditor.createNewEvent(frame, this); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-11 13:38:12 UTC (rev 5466) +++ trunk/crossfire/src/cfeditor/gameobject/scripts/ScriptArchEditor.java 2008-10-11 13:42:29 UTC (rev 5467) @@ -34,7 +34,7 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - public static boolean createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -50,7 +50,7 @@ // collision with existing event -> ask user: replace? if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { // bail out - return false; + return; } } @@ -64,7 +64,7 @@ // if map dir doesn't exist, this is not going to work frame.setVisible(false); ACTION_FACTORY.showMessageDialog(frame, "mapDirDoesntExist", mapDir); - return false; + return; } else { absScriptPath = mapDir.getAbsolutePath() + scriptPath; } @@ -89,7 +89,7 @@ event = new ScriptedEvent(eventType, pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return false; + return; } if (replaceObject != null) { replaceObject.remove(); @@ -124,7 +124,7 @@ event = new ScriptedEvent(eventType, pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return false; + return; } if (replaceObject != null) { replaceObject.remove(); @@ -138,7 +138,6 @@ } } } - return scriptArchData.isChanged(); } } // class ScriptArchEditor Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-11 13:38:12 UTC (rev 5466) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchData.java 2008-10-11 13:42:29 UTC (rev 5467) @@ -159,8 +159,8 @@ } /** {@inheritDoc} */ - public boolean createNewEvent(final JDialog frame) { - return ScriptArchEditor.createNewEvent(frame, this); + public void createNewEvent(final JDialog frame) { + ScriptArchEditor.createNewEvent(frame, this); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-11 13:38:12 UTC (rev 5466) +++ trunk/daimonin/src/daieditor/gameobject/scripts/ScriptArchEditor.java 2008-10-11 13:42:29 UTC (rev 5467) @@ -34,7 +34,7 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - public static boolean createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { + public static void createNewEvent(final JDialog frame, final ScriptArchData scriptArchData) { String scriptPath = inputScriptPath.getText().trim(); final String options = inputOptions.getText().trim(); final int eventType = ScriptArchUtils.indexToEventType(eventTypeBox.getSelectedIndex()); @@ -50,7 +50,7 @@ // collision with existing event -> ask user: replace? if (JOptionPane.showConfirmDialog(frame, "An event of type \"" + ScriptArchUtils.typeName(eventType) + "\" already exists for this object.\n" + "Do you want to replace the existing event?", "Event exists", JOptionPane.YES_NO_OPTION, JOptionPane.INFORMATION_MESSAGE) == JOptionPane.NO_OPTION) { // bail out - return false; + return; } } @@ -64,7 +64,7 @@ // if map dir doesn't exist, this is not going to work frame.setVisible(false); ACTION_FACTORY.showMessageDialog(frame, "mapDirDoesntExist", mapDir); - return false; + return; } else { absScriptPath = mapDir.getAbsolutePath() + scriptPath; } @@ -89,7 +89,7 @@ event = new ScriptedEvent(eventType, pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return false; + return; } if (replaceObject != null) { replaceObject.remove(); @@ -124,7 +124,7 @@ event = new ScriptedEvent(eventType, pluginName, scriptPath, options); } catch (final UndefinedEventArchetypeException ex) { JOptionPane.showMessageDialog(frame, "Cannot create event of type " + eventType + ":\n" + ex.getMessage() + ".", "Cannot create event", JOptionPane.ERROR_MESSAGE); - return false; + return; } if (replaceObject != null) { replaceObject.remove(); @@ -138,7 +138,6 @@ } } } - return scriptArchData.isChanged(); } } // class ScriptArchEditor Modified: trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-11 13:38:12 UTC (rev 5466) +++ trunk/src/app/net/sf/gridarta/gameobject/scripts/ScriptArchData.java 2008-10-11 13:42:29 UTC (rev 5467) @@ -43,10 +43,8 @@ /** * The user has chosen to create a new event, now it is to be done. * @param frame the parent window of the create-new-event dialog - * @return <code>true</code> if the new event was successfully created, - * otherwise <code>false</code>. */ - public abstract boolean createNewEvent(final JDialog frame); + public abstract void createNewEvent(final JDialog frame); public abstract void setChanged(final boolean changed); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-11 14:42:57
|
Revision: 5477 http://gridarta.svn.sourceforge.net/gridarta/?rev=5477&view=rev Author: akirschbaum Date: 2008-10-11 14:42:40 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Remove MapControlFactory.setMapReaderFactory(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -177,8 +177,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory() { - return new DefaultMapControlFactory(); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + return new DefaultMapControlFactory(mapReaderFactory); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -35,6 +35,7 @@ import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapArchObjectFactory; @@ -109,6 +110,14 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; + /** + * Creates a new instance. + * @param mapReaderFactory the map reader factory to use + */ + public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + super(mapReaderFactory); + } + /** {@inheritDoc} */ public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.mapViewFactory = mapViewFactory; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -223,8 +223,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory() { - return new DefaultMapControlFactory(); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + return new DefaultMapControlFactory(mapReaderFactory); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -35,6 +35,7 @@ import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; +import net.sf.gridarta.io.MapReaderFactory; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapArchObjectFactory; @@ -109,6 +110,14 @@ @NotNull private GameObjectMatcher exitTypeGameObjectMatcher; + /** + * Creates a new instance. + * @param mapReaderFactory the map reader factory to use + */ + public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + super(mapReaderFactory); + } + /** {@inheritDoc} */ public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.mapViewFactory = mapViewFactory; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -328,13 +328,12 @@ this.scriptExtension = scriptExtension; this.globalSettings = globalSettings; appPrefsModel = createAppPrefsModel(); - final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(); final MapArchObjectFactory<A> mapArchObjectFactory = newMapArchObjectFactory(); final MapArchObjectParserFactory<A> mapArchObjectParserFactory = newMapArchObjectParserFactory(); final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); - mapControlFactory.setMapReaderFactory(mapReaderFactory); + final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); @@ -528,7 +527,7 @@ protected abstract AppPrefsModel createAppPrefsModel(); @NotNull - protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(); + protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(@NotNull final MapReaderFactory<G, A> mapReaderFactory); @NotNull protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); Modified: trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/src/app/net/sf/gridarta/map/AbstractMapControlFactory.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -25,7 +25,6 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; -import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.MapReader; import net.sf.gridarta.io.MapReaderFactory; import org.jetbrains.annotations.NotNull; @@ -37,19 +36,16 @@ public abstract class AbstractMapControlFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V extends MapViewBasic<G, A, R, V>> implements MapControlFactory<G, A, R, V> { /** - * The gridarta objects factory. + * The {@link MapReaderFactory} to use. */ @NotNull - private MapReaderFactory<G, A> mapReaderFactory; + private final MapReaderFactory<G, A> mapReaderFactory; /** * Creates a new instance. + * @param mapReaderFactory the map reader factory to use */ - protected AbstractMapControlFactory() { - } - - /** {@inheritDoc} */ - public void setMapReaderFactory(@NotNull final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory) { + protected AbstractMapControlFactory(@NotNull final MapReaderFactory<G, A> mapReaderFactory) { this.mapReaderFactory = mapReaderFactory; } Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -34,7 +34,6 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.RendererFactory; -import net.sf.gridarta.io.DefaultMapReaderFactory; import net.sf.gridarta.io.GameObjectParser; import net.sf.gridarta.io.MapArchObjectParserFactory; import org.jetbrains.annotations.NotNull; @@ -107,7 +106,4 @@ @NotNull MapControl<G, A, R, V> newPickmapControl(@NotNull Component parent, @NotNull File file) throws IOException; - @Deprecated - void setMapReaderFactory(@NotNull DefaultMapReaderFactory<G, A, R, V> mapReaderFactory); - } // interface MapControlFactory Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-11 14:29:45 UTC (rev 5476) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-11 14:42:40 UTC (rev 5477) @@ -403,7 +403,7 @@ final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); final GameObjectParserFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParserFactory = new TestGameObjectParserFactory(); final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new DefaultMapReaderFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); - final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(); + final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(mapReaderFactory); final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); final TestArchetypeFactory archetypeFactory = new TestArchetypeFactory(); @@ -889,8 +889,10 @@ /** * Creates a new instance. + * @param mapReaderFactory the map reader factory to use */ - protected TestMapControlFactory() { + protected TestMapControlFactory(@NotNull final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory) { + super(mapReaderFactory); } /** {@inheritDoc} */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-11 14:54:39
|
Revision: 5479 http://gridarta.svn.sourceforge.net/gridarta/?rev=5479&view=rev Author: akirschbaum Date: 2008-10-11 14:54:20 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Remove parameters from MapControlFactory.init(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/map/MapControlFactory.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -177,8 +177,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { - return new DefaultMapControlFactory(mapReaderFactory); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory) { + return new DefaultMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); } /** {@inheritDoc} */ Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -60,13 +60,13 @@ * The {@link MapArchObjectParserFactory} instance to use. */ @NotNull - private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; + private final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; /** * The {@link MapArchObjectFactory} instance to use. */ @NotNull - private MapArchObjectFactory<MapArchObject> mapArchObjectFactory; + private final MapArchObjectFactory<MapArchObject> mapArchObjectFactory; /** * The {@link GameObjectParser} instance to use. @@ -113,16 +113,19 @@ /** * Creates a new instance. * @param mapReaderFactory the map reader factory to use + * @param mapArchObjectFactory the map arch object factory to use + * @param mapArchObjectParserFactory the map arch object parser factory to + * use */ - public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory) { super(mapReaderFactory); + this.mapArchObjectParserFactory = mapArchObjectParserFactory; + this.mapArchObjectFactory = mapArchObjectFactory; } /** {@inheritDoc} */ - public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.mapViewFactory = mapViewFactory; - this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.mapArchObjectFactory = mapArchObjectFactory; this.gameObjectParser = gameObjectParser; this.rendererFactory = rendererFactory; this.mapActions = mapActions; Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -223,8 +223,8 @@ /** {@inheritDoc} */ @NotNull @Override - protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { - return new DefaultMapControlFactory(mapReaderFactory); + protected MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory) { + return new DefaultMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -60,13 +60,13 @@ * The {@link MapArchObjectParserFactory} instance to use. */ @NotNull - private MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; + private final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory; /** * The {@link MapArchObjectFactory} instance to use. */ @NotNull - private MapArchObjectFactory<MapArchObject> mapArchObjectFactory; + private final MapArchObjectFactory<MapArchObject> mapArchObjectFactory; /** * The {@link GameObjectParser} instance to use. @@ -113,16 +113,19 @@ /** * Creates a new instance. * @param mapReaderFactory the map reader factory to use + * @param mapArchObjectFactory the map arch object factory to use + * @param mapArchObjectParserFactory the map arch object parser factory to + * use */ - public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory) { + public DefaultMapControlFactory(@NotNull final MapReaderFactory<GameObject, MapArchObject> mapReaderFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory) { super(mapReaderFactory); + this.mapArchObjectParserFactory = mapArchObjectParserFactory; + this.mapArchObjectFactory = mapArchObjectFactory; } /** {@inheritDoc} */ - public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final MapArchObjectParserFactory<MapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final MapViewFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapViewFactory, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.mapViewFactory = mapViewFactory; - this.mapArchObjectParserFactory = mapArchObjectParserFactory; - this.mapArchObjectFactory = mapArchObjectFactory; this.gameObjectParser = gameObjectParser; this.rendererFactory = rendererFactory; this.mapActions = mapActions; Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -333,7 +333,7 @@ final GameObjectFactory<G, A, R> gameObjectFactory = newGameObjectFactory(); final GameObjectParserFactory<G, A, R> gameObjectParserFactory = newGameObjectParserFactory(gameObjectFactory); final DefaultMapReaderFactory<G, A, R, V> mapReaderFactory = new DefaultMapReaderFactory<G, A, R, V>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); - final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory); + final MapControlFactory<G, A, R, V> mapControlFactory = newMapControlFactory(mapReaderFactory, mapArchObjectFactory, mapArchObjectParserFactory); final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(key, mapReaderFactory, mapControlFactory, globalSettings); final EditTypes editTypes = new EditTypes(tmpMapManager); mapReaderFactory.setEditTypes(editTypes); @@ -467,7 +467,7 @@ archetypeSet.init(gameObjectParser); final AbstractArchetypeParser<G, A, R> archetypeParser = newArchetypeParser(gameObjectParser, archetypeChooserControl, animationObjects, archetypeSet, gameObjectFactory); final MapViewFactory<G, A, R, V> mapViewFactory = newMapViewFactory(faceObjects, selectedSquareView, this, mainView, editTypes, mapImageCache, toolPalette, filterControl); - mapControlFactory.init(mapViewFactory, mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); + mapControlFactory.init(mapViewFactory, gameObjectParser, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); copyBuffer.init(mapArchObjectFactory.newMapArchObject(false), mainView); GameObject.initialize(archetypeSet, archetypeTypeSet, gameObjectMatchers, animationObjects, SystemIcons.getNofaceTileIcon()); init4(gameObjectParser, archetypeParser, editTypes, faceObjects, animationObjects, mainView, globalSettings, archetypeSet); @@ -527,7 +527,7 @@ protected abstract AppPrefsModel createAppPrefsModel(); @NotNull - protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(@NotNull final MapReaderFactory<G, A> mapReaderFactory); + protected abstract MapControlFactory<G, A, R, V> newMapControlFactory(@NotNull final MapReaderFactory<G, A> mapReaderFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory); @NotNull protected abstract GameObjectFactory<G, A, R> newGameObjectFactory(); Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -35,7 +35,6 @@ import net.sf.gridarta.gui.map.MapViewFactory; import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.io.GameObjectParser; -import net.sf.gridarta.io.MapArchObjectParserFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,9 +47,6 @@ /** * Initializes the instance. * @param mapViewFactory the map view factory to use - * @param mapArchObjectParserFactory the map arch object parser factory to - * use - * @param mapArchObjectFactory the map arch object factory instance to use * @param gameObjectParser the game object parser to use * @param rendererFactory the renderer factory to use * @param mapActions the map actions to use @@ -60,7 +56,7 @@ * @param exitTypeGameObjectMatcher the matcher for exit objects */ @Deprecated - void init(@NotNull MapViewFactory<G, A, R, V> mapViewFactory, @NotNull MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull GameObjectParser<G, A, R> gameObjectParser, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull MapActions mapActions, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull GameObjectMatcher exitTypeGameObjectMatcher); + void init(@NotNull MapViewFactory<G, A, R, V> mapViewFactory, @NotNull GameObjectParser<G, A, R> gameObjectParser, @NotNull RendererFactory<G, A, R> rendererFactory, @NotNull MapActions mapActions, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull MapImageCache<G, A, R, V> mapImageCache, @NotNull AutojoinLists<G, A, R> autojoinLists, @NotNull GameObjectMatcher exitTypeGameObjectMatcher); /** * Create a new map control instance. Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-11 14:45:23 UTC (rev 5478) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-11 14:54:20 UTC (rev 5479) @@ -896,7 +896,7 @@ } /** {@inheritDoc} */ - public void init(@NotNull final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewFactory, @NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapViewFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final MapActions mapActions, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-11 22:27:25
|
Revision: 5485 http://gridarta.svn.sourceforge.net/gridarta/?rev=5485&view=rev Author: akirschbaum Date: 2008-10-11 22:27:18 +0000 (Sat, 11 Oct 2008) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CFJavaEditor.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/script/ScriptController.java trunk/src/app/net/sf/gridarta/textedit/textarea/actions/End.java trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Home.java trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/HTMLTokenMarker.java trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/PythonTokenMarker.java Modified: trunk/crossfire/src/cfeditor/CFJavaEditor.java =================================================================== --- trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/crossfire/src/cfeditor/CFJavaEditor.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -88,8 +88,7 @@ if (arg.equals("--help") || arg.equals("-h")) { usage(); return; - } else - if (arg.equals(op = "--outfile") || arg.equals(op = "-o")) { + } else if (arg.equals(op = "--outfile") || arg.equals(op = "-o")) { if (outfile != null) { System.err.println("Warning: Option --outfile specified more than once. Overriding previous argument."); } Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSetLoader.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -269,8 +269,7 @@ log.warn("Cannot read directory: " + f); } } - } else - if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! + } else if (f.isFile()) { // watch out for stuff that's not a file and not a directory!!! if (name.endsWith(".arc")) { //mainControl.setStatusText("Loading Arch: "+ name); archetypeSet.setCurrentFile(f); @@ -368,8 +367,7 @@ final Archetype archetype = archetypeSet.getArchetype(defArchName); if (name == null || defArchName == null || name.length() == 0 || defArchName.length() == 0 || archetype == null) { log.warn("Artifacts file: Line " + lineCount + " Object >" + defArchName + "< / >" + name + "< / >" + objTitle + "< has missing name or defArch"); - } else - if (editorCode != 0 && editorCode != 2) { // the next line of our file is part of a arch parse until a "end" comes + } else if (editorCode != 0 && editorCode != 2) { // the next line of our file is part of a arch parse until a "end" comes // now the editor will do the same as the real server: // get the default arch as base and parse the new values over it // the extended functions of the artifacts file can be ignored here. Modified: trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/daimonin/src/daieditor/gui/map/DefaultLevelRenderer.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -363,8 +363,7 @@ // TODO: This should be improved, especially regarding multi arch mobs inside spawn points. if (tmpNode != null && tmpNode.isLowestPart() || node.isLowestPart()) { img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); - } else - if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { + } else if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); } } else { Modified: trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/daimonin/src/daieditor/gui/map/SimpleLevelRenderer.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -173,8 +173,7 @@ final int y = ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()); grfx.drawImage(img.getImage(), x, y, img.getImageObserver()); //img.paintIcon(this, grfx, xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()), ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr())); - } else - if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { + } else if (node.isInContainer() && ((GameObject) node.getContainer()).getTypeNo() == Archetype.TYPE_SPAWN_POINT) { final int x = xstart - MultiPositionData.getXOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()); final int y = ystart - yoff + MultiPositionData.getYOffset(node.getMultiShapeID(), tmpNode == null ? node.getMultiPartNr() : tmpNode.getMultiPartNr()); grfx.drawImage(img.getImage(), x, y, img.getImageObserver()); Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -222,8 +222,7 @@ if (!save(mapControl)) { return false; } - } else - if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { + } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return false; } } Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeAnimName.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -58,11 +58,9 @@ if (nameOld.equalsIgnoreCase("name")) { if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { dtxt = gameObject.getObjName(); - } else - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + } else if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { dtxt = gameObject.getObjName(); - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { dtxt = archetype.getObjName(); } else { dtxt = archetype.getArchetypeName(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeFaceName.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -58,11 +58,9 @@ if (nameOld.equalsIgnoreCase("name")) { if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { dtxt = gameObject.getObjName(); - } else - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + } else if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { dtxt = gameObject.getObjName(); - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { dtxt = archetype.getObjName(); } else { dtxt = archetype.getArchetypeName(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeAttributeString.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -52,11 +52,9 @@ if (nameOld.equalsIgnoreCase("name")) { if (typeNoEventConnector != 0 && type.getTypeNo() == typeNoEventConnector) { dtxt = gameObject.getObjName(); - } else - if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { + } else if (gameObject.getObjName() != null && gameObject.getObjName().length() > 0) { dtxt = gameObject.getObjName(); - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { dtxt = archetype.getObjName(); } else { dtxt = archetype.getArchetypeName(); Modified: trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java =================================================================== --- trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/archtype/ArchetypeTypeParser.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -172,8 +172,7 @@ final Attr a1 = elem.getAttributeNode("name"); if (a1 == null) { throw new ArchetypeTypeParseException("In '" + XML_IGNORE + "' section of type " + result.typeName + ": ignore_list missing 'name'."); - } else - if (ignoreListTable.containsKey(a1.getValue().trim())) { + } else if (ignoreListTable.containsKey(a1.getValue().trim())) { // just copy everything from ignorelist to this ignore section final List<String> ignlist = ignoreListTable.get(a1.getValue().trim()); for (final String ignItem : ignlist) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribAnimName.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -66,21 +66,18 @@ // events are special: they do not inherit the // archetype name for empty names newName[0] = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { if (!inline.equals(archetype.getObjName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (!inline.equals(archetype.getArchetypeName())) { + } else if (!inline.equals(archetype.getArchetypeName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { + } else if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(ref.getArchetypeAttributeName()))) { newAnim[0] = inline; return ref.getArchetypeAttributeName() + " " + inline; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribFaceName.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -66,21 +66,18 @@ // events are special: they do not inherit the // archetype name for empty names newName[0] = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { if (!inline.equals(archetype.getObjName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (!inline.equals(archetype.getArchetypeName())) { + } else if (!inline.equals(archetype.getArchetypeName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { + } else if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(ref.getArchetypeAttributeName()))) { newAnim[0] = inline; return ref.getArchetypeAttributeName() + " " + inline; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/DialogAttribString.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -67,21 +67,18 @@ // events are special: they do not inherit the // archetype name for empty names newName[0] = inline; - } else - if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { + } else if (archetype.getObjName() != null && archetype.getObjName().length() > 0) { if (!inline.equals(archetype.getObjName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (!inline.equals(archetype.getArchetypeName())) { + } else if (!inline.equals(archetype.getArchetypeName())) { newName[0] = inline; } else { newName[0] = ""; } - } else - if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { + } else if (ref.getArchetypeAttributeName().equalsIgnoreCase("animation")) { if (inline.length() > 0 && !inline.equals(archetype.getAttributeString(ref.getArchetypeAttributeName()))) { newAnim[0] = inline; return ref.getArchetypeAttributeName() + " " + inline; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -834,8 +834,7 @@ if (e.getStateChange() == ItemEvent.DESELECTED) { // remember the deselected type deselected = ((String) e.getItem()).trim(); - } else - if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { + } else if (e.getStateChange() == ItemEvent.SELECTED && !e.getItem().equals(deselected)) { // new type was selected // first, get new type structure final ArchetypeType<G, A, R> newType = archetypeTypeSet.getTypeByName((String) e.getItem()); Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ArchTab.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -246,8 +246,7 @@ } else { return archNameField.getText(); // overrule in map gameObject } - } else - if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { + } else if (archNameField.getText().compareTo(gameObject.getArchetypeName()) == 0) { return null; } else { // def is null, something is in panel, so we set it return archNameField.getText(); // overrule in map gameObject Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/ToolPalette.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -107,11 +107,9 @@ final int mask = event.getModifiers(); if ((mask & InputEvent.BUTTON1_DOWN_MASK) == InputEvent.BUTTON1_DOWN_MASK) { toolSelector = lmbSelector; - } else - if ((mask & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK) { + } else if ((mask & InputEvent.BUTTON2_DOWN_MASK) == InputEvent.BUTTON2_DOWN_MASK) { toolSelector = mmbSelector; - } else - if ((mask & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { + } else if ((mask & InputEvent.BUTTON3_DOWN_MASK) == InputEvent.BUTTON3_DOWN_MASK) { toolSelector = rmbSelector; } else { return null; Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -363,8 +363,7 @@ if (pickmap.isModified()) { return false; } - } else - if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { + } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return false; } } Modified: trunk/src/app/net/sf/gridarta/script/ScriptController.java =================================================================== --- trunk/src/app/net/sf/gridarta/script/ScriptController.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/script/ScriptController.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -201,8 +201,7 @@ if (!saveScript(script)) { return false; } - } else - if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { + } else if (result == JOptionPane.CANCEL_OPTION || result == JOptionPane.CLOSED_OPTION) { return false; } } Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/actions/End.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/actions/End.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/actions/End.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -42,8 +42,7 @@ if (caret == lastDocument) { textArea.getToolkit().beep(); return; - } else - if (!Boolean.TRUE.equals(textArea.getClientProperty(InputHandler.SMART_HOME_END_PROPERTY))) { + } else if (!Boolean.TRUE.equals(textArea.getClientProperty(InputHandler.SMART_HOME_END_PROPERTY))) { caret = lastOfLine; } else if (caret == lastVisible) { caret = lastDocument; Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Home.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Home.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/actions/Home.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -37,8 +37,7 @@ if (caret == 0) { textArea.getToolkit().beep(); return; - } else - if (!Boolean.TRUE.equals(textArea.getClientProperty(InputHandler.SMART_HOME_END_PROPERTY))) { + } else if (!Boolean.TRUE.equals(textArea.getClientProperty(InputHandler.SMART_HOME_END_PROPERTY))) { caret = firstOfLine; } else if (caret == firstVisible) { caret = 0; Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/HTMLTokenMarker.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/HTMLTokenMarker.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/HTMLTokenMarker.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -69,8 +69,7 @@ if (SyntaxUtilities.regionMatches(false, line, i1, "!--")) { i += 3; currentToken = Token.COMMENT1; - } else - if (js && SyntaxUtilities.regionMatches(true, line, i1, "script>")) { + } else if (js && SyntaxUtilities.regionMatches(true, line, i1, "script>")) { addToken(8, Token.KEYWORD1); i += 8; lastOffset = i; Modified: trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/PythonTokenMarker.java =================================================================== --- trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/PythonTokenMarker.java 2008-10-11 21:56:11 UTC (rev 5484) +++ trunk/src/app/net/sf/gridarta/textedit/textarea/tokenmarker/PythonTokenMarker.java 2008-10-11 22:27:18 UTC (rev 5485) @@ -133,8 +133,7 @@ case TRIPLEQUOTE1: if (backslash) { backslash = false; - } else - if (SyntaxUtilities.regionMatches(false, line, i, "\"\"\"")) { + } else if (SyntaxUtilities.regionMatches(false, line, i, "\"\"\"")) { addToken((i += 4) - lastOffset, Token.LITERAL1); currentToken = Token.NULL; lastOffset = lastKeyword = i; @@ -144,8 +143,7 @@ case TRIPLEQUOTE2: if (backslash) { backslash = false; - } else - if (SyntaxUtilities.regionMatches(false, line, i, "'''")) { + } else if (SyntaxUtilities.regionMatches(false, line, i, "'''")) { addToken((i += 4) - lastOffset, Token.LITERAL1); currentToken = Token.NULL; lastOffset = lastKeyword = i; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 13:55:20
|
Revision: 5489 http://gridarta.svn.sourceforge.net/gridarta/?rev=5489&view=rev Author: akirschbaum Date: 2008-10-12 13:55:06 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Do not confuse archetype directory and collected directory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/Collectable.java trunk/src/app/net/sf/gridarta/gameobject/Collector.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java trunk/src/app/net/sf/gridarta/gui/MainActions.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Modified: trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/crossfire/src/cfeditor/gameobject/ArchetypeSet.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -74,7 +74,7 @@ } /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final File dfile = new File(dir, IGUIConstants.ARCH_FILE); // now open the output-stream final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); Modified: trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/crossfire/src/cfeditor/gameobject/anim/AnimationObjects.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -47,7 +47,7 @@ } /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { // TODO } Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -199,7 +199,7 @@ /** {@inheritDoc} */ @Override - protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); try { final int numOfFaceObjects = size(); Modified: trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/daimonin/src/daieditor/gameobject/ArchetypeSet.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -98,7 +98,7 @@ } /** {@inheritDoc} Collects the Archetypes. */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final File dfile = new File(dir, IGUIConstants.ARCH_FILE); // now open the output-stream final BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(dfile), IOUtils.MAP_ENCODING)); Modified: trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/daimonin/src/daieditor/gameobject/anim/AnimationObjects.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -76,7 +76,7 @@ * "animations". The tree information for the editor is written to * "animtree". */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { progress.setLabel(ACTION_FACTORY.getString("archCollectAnimations"), size()); collectAnims(progress, dir); collectAnimTree(progress, dir); Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -144,8 +144,8 @@ /** {@inheritDoc} */ @Override - protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final int stripPath = dir.getAbsolutePath().length(); + protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { + final int stripPath = baseDir.getAbsolutePath().length(); final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); try { final int numOfFaceObjects = size(); Modified: trunk/src/app/net/sf/gridarta/gameobject/Collectable.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/src/app/net/sf/gridarta/gameobject/Collectable.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -36,8 +36,10 @@ * Collect information. * @param progress Progress to report progress to. * @param dir Destination directory to collect data to. + * @param baseDir the base directory from where the archetypes has been + * collected * @throws IOException in case of I/O problems during collection */ - void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException; + void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException; } // interface Collectable Modified: trunk/src/app/net/sf/gridarta/gameobject/Collector.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/src/app/net/sf/gridarta/gameobject/Collector.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -41,6 +41,9 @@ /** The Collectables. */ private final List<Collectable> collectables = new ArrayList<Collectable>(); + /** The archetype directory to collect from. */ + private File archDir; + /** The destination directory to write files to. */ private File destDir; @@ -76,6 +79,14 @@ this.destDir = destDir; } + /** + * Sets the archetype directory to collect from to. + * @param archDir the archetype directory + */ + public void setArchDir(final File archDir) { + this.archDir = archDir; + } + /** Starts collecting. */ public synchronized void start() { if (thread != null) { @@ -110,7 +121,7 @@ try { for (final Collectable collectable : collectables) { try { - collectable.collect(progress, destDir); + collectable.collect(progress, destDir, archDir); } catch (final IOException e) { ACTION_FACTORY.showMessageDialog(progress.getParentComponent(), "archCollectErrorIOException", "arches, animations and animtree, images", e); } Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -76,8 +76,8 @@ * Java image encoder isn't as good as that of gimp in many cases (yet much * better as the old visualtek's). */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - collectTreeFile(progress, dir); + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { + collectTreeFile(progress, dir, baseDir); collectBmapsFile(progress, dir); collectImageFile(progress, dir); } @@ -137,9 +137,11 @@ * Creates the tree file. * @param progress Progress to report progress to. * @param dir Destination directory to collect data to. + * @param baseDir the base directory from where the archetypes has been + * collected * @throws IOException in case of I/O problems during collection */ - protected abstract void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException; + protected abstract void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException; /** * Creates the bmaps file. Modified: trunk/src/app/net/sf/gridarta/gui/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/src/app/net/sf/gridarta/gui/MainActions.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -666,6 +666,7 @@ collectables.add(faceObjects); collector.setCollectables(collectables); collector.setDestDir(new File(globalSettings.getCollectedDirectory())); + collector.setArchDir(new File(globalSettings.getArchDefaultFolder())); collector.start(); aCollectArches.setEnabled(isCollectArchesEnabled()); } Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-12 12:50:12 UTC (rev 5488) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-10-12 13:55:06 UTC (rev 5489) @@ -802,7 +802,7 @@ } /** {@inheritDoc} */ - public void collect(@NotNull final Progress progress, @NotNull final File dir) throws IOException { + public void collect(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 16:27:28
|
Revision: 5497 http://gridarta.svn.sourceforge.net/gridarta/?rev=5497&view=rev Author: akirschbaum Date: 2008-10-12 16:27:25 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:21:54 UTC (rev 5496) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) @@ -98,7 +98,7 @@ // File: Structure* // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + IGUIConstants.PNG_FILE + " at position " + offset); + throw new IOException("Error in file " + getPngFile() + " at position " + offset); } offset += 6; // skip "IMAGE "; while (data[offset++] != (byte) 0x20) { @@ -108,7 +108,7 @@ char c; while ((c = (char) data[offset++]) != ' ') { // read size ' ' if (c < '0' || c > '9') { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + offset + "."); + log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); throw new IOException("syntax error at position " + offset + ": not a digit"); } size *= 10; @@ -125,7 +125,7 @@ final String faceName = faceB.toString().intern(); if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + offset); + throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); } if (treeIn != null) { @@ -207,9 +207,15 @@ /** {@inheritDoc} */ @Override + protected String getFaceTreeFile() { + return IGUIConstants.FACETREE_FILE; + } + + /** {@inheritDoc} */ + @Override protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); + final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); try { final int numOfFaceObjects = size(); progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:21:54 UTC (rev 5496) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) @@ -98,7 +98,7 @@ // File: Structure* // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + IGUIConstants.PNG_FILE + " at position " + offset); + throw new IOException("Error in file " + getPngFile() + " at position " + offset); } offset += 6; // skip "IMAGE "; while (data[offset++] != (byte) 0x20) { @@ -108,7 +108,7 @@ char c; while ((c = (char) data[offset++]) != ' ') { // read size ' ' if (c < '0' || c > '9') { - log.warn("Syntax error in file " + IGUIConstants.PNG_FILE + " at position " + offset + "."); + log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); throw new IOException("syntax error at position " + offset + ": not a digit"); } size *= 10; @@ -125,7 +125,7 @@ final String faceName = faceB.toString().intern(); if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + IGUIConstants.PNG_FILE + " at position " + offset); + throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); } if (treeIn != null) { @@ -207,9 +207,15 @@ /** {@inheritDoc} */ @Override + protected String getFaceTreeFile() { + return IGUIConstants.FACETREE_FILE; + } + + /** {@inheritDoc} */ + @Override protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, IGUIConstants.FACETREE_FILE)), "us-ascii")); + final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); try { final int numOfFaceObjects = size(); progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:21:54 UTC (rev 5496) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) @@ -184,4 +184,10 @@ */ protected abstract String getPngFile(); + /** + * Returns the filename of the face tree file.. + * @return the filename + */ + protected abstract String getFaceTreeFile(); + } // class AbstractFaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 16:33:28
|
Revision: 5498 http://gridarta.svn.sourceforge.net/gridarta/?rev=5498&view=rev Author: akirschbaum Date: 2008-10-12 16:33:22 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) @@ -225,7 +225,8 @@ final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); assert path.startsWith(baseDir.getAbsolutePath()); assert path.endsWith(".png"); - treeFile.append(String.format("\\%05d\t.%s\n", i, path.substring(stripPath, path.length() - 4).replace('\\', '/'))); + final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); + writeTreeFileLine(treeFile, i, name); if (i++ % 100 == 0) { progress.setValue(i); } @@ -236,4 +237,10 @@ } } + /** {@inheritDoc} */ + @Override + protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { + treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); + } + } // class FaceObjects Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) @@ -225,7 +225,8 @@ final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); assert path.startsWith(baseDir.getAbsolutePath()); assert path.endsWith(".png"); - treeFile.append(path.substring(stripPath, path.length() - 4).replace('\\', '/')).append('\n'); + final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); + writeTreeFileLine(treeFile, i, name); if (i++ % 100 == 0) { progress.setValue(i); } @@ -236,4 +237,10 @@ } } + /** {@inheritDoc} */ + @Override + protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { + treeFile.append(faceName).append('\n'); + } + } // class FaceObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:27:25 UTC (rev 5497) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) @@ -190,4 +190,13 @@ */ protected abstract String getFaceTreeFile(); + /** + * Writes one line to the face tree file. + * @param treeFile the face tree file to write + * @param faceNo the face number + * @param faceName the face name + * @throws IOException if writing fails + */ + protected abstract void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException; + } // class AbstractFaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 16:36:49
|
Revision: 5499 http://gridarta.svn.sourceforge.net/gridarta/?rev=5499&view=rev Author: akirschbaum Date: 2008-10-12 16:36:40 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Unify code. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) @@ -92,7 +92,7 @@ final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png final StringBuilder faceB = new StringBuilder(); // face name of png try { - final Pattern pattern = Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)"); + final Pattern pattern = getTreeFilePattern(); int offset = 0; while (offset < data.length) { // File: Structure* @@ -243,4 +243,11 @@ treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); } + /** {@inheritDoc} */ + @NotNull + @Override + protected Pattern getTreeFilePattern() { + return Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)"); + } + } // class FaceObjects Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) @@ -92,7 +92,7 @@ final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png final StringBuilder faceB = new StringBuilder(); // face name of png try { - final Pattern pattern = Pattern.compile("^(.*)"); + final Pattern pattern = getTreeFilePattern(); int offset = 0; while (offset < data.length) { // File: Structure* @@ -243,4 +243,11 @@ treeFile.append(faceName).append('\n'); } + /** {@inheritDoc} */ + @NotNull + @Override + protected Pattern getTreeFilePattern() { + return Pattern.compile("^(.*)"); + } + } // class FaceObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:33:22 UTC (rev 5498) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) @@ -31,6 +31,7 @@ import java.io.PrintStream; import java.io.PrintWriter; import java.nio.channels.FileChannel; +import java.util.regex.Pattern; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.data.AbstractNamedObjects; import net.sf.japi.swing.ActionFactory; @@ -199,4 +200,13 @@ */ protected abstract void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException; + /** + * Returns a {@link Pattern} to extract the face name from a face tree file + * line. The pattern must return the face name in the first capturing + * group. + * @return the pattern + */ + @NotNull + protected abstract Pattern getTreeFilePattern(); + } // class AbstractFaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 16:45:24
|
Revision: 5500 http://gridarta.svn.sourceforge.net/gridarta/?rev=5500&view=rev Author: akirschbaum Date: 2008-10-12 16:45:10 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Move FaceObjects.makeTmpFaceFile() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) @@ -20,7 +20,6 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -41,7 +40,6 @@ import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.utils.ArrayUtils; -import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; @@ -155,50 +153,6 @@ } } - /** - * Returns a file that is a regular file on the file system. Returns the - * passed file if it is a regular file. Otherwise copies the passed file - * into a temporary regular file and returns the copy. - * @param faceFile the input file - * @return the output file which is a regular file on the file system - * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 - */ - private static File makeTmpFaceFile(final File faceFile) { - if (faceFile.exists()) { - return faceFile; - } - - final File tmpFaceFile; - try { - tmpFaceFile = File.createTempFile("gridarta", null); - tmpFaceFile.deleteOnExit(); - final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); - try { - final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); - try { - final byte[] buf = new byte[65536]; - for (;;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - - outputStream.write(buf, 0, len); - } - } - finally { - outputStream.close(); - } - } - finally { - inputStream.close(); - } - } catch (final IOException ex) { - return faceFile; - } - return tmpFaceFile; - } - /** {@inheritDoc} */ @Override protected String getPngFile() { Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) @@ -20,7 +20,6 @@ package daieditor.gameobject.face; import daieditor.IGUIConstants; -import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.ByteArrayOutputStream; @@ -41,7 +40,6 @@ import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.utils.ArrayUtils; -import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; @@ -155,50 +153,6 @@ } } - /** - * Returns a file that is a regular file on the file system. Returns the - * passed file if it is a regular file. Otherwise copies the passed file - * into a temporary regular file and returns the copy. - * @param faceFile the input file - * @return the output file which is a regular file on the file system - * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 - */ - private static File makeTmpFaceFile(final File faceFile) { - if (faceFile.exists()) { - return faceFile; - } - - final File tmpFaceFile; - try { - tmpFaceFile = File.createTempFile("gridarta", null); - tmpFaceFile.deleteOnExit(); - final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); - try { - final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); - try { - final byte[] buf = new byte[65536]; - for (;;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - - outputStream.write(buf, 0, len); - } - } - finally { - outputStream.close(); - } - } - finally { - inputStream.close(); - } - } catch (final IOException ex) { - return faceFile; - } - return tmpFaceFile; - } - /** {@inheritDoc} */ @Override protected String getPngFile() { Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:36:40 UTC (rev 5499) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) @@ -21,6 +21,7 @@ import java.awt.image.ImageFilter; import java.awt.image.RGBImageFilter; +import java.io.BufferedInputStream; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStream; @@ -34,6 +35,7 @@ import java.util.regex.Pattern; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; @@ -209,4 +211,48 @@ @NotNull protected abstract Pattern getTreeFilePattern(); + /** + * Returns a file that is a regular file on the file system. Returns the + * passed file if it is a regular file. Otherwise copies the passed file + * into a temporary regular file and returns the copy. + * @param faceFile the input file + * @return the output file which is a regular file on the file system + * @todo remove this method when CrossfireEditor does not anymore embed crossfire.0 + */ + protected static File makeTmpFaceFile(final File faceFile) { + if (faceFile.exists()) { + return faceFile; + } + + final File tmpFaceFile; + try { + tmpFaceFile = File.createTempFile("gridarta", null); + tmpFaceFile.deleteOnExit(); + final BufferedInputStream inputStream = IOUtils.createStream(null, faceFile.getPath()); + try { + final FileOutputStream outputStream = new FileOutputStream(tmpFaceFile); + try { + final byte[] buf = new byte[65536]; + for (;;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + + outputStream.write(buf, 0, len); + } + } + finally { + outputStream.close(); + } + } + finally { + inputStream.close(); + } + } catch (final IOException ex) { + return faceFile; + } + return tmpFaceFile; + } + } // class AbstractFaceObjects This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 16:47:40
|
Revision: 5501 http://gridarta.svn.sourceforge.net/gridarta/?rev=5501&view=rev Author: akirschbaum Date: 2008-10-12 16:47:31 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Move FaceObjects.collectTreeFile() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) @@ -26,22 +26,17 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.CollectedFaceProvider; import net.sf.gridarta.gameobject.face.DuplicateFaceException; -import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.utils.ArrayUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -167,32 +162,6 @@ /** {@inheritDoc} */ @Override - protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { - final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - assert path.startsWith(baseDir.getAbsolutePath()); - assert path.endsWith(".png"); - final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); - writeTreeFileLine(treeFile, i, name); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - treeFile.close(); - } - } - - /** {@inheritDoc} */ - @Override protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); } Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) @@ -26,22 +26,17 @@ import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.gridarta.gameobject.face.ArchFaceProvider; import net.sf.gridarta.gameobject.face.CollectedFaceProvider; import net.sf.gridarta.gameobject.face.DuplicateFaceException; -import net.sf.gridarta.gameobject.face.FaceObject; import net.sf.gridarta.gameobject.face.FaceObjectProviders; import net.sf.gridarta.utils.ArrayUtils; import net.sf.japi.swing.ActionFactory; -import net.sf.japi.swing.misc.Progress; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -167,32 +162,6 @@ /** {@inheritDoc} */ @Override - protected void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { - final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); - try { - final int numOfFaceObjects = size(); - progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); - int i = 0; - for (final FaceObject faceObject : this) { - final String face = faceObject.getFaceName(); - final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); - assert path.startsWith(baseDir.getAbsolutePath()); - assert path.endsWith(".png"); - final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); - writeTreeFileLine(treeFile, i, name); - if (i++ % 100 == 0) { - progress.setValue(i); - } - } - progress.setValue(numOfFaceObjects); - } finally { - treeFile.close(); - } - } - - /** {@inheritDoc} */ - @Override protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { treeFile.append(faceName).append('\n'); } Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:45:10 UTC (rev 5500) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) @@ -29,6 +29,7 @@ import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; import java.nio.channels.FileChannel; @@ -144,7 +145,29 @@ * collected * @throws IOException in case of I/O problems during collection */ - protected abstract void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException; + private void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { + final int stripPath = baseDir.getAbsolutePath().length(); + final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); + try { + final int numOfFaceObjects = size(); + progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); + int i = 0; + for (final FaceObject faceObject : this) { + final String face = faceObject.getFaceName(); + final String path = ((ArchFaceProvider) FaceObjectProviders.normal).getFilename(face); + assert path.startsWith(baseDir.getAbsolutePath()); + assert path.endsWith(".png"); + final String name = path.substring(stripPath, path.length() - 4).replace('\\', '/'); + writeTreeFileLine(treeFile, i, name); + if (i++ % 100 == 0) { + progress.setValue(i); + } + } + progress.setValue(numOfFaceObjects); + } finally { + treeFile.close(); + } + } /** * Creates the bmaps file. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 17:02:00
|
Revision: 5502 http://gridarta.svn.sourceforge.net/gridarta/?rev=5502&view=rev Author: akirschbaum Date: 2008-10-12 17:01:47 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Move FaceObjects.loadFacesCollection() to common code base. Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/crossfire/src/cfeditor/messages.properties trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/messages.properties trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java trunk/src/app/net/sf/gridarta/messages.properties Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) @@ -20,24 +20,10 @@ package cfeditor.gameobject.face; import cfeditor.IGUIConstants; -import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.gridarta.gameobject.face.CollectedFaceProvider; -import net.sf.gridarta.gameobject.face.DuplicateFaceException; -import net.sf.gridarta.gameobject.face.FaceObjectProviders; -import net.sf.gridarta.utils.ArrayUtils; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -46,109 +32,7 @@ */ public final class FaceObjects extends AbstractFaceObjects { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(FaceObjects.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("cfeditor"); - /** {@inheritDoc} */ - public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - final File tmpFaceFile = makeTmpFaceFile(faceFile); - FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); - final String actualFilename = tmpFaceFile.toString(); - final InputStream inputStream = new FileInputStream(tmpFaceFile); - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); - try { - final byte[] buf = new byte[4096]; - for (; ;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - bufOut.write(buf, 0, len); - } - } finally { - inputStream.close(); - } - final byte[] data = bufOut.toByteArray(); - - // Note: treeIn might stay null, this is optional data. - BufferedReader treeIn = null; - try { - //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. - //noinspection IOResourceOpenedButNotSafelyClosed - treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); - } catch (final FileNotFoundException e) { - log.warn(ACTION_FACTORY.getString("logCantLoadFaceTree")); - } - final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png - final StringBuilder faceB = new StringBuilder(); // face name of png - try { - final Pattern pattern = getTreeFilePattern(); - int offset = 0; - while (offset < data.length) { - // File: Structure* - // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary - if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + getPngFile() + " at position " + offset); - } - offset += 6; // skip "IMAGE "; - while (data[offset++] != (byte) 0x20) { - ; // skip seqnr ' ' - } - int size = 0; - char c; - while ((c = (char) data[offset++]) != ' ') { // read size ' ' - if (c < '0' || c > '9') { - log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); - throw new IOException("syntax error at position " + offset + ": not a digit"); - } - size *= 10; - size += c - '0'; - } - faceB.setLength(0); - while ((c = (char) data[offset++]) != '\n') { // read facename '\n' - if (c == '/') { - faceB.setLength(0); - } else { - faceB.append(c); - } - } - final String faceName = faceB.toString().intern(); - - if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); - } - - if (treeIn != null) { - final String originalFilename = treeIn.readLine(); - if (originalFilename == null) { - log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); - } else { - final Matcher matcher = pattern.matcher(originalFilename); - if (!matcher.matches()) { - log.warn("Syntax error in " + treeFile + ": " + originalFilename); - } else { - addFaceObject(faceName, matcher.group(1), actualFilename, offset, size); - } - } - } - ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me - offset += size; - } - } finally { - try { - if (treeIn != null) { - treeIn.close(); - } - } catch (final IOException e) { - /* ignore */ - } - } - } - - /** {@inheritDoc} */ @Override protected String getPngFile() { return IGUIConstants.PNG_FILE; Modified: trunk/crossfire/src/cfeditor/messages.properties =================================================================== --- trunk/crossfire/src/cfeditor/messages.properties 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/crossfire/src/cfeditor/messages.properties 2008-10-12 17:01:47 UTC (rev 5502) @@ -194,11 +194,9 @@ ####################### # Various Log Messages -logFaceObjectWithoutOriginalName=No originalName for {0}! logDuplicateAnimation=Duplicate Animation: {0} logInventoryInDefArch=Found inventory Object in def arch: {0} logFoundCoordInDefArchSingleTileOrHead=Found {0} cmd in single tile or head (add it to arch text): {1} logDefArchWithZeroType=Archetype type number is zero: {0}. logDefArchWithInvalidTypeNr=Arch {0} has an invalid type nr: {1} logDefArchWithInvalidDirection=Arch {0} has an invalid direction: {1} -logCantLoadFaceTree=Can''t load face tree. You won''t be able to easily choose faces from a tree. To change this, you need either a version of <code>arch/</code> that contains <code>bmaps.paths</code>, or you have to collect arches yourself. Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) @@ -20,24 +20,10 @@ package daieditor.gameobject.face; import daieditor.IGUIConstants; -import java.io.BufferedReader; import java.io.BufferedWriter; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.gameobject.face.AbstractFaceObjects; -import net.sf.gridarta.gameobject.face.CollectedFaceProvider; -import net.sf.gridarta.gameobject.face.DuplicateFaceException; -import net.sf.gridarta.gameobject.face.FaceObjectProviders; -import net.sf.gridarta.utils.ArrayUtils; -import net.sf.japi.swing.ActionFactory; -import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -46,109 +32,7 @@ */ public final class FaceObjects extends AbstractFaceObjects { - /** The Logger for printing log messages. */ - private static final Logger log = Logger.getLogger(FaceObjects.class); - - /** Action Factory. */ - private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("daieditor"); - /** {@inheritDoc} */ - public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { - final File tmpFaceFile = makeTmpFaceFile(faceFile); - FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); - final String actualFilename = tmpFaceFile.toString(); - final InputStream inputStream = new FileInputStream(tmpFaceFile); - final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); - try { - final byte[] buf = new byte[4096]; - for (; ;) { - final int len = inputStream.read(buf); - if (len == -1) { - break; - } - bufOut.write(buf, 0, len); - } - } finally { - inputStream.close(); - } - final byte[] data = bufOut.toByteArray(); - - // Note: treeIn might stay null, this is optional data. - BufferedReader treeIn = null; - try { - //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. - //noinspection IOResourceOpenedButNotSafelyClosed - treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); - } catch (final FileNotFoundException e) { - log.warn(ACTION_FACTORY.getString("logCantLoadFaceTree")); - } - final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png - final StringBuilder faceB = new StringBuilder(); // face name of png - try { - final Pattern pattern = getTreeFilePattern(); - int offset = 0; - while (offset < data.length) { - // File: Structure* - // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary - if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + getPngFile() + " at position " + offset); - } - offset += 6; // skip "IMAGE "; - while (data[offset++] != (byte) 0x20) { - ; // skip seqnr ' ' - } - int size = 0; - char c; - while ((c = (char) data[offset++]) != ' ') { // read size ' ' - if (c < '0' || c > '9') { - log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); - throw new IOException("syntax error at position " + offset + ": not a digit"); - } - size *= 10; - size += c - '0'; - } - faceB.setLength(0); - while ((c = (char) data[offset++]) != '\n') { // read facename '\n' - if (c == '/') { - faceB.setLength(0); - } else { - faceB.append(c); - } - } - final String faceName = faceB.toString().intern(); - - if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); - } - - if (treeIn != null) { - final String originalFilename = treeIn.readLine(); - if (originalFilename == null) { - log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); - } else { - final Matcher matcher = pattern.matcher(originalFilename); - if (!matcher.matches()) { - log.warn("Syntax error in " + treeFile + ": " + originalFilename); - } else { - addFaceObject(faceName, matcher.group(1), actualFilename, offset, size); - } - } - } - ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me - offset += size; - } - } finally { - try { - if (treeIn != null) { - treeIn.close(); - } - } catch (final IOException e) { - /* ignore */ - } - } - } - - /** {@inheritDoc} */ @Override protected String getPngFile() { return IGUIConstants.PNG_FILE; Modified: trunk/daimonin/src/daieditor/messages.properties =================================================================== --- trunk/daimonin/src/daieditor/messages.properties 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/daimonin/src/daieditor/messages.properties 2008-10-12 17:01:47 UTC (rev 5502) @@ -224,7 +224,6 @@ ####################### # Various Log Messages -logFaceObjectWithoutOriginalName=No originalName for {0}! logDuplicateAnimation=Duplicate Animation: {0} logInventoryInDefArch=Found inventory Object in def arch: {0} logFoundCoordInDefArchSingleTileOrHead=Found {0} cmd in single tile or head (add it to arch text): {1} @@ -232,7 +231,6 @@ logDefArchWithInvalidTypeNr=Arch {0} has an invalid type nr: {1} logDefArchWithInvalidDirection=Arch {0} has an invalid direction: {1} logDefArchWithInvalidMpartNr=Arch part {0} has mpart_nr {2}, but head part {1} has mpart_nr {3} -logCantLoadFaceTree.message=Can''t load face tree. You won''t be able to easily choose faces from a tree. To change this, you need either a version of <code>arch/</code> that contains <code>arch/dev/editor/conf/facetree</code>, or you have to collect arches yourself. ################ Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) @@ -22,23 +22,30 @@ import java.awt.image.ImageFilter; import java.awt.image.RGBImageFilter; import java.io.BufferedInputStream; +import java.io.BufferedReader; import java.io.BufferedWriter; +import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintStream; import java.io.PrintWriter; import java.nio.channels.FileChannel; +import java.util.regex.Matcher; import java.util.regex.Pattern; import net.sf.gridarta.CommonConstants; import net.sf.gridarta.data.AbstractNamedObjects; +import net.sf.gridarta.utils.ArrayUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.japi.swing.ActionFactory; import net.sf.japi.swing.misc.Progress; +import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; /** @@ -47,6 +54,9 @@ */ public abstract class AbstractFaceObjects extends AbstractNamedObjects<FaceObject> implements FaceObjects { + /** The Logger for printing log messages. */ + private static final Logger log = Logger.getLogger(AbstractFaceObjects.class); + /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.gridarta"); @@ -278,4 +288,100 @@ return tmpFaceFile; } + /** {@inheritDoc} */ + public void loadFacesCollection(final File faceFile, final File treeFile) throws IOException, FileNotFoundException, DuplicateFaceException { + final File tmpFaceFile = makeTmpFaceFile(faceFile); + FaceObjectProviders.setNormal(new CollectedFaceProvider(tmpFaceFile)); + final String actualFilename = tmpFaceFile.toString(); + final InputStream inputStream = new FileInputStream(tmpFaceFile); + final ByteArrayOutputStream bufOut = new ByteArrayOutputStream((int) tmpFaceFile.length()); + try { + final byte[] buf = new byte[4096]; + for (; ;) { + final int len = inputStream.read(buf); + if (len == -1) { + break; + } + bufOut.write(buf, 0, len); + } + } finally { + inputStream.close(); + } + final byte[] data = bufOut.toByteArray(); + + // Note: treeIn might stay null, this is optional data. + BufferedReader treeIn = null; + try { + //cher: it is safely closed but optional. InspectionGadgets doesn't detect where it's closed. + //noinspection IOResourceOpenedButNotSafelyClosed + treeIn = new BufferedReader(new InputStreamReader(new FileInputStream(treeFile), "us-ascii")); + } catch (final FileNotFoundException e) { + log.warn(ACTION_FACTORY.format("logCantLoadFaceTree", treeFile)); + } + final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png + final StringBuilder faceB = new StringBuilder(); // face name of png + try { + final Pattern pattern = getTreeFilePattern(); + int offset = 0; + while (offset < data.length) { + // File: Structure* + // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary + if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE + throw new IOException("Error in file " + getPngFile() + " at position " + offset); + } + offset += 6; // skip "IMAGE "; + while (data[offset++] != (byte) 0x20) { + ; // skip seqnr ' ' + } + int size = 0; + char c; + while ((c = (char) data[offset++]) != ' ') { // read size ' ' + if (c < '0' || c > '9') { + log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); + throw new IOException("syntax error at position " + offset + ": not a digit"); + } + size *= 10; + size += c - '0'; + } + faceB.setLength(0); + while ((c = (char) data[offset++]) != '\n') { // read facename '\n' + if (c == '/') { + faceB.setLength(0); + } else { + faceB.append(c); + } + } + final String faceName = faceB.toString().intern(); + + if (offset + size > data.length) { + throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); + } + + if (treeIn != null) { + final String originalFilename = treeIn.readLine(); + if (originalFilename == null) { + log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); + } else { + final Matcher matcher = pattern.matcher(originalFilename); + if (!matcher.matches()) { + log.warn("Syntax error in " + treeFile + ": " + originalFilename); + } else { + addFaceObject(faceName, matcher.group(1), actualFilename, offset, size); + } + } + } + ((CollectedFaceProvider) FaceObjectProviders.normal).addInfo(faceName, offset, size); // TODO Remove me + offset += size; + } + } finally { + try { + if (treeIn != null) { + treeIn.close(); + } + } catch (final IOException e) { + /* ignore */ + } + } + } + } // class AbstractFaceObjects Modified: trunk/src/app/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/app/net/sf/gridarta/messages.properties 2008-10-12 16:47:31 UTC (rev 5501) +++ trunk/src/app/net/sf/gridarta/messages.properties 2008-10-12 17:01:47 UTC (rev 5502) @@ -512,8 +512,10 @@ logUnexpectedException=Unexpected exception: {0} logArchfileNotFound=Archfile {0} could not be found logCanonIOE=IOException while canonizing path: {0} +logCantLoadFaceTree=Can''t load face tree. You won''t be able to easily choose faces from a tree. To change this, you need either a version of <code>arch/</code> that contains <code>{0}</code>, or you have to collect arches yourself. logExitWithExit=Exiting with System.exit(). logExitWithoutExit=Trying to exit without System.exit(). +logFaceObjectWithoutOriginalName=No originalName for {0}! # Edit undo.text=Undo This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 17:06:20
|
Revision: 5503 http://gridarta.svn.sourceforge.net/gridarta/?rev=5503&view=rev Author: akirschbaum Date: 2008-10-12 17:06:10 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove FaceObjects.getPngFile(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) @@ -32,10 +32,11 @@ */ public final class FaceObjects extends AbstractFaceObjects { - /** {@inheritDoc} */ - @Override - protected String getPngFile() { - return IGUIConstants.PNG_FILE; + /** + * Creates a new instance. + */ + public FaceObjects() { + super(IGUIConstants.PNG_FILE); } /** {@inheritDoc} */ Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) @@ -32,10 +32,11 @@ */ public final class FaceObjects extends AbstractFaceObjects { - /** {@inheritDoc} */ - @Override - protected String getPngFile() { - return IGUIConstants.PNG_FILE; + /** + * Creates a new instance. + */ + public FaceObjects() { + super(IGUIConstants.PNG_FILE); } /** {@inheritDoc} */ Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:01:47 UTC (rev 5502) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) @@ -75,9 +75,19 @@ }; // ALPHA_FILTER - /** Create an FaceObjects instance. */ - protected AbstractFaceObjects() { + /** + * The filename of the collected image file. + */ + @NotNull + private final String pngFile; + + /** + * Creates a new instance. + * @param pngFile the filename of the collected image file. + */ + protected AbstractFaceObjects(@NotNull final String pngFile) { super(ACTION_FACTORY.getString("nameOfFaceObject")); + this.pngFile = pngFile; } /** @@ -103,7 +113,7 @@ * @throws IOException in case of I/O problems during collection */ private void collectImageFile(@NotNull final Progress progress, @NotNull final File dir) throws IOException { - final File dfile = new File(dir, getPngFile()); + final File dfile = new File(dir, pngFile); final FileOutputStream fout = new FileOutputStream(dfile); //It's safely closed because the stream is closed and that closes the channel. //noinspection ChannelOpenedButNotSafelyClosed @@ -215,12 +225,6 @@ } /** - * Returns the base name of the collected image file. - * @return the base name - */ - protected abstract String getPngFile(); - - /** * Returns the filename of the face tree file.. * @return the filename */ @@ -327,7 +331,7 @@ // File: Structure* // Structure: "IMAGE " seqnr ' ' size ' ' facename '\n' PNGBinary if (!ArrayUtils.contains(data, offset, tag)) { // check for IMAGE - throw new IOException("Error in file " + getPngFile() + " at position " + offset); + throw new IOException("Error in file " + pngFile + " at position " + offset); } offset += 6; // skip "IMAGE "; while (data[offset++] != (byte) 0x20) { @@ -337,7 +341,7 @@ char c; while ((c = (char) data[offset++]) != ' ') { // read size ' ' if (c < '0' || c > '9') { - log.warn("Syntax error in file " + getPngFile() + " at position " + offset + "."); + log.warn("Syntax error in file " + pngFile + " at position " + offset + "."); throw new IOException("syntax error at position " + offset + ": not a digit"); } size *= 10; @@ -354,7 +358,7 @@ final String faceName = faceB.toString().intern(); if (offset + size > data.length) { - throw new IOException("Truncated face data in file " + getPngFile() + " at position " + offset); + throw new IOException("Truncated face data in file " + pngFile + " at position " + offset); } if (treeIn != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 17:09:16
|
Revision: 5504 http://gridarta.svn.sourceforge.net/gridarta/?rev=5504&view=rev Author: akirschbaum Date: 2008-10-12 17:09:05 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove FaceObjects.getFaceTreeFile(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:09:05 UTC (rev 5504) @@ -36,17 +36,11 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } /** {@inheritDoc} */ @Override - protected String getFaceTreeFile() { - return IGUIConstants.FACETREE_FILE; - } - - /** {@inheritDoc} */ - @Override protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); } Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:09:05 UTC (rev 5504) @@ -36,17 +36,11 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); } /** {@inheritDoc} */ @Override - protected String getFaceTreeFile() { - return IGUIConstants.FACETREE_FILE; - } - - /** {@inheritDoc} */ - @Override protected void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException { treeFile.append(faceName).append('\n'); } Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:06:10 UTC (rev 5503) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:09:05 UTC (rev 5504) @@ -82,12 +82,20 @@ private final String pngFile; /** + * The filename of the face tree file. + */ + @NotNull + private final String faceTreeFile; + + /** * Creates a new instance. - * @param pngFile the filename of the collected image file. + * @param pngFile the filename of the collected image file + * @param faceTreeFile the filename of the face tree file */ - protected AbstractFaceObjects(@NotNull final String pngFile) { + protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile) { super(ACTION_FACTORY.getString("nameOfFaceObject")); this.pngFile = pngFile; + this.faceTreeFile = faceTreeFile; } /** @@ -167,7 +175,7 @@ */ private void collectTreeFile(@NotNull final Progress progress, @NotNull final File dir, @NotNull final File baseDir) throws IOException { final int stripPath = baseDir.getAbsolutePath().length(); - final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, getFaceTreeFile())), "us-ascii")); + final BufferedWriter treeFile = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(new File(dir, faceTreeFile)), "us-ascii")); try { final int numOfFaceObjects = size(); progress.setLabel(ACTION_FACTORY.getString("archCollectTree"), numOfFaceObjects); @@ -225,12 +233,6 @@ } /** - * Returns the filename of the face tree file.. - * @return the filename - */ - protected abstract String getFaceTreeFile(); - - /** * Writes one line to the face tree file. * @param treeFile the face tree file to write * @param faceNo the face number This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2008-10-12 17:19:25
|
Revision: 5506 http://gridarta.svn.sourceforge.net/gridarta/?rev=5506&view=rev Author: akirschbaum Date: 2008-10-12 17:19:18 +0000 (Sun, 12 Oct 2008) Log Message: ----------- Remove FaceObjects.getTreeFilePattern(). Modified Paths: -------------- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java Modified: trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:10:34 UTC (rev 5505) +++ trunk/crossfire/src/cfeditor/gameobject/face/FaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) @@ -36,7 +36,7 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)")); } /** {@inheritDoc} */ @@ -45,11 +45,4 @@ treeFile.append(String.format("\\%05d\t.%s\n", faceNo, faceName)); } - /** {@inheritDoc} */ - @NotNull - @Override - protected Pattern getTreeFilePattern() { - return Pattern.compile("^(?:\\\\[0-9]+\t\\.?)?(.*)"); - } - } // class FaceObjects Modified: trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java =================================================================== --- trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:10:34 UTC (rev 5505) +++ trunk/daimonin/src/daieditor/gameobject/face/FaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) @@ -36,7 +36,7 @@ * Creates a new instance. */ public FaceObjects() { - super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE); + super(IGUIConstants.PNG_FILE, IGUIConstants.FACETREE_FILE, Pattern.compile("^(.*)")); } /** {@inheritDoc} */ @@ -45,11 +45,4 @@ treeFile.append(faceName).append('\n'); } - /** {@inheritDoc} */ - @NotNull - @Override - protected Pattern getTreeFilePattern() { - return Pattern.compile("^(.*)"); - } - } // class FaceObjects Modified: trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java =================================================================== --- trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:10:34 UTC (rev 5505) +++ trunk/src/app/net/sf/gridarta/gameobject/face/AbstractFaceObjects.java 2008-10-12 17:19:18 UTC (rev 5506) @@ -88,14 +88,23 @@ private final String faceTreeFile; /** + * The {@link Pattern} for parsing face tree files. The pattern must return + * the face name in the first capturing group. + */ + @NotNull + private final Pattern faceTreeInputPattern; + + /** * Creates a new instance. * @param pngFile the filename of the collected image file * @param faceTreeFile the filename of the face tree file + * @param faceTreeInputPattern the pattern for parsing face tree files */ - protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile) { + protected AbstractFaceObjects(@NotNull final String pngFile, @NotNull final String faceTreeFile, @NotNull final Pattern faceTreeInputPattern) { super(ACTION_FACTORY.getString("nameOfFaceObject")); this.pngFile = pngFile; this.faceTreeFile = faceTreeFile; + this.faceTreeInputPattern = faceTreeInputPattern; } /** @@ -242,15 +251,6 @@ protected abstract void writeTreeFileLine(@NotNull final BufferedWriter treeFile, final int faceNo, @NotNull final String faceName) throws IOException; /** - * Returns a {@link Pattern} to extract the face name from a face tree file - * line. The pattern must return the face name in the first capturing - * group. - * @return the pattern - */ - @NotNull - protected abstract Pattern getTreeFilePattern(); - - /** * Returns a file that is a regular file on the file system. Returns the * passed file if it is a regular file. Otherwise copies the passed file * into a temporary regular file and returns the copy. @@ -327,7 +327,6 @@ final byte[] tag = "IMAGE ".getBytes(); // this is the starting string for a new png final StringBuilder faceB = new StringBuilder(); // face name of png try { - final Pattern pattern = getTreeFilePattern(); int offset = 0; while (offset < data.length) { // File: Structure* @@ -368,7 +367,7 @@ if (originalFilename == null) { log.warn(ACTION_FACTORY.format("logFaceObjectWithoutOriginalName", faceName)); } else { - final Matcher matcher = pattern.matcher(originalFilename); + final Matcher matcher = faceTreeInputPattern.matcher(originalFilename); if (!matcher.matches()) { log.warn("Syntax error in " + treeFile + ": " + originalFilename); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |