From: <aki...@us...> - 2008-08-20 19:11:11
|
Revision: 4915 http://gridarta.svn.sourceforge.net/gridarta/?rev=4915&view=rev Author: akirschbaum Date: 2008-08-20 19:11:09 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Extract RendererFactory from GridartaObjectsFactory. Modified Paths: -------------- trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java trunk/src/app/net/sf/gridarta/AbstractMainControl.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java Added Paths: ----------- trunk/crossfire/src/cfeditor/gui/map/DefaultRendererFactory.java trunk/daimonin/src/daieditor/gui/map/DefaultRendererFactory.java trunk/src/app/net/sf/gridarta/gui/map/RendererFactory.java Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -29,6 +29,7 @@ import cfeditor.gameobject.scripts.ScriptArchUtils; import cfeditor.gui.GameObjectAttributesControl; import cfeditor.gui.map.CMapViewBasic; +import cfeditor.gui.map.DefaultRendererFactory; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; import cfeditor.map.MapArchObject; @@ -210,7 +211,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new CrossfireObjectsFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); + super(new CrossfireObjectsFactory(), new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); @@ -325,7 +326,7 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); final ArchetypeParser archetypeParser = new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); + gridartaObjectsFactory.init(rendererFactory, faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -23,7 +23,6 @@ import cfeditor.gameobject.GameObject; import cfeditor.gameobject.UndefinedArchetype; import cfeditor.gui.map.CMapViewBasic; -import cfeditor.gui.map.SimpleLevelRenderer; import cfeditor.io.GameObjectParser; import cfeditor.io.MapArchObjectParser; import cfeditor.map.DefaultMapControlFactory; @@ -47,15 +46,14 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.RendererFactory; 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.MapReader; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlFactory; -import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -159,18 +157,12 @@ /** {@inheritDoc} */ @NotNull - public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleLevelRenderer(mapModel); - } - - /** {@inheritDoc} */ - @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainView, mapControl, viewCounter, new CMapViewBasic(filterControl, editTypes, mapControl, viewPosition, toolPalette, 32, 32, selectedSquareView), ACTION_FACTORY, mapImageCache); } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; @@ -178,7 +170,7 @@ this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - mapControlFactory = new DefaultMapControlFactory(mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); + mapControlFactory = new DefaultMapControlFactory(rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } public void setFilterControl(@NotNull final CFilterControl filterControl) { Added: trunk/crossfire/src/cfeditor/gui/map/DefaultRendererFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/gui/map/DefaultRendererFactory.java (rev 0) +++ trunk/crossfire/src/cfeditor/gui/map/DefaultRendererFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -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 cfeditor.gui.map; + +import cfeditor.gameobject.Archetype; +import cfeditor.gameobject.GameObject; +import cfeditor.map.MapArchObject; +import net.sf.gridarta.gui.map.LevelRenderer; +import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; + +/** + * Factory for creating {@link LevelRenderer} instances. + * @author Andreas Kirschbaum + */ +public class DefaultRendererFactory implements RendererFactory<GameObject, MapArchObject, Archetype> { + + /** {@inheritDoc} */ + @NotNull + public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { + return new SimpleLevelRenderer(mapModel); + } + +} // class DefaultRendererFactory Property changes on: trunk/crossfire/src/cfeditor/gui/map/DefaultRendererFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -31,6 +31,7 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; @@ -45,6 +46,12 @@ public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** + * The {@link RendererFactory} instance to use. + */ + @NotNull + private final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; + + /** * The {@link MapActions} instance to use. */ @NotNull @@ -76,13 +83,15 @@ /** * Creates a new instance. + * @param rendererFactory the renderer factory to use * @param mapActions the map actions to use * @param archetypeChooserModel the archetype chooser model to use * @param mapImageCache the map image cache to use * @param autojoinLists the autojoin lists to use * @param exitTypeGameObjectMatcher the matcher for exit objects */ - public DefaultMapControlFactory(@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 DefaultMapControlFactory(@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.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; this.mapImageCache = mapImageCache; @@ -93,7 +102,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -102,7 +111,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -28,6 +28,7 @@ import daieditor.gameobject.scripts.ScriptArchUtils; import daieditor.gui.GameObjectAttributesControl; import daieditor.gui.map.CMapViewBasic; +import daieditor.gui.map.DefaultRendererFactory; import daieditor.gui.prefs.AppPrefs; import daieditor.gui.prefs.DevPrefs; import daieditor.gui.prefs.GUIPrefs; @@ -264,7 +265,7 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DaimoninObjectsFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); + super(new DaimoninObjectsFactory(), new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); final boolean mapTileListBottom = prefs.getBoolean(MainView.MAP_TILE_LIST_BOTTOM_KEY, MainView.MAP_TILE_LIST_BOTTOM_DEFAULT); final MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic> mapManagerActions = new MapManagerActions<GameObject, MapArchObject, Archetype, CMapViewBasic>(mapManager); final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeSet); @@ -377,7 +378,7 @@ mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, pickmapChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); final ArchetypeParser archetypeParser = new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); + gridartaObjectsFactory.init(rendererFactory, faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); archetypeSet.loadArchetypes(archetypeParser); if (globalSettings.isAutoPopupDocu()) { Modified: trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java =================================================================== --- trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -23,7 +23,6 @@ import daieditor.gameobject.GameObject; import daieditor.gameobject.UndefinedArchetype; import daieditor.gui.map.CMapViewBasic; -import daieditor.gui.map.SimpleLevelRenderer; import daieditor.io.GameObjectParser; import daieditor.io.MapArchObjectParser; import daieditor.map.DefaultMapControlFactory; @@ -47,15 +46,14 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; +import net.sf.gridarta.gui.map.RendererFactory; 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.MapReader; import net.sf.gridarta.map.MapControl; import net.sf.gridarta.map.MapControlFactory; -import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -163,18 +161,12 @@ /** {@inheritDoc} */ @NotNull - public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleLevelRenderer(mapModel); - } - - /** {@inheritDoc} */ - @NotNull public MapView<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapView(@NotNull final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { return new MapView<GameObject, MapArchObject, Archetype, CMapViewBasic>(mainView, mapControl, viewCounter, new CMapViewBasic((CMainControl) mainControl, editTypes, mapControl, viewPosition, faceObjects, toolPalette, IGUIConstants.TILE_ISO_XLEN, IGUIConstants.TILE_ISO_YLEN, selectedSquareView), ACTION_FACTORY, mapImageCache); } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<GameObject, MapArchObject, Archetype> archetypeParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette, @NotNull final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { this.faceObjects = faceObjects; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; @@ -184,7 +176,7 @@ this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - mapControlFactory = new DefaultMapControlFactory(mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); + mapControlFactory = new DefaultMapControlFactory(rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } } // class DaimoninObjectsFactory Added: trunk/daimonin/src/daieditor/gui/map/DefaultRendererFactory.java =================================================================== --- trunk/daimonin/src/daieditor/gui/map/DefaultRendererFactory.java (rev 0) +++ trunk/daimonin/src/daieditor/gui/map/DefaultRendererFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -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 daieditor.gui.map; + +import daieditor.gameobject.Archetype; +import daieditor.gameobject.GameObject; +import daieditor.map.MapArchObject; +import net.sf.gridarta.gui.map.LevelRenderer; +import net.sf.gridarta.gui.map.RendererFactory; +import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; + +/** + * Factory for creating {@link LevelRenderer} instances. + * @author Andreas Kirschbaum + */ +public class DefaultRendererFactory implements RendererFactory<GameObject, MapArchObject, Archetype> { + + /** {@inheritDoc} */ + @NotNull + public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { + return new SimpleLevelRenderer(mapModel); + } + +} // class DefaultRendererFactory Property changes on: trunk/daimonin/src/daieditor/gui/map/DefaultRendererFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -31,6 +31,7 @@ import net.sf.gridarta.MapImageCache; import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.map.AbstractMapControlFactory; import net.sf.gridarta.map.DefaultMapControl; import net.sf.gridarta.map.MapControl; @@ -45,6 +46,12 @@ public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** + * The {@link RendererFactory} instance to use. + */ + @NotNull + private final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; + + /** * The {@link MapActions} instance to use. */ @NotNull @@ -76,13 +83,15 @@ /** * Creates a new instance. + * @param rendererFactory the renderer factory to use * @param mapActions the map actions to use * @param archetypeChooserModel the archetype chooser model to use * @param mapImageCache the map image cache to use * @param autojoinLists the autojoin lists to use * @param exitTypeGameObjectMatcher the matcher for exit objects */ - public DefaultMapControlFactory(@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 DefaultMapControlFactory(@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.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; this.mapImageCache = mapImageCache; @@ -93,7 +102,7 @@ /** {@inheritDoc} */ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final String mapName, @Nullable final File file) { - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); return mapControl; @@ -103,7 +112,7 @@ @NotNull public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @NotNull final Component parent, @Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final File file) { mapArchObject.setDifficulty(1); - final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + final MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControl = new DefaultMapControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(gridartaObjectsFactory, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); mapControl.resetModified(); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -41,6 +41,7 @@ import net.sf.gridarta.gui.map.MapPreviewAccessory; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.help.Help; import net.sf.gridarta.io.PathManager; @@ -78,9 +79,12 @@ /** Swing FileFilter for png graphics. */ public static final FileFilter pngFileFilter = new HideFileFilterProxy(new EndingFileFilter(true, ACTION_FACTORY.getString("fileDialog.filter.png"), ".png")); - /** The Gridarta Objects Factory. */ + /** The gridarta objects factory. */ protected final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** The renderer factory. */ + protected final RendererFactory<G, A, R> rendererFactory; + /** The edit types instance. */ protected final EditTypes<G, A, R, V> editTypes; @@ -136,12 +140,13 @@ /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory + * @param rendererFactory the renderer factory * @param key The action factory key * @param globalSettings the global settings instance * @param animationObjects the animation objects instance * @param faceObjects the face objects instance */ - protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { + protected AbstractMainControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<? extends AnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { this.globalSettings = globalSettings; final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, globalSettings); editTypes = new EditTypes<G, A, R, V>(tmpMapManager); @@ -151,6 +156,7 @@ this.faceObjects = faceObjects; copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, gridartaObjectsFactory); this.gridartaObjectsFactory = gridartaObjectsFactory; + this.rendererFactory = rendererFactory; globalSettings.readGlobalSettings(); ScriptedEventEditor.setGlobalSettings(globalSettings); archetypeSet = newArchetypeSet(globalSettings, editTypes, animationObjects, faceObjects, gridartaObjectsFactory); @@ -295,7 +301,7 @@ JOptionPane.showMessageDialog(getMainView(), "No map loaded! Please load a map!!", "Error", JOptionPane.ERROR_MESSAGE); return; } - new MapPreview(gridartaObjectsFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); + new MapPreview(rendererFactory.newSimpleLevelRenderer(currentMap.getMapModel()).getFullImage()); } } // class AbstractMainControl Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -32,9 +32,9 @@ import net.sf.gridarta.gameobject.match.GameObjectMatcher; import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; -import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; import net.sf.gridarta.io.GameObjectParser; @@ -42,7 +42,6 @@ import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; -import net.sf.gridarta.map.MapModel; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -121,14 +120,6 @@ MapControl<G, A, R, V> newPickmapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @NotNull Component parent, @NotNull File file); /** - * Create a new level renderer instance. - * @param mapModel the map model to render - * @return the new level renderer - */ - @NotNull - LevelRenderer newSimpleLevelRenderer(@NotNull MapModel<G, A, R> mapModel); - - /** * Creates a new map view instance for a map control. * @param mapControl the map control * @param viewPosition the initiali view position; may be <code>null</code> @@ -141,6 +132,7 @@ /** * Initializes the instance. + * @param rendererFactory the level renderer instance * @param faceObjects the FaceObjects instance * @param archetypeChooserModel the archetype chooser model instance * @param selectedSquareView the selected square view instance @@ -155,6 +147,6 @@ * @param autojoinLists the autojoin lists instance * @param exitTypeGameObjectMatcher the matcher for exit objects */ - void init(@NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final 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 MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher); + void init(@NotNull RendererFactory<G, A, R> rendererFactory, @NotNull FaceObjects faceObjects, @NotNull ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final 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 MapActions mapActions, @NotNull ArchetypeParser<G, A, R> archetypeParser, @NotNull ArchetypeSet<G, A, R> archetypeSet, @NotNull ToolPalette<G, A, R, V> toolPalette, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher); } // interface GridartaObjectsFactory Added: trunk/src/app/net/sf/gridarta/gui/map/RendererFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/RendererFactory.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/RendererFactory.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -0,0 +1,43 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map; + +import net.sf.gridarta.gameobject.Archetype; +import net.sf.gridarta.gameobject.GameObject; +import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapModel; +import org.jetbrains.annotations.NotNull; + +/** + * Factory for creating {@link LevelRenderer} instances. + * @author Andreas Kirschbaum + */ +public interface RendererFactory<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { + + /** + * Creates a new level renderer instance which paints only tiles but no + * grid, cursor, selection, or errors. + * @param mapModel the map model to render + * @return the new level renderer + */ + @NotNull + LevelRenderer newSimpleLevelRenderer(@NotNull MapModel<G, A, R> mapModel); + +} // interface RendererFactory Property changes on: trunk/src/app/net/sf/gridarta/gui/map/RendererFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/src/app/net/sf/gridarta/map/DefaultMapControl.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -41,6 +41,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.io.DefaultMapWriter; import net.sf.gridarta.io.MapWriter; import net.sf.japi.swing.ActionFactory; @@ -72,6 +73,12 @@ private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; /** + * The {@link RendererFactory} instance. + */ + @NotNull + private final RendererFactory<G, A, R> rendererFactory; + + /** * The parent component for error messages. */ @NotNull @@ -151,6 +158,7 @@ /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory instance + * @param rendererFactory the renderer factory * @param parent the parent component for error messages * @param autojoinLists the autojoin lists instance to use * @param mapImageCache the map image cache instance @@ -161,8 +169,9 @@ * @param archetypeChooserModel the archeype chooser model to use * @param mapActions the map actions to use */ - public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MapActions mapActions) { + public DefaultMapControl(@NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final Component parent, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapImageCache<G, A, R, V> mapImageCache, @Nullable final List<G> objects, @NotNull final A mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<G, A, R, V> archetypeChooserModel, @NotNull final MapActions mapActions) { this.gridartaObjectsFactory = gridartaObjectsFactory; + this.rendererFactory = rendererFactory; this.parent = parent; this.mapImageCache = mapImageCache; this.isPickmap = isPickmap; @@ -392,7 +401,7 @@ final LevelRenderer tmpLevelRenderer = levelRendererReference == null ? null : levelRendererReference.get(); final LevelRenderer levelRenderer; if (tmpLevelRenderer == null) { - levelRenderer = gridartaObjectsFactory.newSimpleLevelRenderer(mapModel); + levelRenderer = rendererFactory.newSimpleLevelRenderer(mapModel); levelRendererReference = new SoftReference<LevelRenderer>(levelRenderer); } else { levelRenderer = tmpLevelRenderer; Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-20 19:04:30 UTC (rev 4914) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-20 19:11:09 UTC (rev 4915) @@ -67,6 +67,7 @@ import net.sf.gridarta.gui.map.LevelRenderer; import net.sf.gridarta.gui.map.MapView; import net.sf.gridarta.gui.map.MapViewBasic; +import net.sf.gridarta.gui.map.RendererFactory; import net.sf.gridarta.gui.map.tools.ToolPalette; import net.sf.gridarta.gui.newmap.NewMapDialogFactory; import net.sf.gridarta.gui.objectchooser.ObjectChooser; @@ -392,10 +393,11 @@ @Before public void setUp() { gridartaObjectsFactory = new TestGridartaObjectsFactory(); + final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory = new TestRendererFactory(); final GlobalSettings globalSettings = new TestGlobalSettings(); final AnimationObjects<TestAnimationObject> animationObjects = new TestAnimationObjects(); final FaceObjects faceObjects = new TestFaceObjects(); - final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, "test", globalSettings, animationObjects, faceObjects); + final TestMainControl mainControl = new TestMainControl(gridartaObjectsFactory, rendererFactory, "test", globalSettings, animationObjects, faceObjects); final TestMapArchObject mapArchObject = new TestMapArchObject(); final TestArchetypeSet archetypeSet = new TestArchetypeSet(gridartaObjectsFactory); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(archetypeSet); @@ -403,7 +405,7 @@ final MapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic>(mainControl, "test", gridartaObjectsFactory, 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 TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions); + final TestMapControl mapControl = new TestMapControl(gridartaObjectsFactory, rendererFactory, autojoinLists, mapImageCache, null, mapArchObject, false, null, archetypeChooserModel, mapActions); mapModel = new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(new JPanel(), autojoinLists, mapControl, null, mapArchObject, null, archetypeChooserModel, mapActions); result.setLength(0); @@ -419,13 +421,14 @@ /** * Creates a new instance. * @param gridartaObjectsFactory the gridaarta objects factory to use + * @param rendererFactory the renderer factory to use * @param key the action factory key to use * @param globalSettings the global settings instance to use * @param animationObjects the animation objects instance to use * @param faceObjects the face objects instance to use */ - protected TestMainControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<TestAnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { - super(gridartaObjectsFactory, key, globalSettings, animationObjects, faceObjects); + protected TestMainControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final String key, @NotNull final GlobalSettings globalSettings, @NotNull final AnimationObjects<TestAnimationObject> animationObjects, @NotNull final FaceObjects faceObjects) { + super(gridartaObjectsFactory, rendererFactory, key, globalSettings, animationObjects, faceObjects); } /** {@inheritDoc} */ @@ -494,6 +497,7 @@ /** * Creates a new instance. * @param gridartaObjectsFactory the gridarta objects factory to use + * @param rendererFactory the renderer factory to use * @param autojoinLists the autojoin lists instance to use * @param mapImageCache the map image cache instance * @param objects the objects to insert @@ -503,8 +507,8 @@ * @param archetypeChooserModel the archetype chooser model to use * @param mapActions the map actions to use */ - public TestMapControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final MapActions mapActions) { - super(gridartaObjectsFactory, new JPanel(), autojoinLists, mapImageCache, objects, mapArchObject, isPickmap, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); + public TestMapControl(@NotNull final GridartaObjectsFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> gridartaObjectsFactory, @NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final MapImageCache<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapImageCache, @Nullable final List<TestGameObject> objects, @NotNull final TestMapArchObject mapArchObject, final boolean isPickmap, @Nullable final GameObjectMatcher exitTypeGameObjectMatcher, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @NotNull final MapActions mapActions) { + super(gridartaObjectsFactory, rendererFactory, new JPanel(), autojoinLists, mapImageCache, objects, mapArchObject, isPickmap, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); } } @@ -887,18 +891,12 @@ /** {@inheritDoc} */ @NotNull - public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel) { - throw new AssertionError(); - } - - /** {@inheritDoc} */ - @NotNull public MapView<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControl, @Nullable final Point viewPosition, final int viewCounter) { throw new AssertionError(); } /** {@inheritDoc} */ - public void init(@NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { + public void init(@NotNull final RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> rendererFactory, @NotNull final FaceObjects faceObjects, @NotNull final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> archetypeChooserModel, @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 MapActions mapActions, @NotNull final ArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype> archetypeParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final ToolPalette<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> toolPalette, @NotNull final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists, @NotNull final GameObjectMatcher exitTypeGameObjectMatcher) { throw new AssertionError(); } } @@ -1096,4 +1094,16 @@ } + /** + * A {@link RendererFactory} implementation for testing purposes. + */ + private static class TestRendererFactory implements RendererFactory<TestGameObject, TestMapArchObject, TestArchetype> { + + /** {@inheritDoc} */ + @NotNull + public LevelRenderer newSimpleLevelRenderer(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel) { + throw new AssertionError(); + } + } + } // class DefaultMapModelTest This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |