From: <aki...@us...> - 2008-08-20 19:50:20
|
Revision: 4916 http://gridarta.svn.sourceforge.net/gridarta/?rev=4916&view=rev Author: akirschbaum Date: 2008-08-20 19:50:17 +0000 (Wed, 20 Aug 2008) Log Message: ----------- Extract MapControlFactory 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/CopyBuffer.java trunk/src/app/net/sf/gridarta/DefaultMapManager.java trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.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-08-20 19:11:09 UTC (rev 4915) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -32,6 +32,7 @@ import cfeditor.gui.map.DefaultRendererFactory; import cfeditor.gui.prefs.GUIPrefs; import cfeditor.gui.prefs.ResPrefs; +import cfeditor.map.DefaultMapControlFactory; import cfeditor.map.MapArchObject; import cfeditor.script.ScriptController; import cfeditor.script.ScriptExecException; @@ -211,12 +212,12 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new CrossfireObjectsFactory(), new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); + super(new CrossfireObjectsFactory(), new DefaultRendererFactory(), "cfeditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory()); 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); final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserModel); - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), mapManager); + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, mapControlFactory, new File(globalSettings.getMapDir(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); @@ -326,7 +327,8 @@ mapActions.updateMenuState(); scriptControl.getView().setMenu((JMenu) ACTION_FACTORY.find(mainView.getJMenuBar(), "plugins")); final ArchetypeParser archetypeParser = new ArchetypeParser(gridartaObjectsFactory, archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(rendererFactory, faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); + gridartaObjectsFactory.init(faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); + ((DefaultMapControlFactory) mapControlFactory).init(gridartaObjectsFactory, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, 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:11:09 UTC (rev 4915) +++ trunk/crossfire/src/cfeditor/CrossfireObjectsFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -25,13 +25,10 @@ import cfeditor.gui.map.CMapViewBasic; import cfeditor.io.GameObjectParser; import cfeditor.io.MapArchObjectParser; -import cfeditor.map.DefaultMapControlFactory; import cfeditor.map.MapArchObject; -import java.awt.Component; import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; -import java.util.List; import java.util.prefs.Preferences; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.AutojoinLists; @@ -47,13 +44,11 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; 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.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -101,10 +96,6 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; - /** The map control factory instance. */ - @NotNull - private MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControlFactory = null; - /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { @@ -145,24 +136,12 @@ /** {@inheritDoc} */ @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final String mapName, @Nullable final File file) { - return mapControlFactory.newMapControl(this, parent, objects, mapArchObject, mapName, file); - } - - /** {@inheritDoc} */ - @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final File file) { - return mapControlFactory.newPickmapControl(this, parent, objects, mapArchObject, file); - } - - /** {@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 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) { + 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) { this.selectedSquareView = selectedSquareView; this.mainView = mainView; this.editTypes = editTypes; @@ -170,7 +149,6 @@ this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - mapControlFactory = new DefaultMapControlFactory(rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } public void setFilterControl(@NotNull final CFilterControl filterControl) { Modified: trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/crossfire/src/cfeditor/map/DefaultMapControlFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -46,43 +46,56 @@ public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** + * The {@link GridartaObjectsFactory} instance to use. + */ + @NotNull + private GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; + + /** * The {@link RendererFactory} instance to use. */ @NotNull - private final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; + private RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; /** * The {@link MapActions} instance to use. */ @NotNull - private final MapActions mapActions; + private MapActions mapActions; /** * The {@link ArchetypeChooserModel} instance to use. */ @NotNull - private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; + private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; /** * The {@link MapImageCache} instance to use. */ @NotNull - private final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; + private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; /** * The {@link AutojoinLists} instacne to use. */ @NotNull - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; + private AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; /** * The matcher for exit objects. */ @NotNull - private final GameObjectMatcher exitTypeGameObjectMatcher; + private GameObjectMatcher exitTypeGameObjectMatcher; /** * Creates a new instance. + */ + public DefaultMapControlFactory() { + } + + /** + * Initializes the instance. + * @param gridartaObjectsFactory the gridarta objects factory to use * @param rendererFactory the renderer factory to use * @param mapActions the map actions to use * @param archetypeChooserModel the archetype chooser model to use @@ -90,7 +103,8 @@ * @param autojoinLists the autojoin lists to use * @param exitTypeGameObjectMatcher the matcher for exit objects */ - 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) { + public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @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; this.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; @@ -101,7 +115,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) { + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@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, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); @@ -110,7 +124,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) { + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@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, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(file.getPath()); Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/daimonin/src/daieditor/CMainControl.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -34,6 +34,7 @@ import daieditor.gui.prefs.GUIPrefs; import daieditor.gui.prefs.NetPrefs; import daieditor.gui.prefs.ResPrefs; +import daieditor.map.DefaultMapControlFactory; import daieditor.map.MapArchObject; import daieditor.map.validation.checks.ExitChecker; import daieditor.map.validation.checks.SlayingChecker; @@ -265,12 +266,12 @@ * @throws RuntimeException If the controller cannot be initialized. */ public CMainControl() { - super(new DaimoninObjectsFactory(), new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects()); + super(new DaimoninObjectsFactory(), new DefaultRendererFactory(), "daieditor", new GlobalSettingsImpl(), new AnimationObjects(), new FaceObjects(), new DefaultMapControlFactory()); 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); final ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserControl = new ArchetypeChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeChooserModel); - pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), mapManager); + pickmapChooserControl = new PickmapChooserControl<GameObject, MapArchObject, Archetype, CMapViewBasic>(newMapDialogFactory, this, gridartaObjectsFactory, mapControlFactory, new File(globalSettings.getArchDefaultFolder(), IGUIConstants.PICKMAP_DIR), mapManager); newMapDialogFactory.setPickmapChooserControl(pickmapChooserControl); final ArchetypeTypeSet<GameObject, MapArchObject, Archetype> archetypeTypeSet = new ArchetypeTypeSet<GameObject, MapArchObject, Archetype>(); final GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<GameObject, MapArchObject, Archetype, CMapViewBasic>(archetypeTypeSet, archetypeSet, mapManager); @@ -378,7 +379,8 @@ mainView.init(gameObjectAttributesControl, selectedSquareView, archetypeTypeSet, mapTileListBottom, gameObjectMatchers, archetypeChooserControl, pickmapChooserControl, objectChooser, leftPanel); mapActions.updateMenuState(); final ArchetypeParser archetypeParser = new ArchetypeParser(archetypeChooserControl, animationObjects, archetypeSet); - gridartaObjectsFactory.init(rendererFactory, faceObjects, archetypeChooserModel, selectedSquareView, this, mainView, editTypes, mapImageCache, mapActions, archetypeParser, archetypeSet, toolPalette, autojoinLists, exitMatcher); + ((DefaultMapControlFactory) mapControlFactory).init(gridartaObjectsFactory, rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitMatcher); + gridartaObjectsFactory.init(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:11:09 UTC (rev 4915) +++ trunk/daimonin/src/daieditor/DaimoninObjectsFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -25,13 +25,10 @@ import daieditor.gui.map.CMapViewBasic; import daieditor.io.GameObjectParser; import daieditor.io.MapArchObjectParser; -import daieditor.map.DefaultMapControlFactory; import daieditor.map.MapArchObject; -import java.awt.Component; import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; -import java.util.List; import java.util.prefs.Preferences; import net.sf.gridarta.AbstractMainControl; import net.sf.gridarta.AutojoinLists; @@ -47,13 +44,11 @@ import net.sf.gridarta.gui.MainView; import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; 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.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -105,10 +100,6 @@ @NotNull private ToolPalette<GameObject, MapArchObject, Archetype, CMapViewBasic> toolPalette = null; - /** The map control factory instance. */ - @NotNull - private MapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> mapControlFactory = null; - /** {@inheritDoc} */ @NotNull public GameObject newGameObject() { @@ -149,24 +140,12 @@ /** {@inheritDoc} */ @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final String mapName, @Nullable final File file) { - return mapControlFactory.newMapControl(this, parent, objects, mapArchObject, mapName, file); - } - - /** {@inheritDoc} */ - @NotNull - public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@Nullable final List<GameObject> objects, @NotNull final MapArchObject mapArchObject, @NotNull final Component parent, @NotNull final File file) { - return mapControlFactory.newPickmapControl(this, parent, objects, mapArchObject, file); - } - - /** {@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 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) { + 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) { this.faceObjects = faceObjects; this.selectedSquareView = selectedSquareView; this.mainControl = mainControl; @@ -176,7 +155,6 @@ this.archetypeParser = archetypeParser; this.archetypeSet = archetypeSet; this.toolPalette = toolPalette; - mapControlFactory = new DefaultMapControlFactory(rendererFactory, mapActions, archetypeChooserModel, mapImageCache, autojoinLists, exitTypeGameObjectMatcher); } } // class DaimoninObjectsFactory Modified: trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java =================================================================== --- trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/daimonin/src/daieditor/map/DefaultMapControlFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -46,43 +46,56 @@ public class DefaultMapControlFactory extends AbstractMapControlFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> { /** + * The {@link GridartaObjectsFactory} instance to use. + */ + @NotNull + private GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory; + + /** * The {@link RendererFactory} instance to use. */ @NotNull - private final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; + private RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory; /** * The {@link MapActions} instance to use. */ @NotNull - private final MapActions mapActions; + private MapActions mapActions; /** * The {@link ArchetypeChooserModel} instance to use. */ @NotNull - private final ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; + private ArchetypeChooserModel<GameObject, MapArchObject, Archetype, CMapViewBasic> archetypeChooserModel; /** * The {@link MapImageCache} instance to use. */ @NotNull - private final MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; + private MapImageCache<GameObject, MapArchObject, Archetype, CMapViewBasic> mapImageCache; /** * The {@link AutojoinLists} instacne to use. */ @NotNull - private final AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; + private AutojoinLists<GameObject, MapArchObject, Archetype> autojoinLists; /** * The matcher for exit objects. */ @NotNull - private final GameObjectMatcher exitTypeGameObjectMatcher; + private GameObjectMatcher exitTypeGameObjectMatcher; /** * Creates a new instance. + */ + public DefaultMapControlFactory() { + } + + /** + * Creates a new instance. + * @param gridartaObjectsFactory the gridarta objects factory to use * @param rendererFactory the renderer factory to use * @param mapActions the map actions to use * @param archetypeChooserModel the archetype chooser model to use @@ -90,7 +103,8 @@ * @param autojoinLists the autojoin lists to use * @param exitTypeGameObjectMatcher the matcher for exit objects */ - 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) { + public void init(@NotNull final GridartaObjectsFactory<GameObject, MapArchObject, Archetype, CMapViewBasic> gridartaObjectsFactory, @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; this.rendererFactory = rendererFactory; this.mapActions = mapActions; this.archetypeChooserModel = archetypeChooserModel; @@ -101,7 +115,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) { + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newMapControl(@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, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, false, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); mapControl.setMapFileName(mapName); @@ -110,7 +124,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) { + public MapControl<GameObject, MapArchObject, Archetype, CMapViewBasic> newPickmapControl(@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, rendererFactory, parent, autojoinLists, mapImageCache, objects, mapArchObject, true, exitTypeGameObjectMatcher, archetypeChooserModel, mapActions); mapControl.setMapFile(file); Modified: trunk/src/app/net/sf/gridarta/AbstractMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/AbstractMainControl.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -47,6 +47,7 @@ import net.sf.gridarta.io.PathManager; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.textedit.scripteditor.ScriptEditControlInstance; import net.sf.gridarta.updater.UpdaterManager; import net.sf.japi.swing.ActionFactory; @@ -82,6 +83,9 @@ /** The gridarta objects factory. */ protected final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** The map control factory. */ + protected final MapControlFactory<G, A, R, V> mapControlFactory; + /** The renderer factory. */ protected final RendererFactory<G, A, R> rendererFactory; @@ -145,16 +149,18 @@ * @param globalSettings the global settings instance * @param animationObjects the animation objects instance * @param faceObjects the face objects instance + * @param mapControlFactory the map control instance */ - 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) { + 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, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory) { this.globalSettings = globalSettings; - final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, globalSettings); + this.mapControlFactory = mapControlFactory; + final DefaultMapManager<G, A, R, V> tmpMapManager = new DefaultMapManager<G, A, R, V>(this, key, gridartaObjectsFactory, mapControlFactory, globalSettings); editTypes = new EditTypes<G, A, R, V>(tmpMapManager); tmpMapManager.setEditTypes(editTypes); mapManager = tmpMapManager; this.animationObjects = animationObjects; this.faceObjects = faceObjects; - copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, gridartaObjectsFactory); + copyBuffer = new CopyBuffer<G, A, R, V>(this, editTypes, mapControlFactory); this.gridartaObjectsFactory = gridartaObjectsFactory; this.rendererFactory = rendererFactory; globalSettings.readGlobalSettings(); Modified: trunk/src/app/net/sf/gridarta/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/CopyBuffer.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -30,6 +30,7 @@ import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -71,7 +72,7 @@ * The gridarta objects factory instance. */ @NotNull - private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + private final MapControlFactory<G, A, R, V> mapControlFactory; /** Internal map control to store the cut / copied arches. */ private MapControl<G, A, R, V> copyMapCtrl = null; @@ -80,12 +81,12 @@ * Create the copy buffer. * @param mainControl main control * @param editTypes the edit types instance - * @param gridartaObjectsFactory the gridarta objects factory instance + * @param mapControlFactory the gridarta objects factory instance */ - public CopyBuffer(final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory) { + public CopyBuffer(final MainControl<G, A, R, V> mainControl, @NotNull final EditTypes<G, A, R, V> editTypes, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory) { this.mainControl = mainControl; // link main control in this.editTypes = editTypes; - this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapControlFactory = mapControlFactory; } /** @@ -95,7 +96,7 @@ public void init(final A mapArch) { assert copyMapCtrl == null; mapArch.setMapName("cb"); - copyMapCtrl = gridartaObjectsFactory.newMapControl(null, mapArch, mainControl.getMainView(), "cb", null); + copyMapCtrl = mapControlFactory.newMapControl(mainControl.getMainView(), null, mapArch, "cb", null); } /** Modified: trunk/src/app/net/sf/gridarta/DefaultMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/DefaultMapManager.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -36,6 +36,7 @@ import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.japi.swing.ActionFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -69,6 +70,12 @@ @NotNull private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** + * The map control factory instance. + */ + @NotNull + private final MapControlFactory<G, A, R, V> mapControlFactory; + /** The edit types. */ @NotNull private EditTypes<G, A, R, V> editTypes = null; @@ -90,13 +97,15 @@ * @param mainControl the main control * @param key The action factory key. * @param gridartaObjectsFactory the gridarta objects 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 GlobalSettings globalSettings) { + 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) { this.globalSettings = globalSettings; actionFactory = ActionFactory.getFactory(key); this.mainControl = mainControl; this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapControlFactory = mapControlFactory; } /** @@ -122,7 +131,7 @@ } private MapControl<G, A, R, V> newMap(@Nullable final List<G> objects, @NotNull final A mapArchObject, @Nullable final File file, @NotNull final String mapFileName) { - final MapControl<G, A, R, V> mapControl = gridartaObjectsFactory.newMapControl(objects, mapArchObject, mainControl.getMainView(), mapFileName, file); + final MapControl<G, A, R, V> mapControl = mapControlFactory.newMapControl(mainControl.getMainView(), objects, mapArchObject, mapFileName, file); levels.add(mapControl); fireMapCreatedEvent(mapControl); setCurrentLevel(mapControl); @@ -258,7 +267,7 @@ return null; } - return gridartaObjectsFactory.newMapControl(decoder.getGameObjects(), decoder.getMapArchObject(), mainControl.getMainView(), file.getPath(), file); + return mapControlFactory.newMapControl(mainControl.getMainView(), decoder.getGameObjects(), decoder.getMapArchObject(), file.getPath(), file); } /** Modified: trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/GridartaObjectsFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -19,11 +19,9 @@ package net.sf.gridarta; -import java.awt.Component; import java.awt.Point; import java.io.File; import java.io.FileNotFoundException; -import java.util.List; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.ArchetypeParser; import net.sf.gridarta.gameobject.ArchetypeSet; @@ -34,7 +32,6 @@ import net.sf.gridarta.gui.archetypechooser.ArchetypeChooserModel; 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; @@ -97,29 +94,6 @@ GameObjectParser<G, A, R> newGameObjectParser(); /** - * Create a new map control instance. - * @param objects The objects to insert into the new map. - * @param mapArchObject The map arch object to use for the new map. - * @param parent the parent component for error messages - * @param mapName the map name - * @param file the associated file - * @return The new map control instance. - */ - @NotNull - MapControl<G, A, R, V> newMapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @NotNull Component parent, @NotNull String mapName, @Nullable File file); - - /** - * Create a new pickmap map control instance. - * @param objects The objects to insert into the new pickmap. - * @param mapArchObject The map arch object to use for the new pickmap. - * @param parent the parent component for error messages - * @param file the associated file - * @return The new pickmap map control instance. - */ - @NotNull - MapControl<G, A, R, V> newPickmapControl(@Nullable List<G> objects, @NotNull A mapArchObject, @NotNull Component parent, @NotNull File file); - - /** * 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> @@ -132,7 +106,6 @@ /** * 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 @@ -147,6 +120,6 @@ * @param autojoinLists the autojoin lists instance * @param exitTypeGameObjectMatcher the matcher for exit objects */ - 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); + 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); } // interface GridartaObjectsFactory Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Folder.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -33,6 +33,7 @@ import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -131,12 +132,13 @@ * @param name the map file name * @param gridartaObjectsFactory the <code>GridartaObjectsFactory</code> * instance for loading the pickmap map file + * @param mapControlFactory the map control factory instance * @param parent the parent component for error messages * @return the newly created pickmap * @throws InvalidNameException if the pickmap name is invalid */ - public synchronized Pickmap<G, A, R, V> addPickmap(@NotNull final String name, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent) throws InvalidNameException { - final Pickmap<G, A, R, V> pickmap = new Pickmap<G, A, R, V>(this, name, gridartaObjectsFactory, parent); + public synchronized Pickmap<G, A, R, V> addPickmap(@NotNull final String name, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final Component parent) throws InvalidNameException { + final Pickmap<G, A, R, V> pickmap = new Pickmap<G, A, R, V>(this, name, gridartaObjectsFactory, mapControlFactory, parent); pickmaps.add(pickmap); for (final FolderListener<G, A, R, V> listener : listeners.getListeners(FolderListener.class)) { listener.pickmapAdded(pickmap); Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Loader.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -27,6 +27,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; import net.sf.gridarta.map.MapArchObject; +import net.sf.gridarta.map.MapControlFactory; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -52,6 +53,13 @@ private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; /** + * The {@link MapControlFactory} instance to use for creating map control + * instances. + */ + @NotNull + private final MapControlFactory<G, A, R, V> mapControlFactory; + + /** * The parent component for error messages. */ @NotNull @@ -61,12 +69,14 @@ * Creates a new instance. * @param pickmapChooserModel the model to add the loaded pickmaps to * @param gridartaObjectsFactory the <code>GridartaObjectsFactory</code> + * @param mapControlFactory the map control instance to use * @param parent the parent component for error messages * instance to use for loading pickmap files */ - public Loader(@NotNull final PickmapChooserModel<G, A, R, V> pickmapChooserModel, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent) { + public Loader(@NotNull final PickmapChooserModel<G, A, R, V> pickmapChooserModel, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final Component parent) { this.pickmapChooserModel = pickmapChooserModel; this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapControlFactory = mapControlFactory; this.parent = parent; } @@ -113,7 +123,7 @@ for (final File file : files) { if (file.isFile()) { try { - folder.addPickmap(file.getName(), gridartaObjectsFactory, this.parent); + folder.addPickmap(file.getName(), gridartaObjectsFactory, mapControlFactory, this.parent); } catch (final InvalidNameException ex) { log.warn("ignoring pickmap with invalid name: " + file); } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/Pickmap.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -31,6 +31,7 @@ import net.sf.gridarta.io.MapReader; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -55,6 +56,12 @@ private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; /** + * The {@link MapControlFactory} instance. + */ + @NotNull + private final MapControlFactory<G, A, R, V> mapControlFactory; + + /** * The parent component for error messages. */ @NotNull @@ -80,10 +87,11 @@ * @param name the underlying map file name * @param gridartaObjectsFactory the <code>GridartaObjectsFactory</code> * instance for loading the map file + * @param mapControlFactory the map control instance * @param parent the parent component for error messages * @throws InvalidNameException if <code>name</code> is not valid */ - public Pickmap(@NotNull final Folder<G, A, R, V> folder, @NotNull final String name, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final Component parent) throws InvalidNameException { + public Pickmap(@NotNull final Folder<G, A, R, V> folder, @NotNull final String name, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final Component parent) throws InvalidNameException { if (!isValidPickmapName(name)) { throw new InvalidNameException(name); } @@ -91,6 +99,7 @@ this.folder = folder; this.name = name; this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapControlFactory = mapControlFactory; this.parent = parent; } @@ -151,7 +160,7 @@ decoder.close(); } - pickmap = gridartaObjectsFactory.newPickmapControl(decoder.getGameObjects(), decoder.getMapArchObject(), parent, file); + pickmap = mapControlFactory.newPickmapControl(parent, decoder.getGameObjects(), decoder.getMapArchObject(), file); pickmapView = pickmap.createView(null); } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -44,6 +44,7 @@ import net.sf.gridarta.map.InsertionMode; import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.MapControlListener; import net.sf.gridarta.map.MapModel; import net.sf.japi.swing.ActionFactory; @@ -82,6 +83,12 @@ @NotNull private final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory; + /** + * The map control factory instance. + */ + @NotNull + private final MapControlFactory<G, A, R, V> mapControlFactory; + /** The view for this control. */ @NotNull private final PickmapChooserView<G, A, R, V> view; @@ -178,13 +185,15 @@ * @param newMapDialogFactory the factory for creating new pickmaps * @param mainControl the main control * @param gridartaObjectsFactory the gridarta objects factory instance + * @param mapControlFactory the map control factory instance * @param pickmapDir the pickmaps directory * @param mapManager the map manager instance */ - public PickmapChooserControl(@NotNull final NewMapDialogFactory<G, A, R, V> newMapDialogFactory, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final File pickmapDir, @NotNull final MapManager<G, A, R, V> mapManager) { + public PickmapChooserControl(@NotNull final NewMapDialogFactory<G, A, R, V> newMapDialogFactory, @NotNull final MainControl<G, A, R, V> mainControl, @NotNull final GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull final MapControlFactory<G, A, R, V> mapControlFactory, @NotNull final File pickmapDir, @NotNull final MapManager<G, A, R, V> mapManager) { this.mainControl = mainControl; this.mapManager = mapManager; this.gridartaObjectsFactory = gridartaObjectsFactory; + this.mapControlFactory = mapControlFactory; pickmapChooserModel = new PickmapChooserModel<G, A, R, V>(pickmapDir); folderListActions = new FolderListActions<G, A, R, V>(pickmapChooserModel, newMapDialogFactory); currentPickmapActions = new CurrentPickmapActions<G, A, R, V>(newMapDialogFactory, this); @@ -219,7 +228,7 @@ * Load all pickmaps and build the pickmap-panel. */ public void loadPickmaps() { - new Loader<G, A, R, V>(pickmapChooserModel, gridartaObjectsFactory, mainControl.getMainView()).load(); + new Loader<G, A, R, V>(pickmapChooserModel, gridartaObjectsFactory, mapControlFactory, mainControl.getMainView()).load(); } /** @@ -260,12 +269,12 @@ } } - final MapControl<G, A, R, V> mapControl = gridartaObjectsFactory.newPickmapControl(null, mapArchObject, mainControl.getMainView(), mapFile); + final MapControl<G, A, R, V> mapControl = mapControlFactory.newPickmapControl(mainControl.getMainView(), null, mapArchObject, mapFile); mapControl.save(); final Pickmap<G, A, R, V> pickmap; try { - pickmap = activeFolder.addPickmap(pickmapName, gridartaObjectsFactory, mainControl.getMainView()); + pickmap = activeFolder.addPickmap(pickmapName, gridartaObjectsFactory, mapControlFactory, mainControl.getMainView()); } catch (final InvalidNameException ex) { throw new AssertionError(); // the name has been checked before } Modified: trunk/src/app/net/sf/gridarta/map/MapControlFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/app/net/sf/gridarta/map/MapControlFactory.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -22,7 +22,6 @@ import java.awt.Component; import java.io.File; import java.util.List; -import net.sf.gridarta.GridartaObjectsFactory; import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.MapViewBasic; @@ -37,7 +36,6 @@ /** * Create a new map control instance. - * @param gridartaObjectsFactory the gridarta objects factory * @param parent the parent component for error messages * @param objects the objects to insert into the new map * @param mapArchObject the map arch object to use for the new map @@ -46,11 +44,10 @@ * @return the new map control instance */ @NotNull - MapControl<G, A, R, V> newMapControl(@NotNull GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull Component parent, @Nullable List<G> objects, @NotNull A mapArchObject, @NotNull String mapName, @Nullable File file); + MapControl<G, A, R, V> newMapControl(@NotNull Component parent, @Nullable List<G> objects, @NotNull A mapArchObject, @NotNull String mapName, @Nullable File file); /** * Create a new pickmap map control instance. - * @param gridartaObjectsFactory the gridarta objects factory * @param parent the parent component for error messages * @param objects the objects to insert into the new pickmap * @param mapArchObject the map arch object to use for the new pickmap @@ -58,6 +55,6 @@ * @return the new pickmap map control instance */ @NotNull - MapControl<G, A, R, V> newPickmapControl(@NotNull GridartaObjectsFactory<G, A, R, V> gridartaObjectsFactory, @NotNull Component parent, @Nullable List<G> objects, @NotNull A mapArchObject, @NotNull File file); + MapControl<G, A, R, V> newPickmapControl(@NotNull Component parent, @Nullable List<G> objects, @NotNull A mapArchObject, @NotNull File file); } // interface MapControlFactory Modified: trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-20 19:11:09 UTC (rev 4915) +++ trunk/src/test/net/sf/gridarta/map/DefaultMapModelTest.java 2008-08-20 19:50:17 UTC (rev 4916) @@ -81,6 +81,7 @@ import net.sf.gridarta.map.MapArchObject; import net.sf.gridarta.map.MapArchObjectListener; import net.sf.gridarta.map.MapControl; +import net.sf.gridarta.map.MapControlFactory; import net.sf.gridarta.map.MapModel; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; @@ -393,16 +394,17 @@ @Before public void setUp() { gridartaObjectsFactory = new TestGridartaObjectsFactory(); + final MapControlFactory<TestGameObject, TestMapArchObject, TestArchetype, TestMapViewBasic> mapControlFactory = new TestMapControlFactory(); ... [truncated message content] |