From: <aki...@us...> - 2013-10-15 18:31:24
|
Revision: 9435 http://sourceforge.net/p/gridarta/code/9435 Author: akirschbaum Date: 2013-10-15 18:31:19 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Move code from GameObject to MapRenderer implementations. Removes dependency GameObject -> MapViewSettings. Modified Paths: -------------- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/GameObject.java trunk/src/model/src/test/java/net/sf/gridarta/model/gameobject/TestGameObject.java Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -343,7 +343,7 @@ * @param node the game object to paint */ private void paintGameObject(@NotNull final Graphics g, final int x, final int y, @NotNull final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> node) { - final ImageIcon img = node.getImage(mapViewSettings); + final ImageIcon img = node.getNormalImage(); if (!node.isMulti() || (img.getIconWidth() == IGUIConstants.SQUARE_WIDTH && img.getIconHeight() == IGUIConstants.SQUARE_HEIGHT)) { offset.x = 0; offset.y = 0; Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObject.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -19,12 +19,10 @@ package net.sf.gridarta.var.crossfire.model.gameobject; -import javax.swing.ImageIcon; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.AbstractGameObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -155,16 +153,7 @@ /** * {@inheritDoc} */ - @NotNull @Override - public ImageIcon getImage(@NotNull final MapViewSettings mapViewSettings) { - return getNormalImage(); - } - - /** - * {@inheritDoc} - */ - @Override public int getLightRadius() { return getAttributeInt(GLOW_RADIUS); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -497,7 +497,25 @@ */ private void paintGameObject(@NotNull final Graphics2D g, final int xStart, final int yStart, @NotNull final G gameObject, final boolean inSpawnPoint) { final G head = gameObject.getHead(); - final Icon icon = "trans.101".equals(head.getFaceObjName()) ? unknownSquareIcon : head.getImage(mapViewSettings); + final Icon icon; + if ("trans.101".equals(head.getFaceObjName())) { + icon = unknownSquareIcon; + } else { + final boolean drawDouble = head.isDrawDouble(mapViewSettings.isDoubleFaces()); + if (mapViewSettings.isAlphaType(head.getEditType())) { + if (drawDouble) { + icon = head.getTransparentDoubleImage(); + } else { + icon = head.getTransparentImage(); + } + } else { + if (drawDouble) { + icon = head.getDoubleImage(); + } else { + icon = head.getNormalImage(); + } + } + } final int xOffset = head.getAttributeInt(DefaultIsoGameObject.ALIGN); final int zoom = head.getAttributeInt(DefaultIsoGameObject.ZOOM); final double rotate = getRotate(head); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/DefaultIsoGameObject.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -163,7 +162,7 @@ * @return the transparent face for this game object */ @NotNull - protected ImageIcon getTransparentImage() { + public ImageIcon getTransparentImage() { if (transFace == null) { transFace = faceObjectProviders.getTrans(this); } @@ -175,7 +174,7 @@ * @return the double face for this game object */ @NotNull - protected ImageIcon getDoubleImage() { + public ImageIcon getDoubleImage() { if (doubleFace == null) { doubleFace = faceObjectProviders.getDouble(this); } @@ -187,7 +186,7 @@ * @return the transparent face for this game object */ @NotNull - protected ImageIcon getTransparentDoubleImage() { + public ImageIcon getTransparentDoubleImage() { if (transDoubleFace == null) { transDoubleFace = faceObjectProviders.getTransDouble(this); } @@ -207,28 +206,6 @@ */ @NotNull @Override - public ImageIcon getImage(@NotNull final MapViewSettings mapViewSettings) { - final boolean drawDouble = isDrawDouble(mapViewSettings.isDoubleFaces()); - if (mapViewSettings.isAlphaType(getEditType())) { - if (drawDouble) { - return getTransparentDoubleImage(); - } else { - return getTransparentImage(); - } - } else { - if (drawDouble) { - return getDoubleImage(); - } else { - return getNormalImage(); - } - } - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override @SuppressWarnings("unchecked") public G clone() { //noinspection OverriddenMethodCallDuringObjectConstruction Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/GameObject.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/GameObject.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/gameobject/GameObject.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -20,13 +20,11 @@ package net.sf.gridarta.model.gameobject; import java.util.Iterator; -import javax.swing.ImageIcon; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmodel.MapSquare; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -130,15 +128,6 @@ boolean isEmpty(); /** - * Returns the face for this game object according to the settings of a - * {@link MapViewSettings} instance. - * @param mapViewSettings the map view settings instance - * @return the face - */ - @NotNull - ImageIcon getImage(@NotNull MapViewSettings mapViewSettings); - - /** * Remove this GameObject from its container. Does nothing if the object has * no container. This method also takes perfectly well care of multi-part * GameObjects. Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/gameobject/TestGameObject.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/gameobject/TestGameObject.java 2013-10-15 18:12:21 UTC (rev 9434) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/gameobject/TestGameObject.java 2013-10-15 18:31:19 UTC (rev 9435) @@ -19,13 +19,11 @@ package net.sf.gridarta.model.gameobject; -import javax.swing.ImageIcon; import net.sf.gridarta.model.anim.AnimationObjects; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -69,16 +67,7 @@ /** * {@inheritDoc} */ - @NotNull @Override - public ImageIcon getImage(@NotNull final MapViewSettings mapViewSettings) { - return getNormalImage(); - } - - /** - * {@inheritDoc} - */ - @Override public int getLightRadius() { return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 18:47:25
|
Revision: 9436 http://sourceforge.net/p/gridarta/code/9436 Author: akirschbaum Date: 2013-10-15 18:47:19 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Do not calculate edit types unless the map has a map view. Removes dependency MapModelFactory -> MapViewSettings. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapViewsManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapModelFactory.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapViewsManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapViewsManager.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapViewsManager.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -57,6 +57,12 @@ private FileControl<G, A, R> fileControl; /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** * The {@link MapViewFactory} to use. */ @NotNull @@ -148,6 +154,7 @@ * @param pickmapManager the pickmap manager to use */ public MapViewsManager(@NotNull final MapViewSettings mapViewSettings, @NotNull final MapViewFactory<G, A, R> mapViewFactory, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapManager<G, A, R> pickmapManager) { + this.mapViewSettings = mapViewSettings; this.mapViewFactory = mapViewFactory; this.mapManager = mapManager; mapViewSettings.addMapViewSettingsListener(mapViewSettingsListener); @@ -208,6 +215,7 @@ */ @NotNull public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, @Nullable final Point centerSquare) { + mapControl.getMapModel().addActiveEditType(mapViewSettings.getEditType()); return getMapViewsInt(mapControl).newMapView(mapControl, viewPosition, centerSquare, mapViewFactory); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -102,7 +102,7 @@ final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(); final ArchetypeChooserModel<G, A, R> archetypeChooserModel = new ArchetypeChooserModel<G, A, R>(); final InsertionMode<G, A, R> topmostInsertionMode = new TopmostInsertionMode<G, A, R>(); - final MapModelFactory<G, A, R> mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + final MapModelFactory<G, A, R> mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); final MapControlFactory<G, A, R> mapControlFactory = editorFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory); final MapManager<G, A, R> mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, projectModel.getFaceObjectProviders()); final Set<NamedGameObjectMatcher> matchers = new HashSet<NamedGameObjectMatcher>(); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -223,17 +223,15 @@ * @param autojoinLists the autojoin lists instance to use * @param mapArchObject the map arch object to associate with this model * @param archetypeChooserModel the archetype chooser control - * @param activeEditType the active edit types * @param gameObjectFactory the game object factory for creating game * objects * @param gameObjectMatchers the game object matchers to use * @param topmostInsertionMode the "topmost" insertion mode */ - public DefaultMapModel(@NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final A mapArchObject, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, final int activeEditType, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final InsertionMode<G, A, R> topmostInsertionMode) { + public DefaultMapModel(@NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final A mapArchObject, @NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final InsertionMode<G, A, R> topmostInsertionMode) { this.mapArchObject = mapArchObject; this.autojoinLists = autojoinLists; this.archetypeChooserModel = archetypeChooserModel; - this.activeEditType = activeEditType; this.gameObjectFactory = gameObjectFactory; this.gameObjectMatchers = gameObjectMatchers; this.topmostInsertionMode = topmostInsertionMode; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapModelFactory.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapModelFactory.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapModelFactory.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; import org.jetbrains.annotations.NotNull; @@ -48,12 +47,6 @@ private final AutojoinLists<G, A, R> autojoinLists; /** - * The map view settings instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * The {@link GameObjectFactory} for creating {@link GameObject * GameObjects}. */ @@ -76,16 +69,14 @@ * Creates a new instance. * @param archetypeChooserModel the archetype chooser model to use * @param autojoinLists the autojoin lists to use - * @param mapViewSettings the map view settings instance * @param gameObjectFactory the game object factory for creating game * objects * @param gameObjectMatchers the game object matchers to use * @param topmostInsertionMode the "topmost" insertion mode */ - public MapModelFactory(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final MapViewSettings mapViewSettings, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final InsertionMode<G, A, R> topmostInsertionMode) { + public MapModelFactory(@NotNull final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull final AutojoinLists<G, A, R> autojoinLists, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final InsertionMode<G, A, R> topmostInsertionMode) { this.archetypeChooserModel = archetypeChooserModel; this.autojoinLists = autojoinLists; - this.mapViewSettings = mapViewSettings; this.gameObjectFactory = gameObjectFactory; this.gameObjectMatchers = gameObjectMatchers; this.topmostInsertionMode = topmostInsertionMode; @@ -98,7 +89,7 @@ */ @NotNull public MapModel<G, A, R> newMapModel(@NotNull final A mapArchObject) { - return new DefaultMapModel<G, A, R>(autojoinLists, mapArchObject, archetypeChooserModel, mapViewSettings.getEditType(), gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + return new DefaultMapModel<G, A, R>(autojoinLists, mapArchObject, archetypeChooserModel, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); } } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -163,7 +163,7 @@ mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(projectSettings); - mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, mapModelCreator.getAutojoinLists(), mapViewSettings, mapModelCreator.getGameObjectFactory(), mapModelCreator.getGameObjectMatchers(), mapModelCreator.getTopmostInsertionMode()); + mapModelFactory = new MapModelFactory<TestGameObject, TestMapArchObject, TestArchetype>(archetypeChooserModel, mapModelCreator.getAutojoinLists(), mapModelCreator.getGameObjectFactory(), mapModelCreator.getGameObjectMatchers(), mapModelCreator.getTopmostInsertionMode()); mapControlFactory = new TestMapControlFactory(mapWriter, projectSettings, mapModelFactory); final AbstractMapManager<TestGameObject, TestMapArchObject, TestArchetype> tmpMapManager = new DefaultMapManager<TestGameObject, TestMapArchObject, TestArchetype>(mapReaderFactory, mapControlFactory, projectSettings, mapModelCreator.getFaceObjectProviders()); tmpMapManager.setFileControl(fileControl); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -170,7 +170,7 @@ public MapModel<TestGameObject, TestMapArchObject, TestArchetype> newMapModel(final int w, final int h) { final TestMapArchObject mapArchObject = new TestMapArchObject(); mapArchObject.setMapSize(new Size2D(w, h)); - return new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapArchObject, archetypeChooserModel, 0, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + return new DefaultMapModel<TestGameObject, TestMapArchObject, TestArchetype>(autojoinLists, mapArchObject, archetypeChooserModel, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); } /** Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:31:19 UTC (rev 9435) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:47:19 UTC (rev 9436) @@ -236,7 +236,7 @@ gameObjectMatchers = loadGameObjectMatchers(xmlHelper, errorView, projectSettings); validators = loadValidators(errorView, projectFactory, projectSettings, gameObjectMatchers, archetypeTypeSet, validatorPreferences, mapWriter); final AutojoinLists<G, A, R> autojoinLists = AutojoinListsParser.loadList(errorView, archetypeSet, mapViewSettings, projectSettings.getConfigurationDirectory()); - mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, mapViewSettings, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); + mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); final MapControlFactory<G, A, R> mapControlFactory = projectFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory); mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); pickmapManager = new DefaultPickmapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 18:48:56
|
Revision: 9437 http://sourceforge.net/p/gridarta/code/9437 Author: akirschbaum Date: 2013-10-15 18:48:53 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove unused parameter. Modified Paths: -------------- trunk/src/model/src/main/java/net/sf/gridarta/model/autojoin/AutojoinListsParser.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/autojoin/AutojoinListsParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/autojoin/AutojoinListsParser.java 2013-10-15 18:47:19 UTC (rev 9436) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/autojoin/AutojoinListsParser.java 2013-10-15 18:48:53 UTC (rev 9437) @@ -35,7 +35,6 @@ import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; @@ -61,12 +60,11 @@ * Loads all the autojoin lists from the data file. * @param errorView the error view for reporting errors * @param archetypeSet the archetype set for looking up archetypes - * @param mapViewSettings the map view settings instance * @param baseDir the base directory to load autojoin info from * @return the loaded autojoin lists */ @NotNull - public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> AutojoinLists<G, A, R> loadList(@NotNull final ErrorView errorView, final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapViewSettings mapViewSettings, @NotNull final File baseDir) { + public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> AutojoinLists<G, A, R> loadList(@NotNull final ErrorView errorView, final ArchetypeSet<G, A, R> archetypeSet, @NotNull final File baseDir) { try { final URL url = IOUtils.getResource(baseDir, FILENAME); try { Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:47:19 UTC (rev 9436) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:48:53 UTC (rev 9437) @@ -235,7 +235,7 @@ final ValidatorPreferences validatorPreferences = new DefaultValidatorPreferences(); gameObjectMatchers = loadGameObjectMatchers(xmlHelper, errorView, projectSettings); validators = loadValidators(errorView, projectFactory, projectSettings, gameObjectMatchers, archetypeTypeSet, validatorPreferences, mapWriter); - final AutojoinLists<G, A, R> autojoinLists = AutojoinListsParser.loadList(errorView, archetypeSet, mapViewSettings, projectSettings.getConfigurationDirectory()); + final AutojoinLists<G, A, R> autojoinLists = AutojoinListsParser.loadList(errorView, archetypeSet, projectSettings.getConfigurationDirectory()); mapModelFactory = new MapModelFactory<G, A, R>(archetypeChooserModel, autojoinLists, gameObjectFactory, gameObjectMatchers, topmostInsertionMode); final MapControlFactory<G, A, R> mapControlFactory = projectFactory.newMapControlFactory(mapWriter, projectSettings, mapModelFactory); mapManager = new DefaultMapManager<G, A, R>(mapReaderFactory, mapControlFactory, projectSettings, faceObjectProviders); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 18:57:29
|
Revision: 9438 http://sourceforge.net/p/gridarta/code/9438 Author: akirschbaum Date: 2013-10-15 18:57:22 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove unused parameters. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/resource/DefaultResources.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/resource/DefaultResources.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/resource/DefaultResources.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReader.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReaderFactory.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/GameObjectParser.java trunk/src/model/src/main/java/net/sf/gridarta/model/resource/AbstractResources.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/DefaultMapReaderTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/TestMapReaderFactory.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -450,8 +450,8 @@ */ @NotNull @Override - public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { - return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); + public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { + return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); } /** Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/resource/DefaultResources.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/resource/DefaultResources.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/resource/DefaultResources.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -34,7 +34,6 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.ProjectSettings; @@ -99,15 +98,14 @@ * @param gameObjectParser the game object parser to use * @param archetypeSet the archetype set to update * @param archetypeParser the archetype parser to use - * @param mapViewSettings the map view settings instance * @param faceObjects the face objects instance * @param animationObjects the animation objects instance * @param archFaceProvider the arch face provider to use * @param faceObjectProviders the face object providers for looking up * faces */ - public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { - super(gameObjectParser, archetypeSet, mapViewSettings); + public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { + super(gameObjectParser, archetypeSet); this.gameObjectParser = gameObjectParser; this.archetypeSet = archetypeSet; this.archetypeParser = archetypeParser; Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -341,8 +341,8 @@ */ @NotNull @Override - public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { - return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, smoothFaces, archFaceProvider, faceObjectProviders); + public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { + return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, faceObjects, animationObjects, smoothFaces, archFaceProvider, faceObjectProviders); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/resource/DefaultResources.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/resource/DefaultResources.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/resource/DefaultResources.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -34,7 +34,6 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.ProjectSettings; @@ -106,7 +105,6 @@ * @param gameObjectParser the game object parser instance * @param archetypeSet the archetype set to update * @param archetypeParser the archetype parser to use - * @param mapViewSettings the map view settings instance * @param faceObjects the face objects instance * @param animationObjects the animation objects instance * @param smoothFaces the smooth faces instance @@ -114,8 +112,8 @@ * @param faceObjectProviders the face object providers for looking up * faces */ - public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final SmoothFaces smoothFaces, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { - super(gameObjectParser, archetypeSet, mapViewSettings); + public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final SmoothFaces smoothFaces, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { + super(gameObjectParser, archetypeSet); this.gameObjectParser = gameObjectParser; this.archetypeSet = archetypeSet; this.archetypeParser = archetypeParser; Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -449,8 +449,8 @@ */ @NotNull @Override - public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { - return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); + public AbstractResources<GameObject, MapArchObject, Archetype> newResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SmoothFaces smoothFaces) { + return new DefaultResources(gameObjectParser, archetypeSet, archetypeParser, faceObjects, animationObjects, archFaceProvider, faceObjectProviders); } /** Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/resource/DefaultResources.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/resource/DefaultResources.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/resource/DefaultResources.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -34,7 +34,6 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.resource.CollectedResourcesWriter; import net.sf.gridarta.model.settings.ProjectSettings; @@ -93,15 +92,14 @@ * @param gameObjectParser the game object parser to use * @param archetypeSet the archetype set to update * @param archetypeParser the archetype parser to use - * @param mapViewSettings the map view settings instance * @param faceObjects the face objects instance * @param animationObjects the animation objects instance * @param archFaceProvider the arch face provider to use * @param faceObjectProviders the face object providers for looking up * faces */ - public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { - super(gameObjectParser, archetypeSet, mapViewSettings); + public DefaultResources(@NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders) { + super(gameObjectParser, archetypeSet); this.archetypeSet = archetypeSet; this.archetypeParser = archetypeParser; this.faceObjects = faceObjects; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -97,7 +97,7 @@ final GameObjectParserFactory<G, A, R> gameObjectParserFactory = editorFactory.newGameObjectParserFactory(gameObjectFactory, projectModel.getArchetypeSet(), projectModel.getArchetypeTypeSet()); final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); final MapViewSettings mapViewSettings = new DefaultMapViewSettings(); - final MapReaderFactory<G, A> mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, mapViewSettings); + final MapReaderFactory<G, A> mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<G, A, R>(mapArchObjectParserFactory, gameObjectParser); final AutojoinLists<G, A, R> autojoinLists = new AutojoinLists<G, A, R>(); final ArchetypeChooserModel<G, A, R> archetypeChooserModel = new ArchetypeChooserModel<G, A, R>(); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -33,7 +33,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.utils.StringUtils; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -187,7 +186,7 @@ * {@inheritDoc} */ @Override - public void collectTempList(@NotNull final MapViewSettings mapViewSettings, final List<G> objects) { + public void collectTempList(@NotNull final List<G> objects) { final Collection<G> tailList = new ArrayList<G>(); for (final G gameObject : objects) { Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReader.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReader.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReader.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -30,7 +30,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.utils.IOUtils; import org.jetbrains.annotations.NotNull; @@ -59,12 +58,11 @@ * instance * @param mapArchObjectFactory the map arch object factory instance * @param gameObjectParser the game object parser instance - * @param mapViewSettings the map view settings instance * @param file the file to open * @throws IOException in case the file couldn't be read * @throws InvalidMapFormatException in case the file is in wrong format */ - public DefaultMapReader(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final File file) throws IOException { + public DefaultMapReader(@NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final File file) throws IOException { final FileInputStream fis = new FileInputStream(file); try { final InputStreamReader isr = new InputStreamReader(fis, IOUtils.MAP_ENCODING); @@ -85,7 +83,7 @@ fis.close(); } - gameObjectParser.collectTempList(mapViewSettings, objects); + gameObjectParser.collectTempList(objects); } /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReaderFactory.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReaderFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/DefaultMapReaderFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -53,24 +52,16 @@ private final GameObjectParserFactory<G, A, R> gameObjectParserFactory; /** - * The {@link MapViewSettings} instance to use. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * Creates a new instance. * @param mapArchObjectFactory the map arch object factory instance * @param mapArchObjectParserFactory the map arch object parser factory * instance * @param gameObjectParserFactory the game object parser factory instance - * @param mapViewSettings the map view settings instance */ - public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory, @NotNull final MapViewSettings mapViewSettings) { + public DefaultMapReaderFactory(@NotNull final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull final MapArchObjectParserFactory<A> mapArchObjectParserFactory, @NotNull final GameObjectParserFactory<G, A, R> gameObjectParserFactory) { this.mapArchObjectFactory = mapArchObjectFactory; this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.gameObjectParserFactory = gameObjectParserFactory; - this.mapViewSettings = mapViewSettings; } /** @@ -80,7 +71,7 @@ @Override public MapReader<G, A> newMapReader(@NotNull final File file) throws IOException { final GameObjectParser<G, A, R> gameObjectParser = gameObjectParserFactory.newGameObjectParser(); - return new DefaultMapReader<G, A, R>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapViewSettings, file); + return new DefaultMapReader<G, A, R>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, file); } } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/GameObjectParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/GameObjectParser.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/GameObjectParser.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -27,7 +27,6 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -76,10 +75,9 @@ /** * Browse first through the archetype list and attach map arches to it then * browse through the face list and try to find the pictures. - * @param mapViewSettings the map view settings instance * @param objects the list of game objects to collect */ - void collectTempList(@NotNull MapViewSettings mapViewSettings, List<G> objects); + void collectTempList(@NotNull List<G> objects); /** * Returns the modified fields of a {@link GameObject}. These fields are Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/resource/AbstractResources.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/resource/AbstractResources.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/resource/AbstractResources.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -29,7 +29,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.japi.swing.misc.Progress; import org.jetbrains.annotations.NotNull; @@ -53,12 +52,6 @@ private final ArchetypeSet<G, A, R> archetypeSet; /** - * The {@link MapViewSettings} instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * Whether the resources have been loaded. */ private boolean loaded; @@ -72,12 +65,10 @@ * Creates a new instance. * @param gameObjectParser the game object parser to use * @param archetypeSet the archetype set to update - * @param mapViewSettings the map view settings instance */ - protected AbstractResources(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final MapViewSettings mapViewSettings) { + protected AbstractResources(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ArchetypeSet<G, A, R> archetypeSet) { this.gameObjectParser = gameObjectParser; this.archetypeSet = archetypeSet; - this.mapViewSettings = mapViewSettings; } /** @@ -85,7 +76,7 @@ * @param invObjects all archetypes */ private void finishRead(@NotNull final List<G> invObjects) { - gameObjectParser.collectTempList(mapViewSettings, invObjects); + gameObjectParser.collectTempList(invObjects); archetypeSet.connectFaces(); // attach faces to arches } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/io/DefaultMapReaderTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/io/DefaultMapReaderTest.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/io/DefaultMapReaderTest.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -32,8 +32,6 @@ import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; import net.sf.gridarta.utils.Size2D; import org.junit.Assert; import org.junit.Test; @@ -69,8 +67,7 @@ mapModel.insertArchToMap(arch1x1, null, new Point(0, 0), false); mapModel.insertArchToMap(arch1x1, null, new Point(1, 0), false); mapControl.save(); - final MapViewSettings mapViewSettings = new TestMapViewSettings(); - final DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype> reader = mapControlCreator.newMapReader(mapViewSettings, mapFile); + final DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype> reader = mapControlCreator.newMapReader(mapFile); final List<TestGameObject> objects = reader.getGameObjects(); Assert.assertEquals(6, objects.size()); Assert.assertEquals("arch1x1", objects.get(0).getArchetype().getArchetypeName()); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/io/TestMapReaderFactory.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/io/TestMapReaderFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/io/TestMapReaderFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -53,24 +52,16 @@ private final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser; /** - * The {@link MapViewSettings} instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * Creates a new instance. * @param mapArchObjectParserFactory the map arch object parser factory * instance * @param mapArchObjectFactory the map arch object factory instance * @param gameObjectParser the game object parser instance - * @param mapViewSettings the map view settings instance */ - public TestMapReaderFactory(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final MapViewSettings mapViewSettings) { + public TestMapReaderFactory(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser) { this.mapArchObjectParserFactory = mapArchObjectParserFactory; this.mapArchObjectFactory = mapArchObjectFactory; this.gameObjectParser = gameObjectParser; - this.mapViewSettings = mapViewSettings; } /** @@ -79,7 +70,7 @@ @NotNull @Override public MapReader<TestGameObject, TestMapArchObject> newMapReader(@NotNull final File file) throws IOException { - return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapViewSettings, file); + return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, file); } } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapcontrol/TestMapControlCreator.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -49,8 +49,6 @@ import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapmodel.TestMapModelHelper; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; import net.sf.gridarta.model.settings.ProjectSettings; @@ -157,8 +155,7 @@ exitMatcher = new ExitMatcher<TestGameObject, TestMapArchObject, TestArchetype>(exitGameObjectMatcher); mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); gameObjectParser = mapModelCreator.newGameObjectParser(); - final TestMapViewSettings mapViewSettings = new TestMapViewSettings(); - mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapViewSettings); + mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser); projectSettings = new TestProjectSettings(); mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); @@ -324,15 +321,13 @@ /** * Creates a new instance. - * @param mapViewSettings the map view settings to pass to the map reader - * constructor * @param mapFile the file to pass to the map reader constructor * @return the map reader instance * @throws IOException if the map reader cannot be created */ @NotNull - public DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype> newMapReader(@NotNull final MapViewSettings mapViewSettings, @NotNull final File mapFile) throws IOException { - return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapViewSettings, mapFile); + public DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype> newMapReader(@NotNull final File mapFile) throws IOException { + return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, mapFile); } } Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -40,7 +40,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.mapcontrol.MapControlFactory; import net.sf.gridarta.model.mapmodel.MapModelFactory; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.ProjectSettings; @@ -128,7 +127,6 @@ * @param gameObjectParser the game object parser to use * @param archetypeSet the archetype set to use * @param archetypeParser the archetype parser to use - * @param mapViewSettings the map view settings to use * @param faceObjects the face objects to use * @param animationObjects the animation objects to use * @param archFaceProvider the arch face provider to use @@ -138,7 +136,7 @@ * @return the new instance */ @NotNull - AbstractResources<G, A, R> newResources(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AbstractArchetypeParser<G, A, R, ?> archetypeParser, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull SmoothFaces smoothFaces); + AbstractResources<G, A, R> newResources(@NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final AbstractArchetypeParser<G, A, R, ?> archetypeParser, @NotNull final FaceObjects faceObjects, @NotNull final AnimationObjects animationObjects, @NotNull final ArchFaceProvider archFaceProvider, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull SmoothFaces smoothFaces); /** * Creates a new {@link MapArchObjectParserFactory} instance. Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:48:53 UTC (rev 9437) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 18:57:22 UTC (rev 9438) @@ -218,7 +218,7 @@ gameObjectParser = gameObjectParserFactory.newGameObjectParser(); final AbstractArchetypeParser<G, A, R, ?> archetypeParser = projectFactory.newArchetypeParser(errorView, gameObjectParser, animationObjects, archetypeSet, gameObjectFactory, projectSettings, smoothFaces); final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); - resources = projectFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, mapViewSettings, faceObjects, animationObjects, archFaceProvider, faceObjectProviders, smoothFaces); + resources = projectFactory.newResources(gameObjectParser, archetypeSet, archetypeParser, faceObjects, animationObjects, archFaceProvider, faceObjectProviders, smoothFaces); loadArchetypes(errorView, projectSettings, archetypeSet, archetypeChooserModel, resources, configSource); faceObjectProviders.addFaceObjectProvidersListener(new FaceObjectProvidersListener() { @@ -230,7 +230,7 @@ }); final MapArchObjectParserFactory<A> mapArchObjectParserFactory = projectFactory.newMapArchObjectParserFactory(); mapArchObjectFactory = projectFactory.newMapArchObjectFactory(projectSettings); - mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory, mapViewSettings); + mapReaderFactory = new DefaultMapReaderFactory<G, A, R>(mapArchObjectFactory, mapArchObjectParserFactory, gameObjectParserFactory); final MapWriter<G, A, R> mapWriter = new DefaultMapWriter<G, A, R>(mapArchObjectParserFactory, gameObjectParser); final ValidatorPreferences validatorPreferences = new DefaultValidatorPreferences(); gameObjectMatchers = loadGameObjectMatchers(xmlHelper, errorView, projectSettings); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 19:06:35
|
Revision: 9439 http://sourceforge.net/p/gridarta/code/9439 Author: akirschbaum Date: 2013-10-15 19:06:21 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove dependency MapCursor -> MapViewSettings. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -405,8 +405,8 @@ */ @NotNull @Override - public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager, @NotNull final MapViewSettings mapViewSettings) { - return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, isoMapSquareInfo.getXLen(), isoMapSquareInfo.getYLen(), pathManager, mapViewSettings); + public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager) { + return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, isoMapSquareInfo.getXLen(), isoMapSquareInfo.getYLen(), pathManager); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -296,8 +296,8 @@ */ @NotNull @Override - public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager, @NotNull final MapViewSettings mapViewSettings) { - return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, IGUIConstants.SQUARE_WIDTH, IGUIConstants.SQUARE_HEIGHT, pathManager, mapViewSettings); + public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager) { + return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, IGUIConstants.SQUARE_WIDTH, IGUIConstants.SQUARE_HEIGHT, pathManager); } /** Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -404,8 +404,8 @@ */ @NotNull @Override - public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager, @NotNull final MapViewSettings mapViewSettings) { - return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, isoMapSquareInfo.getXLen(), isoMapSquareInfo.getYLen(), pathManager, mapViewSettings); + public MapViewFactory<GameObject, MapArchObject, Archetype> newMapViewFactory(@NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final PathManager pathManager) { + return new DefaultMapViewFactory<GameObject, MapArchObject, Archetype>(rendererFactory, isoMapSquareInfo.getXLen(), isoMapSquareInfo.getYLen(), pathManager); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/DeleteArchAction.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.utils.EditorAction; import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; @@ -37,6 +38,12 @@ public class DeleteArchAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractMapCursorAction<G, A, R> implements EditorAction { /** + * The {@link MapViewSettings} for querying options. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** * The {@link Action} associated with this editor action. Set to {@code * null} if no action is associated. */ @@ -46,9 +53,11 @@ /** * Creates a new instance. * @param mapViewManager the map view manager + * @param mapViewSettings the map view settings for querying options */ - public DeleteArchAction(@NotNull final MapViewManager<G, A, R> mapViewManager) { + public DeleteArchAction(@NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapViewSettings mapViewSettings) { super(mapViewManager); + this.mapViewSettings = mapViewSettings; } /** @@ -74,7 +83,7 @@ */ private boolean doDeleteArch(final boolean performAction) { final MapCursor<G, A, R> mapCursor = getActiveMapCursor(); - return mapCursor != null && mapCursor.deleteSelectedGameObject(performAction); + return mapCursor != null && mapCursor.deleteSelectedGameObject(performAction, mapViewSettings.isAutojoin()); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -30,7 +30,6 @@ import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; @@ -70,25 +69,17 @@ private final PathManager pathManager; /** - * The {@link MapViewSettings} instance. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * Creates a new instance. * @param rendererFactory the renderer factory to use * @param xScrollDistance the x distance when scrolling * @param yScrollDistance the y distance when scrolling * @param pathManager the path manager for converting path names - * @param mapViewSettings the map view settings instance */ - public DefaultMapViewFactory(@NotNull final RendererFactory<G, A, R> rendererFactory, final int xScrollDistance, final int yScrollDistance, @NotNull final PathManager pathManager, @NotNull final MapViewSettings mapViewSettings) { + public DefaultMapViewFactory(@NotNull final RendererFactory<G, A, R> rendererFactory, final int xScrollDistance, final int yScrollDistance, @NotNull final PathManager pathManager) { this.rendererFactory = rendererFactory; this.xScrollDistance = xScrollDistance; this.yScrollDistance = yScrollDistance; this.pathManager = pathManager; - this.mapViewSettings = mapViewSettings; } /** @@ -101,7 +92,7 @@ final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); final AbstractMapRenderer<G, A, R> renderer = mapControl.isPickmap() ? rendererFactory.newPickmapRenderer(mapModel, mapGrid) : rendererFactory.newMapRenderer(mapModel, mapGrid); renderer.setFocusable(true); - final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, pathManager, mapGrid, new MapCursor<G, A, R>(mapGrid, mapModel, mapViewSettings), renderer, viewPosition, xScrollDistance, yScrollDistance); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, pathManager, mapGrid, new MapCursor<G, A, R>(mapGrid, mapModel), renderer, viewPosition, xScrollDistance, yScrollDistance); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -466,7 +466,7 @@ final MapCursor<G, A, R> mapCursor = this.mapCursor; if (mapCursor != null && index < model.getSize()) { setSelectedIndex(index); - mapCursor.deleteSelectedGameObject(true); + mapCursor.deleteSelectedGameObject(true, mapViewSettings.isAutojoin()); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -135,12 +135,11 @@ * Creates a new {@link MapViewFactory} instance. * @param rendererFactory the renderer factory to use * @param pathManager the path manager for converting path names - * @param mapViewSettings the map view settings to pass to the created map * view factories * @return the new instance */ @NotNull - MapViewFactory<G, A, R> newMapViewFactory(@NotNull RendererFactory<G, A, R> rendererFactory, @NotNull PathManager pathManager, @NotNull MapViewSettings mapViewSettings); + MapViewFactory<G, A, R> newMapViewFactory(@NotNull RendererFactory<G, A, R> rendererFactory, @NotNull PathManager pathManager); /** * Creates a new {@link AppPreferencesModel} instance. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -313,7 +313,7 @@ */ public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { this.projectModel = projectModel; - final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, pathManager, projectModel.getMapViewSettings()); + final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, pathManager); mapViewsManager = new MapViewsManager<G, A, R>(projectModel.getMapViewSettings(), mapViewFactory, projectModel.getMapManager(), projectModel.getPickmapManager()); scriptExtension = editorFactory.getScriptExtension(); final DisplayMode<G, A, R> displayModeGameObjectNames = new DisplayNameCellRenderer<G, A, R>(projectModel.getFaceObjectProviders()); @@ -517,7 +517,7 @@ createAction("startStopDrag", "Map Cursor,Map/Selection", new StartStopDragAction<G, A, R>(mapViewManager)); createAction("releaseDrag", "Map Cursor,Map/Selection", new ReleaseDragAction<G, A, R>(mapViewManager)); createAction("insertArch", "Map Cursor,Map", new InsertArchAction<G, A, R>(mapViewManager, objectChooser, projectModel.getMapViewSettings())); - createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager)); + createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager, projectModel.getMapViewSettings())); createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); Modified: trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -76,7 +76,7 @@ // select + cut final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = TestMapControlCreatorUtils.newCopyBuffer(testMapControlCreator); - final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = TestMapControlCreatorUtils.newMapView(mapControl, testMapControlCreator.getMapModelCreator().getMapViewSettings()); + final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = TestMapControlCreatorUtils.newMapView(mapControl); mapView.getMapGrid().select(new Point(1, 1), SelectionMode.ADD); copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); Modified: trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -27,7 +27,6 @@ import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -38,21 +37,6 @@ public class TestMapViewFactory implements MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype> { /** - * The {@link MapViewSettings} to pass to the created map view factories. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** - * Creates a new instance. - * @param mapViewSettings the map view settings instance to pass to the - * created map view factories - */ - public TestMapViewFactory(@NotNull final MapViewSettings mapViewSettings) { - this.mapViewSettings = mapViewSettings; - } - - /** * {@inheritDoc} */ @NotNull @@ -60,7 +44,7 @@ public MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @Nullable final Point viewPosition, final int viewCounter) { final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - return new TestMapView(mapControl, mapGrid, new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(mapGrid, mapModel, mapViewSettings)); + return new TestMapView(mapControl, mapGrid, new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(mapGrid, mapModel)); } } Modified: trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/gridarta/src/test/java/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -41,7 +41,6 @@ import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -59,14 +58,13 @@ /** * Creates a new {@link MapView} instance. * @param mapControl the associated map control - * @param mapViewSettings the map view settings instance to use * @return the map view instance */ @NotNull - public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapViewSettings mapViewSettings) { + public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); - return new TestMapView(mapControl, mapGrid, new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(mapGrid, mapModel, mapViewSettings)); + return new TestMapView(mapControl, mapGrid, new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(mapGrid, mapModel)); } /** @@ -87,7 +85,7 @@ */ @NotNull public static MapViewsManager<TestGameObject, TestMapArchObject, TestArchetype> newMapViewsManager(@NotNull final TestMapControlCreator mapControlCreator) { - final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype> mapViewFactory = new TestMapViewFactory(mapControlCreator.getMapModelCreator().getMapViewSettings()); + final MapViewFactory<TestGameObject, TestMapArchObject, TestArchetype> mapViewFactory = new TestMapViewFactory(); return new MapViewsManager<TestGameObject, TestMapArchObject, TestArchetype>(mapControlCreator.getMapModelCreator().getMapViewSettings(), mapViewFactory, mapControlCreator.getMapManager(), mapControlCreator.getPickmapManager()); } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -33,7 +33,6 @@ import net.sf.gridarta.model.mapgrid.SelectionMode; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.utils.EventListenerList2; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -91,12 +90,6 @@ private final MapModel<G, A, R> mapModel; /** - * The {@link MapViewSettings} for querying options. - */ - @NotNull - private final MapViewSettings mapViewSettings; - - /** * Used to test if coordinates are on the map. Created by MapGrid. */ @NotNull @@ -171,12 +164,10 @@ * construction. * @param mapGrid Cursor is bound to this grid * @param mapModel the map model of this cursor - * @param mapViewSettings the map view settings for querying options */ - public MapCursor(@NotNull final MapGrid mapGrid, @NotNull final MapModel<G, A, R> mapModel, @NotNull final MapViewSettings mapViewSettings) { + public MapCursor(@NotNull final MapGrid mapGrid, @NotNull final MapModel<G, A, R> mapModel) { this.mapGrid = mapGrid; this.mapModel = mapModel; - this.mapViewSettings = mapViewSettings; mapRec = mapGrid.getMapRec(); final MapGridListener mapGridListener = new MapGridListener() { @@ -680,9 +671,10 @@ * Deletes the selected game object. Does nothing if no game object is * selected. * @param performAction whether the action should be performed + * @param autoJoin whether to preform auto-joining * @return whether the action was or can be performed */ - public boolean deleteSelectedGameObject(final boolean performAction) { + public boolean deleteSelectedGameObject(final boolean performAction, final boolean autoJoin) { if (!onMap) { return false; } @@ -701,7 +693,7 @@ mapModel.beginTransaction("Delete"); // TODO; I18N/L10N try { G nextGameObject = mapSquare.getNext(gameObject); - mapModel.removeGameObject(gameObject, mapViewSettings.isAutojoin()); + mapModel.removeGameObject(gameObject, autoJoin); if (nextGameObject == null) { nextGameObject = mapSquare.getFirst(); } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-10-15 18:57:22 UTC (rev 9438) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-10-15 19:06:21 UTC (rev 9439) @@ -30,7 +30,6 @@ import net.sf.gridarta.model.mapgrid.SelectionMode; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; -import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -67,7 +66,7 @@ private static MapCursor<TestGameObject, TestMapArchObject, TestArchetype> createCursor(@NotNull final MapGrid grid) { final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final Size2D gridSize = grid.getSize(); - final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(grid, mapModelCreator.newMapModel(gridSize.getWidth(), gridSize.getHeight()), new TestMapViewSettings()); + final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(grid, mapModelCreator.newMapModel(gridSize.getWidth(), gridSize.getHeight())); cursor.addMapCursorListener(listener); Assert.assertFalse("MapCursor has to be disabled when created.", cursor.isActive()); listener.changedPosCounter = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 19:11:54
|
Revision: 9440 http://sourceforge.net/p/gridarta/code/9440 Author: akirschbaum Date: 2013-10-15 19:11:50 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove dependency ProjectModel -> MapViewSettings. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 19:06:21 UTC (rev 9439) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 19:11:50 UTC (rev 9440) @@ -184,6 +184,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mappathnormalizer.MapPathNormalizer; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; import net.sf.gridarta.model.pickmapsettings.DefaultPickmapSettings; @@ -296,6 +297,7 @@ * Creates a new instance. * @param projectModel the project model to edit * @param projectSettings the project settings instance + * @param mapViewSettings the map view settings * @param editorSettings the editor settings instance * @param errorView the error view for reporting errors * @param guiUtils the gui utils for creating icons @@ -311,10 +313,10 @@ * @param rendererFactory the renderer factory instance * @param filterControl the filter control instance */ - public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { + public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { this.projectModel = projectModel; final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, pathManager); - mapViewsManager = new MapViewsManager<G, A, R>(projectModel.getMapViewSettings(), mapViewFactory, projectModel.getMapManager(), projectModel.getPickmapManager()); + mapViewsManager = new MapViewsManager<G, A, R>(mapViewSettings, mapViewFactory, projectModel.getMapManager(), projectModel.getPickmapManager()); scriptExtension = editorFactory.getScriptExtension(); final DisplayMode<G, A, R> displayModeGameObjectNames = new DisplayNameCellRenderer<G, A, R>(projectModel.getFaceObjectProviders()); final DisplayMode<G, A, R> displayModeArchetypeNames = new ArchetypeNameCellRenderer<G, A, R>(projectModel.getFaceObjectProviders()); @@ -351,7 +353,7 @@ final GameObjectMatcher belowFloorMatcher = projectModel.getGameObjectMatchers().getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_below_floor", "below_floor"); final GameObjectMatcher systemObjectMatcher = projectModel.getGameObjectMatchers().getMatcher("system_system_object"); final InsertionModeSet<G, A, R> insertionModeSet = new InsertionModeSet<G, A, R>(projectModel.getTopmostInsertionMode(), floorMatcher, wallMatcher, belowFloorMatcher, systemObjectMatcher); - final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(projectModel.getMapViewSettings(), projectModel.getGameObjectFactory(), projectModel.getMapArchObjectFactory(), projectModel.getMapModelFactory(), insertionModeSet); + final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings, projectModel.getGameObjectFactory(), projectModel.getMapArchObjectFactory(), projectModel.getMapModelFactory(), insertionModeSet); final FindDialogManager<G, A, R> findDialogManager = new FindDialogManager<G, A, R>(parent, mapViewManager); final Exiter exiter = new DefaultExiter(parent); scriptEditControl = new ScriptEditControl(editorFactory.getScriptFileFilter(), scriptExtension, parent, projectSettings.getMapsDirectory(), preferences, exiter); @@ -373,14 +375,14 @@ final DelayedMapModelListenerManager<G, A, R> delayedMapModelListenerManager = new DelayedMapModelListenerManager<G, A, R>(projectModel.getMapManager(), exiter); final Control<?, G, A, R> lockedItemsControl = new LockedItemsControl<G, A, R>(mapViewManager, delayedMapModelListenerManager, editorFactory.getLockedItemsTypeNumbers()); final EnterMap<G, A, R> enterMap = new EnterMap<G, A, R>(parent, editorFactory.getDirectionMap(), mapPathNormalizer, fileControl, mapViewsManager); - final EditorAction mapActions = new MapActions<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, editorFactory.isAllowRandomMapParameters(), mapPropertiesDialogFactory, projectModel.getMapViewSettings(), mapViewsManager, enterMap); + final EditorAction mapActions = new MapActions<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, editorFactory.isAllowRandomMapParameters(), mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); final File scriptsFile = new File(projectSettings.getMapsDirectory(), editorFactory.getScriptsDir()); updaterManager = new UpdaterManager(exiter, projectModel.getMapManager(), parent, editorFactory.getGridartaJarFilename()); final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, projectModel.getArchetypeTypeSet()); final EditorAction undoControl = new UndoControl<G, A, R>(projectModel.getMapManager(), projectModel.getGameObjectFactory(), projectModel.getGameObjectMatchers()); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); - final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(projectModel.getMapViewSettings(), projectModel.getMapManager()); + final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, projectModel.getMapManager()); final EditorAction mapFileActions = new MapFileActions<G, A, R>(imageCreator2, projectModel.getMapManager(), mapViewsManager, mapViewManager, fileControl, parent); final BookmarksMapMenuPreferences bookmarksMapMenuPreferences = new BookmarksMapMenuPreferences(); final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); @@ -393,14 +395,14 @@ final ArchetypeChooserView<G, A, R> archetypeChooserView = new ArchetypeChooserView<G, A, R>(editorFactory.isCreateDirectionPane(), projectModel.getArchetypeChooserModel(), projectModel.getFaceObjectProviders(), displayGameObjectNamesAction, displayArchetypeNamesAction, displayIconsOnlyAction, displayModeGameObjectNames, displayModeArchetypeNames, displayModeIconsOnly); final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(projectModel.getArchetypeChooserModel(), archetypeChooserView, editorFactory.isCreateDirectionPane(), projectModel.getFaceObjectProviders()); final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl, projectModel.getArchetypeChooserModel(), pickmapChooserModel, projectModel.getArchetypeTypeSet()); - final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(projectModel.getMapViewSettings(), selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); - final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, projectModel.getMapManager(), selectedSquareModel, projectModel.getGameObjectFactory(), projectModel.getMapViewSettings()); + final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); + final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, projectModel.getMapManager(), selectedSquareModel, projectModel.getGameObjectFactory(), mapViewSettings); final GameObjectTab<G, A, R> gameObjectTab = new GameObjectTab<G, A, R>("gameObject", gameObjectAttributesControl, Location.BOTTOM, false, 0, true); newMapDialogFactory.setObjectChooser(objectChooser); final ReplaceDialogManager<G, A, R> replaceDialogManager = new ReplaceDialogManager<G, A, R>(parent, copyBuffer, objectChooser, mapViewManager, projectModel.getFaceObjectProviders(), insertionModeSet); final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory = new PluginParameterViewFactory<G, A, R>(projectModel.getArchetypeSet(), gameObjectAttributesModel, objectChooser, projectModel.getMapManager(), projectModel.getFaceObjectProviders()); final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, pluginModel, parent, pluginParameterViewFactory, scriptsFile, systemIcons); - final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, projectModel.getMapViewSettings(), projectModel.getArchetypeSet(), copyBuffer, objectChooser, projectModel.getMapManager(), mapViewManager, insertionModeSet); + final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, mapViewSettings, projectModel.getArchetypeSet(), copyBuffer, objectChooser, projectModel.getMapManager(), mapViewManager, insertionModeSet); final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(mapViewManager); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, projectModel.getMapManager())); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, projectModel.getMapManager())); @@ -436,7 +438,7 @@ createAction("enterSouthWestMap", "Map Navigation", mapActions); createAction("enterNorthWestMap", "Map Navigation", mapActions); createToggleAction("gridVisible", "Map Navigation", mapActions); - createToggleAction("lightVisible", "Map Navigation", new LightVisibleAction(projectModel.getMapViewSettings())); + createToggleAction("lightVisible", "Map Navigation", new LightVisibleAction(mapViewSettings)); createToggleAction("smoothing", "Map Navigation", mapActions); createToggleAction("doubleFaces", "Map Navigation", mapActions); createToggleAction("tileShow", "Map Navigation", mapActions); @@ -516,8 +518,8 @@ createAction("subFromSelection", "Map Cursor,Map/Selection", new SubFromSelectionAction<G, A, R>(mapViewManager)); createAction("startStopDrag", "Map Cursor,Map/Selection", new StartStopDragAction<G, A, R>(mapViewManager)); createAction("releaseDrag", "Map Cursor,Map/Selection", new ReleaseDragAction<G, A, R>(mapViewManager)); - createAction("insertArch", "Map Cursor,Map", new InsertArchAction<G, A, R>(mapViewManager, objectChooser, projectModel.getMapViewSettings())); - createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager, projectModel.getMapViewSettings())); + createAction("insertArch", "Map Cursor,Map", new InsertArchAction<G, A, R>(mapViewManager, objectChooser, mapViewSettings)); + createAction("deleteArch", "Map Cursor,Map", new DeleteArchAction<G, A, R>(mapViewManager, mapViewSettings)); createAction("selectArchAbove", "Map Cursor,Selected Square View", new SelectArchBelowAction<G, A, R>(mapViewManager)); createAction("selectArchBelow", "Map Cursor,Selected Square View", new SelectArchAboveAction<G, A, R>(mapViewManager)); createAction("archAttributes", "Map", new ArchAttributesAction<G, A, R>(mapViewManager, gameObjectAttributesDialogFactory)); @@ -539,7 +541,7 @@ mainViewFrame.add(new MainToolbar(editorSettings).getComponent(), BorderLayout.NORTH); mainViewFrame.add(statusBar, BorderLayout.SOUTH); mainView.addTab(gameObjectTab); - mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, projectModel.getMapViewSettings(), editorFactory.getCompassIcon(guiUtils), projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); + mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, editorFactory.getCompassIcon(guiUtils), projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, false, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, false, 3, true)); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-15 19:06:21 UTC (rev 9439) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-15 19:11:50 UTC (rev 9440) @@ -55,6 +55,8 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapviewsettings.DefaultMapViewSettings; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.NamedGameObjectMatcher; import net.sf.gridarta.model.scripts.ScriptArchUtils; import net.sf.gridarta.model.scripts.ScriptedEventFactory; @@ -219,7 +221,8 @@ final NamedFilter defaultNamedFilterList = new NamedFilter(projectModel.getGameObjectMatchers().getFilters()); final FilterControl<G, A, R> filterControl = new DefaultFilterControl<G, A, R>(defaultNamedFilterList); - final RendererFactory<G, A, R> rendererFactory = editorFactory.newRendererFactory(projectModel.getMapViewSettings(), filterControl, projectModel.getGameObjectParser(), projectModel.getFaceObjectProviders(), systemIcons, projectModel.getSmoothFaces()); + final MapViewSettings mapViewSettings = new DefaultMapViewSettings(); + final RendererFactory<G, A, R> rendererFactory = editorFactory.newRendererFactory(mapViewSettings, filterControl, projectModel.getGameObjectParser(), projectModel.getFaceObjectProviders(), systemIcons, projectModel.getSmoothFaces()); final NamedFilter defaultFilterList = new NamedFilter(Collections.<NamedGameObjectMatcher>emptyList()); final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(projectModel.getArchetypeSet(), projectModel.getMapManager(), defaultFilterList, projectSettings); @@ -239,7 +242,7 @@ try { switch (mode) { case NORMAL: - returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, projectSettings, editorSettings, pathManager, systemIcons, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor); + returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, projectSettings, mapViewSettings, editorSettings, pathManager, systemIcons, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor); break; case BATCH_PNG: @@ -327,6 +330,7 @@ * @param pluginModel the plugin model to use * @param projectModel the project model to use * @param projectSettings the project settings + * @param mapViewSettings the map view settings * @param editorSettings the editor settings * @param pathManager the path manager * @param systemIcons the system icons for creating icons @@ -336,13 +340,13 @@ * @param scriptArchEditor the script arch editor * @return return code suitable for passing to {@link System#exit(int)} */ - private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final EditorSettings editorSettings, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { + private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { final GUIMainControl<?, ?, ?>[] guiMainControl = new GUIMainControl<?, ?, ?>[1]; final Runnable runnable = new Runnable() { @Override public void run() { - guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, projectSettings, editorSettings, errorView, guiUtils, pluginModel, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, editorFactory, pathManager, systemIcons, configSourceFactory, rendererFactory, filterControl); + guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, projectSettings, mapViewSettings, editorSettings, errorView, guiUtils, pluginModel, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, editorFactory, pathManager, systemIcons, configSourceFactory, rendererFactory, filterControl); } }; Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 19:06:21 UTC (rev 9439) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-15 19:11:50 UTC (rev 9440) @@ -73,8 +73,6 @@ import net.sf.gridarta.model.mapmodel.InsertionMode; import net.sf.gridarta.model.mapmodel.MapModelFactory; import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; -import net.sf.gridarta.model.mapviewsettings.DefaultMapViewSettings; -import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.GameObjectMatchersParser; @@ -142,9 +140,6 @@ private final GameObjectMatchers gameObjectMatchers; @NotNull - private final MapViewSettings mapViewSettings = new DefaultMapViewSettings(); - - @NotNull private final GameObjectParser<G, A, R> gameObjectParser; @NotNull @@ -476,11 +471,6 @@ } @NotNull - public MapViewSettings getMapViewSettings() { - return mapViewSettings; - } - - @NotNull public GameObjectParser<G, A, R> getGameObjectParser() { return gameObjectParser; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 19:37:21
|
Revision: 9442 http://sourceforge.net/p/gridarta/code/9442 Author: akirschbaum Date: 2013-10-15 19:37:13 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove NewMapDialogFactory.setPickmapChooserView(). Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -42,6 +42,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserView; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.EditorFactory; @@ -432,8 +433,8 @@ */ @NotNull @Override - public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final Component parent) { - return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, parent); + public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final PickmapChooserView<GameObject, MapArchObject, Archetype> pickmapChooserView, @NotNull final Component parent) { + return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, pickmapChooserView, parent); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -40,6 +40,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserView; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.EditorFactory; @@ -323,8 +324,8 @@ */ @NotNull @Override - public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final Component parent) { - return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, parent); + public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final PickmapChooserView<GameObject, MapArchObject, Archetype> pickmapChooserView, @NotNull final Component parent) { + return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, 0, false, false, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, pickmapChooserView, parent); } /** Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -42,6 +42,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserView; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.maincontrol.EditorFactory; @@ -431,8 +432,8 @@ */ @NotNull @Override - public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final Component parent) { - return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, parent); + public NewMapDialogFactory<GameObject, MapArchObject, Archetype> newNewMapDialogFactory(@NotNull final MapViewsManager<GameObject, MapArchObject, Archetype> mapViewsManager, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final PickmapChooserView<GameObject, MapArchObject, Archetype> pickmapChooserView, @NotNull final Component parent) { + return new NewMapDialogFactory<GameObject, MapArchObject, Archetype>(mapViewsManager, mapArchObjectFactory, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPSIZE, IGUIConstants.DEF_MAPDIFFICULTY, true, true, IGUIConstants.DEF_PICKMAP_WIDTH, IGUIConstants.DEF_PICKMAP_HEIGHT, pickmapChooserView, parent); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/newmap/NewMapDialogFactory.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -89,7 +89,7 @@ * The pickmap chooser control. */ @NotNull - private PickmapChooserView<G, A, R> pickmapChooserView; + private final PickmapChooserView<G, A, R> pickmapChooserView; /** * The object chooser instance. @@ -114,9 +114,11 @@ * @param showMapDifficulty whether to show the "mapDifficulty" field * @param defaultPickmapWidth the default width for new pickmaps * @param defaultPickmapHeight the default height for new pickmaps + * @param pickmapChooserView the pickmap chooser view for creating new + * pickmaps * @param parent the parent component */ - public NewMapDialogFactory(@NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight, @NotNull final Component parent) { + public NewMapDialogFactory(@NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final MapArchObjectFactory<A> mapArchObjectFactory, final int defaultMapWidth, final int defaultMapHeight, final int defaultMapDifficulty, final boolean showMapDifficulty, final boolean showMapSizeDefault, final int defaultPickmapWidth, final int defaultPickmapHeight, @NotNull final PickmapChooserView<G, A, R> pickmapChooserView, @NotNull final Component parent) { this.mapViewsManager = mapViewsManager; this.mapArchObjectFactory = mapArchObjectFactory; this.defaultMapWidth = defaultMapWidth; @@ -126,15 +128,11 @@ this.showMapDifficulty = showMapDifficulty; this.defaultPickmapWidth = defaultPickmapWidth; this.defaultPickmapHeight = defaultPickmapHeight; + this.pickmapChooserView = pickmapChooserView; this.parent = parent; } @Deprecated - public void setPickmapChooserView(@NotNull final PickmapChooserView<G, A, R> pickmapChooserView) { - this.pickmapChooserView = pickmapChooserView; - } - - @Deprecated public void setObjectChooser(@NotNull final ObjectChooser<G, A, R> objectChooser) { this.objectChooser = objectChooser; } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -30,6 +30,7 @@ import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.renderer.RendererFactory; +import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserView; import net.sf.gridarta.gui.scripts.ScriptArchDataUtils; import net.sf.gridarta.gui.scripts.ScriptedEventEditor; import net.sf.gridarta.model.archetype.Archetype; @@ -134,8 +135,8 @@ /** * Creates a new {@link MapViewFactory} instance. * @param rendererFactory the renderer factory to use - * @param pathManager the path manager for converting path names - * view factories + * @param pathManager the path manager for converting path names view + * factories * @return the new instance */ @NotNull @@ -163,11 +164,13 @@ * Creates a new {@link NewMapDialogFactory} instance. * @param mapViewsManager the map views * @param mapArchObjectFactory the map arch object factory instance + * @param pickmapChooserView the pickmap chooser view for creating new + * pickmaps * @param parent the parent component of the dialogs * @return the new new map dialog factory instance */ @NotNull - NewMapDialogFactory<G, A, R> newNewMapDialogFactory(@NotNull MapViewsManager<G, A, R> mapViewsManager, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull Component parent); + NewMapDialogFactory<G, A, R> newNewMapDialogFactory(@NotNull MapViewsManager<G, A, R> mapViewsManager, @NotNull MapArchObjectFactory<A> mapArchObjectFactory, @NotNull PickmapChooserView<G, A, R> pickmapChooserView, @NotNull Component parent); /** * Creates a new {@link PreferencesGroup} instance. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 19:31:13 UTC (rev 9441) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-15 19:37:13 UTC (rev 9442) @@ -338,12 +338,11 @@ final ImageIcon icon = systemIcons.getAppIcon(); mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); final Frame parent = mainViewFrame; - newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, projectModel.getMapArchObjectFactory(), parent); final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); + final PickmapChooserView<G, A, R> pickmapChooserView = new PickmapChooserView<G, A, R>(pickmapChooserModel, mapFolderTree, projectModel.getMapArchObjectFactory(), projectModel.getMapReaderFactory(), projectModel.getPickmapManager()); + newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, projectModel.getMapArchObjectFactory(), pickmapChooserView, parent); final PickmapSettings pickmapSettings = new DefaultPickmapSettings(); - final PickmapChooserView<G, A, R> pickmapChooserView = new PickmapChooserView<G, A, R>(pickmapChooserModel, mapFolderTree, projectModel.getMapArchObjectFactory(), projectModel.getMapReaderFactory(), projectModel.getPickmapManager()); final PickmapChooserControl<G, A, R> pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapFolderTree, projectModel.getMapManager(), parent, mapViewsManager, pickmapChooserView); - newMapDialogFactory.setPickmapChooserView(pickmapChooserView); final CFTreasureListTree treasureListTree = new CFTreasureListTree(projectModel.getTreasureTree(), parent, projectModel.getArchetypeSet(), projectModel.getFaceObjectProviders(), systemIcons); final ImageIcon noFaceSquareIcon = systemIcons.getNoFaceSquareIcon(); final ImageIcon unknownSquareIcon = systemIcons.getUnknownSquareIcon(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 20:57:47
|
Revision: 9448 http://sourceforge.net/p/gridarta/code/9448 Author: akirschbaum Date: 2013-10-15 20:57:40 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Support undo operations if different maps are modified concurrently. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/model/src/main/java/net/sf/gridarta/model/undo/UndoModel.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-10-15 20:28:10 UTC (rev 9447) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-10-15 20:57:40 UTC (rev 9448) @@ -76,69 +76,6 @@ private int maxUndoStates = 100; /** - * Listener to be notified for map transactions. The same listener is - * registered for all known maps. - */ - @NotNull - private final MapTransactionListener<G, A, R> mapTransactionListener = new MapTransactionListener<G, A, R>() { - - /** - * Records the map state at transaction begin time. It is used to - * detect (and drop) edit operations that do not change the map - * state. - * - * XXX: since only one listener instance is used for all maps, it - * will not work if concurrent transactions occur - */ - @Nullable - private UndoState<G, A, R> undoState; - - /** - * Records the undo model at transaction begin time. - */ - @Nullable - private UndoModel<G, A, R> undoModel; - - @Override - public void preBeginTransaction() { - // ignore - } - - @Override - public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { - undoModel = undoModels.get(mapModel); - undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().createClone()); - } - - @Override - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { - final UndoState<G, A, R> savedUndoState = undoState; - assert savedUndoState != null; - final UndoModel<G, A, R> savedUndoModel = undoModel; - assert savedUndoModel != null; - if (savedSquares.isEmpty() && savedUndoState.getMapArchObject().equals(mapModel.getMapArchObject())) { - return; - } - - final SavedSquares<G, A, R> clonedSavedSquares = savedSquares.cloneAndClear(); - clonedSavedSquares.removeEmptySquares(savedUndoState.getMapArchObject().getMapSize()); - savedUndoState.setSavedSquares(clonedSavedSquares); - savedUndoModel.finish(savedUndoState); - if (maxUndoStates > 0) { - savedUndoModel.trimToSize(maxUndoStates); - } - - refreshMenus(); - } - - @Override - public void postEndTransaction() { - // ignore - } - - }; - - /** * Action for "undo" function. */ @Nullable @@ -167,8 +104,64 @@ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - undoModels.put(mapControl.getMapModel(), new UndoModel<G, A, R>(gameObjectFactory, gameObjectMatchers)); - mapControl.getMapModel().addMapTransactionListener(mapTransactionListener); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + final MapTransactionListener<G, A, R> mapTransactionListener = new MapTransactionListener<G, A, R>() { + + /** + * Records the map state at transaction begin time. It is + * used to detect (and drop) edit operations that do not + * change the map state. + */ + @Nullable + private UndoState<G, A, R> undoState; + + /** + * Records the undo model at transaction begin time. + */ + @Nullable + private UndoModel<G, A, R> undoModel; + + @Override + public void preBeginTransaction() { + // ignore + } + + @Override + public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { + undoModel = undoModels.get(mapModel); + undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().createClone()); + } + + @Override + public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { + final UndoState<G, A, R> savedUndoState = undoState; + assert savedUndoState != null; + final UndoModel<G, A, R> savedUndoModel = undoModel; + assert savedUndoModel != null; + if (savedSquares.isEmpty() && savedUndoState.getMapArchObject().equals(mapModel.getMapArchObject())) { + return; + } + + final SavedSquares<G, A, R> clonedSavedSquares = savedSquares.cloneAndClear(); + clonedSavedSquares.removeEmptySquares(savedUndoState.getMapArchObject().getMapSize()); + savedUndoState.setSavedSquares(clonedSavedSquares); + savedUndoModel.finish(savedUndoState); + if (maxUndoStates > 0) { + savedUndoModel.trimToSize(maxUndoStates); + } + + refreshMenus(); + } + + @Override + public void postEndTransaction() { + // ignore + } + + }; + + mapModel.addMapTransactionListener(mapTransactionListener); + undoModels.put(mapModel, new UndoModel<G, A, R>(gameObjectFactory, gameObjectMatchers, mapTransactionListener)); } @Override @@ -178,8 +171,9 @@ @Override public void mapClosed(@NotNull final MapControl<G, A, R> mapControl) { - undoModels.remove(mapControl.getMapModel()); - mapControl.getMapModel().removeMapTransactionListener(mapTransactionListener); + final UndoModel<G, A, R> undoModel = undoModels.remove(mapControl.getMapModel()); + assert undoModel != null; + mapControl.getMapModel().removeMapTransactionListener(undoModel.getMapTransactionListener()); } }; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/undo/UndoModel.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/undo/UndoModel.java 2013-10-15 20:28:10 UTC (rev 9447) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/undo/UndoModel.java 2013-10-15 20:57:40 UTC (rev 9448) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectFactory; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmodel.MapTransactionListener; import net.sf.gridarta.model.mapmodel.SavedSquares; import net.sf.gridarta.model.match.GameObjectMatchers; import org.jetbrains.annotations.NotNull; @@ -52,6 +53,12 @@ private final GameObjectMatchers gameObjectMatchers; /** + * The stored {@link MapTransactionListener}. + */ + @NotNull + private final MapTransactionListener<G, A, R> mapTransactionListener; + + /** * The undo stack. It consists of recorded {@link UndoState UndoStates} for * the associated {@link net.sf.gridarta.model.mapmodel.MapModel}. */ @@ -74,13 +81,25 @@ * Creates a new instance. * @param gameObjectFactory the game object factory to use * @param gameObjectMatchers the game object matchers to use + * @param mapTransactionListener the map transaction listener to store */ - public UndoModel(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers) { + public UndoModel(@NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final MapTransactionListener<G, A, R> mapTransactionListener) { this.gameObjectFactory = gameObjectFactory; this.gameObjectMatchers = gameObjectMatchers; + this.mapTransactionListener = mapTransactionListener; } /** + * Returns the {@link MapTransactionListener} that was passed to the + * constructor. + * @return the map transaction listener + */ + @NotNull + public MapTransactionListener<G, A, R> getMapTransactionListener() { + return mapTransactionListener; + } + + /** * Add a new undo state to the undo stack. This discards the existing "redo" * information (if present). * @param undoState the undo state to add This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 21:01:06
|
Revision: 9449 http://sourceforge.net/p/gridarta/code/9449 Author: akirschbaum Date: 2013-10-15 21:01:00 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Remove redundant parameters from MapTransactionListener. Fixes cyclic dependency between MapModel and MapTransactionListener. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mainwindow/GameObjectTextEditorTab.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapTransactionListener.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mainwindow/GameObjectTextEditorTab.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mainwindow/GameObjectTextEditorTab.java 2013-10-15 20:57:40 UTC (rev 9448) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mainwindow/GameObjectTextEditorTab.java 2013-10-15 21:01:00 UTC (rev 9449) @@ -132,12 +132,12 @@ } @Override - public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { + public void beginTransaction(@NotNull final String name) { // ignore } @Override - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { + public void endTransaction(@NotNull final SavedSquares<G, A, R> savedSquares) { // ignore } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2013-10-15 20:57:40 UTC (rev 9448) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2013-10-15 21:01:00 UTC (rev 9449) @@ -301,12 +301,12 @@ } @Override - public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { + public void beginTransaction(@NotNull final String name) { // ignore } @Override - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { + public void endTransaction(@NotNull final SavedSquares<G, A, R> savedSquares) { // ignore } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-10-15 20:57:40 UTC (rev 9448) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-10-15 21:01:00 UTC (rev 9449) @@ -127,13 +127,13 @@ } @Override - public void beginTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final String name) { + public void beginTransaction(@NotNull final String name) { undoModel = undoModels.get(mapModel); undoState = new UndoState<G, A, R>(name, mapModel.getMapArchObject().createClone()); } @Override - public void endTransaction(@NotNull final MapModel<G, A, R> mapModel, @NotNull final SavedSquares<G, A, R> savedSquares) { + public void endTransaction(@NotNull final SavedSquares<G, A, R> savedSquares) { final UndoState<G, A, R> savedUndoState = undoState; assert savedUndoState != null; final UndoModel<G, A, R> savedUndoModel = undoModel; Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2013-10-15 20:57:40 UTC (rev 9448) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2013-10-15 21:01:00 UTC (rev 9449) @@ -665,7 +665,7 @@ private void fireBeginTransaction(@NotNull final String name) { savedSquares.clear(); for (final MapTransactionListener<G, A, R> listener : mapTransactionListeners.getListeners()) { - listener.beginTransaction(this, name); + listener.beginTransaction(name); } } @@ -674,7 +674,7 @@ */ private void fireEndTransaction() { for (final MapTransactionListener<G, A, R> listener : mapTransactionListeners.getListeners()) { - listener.endTransaction(this, savedSquares); + listener.endTransaction(savedSquares); } savedSquares.clear(); } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapTransactionListener.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapTransactionListener.java 2013-10-15 20:57:40 UTC (rev 9448) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/MapTransactionListener.java 2013-10-15 21:01:00 UTC (rev 9449) @@ -39,17 +39,15 @@ /** * A map transaction has started. - * @param mapModel the map model * @param name the transaction name */ - void beginTransaction(@NotNull MapModel<G, A, R> mapModel, @NotNull String name); + void beginTransaction(@NotNull String name); /** * A map transaction has ended. - * @param mapModel the map model * @param savedSquares the squares affected by the transaction */ - void endTransaction(@NotNull MapModel<G, A, R> mapModel, @NotNull SavedSquares<G, A, R> savedSquares); + void endTransaction(@NotNull SavedSquares<G, A, R> savedSquares); /** * A map transaction has been finished. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-15 21:09:11
|
Revision: 9450 http://sourceforge.net/p/gridarta/code/9450 Author: akirschbaum Date: 2013-10-15 21:09:05 +0000 (Tue, 15 Oct 2013) Log Message: ----------- Move AttributeListUtils to different package. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjecttexteditor/GameObjectTextEditor.java trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractArchetypeParser.java Added Paths: ----------- trunk/src/model/src/main/java/net/sf/gridarta/model/io/AttributeListUtils.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java Removed Paths: ------------- trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java trunk/src/model/src/test/java/net/sf/gridarta/model/archetype/AttributeListUtilsTest.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjecttexteditor/GameObjectTextEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjecttexteditor/GameObjectTextEditor.java 2013-10-15 21:01:00 UTC (rev 9449) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/gameobjecttexteditor/GameObjectTextEditor.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -36,11 +36,11 @@ import javax.swing.text.StyleConstants; import javax.swing.text.StyleContext; import net.sf.gridarta.gui.utils.Severity; -import net.sf.gridarta.model.archetype.AttributeListUtils; import net.sf.gridarta.model.archetypetype.ArchetypeType; import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.GameObjectUtils; +import net.sf.gridarta.model.io.AttributeListUtils; import net.sf.gridarta.utils.StringUtils; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; Deleted: trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java 2013-10-15 21:01:00 UTC (rev 9449) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -1,113 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.archetype; - -import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.utils.StringUtils; -import org.jetbrains.annotations.NotNull; - -/** - * Utility class for archetype attribute related functions. - * @author Andreas Kirschbaum - */ -public class AttributeListUtils { - - /** - * Private constructor to prevent instantiation. - */ - private AttributeListUtils() { - } - - /** - * Removes an attribute from an attribute list. - * @param attributeList the attribute list to modify - * @param key the attribute key to remove - * @return the attribute list with the given key removed - */ - public static String removeAttribute(@NotNull final String attributeList, @NotNull final String key) { - if (attributeList.length() <= 0) { - return attributeList; - } - - final String prefix = key + " "; - - final String[] lines = StringUtils.PATTERN_END_OF_LINE.split(attributeList, -1); - - final StringBuilder sb = new StringBuilder(); - for (final String line : lines) { - if (!line.isEmpty() && !line.startsWith(prefix)) { - sb.append(line); - sb.append('\n'); - } - } - return sb.toString(); - } - - /** - * Returns all attributes from the given game object that don't exist in an - * archetype. Ignores the values; compares only keys. - * @param gameObject the game object - * @param archetype the archetype - * @return all attributes from the archetype that don't occur in the game - * object - */ - @NotNull - public static String diffArchTextKeys(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final BaseObject<?, ?, ?, ?> archetype) { - final CharSequence oldObjectText = gameObject.getObjectText(); - final StringBuilder result = new StringBuilder(); - for (final String line : StringUtils.PATTERN_END_OF_LINE.split(archetype.getObjectText(), 0)) { - final int spaceIndex = line.indexOf(' '); - if (!line.isEmpty() && spaceIndex > 0 && StringUtils.diffTextString(oldObjectText, line.substring(0, spaceIndex + 1), true) == null) { - result.append(line).append('\n'); - } - } - return result.toString(); - } - - /** - * Returns all entries from the given attributes that don't exist in an - * archetype. - * @param attributes the attributes - * @param archetype the game object - * @return all lines from <code>attributes</code> that don't occur in this - * game object - */ - @NotNull - public static String diffArchTextValues(@NotNull final BaseObject<?, ?, ?, ?> archetype, @NotNull final CharSequence attributes) { - final CharSequence oldObjectText = archetype.getObjectText(); - final StringBuilder result = new StringBuilder(); - for (final String line : StringUtils.PATTERN_END_OF_LINE.split(attributes, 0)) { - try { - final CharSequence test = StringUtils.diffTextString(oldObjectText, line, false); - char c = '\n'; - if (test != null) { - c = test.charAt(0); - } - if (!line.isEmpty() && (test == null || c == '\n')) { - result.append(line).append('\n'); - } - } catch (final StringIndexOutOfBoundsException ignored) { - // ignore - } - } - return result.toString(); - } - -} Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractArchetypeParser.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractArchetypeParser.java 2013-10-15 21:01:00 UTC (rev 9449) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/AbstractArchetypeParser.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -27,7 +27,6 @@ import net.sf.gridarta.model.anim.IllegalAnimationException; import net.sf.gridarta.model.archetype.AbstractArchetypeBuilder; import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.archetype.AttributeListUtils; import net.sf.gridarta.model.archetype.DuplicateArchetypeException; import net.sf.gridarta.model.archetypeset.ArchetypeSet; import net.sf.gridarta.model.errorview.ErrorViewCategory; Copied: trunk/src/model/src/main/java/net/sf/gridarta/model/io/AttributeListUtils.java (from rev 9433, trunk/src/model/src/main/java/net/sf/gridarta/model/archetype/AttributeListUtils.java) =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/io/AttributeListUtils.java (rev 0) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/io/AttributeListUtils.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -0,0 +1,113 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.utils.StringUtils; +import org.jetbrains.annotations.NotNull; + +/** + * Utility class for archetype attribute related functions. + * @author Andreas Kirschbaum + */ +public class AttributeListUtils { + + /** + * Private constructor to prevent instantiation. + */ + private AttributeListUtils() { + } + + /** + * Removes an attribute from an attribute list. + * @param attributeList the attribute list to modify + * @param key the attribute key to remove + * @return the attribute list with the given key removed + */ + public static String removeAttribute(@NotNull final String attributeList, @NotNull final String key) { + if (attributeList.length() <= 0) { + return attributeList; + } + + final String prefix = key + " "; + + final String[] lines = StringUtils.PATTERN_END_OF_LINE.split(attributeList, -1); + + final StringBuilder sb = new StringBuilder(); + for (final String line : lines) { + if (!line.isEmpty() && !line.startsWith(prefix)) { + sb.append(line); + sb.append('\n'); + } + } + return sb.toString(); + } + + /** + * Returns all attributes from the given game object that don't exist in an + * archetype. Ignores the values; compares only keys. + * @param gameObject the game object + * @param archetype the archetype + * @return all attributes from the archetype that don't occur in the game + * object + */ + @NotNull + public static String diffArchTextKeys(@NotNull final BaseObject<?, ?, ?, ?> gameObject, @NotNull final BaseObject<?, ?, ?, ?> archetype) { + final CharSequence oldObjectText = gameObject.getObjectText(); + final StringBuilder result = new StringBuilder(); + for (final String line : StringUtils.PATTERN_END_OF_LINE.split(archetype.getObjectText(), 0)) { + final int spaceIndex = line.indexOf(' '); + if (!line.isEmpty() && spaceIndex > 0 && StringUtils.diffTextString(oldObjectText, line.substring(0, spaceIndex + 1), true) == null) { + result.append(line).append('\n'); + } + } + return result.toString(); + } + + /** + * Returns all entries from the given attributes that don't exist in an + * archetype. + * @param attributes the attributes + * @param archetype the game object + * @return all lines from <code>attributes</code> that don't occur in this + * game object + */ + @NotNull + public static String diffArchTextValues(@NotNull final BaseObject<?, ?, ?, ?> archetype, @NotNull final CharSequence attributes) { + final CharSequence oldObjectText = archetype.getObjectText(); + final StringBuilder result = new StringBuilder(); + for (final String line : StringUtils.PATTERN_END_OF_LINE.split(attributes, 0)) { + try { + final CharSequence test = StringUtils.diffTextString(oldObjectText, line, false); + char c = '\n'; + if (test != null) { + c = test.charAt(0); + } + if (!line.isEmpty() && (test == null || c == '\n')) { + result.append(line).append('\n'); + } + } catch (final StringIndexOutOfBoundsException ignored) { + // ignore + } + } + return result.toString(); + } + +} Property changes on: trunk/src/model/src/main/java/net/sf/gridarta/model/io/AttributeListUtils.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Deleted: trunk/src/model/src/test/java/net/sf/gridarta/model/archetype/AttributeListUtilsTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/archetype/AttributeListUtilsTest.java 2013-10-15 21:01:00 UTC (rev 9449) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/archetype/AttributeListUtilsTest.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -1,108 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.archetype; - -import net.sf.gridarta.model.anim.AnimationObjects; -import net.sf.gridarta.model.anim.TestAnimationObjects; -import net.sf.gridarta.model.baseobject.BaseObject; -import net.sf.gridarta.model.face.FaceObjectProviders; -import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.model.face.TestFaceObjects; -import net.sf.gridarta.model.gameobject.TestGameObjectFactory; -import net.sf.gridarta.utils.GUIUtils; -import net.sf.gridarta.utils.SystemIcons; -import org.jetbrains.annotations.NotNull; -import org.junit.Assert; -import org.junit.Test; - -/** - * Test for {@link AttributeListUtils}. - * @author Andreas Kirschbaum - */ -public class AttributeListUtilsTest { - - /** - * Test case for {@link AttributeListUtils#removeAttribute(String, - * String)}. - */ - @Test - public void testRemoveAttribute() { - checkRemoveAttribute("", "abc", ""); - - checkRemoveAttribute("abc def\n", "abc", ""); - checkRemoveAttribute("abc def\n", "ab", "abc def\n"); - checkRemoveAttribute("abc def\n", "abcd", "abc def\n"); - - checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "abc", "ghi jkl\n" + "mno pqr\n"); - checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "def", "abc def\n" + "ghi jkl\n" + "mno pqr\n"); - checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "ghi", "abc def\n" + "mno pqr\n"); - checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "mno", "abc def\n" + "ghi jkl\n"); - - checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "Abc", "abc def\n" + "ghi jkl\n" + "mno pqr\n"); - - checkRemoveAttribute("abc def\n\n" + "ghi jkl\n\n", "xyz", "abc def\n" + "ghi jkl\n"); - checkRemoveAttribute("\n\n" + "abc def\n\n", "ghi", "abc def\n"); - checkRemoveAttribute("\n\n" + "abc def\n\n", "abc", ""); - } - - /** - * Calls {@link AttributeListUtils#removeAttribute(String, String)} and - * checks for expected results. - * @param attributeList the attribute list parameter to pass - * @param key the key parameter to pass - * @param expectedResult the expected result value - */ - private static void checkRemoveAttribute(@NotNull final String attributeList, @NotNull final String key, @NotNull final String expectedResult) { - Assert.assertEquals(expectedResult, AttributeListUtils.removeAttribute(attributeList, key)); - } - - /** - * Checks that {@link AttributeListUtils#diffArchTextValues(BaseObject, - * CharSequence)} returns correct values. - */ - @Test - public void checkDiffArchTextValues1() { - Assert.assertEquals("b 3\nd 4\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nb 2\nc 3\n"), "b 3\na 1\nd 4\n")); - Assert.assertEquals("d 4\nb 3\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nb 2\nc 3\n"), "d 4\nb 3\na 1\n")); - Assert.assertEquals("b 3\nd 4\n", AttributeListUtils.diffArchTextValues(newArchetype("c 3\nb 2\na 1\n"), "b 3\na 1\nd 4\n")); - Assert.assertEquals("d 4\nb 3\n", AttributeListUtils.diffArchTextValues(newArchetype("c 3\nb 2\na 1\n"), "d 4\nb 3\na 1\n")); - Assert.assertEquals("e 5\nb 2\nf 6\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nc 3\n"), "e 5\nb 2\nf 6\n")); - Assert.assertEquals("f 6\nb 2\ne 5\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nc 3\n"), "f 6\nb 2\ne 5\n")); - } - - /** - * Creates a new archetype. - * @param objectText the object text of the new archetype - * @return the new archetype - */ - @NotNull - private static BaseObject<?, ?, ?, ?> newArchetype(@NotNull final String objectText) { - final FaceObjects faceObjects = new TestFaceObjects(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); - final AnimationObjects animationObjects = new TestAnimationObjects(); - final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final TestArchetype archetype = gameObjectFactory.newArchetype("arch"); - archetype.setObjectText(objectText); - return archetype; - } - -} Copied: trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java (from rev 9433, trunk/src/model/src/test/java/net/sf/gridarta/model/archetype/AttributeListUtilsTest.java) =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java (rev 0) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java 2013-10-15 21:09:05 UTC (rev 9450) @@ -0,0 +1,109 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import net.sf.gridarta.model.anim.AnimationObjects; +import net.sf.gridarta.model.anim.TestAnimationObjects; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.baseobject.BaseObject; +import net.sf.gridarta.model.face.FaceObjectProviders; +import net.sf.gridarta.model.face.FaceObjects; +import net.sf.gridarta.model.face.TestFaceObjects; +import net.sf.gridarta.model.gameobject.TestGameObjectFactory; +import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.SystemIcons; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link AttributeListUtils}. + * @author Andreas Kirschbaum + */ +public class AttributeListUtilsTest { + + /** + * Test case for {@link AttributeListUtils#removeAttribute(String, + * String)}. + */ + @Test + public void testRemoveAttribute() { + checkRemoveAttribute("", "abc", ""); + + checkRemoveAttribute("abc def\n", "abc", ""); + checkRemoveAttribute("abc def\n", "ab", "abc def\n"); + checkRemoveAttribute("abc def\n", "abcd", "abc def\n"); + + checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "abc", "ghi jkl\n" + "mno pqr\n"); + checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "def", "abc def\n" + "ghi jkl\n" + "mno pqr\n"); + checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "ghi", "abc def\n" + "mno pqr\n"); + checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "mno", "abc def\n" + "ghi jkl\n"); + + checkRemoveAttribute("abc def\n" + "ghi jkl\n" + "mno pqr\n", "Abc", "abc def\n" + "ghi jkl\n" + "mno pqr\n"); + + checkRemoveAttribute("abc def\n\n" + "ghi jkl\n\n", "xyz", "abc def\n" + "ghi jkl\n"); + checkRemoveAttribute("\n\n" + "abc def\n\n", "ghi", "abc def\n"); + checkRemoveAttribute("\n\n" + "abc def\n\n", "abc", ""); + } + + /** + * Calls {@link AttributeListUtils#removeAttribute(String, String)} and + * checks for expected results. + * @param attributeList the attribute list parameter to pass + * @param key the key parameter to pass + * @param expectedResult the expected result value + */ + private static void checkRemoveAttribute(@NotNull final String attributeList, @NotNull final String key, @NotNull final String expectedResult) { + Assert.assertEquals(expectedResult, AttributeListUtils.removeAttribute(attributeList, key)); + } + + /** + * Checks that {@link AttributeListUtils#diffArchTextValues(BaseObject, + * CharSequence)} returns correct values. + */ + @Test + public void checkDiffArchTextValues1() { + Assert.assertEquals("b 3\nd 4\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nb 2\nc 3\n"), "b 3\na 1\nd 4\n")); + Assert.assertEquals("d 4\nb 3\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nb 2\nc 3\n"), "d 4\nb 3\na 1\n")); + Assert.assertEquals("b 3\nd 4\n", AttributeListUtils.diffArchTextValues(newArchetype("c 3\nb 2\na 1\n"), "b 3\na 1\nd 4\n")); + Assert.assertEquals("d 4\nb 3\n", AttributeListUtils.diffArchTextValues(newArchetype("c 3\nb 2\na 1\n"), "d 4\nb 3\na 1\n")); + Assert.assertEquals("e 5\nb 2\nf 6\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nc 3\n"), "e 5\nb 2\nf 6\n")); + Assert.assertEquals("f 6\nb 2\ne 5\n", AttributeListUtils.diffArchTextValues(newArchetype("a 1\nc 3\n"), "f 6\nb 2\ne 5\n")); + } + + /** + * Creates a new archetype. + * @param objectText the object text of the new archetype + * @return the new archetype + */ + @NotNull + private static BaseObject<?, ?, ?, ?> newArchetype(@NotNull final String objectText) { + final FaceObjects faceObjects = new TestFaceObjects(); + final GUIUtils guiUtils = new GUIUtils(); + final SystemIcons systemIcons = new SystemIcons(guiUtils); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final AnimationObjects animationObjects = new TestAnimationObjects(); + final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + final TestArchetype archetype = gameObjectFactory.newArchetype("arch"); + archetype.setObjectText(objectText); + return archetype; + } + +} Property changes on: trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-16 20:00:54
|
Revision: 9457 http://sourceforge.net/p/gridarta/code/9457 Author: akirschbaum Date: 2013-10-16 20:00:49 +0000 (Wed, 16 Oct 2013) Log Message: ----------- Remove unused parameters. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-16 19:52:44 UTC (rev 9456) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-16 20:00:49 UTC (rev 9457) @@ -262,7 +262,7 @@ */ @NotNull @Override - public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { + public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker = new AttributeRangeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster_only", "system_monster", "monster"); if (monsterMatcher != null) { Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-16 19:52:44 UTC (rev 9456) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-16 20:00:49 UTC (rev 9457) @@ -225,7 +225,7 @@ */ @NotNull @Override - public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { + public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker = new AttributeRangeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster"); if (monsterMatcher != null) { Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-16 19:52:44 UTC (rev 9456) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-16 20:00:49 UTC (rev 9457) @@ -261,7 +261,7 @@ */ @NotNull @Override - public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> mapValidators, @NotNull final ErrorViewCollector errorViewCollector, @NotNull final ProjectSettings projectSettings, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { + public AttributeRangeChecker<GameObject, MapArchObject, Archetype> loadAttributeRangeChecker(@NotNull final ErrorViewCollector errorViewCollector, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences) { final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker = new AttributeRangeChecker<GameObject, MapArchObject, Archetype>(validatorPreferences); final GameObjectMatcher monsterMatcher = gameObjectMatchers.getMatcherWarn(errorViewCollector, "system_monster_only", "system_monster", "monster"); if (monsterMatcher != null) { Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java 2013-10-16 19:52:44 UTC (rev 9456) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectFactory.java 2013-10-16 20:00:49 UTC (rev 9457) @@ -44,7 +44,6 @@ import net.sf.gridarta.model.resource.AbstractResources; import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.gridarta.model.smoothface.SmoothFaces; -import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.model.validation.ValidatorPreferences; import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; import org.jetbrains.annotations.NotNull; @@ -155,15 +154,13 @@ /** * Loads the attribute range checker for map validation. - * @param mapValidators the map validators that delegates to add to * @param errorViewCollector the error view collector to use - * @param projectSettings the project settings instance * @param gameObjectMatchers the defined game object matchers * @param validatorPreferences the validator preferences to use * @return the loaded attribute range checker */ @NotNull - AttributeRangeChecker<G, A, R> loadAttributeRangeChecker(@NotNull DelegatingMapValidator<G, A, R> mapValidators, @NotNull ErrorViewCollector errorViewCollector, @NotNull ProjectSettings projectSettings, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences); + AttributeRangeChecker<G, A, R> loadAttributeRangeChecker(@NotNull ErrorViewCollector errorViewCollector, @NotNull GameObjectMatchers gameObjectMatchers, @NotNull final ValidatorPreferences validatorPreferences); /** * Creates a new {@link MapControlFactory} instance. Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-16 19:52:44 UTC (rev 9456) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-16 20:00:49 UTC (rev 9457) @@ -331,7 +331,7 @@ final EnvironmentChecker<G, A, R> environmentChecker = new EnvironmentChecker<G, A, R>(validatorPreferences); final ValidatorFactory<G, A, R> validatorFactory = new ValidatorFactory<G, A, R>(validatorPreferences, gameObjectMatchers, projectSettings, mapWriter); loadValidators(validators, validatorFactory, errorView); - final AttributeRangeChecker<G, A, R> attributeRangeChecker = projectFactory.loadAttributeRangeChecker(validators, new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), projectSettings, gameObjectMatchers, validatorPreferences); + final AttributeRangeChecker<G, A, R> attributeRangeChecker = projectFactory.loadAttributeRangeChecker(new ErrorViewCollector(errorView, new File("GameObjectMatchers.xml")), gameObjectMatchers, validatorPreferences); validators.addValidator(attributeRangeChecker); validators.addValidator(environmentChecker); ArchetypeTypeChecks.addChecks(archetypeTypeSet, attributeRangeChecker, environmentChecker); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-17 18:53:17
|
Revision: 9461 http://sourceforge.net/p/gridarta/code/9461 Author: akirschbaum Date: 2013-10-17 18:53:10 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Move PathManager to ProjectModel. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-16 20:18:59 UTC (rev 9460) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 18:53:10 UTC (rev 9461) @@ -181,7 +181,6 @@ import net.sf.gridarta.model.exitconnector.ExitConnectorModel; import net.sf.gridarta.model.exitconnector.ExitMatcher; import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmodel.InsertionModeSet; import net.sf.gridarta.model.mappathnormalizer.MapPathNormalizer; @@ -308,15 +307,14 @@ * @param scriptArchDataUtils the script arch data utils instance * @param scriptArchUtils the script arch utils instance * @param editorFactory the editor factory instance - * @param pathManager the path manager for converting path names * @param systemIcons the system icons for creating icons * @param configSourceFactory the config source factory instance * @param rendererFactory the renderer factory instance * @param filterControl the filter control instance */ - public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { + public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { this.projectModel = projectModel; - final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, pathManager); + final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, projectModel.getPathManager()); scriptExtension = editorFactory.getScriptExtension(); final DisplayMode<G, A, R> displayModeGameObjectNames = new DisplayNameCellRenderer<G, A, R>(projectModel.getFaceObjectProviders()); final DisplayMode<G, A, R> displayModeArchetypeNames = new ArchetypeNameCellRenderer<G, A, R>(projectModel.getFaceObjectProviders()); @@ -394,7 +392,7 @@ final BookmarksMapMenuPreferences bookmarksMapMenuPreferences = new BookmarksMapMenuPreferences(); final MapMenu mapMenu = bookmarksMapMenuPreferences.getMapMenu(); @Nullable final MapMenuManager<G, A, R> bookmarksMapMenuManager = new MapMenuManager<G, A, R>(mapMenu, mapViewsManager, fileControl, mapImageCache); - final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, projectModel.getArchetypeSet(), projectModel.getMapManager(), fileControl, pathManager, insertionModeSet); // XXX: should be part of DefaultMainControl + final ExitConnectorActions<G, A, R> exitConnectorActions = new ExitConnectorActions<G, A, R>(exitConnectorModel, exitMatcher, projectModel.getArchetypeSet(), projectModel.getMapManager(), fileControl, projectModel.getPathManager(), insertionModeSet); // XXX: should be part of DefaultMainControl final EditorAction exitConnectorController = new ExitConnectorController<G, A, R>(exitConnectorActions, exitConnectorModel, mapViewManager); final ToolPalette<G, A, R> toolPalette = new ToolPalette<G, A, R>(mapViewSettings, selectedSquareModel, objectChooser, pickmapSettings, floorMatcher, wallMatcher, monsterMatcher, insertionModeSet); final GameObjectAttributesControl<G, A, R> gameObjectAttributesControl = new GameObjectAttributesControl<G, A, R>(gameObjectAttributesModel, gameObjectAttributesDialogFactory, objectChooser, projectModel.getMapManager(), selectedSquareModel, projectModel.getGameObjectFactory(), mapViewSettings); @@ -495,7 +493,7 @@ createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); createAction("newMap", "Map", new NewMapAction<G, A, R>(newMapDialogFactory)); createAction("goMap", "Map", new GoMapDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewsManager, projectSettings, exiter)); - createAction("goExit", "Map Navigation", new GoExitDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitGameObjectMatcher, pathManager, enterMap, projectModel.getFaceObjectProviders())); + createAction("goExit", "Map Navigation", new GoExitDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitGameObjectMatcher, projectModel.getPathManager(), enterMap, projectModel.getFaceObjectProviders())); createAction("cleanCompletelyBlockedSquares", "Tool", new CleanCompletelyBlockedSquaresAction<G, A, R>(projectModel.getMapManager())); createAction("collectSpells", "Tool", new CollectSpellsAction(spellUtils, projectSettings, parent)); createAction("controlClient", "Tool", new ControlClientAction(appPreferencesModel, mainViewFrame)); @@ -531,7 +529,7 @@ createAction("gameObjectTextEditor", "Tool", new MainViewActions<G, A, R>(mainView, gameObjectAttributesControl, gameObjectTab, textEditorTab)); createAction("manageBookmarks", "Bookmarks", new ManageBookmarksAction<G, A, R>(mapMenu, mapImageCache, parent)); createAction("addBookmark", "Bookmarks", new AddBookmarkAction<G, A, R>(bookmarksMapMenuPreferences, mapViewManager)); - createActionOptional("openInClient", "Map", editorFactory.newServerActions(mapViewManager, fileControl, pathManager)); + createActionOptional("openInClient", "Map", editorFactory.newServerActions(mapViewManager, fileControl, projectModel.getPathManager())); createAction("exitCopy", "Exit Connector", exitConnectorController); createAction("exitPaste", "Exit Connector", exitConnectorController); createAction("exitConnect", "Exit Connector", exitConnectorController); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-16 20:18:59 UTC (rev 9460) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-17 18:53:10 UTC (rev 9461) @@ -53,7 +53,6 @@ import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.filter.NamedFilter; import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapviewsettings.DefaultMapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; @@ -209,14 +208,13 @@ final ConfigSourceFactory configSourceFactory = new DefaultConfigSourceFactory(); final EditorSettings editorSettings = new DefaultEditorSettings(); final ProjectSettings projectSettings = editorFactory.newProjectSettings(editorSettings); - final PathManager pathManager = new PathManager(projectSettings); final ConfigSource configSource = configSourceFactory.getConfigSource(mode == GridartaRunMode.COLLECT_ARCHES ? "ARCH_DIRECTORY" : projectSettings.getConfigSourceName()); final ProjectModel<G, A, R> projectModel = new ProjectModel<G, A, R>(errorView, projectSettings, editorFactory, systemIcons, configSource); final ScriptedEventEditor<G, A, R> scriptedEventEditor = new ScriptedEventEditor<G, A, R>(projectSettings); final ScriptArchUtils scriptArchUtils = DefaultMainControl.loadScriptArchUtils(errorView, editorFactory, projectModel.getArchetypeTypeSet()); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, projectModel.getGameObjectFactory(), scriptedEventEditor, projectModel.getArchetypeSet()); - final ScriptArchEditor<G, A, R> scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, editorFactory.getScriptExtension(), editorFactory.getScriptName(), scriptArchUtils, editorFactory.getScriptFileFilter(), projectSettings, projectModel.getMapManager(), pathManager); + final ScriptArchEditor<G, A, R> scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, editorFactory.getScriptExtension(), editorFactory.getScriptName(), scriptArchUtils, editorFactory.getScriptFileFilter(), projectSettings, projectModel.getMapManager(), projectModel.getPathManager()); final ScriptArchDataUtils<G, A, R> scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); final NamedFilter defaultNamedFilterList = new NamedFilter(projectModel.getGameObjectMatchers().getFilters()); @@ -242,7 +240,7 @@ try { switch (mode) { case NORMAL: - returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, projectSettings, mapViewSettings, editorSettings, pathManager, systemIcons, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor); + returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, projectSettings, mapViewSettings, editorSettings, systemIcons, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, scriptArchEditor); break; case BATCH_PNG: @@ -332,7 +330,6 @@ * @param projectSettings the project settings * @param mapViewSettings the map view settings * @param editorSettings the editor settings - * @param pathManager the path manager * @param systemIcons the system icons for creating icons * @param scriptedEventEditor the scripted event editor * @param scriptArchDataUtils the script arch data utils @@ -340,13 +337,13 @@ * @param scriptArchEditor the script arch editor * @return return code suitable for passing to {@link System#exit(int)} */ - private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final PathManager pathManager, @NotNull final SystemIcons systemIcons, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { + private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final SystemIcons systemIcons, @NotNull final ScriptedEventEditor<G, A, R> scriptedEventEditor, @NotNull final ScriptArchDataUtils<G, A, R> scriptArchDataUtils, @NotNull final ScriptArchUtils scriptArchUtils, @NotNull final ScriptArchEditor<G, A, R> scriptArchEditor) { final GUIMainControl<?, ?, ?>[] guiMainControl = new GUIMainControl<?, ?, ?>[1]; final Runnable runnable = new Runnable() { @Override public void run() { - guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, projectSettings, mapViewSettings, editorSettings, errorView, guiUtils, pluginModel, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, editorFactory, pathManager, systemIcons, configSourceFactory, rendererFactory, filterControl); + guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, projectSettings, mapViewSettings, editorSettings, errorView, guiUtils, pluginModel, scriptArchEditor, scriptedEventEditor, scriptArchDataUtils, scriptArchUtils, editorFactory, systemIcons, configSourceFactory, rendererFactory, filterControl); } }; Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-16 20:18:59 UTC (rev 9460) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-17 18:53:10 UTC (rev 9461) @@ -63,6 +63,7 @@ import net.sf.gridarta.model.io.MapArchObjectParserFactory; import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.io.MapWriter; +import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.mapcontrol.MapControlFactory; @@ -190,6 +191,9 @@ @NotNull private final TreasureTree treasureTree; + @NotNull + private final PathManager pathManager; + public ProjectModel(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ProjectFactory<G, A, R> projectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSource configSource) { final XmlHelper xmlHelper; try { @@ -240,6 +244,7 @@ scriptsFile = new File(projectSettings.getMapsDirectory(), projectFactory.getScriptsDir()); final Map<String, TreasureTreeNode> specialTreasureLists = loadSpecialTreasureLists(errorView, xmlHelper.getDocumentBuilder(), projectSettings); treasureTree = TreasureLoader.parseTreasures(errorView, specialTreasureLists, configSource, projectSettings); + pathManager = new PathManager(projectSettings); } @NotNull @@ -555,4 +560,9 @@ return treasureTree; } + @NotNull + public PathManager getPathManager() { + return pathManager; + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-17 19:34:43
|
Revision: 9470 http://sourceforge.net/p/gridarta/code/9470 Author: akirschbaum Date: 2013-10-17 19:34:38 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Add ProjectSettings to ProjectModel. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 19:21:38 UTC (rev 9469) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 19:34:38 UTC (rev 9470) @@ -193,7 +193,6 @@ import net.sf.gridarta.model.scripts.ScriptedEventFactory; import net.sf.gridarta.model.settings.DefaultVolatileSettings; import net.sf.gridarta.model.settings.EditorSettings; -import net.sf.gridarta.model.settings.ProjectSettings; import net.sf.gridarta.model.settings.VolatileSettings; import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.project.ProjectModel; @@ -297,7 +296,6 @@ /** * Creates a new instance. * @param projectModel the project model to edit - * @param projectSettings the project settings instance * @param mapViewSettings the map view settings * @param editorSettings the editor settings instance * @param errorView the error view for reporting errors @@ -309,7 +307,7 @@ * @param rendererFactory the renderer factory instance * @param filterControl the filter control instance */ - public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { + public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl) { this.projectModel = projectModel; final MapViewFactory<G, A, R> mapViewFactory = editorFactory.newMapViewFactory(rendererFactory, projectModel.getPathManager()); scriptExtension = editorFactory.getScriptExtension(); @@ -319,7 +317,7 @@ final ExitConnectorModel exitConnectorModel = new DefaultExitConnectorModel(); final ShortcutsManager shortcutsManager = new ShortcutsManager(ACTION_BUILDER); final ImageCreator<G, A, R> imageCreator = new ImageCreator<G, A, R>(projectModel.getMapManager(), rendererFactory); - final VolatileSettings volatileSettings = new DefaultVolatileSettings(projectSettings.getMapsDirectory()); + final VolatileSettings volatileSettings = new DefaultVolatileSettings(projectModel.getProjectSettings().getMapsDirectory()); final ImageCreator2<G, A, R> imageCreator2 = new ImageCreator2<G, A, R>(volatileSettings, imageCreator); final String spellFile = editorFactory.getSpellFile(); final SpellsUtils spellUtils = spellFile != null ? new SpellsUtils(spellFile) : null; @@ -327,7 +325,7 @@ final MapViewManager<G, A, R> mapViewManager = new MapViewManager<G, A, R>(); final StatusBar<G, A, R> statusBar = new StatusBar<G, A, R>(projectModel.getMapManager(), mapViewManager, projectModel.getArchetypeSet(), projectModel.getFaceObjects()); final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(projectModel.getMapManager(), systemIcons.getDefaultIcon(), systemIcons.getDefaultPreview(), rendererFactory, editorFactory.getCacheFiles()); - final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(projectSettings.getPickmapDir()); + final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(projectModel.getProjectSettings().getPickmapDir()); final ImageIcon icon = systemIcons.getAppIcon(); mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); final Frame parent = mainViewFrame; @@ -340,33 +338,33 @@ final SelectedSquareModel<G, A, R> selectedSquareModel = new SelectedSquareModel<G, A, R>(); final GameObjectMatcher floorMatcher = projectModel.getGameObjectMatchers().getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = projectModel.getGameObjectMatchers().getMatcher("system_wall", "wall"); - final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, new File(projectSettings.getConfigurationDirectory(), "GameObjectMatchers.xml")); + final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, new File(projectModel.getProjectSettings().getConfigurationDirectory(), "GameObjectMatchers.xml")); final GameObjectMatcher belowFloorMatcher = projectModel.getGameObjectMatchers().getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_below_floor", "below_floor"); final GameObjectMatcher systemObjectMatcher = projectModel.getGameObjectMatchers().getMatcher("system_system_object"); final InsertionModeSet<G, A, R> insertionModeSet = new InsertionModeSet<G, A, R>(projectModel.getTopmostInsertionMode(), floorMatcher, wallMatcher, belowFloorMatcher, systemObjectMatcher); final CopyBuffer<G, A, R> copyBuffer = new CopyBuffer<G, A, R>(mapViewSettings, projectModel.getGameObjectFactory(), projectModel.getMapArchObjectFactory(), projectModel.getMapModelFactory(), insertionModeSet); final FindDialogManager<G, A, R> findDialogManager = new FindDialogManager<G, A, R>(parent, mapViewManager); final Exiter exiter = new DefaultExiter(parent); - scriptEditControl = new ScriptEditControl(editorFactory.getScriptFileFilter(), scriptExtension, parent, projectSettings.getMapsDirectory(), preferences, exiter); + scriptEditControl = new ScriptEditControl(editorFactory.getScriptFileFilter(), scriptExtension, parent, projectModel.getProjectSettings().getMapsDirectory(), preferences, exiter); final TextAreaDefaults textAreaDefaults = new TextAreaDefaults(scriptEditControl); scriptEditControl.setTextAreaDefaults(textAreaDefaults); - final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(projectModel.getArchetypeTypeSet(), parent, treasureListTree, projectModel.getFaceObjectProviders(), projectModel.getAnimationObjects(), projectSettings, editorFactory.getMapFileFilter(), editorFactory.getScriptFileFilter(), projectModel.getFaceObjects(), projectModel.getGameObjectSpells(), projectModel.getNumberSpells(), editorFactory.getUndefinedSpellIndex(), projectModel.getTreasureTree(), noFaceSquareIcon, unknownSquareIcon, textAreaDefaults, projectModel.getMapManager()); - final ScriptedEventEditor<G, A, R> scriptedEventEditor = new ScriptedEventEditor<G, A, R>(projectSettings, scriptEditControl); + final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory = new GameObjectAttributesDialogFactory<G, A, R>(projectModel.getArchetypeTypeSet(), parent, treasureListTree, projectModel.getFaceObjectProviders(), projectModel.getAnimationObjects(), projectModel.getProjectSettings(), editorFactory.getMapFileFilter(), editorFactory.getScriptFileFilter(), projectModel.getFaceObjects(), projectModel.getGameObjectSpells(), projectModel.getNumberSpells(), editorFactory.getUndefinedSpellIndex(), projectModel.getTreasureTree(), noFaceSquareIcon, unknownSquareIcon, textAreaDefaults, projectModel.getMapManager()); + final ScriptedEventEditor<G, A, R> scriptedEventEditor = new ScriptedEventEditor<G, A, R>(projectModel.getProjectSettings(), scriptEditControl); final ScriptArchUtils scriptArchUtils = DefaultMainControl.loadScriptArchUtils(errorView, editorFactory, projectModel.getArchetypeTypeSet()); final ScriptedEventFactory<G, A, R> scriptedEventFactory = editorFactory.newScriptedEventFactory(scriptArchUtils, projectModel.getGameObjectFactory(), scriptedEventEditor, projectModel.getArchetypeSet()); - final ScriptArchEditor<G, A, R> scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, editorFactory.getScriptExtension(), editorFactory.getScriptName(), scriptArchUtils, editorFactory.getScriptFileFilter(), projectSettings, projectModel.getMapManager(), projectModel.getPathManager(), scriptEditControl); + final ScriptArchEditor<G, A, R> scriptArchEditor = new ScriptArchEditor<G, A, R>(scriptedEventFactory, editorFactory.getScriptExtension(), editorFactory.getScriptName(), scriptArchUtils, editorFactory.getScriptFileFilter(), projectModel.getProjectSettings(), projectModel.getMapManager(), projectModel.getPathManager(), scriptEditControl); final ScriptArchDataUtils<G, A, R> scriptArchDataUtils = editorFactory.newScriptArchDataUtils(scriptArchUtils, scriptedEventFactory, scriptedEventEditor); final GameObjectMatcher monsterMatcherTmp = projectModel.getGameObjectMatchers().getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_monster", "monster"); final GameObjectMatcher monsterMatcher = monsterMatcherTmp == null ? new TypeNrsGameObjectMatcher() : monsterMatcherTmp; final GameObjectMatcher exitGameObjectMatcherTmp = projectModel.getGameObjectMatchers().getMatcherWarn(gameObjectMatchersErrorViewCollector, "system_exit", "exit"); final GameObjectMatcher exitGameObjectMatcher = exitGameObjectMatcherTmp == null ? new TypeNrsGameObjectMatcher() : exitGameObjectMatcherTmp; final ExitMatcher<G, A, R> exitMatcher = new ExitMatcher<G, A, R>(exitGameObjectMatcher); - final MapPathNormalizer mapPathNormalizer = new MapPathNormalizer(projectSettings); - final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory = editorFactory.newMapPropertiesDialogFactory(projectSettings, projectModel.getMapManager(), mapPathNormalizer); + final MapPathNormalizer mapPathNormalizer = new MapPathNormalizer(projectModel.getProjectSettings()); + final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory = editorFactory.newMapPropertiesDialogFactory(projectModel.getProjectSettings(), projectModel.getMapManager(), mapPathNormalizer); final DelayedMapModelListenerManager<G, A, R> delayedMapModelListenerManager = new DelayedMapModelListenerManager<G, A, R>(projectModel.getMapManager(), exiter); final Control<?, G, A, R> lockedItemsControl = new LockedItemsControl<G, A, R>(mapViewManager, delayedMapModelListenerManager, editorFactory.getLockedItemsTypeNumbers()); final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel = new GameObjectAttributesModel<G, A, R>(); - final File scriptsFile = new File(projectSettings.getMapsDirectory(), editorFactory.getScriptsDir()); + final File scriptsFile = new File(projectModel.getProjectSettings().getMapsDirectory(), editorFactory.getScriptsDir()); updaterManager = new UpdaterManager(exiter, projectModel.getMapManager(), parent, editorFactory.getGridartaJarFilename()); final TextEditorTab<G, A, R> textEditorTab = new TextEditorTab<G, A, R>(gameObjectAttributesModel, projectModel.getArchetypeTypeSet()); final EditorAction undoControl = new UndoControl<G, A, R>(projectModel.getMapManager(), projectModel.getGameObjectFactory(), projectModel.getGameObjectMatchers()); @@ -377,7 +375,7 @@ final ArchetypeChooserControl<G, A, R> archetypeChooserControl = new ArchetypeChooserControl<G, A, R>(projectModel.getArchetypeChooserModel(), archetypeChooserView); mapViewsManager = new MapViewsManager<G, A, R>(mapViewSettings, mapViewFactory, projectModel.getMapManager(), projectModel.getPickmapManager()); newMapDialogFactory = editorFactory.newNewMapDialogFactory(mapViewsManager, projectModel.getMapArchObjectFactory(), pickmapChooserView, parent); - fileControl = new DefaultFileControl<G, A, R>(projectSettings, volatileSettings, mapImageCache, projectModel.getMapManager(), mapViewsManager, parent, GuiFileFilters.mapFileFilter, editorFactory.getScriptFileFilter(), newMapDialogFactory, scriptExtension, scriptEditControl); + fileControl = new DefaultFileControl<G, A, R>(projectModel.getProjectSettings(), volatileSettings, mapImageCache, projectModel.getMapManager(), mapViewsManager, parent, GuiFileFilters.mapFileFilter, editorFactory.getScriptFileFilter(), newMapDialogFactory, scriptExtension, scriptEditControl); mapViewsManager.setFileControl(fileControl); final PickmapChooserControl<G, A, R> pickmapChooserControl = new PickmapChooserControl<G, A, R>(pickmapChooserModel, pickmapSettings, newMapDialogFactory, mapFolderTree, projectModel.getMapManager(), parent, mapViewsManager, fileControl, pickmapChooserView); final DefaultObjectChooser<G, A, R> objectChooser = new DefaultObjectChooser<G, A, R>(archetypeChooserControl, pickmapChooserControl, projectModel.getArchetypeChooserModel(), pickmapChooserModel, projectModel.getArchetypeTypeSet()); @@ -485,20 +483,20 @@ createAction("expandEmptySelection", "Map/Selection", mainActions); createAction("growSelection", "Map/Selection", new GrowSelectionAction<G, A, R>(mapViewManager)); createAction("shrinkSelection", "Map/Selection", new ShrinkSelectionAction<G, A, R>(mapViewManager)); - createAction("collectArches", "Tool", new CollectArchesAction<G, A, R>(projectSettings, projectModel.getResources(), exiter, mainViewFrame)); + createAction("collectArches", "Tool", new CollectArchesAction<G, A, R>(projectModel.getProjectSettings(), projectModel.getResources(), exiter, mainViewFrame)); createAction("reloadFaces", "Image,Tool", new ReloadFacesAction<G, A, R>(projectModel.getArchetypeSet(), projectModel.getFaceObjectProviders())); createAction("validateMap", "Map,Tool", new ValidateMapAction<G, A, R>(projectModel.getValidators(), projectModel.getMapManager())); createAction("showHelp", "Help", new ShowHelpAction(parent)); createAction("tipOfTheDay", "Help", new TipOfTheDayAction(parent)); createAction("newMap", "Map", new NewMapAction<G, A, R>(newMapDialogFactory)); - createAction("goMap", "Map", new GoMapDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewsManager, projectSettings, exiter)); + createAction("goMap", "Map", new GoMapDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewsManager, projectModel.getProjectSettings(), exiter)); createAction("goExit", "Map Navigation", new GoExitDialogManager<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitGameObjectMatcher, projectModel.getPathManager(), enterMap, projectModel.getFaceObjectProviders())); createAction("cleanCompletelyBlockedSquares", "Tool", new CleanCompletelyBlockedSquaresAction<G, A, R>(projectModel.getMapManager())); - createAction("collectSpells", "Tool", new CollectSpellsAction(spellUtils, projectSettings, parent)); + createAction("collectSpells", "Tool", new CollectSpellsAction(spellUtils, projectModel.getProjectSettings(), parent)); createAction("controlClient", "Tool", new ControlClientAction(appPreferencesModel, mainViewFrame)); createAction("controlServer", "Tool", new ControlServerAction(appPreferencesModel, mainViewFrame)); createAction("gc", "Tool", new GcAction(statusBar)); - createAction("options", "Tool", new OptionsAction<G, A, R>(editorFactory, projectSettings, editorSettings, projectModel.getValidators(), appPreferencesModel, exitConnectorModel, configSourceFactory, parent)); + createAction("options", "Tool", new OptionsAction<G, A, R>(editorFactory, projectModel.getProjectSettings(), editorSettings, projectModel.getValidators(), appPreferencesModel, exitConnectorModel, configSourceFactory, parent)); createAction("shortcuts", "Tool", new ShortcutsAction(shortcutsManager, parent)); createAction("zoom", "Tool", new ZoomAction<G, A, R>(projectModel.getMapManager(), rendererFactory, parent)); createAction("moveCursorNorth", "Map Cursor,Map/Selection", mapCursorActions); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-17 19:21:38 UTC (rev 9469) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-17 19:34:38 UTC (rev 9470) @@ -212,12 +212,12 @@ final RendererFactory<G, A, R> rendererFactory = editorFactory.newRendererFactory(mapViewSettings, filterControl, projectModel.getGameObjectParser(), projectModel.getFaceObjectProviders(), systemIcons, projectModel.getSmoothFaces()); final NamedFilter defaultFilterList = new NamedFilter(Collections.<NamedGameObjectMatcher>emptyList()); - final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(projectModel.getArchetypeSet(), projectModel.getMapManager(), defaultFilterList, projectSettings); + final PluginParameterFactory<G, A, R> pluginParameterFactory = new PluginParameterFactory<G, A, R>(projectModel.getArchetypeSet(), projectModel.getMapManager(), defaultFilterList, projectModel.getProjectSettings()); final PluginModelParser<G, A, R> pluginModelParser = new PluginModelParser<G, A, R>(pluginParameterFactory); final PluginModel<G, A, R> pluginModel = PluginModelLoader.loadPlugins(pluginParameterFactory, pluginModelParser, errorView, projectModel.getScriptsFile()); pluginModel.addPluginParameter("archetypeSet", projectModel.getArchetypeSet()); - pluginModel.addPluginParameter("projectSettings", projectSettings); - pluginModel.addPluginParameter("globalSettings", projectSettings); // XXX: for compatibility with existing scripts; should be replaced with "projectSettings" + pluginModel.addPluginParameter("projectSettings", projectModel.getProjectSettings()); + pluginModel.addPluginParameter("globalSettings", projectModel.getProjectSettings()); // XXX: for compatibility with existing scripts; should be replaced with "projectSettings" pluginModel.addPluginParameter("mapManager", projectModel.getMapManager()); pluginModel.addPluginParameter("validators", projectModel.getValidators()); pluginModel.addPluginParameter("rendererFactory", rendererFactory); @@ -229,7 +229,7 @@ try { switch (mode) { case NORMAL: - returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, projectSettings, mapViewSettings, editorSettings, systemIcons); + returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, rendererFactory, filterControl, pluginModel, projectModel, mapViewSettings, editorSettings, systemIcons); break; case BATCH_PNG: @@ -245,7 +245,7 @@ break; case COLLECT_ARCHES: - returnCode = new CollectArchesCommand(projectModel.getResources(), projectSettings).execute(); + returnCode = new CollectArchesCommand(projectModel.getResources(), projectModel.getProjectSettings()).execute(); break; default: @@ -316,19 +316,18 @@ * @param filterControl the filter control to use * @param pluginModel the plugin model to use * @param projectModel the project model to use - * @param projectSettings the project settings * @param mapViewSettings the map view settings * @param editorSettings the editor settings * @param systemIcons the system icons for creating icons * @return return code suitable for passing to {@link System#exit(int)} */ - private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final ProjectSettings projectSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final SystemIcons systemIcons) { + private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<G, A, R> rendererFactory, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final MapViewSettings mapViewSettings, @NotNull final EditorSettings editorSettings, @NotNull final SystemIcons systemIcons) { final GUIMainControl<?, ?, ?>[] guiMainControl = new GUIMainControl<?, ?, ?>[1]; final Runnable runnable = new Runnable() { @Override public void run() { - guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, projectSettings, mapViewSettings, editorSettings, errorView, guiUtils, pluginModel, editorFactory, systemIcons, configSourceFactory, rendererFactory, filterControl); + guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, mapViewSettings, editorSettings, errorView, guiUtils, pluginModel, editorFactory, systemIcons, configSourceFactory, rendererFactory, filterControl); } }; Modified: trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java =================================================================== --- trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-17 19:21:38 UTC (rev 9469) +++ trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java 2013-10-17 19:34:38 UTC (rev 9470) @@ -126,6 +126,9 @@ private static final Category log = Logger.getLogger(ProjectModel.class); @NotNull + private final ProjectSettings projectSettings; + + @NotNull private final ArchetypeTypeSet archetypeTypeSet; @NotNull @@ -195,6 +198,7 @@ private final PathManager pathManager; public ProjectModel(@NotNull final ErrorView errorView, @NotNull final ProjectSettings projectSettings, @NotNull final ProjectFactory<G, A, R> projectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSource configSource) { + this.projectSettings = projectSettings; final XmlHelper xmlHelper; try { xmlHelper = new XmlHelper(); @@ -451,6 +455,11 @@ } @NotNull + public ProjectSettings getProjectSettings() { + return projectSettings; + } + + @NotNull public ArchetypeTypeSet getArchetypeTypeSet() { return archetypeTypeSet; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-17 20:45:35
|
Revision: 9476 http://sourceforge.net/p/gridarta/code/9476 Author: akirschbaum Date: 2013-10-17 20:45:31 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Rename GUIUtils to ResourceIcons. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/MapPreview.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/model/src/test/java/net/sf/gridarta/model/archetypeset/DefaultArchetypeSetTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/artifact/TestParser.java trunk/src/model/src/test/java/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/ArchetypeParserTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java trunk/src/model/src/test/java/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/SystemIcons.java Added Paths: ----------- trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java Removed Paths: ------------- trunk/src/utils/src/main/java/net/sf/gridarta/utils/GUIUtils.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -93,9 +93,9 @@ import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; import net.sf.gridarta.model.validation.checks.InvalidCheckException; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.actions.AtrinikServerActions; @@ -563,8 +563,8 @@ * {@inheritDoc} */ @Override - public ImageIcon getCompassIcon(@NotNull final GUIUtils guiUtils) { - return guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH); + public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { + return resourceIcons.getResourceIcon(IGUIConstants.TILE_NORTH); } /** Modified: trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java =================================================================== --- trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -36,7 +36,7 @@ import net.sf.gridarta.model.gameobject.MultiPositionData; import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.GameObjectParser; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.atrinik.model.archetype.Archetype; import net.sf.gridarta.var.atrinik.model.archetype.DefaultArchetypeFactory; @@ -142,8 +142,8 @@ @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final FaceObjects faceObjects = new DefaultFaceObjects(true); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new DefaultAnimationObjects(); final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -89,8 +89,8 @@ import net.sf.gridarta.model.validation.checks.InvalidCheckException; import net.sf.gridarta.utils.ConfigFileUtils; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.gui.map.renderer.DefaultRendererFactory; @@ -454,7 +454,7 @@ * {@inheritDoc} */ @Override - public ImageIcon getCompassIcon(@NotNull final GUIUtils guiUtils) { + public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { return null; } Modified: trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java =================================================================== --- trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -24,7 +24,7 @@ import net.sf.gridarta.model.face.DefaultFaceObjects; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetype; @@ -59,8 +59,8 @@ */ public GameObjectCreator() { final FaceObjects faceObjects = new DefaultFaceObjects(false); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); animationObjects = new DefaultAnimationObjects(); archetype = new DefaultArchetype("arch", faceObjectProviders, animationObjects); Modified: trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java =================================================================== --- trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -35,7 +35,7 @@ import net.sf.gridarta.model.io.AbstractArchetypeParserTest; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.smoothface.SmoothFaces; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetypeFactory; @@ -101,8 +101,8 @@ @Override protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final FaceObjects faceObjects = new DefaultFaceObjects(false); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new DefaultAnimationObjects(); final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects); Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -93,9 +93,9 @@ import net.sf.gridarta.model.validation.checks.AttributeRangeChecker; import net.sf.gridarta.model.validation.checks.InvalidCheckException; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.gui.map.renderer.DefaultRendererFactory; @@ -562,8 +562,8 @@ * {@inheritDoc} */ @Override - public ImageIcon getCompassIcon(@NotNull final GUIUtils guiUtils) { - return guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH); + public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { + return resourceIcons.getResourceIcon(IGUIConstants.TILE_NORTH); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/MapPreview.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/MapPreview.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/MapPreview.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -111,7 +111,7 @@ frame = new JFrame("Map Previewer"); // WARNING: Do not set the icon. There's a bug that will prevent the frame from getting properly disposed. // This code will be put back in as soon as sun fixes the setIconImage() bug in their java.awt.peer.FramePeer impl. - //ImageIcon icon = GUIUtils.getIcon(GUIConstants.APP_ICON); + //ImageIcon icon = ResourceIcons.getIcon(GUIConstants.APP_ICON); //if (icon != null) { // frame.setIconImage(icon.getImage()); //} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -60,7 +60,7 @@ import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.project.ProjectFactory; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.prefs.PreferencesGroup; import org.jetbrains.annotations.NotNull; @@ -252,11 +252,11 @@ /** * Returns the icon to display in the selected square view. - * @param guiUtils the gui utils for creating icons + * @param resourceIcons the gui utils for creating icons * @return the icon or {@code null} to display no icon */ @Nullable - ImageIcon getCompassIcon(@NotNull GUIUtils guiUtils); + ImageIcon getCompassIcon(@NotNull ResourceIcons resourceIcons); /** * Returns the filename of the editor's .jar file. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -205,8 +205,8 @@ import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.Exiter; -import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.GuiFileFilters; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -301,12 +301,12 @@ * @param projectModel the project model to edit * @param editorSettings the editor settings instance * @param errorView the error view for reporting errors - * @param guiUtils the gui utils for creating icons + * @param resourceIcons the gui utils for creating icons * @param editorFactory the editor factory instance * @param systemIcons the system icons for creating icons * @param configSourceFactory the config source factory instance */ - public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory) { + public GUIMainControl(@NotNull final ProjectModel<G, A, R> projectModel, @NotNull final EditorSettings editorSettings, @NotNull final ErrorView errorView, @NotNull final ResourceIcons resourceIcons, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final SystemIcons systemIcons, @NotNull final ConfigSourceFactory configSourceFactory) { this.projectModel = projectModel; final NamedFilter defaultNamedFilterList = new NamedFilter(projectModel.getGameObjectMatchers().getFilters()); final FilterControl<G, A, R> filterControl = new DefaultFilterControl<G, A, R>(defaultNamedFilterList); @@ -541,7 +541,7 @@ mainViewFrame.add(new MainToolbar(editorSettings).getComponent(), BorderLayout.NORTH); mainViewFrame.add(statusBar, BorderLayout.SOUTH); mainView.addTab(gameObjectTab); - mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, editorFactory.getCompassIcon(guiUtils), projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); + mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, editorFactory.getCompassIcon(resourceIcons), projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, false, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, false, 3, true)); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -53,7 +53,7 @@ import net.sf.gridarta.preferences.FilePreferencesFactory; import net.sf.gridarta.project.ProjectModel; import net.sf.gridarta.utils.ConfigFileUtils; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SyntaxErrorException; import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.action.ActionBuilder; @@ -187,8 +187,8 @@ // Create the application and give it the parameters final ErrorView errorView = GraphicsEnvironment.isHeadless() || mode.isConsoleMode() || plugin != null ? new ConsoleErrorView() : new DefaultErrorView(null); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final ConfigSourceFactory configSourceFactory = new DefaultConfigSourceFactory(); final EditorSettings editorSettings = new DefaultEditorSettings(); final ProjectSettings projectSettings = editorFactory.newProjectSettings(editorSettings); @@ -201,7 +201,7 @@ try { switch (mode) { case NORMAL: - returnCode = runNormal(args2, editorFactory, errorView, guiUtils, configSourceFactory, projectModel, editorSettings, systemIcons); + returnCode = runNormal(args2, editorFactory, errorView, resourceIcons, configSourceFactory, projectModel, editorSettings, systemIcons); break; case BATCH_PNG: @@ -282,20 +282,20 @@ * @param args the files to open * @param editorFactory the editor factory to use * @param errorView the error view to add errors to - * @param guiUtils the gui utils to use + * @param resourceIcons the gui utils to use * @param configSourceFactory the config source factory to use * @param projectModel the project model to use * @param editorSettings the editor settings * @param systemIcons the system icons for creating icons * @return return code suitable for passing to {@link System#exit(int)} */ - private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final EditorSettings editorSettings, @NotNull final SystemIcons systemIcons) { + private int runNormal(@NotNull final Iterable<String> args, @NotNull final EditorFactory<G, A, R> editorFactory, @NotNull final ErrorView errorView, @NotNull final ResourceIcons resourceIcons, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final ProjectModel<G, A, R> projectModel, @NotNull final EditorSettings editorSettings, @NotNull final SystemIcons systemIcons) { final GUIMainControl<?, ?, ?>[] guiMainControl = new GUIMainControl<?, ?, ?>[1]; final Runnable runnable = new Runnable() { @Override public void run() { - guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, editorSettings, errorView, guiUtils, editorFactory, systemIcons, configSourceFactory); + guiMainControl[0] = new GUIMainControl<G, A, R>(projectModel, editorSettings, errorView, resourceIcons, editorFactory, systemIcons, configSourceFactory); } }; Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/archetypeset/DefaultArchetypeSetTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/archetypeset/DefaultArchetypeSetTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/archetypeset/DefaultArchetypeSetTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -33,7 +33,7 @@ import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.junit.Assert; import org.junit.Test; @@ -51,8 +51,8 @@ @Test public void testRetainLoadOrder() throws DuplicateArchetypeException { final FaceObjects faceObjects = new TestFaceObjects(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(faceObjectProviders, animationObjects); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -28,7 +28,7 @@ import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.face.TestFaceObjects; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.junit.Assert; import org.junit.Test; @@ -44,8 +44,8 @@ */ @Test public void testAttributes1() { - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjects faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); @@ -61,8 +61,8 @@ */ @Test public void testAttributes2() { - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjects faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); @@ -91,8 +91,8 @@ */ @Test public void testAttributes3() { - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjects faceObjects = new TestFaceObjects(); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/artifact/TestParser.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/artifact/TestParser.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/artifact/TestParser.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -47,7 +47,7 @@ import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.TestArchetypeParser; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; @@ -99,8 +99,8 @@ * @param errorView the error view to use for parsing */ public TestParser(@NotNull final TestErrorView errorView) { - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final File file = new File("*string*"); errorViewCollector = new ErrorViewCollector(errorView, file); final FaceObjects faceObjects = new TestFaceObjects(); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -34,7 +34,7 @@ import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapmodel.TopmostInsertionMode; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -542,8 +542,8 @@ */ @Before public void setUp() { - final GUIUtils guiUtils = new GUIUtils(); - systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + systemIcons = new SystemIcons(resourceIcons); } } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/io/ArchetypeParserTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/io/ArchetypeParserTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/io/ArchetypeParserTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -35,7 +35,7 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -194,8 +194,8 @@ @Override protected AbstractArchetypeParser<TestGameObject, TestMapArchObject, TestArchetype, ? extends AbstractArchetypeBuilder<TestGameObject, TestMapArchObject, TestArchetype>> newArchetypeParser() { final FaceObjects faceObjects = new TestFaceObjects(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -27,7 +27,7 @@ import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.model.face.TestFaceObjects; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.junit.Assert; @@ -96,8 +96,8 @@ @NotNull private static BaseObject<?, ?, ?, ?> newArchetype(@NotNull final String objectText) { final FaceObjects faceObjects = new TestFaceObjects(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); final TestGameObjectFactory gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -51,7 +51,7 @@ import net.sf.gridarta.model.mapviewsettings.TestMapViewSettings; import net.sf.gridarta.model.match.GameObjectMatchers; import net.sf.gridarta.model.match.TypeNrsGameObjectMatcher; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; @@ -141,14 +141,14 @@ */ public TestMapModelCreator(final boolean createIcons) { autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(); - final GUIUtils guiUtils = new GUIUtils(); + final ResourceIcons resourceIcons = new ResourceIcons(); if (createIcons) { final ImageIcon imageIcon = new ImageIcon(new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB)); for (final String iconName : ICON_NAMES) { - guiUtils.addToCache(iconName, imageIcon); + resourceIcons.addToCache(iconName, imageIcon); } } - systemIcons = new SystemIcons(guiUtils); + systemIcons = new SystemIcons(resourceIcons); final FaceObjects faceObjects = new TestFaceObjects(); faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); final FaceProvider faceProvider = new EmptyFaceProvider(); Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -30,7 +30,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -173,8 +173,8 @@ */ @Before public void setUp() { - final GUIUtils guiUtils = new GUIUtils(); - systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + systemIcons = new SystemIcons(resourceIcons); } } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -55,7 +55,7 @@ import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.TestArchetypeParser; import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import net.sf.gridarta.utils.GUIUtils; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -163,8 +163,8 @@ private static AnimationObjects readAnimations(@NotNull final File archDirectory, @NotNull final File collectedDirectory) { final ArchFaceProvider archFaceProvider = new ArchFaceProvider(); final FaceObjects faceObjects = new TestFaceObjects(); - final GUIUtils guiUtils = new GUIUtils(); - final SystemIcons systemIcons = new SystemIcons(guiUtils); + final ResourceIcons resourceIcons = new ResourceIcons(); + final SystemIcons systemIcons = new SystemIcons(resourceIcons); final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); final AnimationObjects animationObjects = new TestAnimationObjects(); final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(faceObjectProviders, animationObjects); Deleted: trunk/src/utils/src/main/java/net/sf/gridarta/utils/GUIUtils.java =================================================================== --- trunk/src/utils/src/main/java/net/sf/gridarta/utils/GUIUtils.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/utils/src/main/java/net/sf/gridarta/utils/GUIUtils.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -1,105 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.utils; - -import java.io.File; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.MissingResourceException; -import javax.swing.ImageIcon; -import org.apache.log4j.Category; -import org.apache.log4j.Logger; -import org.jetbrains.annotations.NotNull; - -/** - * <code>CGUtils</code> is a collection of GUI utility methods. Mainly focusing - * on resource management. - * @author <a href="mailto:mic...@no...">Michael Toennies</a> - * @author <a href="mailto:and...@gm...">Andreas Vogl</a> - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class GUIUtils { - - /** - * The Logger for printing log messages. - */ - private static final Category log = Logger.getLogger(GUIUtils.class); - - /** - * Caches image icons. Maps icon name to image icon. - */ - @NotNull - private final Map<String, ImageIcon> imageCache = new HashMap<String, ImageIcon>(); - - /** - * Returns the image icon for the given icon name. Loads every icon only - * once and uses hash table to return the same instance if same icon name is - * given. Note: There must not be conflicting icon names from different - * directories. - * @param iconName the icon name - * @return the image icon for the given icon name - * @throws MissingResourceException if the icon cannot be loaded - */ - @NotNull - public ImageIcon getResourceIcon(@NotNull final String iconName) throws MissingResourceException { - // check cache - if (imageCache.containsKey(iconName)) { - if (log.isDebugEnabled()) { - log.debug("getResourceIcon(" + iconName + "): return cached"); - } - return imageCache.get(iconName); - } - - @NotNull final ImageIcon icon; - - final URL iconURL = GUIUtils.class.getClassLoader().getResource(iconName); - if (iconURL != null) { - if (log.isDebugEnabled()) { - log.debug("getResourceIcon(" + iconName + "): loading from resource: " + iconURL); - } - icon = new ImageIcon(iconURL); - } else { - final File iconFile = new File(iconName); - if (iconFile.exists()) { - if (log.isDebugEnabled()) { - log.debug("getResourceIcon(" + iconName + "): loading from file: " + iconFile); - } - icon = new ImageIcon(iconFile.getAbsolutePath()); - } else { - log.warn("Cannot find icon '" + iconName + "'"); - throw new MissingResourceException("missing resource: icon " + iconName, GUIUtils.class.getName(), iconName); - } - } - - imageCache.put(iconName, icon); - return icon; - } - - /** - * Add an image to the cache. - * @param name the name - * @param imageIcon the image icon - */ - public void addToCache(@NotNull final String name, @NotNull final ImageIcon imageIcon) { - imageCache.put(name, imageIcon); - } - -} Copied: trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java (from rev 9453, trunk/src/utils/src/main/java/net/sf/gridarta/utils/GUIUtils.java) =================================================================== --- trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java (rev 0) +++ trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -0,0 +1,106 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.utils; + +import java.io.File; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.MissingResourceException; +import javax.swing.ImageIcon; +import org.apache.log4j.Category; +import org.apache.log4j.Logger; +import org.jetbrains.annotations.NotNull; + +/** + * Creates {@link ImageIcon} instances from resources. The returned image icons + * are cached. + * @author <a href="mailto:mic...@no...">Michael Toennies</a> + * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author Andreas Kirschbaum + */ +public class ResourceIcons { + + /** + * The Logger for printing log messages. + */ + private static final Category log = Logger.getLogger(ResourceIcons.class); + + /** + * Caches image icons. Maps icon name to image icon. + */ + @NotNull + private final Map<String, ImageIcon> imageCache = new HashMap<String, ImageIcon>(); + + /** + * Returns the image icon for the given icon name. Loads every icon only + * once and uses hash table to return the same instance if same icon name is + * given. Note: There must not be conflicting icon names from different + * directories. + * @param iconName the icon name + * @return the image icon for the given icon name + * @throws MissingResourceException if the icon cannot be loaded + */ + @NotNull + public ImageIcon getResourceIcon(@NotNull final String iconName) throws MissingResourceException { + // check cache + if (imageCache.containsKey(iconName)) { + if (log.isDebugEnabled()) { + log.debug("getResourceIcon(" + iconName + "): return cached"); + } + return imageCache.get(iconName); + } + + @NotNull final ImageIcon icon; + + final URL iconURL = ResourceIcons.class.getClassLoader().getResource(iconName); + if (iconURL != null) { + if (log.isDebugEnabled()) { + log.debug("getResourceIcon(" + iconName + "): loading from resource: " + iconURL); + } + icon = new ImageIcon(iconURL); + } else { + final File iconFile = new File(iconName); + if (iconFile.exists()) { + if (log.isDebugEnabled()) { + log.debug("getResourceIcon(" + iconName + "): loading from file: " + iconFile); + } + icon = new ImageIcon(iconFile.getAbsolutePath()); + } else { + log.warn("Cannot find icon '" + iconName + "'"); + throw new MissingResourceException("missing resource: icon " + iconName, ResourceIcons.class.getName(), iconName); + } + } + + imageCache.put(iconName, icon); + return icon; + } + + /** + * Add an image to the cache. + * @param name the name + * @param imageIcon the image icon + */ + public void addToCache(@NotNull final String name, @NotNull final ImageIcon imageIcon) { + imageCache.put(name, imageIcon); + } + +} Property changes on: trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:mergeinfo ## -0,0 +1 ## +/streams/cher-japi-update/src/app/net/sf/gridarta/gui/utils/GUIUtils.java:5966-5991 \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/utils/src/main/java/net/sf/gridarta/utils/SystemIcons.java =================================================================== --- trunk/src/utils/src/main/java/net/sf/gridarta/utils/SystemIcons.java 2013-10-17 20:35:48 UTC (rev 9475) +++ trunk/src/utils/src/main/java/net/sf/gridarta/utils/SystemIcons.java 2013-10-17 20:45:31 UTC (rev 9476) @@ -107,10 +107,10 @@ private static final String APP_ICON = ICON_DIR + "app_icon.gif"; /** - * The {@link GUIUtils} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final GUIUtils guiUtils; + private final ResourceIcons resourceIcons; @Nullable private ImageIcon mapSelIcon; @@ -195,17 +195,17 @@ /** * Creates a new instance. - * @param guiUtils the gui utils for creating icons + * @param resourceIcons the gui utils for creating icons */ - public SystemIcons(@NotNull final GUIUtils guiUtils) { - this.guiUtils = guiUtils; + public SystemIcons(@NotNull final ResourceIcons resourceIcons) { + this.resourceIcons = resourceIcons; } @NotNull @SuppressWarnings("NullableProblems") public ImageIcon getMapCursorIcon() { if (mapCursorIcon == null) { - mapCursorIcon = guiUtils.getResourceIcon(SQUARE_CURSOR); + mapCursorIcon = resourceIcons.getResourceIcon(SQUARE_CURSOR); } return mapCursorIcon; } @@ -214,7 +214,7 @@ @SuppressWarnings("NullableProblems") public Icon getEmptySquareIcon() { if (emptySquareIcon == null) { - emptySquareIcon = guiUtils.getResourceIcon(SQUARE_EMPTY); + emptySquareIcon = resourceIcons.getResourceIcon(SQUARE_EMPTY); } return emptySquareIcon; } @@ -223,7 +223,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getUnknownSquareIcon() { if (unknownSquareIcon == null) { - unknownSquareIcon = guiUtils.getResourceIcon(SQUARE_UNKNOWN); + unknownSquareIcon = resourceIcons.getResourceIcon(SQUARE_UNKNOWN); } return unknownSquareIcon; } @@ -233,7 +233,7 @@ public ImageIcon getWarningSquareIcon() { if (warningSquareIcon == null) { final ImageFilter alphaFilter = AlphaImageFilterInstance.ALPHA_FILTER; - final ImageIcon sysIcon = guiUtils.getResourceIcon(SQUARE_WARNING); + final ImageIcon sysIcon = resourceIcons.getResourceIcon(SQUARE_WARNING); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); final ImageProducer producer = new FilteredImageSource(source, alphaFilter); @@ -253,7 +253,7 @@ public ImageIcon getLightSquareIcon() { if (lightSquareIcon == null) { final ImageFilter alphaFilter = AlphaImageFilterInstance.ALPHA_FILTER; - final ImageIcon sysIcon = guiUtils.getResourceIcon(SQUARE_LIGHT); + final ImageIcon sysIcon = resourceIcons.getResourceIcon(SQUARE_LIGHT); final Image image = sysIcon.getImage(); final ImageProducer source = image.getSource(); final ImageProducer producer = new FilteredImageSource(source, alphaFilter); @@ -267,7 +267,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getNoFaceSquareIcon() { if (noFaceSquareIcon == null) { - noFaceSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_FACE); + noFaceSquareIcon = resourceIcons.getResourceIcon(SQUARE_NO_FACE); } return noFaceSquareIcon; } @@ -276,7 +276,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getNoArchSquareIcon() { if (noArchSquareIcon == null) { - noArchSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_ARCH); + noArchSquareIcon = resourceIcons.getResourceIcon(SQUARE_NO_ARCH); } return noArchSquareIcon; } @@ -285,7 +285,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapSelectedIcon() { if (mapSelIcon == null) { - mapSelIcon = guiUtils.getResourceIcon(SQUARE_SELECTED_SQUARE); + mapSelIcon = resourceIcons.getResourceIcon(SQUARE_SELECTED_SQUARE); } return mapSelIcon; } @@ -294,7 +294,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapSelectedIconNorth() { if (mapSelIconNorth == null) { - mapSelIconNorth = guiUtils.getResourceIcon(SQUARE_SELECTED_SQUARE_NORTH); + mapSelIconNorth = resourceIcons.getResourceIcon(SQUARE_SELECTED_SQUARE_NORTH); } return mapSelIconNorth; } @@ -303,7 +303,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapSelectedIconEast() { if (mapSelIconEast == null) { - mapSelIconEast = guiUtils.getResourceIcon(SQUARE_SELECTED_SQUARE_EAST); + mapSelIconEast = resourceIcons.getResourceIcon(SQUARE_SELECTED_SQUARE_EAST); } return mapSelIconEast; } @@ -312,7 +312,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapSelectedIconSouth() { if (mapSelIconSouth == null) { - mapSelIconSouth = guiUtils.getResourceIcon(SQUARE_SELECTED_SQUARE_SOUTH); + mapSelIconSouth = resourceIcons.getResourceIcon(SQUARE_SELECTED_SQUARE_SOUTH); } return mapSelIconSouth; } @@ -321,7 +321,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapSelectedIconWest() { if (mapSelIconWest == null) { - mapSelIconWest = guiUtils.getResourceIcon(SQUARE_SELECTED_SQUARE_WEST); + mapSelIconWest = resourceIcons.getResourceIcon(SQUARE_SELECTED_SQUARE_WEST); } return mapSelIconWest; } @@ -330,7 +330,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getMapPreSelectedIcon() { if (mapPreSelIcon == null) { - mapPreSelIcon = guiUtils.getResourceIcon(SQUARE_PRE_SELECTED_SQUARE); + mapPreSelIcon = resourceIcons.getResourceIcon(SQUARE_PRE_SELECTED_SQUARE); } return mapPreSelIcon; } @@ -343,7 +343,7 @@ @SuppressWarnings("NullableProblems") public Image getDefaultIcon() { if (defaultIcon == null) { - final ImageIcon icon = guiUtils.getResourceIcon(DEFAULT_ICON); + final ImageIcon icon = resourceIcons.getResourceIcon(DEFAULT_ICON); defaultIcon = icon.getImage(); } assert defaultIcon != null; @@ -358,7 +358,7 @@ @SuppressWarnings("NullableProblems") public Image getDefaultPreview() { if (defaultPreview == null) { - final ImageIcon icon = guiUtils.getResourceIcon(DEFAULT_PREVIEW); + final ImageIcon icon = resourceIcons.getResourceIcon(DEFAULT_PREVIEW); defaultPreview = icon.getImage(); } assert defaultPreview != null; @@ -369,7 +369,7 @@ @SuppressWarnings("NullableProblems") public Icon getTreasureListIcon() { if (treasureListIcon == null) { - treasureListIcon = guiUtils.getResourceIcon(TREASURE_LIST); + treasureListIcon = resourceIcons.getResourceIcon(TREASURE_LIST); } return treasureListIcon; } @@ -378,7 +378,7 @@ @SuppressWarnings("NullableProblems") public Icon getTreasureOneListIcon() { if (treasureOneListIcon == null) { - treasureOneListIcon = guiUtils.getResourceIcon(TREASUREONE_LIST); + treasureOneListIcon = resourceIcons.getResourceIcon(TREASUREONE_LIST); } return treasureOneListIcon; } @@ -387,7 +387,7 @@ @SuppressWarnings("NullableProblems") public Icon getTreasureYesIcon() { if (treasureYesIcon == null) { - treasureYesIcon = guiUtils.getResourceIcon(TREASURE_YES); + treasureYesIcon = resourceIcons.getResourceIcon(TREASURE_YES); } return treasureYesIcon; } @@ -396,7 +396,7 @@ @SuppressWarnings("NullableProblems") public Icon getTreasureNoIcon() { if (treasureNoIcon == null) { - treasureNoIcon = guiUtils.getResourceIcon(TREASURE_NO); + treasureNoIcon = resourceIcons.getResourceIcon(TREASURE_NO); } return treasureNoIcon; } @@ -405,7 +405,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getCloseTabSmallIcon() { if (closeTabSmallIcon == null) { - closeTabSmallIcon = guiUtils.getResourceIcon(CLOSE_TAB_SMALL_ICON); + closeTabSmallIcon = resourceIcons.getResourceIcon(CLOSE_TAB_SMALL_ICON); } return closeTabSmallIcon; } @@ -414,7 +414,7 @@ @SuppressWarnings("NullableProblems") public Icon getAutoRunSmallIcon() { if (autoRunSmallIcon == null) { - autoRunSmallIcon = guiUtils.getResourceIcon(AUTO_RUN_SMALL_ICON); + autoRunSmallIcon = resourceIcons.getResourceIcon(AUTO_RUN_SMALL_ICON); } return autoRunSmallIcon; } @@ -423,7 +423,7 @@ @SuppressWarnings("NullableProblems") public Icon getFilterSmallIcon() { if (filterSmallIcon == null) { - filterSmallIcon = guiUtils.getResourceIcon(FILTER_SMALL_ICON); + filterSmallIcon = resourceIcons.getResourceIcon(FILTER_SMALL_ICON); } return filterSmallIcon; } @@ -432,7 +432,7 @@ @SuppressWarnings("NullableProblems") public Icon getRunPluginSmallIcon() { if (runPluginSmallIcon == null) { - runPluginSmallIcon = guiUtils.getResourceIcon(RUN_PLUGIN_SMALL_ICON); + runPluginSmallIcon = resourceIcons.getResourceIcon(RUN_PLUGIN_SMALL_ICON); } return runPluginSmallIcon; } @@ -445,7 +445,7 @@ @SuppressWarnings("NullableProblems") public ImageIcon getAppIcon() { if (appIcon == null) { - appIcon = guiUtils.getResourceIcon(APP_ICON); + appIcon = resourceIcons.getResourceIcon(APP_ICON); } return appIcon; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-17 21:05:57
|
Revision: 9477 http://sourceforge.net/p/gridarta/code/9477 Author: akirschbaum Date: 2013-10-17 21:05:52 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Move code from EditorFactory implementations to GUIMainControl. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) @@ -22,7 +22,6 @@ import java.awt.Component; import java.io.IOException; import java.net.URL; -import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; @@ -95,7 +94,6 @@ import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; -import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.actions.AtrinikServerActions; @@ -562,9 +560,10 @@ /** * {@inheritDoc} */ + @NotNull @Override - public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { - return resourceIcons.getResourceIcon(IGUIConstants.TILE_NORTH); + public String getCompassIconName() { + return IGUIConstants.TILE_NORTH; } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.crossfire.maincontrol; import java.awt.Component; -import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; @@ -90,7 +89,6 @@ import net.sf.gridarta.utils.ConfigFileUtils; import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; -import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.gui.map.renderer.DefaultRendererFactory; @@ -453,8 +451,9 @@ /** * {@inheritDoc} */ + @Nullable @Override - public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { + public String getCompassIconName() { return null; } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) @@ -22,7 +22,6 @@ import java.awt.Component; import java.io.IOException; import java.net.URL; -import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; @@ -95,7 +94,6 @@ import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; -import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.gui.map.renderer.DefaultRendererFactory; @@ -561,9 +559,10 @@ /** * {@inheritDoc} */ + @NotNull @Override - public ImageIcon getCompassIcon(@NotNull final ResourceIcons resourceIcons) { - return resourceIcons.getResourceIcon(IGUIConstants.TILE_NORTH); + public String getCompassIconName() { + return IGUIConstants.TILE_NORTH; } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-17 20:45:31 UTC (rev 9476) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) @@ -20,7 +20,6 @@ package net.sf.gridarta.maincontrol; import java.awt.Component; -import javax.swing.ImageIcon; import javax.swing.filechooser.FileFilter; import net.sf.gridarta.gui.dialog.mapproperties.MapPropertiesDialogFactory; import net.sf.gridarta.gui.dialog.newmap.NewMapDialogFactory; @@ -60,7 +59,6 @@ import net.sf.gridarta.model.validation.DelegatingMapValidator; import net.sf.gridarta.project.ProjectFactory; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.SystemIcons; import net.sf.japi.swing.prefs.PreferencesGroup; import org.jetbrains.annotations.NotNull; @@ -251,12 +249,11 @@ boolean isAllowRandomMapParameters(); /** - * Returns the icon to display in the selected square view. - * @param resourceIcons the gui utils for creating icons - * @return the icon or {@code null} to display no icon + * Returns the icon name to display in the selected square view. + * @return the icon name or {@code null} to display no icon */ @Nullable - ImageIcon getCompassIcon(@NotNull ResourceIcons resourceIcons); + String getCompassIconName(); /** * Returns the filename of the editor's .jar file. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 20:45:31 UTC (rev 9476) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 21:05:52 UTC (rev 9477) @@ -541,7 +541,9 @@ mainViewFrame.add(new MainToolbar(editorSettings).getComponent(), BorderLayout.NORTH); mainViewFrame.add(statusBar, BorderLayout.SOUTH); mainView.addTab(gameObjectTab); - mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, editorFactory.getCompassIcon(resourceIcons), projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); + final String compassIconName = editorFactory.getCompassIconName(); + final ImageIcon compassIcon = compassIconName == null ? null : resourceIcons.getResourceIcon(compassIconName); + mainView.addTab(new Tab("selectedSquare", new SelectedSquareView<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, mapViewManager, mapViewSettings, compassIcon, projectModel.getFaceObjectProviders(), unknownSquareIcon, moveSquareUpAction, moveSquareDownAction, moveSquareTopAction, moveSquareBottomAction, moveSquareEnvAction, moveSquareInvAction), Location.RIGHT, false, 1, true)); mainView.addTab(new Tab("tools", toolPalette, Location.LEFT, false, 2, false)); mainView.addTab(new Tab("objects", objectChooser, Location.LEFT, false, 3, true)); final JMenu windowMenu = MenuUtils.getMenu(menuBar, "window"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-10-17 21:35:34
|
Revision: 9478 http://sourceforge.net/p/gridarta/code/9478 Author: akirschbaum Date: 2013-10-17 21:35:29 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Merge SystemIcons into ResourceIcons. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/IGUIConstants.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/MapRendererTest.java trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/TestMapRenderer.java trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/DefaultRendererFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/IGUIConstants.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginController.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/CFTreasureListTree.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/TreasureCellRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/EditorFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GridartaEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/ImageCreatorFactory.java trunk/src/model/src/main/java/net/sf/gridarta/model/face/FaceObjectProviders.java trunk/src/model/src/test/java/net/sf/gridarta/model/archetypeset/DefaultArchetypeSetTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/archetypetype/ArchetypeTypeTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/artifact/TestParser.java trunk/src/model/src/test/java/net/sf/gridarta/model/baseobject/AbstractBaseObjectTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/ArchetypeParserTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/io/AttributeListUtilsTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapmodel/TestMapModelCreator.java trunk/src/model/src/test/java/net/sf/gridarta/model/match/NamedGameObjectMatcherTest.java trunk/src/model/src/test/java/net/sf/gridarta/model/resource/AbstractFilesResourcesReaderTest.java trunk/src/project/src/main/java/net/sf/gridarta/project/ProjectModel.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java Removed Paths: ------------- trunk/src/utils/src/main/java/net/sf/gridarta/utils/SystemIcons.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/IGUIConstants.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/IGUIConstants.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/IGUIConstants.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.atrinik; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; /** * Defines common UI constants used in different dialogs and all used icon @@ -73,7 +73,7 @@ String ARTIFACTS_FILE = "artifacts"; // file with artifact definitions - String TILE_NORTH = SystemIcons.SYSTEM_DIR + "north.png"; + String TILE_NORTH = ResourceIcons.SYSTEM_DIR + "north.png"; /** * Name of the files the spell information (names and numbers). Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -31,7 +31,7 @@ import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.atrinik.model.archetype.Archetype; import net.sf.gridarta.var.atrinik.model.gameobject.GameObject; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; @@ -81,10 +81,10 @@ private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * Creates a new instance. @@ -96,16 +96,16 @@ * @param gridMapSquarePainter the grid square painter to use * @param gameObjectParser the game object parser for creating tooltip * information - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final SystemIcons systemIcons) { + public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ResourceIcons resourceIcons) { this.mapViewSettings = mapViewSettings; this.filterControl = filterControl; this.multiPositionData = multiPositionData; this.isoMapSquareInfo = isoMapSquareInfo; this.gridMapSquarePainter = gridMapSquarePainter; this.gameObjectParser = gameObjectParser; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; } /** @@ -114,7 +114,7 @@ @NotNull @Override public SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype> newSimpleMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, systemIcons.getUnknownSquareIcon()); + return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getUnknownSquareIcon()); } /** @@ -123,7 +123,7 @@ @NotNull @Override public IsoMapRenderer<GameObject, MapArchObject, Archetype> newMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons); + return new IsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons); } /** @@ -132,7 +132,7 @@ @NotNull @Override public IsoPickmapRenderer<GameObject, MapArchObject, Archetype> newPickmapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons.getUnknownSquareIcon()); + return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); } } Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -94,7 +94,7 @@ import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.atrinik.IGUIConstants; import net.sf.gridarta.var.atrinik.actions.AtrinikServerActions; import net.sf.gridarta.var.atrinik.gui.map.renderer.DefaultRendererFactory; @@ -395,8 +395,8 @@ */ @NotNull @Override - public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons, @NotNull final SmoothFaces smoothFaces) { - return new DefaultRendererFactory(mapViewSettings, filterControl, multiPositionData, isoMapSquareInfo, new GridMapSquarePainter(systemIcons), gameObjectParser, systemIcons); + public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothFaces smoothFaces) { + return new DefaultRendererFactory(mapViewSettings, filterControl, multiPositionData, isoMapSquareInfo, new GridMapSquarePainter(resourceIcons), gameObjectParser, resourceIcons); } /** Modified: trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/MapRendererTest.java =================================================================== --- trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/MapRendererTest.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/MapRendererTest.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -37,7 +37,7 @@ import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.NamedGameObjectMatcher; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.jetbrains.annotations.NotNull; import org.junit.Assert; import org.junit.Test; @@ -271,10 +271,10 @@ final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); final IsoMapSquareInfo isoMapSquareInfo = new IsoMapSquareInfo(1, 1, 1, 1); final MultiPositionData multiPositionData = new MultiPositionData(isoMapSquareInfo); - final SystemIcons systemIcons = mapModelCreator.getSystemIcons(); - final GridMapSquarePainter gridMapSquarePainter = new GridMapSquarePainter(systemIcons); + final ResourceIcons resourceIcons = mapModelCreator.getResourceIcons(); + final GridMapSquarePainter gridMapSquarePainter = new GridMapSquarePainter(resourceIcons); final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = mapModelCreator.newGameObjectParser(); - return new TestMapRenderer(mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons); + return new TestMapRenderer(mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons); } } Modified: trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/TestMapRenderer.java =================================================================== --- trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/TestMapRenderer.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/gui/map/renderer/TestMapRenderer.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -34,7 +34,7 @@ import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.jetbrains.annotations.NotNull; /** @@ -67,10 +67,10 @@ * @param gridMapSquarePainter the grid square painter to use * @param gameObjectParser the game object parser for creating tooltip * information - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public TestMapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<TestGameObject, TestMapArchObject, TestArchetype> filterControl, @NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final SystemIcons systemIcons) { - super(100, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons); + public TestMapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<TestGameObject, TestMapArchObject, TestArchetype> filterControl, @NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final ResourceIcons resourceIcons) { + super(100, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons); } /** Modified: trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java =================================================================== --- trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/atrinik/src/test/java/net/sf/gridarta/var/atrinik/model/io/ArchetypeParserTest.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -37,7 +37,6 @@ import net.sf.gridarta.model.io.AbstractArchetypeParser; import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.utils.ResourceIcons; -import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.atrinik.model.archetype.Archetype; import net.sf.gridarta.var.atrinik.model.archetype.DefaultArchetypeFactory; import net.sf.gridarta.var.atrinik.model.gameobject.DefaultGameObjectFactory; @@ -143,8 +142,7 @@ protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final FaceObjects faceObjects = new DefaultFaceObjects(true); final ResourceIcons resourceIcons = new ResourceIcons(); - final SystemIcons systemIcons = new SystemIcons(resourceIcons); - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, resourceIcons); final AnimationObjects animationObjects = new DefaultAnimationObjects(); final ArchetypeTypeSet archetypeTypeSet = new ArchetypeTypeSet(); final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects, archetypeTypeSet); Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/DefaultRendererFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -28,7 +28,7 @@ import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.smoothface.SmoothFaces; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; @@ -78,10 +78,10 @@ private final FaceObjectProviders faceObjectProviders; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * Creates a new instance. @@ -93,16 +93,16 @@ * information * @param faceObjectProviders the face object providers for looking up * faces - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final SmoothFaces smoothFaces, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons) { + public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final SmoothFaces smoothFaces, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ResourceIcons resourceIcons) { this.mapViewSettings = mapViewSettings; this.filterControl = filterControl; this.smoothFaces = smoothFaces; this.gridMapSquarePainter = gridMapSquarePainter; this.gameObjectParser = gameObjectParser; this.faceObjectProviders = faceObjectProviders; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; } /** @@ -112,7 +112,7 @@ @Override public SimpleFlatMapRenderer newSimpleMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { final SmoothingRenderer smoothingRenderer = new SmoothingRenderer(mapModel, smoothFaces, faceObjectProviders); - return new SimpleFlatMapRenderer(mapModel, systemIcons, smoothingRenderer); + return new SimpleFlatMapRenderer(mapModel, resourceIcons, smoothingRenderer); } /** @@ -122,7 +122,7 @@ @Override public FlatMapRenderer newMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { final SmoothingRenderer smoothingRenderer = new SmoothingRenderer(mapModel, smoothFaces, faceObjectProviders); - return new FlatMapRenderer(mapViewSettings, filterControl, mapModel, mapGrid, gridMapSquarePainter, gameObjectParser, systemIcons, smoothingRenderer); + return new FlatMapRenderer(mapViewSettings, filterControl, mapModel, mapGrid, gridMapSquarePainter, gameObjectParser, resourceIcons, smoothingRenderer); } /** Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -41,7 +41,7 @@ import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; @@ -150,13 +150,13 @@ * @param gridMapSquarePainter the grid square painter to use * @param gameObjectParser the game object parser for creating tooltip * information - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons * @param smoothingRenderer the smoothing renderer to use */ - public FlatMapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final SystemIcons systemIcons, @NotNull final SmoothingRenderer smoothingRenderer) { + public FlatMapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothingRenderer smoothingRenderer) { super(mapViewSettings, mapModel, mapGrid, 32, gridMapSquarePainter, gameObjectParser); this.mapModel = mapModel; - emptySquareIcon = systemIcons.getEmptySquareIcon(); + emptySquareIcon = resourceIcons.getEmptySquareIcon(); this.filterControl = filterControl; this.mapViewSettings = mapViewSettings; this.smoothingRenderer = smoothingRenderer; Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -28,8 +28,8 @@ import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.utils.Size2D; -import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.gameobject.GameObject; @@ -56,10 +56,10 @@ private final MapModel<GameObject, MapArchObject, Archetype> mapModel; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * Temporary variable. @@ -77,13 +77,13 @@ /** * Creates a new instance. * @param mapModel the map model to render - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons * @param smoothingRenderer the smoothing renderer to use */ - public SimpleFlatMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final SystemIcons systemIcons, @NotNull final SmoothingRenderer smoothingRenderer) { + public SimpleFlatMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothingRenderer smoothingRenderer) { super(mapModel, null); this.mapModel = mapModel; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; this.smoothingRenderer = smoothingRenderer; } @@ -146,7 +146,7 @@ */ private void paintSquare(@NotNull final Graphics graphics, @NotNull final Point point) { if (mapModel.getMapSquare(point).isEmpty()) { - systemIcons.getEmptySquareIcon().paintIcon(this, graphics, point.x * IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT); + resourceIcons.getEmptySquareIcon().paintIcon(this, graphics, point.x * IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT); return; } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -89,7 +89,7 @@ import net.sf.gridarta.utils.ConfigFileUtils; import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; import net.sf.gridarta.var.crossfire.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.crossfire.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -285,9 +285,9 @@ */ @NotNull @Override - public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons, @NotNull final SmoothFaces smoothFaces) { - final GridMapSquarePainter gridMapSquarePainter = new GridMapSquarePainter(systemIcons); - return new DefaultRendererFactory(mapViewSettings, filterControl, smoothFaces, gridMapSquarePainter, gameObjectParser, faceObjectProviders, systemIcons); + public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothFaces smoothFaces) { + final GridMapSquarePainter gridMapSquarePainter = new GridMapSquarePainter(resourceIcons); + return new DefaultRendererFactory(mapViewSettings, filterControl, smoothFaces, gridMapSquarePainter, gameObjectParser, faceObjectProviders, resourceIcons); } /** Modified: trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java =================================================================== --- trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/gameobject/GameObjectCreator.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -25,7 +25,6 @@ import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.face.FaceObjects; import net.sf.gridarta.utils.ResourceIcons; -import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetype; import org.jetbrains.annotations.NotNull; @@ -60,8 +59,7 @@ public GameObjectCreator() { final FaceObjects faceObjects = new DefaultFaceObjects(false); final ResourceIcons resourceIcons = new ResourceIcons(); - final SystemIcons systemIcons = new SystemIcons(resourceIcons); - faceObjectProviders = new FaceObjectProviders(1, faceObjects, systemIcons); + faceObjectProviders = new FaceObjectProviders(1, faceObjects, resourceIcons); animationObjects = new DefaultAnimationObjects(); archetype = new DefaultArchetype("arch", faceObjectProviders, animationObjects); } Modified: trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java =================================================================== --- trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/crossfire/src/test/java/net/sf/gridarta/var/crossfire/model/io/ArchetypeParserTest.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -36,7 +36,6 @@ import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.smoothface.SmoothFaces; import net.sf.gridarta.utils.ResourceIcons; -import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.model.archetype.Archetype; import net.sf.gridarta.var.crossfire.model.archetype.DefaultArchetypeFactory; import net.sf.gridarta.var.crossfire.model.gameobject.DefaultGameObjectFactory; @@ -102,8 +101,7 @@ protected AbstractArchetypeParser<GameObject, MapArchObject, Archetype, ? extends AbstractArchetypeBuilder<GameObject, MapArchObject, Archetype>> newArchetypeParser() { final FaceObjects faceObjects = new DefaultFaceObjects(false); final ResourceIcons resourceIcons = new ResourceIcons(); - final SystemIcons systemIcons = new SystemIcons(resourceIcons); - final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, systemIcons); + final FaceObjectProviders faceObjectProviders = new FaceObjectProviders(0, faceObjects, resourceIcons); final AnimationObjects animationObjects = new DefaultAnimationObjects(); final DefaultGameObjectFactory gameObjectFactory = new DefaultGameObjectFactory(faceObjectProviders, animationObjects); final DefaultArchetypeFactory archetypeFactory = new DefaultArchetypeFactory(faceObjectProviders, animationObjects); Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/IGUIConstants.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/IGUIConstants.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/IGUIConstants.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -20,7 +20,7 @@ package net.sf.gridarta.var.daimonin; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; /** * Defines common UI constants used in different dialogs and all used icon @@ -73,7 +73,7 @@ String ARTIFACTS_FILE = "artifacts"; // file with artifact definitions - String TILE_NORTH = SystemIcons.SYSTEM_DIR + "north.png"; + String TILE_NORTH = ResourceIcons.SYSTEM_DIR + "north.png"; /** * Name of the files the spell information (names and numbers). Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -31,7 +31,7 @@ import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.daimonin.model.archetype.Archetype; import net.sf.gridarta.var.daimonin.model.gameobject.GameObject; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; @@ -81,10 +81,10 @@ private final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * Creates a new instance. @@ -96,16 +96,16 @@ * @param gridMapSquarePainter the grid square painter to use * @param gameObjectParser the game object parser for creating tooltip * information - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final SystemIcons systemIcons) { + public DefaultRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ResourceIcons resourceIcons) { this.mapViewSettings = mapViewSettings; this.filterControl = filterControl; this.multiPositionData = multiPositionData; this.isoMapSquareInfo = isoMapSquareInfo; this.gridMapSquarePainter = gridMapSquarePainter; this.gameObjectParser = gameObjectParser; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; } /** @@ -114,7 +114,7 @@ @NotNull @Override public SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype> newSimpleMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, systemIcons.getUnknownSquareIcon()); + return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getUnknownSquareIcon()); } /** @@ -123,7 +123,7 @@ @NotNull @Override public IsoMapRenderer<GameObject, MapArchObject, Archetype> newMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons); + return new IsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, filterControl, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons); } /** @@ -132,7 +132,7 @@ @NotNull @Override public IsoPickmapRenderer<GameObject, MapArchObject, Archetype> newPickmapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons.getUnknownSquareIcon()); + return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); } } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -94,7 +94,7 @@ import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.GuiFileFilters; import net.sf.gridarta.utils.IOUtils; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.gridarta.var.daimonin.IGUIConstants; import net.sf.gridarta.var.daimonin.gui.map.renderer.DefaultRendererFactory; import net.sf.gridarta.var.daimonin.gui.mappropertiesdialog.DefaultMapPropertiesDialogFactory; @@ -394,8 +394,8 @@ */ @NotNull @Override - public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final SystemIcons systemIcons, @NotNull final SmoothFaces smoothFaces) { - return new DefaultRendererFactory(mapViewSettings, filterControl, multiPositionData, isoMapSquareInfo, new GridMapSquarePainter(systemIcons), gameObjectParser, systemIcons); + public RendererFactory<GameObject, MapArchObject, Archetype> newRendererFactory(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothFaces smoothFaces) { + return new DefaultRendererFactory(mapViewSettings, filterControl, multiPositionData, isoMapSquareInfo, new GridMapSquarePainter(resourceIcons), gameObjectParser, resourceIcons); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginController.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginController.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginController.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -39,7 +39,7 @@ import net.sf.gridarta.utils.ActionUtils; import net.sf.gridarta.utils.EditorAction; import net.sf.gridarta.utils.FileChooserUtils; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -126,13 +126,13 @@ /** * Creates a new instance. */ - public PluginController(@NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameters pluginParameters, @NotNull final Component parent, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final File pluginsDir, @NotNull final SystemIcons systemIcons) { + public PluginController(@NotNull final FilterControl<G, A, R> filterControl, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameters pluginParameters, @NotNull final Component parent, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final File pluginsDir, @NotNull final ResourceIcons resourceIcons) { this.parent = parent; this.filterControl = filterControl; this.pluginModel = pluginModel; this.pluginParameters = pluginParameters; this.pluginsDir = pluginsDir; - view = new PluginView<G, A, R>(this, pluginModel, pluginParameterViewFactory, systemIcons); + view = new PluginView<G, A, R>(this, pluginModel, pluginParameterViewFactory, resourceIcons); pluginModel.addPluginModelListener(pluginModelListener); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -60,7 +60,7 @@ import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.plugin.parameter.NoSuchParameterException; import net.sf.gridarta.plugin.parameter.PluginParameter; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.fife.ui.rsyntaxtextarea.RSyntaxTextArea; @@ -163,9 +163,9 @@ * Create a visual JComponent used to edit the given script. * @param plugin the script object to edit * @param pluginController the associated script control instance - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public PluginEditor(@NotNull final Plugin<G, A, R> plugin, @NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final SystemIcons systemIcons) { + public PluginEditor(@NotNull final Plugin<G, A, R> plugin, @NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { this.pluginModel = pluginModel; this.plugin = plugin; this.pluginParameterViewFactory = pluginParameterViewFactory; @@ -184,13 +184,13 @@ optionsTab.add(new JPanel(), gbc); gbc.gridx = 1; gbc.weightx = 0.02; - final Component autoRunIcon = new JLabel(systemIcons.getAutoRunSmallIcon()); + final Component autoRunIcon = new JLabel(resourceIcons.getAutoRunSmallIcon()); optionsTab.add(autoRunIcon, gbc); gbc.gridy = 2; - final Component filterIcon = new JLabel(systemIcons.getFilterSmallIcon()); + final Component filterIcon = new JLabel(resourceIcons.getFilterSmallIcon()); optionsTab.add(filterIcon, gbc); gbc.gridy = 3; - final Component runPluginIcon = new JLabel(systemIcons.getRunPluginSmallIcon()); + final Component runPluginIcon = new JLabel(resourceIcons.getRunPluginSmallIcon()); optionsTab.add(runPluginIcon, gbc); gbc.gridx = 2; gbc.gridy = 1; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -48,7 +48,7 @@ import net.sf.gridarta.plugin.Plugin; import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.plugin.PluginModelListener; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -73,10 +73,10 @@ private final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; //TODO fix a memory leak. If a script is remove, it stays in hash map along with it's visual component @@ -89,14 +89,14 @@ * Creates a PluginManager. * @param pluginController the script controller to base this script manager * on - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public PluginManager(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final SystemIcons systemIcons) { + public PluginManager(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { super("Editor plugins management"); this.pluginController = pluginController; this.pluginModel = pluginModel; this.pluginParameterViewFactory = pluginParameterViewFactory; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; getContentPane().setLayout(new BorderLayout()); final Container left = new JPanel(new BorderLayout()); getContentPane().add(left, BorderLayout.WEST); @@ -225,7 +225,7 @@ PluginEditor<G, A, R> pluginEditor = components.get(plugin); if (pluginEditor == null) { - pluginEditor = new PluginEditor<G, A, R>(plugin, pluginController, pluginModel, pluginParameterViewFactory, systemIcons); + pluginEditor = new PluginEditor<G, A, R>(plugin, pluginController, pluginModel, pluginParameterViewFactory, resourceIcons); components.put(plugin, pluginEditor); scriptPanel.add(pluginEditor, Integer.toString(pluginEditor.hashCode())); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -27,7 +27,7 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.utils.EditorAction; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -61,27 +61,27 @@ private final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * Creates a new instance. - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public PluginManagerFactory(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final SystemIcons systemIcons) { + public PluginManagerFactory(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { this.pluginController = pluginController; this.pluginModel = pluginModel; this.pluginParameterViewFactory = pluginParameterViewFactory; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; } @ActionMethod public void editPlugins() { synchronized (sync) { if (scriptManager == null) { - scriptManager = new PluginManager<G, A, R>(pluginController, pluginModel, pluginParameterViewFactory, systemIcons); + scriptManager = new PluginManager<G, A, R>(pluginController, pluginModel, pluginParameterViewFactory, resourceIcons); } scriptManager.pack(); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -45,7 +45,7 @@ import net.sf.gridarta.plugin.PluginModel; import net.sf.gridarta.plugin.PluginModelListener; import net.sf.gridarta.plugin.parameter.PluginParameter; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.apache.log4j.Category; import org.apache.log4j.Logger; import org.jetbrains.annotations.NotNull; @@ -76,10 +76,10 @@ private final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory; /** - * The {@link SystemIcons} for creating icons. + * The {@link ResourceIcons} for creating icons. */ @NotNull - private final SystemIcons systemIcons; + private final ResourceIcons resourceIcons; /** * The menu to add script commands to. @@ -132,15 +132,15 @@ * Creates a PluginView. * @param pluginController controller of this PluginView * @param pluginModel the script model - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons * @warning Creating a view from a controller instead of a model is error * prone. */ - public PluginView(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final SystemIcons systemIcons) { + public PluginView(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { this.pluginController = pluginController; this.pluginModel = pluginModel; this.pluginParameterViewFactory = pluginParameterViewFactory; - this.systemIcons = systemIcons; + this.resourceIcons = resourceIcons; pluginModel.addPluginModelListener(pluginModelListener); } @@ -192,7 +192,7 @@ if (console == null) { console = new JFrame("Beanshell scripts I/O Console"); console.setSize(400, 200); - consolePane = new CloseableTabbedPane(systemIcons.getCloseTabSmallIcon()); + consolePane = new CloseableTabbedPane(resourceIcons.getCloseTabSmallIcon()); console.getContentPane().add(consolePane); } console.setVisible(true); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -23,7 +23,7 @@ import java.awt.Image; import java.awt.image.ImageObserver; import net.sf.gridarta.model.mapgrid.MapGrid; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.jetbrains.annotations.NotNull; /** @@ -81,18 +81,18 @@ /** * Creates a new instance. - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public GridMapSquarePainter(@NotNull final SystemIcons systemIcons) { - selImg = systemIcons.getMapSelectedIcon().getImage(); - selImgNorth = systemIcons.getMapSelectedIconNorth().getImage(); - selImgEast = systemIcons.getMapSelectedIconEast().getImage(); - selImgSouth = systemIcons.getMapSelectedIconSouth().getImage(); - selImgWest = systemIcons.getMapSelectedIconWest().getImage(); - preSelImg = systemIcons.getMapPreSelectedIcon().getImage(); - cursorImg = systemIcons.getMapCursorIcon().getImage(); - warningSquareImg = systemIcons.getWarningSquareIcon().getImage(); - lightSquare = systemIcons.getLightSquareIcon().getImage(); + public GridMapSquarePainter(@NotNull final ResourceIcons resourceIcons) { + selImg = resourceIcons.getMapSelectedIcon().getImage(); + selImgNorth = resourceIcons.getMapSelectedIconNorth().getImage(); + selImgEast = resourceIcons.getMapSelectedIconEast().getImage(); + selImgSouth = resourceIcons.getMapSelectedIconSouth().getImage(); + selImgWest = resourceIcons.getMapSelectedIconWest().getImage(); + preSelImg = resourceIcons.getMapPreSelectedIcon().getImage(); + cursorImg = resourceIcons.getMapCursorIcon().getImage(); + warningSquareImg = resourceIcons.getWarningSquareIcon().getImage(); + lightSquare = resourceIcons.getLightSquareIcon().getImage(); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2013-10-17 21:05:52 UTC (rev 9477) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2013-10-17 21:35:29 UTC (rev 9478) @@ -38,7 +38,7 @@ import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; -import net.sf.gridarta.utils.SystemIcons; +import net.sf.gridarta.utils.ResourceIcons; import org.jetbrains.annotations.NotNull; /** @@ -118,12 +118,12 @@ * @param gridMapSquarePainter the grid square painter to use * @param gameObjectParser the game object parser for creating tooltip * information - * @param systemIcons the system icons for creating icons + * @param resourceIcons the resource icons for creating icons */ - public IsoMapRenderer(final int spawnPointTypeNo, @NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final SystemIcons systemIcons) { - super(spawnPointTypeNo, mapViewSettings, mapModel, mapGrid, isoMapSquareInfo.getXLen(), 2 * isoMapSquareInfo.getYLen(), multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, systemIcons.getUnknownSquareIcon()); + public IsoMapRenderer(final int spawnPointTypeNo, @NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ResourceIcons resourceIcons) { + super(spawnPointTypeNo, mapViewSettings, mapModel, mapGrid, isoMapSquareInfo.getXLen(), 2 * isoMapSquareInfo.getYLen(), multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); this.filterControl = filterControl; - emptySquareIcon = systemIcons.getEmptySquareIcon(); + empty... [truncated message content] |
From: <aki...@us...> - 2013-10-17 21:52:07
|
Revision: 9481 http://sourceforge.net/p/gridarta/code/9481 Author: akirschbaum Date: 2013-10-17 21:52:03 +0000 (Thu, 17 Oct 2013) Log Message: ----------- Inline functions to avoid duplicate caching of images. Modified Paths: -------------- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/TreasureCellRenderer.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/model/src/main/java/net/sf/gridarta/model/face/FaceObjectProviders.java trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java Modified: trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java =================================================================== --- trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/atrinik/src/main/java/net/sf/gridarta/var/atrinik/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -114,7 +114,7 @@ @NotNull @Override public SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype> newSimpleMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getUnknownSquareIcon()); + return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN)); } /** @@ -132,7 +132,7 @@ @NotNull @Override public IsoPickmapRenderer<GameObject, MapArchObject, Archetype> newPickmapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); + return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN)); } } Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -156,7 +156,7 @@ public FlatMapRenderer(@NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<GameObject, MapArchObject, Archetype> gameObjectParser, @NotNull final ResourceIcons resourceIcons, @NotNull final SmoothingRenderer smoothingRenderer) { super(mapViewSettings, mapModel, mapGrid, 32, gridMapSquarePainter, gameObjectParser); this.mapModel = mapModel; - emptySquareIcon = resourceIcons.getEmptySquareIcon(); + emptySquareIcon = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_EMPTY); this.filterControl = filterControl; this.mapViewSettings = mapViewSettings; this.smoothingRenderer = smoothingRenderer; Modified: trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/crossfire/src/main/java/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -146,7 +146,7 @@ */ private void paintSquare(@NotNull final Graphics graphics, @NotNull final Point point) { if (mapModel.getMapSquare(point).isEmpty()) { - resourceIcons.getEmptySquareIcon().paintIcon(this, graphics, point.x * IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT); + resourceIcons.getResourceIcon(ResourceIcons.SQUARE_EMPTY).paintIcon(this, graphics, point.x * IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT); return; } Modified: trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java =================================================================== --- trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/daimonin/src/main/java/net/sf/gridarta/var/daimonin/gui/map/renderer/DefaultRendererFactory.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -114,7 +114,7 @@ @NotNull @Override public SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype> newSimpleMapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel) { - return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getUnknownSquareIcon()); + return new SimpleIsoMapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapModel, multiPositionData, isoMapSquareInfo, resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN)); } /** @@ -132,7 +132,7 @@ @NotNull @Override public IsoPickmapRenderer<GameObject, MapArchObject, Archetype> newPickmapRenderer(@NotNull final MapModel<GameObject, MapArchObject, Archetype> mapModel, @NotNull final MapGrid mapGrid) { - return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); + return new IsoPickmapRenderer<GameObject, MapArchObject, Archetype>(Archetype.TYPE_SPAWN_POINT, mapViewSettings, mapModel, mapGrid, multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN)); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -184,13 +184,13 @@ optionsTab.add(new JPanel(), gbc); gbc.gridx = 1; gbc.weightx = 0.02; - final Component autoRunIcon = new JLabel(resourceIcons.getAutoRunSmallIcon()); + final Component autoRunIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.AUTO_RUN_SMALL_ICON)); optionsTab.add(autoRunIcon, gbc); gbc.gridy = 2; - final Component filterIcon = new JLabel(resourceIcons.getFilterSmallIcon()); + final Component filterIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.FILTER_SMALL_ICON)); optionsTab.add(filterIcon, gbc); gbc.gridy = 3; - final Component runPluginIcon = new JLabel(resourceIcons.getRunPluginSmallIcon()); + final Component runPluginIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.RUN_PLUGIN_SMALL_ICON)); optionsTab.add(runPluginIcon, gbc); gbc.gridx = 2; gbc.gridy = 1; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -192,7 +192,7 @@ if (console == null) { console = new JFrame("Beanshell scripts I/O Console"); console.setSize(400, 200); - consolePane = new CloseableTabbedPane(resourceIcons.getCloseTabSmallIcon()); + consolePane = new CloseableTabbedPane(resourceIcons.getResourceIcon(ResourceIcons.CLOSE_TAB_SMALL_ICON)); console.getContentPane().add(consolePane); } console.setVisible(true); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/GridMapSquarePainter.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -84,13 +84,13 @@ * @param resourceIcons the resource icons for creating icons */ public GridMapSquarePainter(@NotNull final ResourceIcons resourceIcons) { - selImg = resourceIcons.getMapSelectedIcon().getImage(); - selImgNorth = resourceIcons.getMapSelectedIconNorth().getImage(); - selImgEast = resourceIcons.getMapSelectedIconEast().getImage(); - selImgSouth = resourceIcons.getMapSelectedIconSouth().getImage(); - selImgWest = resourceIcons.getMapSelectedIconWest().getImage(); - preSelImg = resourceIcons.getMapPreSelectedIcon().getImage(); - cursorImg = resourceIcons.getMapCursorIcon().getImage(); + selImg = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_SELECTED_SQUARE).getImage(); + selImgNorth = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_SELECTED_SQUARE_NORTH).getImage(); + selImgEast = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_SELECTED_SQUARE_EAST).getImage(); + selImgSouth = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_SELECTED_SQUARE_SOUTH).getImage(); + selImgWest = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_SELECTED_SQUARE_WEST).getImage(); + preSelImg = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_PRE_SELECTED_SQUARE).getImage(); + cursorImg = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_CURSOR).getImage(); warningSquareImg = resourceIcons.getWarningSquareIcon().getImage(); lightSquare = resourceIcons.getLightSquareIcon().getImage(); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/renderer/IsoMapRenderer.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -121,9 +121,9 @@ * @param resourceIcons the resource icons for creating icons */ public IsoMapRenderer(final int spawnPointTypeNo, @NotNull final MapViewSettings mapViewSettings, @NotNull final FilterControl<G, A, R> filterControl, @NotNull final MapModel<G, A, R> mapModel, @NotNull final MapGrid mapGrid, @NotNull final MultiPositionData multiPositionData, @NotNull final IsoMapSquareInfo isoMapSquareInfo, @NotNull final GridMapSquarePainter gridMapSquarePainter, @NotNull final GameObjectParser<G, A, R> gameObjectParser, @NotNull final ResourceIcons resourceIcons) { - super(spawnPointTypeNo, mapViewSettings, mapModel, mapGrid, isoMapSquareInfo.getXLen(), 2 * isoMapSquareInfo.getYLen(), multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getUnknownSquareIcon()); + super(spawnPointTypeNo, mapViewSettings, mapModel, mapGrid, isoMapSquareInfo.getXLen(), 2 * isoMapSquareInfo.getYLen(), multiPositionData, isoMapSquareInfo, gridMapSquarePainter, gameObjectParser, resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN)); this.filterControl = filterControl; - emptySquareIcon = resourceIcons.getEmptySquareIcon(); + emptySquareIcon = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_EMPTY); this.mapViewSettings = mapViewSettings; this.isoMapSquareInfo = isoMapSquareInfo; this.filterControl.addConfigListener(filterConfigListener); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/TreasureCellRenderer.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/TreasureCellRenderer.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/treasurelist/TreasureCellRenderer.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -88,7 +88,7 @@ try { setIcon(faceObjectProviders.getFace(archetypeSet.getArchetype(treasureObj.getName()))); } catch (final UndefinedArchetypeException ignored) { - setIcon(resourceIcons.getNoArchSquareIcon()); + setIcon(resourceIcons.getResourceIcon(ResourceIcons.SQUARE_NO_ARCH)); } setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); } @@ -100,7 +100,7 @@ @Override public void visit(@NotNull final NoTreasureObj treasureObj) { setForeground(Color.gray); - setIcon(resourceIcons.getTreasureNoIcon()); + setIcon(resourceIcons.getResourceIcon(ResourceIcons.TREASURE_NO)); } @Override @@ -111,7 +111,7 @@ setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); } else { setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); - setIcon(resourceIcons.getTreasureListIcon()); + setIcon(resourceIcons.getResourceIcon(ResourceIcons.TREASURE_LIST)); } } else { if (treasureObj.getName().equalsIgnoreCase("none")) { @@ -119,7 +119,7 @@ setBorder(BorderFactory.createEmptyBorder(5, 0, 5, 0)); } else { setBorder(BorderFactory.createEmptyBorder(1, 0, 1, 0)); - setIcon(resourceIcons.getTreasureOneListIcon()); + setIcon(resourceIcons.getResourceIcon(ResourceIcons.TREASUREONE_LIST)); } } } @@ -127,7 +127,7 @@ @Override public void visit(@NotNull final YesTreasureObj treasureObj) { setForeground(Color.gray); - setIcon(resourceIcons.getTreasureYesIcon()); + setIcon(resourceIcons.getResourceIcon(ResourceIcons.TREASURE_YES)); } }; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -325,17 +325,17 @@ final AppPreferencesModel appPreferencesModel = editorFactory.createAppPreferencesModel(); final MapViewManager<G, A, R> mapViewManager = new MapViewManager<G, A, R>(); final StatusBar<G, A, R> statusBar = new StatusBar<G, A, R>(projectModel.getMapManager(), mapViewManager, projectModel.getArchetypeSet(), projectModel.getFaceObjects()); - final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(projectModel.getMapManager(), resourceIcons.getDefaultIcon(), resourceIcons.getDefaultPreview(), rendererFactory, editorFactory.getCacheFiles()); + final MapImageCache<G, A, R> mapImageCache = new MapImageCache<G, A, R>(projectModel.getMapManager(), resourceIcons.getResourceIcon(ResourceIcons.DEFAULT_ICON).getImage(), resourceIcons.getResourceIcon(ResourceIcons.DEFAULT_PREVIEW).getImage(), rendererFactory, editorFactory.getCacheFiles()); final MapFolderTree<G, A, R> mapFolderTree = new MapFolderTree<G, A, R>(projectModel.getProjectSettings().getPickmapDir()); - final ImageIcon icon = resourceIcons.getAppIcon(); + final ImageIcon icon = resourceIcons.getResourceIcon(ResourceIcons.APP_ICON); mainViewFrame = new JFrame(ACTION_BUILDER.format("mainWindow.title", getBuildNumberAsString())); final Frame parent = mainViewFrame; final PickmapChooserModel<G, A, R> pickmapChooserModel = new PickmapChooserModel<G, A, R>(); final PickmapChooserView<G, A, R> pickmapChooserView = new PickmapChooserView<G, A, R>(pickmapChooserModel, mapFolderTree, projectModel.getMapArchObjectFactory(), projectModel.getMapReaderFactory(), projectModel.getPickmapManager()); final PickmapSettings pickmapSettings = new DefaultPickmapSettings(); final CFTreasureListTree treasureListTree = new CFTreasureListTree(projectModel.getTreasureTree(), parent, projectModel.getArchetypeSet(), projectModel.getFaceObjectProviders(), resourceIcons); - final ImageIcon noFaceSquareIcon = resourceIcons.getNoFaceSquareIcon(); - final ImageIcon unknownSquareIcon = resourceIcons.getUnknownSquareIcon(); + final ImageIcon noFaceSquareIcon = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_NO_FACE); + final ImageIcon unknownSquareIcon = resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN); final SelectedSquareModel<G, A, R> selectedSquareModel = new SelectedSquareModel<G, A, R>(); final GameObjectMatcher floorMatcher = projectModel.getGameObjectMatchers().getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = projectModel.getGameObjectMatchers().getMatcher("system_wall", "wall"); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/face/FaceObjectProviders.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/face/FaceObjectProviders.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/face/FaceObjectProviders.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -311,16 +311,16 @@ @NotNull private ImageIcon getFace(@Nullable final String faceName, final boolean hasUndefinedArchetype, @NotNull final FaceProvider singleFaceProvider, @NotNull final FaceProvider doubleFaceProvider) { if (hasUndefinedArchetype) { - return resourceIcons.getNoArchSquareIcon(); + return resourceIcons.getResourceIcon(ResourceIcons.SQUARE_NO_ARCH); } if (faceName == null) { - return resourceIcons.getNoFaceSquareIcon(); + return resourceIcons.getResourceIcon(ResourceIcons.SQUARE_NO_FACE); } final FaceObject faceObject = faceObjects.get(faceName); if (faceObject == null) { - return resourceIcons.getNoFaceSquareIcon(); + return resourceIcons.getResourceIcon(ResourceIcons.SQUARE_NO_FACE); } final FaceProvider faceProvider = faceObject.isDouble() ? doubleFaceProvider : singleFaceProvider; @@ -328,7 +328,7 @@ final String effectiveFaceName = alternativeFaceName != null && singleFaceProvider == doubleFaceProvider ? alternativeFaceName : faceName; final ImageIcon face = faceProvider.getImageIconForFacename(effectiveFaceName); if (face == null) { - return resourceIcons.getUnknownSquareIcon(); + return resourceIcons.getResourceIcon(ResourceIcons.SQUARE_UNKNOWN); } return face; Modified: trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java =================================================================== --- trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java 2013-10-17 21:37:32 UTC (rev 9480) +++ trunk/src/utils/src/main/java/net/sf/gridarta/utils/ResourceIcons.java 2013-10-17 21:52:03 UTC (rev 9481) @@ -29,7 +29,6 @@ import java.util.HashMap; import java.util.Map; import java.util.MissingResourceException; -import javax.swing.Icon; import javax.swing.ImageIcon; import org.apache.log4j.Category; import org.apache.log4j.Logger; @@ -56,22 +55,31 @@ */ public static final String SYSTEM_DIR = "system/"; + @NotNull public static final String SQUARE_SELECTED_SQUARE = SYSTEM_DIR + "selected_square.png"; + @NotNull public static final String SQUARE_SELECTED_SQUARE_NORTH = SYSTEM_DIR + "selected_square_n.png"; + @NotNull public static final String SQUARE_SELECTED_SQUARE_EAST = SYSTEM_DIR + "selected_square_e.png"; + @NotNull public static final String SQUARE_SELECTED_SQUARE_SOUTH = SYSTEM_DIR + "selected_square_s.png"; + @NotNull public static final String SQUARE_SELECTED_SQUARE_WEST = SYSTEM_DIR + "selected_square_w.png"; + @NotNull public static final String SQUARE_PRE_SELECTED_SQUARE = SYSTEM_DIR + "pre_selected_square.png"; + @NotNull public static final String SQUARE_CURSOR = SYSTEM_DIR + "cursor.png"; + @NotNull public static final String SQUARE_EMPTY = SYSTEM_DIR + "empty.png"; + @NotNull public static final String SQUARE_UNKNOWN = SYSTEM_DIR + "unknown.png"; public static final String SQUARE_WARNING = SYSTEM_DIR + "warning.png"; @@ -82,40 +90,53 @@ */ private static final String SQUARE_LIGHT = SYSTEM_DIR + "light.png"; + @NotNull public static final String SQUARE_NO_FACE = SYSTEM_DIR + "no_face.png"; + @NotNull public static final String SQUARE_NO_ARCH = SYSTEM_DIR + "no_arch.png"; - private static final String TREASURE_LIST = SYSTEM_DIR + "treasure_list.png"; + @NotNull + public static final String TREASURE_LIST = SYSTEM_DIR + "treasure_list.png"; - private static final String TREASUREONE_LIST = SYSTEM_DIR + "treasureone_list.png"; + @NotNull + public static final String TREASUREONE_LIST = SYSTEM_DIR + "treasureone_list.png"; - private static final String TREASURE_YES = SYSTEM_DIR + "treasure_yes.png"; + @NotNull + public static final String TREASURE_YES = SYSTEM_DIR + "treasure_yes.png"; - private static final String TREASURE_NO = SYSTEM_DIR + "treasure_no.png"; + @NotNull + public static final String TREASURE_NO = SYSTEM_DIR + "treasure_no.png"; /** * The default map icon to use if no icon can be created. */ + @NotNull public static final String DEFAULT_ICON = SYSTEM_DIR + "default_icon.png"; /** * The default map preview to use if no icon can be created. */ + @NotNull public static final String DEFAULT_PREVIEW = SYSTEM_DIR + "default_preview.png"; - private static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "close_tab_small_icon.gif"; + @NotNull + public static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "close_tab_small_icon.gif"; - private static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "auto_run_small_icon.gif"; + @NotNull + public static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "auto_run_small_icon.gif"; - private static final String FILTER_SMALL_ICON = ICON_DIR + "filter_small_icon.gif"; + @NotNull + public static final String FILTER_SMALL_ICON = ICON_DIR + "filter_small_icon.gif"; - private static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "run_plugin_small_icon.gif"; + @NotNull + public static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "run_plugin_small_icon.gif"; /** * Application icon definitions (icon-dir). */ - private static final String APP_ICON = ICON_DIR + "app_icon.gif"; + @NotNull + public static final String APP_ICON = ICON_DIR + "app_icon.gif"; /** * The Logger for printing log messages. @@ -129,87 +150,12 @@ private final Map<String, ImageIcon> imageCache = new HashMap<String, ImageIcon>(); @Nullable - private ImageIcon mapSelIcon; - - @Nullable - private ImageIcon mapSelIconNorth; - - @Nullable - private ImageIcon mapSelIconEast; - - @Nullable - private ImageIcon mapSelIconSouth; - - @Nullable - private ImageIcon mapSelIconWest; - - @Nullable - private ImageIcon mapPreSelIcon; - - @Nullable - private ImageIcon mapCursorIcon; - - @Nullable - private Icon emptySquareIcon; - - @Nullable - private ImageIcon unknownSquareIcon; - - @Nullable private ImageIcon warningSquareIcon; @Nullable private ImageIcon lightSquareIcon; - @Nullable - private ImageIcon noFaceSquareIcon; - - @Nullable - private ImageIcon noArchSquareIcon; - /** - * The default icon {@link Image} for map previews. - */ - @Nullable - private Image defaultIcon; - - /** - * The default preview {@link Image} for map icon. - */ - @Nullable - private Image defaultPreview; - - @Nullable - private Icon treasureListIcon; - - @Nullable - private Icon treasureOneListIcon; - - @Nullable - private Icon treasureYesIcon; - - @Nullable - private Icon treasureNoIcon; - - @Nullable - private ImageIcon closeTabSmallIcon; - - @Nullable - private Icon autoRunSmallIcon; - - @Nullable - private Icon filterSmallIcon; - - @Nullable - private Icon runPluginSmallIcon; - - /** - * The application's icon or <code>null</code> if none is available. - */ - @Nullable - private ImageIcon appIcon; - - /** * Returns the image icon for the given icon name. Loads every icon only * once and uses hash table to return the same instance if same icon name is * given. Note: There must not be conflicting icon names from different @@ -265,33 +211,6 @@ @NotNull @SuppressWarnings("NullableProblems") - public ImageIcon getMapCursorIcon() { - if (mapCursorIcon == null) { - mapCursorIcon = getResourceIcon(SQUARE_CURSOR); - } - return mapCursorIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getEmptySquareIcon() { - if (emptySquareIcon == null) { - emptySquareIcon = getResourceIcon(SQUARE_EMPTY); - } - return emptySquareIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getUnknownSquareIcon() { - if (unknownSquareIcon == null) { - unknownSquareIcon = getResourceIcon(SQUARE_UNKNOWN); - } - return unknownSquareIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") public ImageIcon getWarningSquareIcon() { if (warningSquareIcon == null) { final ImageFilter alphaFilter = AlphaImageFilterInstance.ALPHA_FILTER; @@ -325,191 +244,4 @@ return lightSquareIcon; } - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getNoFaceSquareIcon() { - if (noFaceSquareIcon == null) { - noFaceSquareIcon = getResourceIcon(SQUARE_NO_FACE); - } - return noFaceSquareIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getNoArchSquareIcon() { - if (noArchSquareIcon == null) { - noArchSquareIcon = getResourceIcon(SQUARE_NO_ARCH); - } - return noArchSquareIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapSelectedIcon() { - if (mapSelIcon == null) { - mapSelIcon = getResourceIcon(SQUARE_SELECTED_SQUARE); - } - return mapSelIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapSelectedIconNorth() { - if (mapSelIconNorth == null) { - mapSelIconNorth = getResourceIcon(SQUARE_SELECTED_SQUARE_NORTH); - } - return mapSelIconNorth; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapSelectedIconEast() { - if (mapSelIconEast == null) { - mapSelIconEast = getResourceIcon(SQUARE_SELECTED_SQUARE_EAST); - } - return mapSelIconEast; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapSelectedIconSouth() { - if (mapSelIconSouth == null) { - mapSelIconSouth = getResourceIcon(SQUARE_SELECTED_SQUARE_SOUTH); - } - return mapSelIconSouth; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapSelectedIconWest() { - if (mapSelIconWest == null) { - mapSelIconWest = getResourceIcon(SQUARE_SELECTED_SQUARE_WEST); - } - return mapSelIconWest; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getMapPreSelectedIcon() { - if (mapPreSelIcon == null) { - mapPreSelIcon = getResourceIcon(SQUARE_PRE_SELECTED_SQUARE); - } - return mapPreSelIcon; - } - - /** - * Returns the default icon {@link Image} for map previews. - * @return the image - */ - @NotNull - @SuppressWarnings("NullableProblems") - public Image getDefaultIcon() { - if (defaultIcon == null) { - final ImageIcon icon = getResourceIcon(DEFAULT_ICON); - defaultIcon = icon.getImage(); - } - assert defaultIcon != null; - return defaultIcon; - } - - /** - * Returns the default preview {@link Image} for map icon. - * @return the image - */ - @NotNull - @SuppressWarnings("NullableProblems") - public Image getDefaultPreview() { - if (defaultPreview == null) { - final ImageIcon icon = getResourceIcon(DEFAULT_PREVIEW); - defaultPreview = icon.getImage(); - } - assert defaultPreview != null; - return defaultPreview; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getTreasureListIcon() { - if (treasureListIcon == null) { - treasureListIcon = getResourceIcon(TREASURE_LIST); - } - return treasureListIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getTreasureOneListIcon() { - if (treasureOneListIcon == null) { - treasureOneListIcon = getResourceIcon(TREASUREONE_LIST); - } - return treasureOneListIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getTreasureYesIcon() { - if (treasureYesIcon == null) { - treasureYesIcon = getResourceIcon(TREASURE_YES); - } - return treasureYesIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getTreasureNoIcon() { - if (treasureNoIcon == null) { - treasureNoIcon = getResourceIcon(TREASURE_NO); - } - return treasureNoIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public ImageIcon getCloseTabSmallIcon() { - if (closeTabSmallIcon == null) { - closeTabSmallIcon = getResourceIcon(CLOSE_TAB_SMALL_ICON); - } - return closeTabSmallIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getAutoRunSmallIcon() { - if (autoRunSmallIcon == null) { - autoRunSmallIcon = getResourceIcon(AUTO_RUN_SMALL_ICON); - } - return autoRunSmallIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getFilterSmallIcon() { - if (filterSmallIcon == null) { - filterSmallIcon = getResourceIcon(FILTER_SMALL_ICON); - } - return filterSmallIcon; - } - - @NotNull - @SuppressWarnings("NullableProblems") - public Icon getRunPluginSmallIcon() { - if (runPluginSmallIcon == null) { - runPluginSmallIcon = getResourceIcon(RUN_PLUGIN_SMALL_ICON); - } - return runPluginSmallIcon; - } - - /** - * Returns the application's icon. - * @return the icon or <code>null</code> if none is available - */ - @Nullable - @SuppressWarnings("NullableProblems") - public ImageIcon getAppIcon() { - if (appIcon == null) { - appIcon = getResourceIcon(APP_ICON); - } - return appIcon; - } - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-11-23 10:16:25
|
Revision: 9491 http://sourceforge.net/p/gridarta/code/9491 Author: akirschbaum Date: 2013-11-23 10:16:18 +0000 (Sat, 23 Nov 2013) Log Message: ----------- Fix layout issues in plugin manager dialog. Modified Paths: -------------- trunk/src/atrinik/ChangeLog trunk/src/crossfire/ChangeLog trunk/src/daimonin/ChangeLog trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/atrinik/ChangeLog =================================================================== --- trunk/src/atrinik/ChangeLog 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/atrinik/ChangeLog 2013-11-23 10:16:18 UTC (rev 9491) @@ -1,3 +1,7 @@ +2013-11-23 Andreas Kirschbaum + + * Fix layout issues in plugin manager dialog. + 2013-10-05 Andreas Kirschbaum * Do not automatically open the help dialog when the editor is Modified: trunk/src/crossfire/ChangeLog =================================================================== --- trunk/src/crossfire/ChangeLog 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/crossfire/ChangeLog 2013-11-23 10:16:18 UTC (rev 9491) @@ -1,3 +1,7 @@ +2013-11-23 Andreas Kirschbaum + + * Fix layout issues in plugin manager dialog. + 2013-10-05 Andreas Kirschbaum * Do not automatically open the help dialog when the editor is Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/daimonin/ChangeLog 2013-11-23 10:16:18 UTC (rev 9491) @@ -1,3 +1,7 @@ +2013-11-23 Andreas Kirschbaum + + * Fix layout issues in plugin manager dialog. + 2013-10-05 Andreas Kirschbaum * Do not automatically open the help dialog when the editor is Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-11-23 10:16:18 UTC (rev 9491) @@ -177,31 +177,6 @@ @NotNull private Component createOptionsTab(@NotNull final PluginController<G, A, R> pluginController, @NotNull final ResourceIcons resourceIcons) { - final Container optionsTab = new JPanel(new GridBagLayout()); - final GridBagConstraints gbc = new GridBagConstraints(); - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - gbc.gridwidth = 2; - optionsTab.add(new JLabel("Plugin run mode", SwingConstants.LEFT), gbc); - gbc.gridwidth = 1; - gbc.gridy = 1; - gbc.weightx = 0.1; - optionsTab.add(new JPanel(), gbc); - gbc.gridx = 1; - gbc.weightx = 0.02; - final Component autoRunIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.AUTO_RUN_SMALL_ICON)); - optionsTab.add(autoRunIcon, gbc); - gbc.gridy = 2; - final Component filterIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.FILTER_SMALL_ICON)); - optionsTab.add(filterIcon, gbc); - gbc.gridy = 3; - final Component runPluginIcon = new JLabel(resourceIcons.getResourceIcon(ResourceIcons.RUN_PLUGIN_SMALL_ICON)); - optionsTab.add(runPluginIcon, gbc); - gbc.gridx = 2; - gbc.gridy = 1; - gbc.weightx = 0.9; - gbc.fill = GridBagConstraints.NONE; - gbc.anchor = GridBagConstraints.WEST; typeAutoRun.addActionListener(new ActionListener() { @Override @@ -210,8 +185,7 @@ } }); typeAutoRun.setSelected(plugin.isAutoBoot()); - optionsTab.add(typeAutoRun, gbc); - gbc.gridy = 2; + typeFilter.addActionListener(new ActionListener() { @Override @@ -220,8 +194,7 @@ } }); typeFilter.setSelected(plugin.isFilter()); - optionsTab.add(typeFilter, gbc); - gbc.gridy = 3; + typeBash.addActionListener(new ActionListener() { @Override @@ -230,10 +203,8 @@ } }); typeBash.setSelected(plugin.isScript()); - optionsTab.add(typeBash, gbc); - gbc.gridx = 0; - gbc.gridy = 4; - final AbstractButton registerButton = new JButton("re-register script"); + + final AbstractButton registerButton = new JButton("Re-register script"); registerButton.setToolTipText("Force plugin manager to unregister this plugin from filter list, launch the auto-run (if plugin is auto-start) and re-register it (if filter plugin)"); registerButton.addActionListener(new ActionListener() { @@ -242,8 +213,7 @@ pluginModel.reRegister(plugin); } }); - optionsTab.add(registerButton, gbc); - gbc.gridy = 5; + final AbstractButton exportButton = new JButton("Export script..."); exportButton.setToolTipText("Export the specified plugin as XML (for distribution)"); exportButton.addActionListener(new ActionListener() { @@ -253,14 +223,69 @@ pluginController.savePluginAs(plugin, false); } }); - optionsTab.add(exportButton, gbc); + + final Container optionsTab = new JPanel(new GridBagLayout()); + final GridBagConstraints gbc = new GridBagConstraints(); + + final Container paramButtons = new JPanel(); + paramButtons.setLayout(new StackLayout(5)); + paramButtons.add(registerButton); + paramButtons.add(exportButton); + + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.CENTER; + optionsTab.add(new JLabel("Plugin run mode", SwingConstants.LEFT), gbc); + + gbc.gridx = 0; + gbc.gridwidth = 1; + gbc.weightx = 0.0; + gbc.anchor = GridBagConstraints.CENTER; + + gbc.gridy = 1; + optionsTab.add(new JLabel(resourceIcons.getResourceIcon(ResourceIcons.AUTO_RUN_SMALL_ICON)), gbc); + gbc.gridy = 2; + optionsTab.add(new JLabel(resourceIcons.getResourceIcon(ResourceIcons.FILTER_SMALL_ICON)), gbc); + gbc.gridy = 3; + optionsTab.add(new JLabel(resourceIcons.getResourceIcon(ResourceIcons.RUN_PLUGIN_SMALL_ICON)), gbc); + + gbc.gridx = 1; + gbc.gridwidth = 1; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + + gbc.gridy = 1; + optionsTab.add(typeAutoRun, gbc); + gbc.gridy = 2; + optionsTab.add(typeFilter, gbc); + gbc.gridy = 3; + optionsTab.add(typeBash, gbc); + + gbc.gridx = 0; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.WEST; + gbc.fill = GridBagConstraints.NONE; + + gbc.gridy = 4; + optionsTab.add(paramButtons, gbc); + + gbc.gridx = 0; + gbc.gridy = 5; + gbc.gridwidth = 2; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + optionsTab.add(new JPanel(), gbc); + return optionsTab; } @NotNull private Component createParameterTab() { - final Container parameterTab = new JPanel(new BorderLayout()); - redrawTable(); plugin.addChangeListener(new ChangeListener() { @Override @@ -268,10 +293,7 @@ redrawTable(); } }); - final Component scrollPane1 = new JScrollPane(paramTable); - parameterTab.add(scrollPane1, BorderLayout.CENTER); - final Container paramButtons = new JPanel(); - paramButtons.setLayout(new StackLayout(5)); + final AbstractButton addParameter = new JButton("Add parameter"); addParameter.addActionListener(new ActionListener() { @@ -280,6 +302,7 @@ plugin.newParameter(); } }); + removeParameter.addActionListener(new ActionListener() { @Override @@ -300,9 +323,31 @@ } } }); + + final Container paramButtons = new JPanel(); + paramButtons.setLayout(new StackLayout(5)); paramButtons.add(addParameter); paramButtons.add(removeParameter); - parameterTab.add(paramButtons, BorderLayout.EAST); + + final GridBagConstraints gbc = new GridBagConstraints(); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.gridwidth = 1; + gbc.weightx = 1.0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.WEST; + + final Container parameterTab = new JPanel(new GridBagLayout()); + parameterTab.add(new JScrollPane(paramTable), gbc); + gbc.gridy++; + parameterTab.add(paramButtons, gbc); + gbc.gridy++; + gbc.weighty = 1.0; + gbc.fill = GridBagConstraints.BOTH; + parameterTab.add(new JPanel(), gbc); + + redrawTable(); return parameterTab; } @@ -310,6 +355,7 @@ private Component createCode() { final RSyntaxTextArea code = new RSyntaxTextArea(); code.setText(plugin.getCode()); + code.setCaretPosition(0); code.setFont(new Font("Monospaced", Font.PLAIN, 14)); code.getDocument().addDocumentListener(new DocumentListener() { @@ -329,6 +375,7 @@ } }); code.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); + code.setRows(40); return new RTextScrollPane(code); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManager.java 2013-11-23 10:16:18 UTC (rev 9491) @@ -22,6 +22,7 @@ import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Container; import java.awt.GridLayout; import java.awt.event.ActionEvent; @@ -87,11 +88,12 @@ /** * Creates a PluginManager. + * @param parent the parent component to center this window on * @param pluginController the script controller to base this script manager * on * @param resourceIcons the resource icons for creating icons */ - public PluginManager(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { + public PluginManager(@NotNull final Component parent, @NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { this.pluginController = pluginController; this.pluginModel = pluginModel; this.pluginParameterViewFactory = pluginParameterViewFactory; @@ -207,7 +209,7 @@ left.add(bottomLeft, BorderLayout.SOUTH); scripts.setSelectedIndex(0); frame.pack(); - frame.setVisible(true); + frame.setLocationRelativeTo(parent); } private void showScript(final Plugin<G, A, R> plugin) { @@ -243,7 +245,6 @@ * Shows the plugin manager window. */ public void show() { - frame.pack(); frame.setVisible(true); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginManagerFactory.java 2013-11-23 10:16:18 UTC (rev 9491) @@ -19,6 +19,7 @@ package net.sf.gridarta.gui.dialog.plugin; +import java.awt.Component; import javax.swing.Action; import net.sf.gridarta.gui.dialog.plugin.parameter.PluginParameterViewFactory; import net.sf.gridarta.model.archetype.Archetype; @@ -42,6 +43,12 @@ private static final ActionBuilder ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder("net.sf.gridarta"); /** + * The parent {@link Component} to center the editor window on. + */ + @NotNull + private final Component parent; + + /** * The synchronization object. */ @NotNull @@ -67,9 +74,11 @@ /** * Creates a new instance. + * @param parent the parent component to center the editor window on * @param resourceIcons the resource icons for creating icons */ - public PluginManagerFactory(@NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { + public PluginManagerFactory(@NotNull final Component parent, @NotNull final PluginController<G, A, R> pluginController, @NotNull final PluginModel<G, A, R> pluginModel, @NotNull final PluginParameterViewFactory<G, A, R> pluginParameterViewFactory, @NotNull final ResourceIcons resourceIcons) { + this.parent = parent; this.pluginController = pluginController; this.pluginModel = pluginModel; this.pluginParameterViewFactory = pluginParameterViewFactory; @@ -80,7 +89,7 @@ public void editPlugins() { synchronized (sync) { if (pluginManager == null) { - pluginManager = new PluginManager<G, A, R>(pluginController, pluginModel, pluginParameterViewFactory, resourceIcons); + pluginManager = new PluginManager<G, A, R>(parent, pluginController, pluginModel, pluginParameterViewFactory, resourceIcons); } pluginManager.show(); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-11-23 09:39:17 UTC (rev 9490) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-11-23 10:16:18 UTC (rev 9491) @@ -440,7 +440,7 @@ createToggleAction("smoothing", "Map Navigation", mapActions); createToggleAction("doubleFaces", "Map Navigation", mapActions); createToggleAction("tileShow", "Map Navigation", mapActions); - createAction("editPlugins", "Plugin", new PluginManagerFactory<G, A, R>(pluginControl, projectModel.getPluginModel(), pluginParameterViewFactory, resourceIcons)); + createAction("editPlugins", "Plugin", new PluginManagerFactory<G, A, R>(mainViewFrame, pluginControl, projectModel.getPluginModel(), pluginParameterViewFactory, resourceIcons)); createAction("savePlugins", "Plugin", pluginControl); createAction("importPlugin", "Plugin", pluginControl); createAction("update", "Tool", updaterManager); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-11-23 13:33:39
|
Revision: 9499 http://sourceforge.net/p/gridarta/code/9499 Author: akirschbaum Date: 2013-11-23 13:33:30 +0000 (Sat, 23 Nov 2013) Log Message: ----------- Update comments. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/AbstractPerMapDialogManager.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicateMapFolderException.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicatePickmapException.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/InvalidNameException.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolderNotEmptyException.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/utils/AsynchronousProgress.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterListener.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeAnimationName.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -75,4 +75,4 @@ addLine(doc, style, "", " = " + value); } -} // DialogAttributeAnimationName +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeFaceName.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -75,4 +75,4 @@ addLine(doc, style, "", " = " + value); } -} // DialogAttributeFaceName +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/gameobjectattributes/DialogAttributeString.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -77,4 +77,4 @@ addLine(doc, style, "", " = " + value); } -} // DialogAttributeString +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -93,4 +93,4 @@ return config; } -} // class MapPathParameterView +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/AbstractPerMapDialogManager.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/AbstractPerMapDialogManager.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/AbstractPerMapDialogManager.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -127,4 +127,4 @@ */ protected abstract void dispose(@NotNull final D dialog); -} // class AbstractPerMapDialogManager +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicateMapFolderException.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicateMapFolderException.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicateMapFolderException.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -40,4 +40,4 @@ super("duplicate folder: " + folderName); } -} // DuplicateMapFolderException +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicatePickmapException.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicatePickmapException.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/DuplicatePickmapException.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -40,4 +40,4 @@ super("duplicate folder: " + pickmapName); } -} // DuplicatePickmapException +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/InvalidNameException.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/InvalidNameException.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/InvalidNameException.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -40,4 +40,4 @@ super(name); } -} // InvalidNameException +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolderNotEmptyException.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolderNotEmptyException.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapfiles/MapFolderNotEmptyException.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -40,4 +40,4 @@ super("folder contains sub-folders: " + folderName); } -} // MapFolderNotEmptyException +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/undo/UndoControl.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -335,4 +335,4 @@ } } -} // UndoControl +} Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/utils/AsynchronousProgress.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/utils/AsynchronousProgress.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/utils/AsynchronousProgress.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -105,4 +105,4 @@ }); } -} // AsynchronousProgress +} Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -74,4 +74,4 @@ setValue(PathManager.getMapPath(file.getAbsolutePath(), baseDir)); } -} // class AbstractPathParameter +} Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -32,18 +32,33 @@ */ public abstract class AbstractPluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> implements PluginParameter<G, A, R> { + /** + * The current value. + */ @Nullable private V value; + /** + * The description of the value for the user interface. + */ @NotNull private String description = "[description]"; + /** + * The name of the parameter for the plugin script. + */ @NotNull private String name = "[name]"; + /** + * The listeners to be notified about changes. + */ @NotNull private final EventListenerList2<PluginParameterListener<G, A, R>> listeners = new EventListenerList2<PluginParameterListener<G, A, R>>(PluginParameterListener.class); + /** + * Creates a new instance. + */ protected AbstractPluginParameter() { } @@ -90,6 +105,11 @@ return value; } + /** + * Updates the parameter value. + * @param value the new value + * @return whether the value has changed + */ public boolean setValue(@Nullable final V value) { if (this.value == null ? value == null : this.value.equals(value)) { return false; @@ -115,6 +135,9 @@ listeners.remove(listener); } + /** + * Notifies all listeners about a state change. + */ protected void fireDataChanged() { for (final PluginParameterListener<G, A, R> listener : listeners.getListeners()) { listener.stateChanged(this); Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -35,9 +35,15 @@ @NotNull public static final String PARAMETER_TYPE = Boolean.class.getName(); + /** + * The string representation of the "true" value. + */ @NotNull private String trueText = "Yes"; + /** + * The string representation of the "false" value. + */ @NotNull private String falseText = "No"; @@ -75,20 +81,36 @@ return PARAMETER_TYPE; } + /** + * Returns the string representation of the "false" value. + * @return the string representation + */ @NotNull public String getFalseText() { return falseText; } + /** + * Returns the string representation of the "true" value. + * @return the string representation + */ @NotNull public String getTrueText() { return trueText; } + /** + * Sets the string representation of the "false" value. + * @param falseText the string representation + */ public void setFalseText(@NotNull final String falseText) { this.falseText = falseText; } + /** + * Sets the string representation of the "true" value. + * @param trueText the string representation + */ public void setTrueText(@NotNull final String trueText) { this.trueText = trueText; } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterListener.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterListener.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterListener.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -32,6 +32,10 @@ */ public interface PluginParameterListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends EventListener { + /** + * Called whenever a plugin parameter's value has changed. + * @param pluginParameter the plugin parameter that has changed + */ void stateChanged(@NotNull PluginParameter<G, A, R> pluginParameter); } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -26,31 +26,72 @@ /** * Interface for visitors of {@link PluginParameter} instances. + * @param <T> an implementation-specific type for visitor return values * @author Andreas Kirschbaum */ public interface PluginParameterVisitor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T> { + /** + * Called for {@link ArchParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull ArchParameter<G, A, R> parameter); + /** + * Called for {@link BooleanParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull BooleanParameter<G, A, R> parameter); + /** + * Called for {@link DoubleParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull DoubleParameter<G, A, R> parameter); + /** + * Called for {@link FilterParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull FilterParameter<G, A, R> parameter); + /** + * Called for {@link IntegerParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull IntegerParameter<G, A, R> parameter); + /** + * Called for {@link MapParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull MapParameter<G, A, R> parameter); + /** + * Called for {@link MapPathParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull MapPathParameter<G, A, R> parameter); + /** + * Called for {@link StringParameter} instances. + * @param parameter the parameter instance + * @return an implementation-specific return value + */ @NotNull T visit(@NotNull StringParameter<G, A, R> parameter); Modified: trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java =================================================================== --- trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2013-11-23 13:32:53 UTC (rev 9498) +++ trunk/src/textedit/src/main/java/net/sf/gridarta/textedit/textarea/tokenmarker/TokenMarkerFactory.java 2013-11-23 13:33:30 UTC (rev 9499) @@ -111,4 +111,4 @@ } } -} // TokenMarkerFactory +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-11-23 13:42:03
|
Revision: 9502 http://sourceforge.net/p/gridarta/code/9502 Author: akirschbaum Date: 2013-11-23 13:41:59 +0000 (Sat, 23 Nov 2013) Log Message: ----------- Rename class name. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterFactory.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java Added Paths: ----------- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java Removed Paths: ------------- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchParameter.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java 2013-11-23 13:39:53 UTC (rev 9501) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -28,7 +28,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmanager.MapManager; -import net.sf.gridarta.plugin.parameter.ArchParameter; +import net.sf.gridarta.plugin.parameter.ArchetypeParameter; import net.sf.gridarta.plugin.parameter.BooleanParameter; import net.sf.gridarta.plugin.parameter.DoubleParameter; import net.sf.gridarta.plugin.parameter.FilterParameter; @@ -76,7 +76,7 @@ @NotNull @Override - public PluginParameterView<G, A, R> visit(@NotNull final ArchParameter<G, A, R> parameter) { + public PluginParameterView<G, A, R> visit(@NotNull final ArchetypeParameter<G, A, R> parameter) { return new ArchParameterView<G, A, R>(parameter, gameObjectAttributesModel, archetypeSet, objectChooser, faceObjectProviders); } Deleted: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchParameter.java 2013-11-23 13:39:53 UTC (rev 9501) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchParameter.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -1,107 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.plugin.parameter; - -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.archetype.UndefinedArchetypeException; -import net.sf.gridarta.model.archetypeset.ArchetypeSet; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.maparchobject.MapArchObject; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * A {@link PluginParameter} that holds an {@link Archetype} value. - */ -public class ArchParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Archetype<G, A, R>> { - - /** - * The string representation of this parameter type. - */ - @NotNull - public static final String PARAMETER_TYPE = Archetype.class.getName(); - - /** - * The {@link ArchetypeSet} for looking up archetypes. - */ - @NotNull - private final ArchetypeSet<G, A, R> archetypeSet; - - private String valueString; - - /** - * Creates a new instance. - * @param archetypeSet the archetype set for looking up archetypes - */ - public ArchParameter(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { - this.archetypeSet = archetypeSet; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public <T> T visit(@NotNull final PluginParameterVisitor<G, A, R, T> visitor) { - return visitor.visit(this); - } - - /** - * {@inheritDoc} - */ - @Nullable - @Override - public Archetype<G, A, R> getValue() { - if (super.getValue() == null) { - setValue(archetypeSet.getOrCreateArchetype(valueString)); - } - return super.getValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean setStringValue(@NotNull final String value) { - final Archetype<G, A, R> archetype; - try { - archetype = archetypeSet.getArchetype(value); - } catch (final UndefinedArchetypeException ignored) { - return false; - } - setValue(archetype); - return true; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getParameterType() { - return PARAMETER_TYPE; - } - - @Nullable - public String getValueString() { - return valueString; - } - -} Copied: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java (from rev 9493, trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchParameter.java) =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java (rev 0) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -0,0 +1,107 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.plugin.parameter; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.archetype.UndefinedArchetypeException; +import net.sf.gridarta.model.archetypeset.ArchetypeSet; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A {@link PluginParameter} that holds an {@link Archetype} value. + */ +public class ArchetypeParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Archetype<G, A, R>> { + + /** + * The string representation of this parameter type. + */ + @NotNull + public static final String PARAMETER_TYPE = Archetype.class.getName(); + + /** + * The {@link ArchetypeSet} for looking up archetypes. + */ + @NotNull + private final ArchetypeSet<G, A, R> archetypeSet; + + private String valueString; + + /** + * Creates a new instance. + * @param archetypeSet the archetype set for looking up archetypes + */ + public ArchetypeParameter(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { + this.archetypeSet = archetypeSet; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public <T> T visit(@NotNull final PluginParameterVisitor<G, A, R, T> visitor) { + return visitor.visit(this); + } + + /** + * {@inheritDoc} + */ + @Nullable + @Override + public Archetype<G, A, R> getValue() { + if (super.getValue() == null) { + setValue(archetypeSet.getOrCreateArchetype(valueString)); + } + return super.getValue(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean setStringValue(@NotNull final String value) { + final Archetype<G, A, R> archetype; + try { + archetype = archetypeSet.getArchetype(value); + } catch (final UndefinedArchetypeException ignored) { + return false; + } + setValue(archetype); + return true; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getParameterType() { + return PARAMETER_TYPE; + } + + @Nullable + public String getValueString() { + return valueString; + } + +} Property changes on: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +LF \ No newline at end of property Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-23 13:39:53 UTC (rev 9501) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -64,7 +64,7 @@ @NotNull @Override - public Element visit(@NotNull final ArchParameter<G, A, R> parameter) { + public Element visit(@NotNull final ArchetypeParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); final Archetype<G, A, R> archetype = parameter.getValue(); @@ -190,7 +190,7 @@ @NotNull @Override - public PluginParameter<G, A, R> visit(@NotNull final ArchParameter<G, A, R> parameter) { + public PluginParameter<G, A, R> visit(@NotNull final ArchetypeParameter<G, A, R> parameter) { fromXML(parameter); assert e != null; parameter.setStringValue(e.getChildTextTrim("value")); Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterFactory.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterFactory.java 2013-11-23 13:39:53 UTC (rev 9501) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterFactory.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -92,8 +92,8 @@ if (type.equals(BooleanParameter.PARAMETER_TYPE)) { return new BooleanParameter<G, A, R>(); } - if (type.equals(ArchParameter.PARAMETER_TYPE)) { - return new ArchParameter<G, A, R>(archetypeSet); + if (type.equals(ArchetypeParameter.PARAMETER_TYPE)) { + return new ArchetypeParameter<G, A, R>(archetypeSet); } if (type.equals(MapParameter.PARAMETER_TYPE)) { return new MapParameter<G, A, R>(mapManager); @@ -116,7 +116,7 @@ @NotNull public String[] getTypes() { - return new String[] { StringParameter.PARAMETER_TYPE, IntegerParameter.PARAMETER_TYPE, DoubleParameter.PARAMETER_TYPE, BooleanParameter.PARAMETER_TYPE, ArchParameter.PARAMETER_TYPE, MapParameter.PARAMETER_TYPE, FilterParameter.PARAMETER_TYPE, MapPathParameter.PARAMETER_TYPE, }; + return new String[] { StringParameter.PARAMETER_TYPE, IntegerParameter.PARAMETER_TYPE, DoubleParameter.PARAMETER_TYPE, BooleanParameter.PARAMETER_TYPE, ArchetypeParameter.PARAMETER_TYPE, MapParameter.PARAMETER_TYPE, FilterParameter.PARAMETER_TYPE, MapPathParameter.PARAMETER_TYPE, }; } } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java 2013-11-23 13:39:53 UTC (rev 9501) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterVisitor.java 2013-11-23 13:41:59 UTC (rev 9502) @@ -32,12 +32,12 @@ public interface PluginParameterVisitor<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T> { /** - * Called for {@link ArchParameter} instances. + * Called for {@link ArchetypeParameter} instances. * @param parameter the parameter instance * @return an implementation-specific return value */ @NotNull - T visit(@NotNull ArchParameter<G, A, R> parameter); + T visit(@NotNull ArchetypeParameter<G, A, R> parameter); /** * Called for {@link BooleanParameter} instances. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-11-24 08:35:19
|
Revision: 9506 http://sourceforge.net/p/gridarta/code/9506 Author: akirschbaum Date: 2013-11-24 08:35:12 +0000 (Sun, 24 Nov 2013) Log Message: ----------- Fix plugin script parameter editor. Modified Paths: -------------- trunk/src/atrinik/ChangeLog trunk/src/crossfire/ChangeLog trunk/src/daimonin/ChangeLog trunk/src/plugin/build.gradle trunk/src/plugin/plugin.iml trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/StringParameter.java Added Paths: ----------- trunk/src/plugin/src/test/java/net/ trunk/src/plugin/src/test/java/net/sf/ trunk/src/plugin/src/test/java/net/sf/gridarta/ trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/ trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/ trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java Modified: trunk/src/atrinik/ChangeLog =================================================================== --- trunk/src/atrinik/ChangeLog 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/atrinik/ChangeLog 2013-11-24 08:35:12 UTC (rev 9506) @@ -1,3 +1,7 @@ +2013-11-24 Andreas Kirschbaum + + * Fix plugin script parameter editor. + 2013-11-23 Andreas Kirschbaum * Fix layout issues in plugin manager dialog. Modified: trunk/src/crossfire/ChangeLog =================================================================== --- trunk/src/crossfire/ChangeLog 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/crossfire/ChangeLog 2013-11-24 08:35:12 UTC (rev 9506) @@ -1,3 +1,7 @@ +2013-11-24 Andreas Kirschbaum + + * Fix plugin script parameter editor. + 2013-11-23 Andreas Kirschbaum * Fix layout issues in plugin manager dialog. Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/daimonin/ChangeLog 2013-11-24 08:35:12 UTC (rev 9506) @@ -1,3 +1,7 @@ +2013-11-24 Andreas Kirschbaum + + * Fix plugin script parameter editor. + 2013-11-23 Andreas Kirschbaum * Fix layout issues in plugin manager dialog. Modified: trunk/src/plugin/build.gradle =================================================================== --- trunk/src/plugin/build.gradle 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/plugin/build.gradle 2013-11-24 08:35:12 UTC (rev 9506) @@ -9,4 +9,5 @@ compile name: 'log4j', version: '1.2.13' compile project(':src:model') testCompile name: 'junit', version: '4.2' + testCompile project(':src:model').sourceSets.test.output } Modified: trunk/src/plugin/plugin.iml =================================================================== --- trunk/src/plugin/plugin.iml 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/plugin/plugin.iml 2013-11-24 08:35:12 UTC (rev 9506) @@ -17,6 +17,7 @@ <orderEntry type="library" name="bsh-core" level="project" /> <orderEntry type="library" name="bsh-util" level="project" /> <orderEntry type="library" name="jdom" level="project" /> + <orderEntry type="library" name="junit" level="project" /> <orderEntry type="library" name="log4j" level="project" /> </component> </module> Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java 2013-11-24 08:35:12 UTC (rev 9506) @@ -91,7 +91,7 @@ * @param max the maximal allowed value */ public void setMax(final int max) { - this.max = Math.min(min, max); + this.max = Math.max(min, max); if (getValue() > this.max) { setValue(this.max); } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-24 08:35:12 UTC (rev 9506) @@ -215,7 +215,13 @@ @Override public PluginParameter<G, A, R> visit(@NotNull final DoubleParameter<G, A, R> parameter) { fromXML(parameter); + final String val = e.getChildText("value"); try { + parameter.setValue(NumberUtils.parseDouble(val)); + } catch (final NumberFormatException ignored) { + parameter.setValue(0.0); + } + try { parameter.setMin(Double.parseDouble(e.getChildTextTrim("minimum"))); } catch (final NumberFormatException ignored) { } @@ -223,8 +229,6 @@ parameter.setMax(Double.parseDouble(e.getChildTextTrim("maximum"))); } catch (final NumberFormatException ignored) { } - final String val = e.getChildText("value"); - parameter.setValue(NumberUtils.parseDouble(val)); return parameter; } @@ -245,8 +249,7 @@ fromXML(parameter); final String val = e.getChildText("value"); try { - final Integer iVal = Integer.parseInt(val); - parameter.setValue(iVal); + parameter.setValue(Integer.parseInt(val)); } catch (final NumberFormatException ignored) { parameter.setValue(0); } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/StringParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/StringParameter.java 2013-11-23 15:16:13 UTC (rev 9505) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/StringParameter.java 2013-11-24 08:35:12 UTC (rev 9506) @@ -49,7 +49,7 @@ if (log.isDebugEnabled()) { log.debug("New instance of " + StringParameter.class.getName()); } - setValue("[description]"); + setValue(""); } /** Added: trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java =================================================================== --- trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java (rev 0) +++ trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java 2013-11-24 08:35:12 UTC (rev 9506) @@ -0,0 +1,901 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.plugin.parameter; + +import java.io.File; +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.Collections; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.filter.NamedFilter; +import net.sf.gridarta.model.filter.NamedFilterConfig; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcontrol.TestMapControlCreator; +import net.sf.gridarta.model.mapmodel.TestMapModelCreator; +import net.sf.gridarta.model.match.NamedGameObjectMatcher; +import net.sf.gridarta.utils.Size2D; +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Ignore; +import org.junit.Test; + +/** + * Regression tests for {@link PluginParameterCodec}. + * @author Andreas Kirschbaum + */ +public class PluginParameterCodecTest { + + /** + * Checks that an {@link ArchetypeParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Ignore + @Test + public void testArchetypeToXml1() throws IOException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new ArchetypeParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapModelCreator.getArchetypeSet()); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value/>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that an {@link ArchetypeParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Ignore + @Test + public void testArchetypeToXml2() throws IOException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new ArchetypeParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapModelCreator.getArchetypeSet()); + parameter.setStringValue("undefined_archetype"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value>undefined_archetype</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that an {@link ArchetypeParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testArchetypeToXml3() throws IOException { + final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); + final TestArchetype archetype = mapModelCreator.getArchetype("existing_archetype"); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new ArchetypeParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapModelCreator.getArchetypeSet()); + parameter.setStringValue(archetype.getArchetypeName()); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value>existing_archetype</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link BooleanParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testBooleanToXml1() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new BooleanParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Boolean</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <trueText>Yes</trueText>\r\n"); + sb.append(" <falseText>No</falseText>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link BooleanParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testBooleanToXml2() throws IOException { + final BooleanParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new BooleanParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setStringValue("true"); + parameter.setTrueText("true-text"); + parameter.setFalseText("false-text"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>java.lang.Boolean</type>\r\n"); + sb.append(" <value>true</value>\r\n"); + sb.append(" <trueText>true-text</trueText>\r\n"); + sb.append(" <falseText>false-text</falseText>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link DoubleParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testDoubleToXml1() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new DoubleParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Double</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <minimum>0.0</minimum>\r\n"); + sb.append(" <maximum>1.0</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link DoubleParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testDoubleToXml2() throws IOException { + final DoubleParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new DoubleParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setValue(12.34); + parameter.setMin(-123.456); + parameter.setMax(234.0); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>java.lang.Double</type>\r\n"); + sb.append(" <value>12.34</value>\r\n"); + sb.append(" <minimum>-123.456</minimum>\r\n"); + sb.append(" <maximum>234.0</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link FilterParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testFilterToXml1() throws IOException { + final Iterable<NamedGameObjectMatcher> matchers = Collections.emptyList(); + final NamedFilter namedFilter = new NamedFilter(matchers); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new FilterParameter<TestGameObject, TestMapArchObject, TestArchetype>(namedFilter); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.filter.NamedFilterConfig</type>\r\n"); + sb.append(" <value>\r\n"); + sb.append(" <enabled>false</enabled>\r\n"); + sb.append(" <inverted>false</inverted>\r\n"); + sb.append(" </value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link FilterParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testFilterToXml2() throws IOException { + final Iterable<NamedGameObjectMatcher> matchers = Collections.emptyList(); + final NamedFilter namedFilter = new NamedFilter(matchers); + final AbstractPluginParameter<TestGameObject, TestMapArchObject, TestArchetype, NamedFilterConfig> parameter = new FilterParameter<TestGameObject, TestMapArchObject, TestArchetype>(namedFilter); + final NamedFilterConfig config = namedFilter.createConfig(); + config.setInverted(true); + config.setEnabled(true); + parameter.setValue(config); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.filter.NamedFilterConfig</type>\r\n"); + sb.append(" <value>\r\n"); + sb.append(" <enabled>true</enabled>\r\n"); + sb.append(" <inverted>true</inverted>\r\n"); + sb.append(" </value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that an {@link IntegerParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testIntegerToXml1() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new IntegerParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Integer</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <minimum>-2147483648</minimum>\r\n"); + sb.append(" <maximum>2147483647</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that an {@link IntegerParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testIntegerToXml2() throws IOException { + final IntegerParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new IntegerParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setValue(2); + parameter.setMin(-123); + parameter.setMax(234); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>java.lang.Integer</type>\r\n"); + sb.append(" <value>2</value>\r\n"); + sb.append(" <minimum>-123</minimum>\r\n"); + sb.append(" <maximum>234</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link MapParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testMapToXml1() throws IOException { + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new MapParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapControlCreator.getMapManager()); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.mapcontrol.MapControl</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link MapParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testMapToXml2() throws IOException { + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final MapParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new MapParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapControlCreator.getMapManager()); + parameter.setValueToCurrent(); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.mapcontrol.MapControl</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link MapParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Ignore + @Test + public void testMapToXml3() throws IOException { + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final AbstractPluginParameter<TestGameObject, TestMapArchObject, TestArchetype, Object> parameter = new MapParameter<TestGameObject, TestMapArchObject, TestArchetype>(mapControlCreator.getMapManager()); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = mapControlCreator.newMapControl(new File("/tmp/path/to/map"), "map name", new Size2D(13, 15)); + parameter.setValue(mapControl); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.mapcontrol.MapControl</type>\r\n"); + sb.append(" <value>/path/to/map</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link MapPathParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testMapPathToXml1() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new MapPathParameter<TestGameObject, TestMapArchObject, TestArchetype>(new File("/tmp")); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>MapPathParameter</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link MapPathParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testMapPathToXml2() throws IOException { + final AbstractPluginParameter<TestGameObject, TestMapArchObject, TestArchetype, String> parameter = new MapPathParameter<TestGameObject, TestMapArchObject, TestArchetype>(new File("/tmp")); + parameter.setValue("/path"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>MapPathParameter</type>\r\n"); + sb.append(" <value>/path</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link StringParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testStringToXml1() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new StringParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setName("Name"); + parameter.setDescription("Description"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.String</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link StringParameter} instance is correctly encoded. + * @throws IOException if the test fails + */ + @Test + public void testStringToXml2() throws IOException { + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = new StringParameter<TestGameObject, TestMapArchObject, TestArchetype>(); + parameter.setStringValue("string value"); + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>[name]</name>\r\n"); + sb.append(" <description>[description]</description>\r\n"); + sb.append(" <type>java.lang.String</type>\r\n"); + sb.append(" <value>string value</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + Assert.assertEquals(sb.toString(), toXML(parameter)); + } + + /** + * Checks that a {@link ArchetypeParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Ignore + @Test + public void testArchetypeFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value/>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof ArchetypeParameter); + final ArchetypeParameter<?, ?, ?> archetypeParameter = (ArchetypeParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.archetype.Archetype", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertNull(parameter.getValue()); + Assert.assertEquals("XXX", archetypeParameter.getValueString()); + } + + /** + * Checks that an {@link ArchetypeParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Ignore + @Test + public void testArchetypeFromXml2() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value>undefined_archetype</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof ArchetypeParameter); + final ArchetypeParameter<?, ?, ?> archetypeParameter = (ArchetypeParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.archetype.Archetype", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertNull(parameter.getValue()); + Assert.assertEquals("undefined_archetype", archetypeParameter.getValueString()); + } + + /** + * Checks that an {@link ArchetypeParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Ignore + @Test + public void testArchetypeFromXml3() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.archetype.Archetype</type>\r\n"); + sb.append(" <value>existing_archetype</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final TestArchetype archetype = mapControlCreator.getMapModelCreator().getArchetype("existing_archetype"); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof ArchetypeParameter); + final ArchetypeParameter<?, ?, ?> archetypeParameter = (ArchetypeParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.archetype.Archetype", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertSame(archetype, parameter.getValue()); + Assert.assertEquals("existing_archetype", archetypeParameter.getValueString()); + } + + /** + * Checks that a {@link BooleanParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testBooleanFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Boolean</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <trueText>Yes</trueText>\r\n"); + sb.append(" <falseText>No</falseText>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof BooleanParameter); + final BooleanParameter<?, ?, ?> booleanParameter = (BooleanParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Boolean", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertSame(Boolean.FALSE, parameter.getValue()); + Assert.assertEquals("No", booleanParameter.getFalseText()); + Assert.assertEquals("Yes", booleanParameter.getTrueText()); + } + + /** + * Checks that a {@link BooleanParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testBooleanFromXml2() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Boolean</type>\r\n"); + sb.append(" <value>true</value>\r\n"); + sb.append(" <trueText>true-text</trueText>\r\n"); + sb.append(" <falseText>false-text</falseText>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof BooleanParameter); + final BooleanParameter<?, ?, ?> booleanParameter = (BooleanParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Boolean", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertSame(Boolean.TRUE, parameter.getValue()); + Assert.assertEquals("false-text", booleanParameter.getFalseText()); + Assert.assertEquals("true-text", booleanParameter.getTrueText()); + } + + /** + * Checks that a {@link DoubleParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testDoubleFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Double</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <minimum>0.0</minimum>\r\n"); + sb.append(" <maximum>1.0</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof DoubleParameter); + final DoubleParameter<?, ?, ?> doubleParameter = (DoubleParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Double", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertEquals(0.0, parameter.getValue()); + Assert.assertEquals(0.0, doubleParameter.getMin()); + Assert.assertEquals(1.0, doubleParameter.getMax()); + } + + /** + * Checks that a {@link DoubleParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testDoubleFromXml2() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Double</type>\r\n"); + sb.append(" <value>12.34</value>\r\n"); + sb.append(" <minimum>-123.456</minimum>\r\n"); + sb.append(" <maximum>234.0</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof DoubleParameter); + final DoubleParameter<?, ?, ?> doubleParameter = (DoubleParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Double", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertEquals(12.34, parameter.getValue()); + Assert.assertEquals(-123.456, doubleParameter.getMin()); + Assert.assertEquals(234.0, doubleParameter.getMax()); + } + + /** + * Checks that a {@link FilterParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testFilterFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.filter.NamedFilterConfig</type>\r\n"); + sb.append(" <value>\r\n"); + sb.append(" <enabled>false</enabled>\r\n"); + sb.append(" <inverted>false</inverted>\r\n"); + sb.append(" </value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof FilterParameter); + //noinspection TypeMayBeWeakened + final FilterParameter<?, ?, ?> filterParameter = (FilterParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.filter.NamedFilterConfig", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertFalse(filterParameter.getValue().isEnabled()); + Assert.assertFalse(filterParameter.getValue().isInverted()); + } + + /** + * Checks that a {@link FilterParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testFilterFromXml2() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.filter.NamedFilterConfig</type>\r\n"); + sb.append(" <value>\r\n"); + sb.append(" <enabled>true</enabled>\r\n"); + sb.append(" <inverted>true</inverted>\r\n"); + sb.append(" </value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof FilterParameter); + //noinspection TypeMayBeWeakened + final FilterParameter<?, ?, ?> filterParameter = (FilterParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.filter.NamedFilterConfig", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertTrue(filterParameter.getValue().isEnabled()); + Assert.assertTrue(filterParameter.getValue().isInverted()); + } + + /** + * Checks that an {@link IntegerParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testIntegerFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Integer</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append(" <minimum>-2147483648</minimum>\r\n"); + sb.append(" <maximum>2147483647</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof IntegerParameter); + final IntegerParameter<?, ?, ?> integerParameter = (IntegerParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Integer", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertEquals(0, parameter.getValue()); + Assert.assertEquals(-2147483648, integerParameter.getMin()); + Assert.assertEquals(2147483647, integerParameter.getMax()); + } + + /** + * Checks that an {@link IntegerParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testIntegerFromXml2() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>java.lang.Integer</type>\r\n"); + sb.append(" <value>2</value>\r\n"); + sb.append(" <minimum>-123</minimum>\r\n"); + sb.append(" <maximum>234</maximum>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof IntegerParameter); + final IntegerParameter<?, ?, ?> integerParameter = (IntegerParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("java.lang.Integer", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertEquals(2, parameter.getValue()); + Assert.assertEquals(-123, integerParameter.getMin()); + Assert.assertEquals(234, integerParameter.getMax()); + } + + /** + * Checks that a {@link MapParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Test + public void testMapFromXml1() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.mapcontrol.MapControl</type>\r\n"); + sb.append(" <value />\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof MapParameter); + //final MapParameter<?, ?, ?> mapParameter = (MapParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.mapcontrol.MapControl", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + Assert.assertSame(mapControlCreator.getMapManager().getCurrentMap(), parameter.getValue()); + } + + /** + * Checks that a {@link MapParameter} is correctly decoded. + * @throws IOException if the test fails + * @throws JDOMException if the test fails + * @throws NoSuchParameterException if the test fails + */ + @Ignore + @Test + public void testMapFromXml3() throws IOException, JDOMException, NoSuchParameterException { + final StringBuilder sb = new StringBuilder(); + sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n"); + sb.append("<parameter>\r\n"); + sb.append(" <name>Name</name>\r\n"); + sb.append(" <description>Description</description>\r\n"); + sb.append(" <type>net.sf.gridarta.model.mapcontrol.MapControl</type>\r\n"); + sb.append(" <value>/path/to/map</value>\r\n"); + sb.append("</parameter>\r\n"); + sb.append("\r\n"); + final TestMapControlCreator mapControlCreator = new TestMapControlCreator(); + mapControlCreator.getMapManager().newMap(null, new TestMapArchObject(), new File("/tmp/path/to/map"), false); + final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter = fromXML(mapControlCreator, sb.toString()); + Assert.assertTrue(parameter instanceof MapParameter); + //noinspection TypeMayBeWeakened + final MapParameter<?, ?, ?> mapParameter = (MapParameter<?, ?, ?>) parameter; + Assert.assertEquals("Name", parameter.getName()); + Assert.assertEquals("net.sf.gridarta.model.mapcontrol.MapControl", parameter.getParameterType()); + Assert.assertEquals("Description", parameter.getDescription()); + final MapControl<?, ?, ?> mapControl2 = (MapControl<?, ?, ?>) mapParameter.getValue(); + Assert.assertNotNull(mapControl2); + final File mapFile = mapControl2.getMapModel().getMapFile(); + Assert.assertNotNull(mapFile); + Assert.assertTrue(mapFile.getPath().endsWith("/path/to/map")); + } + + /** + * Encodes a {@link PluginParameter} to its string representation. + * @param parameter the plugin parameter + * @return the string representation + * @throws IOException if encoding fails + */ + @NotNull + private static String toXML(@NotNull final PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> parameter) throws IOException { + final PluginParameterCodec<TestGameObject, TestMapArchObject, TestArchetype> codec = new PluginParameterCodec<TestGameObject, TestMapArchObject, TestArchetype>(); + final Element element = codec.toXML(parameter); + final Document d = new Document(element); + final XMLOutputter out = new XMLOutputter(); + out.setFormat(Format.getPrettyFormat()); + final Writer writer = new StringWriter(); + out.output(d, writer); + //noinspection ObjectToString + return writer.toString(); + } + + /** + * Decodes a {@link PluginParameter} from its string representation. + * @param mapControlCreator the map control creator to use + * @param string the string representation + * @return the plugin parameter + * @throws IOException if decoding fails + * @throws JDOMException if decoding fails + * @throws NoSuchParameterException if decoding fails + */ + @NotNull + private static PluginParameter<TestGameObject, TestMapArchObject, TestArchetype> fromXML(@NotNull final TestMapControlCreator mapControlCreator, @NotNull final String string) throws IOException, JDOMException, NoSuchParameterException { + final SAXBuilder builder = new SAXBuilder(false); + final Document document = builder.build(new StringReader(string)); + final Iterable<NamedGameObjectMatcher> matchers = Collections.emptyList(); + final NamedFilter filterList = new NamedFilter(matchers); + final PluginParameterFactory<TestGameObject, TestMapArchObject, TestArchetype> parameterFactory = new PluginParameterFactory<TestGameObject, TestMapArchObject, TestArchetype>(mapControlCreator.getArchetypeSet(), mapControlCreator.getMapManager(), filterList, mapControlCreator.getProjectSettings()); + final Element element = document.getRootElement(); + return parameterFactory.createParameter(element); + } + +} Property changes on: trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-11-24 09:32:26
|
Revision: 9510 http://sourceforge.net/p/gridarta/code/9510 Author: akirschbaum Date: 2013-11-24 09:32:18 +0000 (Sun, 24 Nov 2013) Log Message: ----------- Clean up plugin parameter implementations. Fixes archetype plugin parameters. Modified Paths: -------------- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ArchParameterView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/IntegerParameterView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapParameterView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterDescriptionEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterNameEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterTypeEditor.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/StringParameterView.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/Plugin.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginExecutor.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginModelParser.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/DoubleParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/FilterParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/MapParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterFactory.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/StringParameter.java trunk/src/plugin/src/test/java/net/sf/gridarta/plugin/parameter/PluginParameterCodecTest.java Added Paths: ----------- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractStringPluginParameter.java trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractValuePluginParameter.java Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginEditor.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -105,16 +105,16 @@ private final Plugin<G, A, R> plugin; @NotNull - private final Map<PluginParameter<G, A, R>, ParameterNameEditor<G, A, R>> paramNameEditors = new HashMap<PluginParameter<G, A, R>, ParameterNameEditor<G, A, R>>(); + private final Map<PluginParameter<G, A, R, ?>, ParameterNameEditor<G, A, R>> paramNameEditors = new HashMap<PluginParameter<G, A, R, ?>, ParameterNameEditor<G, A, R>>(); @NotNull - private final Map<PluginParameter<G, A, R>, ParameterDescriptionEditor<G, A, R>> paramDescriptionEditors = new HashMap<PluginParameter<G, A, R>, ParameterDescriptionEditor<G, A, R>>(); + private final Map<PluginParameter<G, A, R, ?>, ParameterDescriptionEditor<G, A, R>> paramDescriptionEditors = new HashMap<PluginParameter<G, A, R, ?>, ParameterDescriptionEditor<G, A, R>>(); @NotNull - private final Map<PluginParameter<G, A, R>, ParameterTypeEditor<G, A, R>> paramTypeEditors = new HashMap<PluginParameter<G, A, R>, ParameterTypeEditor<G, A, R>>(); + private final Map<PluginParameter<G, A, R, ?>, ParameterTypeEditor<G, A, R>> paramTypeEditors = new HashMap<PluginParameter<G, A, R, ?>, ParameterTypeEditor<G, A, R>>(); @NotNull - private final Map<PluginParameter<G, A, R>, PluginParameterView<G, A, R>> paramViews = new HashMap<PluginParameter<G, A, R>, PluginParameterView<G, A, R>>(); + private final Map<PluginParameter<G, A, R, ?>, PluginParameterView<G, A, R>> paramViews = new HashMap<PluginParameter<G, A, R, ?>, PluginParameterView<G, A, R>>(); private int selectedRow = -1; @@ -337,7 +337,7 @@ gbc.gridx = 4; paramTable.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "pluginEditorTitleDefault.text"), gbc); int i = 0; - for (final PluginParameter<G, A, R> parameter : plugin) { + for (final PluginParameter<G, A, R, ?> parameter : plugin) { gbc.gridy = i + 1; putRow(gbc, parameter); i++; @@ -350,7 +350,7 @@ c.addMouseListener(cellMouseListener); } - private Component getParameterNameEditor(@NotNull final PluginParameter<G, A, R> param) { + private Component getParameterNameEditor(@NotNull final PluginParameter<G, A, R, ?> param) { if (log.isDebugEnabled()) { log.debug("Doing " + param); } @@ -366,7 +366,7 @@ return newParameterNameEditor; } - private Component getParameterDescriptionEditor(@NotNull final PluginParameter<G, A, R> param) { + private Component getParameterDescriptionEditor(@NotNull final PluginParameter<G, A, R, ?> param) { final Component existingParameterDescriptionEditor = paramDescriptionEditors.get(param); if (existingParameterDescriptionEditor != null) { return existingParameterDescriptionEditor; @@ -378,7 +378,7 @@ return newParameterDescriptionEditor; } - private Component getParameterTypeEditor(@NotNull final PluginParameter<G, A, R> param) { + private Component getParameterTypeEditor(@NotNull final PluginParameter<G, A, R, ?> param) { final Component existingParameterTypeEditor = paramTypeEditors.get(param); if (existingParameterTypeEditor != null) { return existingParameterTypeEditor; @@ -390,7 +390,7 @@ return newParameterTypeEditor; } - private PluginParameterView<G, A, R> getParameterView(@NotNull final PluginParameter<G, A, R> param) { + private PluginParameterView<G, A, R> getParameterView(@NotNull final PluginParameter<G, A, R, ?> param) { final PluginParameterView<G, A, R> existingPluginParameterView = paramViews.get(param); if (existingPluginParameterView != null) { return existingPluginParameterView; @@ -405,7 +405,7 @@ return newPluginParameterView; } - private void putRow(@NotNull final GridBagConstraints gbc, @NotNull final PluginParameter<G, A, R> param) { + private void putRow(@NotNull final GridBagConstraints gbc, @NotNull final PluginParameter<G, A, R, ?> param) { gbc.gridx = 0; paramTable.add(getParameterNameEditor(param), gbc); gbc.gridx = 1; @@ -518,7 +518,7 @@ return; } - final PluginParameter<G, A, R> parameter; + final PluginParameter<G, A, R, ?> parameter; try { parameter = plugin.getParameter(selectedRow); } catch (final NoSuchParameterException ignored) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/PluginView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -222,7 +222,7 @@ dialog.setModal(true); dialog.getContentPane().removeAll(); int i = 0; - for (final PluginParameter<G, A, R> parameter : plugin) { + for (final PluginParameter<G, A, R, ?> parameter : plugin) { log.debug("adding parameter"); final Component name = new JLabel(parameter.getName()); final PluginParameterView<G, A, R> view = pluginParameterViewFactory.getView(panel, parameter); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ArchParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ArchParameterView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ArchParameterView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -31,7 +31,7 @@ import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.plugin.parameter.AbstractPluginParameter; +import net.sf.gridarta.plugin.parameter.ArchetypeParameter; import org.jetbrains.annotations.NotNull; public class ArchParameterView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements PluginParameterView<G, A, R> { @@ -43,14 +43,14 @@ private final JComboBox value; @NotNull - private final AbstractPluginParameter<G, A, R, Archetype<G, A, R>> parameter; + private final ArchetypeParameter<G, A, R> parameter; /** * Creates a new instance. * @param faceObjectProviders the face object providers for looking up * faces */ - public ArchParameterView(@NotNull final AbstractPluginParameter<G, A, R, Archetype<G, A, R>> param, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final FaceObjectProviders faceObjectProviders) { + public ArchParameterView(@NotNull final ArchetypeParameter<G, A, R> param, @NotNull final GameObjectAttributesModel<G, A, R> gameObjectAttributesModel, @NotNull final ArchetypeSet<G, A, R> archetypeSet, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final FaceObjectProviders faceObjectProviders) { value = new ArchComboBox<G, A, R>(gameObjectAttributesModel, archetypeSet, objectChooser, faceObjectProviders); parameter = param; value.setSelectedItem(param.getValue()); @@ -62,7 +62,7 @@ //JComboBox does not use type parameters @SuppressWarnings("unchecked") final Archetype<G, A, R> archetype = (Archetype<G, A, R>) value.getSelectedItem(); - parameter.setValue(archetype); + parameter.setStringValue(archetype.getArchetypeName()); } } }); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/IntegerParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/IntegerParameterView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/IntegerParameterView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -26,7 +26,6 @@ import javax.swing.JComponent; import javax.swing.JOptionPane; import javax.swing.JSpinner; -import javax.swing.SpinnerModel; import javax.swing.SpinnerNumberModel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -49,12 +48,7 @@ public IntegerParameterView(@NotNull final IntegerParameter<G, A, R> parameter) { this.parameter = parameter; - final SpinnerModel mdl = new SpinnerNumberModel(0, parameter.getMin(), parameter.getMax(), 1); - value = new TooltipSpinner(mdl); - try { - value.setValue(parameter.getValue()); - } catch (final Exception ignored) { - } + value = new TooltipSpinner(new SpinnerNumberModel((int) parameter.getValue(), parameter.getMin(), parameter.getMax(), 1)); value.addChangeListener(new ChangeListener() { @Override Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapParameterView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapParameterView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -21,6 +21,7 @@ import java.awt.event.ItemEvent; import java.awt.event.ItemListener; +import java.io.File; import javax.swing.ComboBoxModel; import javax.swing.JComboBox; import javax.swing.JComponent; @@ -28,6 +29,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapcontrol.MapControl; import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.plugin.parameter.MapParameter; import org.jetbrains.annotations.NotNull; @@ -57,7 +59,15 @@ if (value.getSelectedIndex() == 0) { parameter.setValueToCurrent(); } else { - parameter.setValue(value.getSelectedItem()); + final MapControl<?, ?, ?> mapControl = (MapControl<?, ?, ?>) value.getSelectedItem(); + final String stringValue; + if (mapControl == null) { + stringValue = ""; + } else { + final File mapFile = mapControl.getMapModel().getMapFile(); + stringValue = mapFile == null ? "" : mapFile.getPath(); + } + parameter.setStringValue(stringValue); } } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/MapPathParameterView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -29,11 +29,12 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.plugin.parameter.MapPathParameter; +import net.sf.gridarta.plugin.parameter.AbstractPathParameter; import org.jetbrains.annotations.NotNull; /** - * A {@link PluginParameterView} that displays a {@link MapPathParameter}. + * A {@link PluginParameterView} that displays a {@link + * net.sf.gridarta.plugin.parameter.MapPathParameter}. * @author Andreas Kirschbaum */ public class MapPathParameterView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements PluginParameterView<G, A, R> { @@ -52,9 +53,9 @@ * @param parent the parent component for the file chooser * @param parameter the parameter to affect */ - public MapPathParameterView(@NotNull final JComponent parent, @NotNull final MapPathParameter<G, A, R> parameter) { - final String value = parameter.getValue(); - valueComponent = new JFileField(parent, null, parameter.getBaseDir(), new File(value == null ? "" : value), JFileChooser.FILES_AND_DIRECTORIES); + public MapPathParameterView(@NotNull final JComponent parent, @NotNull final AbstractPathParameter<G, A, R> parameter) { + final File value = parameter.getValue(); + valueComponent = new JFileField(parent, null, parameter.getBaseDir(), value == null ? new File("") : value, JFileChooser.FILES_AND_DIRECTORIES); valueComponent.addDocumentListener(new DocumentListener() { @Override Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterDescriptionEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterDescriptionEditor.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterDescriptionEditor.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -31,9 +31,9 @@ private static final long serialVersionUID = 1L; - private final PluginParameter<G, A, R> parameter; + private final PluginParameter<G, A, R, ?> parameter; - public ParameterDescriptionEditor(final PluginParameter<G, A, R> param) { + public ParameterDescriptionEditor(final PluginParameter<G, A, R, ?> param) { parameter = param; setText(param.getDescription()); getDocument().addDocumentListener(new DocumentListener() { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterNameEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterNameEditor.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterNameEditor.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -31,7 +31,7 @@ private static final long serialVersionUID = 1L; - private final PluginParameter<G, A, R> parameter; + private final PluginParameter<G, A, R, ?> parameter; private final DocumentListener documentListener = new DocumentListener() { @@ -52,7 +52,7 @@ }; - public ParameterNameEditor(final PluginParameter<G, A, R> parameter) { + public ParameterNameEditor(final PluginParameter<G, A, R, ?> parameter) { this.parameter = parameter; setText(parameter.getName()); getDocument().addDocumentListener(documentListener); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterTypeEditor.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterTypeEditor.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/ParameterTypeEditor.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -44,7 +44,7 @@ private static final Category log = Logger.getLogger(ParameterTypeEditor.class); @NotNull - private final PluginParameter<G, A, R> parameter; + private final PluginParameter<G, A, R, ?> parameter; @NotNull private final Plugin<G, A, R> plugin; @@ -67,7 +67,7 @@ }; - public ParameterTypeEditor(@NotNull final PluginModel<G, A, R> pluginModel, @NotNull final Plugin<G, A, R> plugin, @NotNull final PluginParameter<G, A, R> parameter) { + public ParameterTypeEditor(@NotNull final PluginModel<G, A, R> pluginModel, @NotNull final Plugin<G, A, R> plugin, @NotNull final PluginParameter<G, A, R, ?> parameter) { super(pluginModel.getTypes()); this.parameter = parameter; this.plugin = plugin; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/PluginParameterViewFactory.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -142,7 +142,7 @@ * @param parent the parent component for showing dialogs */ @NotNull - public PluginParameterView<G, A, R> getView(@NotNull final JComponent parent, @NotNull final PluginParameter<G, A, R> parameter) { + public PluginParameterView<G, A, R> getView(@NotNull final JComponent parent, @NotNull final PluginParameter<G, A, R, ?> parameter) { this.parent = parent; try { return parameter.visit(visitor); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/StringParameterView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/StringParameterView.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/plugin/parameter/StringParameterView.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -29,7 +29,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.plugin.parameter.AbstractPluginParameter; +import net.sf.gridarta.plugin.parameter.StringParameter; import org.jetbrains.annotations.NotNull; public class StringParameterView<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements PluginParameterView<G, A, R> { @@ -41,9 +41,9 @@ private final JComponent config = new JPanel(); @NotNull - private final AbstractPluginParameter<G, A, R, String> linkedParameter; + private final StringParameter<G, A, R> linkedParameter; - public StringParameterView(@NotNull final AbstractPluginParameter<G, A, R, String> parameter) { + public StringParameterView(@NotNull final StringParameter<G, A, R> parameter) { linkedParameter = parameter; final Document d = value.getDocument(); d.addDocumentListener(new DocumentListener() { Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/Plugin.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/Plugin.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/Plugin.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -51,7 +51,7 @@ * @author tchize * @author Andreas Kirschbaum */ -public class Plugin<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements Iterable<PluginParameter<G, A, R>> { +public class Plugin<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements Iterable<PluginParameter<G, A, R, ?>> { /** * The Logger for printing log messages. @@ -69,7 +69,7 @@ * The {@link PluginParameter PluginParameters} for this plugin. */ @NotNull - private final List<PluginParameter<G, A, R>> parameters = new ArrayList<PluginParameter<G, A, R>>(); + private final List<PluginParameter<G, A, R, ?>> parameters = new ArrayList<PluginParameter<G, A, R, ?>>(); /** * The plugin name. @@ -182,7 +182,7 @@ */ public int getParameter(@NotNull final String paramName) { int index = 0; - for (final PluginParameter<G, A, R> parameter : parameters) { + for (final PluginParameter<G, A, R, ?> parameter : parameters) { if (parameter.getName().equals(paramName)) { return index; } @@ -204,7 +204,7 @@ * Creates a new plugin parameter. */ public void newParameter() { - final PluginParameter<G, A, R> pluginParameter; + final PluginParameter<G, A, R, ?> pluginParameter; try { pluginParameter = pluginParameterFactory.createParameter(StringParameter.PARAMETER_TYPE); } catch (final NoSuchParameterException ex) { @@ -267,9 +267,9 @@ model.filter = filter; model.script = script; model.modified = modified; - for (final PluginParameter<G, A, R> parameter : parameters) { + for (final PluginParameter<G, A, R, ?> parameter : parameters) { final Element paramXml = codec.toXML(parameter); - final PluginParameter<G, A, R> clonedParam; + final PluginParameter<G, A, R, ?> clonedParam; try { clonedParam = pluginParameterFactory.createParameter(paramXml); } catch (final NoSuchParameterException ex) { @@ -284,7 +284,7 @@ * Adds a plugin parameter to this plugin. * @param pluginParameter the plugin parameter to add */ - public void addParameter(@NotNull final PluginParameter<G, A, R> pluginParameter) { + public void addParameter(@NotNull final PluginParameter<G, A, R, ?> pluginParameter) { parameters.add(pluginParameter); modified = true; notifyListeners(); @@ -297,7 +297,7 @@ * @return the plugin parameter * @throws NoSuchParameterException if the index is invalid */ - public PluginParameter<G, A, R> getParameter(final int index) throws NoSuchParameterException { + public PluginParameter<G, A, R, ?> getParameter(final int index) throws NoSuchParameterException { try { return parameters.get(index); } catch (final IndexOutOfBoundsException ignored) { @@ -387,7 +387,7 @@ * @param newType the new type * @throws NoSuchParameterException if the index is invalid */ - public void convertType(@NotNull final PluginParameter<G, A, R> pluginParameter, @NotNull final String newType) throws NoSuchParameterException { + public void convertType(@NotNull final PluginParameter<G, A, R, ?> pluginParameter, @NotNull final String newType) throws NoSuchParameterException { final int index = parameters.indexOf(pluginParameter); convertType(index, newType); } @@ -435,7 +435,7 @@ */ @NotNull @Override - public Iterator<PluginParameter<G, A, R>> iterator() { + public Iterator<PluginParameter<G, A, R, ?>> iterator() { return Collections.unmodifiableList(parameters).iterator(); } @@ -469,7 +469,7 @@ * @return the plugin parameter in XML representation */ @NotNull - public Content toXML(@NotNull final PluginParameter<G, A, R> pluginParameter) { + public Content toXML(@NotNull final PluginParameter<G, A, R, ?> pluginParameter) { return codec.toXML(pluginParameter); } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginExecutor.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginExecutor.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginExecutor.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -91,7 +91,7 @@ if (index == -1) { final StringBuilder sb = new StringBuilder(); boolean firstParameter = true; - for (final PluginParameter<?, ?, ?> parameter : clonedPlugin) { + for (final PluginParameter<?, ?, ?, ?> parameter : clonedPlugin) { sb.append(firstParameter ? " " : ", "); sb.append(parameter.getName()); firstParameter = false; @@ -100,7 +100,7 @@ return 1; } - final PluginParameter<G, A, R> parameter; + final PluginParameter<G, A, R, ?> parameter; try { parameter = clonedPlugin.getParameter(index); } catch (final NoSuchParameterException ex) { @@ -179,7 +179,7 @@ runner.setConsole(console); try { pluginParameters.setInterpreterValues(runner, PluginRunMode.BATCH); - for (final PluginParameter<G, A, R> parameter : plugin) { + for (final PluginParameter<G, A, R, ?> parameter : plugin) { runner.set(parameter.getName(), parameter.getValue()); } } catch (final TargetError ex) { Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginModelParser.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginModelParser.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/PluginModelParser.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -117,7 +117,7 @@ final Collection<Element> parameters = node.getChildren("parameter"); if (parameters != null && !parameters.isEmpty()) { for (final Element parameter : parameters) { - PluginParameter<G, A, R> pluginParameter; + PluginParameter<G, A, R, ?> pluginParameter; try { pluginParameter = pluginParameterFactory.createParameter(parameter); } catch (final NoSuchParameterException ex) { @@ -163,7 +163,7 @@ modes.addContent(filter); root.addContent(modes); - for (final PluginParameter<G, A, R> pluginParameter : plugin) { + for (final PluginParameter<G, A, R, ?> pluginParameter : plugin) { root.addContent(plugin.toXML(pluginParameter)); } return root; Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPathParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -25,13 +25,14 @@ import net.sf.gridarta.model.io.PathManager; import net.sf.gridarta.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Base class for {@link PluginParameter PluginParameters} that hold a {@link * File} value. * @author Andreas Kirschbaum */ -public abstract class AbstractPathParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, String> { +public abstract class AbstractPathParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractStringPluginParameter<G, A, R, File> { /** * The base directory. @@ -44,20 +45,11 @@ * @param baseDir the base directory */ protected AbstractPathParameter(@NotNull final File baseDir) { + super(""); this.baseDir = baseDir; - setValue(""); } /** - * {@inheritDoc} - */ - @Override - public boolean setStringValue(@NotNull final String stringValue) { - setValue(stringValue); - return true; - } - - /** * Returns the base directory. * @return the base directory */ @@ -71,7 +63,21 @@ * @param file the file */ public void setFile(@NotNull final File file) { - setValue(PathManager.getMapPath(file.getAbsolutePath(), baseDir)); + setStringValue(PathManager.getMapPath(file.getAbsolutePath(), baseDir)); } + /** + * {@inheritDoc} + */ + @Nullable + @Override + public File getValue() { + final String stringValue = getStringValue(); + if (stringValue.isEmpty()) { + return null; + } + final File file = new File(stringValue); + return file.exists() ? file : null; + } + } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractPluginParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -23,13 +23,12 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * Parameter for a Plugin. * @author tchize */ -public abstract class AbstractPluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> implements PluginParameter<G, A, R> { +public abstract class AbstractPluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> implements PluginParameter<G, A, R, V> { /** * The name of the parameter for the plugin script. @@ -44,12 +43,6 @@ private String description = "[description]"; /** - * The current value. - */ - @Nullable - private V value; - - /** * Creates a new instance. */ protected AbstractPluginParameter() { @@ -89,27 +82,4 @@ this.description = description; } - /** - * {@inheritDoc} - */ - @Nullable - @Override - public V getValue() { - return value; - } - - /** - * Updates the parameter value. - * @param value the new value - * @return whether the value has changed - */ - public boolean setValue(@Nullable final V value) { - if (this.value == null ? value == null : this.value.equals(value)) { - return false; - } - - this.value = value; - return true; - } - } Added: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractStringPluginParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractStringPluginParameter.java (rev 0) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractStringPluginParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -0,0 +1,67 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.plugin.parameter; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base class for {@link PluginParameter} implementations for which the + * value is calculated from the string representation. + * @author Andreas Kirschbaum + */ +public abstract class AbstractStringPluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> extends AbstractPluginParameter<G, A, R, V> { + + /** + * The current value. + */ + @NotNull + private String stringValue; + + /** + * Creates a new instance. + * @param stringValue the initial value + */ + protected AbstractStringPluginParameter(@NotNull final String stringValue) { + this.stringValue = stringValue; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getStringValue() { + return stringValue; + } + + /** + * Updates the parameter value. + * @param stringValue the new value + */ + @Override + public boolean setStringValue(@NotNull final String stringValue) { + this.stringValue = stringValue; + return true; + } + +} Property changes on: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractStringPluginParameter.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractValuePluginParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractValuePluginParameter.java (rev 0) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractValuePluginParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -0,0 +1,65 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2011 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.plugin.parameter; + +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * Abstract base class for {@link PluginParameter} implementations for which the + * string representation of the value is calculated from the value. + * @author Andreas Kirschbaum + */ +public abstract class AbstractValuePluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> extends AbstractPluginParameter<G, A, R, V> { + + /** + * The current value. + */ + @NotNull + private V value; + + /** + * Creates a new instance. + * @param value the initial value + */ + protected AbstractValuePluginParameter(@NotNull final V value) { + this.value = value; + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public V getValue() { + return value; + } + + /** + * Updates the parameter value. + * @param value the new value + */ + public void setValue(@NotNull final V value) { + this.value = value; + } + +} Property changes on: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/AbstractValuePluginParameter.java ___________________________________________________________________ Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/ArchetypeParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -30,7 +30,7 @@ /** * A {@link PluginParameter} that holds an {@link Archetype} value. */ -public class ArchetypeParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Archetype<G, A, R>> { +public class ArchetypeParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractStringPluginParameter<G, A, R, Archetype<G, A, R>> { /** * The string representation of this parameter type. @@ -44,13 +44,12 @@ @NotNull private final ArchetypeSet<G, A, R> archetypeSet; - private String valueString; - /** * Creates a new instance. * @param archetypeSet the archetype set for looking up archetypes */ public ArchetypeParameter(@NotNull final ArchetypeSet<G, A, R> archetypeSet) { + super(""); // XXX this.archetypeSet = archetypeSet; } @@ -69,25 +68,11 @@ @Nullable @Override public Archetype<G, A, R> getValue() { - if (super.getValue() == null) { - setValue(archetypeSet.getOrCreateArchetype(valueString)); - } - return super.getValue(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean setStringValue(@NotNull final String stringValue) { - final Archetype<G, A, R> archetype; try { - archetype = archetypeSet.getArchetype(stringValue); + return archetypeSet.getArchetype(getStringValue()); } catch (final UndefinedArchetypeException ignored) { - return false; + return null; } - setValue(archetype); - return true; } /** @@ -99,9 +84,4 @@ return PARAMETER_TYPE; } - @Nullable - public String getValueString() { - return valueString; - } - } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/BooleanParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -27,7 +27,7 @@ /** * A {@link PluginParameter} that holds a boolean value. */ -public class BooleanParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Boolean> { +public class BooleanParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValuePluginParameter<G, A, R, Boolean> { /** * The string representation of this parameter type. @@ -48,6 +48,13 @@ private String falseText = "No"; /** + * Creates a new instance. + */ + public BooleanParameter() { + super(false); + } + + /** * {@inheritDoc} */ @NotNull @@ -62,14 +69,14 @@ @Override public boolean setStringValue(@NotNull final String stringValue) { if (stringValue.equals("true")) { - setValue(Boolean.TRUE); - return true; + setValue(true); } else if (stringValue.equals("false")) { - setValue(Boolean.FALSE); - return true; + setValue(false); } else { return false; } + + return true; } /** @@ -82,6 +89,15 @@ } /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getStringValue() { + return getValue().toString(); + } + + /** * Returns the string representation of the "false" value. * @return the string representation */ Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/DoubleParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/DoubleParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/DoubleParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -27,7 +27,7 @@ /** * A {@link PluginParameter} that holds a double value. */ -public class DoubleParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Double> { +public class DoubleParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValuePluginParameter<G, A, R, Double> { /** * The string representation of this parameter type. @@ -48,6 +48,13 @@ private double max = 1.0; /** + * Creates a new instance. + */ + public DoubleParameter() { + super(0.0); + } + + /** * {@inheritDoc} */ @NotNull @@ -67,13 +74,29 @@ } catch (final NumberFormatException ignored) { return false; } + if (doubleValue < min) { + return false; + } + if (doubleValue > max) { + return false; + } setValue(doubleValue); + //noinspection FloatingPointEquality + assert getValue() == doubleValue; return true; } /** * {@inheritDoc} */ + @Override + public void setValue(@NotNull final Double value) { + super.setValue(Math.max(Math.min(value, max), min)); + } + + /** + * {@inheritDoc} + */ @NotNull @Override public String getParameterType() { @@ -81,6 +104,15 @@ } /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getStringValue() { + return getValue().toString(); + } + + /** * Returns the maximal allowed value. * @return the maximal allowed value */ Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/FilterParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/FilterParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/FilterParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -25,8 +25,9 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; -public class FilterParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, NamedFilterConfig> { +public class FilterParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractStringPluginParameter<G, A, R, NamedFilterConfig> { @NotNull public static final String PARAMETER_TYPE = NamedFilterConfig.class.getName(); @@ -34,27 +35,21 @@ @NotNull private final NamedFilter defaultFilterList; + /** + * Creates a new instance. + */ public FilterParameter(@NotNull final NamedFilter defaultFilterList) { + super(""); this.defaultFilterList = defaultFilterList; } - @NotNull - @Override - public NamedFilterConfig getValue() { - NamedFilterConfig o = super.getValue(); - if (o == null) { - o = defaultFilterList.createConfig(); - setValue(o); - } - return o; - } - /** * {@inheritDoc} */ + @Nullable @Override - public boolean setStringValue(@NotNull final String stringValue) { - return false; // XXX: not implemented + public NamedFilterConfig getValue() { + return null; // XXX: not implemented } /** Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/IntegerParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -25,9 +25,10 @@ import org.jetbrains.annotations.NotNull; /** - * A {@link PluginParameter} that holds an integer value. + * A {@link PluginParameter} that holds an integer value and a range of valid + * values. */ -public class IntegerParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Integer> { +public class IntegerParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractValuePluginParameter<G, A, R, Integer> { /** * The string representation of this parameter type. @@ -46,6 +47,13 @@ private int max = Integer.MAX_VALUE; /** + * Creates a new instance. + */ + public IntegerParameter() { + super(0); + } + + /** * {@inheritDoc} */ @NotNull @@ -65,13 +73,28 @@ } catch (final NumberFormatException ignored) { return false; } - setValue(intValue); + if (intValue < min) { + return false; + } + if (intValue > max) { + return false; + } + super.setValue(intValue); + assert getValue() == intValue; return true; } /** * {@inheritDoc} */ + @Override + public void setValue(@NotNull final Integer value) { + super.setValue(Math.max(Math.min(value, max), min)); + } + + /** + * {@inheritDoc} + */ @NotNull @Override public String getParameterType() { @@ -79,6 +102,15 @@ } /** + * {@inheritDoc} + */ + @NotNull + @Override + public String getStringValue() { + return getValue().toString(); + } + + /** * Returns the maximal allowed value. * @return the maximal allowed value */ Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/MapParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/MapParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/MapParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -30,7 +30,7 @@ /** * A {@link PluginParameter} that holds a {@link MapControl} value. */ -public class MapParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractPluginParameter<G, A, R, Object> { // XXX: find correct parameter type: String or MapControl<GameObject, MapArchObject, Archetype> +public class MapParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends AbstractStringPluginParameter<G, A, R, MapControl<G, A, R>> { /** * The string representation of this parameter type. @@ -57,6 +57,7 @@ * instances */ public MapParameter(@NotNull final MapManager<G, A, R> mapManager) { + super(""); // XXX this.mapManager = mapManager; } @@ -83,47 +84,34 @@ */ @Nullable @Override - public Object getValue() { - final String s = (String) super.getValue(); - if (CURRENT_MAP.equals(s)) { + public MapControl<G, A, R> getValue() { + final String stringValue = getStringValue(); + if (CURRENT_MAP.equals(stringValue)) { return mapManager.getCurrentMap(); } for (final MapControl<G, A, R> mapControl : mapManager.getOpenedMaps()) { - if (mapControl.getMapModel().getMapArchObject().getMapName().equalsIgnoreCase(s)) { + if (mapControl.getMapModel().getMapArchObject().getMapName().equalsIgnoreCase(stringValue)) { return mapControl; } } - return mapManager.getCurrentMap(); + return null; } /** - * {@inheritDoc} + * Selects the current map. */ - @Override - public boolean setValue(@Nullable final Object value) { - if (value == null) { - return super.setValue(null); - } else { - final MapControl<?, ?, ?> map = (MapControl<?, ?, ?>) value; - return super.setValue(map.getMapModel().getMapArchObject().getMapName()); - } + public void setValueToCurrent() { + setStringValue(CURRENT_MAP); } /** - * {@inheritDoc} + * Returns whether the current map is selected. + * @return whether the current map is selected */ - @Override - public boolean setStringValue(@NotNull final String stringValue) { - return super.setValue(stringValue); + public boolean isCurrentMap() { + return getStringValue().equals(CURRENT_MAP); } - /** - * Selects the current map. - */ - public void setValueToCurrent() { - super.setValue(CURRENT_MAP); - } - } Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameter.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameter.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameter.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -30,7 +30,7 @@ * @author tchize * @author Andreas Kirschbaum */ -public interface PluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { +public interface PluginParameter<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, V> { /** * The name of the parameter. It identifies the parameter in the user @@ -69,15 +69,23 @@ /** * Returns the current value of the parameter. - * @return the value or {@code null} if unknown or invalid. + * @return the value or {@code null} if invalid. */ @Nullable - Object getValue(); + V getValue(); /** + * Returns the string representation of the current value of the parameter. + * @return the string representation of the value + */ + @NotNull + String getStringValue(); + + /** * Sets the parameter value from string representation. - * @param stringValue the value to set - * @return whether the value was updated + * @param stringValue the string representation of the value to set + * @return {@code true} if the value was accepted or {@code false} if the + * value was not changed because the new value is invalid */ boolean setStringValue(@NotNull String stringValue); Modified: trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java =================================================================== --- trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-24 09:14:49 UTC (rev 9509) +++ trunk/src/plugin/src/main/java/net/sf/gridarta/plugin/parameter/PluginParameterCodec.java 2013-11-24 09:32:18 UTC (rev 9510) @@ -24,7 +24,6 @@ import net.sf.gridarta.model.filter.NamedFilterConfig; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; -import net.sf.gridarta.utils.NumberUtils; import org.jdom.Element; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -48,7 +47,7 @@ * @return the plugin parameter in XML encoding */ @NotNull - private Element toXML(@NotNull final PluginParameter<G, A, R> parameter) { + private Element toXML(@NotNull final PluginParameter<G, A, R, ?> parameter) { final Element e = new Element("parameter"); final Element n = new Element("name"); final Element d = new Element("description"); @@ -67,12 +66,7 @@ public Element visit(@NotNull final ArchetypeParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); - final Archetype<G, A, R> archetype = parameter.getValue(); - if (archetype != null) { - v.addContent(archetype.getArchetypeName()); - } else { - v.addContent(parameter.getValueString()); - } + v.addContent(parameter.getStringValue()); e.addContent(v); return e; } @@ -82,8 +76,7 @@ public Element visit(@NotNull final BooleanParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); - final Boolean value = parameter.getValue(); - v.addContent(value != null ? value.toString() : ""); + v.addContent(parameter.getStringValue()); e.addContent(v); final Element yes = new Element("trueText"); yes.addContent(parameter.getTrueText()); @@ -99,8 +92,7 @@ public Element visit(@NotNull final DoubleParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); - final Double value = parameter.getValue(); - v.addContent(value != null ? value.toString() : ""); + v.addContent(parameter.getStringValue()); e.addContent(v); final Element min = new Element("minimum"); final Element max = new Element("maximum"); @@ -124,8 +116,7 @@ public Element visit(@NotNull final IntegerParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); - final Integer value = parameter.getValue(); - v.addContent(value != null ? value.toString() : ""); + v.addContent(parameter.getStringValue()); e.addContent(v); final Element min = new Element("minimum"); final Element max = new Element("maximum"); @@ -141,7 +132,7 @@ public Element visit(@NotNull final MapParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element v = new Element("value"); - v.addContent((String) parameter.getValue()); + v.addContent(parameter.isCurrentMap() ? "" : parameter.getStringValue()); e.addContent(v); return e; } @@ -151,8 +142,7 @@ public Element visit(@NotNull final MapPathParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element s = new Element("value"); - final String value = parameter.getValue(); - s.addContent(value != null ? value : ""); + s.addContent(parameter.getStringValue()); e.addContent(s); return e; } @@ -162,8 +152,7 @@ public Element visit(@NotNull final StringParameter<G, A, R> parameter) { final Element e = toXML(parameter); final Element s = new Element("value"); - final String value = parameter.getValue(); - s.addContent(value != null ? value : ""); + s.addContent(parameter.getStringValue()); e.addContent(s); return e; } @@ -175,121 +164,97 @@ * from XML representation. */ @NotNull - private final PluginParameterVisitor<G, A, R, PluginParameter<G, A, R>> fromXML = new PluginParameterVisitor<G, A, R, PluginParameter<G, A, R>>() { + private final PluginParameterVisitor<G, A, R, PluginParameter<G, A, R, ?>> fromXML = new PluginParameterVisitor<G, A, R, PluginParameter<G, A, R, ?>>() { /** * Restores generic plugin parameter values. * @param parameter the plugin parameter being restored */ - public void... [truncated message content] |
From: <aki...@us...> - 2013-12-03 00:32:20
|
Revision: 9517 http://sourceforge.net/p/gridarta/code/9517 Author: akirschbaum Date: 2013-12-03 00:32:13 +0000 (Tue, 03 Dec 2013) Log Message: ----------- Properly enable or disable "Move Cursor" actions if the map size changes. Modified Paths: -------------- trunk/src/atrinik/ChangeLog trunk/src/crossfire/ChangeLog trunk/src/daimonin/ChangeLog trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java Modified: trunk/src/atrinik/ChangeLog =================================================================== --- trunk/src/atrinik/ChangeLog 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/atrinik/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) @@ -1,3 +1,8 @@ +2013-12-03 Andreas Kirschbaum + + * Properly enable or disable "Move Cursor" actions if the map size + changes. + 2013-11-24 Andreas Kirschbaum * Fix plugin script parameter editor. Modified: trunk/src/crossfire/ChangeLog =================================================================== --- trunk/src/crossfire/ChangeLog 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/crossfire/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) @@ -1,3 +1,8 @@ +2013-12-03 Andreas Kirschbaum + + * Properly enable or disable "Move Cursor" actions if the map size + changes. + 2013-11-24 Andreas Kirschbaum * Fix plugin script parameter editor. Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/daimonin/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) @@ -1,3 +1,8 @@ +2013-12-03 Andreas Kirschbaum + + * Properly enable or disable "Move Cursor" actions if the map size + changes. + 2013-11-24 Andreas Kirschbaum * Fix plugin script parameter editor. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -90,6 +90,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -108,6 +108,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -147,6 +147,11 @@ //ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -340,6 +340,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -81,6 +81,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -113,6 +113,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + refreshActions(); + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -147,6 +147,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -147,6 +147,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -271,6 +271,11 @@ } } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -332,6 +332,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + }; /** Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -155,6 +155,13 @@ private G transactionGameObject; /** + * The value of {@link #mapRec} at the start of the outermost map cursor + * transaction. + */ + @NotNull + private final Rectangle transactionMapRec = new Rectangle(); + + /** * The MapCursorListeners to inform of changes. */ @NotNull @@ -181,22 +188,24 @@ @Override public void mapGridResized(@NotNull final MapGridEvent e) { final Size2D newSize = mapGrid.getGridSize(); - mapRec.setSize(newSize.getWidth(), newSize.getHeight()); - // Test if drag start point is outside map -> move inside - if (dragging && !mapRec.contains(dragStart)) { - dragStart.x = Math.min(dragStart.x, mapRec.width - 1); - dragStart.y = Math.min(dragStart.y, mapRec.height - 1); - } - // Test if cursor position is outside map -> move inside - if (onMap && !mapRec.contains(pos)) { - beginTransaction(); - try { + final int newWidth = newSize.getWidth(); + final int newHeight = newSize.getHeight(); + beginTransaction(); + try { + mapRec.setSize(newWidth, newHeight); + // Test if drag start point is outside map -> move inside + if (dragging && !mapRec.contains(dragStart)) { + dragStart.x = Math.min(dragStart.x, mapRec.width - 1); + dragStart.y = Math.min(dragStart.y, mapRec.height - 1); + } + // Test if cursor position is outside map -> move inside + if (onMap && !mapRec.contains(pos)) { pos.x = Math.min(pos.x, mapRec.width - 1); pos.y = Math.min(pos.y, mapRec.height - 1); selectMapSquare(); - } finally { - endTransaction(); } + } finally { + endTransaction(); } } @@ -508,6 +517,7 @@ transactionDragging = dragging; transactionMapSquare = mapSquare; transactionGameObject = gameObject; + transactionMapRec.setRect(mapRec); } transactionDepth++; mapGrid.beginTransaction(); @@ -531,6 +541,7 @@ final boolean changedPos = !pos.equals(transactionPos) || mapSquare != transactionMapSquare; final boolean changedMode = onMap != transactionOnMap || dragging != transactionDragging; final boolean changedGameObject = gameObject != transactionGameObject; + final boolean changedSize = !mapRec.equals(transactionMapRec); if (!onMap) { mapGrid.unSelect(); } @@ -555,6 +566,11 @@ listener.mapCursorChangedGameObject(mapSquare, gameObject); } } + if (changedSize) { + for (final MapCursorListener<G, A, R> listener : listenerList.getListeners()) { + listener.mapCursorChangedSize(); + } + } } mapGrid.endTransaction(); Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -59,4 +59,9 @@ */ void mapCursorChangedGameObject(@Nullable MapSquare<G, A, R> mapSquare, @Nullable G gameObject); + /** + * Called whenever the map cursor's map grid size has changed. + */ + void mapCursorChangedSize(); + } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-12-03 00:13:05 UTC (rev 9516) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-12-03 00:32:13 UTC (rev 9517) @@ -505,6 +505,11 @@ // ignore } + @Override + public void mapCursorChangedSize() { + // ignore + } + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2013-12-03 11:03:34
|
Revision: 9518 http://sourceforge.net/p/gridarta/code/9518 Author: akirschbaum Date: 2013-12-03 11:03:27 +0000 (Tue, 03 Dec 2013) Log Message: ----------- Always show the map cursor. Modified Paths: -------------- trunk/src/atrinik/ChangeLog trunk/src/crossfire/ChangeLog trunk/src/daimonin/ChangeLog trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/EnterMap.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/AbstractMapView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/DeletionTool.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/SelectionTool.java trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages.properties trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_de.properties trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_fr.properties trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_sv.properties trunk/src/model/src/main/java/net/sf/gridarta/model/exitconnector/ExitMatcher.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/TopLevelGameObjectIterator.java trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java Modified: trunk/src/atrinik/ChangeLog =================================================================== --- trunk/src/atrinik/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/atrinik/ChangeLog 2013-12-03 11:03:27 UTC (rev 9518) @@ -1,5 +1,8 @@ 2013-12-03 Andreas Kirschbaum + * Always show the map cursor. For newly opened maps place the map + cursor at the map's default enter position. + * Properly enable or disable "Move Cursor" actions if the map size changes. Modified: trunk/src/crossfire/ChangeLog =================================================================== --- trunk/src/crossfire/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/crossfire/ChangeLog 2013-12-03 11:03:27 UTC (rev 9518) @@ -1,5 +1,8 @@ 2013-12-03 Andreas Kirschbaum + * Always show the map cursor. For newly opened maps place the map + cursor at the map's default enter position. + * Properly enable or disable "Move Cursor" actions if the map size changes. Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/daimonin/ChangeLog 2013-12-03 11:03:27 UTC (rev 9518) @@ -1,5 +1,8 @@ 2013-12-03 Andreas Kirschbaum + * Always show the map cursor. For newly opened maps place the map + cursor at the map's default enter position. + * Properly enable or disable "Move Cursor" actions if the map size changes. Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/AbstractMapCursorAction.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -76,7 +76,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { updateAction(); } @@ -114,7 +114,7 @@ @Nullable protected MapCursor<G, A, R> getActiveMapCursor() { final MapView<G, A, R> mapView = currentMapView; - return mapView == null ? null : getActiveMapCursor(mapView); + return mapView == null ? null : mapView.getMapCursor(); } /** @@ -127,18 +127,6 @@ } /** - * Return the map cursor of a map view if it is active. - * @param mapView the map view - * @return the map cursor, or <code>null</code> if the cursor is not active, - * or if no map view exists - */ - @Nullable - private MapCursor<G, A, R> getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { - final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); - return mapCursor.isActive() ? mapCursor : null; - } - - /** * Called whenever the current map cursor has changed. */ protected abstract void updateAction(); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/action/ArchAttributesAction.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -94,7 +94,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { updateActions(); } @@ -164,11 +164,7 @@ return false; } - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(currentMapView); - if (mapCursor == null) { - return false; - } - + final MapCursor<G, A, R> mapCursor = currentMapView.getMapCursor(); final G gameObject = mapCursor.getGameObject(); if (gameObject == null) { return false; @@ -181,16 +177,4 @@ return true; } - /** - * Return the map cursor of a map view if it is active. - * @param mapView the map view - * @return the map cursor, or <code>null</code> if the cursor is not active, - * or if no map view exists - */ - @Nullable - private MapCursor<G, A, R> getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { - final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); - return mapCursor.isActive() ? mapCursor : null; - } - } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/actions/AbstractServerActions.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -165,16 +165,8 @@ } final Point cursor = mapView.getMapCursor().getLocation(); - final int mapX; - final int mapY; - if (cursor == null) { - final A mapArchObject = mapModel.getMapArchObject(); - mapX = mapArchObject.getEnterX(); - mapY = mapArchObject.getEnterY(); - } else { - mapX = cursor.x; - mapY = cursor.y; - } + final int mapX = cursor.x; + final int mapY = cursor.y; try { teleportCharacterToMap(mapPath, mapX, mapY); } catch (final IOException ex) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -166,12 +166,12 @@ final Point point = mapView.getMapCursor().getLocation(); coordinatesPanel.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "goLocationX"), gbcLabel); - xCoordinateField.setText(point == null ? "0" : Integer.toString(point.x)); + xCoordinateField.setText(Integer.toString(point.x)); xCoordinateField.setColumns(3); coordinatesPanel.add(xCoordinateField, gbcField); coordinatesPanel.add(ActionBuilderUtils.newLabel(ACTION_BUILDER, "goLocationY"), gbcLabel); - yCoordinateField.setText(point == null ? "0" : Integer.toString(point.y)); + yCoordinateField.setText(Integer.toString(point.y)); yCoordinateField.setColumns(3); coordinatesPanel.add(yCoordinateField, gbcField); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -133,7 +133,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { // ignore } @@ -238,8 +238,7 @@ } final Point location = mapView.getMapCursor().getLocation(); - // no active cursor ==> no location to remember - return location != null && exitConnectorActions.doExitCopy(performAction, mapView.getMapControl(), location); + return exitConnectorActions.doExitCopy(performAction, mapView.getMapControl(), location); } /** @@ -254,7 +253,7 @@ } final Point targetLocation = mapView.getMapCursor().getLocation(); - return targetLocation != null && exitConnectorActions.doExitPaste(performAction, mapView.getMapControl(), targetLocation); + return exitConnectorActions.doExitPaste(performAction, mapView.getMapControl(), targetLocation); } /** @@ -269,7 +268,7 @@ } final Point targetLocation = mapView.getMapCursor().getLocation(); - return targetLocation != null && exitConnectorActions.doExitConnect(performAction, mapView.getMapControl(), targetLocation); + return exitConnectorActions.doExitConnect(performAction, mapView.getMapControl(), targetLocation); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/EnterMap.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -288,10 +288,6 @@ return null; } final Point oldCursorLocation = oldMapView.getMapCursor().getLocation(); - if (oldCursorLocation == null) { - return null; - } - final Size2D mapSize = newMapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); switch (direction) { case SOUTH: Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -326,7 +326,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { updateActions(); } @@ -567,8 +567,6 @@ final MapSquare<G, A, R> mapSquare = exit.getMapSquare(); assert mapSquare != null; mapView.setCursorLocation(mapSquare.getMapLocation()); - } else { - mapView.setCursorLocation(null); } } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/AbstractMapView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -144,20 +144,18 @@ * {@inheritDoc} */ @Override - public void setCursorLocation(@Nullable final Point point) { - if (point != null) { - final Size2D mapSize = getMapControl().getMapModel().getMapArchObject().getMapSize(); - if (point.x >= mapSize.getWidth()) { - point.x = mapSize.getWidth() - 1; - } else if (point.x < 0) { - point.x = 0; - } - if (point.y >= mapSize.getHeight()) { - point.y = mapSize.getHeight() - 1; - } else if (point.y < 0) { - point.y = 0; - } + public void setCursorLocation(@NotNull final Point point) { + final Size2D mapSize = getMapControl().getMapModel().getMapArchObject().getMapSize(); + if (point.x >= mapSize.getWidth()) { + point.x = mapSize.getWidth() - 1; + } else if (point.x < 0) { + point.x = 0; } + if (point.y >= mapSize.getHeight()) { + point.y = mapSize.getHeight() - 1; + } else if (point.y < 0) { + point.y = 0; + } mapCursor.setLocation(point); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -67,7 +67,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { ensureVisibleMapCursor(); } @@ -133,9 +133,7 @@ */ private void ensureVisibleMapCursor() { final Point cursorLocation = mapCursor.getLocation(); - if (cursorLocation != null) { - renderer.scrollRectToVisible(renderer.getSquareBounds(cursorLocation)); - } + renderer.scrollRectToVisible(renderer.getSquareBounds(cursorLocation)); } /** Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapView.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapview/MapView.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -137,9 +137,9 @@ /** * Sets the cursor location. If the map location is not within map bounds * the cursor is set to the nearest valid location. - * @param point the new location or <code>null</code> to remove the cursor; + * @param point the new location * will be modified to the actually set cursor location */ - void setCursorLocation(@Nullable Point point); + void setCursorLocation(@NotNull Point point); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -20,6 +20,8 @@ package net.sf.gridarta.gui.mapcursor; import java.awt.Point; +import java.io.File; +import java.util.Set; import javax.swing.Action; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; @@ -31,8 +33,11 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapcursor.MapCursorListener; +import net.sf.gridarta.model.mapmodel.MapModelListener; import net.sf.gridarta.model.mapmodel.MapSquare; +import net.sf.gridarta.model.validation.ErrorCollector; import net.sf.gridarta.utils.EditorAction; +import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionMethod; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -82,11 +87,13 @@ @Override public void mapViewCreated(@NotNull final MapView<G, A, R> mapView) { mapView.getMapCursor().addMapCursorListener(mapCursorListener); + mapView.getMapControl().getMapModel().addMapModelListener(mapModelListener); } @Override public void mapViewClosing(@NotNull final MapView<G, A, R> mapView) { mapView.getMapCursor().removeMapCursorListener(mapCursorListener); + mapView.getMapControl().getMapModel().removeMapModelListener(mapModelListener); } }; @@ -99,7 +106,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { refreshActions(); } @@ -121,6 +128,45 @@ }; /** + * The map model listener used to detect map size changes in {@link + * #currentMapView}. + */ + @NotNull + private final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { + + @Override + public void mapSizeChanged(@NotNull final Size2D newSize) { + refreshActions(); + } + + @Override + public void mapSquaresChanged(@NotNull final Set<MapSquare<G, A, R>> mapSquares) { + // ignore + } + + @Override + public void mapObjectsChanged(@NotNull final Set<G> gameObjects, @NotNull final Set<G> transientGameObjects) { + // ignore + } + + @Override + public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { + // ignore + } + + @Override + public void mapFileChanged(@Nullable final File oldMapFile) { + // ignore + } + + @Override + public void modifiedChanged() { + // ignore + } + + }; + + /** * Create a new instance. * @param mapViewManager the map view manager */ @@ -196,18 +242,6 @@ } /** - * Return the map cursor of a map view if it is active. - * @param mapView the map view - * @return the map cursor, or <code>null</code> if the cursor is not active, - * or if no map view exists - */ - @Nullable - private MapCursor<G, A, R> getActiveMapCursor(@NotNull final MapView<G, A, R> mapView) { - final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); - return mapCursor.isActive() ? mapCursor : null; - } - - /** * Enable/disable menu entries based on the current cursor state. */ private void refreshActions() { @@ -231,11 +265,7 @@ return false; } - final MapCursor<G, A, R> mapCursor = getActiveMapCursor(mapView); - if (mapCursor == null) { - return false; - } - + final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); if (!mapCursor.goTo(performAction, direction)) { return false; } @@ -243,10 +273,8 @@ if (performAction) { final MapRenderer renderer = mapView.getRenderer(); final Point location = mapCursor.getLocation(); - if (location != null) { - location.translate(BORDER * direction.getDx(), BORDER * direction.getDy()); - renderer.scrollRectToVisible(renderer.getSquareBounds(location)); - } + location.translate(BORDER * direction.getDx(), BORDER * direction.getDy()); + renderer.scrollRectToVisible(renderer.getSquareBounds(location)); } return true; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/misc/StatusBar.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -133,7 +133,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { mapCursorChanged(mapView == null ? null : mapView.getMapCursor()); } @@ -355,20 +355,16 @@ formatCursor = ""; } else { final Point pos = mapCursor.getLocation(); - if (pos == null) { - formatCursor = ACTION_BUILDER.format("statusCursorInactive"); + final int cursorX = pos.x; + final int cursorY = pos.y; + if (mapCursor.isDragging()) { + final Dimension offset = mapCursor.getDragOffset(); + assert offset != null; + final int offsetX = Math.abs(offset.width) + 1; + final int offsetY = Math.abs(offset.height) + 1; + formatCursor = ACTION_BUILDER.format("statusCursorDragging", cursorX, cursorY, offsetX, offsetY); } else { - final int cursorX = pos.x; - final int cursorY = pos.y; - if (mapCursor.isDragging()) { - final Dimension offset = mapCursor.getDragOffset(); - assert offset != null; - final int offsetX = Math.abs(offset.width) + 1; - final int offsetY = Math.abs(offset.height) + 1; - formatCursor = ACTION_BUILDER.format("statusCursorDragging", cursorX, cursorY, offsetX, offsetY); - } else { - formatCursor = ACTION_BUILDER.format("statusCursorActive", cursorX, cursorY); - } + formatCursor = ACTION_BUILDER.format("statusCursorActive", cursorX, cursorY); } } cursor.setText(formatCursor); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/objectchooser/DefaultObjectChooser.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -133,7 +133,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { updatePickmapInfo(activePickmapView == null ? null : activePickmapView.getMapCursor()); } @@ -410,10 +410,8 @@ gameObject = null; } else { final Point location = mapCursor.getLocation(); - if (location == null) { + if (activeMapFile == null) { gameObject = null; - } else if (activeMapFile == null) { - gameObject = null; } else { final MapControl<G, A, R> pickmap = activeMapFile.getPickmap(); if (pickmap == null) { Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -255,7 +255,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { // ignore } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/DeletionTool.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/DeletionTool.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/DeletionTool.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -211,7 +211,7 @@ final MapCursor<G, A, R> mapCursor = e.getMapCursor(); final MapControl<G, A, R> mapControl = e.getMapControl(); mapCursor.setLocationSafe(mapLoc); - if (mapLoc != null && mapCursor.isActive()) { + if (mapLoc != null) { // delete the topmost arch (matching the view settings) on that square and redraw the map deleteArch(mapLoc, mapControl); } Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/SelectionTool.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/panel/tools/SelectionTool.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -129,6 +129,9 @@ @Override public void pressed(final MouseOpEvent<G, A, R> e) { final Point mapLoc = e.getMapLocation(); + if (mapLoc == null) { + return; + } final int mod = e.getModifiers(); final MapCursor<G, A, R> mapCursor = e.getMapCursor(); mapCursor.beginTransaction(); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/mainactions/MainActions.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -318,7 +318,7 @@ private final MapCursorListener<G, A, R> mapCursorListener = new MapCursorListener<G, A, R>() { @Override - public void mapCursorChangedPos(@Nullable final Point location) { + public void mapCursorChangedPos(@NotNull final Point location) { // ignore } @@ -975,10 +975,6 @@ } final Point startLocation = mapView.getMapCursor().getLocation(); - if (startLocation == null) { - return false; - } - if (copyBuffer.isEmpty()) { return false; } @@ -1002,10 +998,6 @@ } final Point startLocation = mapView.getMapCursor().getLocation(); - if (startLocation == null) { - return false; - } - if (copyBuffer.isEmpty()) { return false; } @@ -1023,8 +1015,7 @@ if (performAction) { final Point cursorLocation = mapView.getMapCursor().getLocation(); - final Point origin = cursorLocation == null ? selectedRec.getLocation() : cursorLocation; - copyBuffer.pasteTiled(mapView, selectedSquares, origin); + copyBuffer.pasteTiled(mapView, selectedSquares, cursorLocation); } return true; @@ -1179,10 +1170,6 @@ } final Point mapCursorLocation = mapView.getMapCursor().getLocation(); - if (mapCursorLocation == null) { - return false; - } - if (performAction) { FillUtils.floodFill(mapView.getMapControl().getMapModel(), mapCursorLocation, objectChooser.getSelections(), insertionModeSet); } Modified: trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages.properties =================================================================== --- trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages.properties 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages.properties 2013-12-03 11:03:27 UTC (rev 9518) @@ -658,7 +658,6 @@ statusMouseOn=Mouse {0,number,integer}/{1,number,integer} statusCursorDragging=Cursor {0,number,integer}/{1,number,integer} [{2,number,integer}/{3,number,integer}] statusCursorActive=Cursor {0,number,integer}/{1,number,integer} -statusCursorInactive=Cursor off map ####################### # Various Log Messages Modified: trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_de.properties =================================================================== --- trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_de.properties 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_de.properties 2013-12-03 11:03:27 UTC (rev 9518) @@ -636,7 +636,6 @@ statusMouseOn=Maus {0,number,integer}/{1,number,integer} statusCursorDragging=Cursor {0,number,integer}/{1,number,integer} [{2,number,integer}/{3,number,integer}] statusCursorActive=Cursor {0,number,integer}/{1,number,integer} -statusCursorInactive=Cursor nicht auf Karte # Edit undo.text=R\u00fcckg\u00e4ngig Modified: trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_fr.properties =================================================================== --- trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_fr.properties 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_fr.properties 2013-12-03 11:03:27 UTC (rev 9518) @@ -630,7 +630,6 @@ #statusMouseOn= statusCursorDragging=Souris {0,number,integer}/{1,number,integer} [{2,number,integer}/{3,number,integer}] statusCursorActive=Souris {0,number,integer}/{1,number,integer} -#statusCursorInactive= # Edit undo.text=Annuler Modified: trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_sv.properties =================================================================== --- trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_sv.properties 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/gridarta/src/main/resources/net/sf/gridarta/messages_sv.properties 2013-12-03 11:03:27 UTC (rev 9518) @@ -630,7 +630,6 @@ statusMouseOn=Mus {0,number,integer}/{1,number,integer} statusCursorDragging=Mark\u00f6r {0,number,integer}/{1,number,integer} [{2,number,integer}x{3,number,integer}] statusCursorActive=Mark\u00f6r {0,number,integer}/{1,number,integer} -statusCursorInactive=Mark\u00f6r utanf\u00f6r karta # Edit undo.text=\u00c5ngra Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/exitconnector/ExitMatcher.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -59,12 +59,11 @@ * information. * @param mapModel the map model to check * @param point the map square to check - * @return the head of the exit game object or <code>null</code> if none was - * found + * @return the head of the exit game object */ @Nullable - public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.getMapArchObject().isPointValid(point)) { + public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point) { + if (!mapModel.getMapArchObject().isPointValid(point)) { return null; } for (final GameObject<G, A, R> part : mapModel.getMapSquare(point)) { Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursor.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -54,7 +54,7 @@ * MapGrid. */ @NotNull - private final Point pos = new Point(); + private final Point pos; /** * Position where dragging has started. @@ -69,11 +69,6 @@ private final Dimension dragOffset = new Dimension(); /** - * Whether the cursor is currently on map. - */ - private boolean onMap; - - /** * Gets set to <code>true</code> when in drag mode. */ private boolean dragging; @@ -129,12 +124,6 @@ private final Point transactionPos = new Point(); /** - * The value of {@link #onMap} at the start of the outermost map cursor - * transaction. - */ - private boolean transactionOnMap; - - /** * The value of {@link #dragging} at the start of the outermost map cursor * transaction. */ @@ -178,6 +167,8 @@ this.mapModel = mapModel; final Size2D gridSize = mapGrid.getGridSize(); mapRec = new Rectangle(0, 0, gridSize.getWidth(), gridSize.getHeight()); + final A mapArchObject = mapModel.getMapArchObject(); + pos = fixPoint(new Point(mapArchObject.getEnterX(), mapArchObject.getEnterY())); final MapGridListener mapGridListener = new MapGridListener() { @Override @@ -199,7 +190,7 @@ dragStart.y = Math.min(dragStart.y, mapRec.height - 1); } // Test if cursor position is outside map -> move inside - if (onMap && !mapRec.contains(pos)) { + if (!mapRec.contains(pos)) { pos.x = Math.min(pos.x, mapRec.width - 1); pos.y = Math.min(pos.y, mapRec.height - 1); selectMapSquare(); @@ -211,39 +202,36 @@ }; mapGrid.addMapGridListener(mapGridListener); + mapGrid.setCursor(pos); + beginTransaction(); + try { + selectMapSquare(); + } finally { + endTransaction(); + } } /** * Get position of cursor. - * @return coordinates of cursor or <code>null</code> if cursor is not - * active + * @return coordinates of cursor */ - @Nullable + @NotNull public Point getLocation() { - return onMap ? new Point(pos) : null; + return new Point(pos); } /** - * Move cursor to a new location. If new location is not on map, cursor gets - * disabled. - * @param p New location. If <code>p == null</code> cursor gets disabled + * Move cursor to a new location. If new location is not on map, the nearest + * valid location is chosen. + * @param p the new location */ - public void setLocation(@Nullable final Point p) { + public void setLocation(@NotNull final Point p) { beginTransaction(); try { - if (p != null && mapRec.contains(p)) { - if (onMap) { - if (!pos.equals(p)) { - pos.setLocation(p); - selectMapSquare(); - } - } else { - pos.setLocation(p); - selectMapSquare(); - onMap = true; - } - } else { - onMap = false; + final Point effectivePoint = fixPoint(p); + if (!pos.equals(effectivePoint)) { + pos.setLocation(effectivePoint); + selectMapSquare(); } } finally { endTransaction(); @@ -261,18 +249,11 @@ final boolean hasChanged; try { if (p != null && mapRec.contains(p)) { - if (onMap) { - if (pos.equals(p)) { - hasChanged = false; - } else { - pos.setLocation(p); - selectMapSquare(); - hasChanged = true; - } + if (pos.equals(p)) { + hasChanged = false; } else { pos.setLocation(p); selectMapSquare(); - onMap = true; hasChanged = true; } } else { @@ -288,7 +269,7 @@ * Set cursor to drag mode when it is active. */ public void dragStart() { - if (onMap && !dragging) { + if (!dragging) { beginTransaction(); try { dragStart.setLocation(pos); @@ -362,7 +343,7 @@ public final void deactivate() { beginTransaction(); try { - onMap = false; + dragging = false; mapGrid.unSelect(); } finally { endTransaction(); @@ -370,14 +351,6 @@ } /** - * Get cursor state. - * @return <code>true</code> if cursor is on the map - */ - public boolean isActive() { - return onMap; - } - - /** * Get offset from start position of dragging. * @return offset or <code>null</code> when not in drag mode * @noinspection NullableProblems @@ -403,21 +376,18 @@ * @return <code>true</code> if cursor really moved */ public boolean goTo(final boolean performAction, @NotNull final Direction dir) { - if (onMap) { - tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); - if (!mapRec.contains(tmpPoint)) { - return false; + tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); + if (!mapRec.contains(tmpPoint)) { + return false; + } + if (performAction) { + if (dragging) { + dragTo(tmpPoint); + } else { + setLocationSafe(tmpPoint); } - if (performAction) { - if (dragging) { - dragTo(tmpPoint); - } else { - setLocationSafe(tmpPoint); - } - } - return true; } - return false; + return true; } /** @@ -457,9 +427,8 @@ /** * Sets the selected {@link GameObject}. If the game object is not on a map - * or not on the map this cursor is attached to, the cursor is deactivated. - * @param gameObject the selected game object or <code>null</code> to - * deactivate the cursor + * or not on the map this cursor is attached to, the cursor is unchanged. + * @param gameObject the selected game object */ public void setGameObject(@Nullable final G gameObject) { beginTransaction(); @@ -468,10 +437,7 @@ this.gameObject = null; } else { final MapSquare<G, A, R> mapSquare = gameObject.getMapSquare(); - if (mapSquare == null || mapSquare.getMapModel() != mapModel) { - onMap = false; - } else { - onMap = true; + if (mapSquare != null && mapSquare.getMapModel() == mapModel) { pos.setLocation(mapSquare.getMapX(), mapSquare.getMapY()); this.mapSquare = mapSquare; this.gameObject = gameObject; @@ -484,17 +450,13 @@ /** * Sets the selected {@link MapSquare}. If the map square does not belong to - * the map this cursor is attached to, the cursor is deactivated. - * @param mapSquare the selected map square or <code>null</code> to - * deactivate the cursor + * the map this cursor is attached to, the cursor is unchanged. + * @param mapSquare the selected map square */ public void setMapSquare(@Nullable final MapSquare<G, A, R> mapSquare) { beginTransaction(); try { - if (mapSquare == null || mapSquare.getMapModel() != mapModel) { - onMap = false; - } else { - onMap = true; + if (mapSquare != null && mapSquare.getMapModel() == mapModel) { pos.setLocation(mapSquare.getMapX(), mapSquare.getMapY()); this.mapSquare = mapSquare; selectTopmostGameObject(); @@ -510,10 +472,9 @@ * come before the view is really required to update. Each invocation of * this function requires its own invocation of {@link #endTransaction()}. */ - public void beginTransaction() { + public final void beginTransaction() { if (transactionDepth == 0) { transactionPos.setLocation(pos); - transactionOnMap = onMap; transactionDragging = dragging; transactionMapSquare = mapSquare; transactionGameObject = gameObject; @@ -527,28 +488,17 @@ * End a transaction. Invoking this method will reduce the transaction depth * by 1. <p/> If the last transaction is ended, the changes are committed. */ - public void endTransaction() { + public final void endTransaction() { assert transactionDepth > 0; transactionDepth--; - if (!onMap) { - dragging = false; - mapSquare = null; - gameObject = null; - } - if (transactionDepth == 0) { final boolean changedPos = !pos.equals(transactionPos) || mapSquare != transactionMapSquare; - final boolean changedMode = onMap != transactionOnMap || dragging != transactionDragging; + final boolean changedMode = dragging != transactionDragging; final boolean changedGameObject = gameObject != transactionGameObject; final boolean changedSize = !mapRec.equals(transactionMapRec); - if (!onMap) { - mapGrid.unSelect(); - } - if (transactionOnMap && (!onMap || !pos.equals(transactionPos))) { + if (!pos.equals(transactionPos)) { mapGrid.unSetCursor(transactionPos); - } - if (onMap && (!transactionOnMap || !pos.equals(transactionPos))) { mapGrid.setCursor(pos); } if (changedMode) { @@ -664,10 +614,6 @@ * @return whether the action was or can be performed */ public boolean insertGameObject(final boolean performAction, @NotNull final BaseObject<G, A, R, ?> gameObject, final boolean insertAtEnd, final boolean join) { - if (!onMap) { - return false; - } - if (performAction) { mapModel.beginTransaction("Insert"); // TODO; I18N/L10N try { @@ -695,10 +641,6 @@ * @return whether the action was or can be performed */ public boolean deleteSelectedGameObject(final boolean performAction, final boolean autoJoin) { - if (!onMap) { - return false; - } - final G gameObject = this.gameObject; if (gameObject == null) { return false; @@ -740,4 +682,18 @@ return true; } + /** + * Returns a valid location that is on the map. + * @param p the preferred location + * @return the valid location + */ + @NotNull + private Point fixPoint(@NotNull final Point p) { + if (mapRec.contains(p)) { + return p; + } + + return new Point(Math.max(Math.min(p.x, mapRec.width - 1), 0), Math.max(Math.min(p.y, mapRec.height - 1), 0)); + } + } Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.mapmodel.MapSquare; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** @@ -35,12 +36,10 @@ public interface MapCursorListener<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends EventListener { /** - * This event handler is called when {@link MapCursor} has moved, appeared - * or disappeared. - * @param location the new location or <code>null</code> if the cursor - * disappeared + * This event handler is called when {@link MapCursor} has moved. + * @param location the new location */ - void mapCursorChangedPos(@Nullable Point location); + void mapCursorChangedPos(@NotNull Point location); /** * This event handler is called when {@link MapCursor} changes mode (drag, Modified: trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/TopLevelGameObjectIterator.java =================================================================== --- trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/TopLevelGameObjectIterator.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/model/src/main/java/net/sf/gridarta/model/mapmodel/TopLevelGameObjectIterator.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -58,13 +58,13 @@ /** * Creates a new instance. * @param mapModel the map model to iterate over - * @param start the starting point or <code>null</code> for default + * @param start the starting point * @param direction the direction to iterate: <code>+1</code> for forward, * <code>-1</code> for backward * @param skipFirst whether to skip the first map square and return it at * the end */ - public TopLevelGameObjectIterator(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point start, final int direction, final boolean skipFirst) { + public TopLevelGameObjectIterator(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point start, final int direction, final boolean skipFirst) { mapSquareIterator = new MapSquareIterator<G, A, R>(mapModel, start, direction, skipFirst); findNext(); } Modified: trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java =================================================================== --- trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-12-03 00:32:13 UTC (rev 9517) +++ trunk/src/model/src/test/java/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2013-12-03 11:03:27 UTC (rev 9518) @@ -28,6 +28,7 @@ import net.sf.gridarta.model.maparchobject.TestMapArchObject; import net.sf.gridarta.model.mapgrid.MapGrid; import net.sf.gridarta.model.mapgrid.SelectionMode; +import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.model.mapmodel.TestMapModelCreator; import net.sf.gridarta.utils.Size2D; @@ -45,6 +46,16 @@ public class MapCursorTest { /** + * The enter x coordinate of newly created maps. + */ + private static final int ENTER_X = 1; + + /** + * The enter y coordinate of newly created maps. + */ + private static final int ENTER_Y = 2; + + /** * The size of the map grid for the tested cursor. */ @NotNull @@ -66,9 +77,11 @@ private static MapCursor<TestGameObject, TestMapArchObject, TestArchetype> createCursor(@NotNull final MapGrid grid) { final TestMapModelCreator mapModelCreator = new TestMapModelCreator(false); final Size2D gridSize = grid.getSize(); - final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(grid, mapModelCreator.newMapModel(gridSize.getWidth(), gridSize.getHeight())); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapModelCreator.newMapModel(gridSize.getWidth(), gridSize.getHeight()); + mapModel.getMapArchObject().setEnterX(ENTER_X); + mapModel.getMapArchObject().setEnterY(ENTER_Y); + final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = new MapCursor<TestGameObject, TestMapArchObject, TestArchetype>(grid, mapModel); cursor.addMapCursorListener(listener); - Assert.assertFalse("MapCursor has to be disabled when created.", cursor.isActive()); listener.changedPosCounter = 0; listener.changedModeCounter = 0; return cursor; @@ -82,37 +95,31 @@ final MapGrid grid = new MapGrid(gridSize); final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = createCursor(grid); final Point p = new Point(); - for (int i = -2; i < gridSize.getWidth() + 2; i++) { + final int width = gridSize.getWidth(); + final int height = gridSize.getHeight(); + for (int i = -2; i < width + 2; i++) { p.setLocation(i, -1); cursor.setLocation(p); + testEvents(1, 0); + Assert.assertEquals(new Point(Math.max(0, Math.min(width - 1, i)), 0), cursor.getLocation()); testEvents(0, 0); - Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); - testEvents(0, 0); - Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); - testEvents(0, 0); - p.setLocation(i, gridSize.getHeight()); + p.setLocation(i, height); cursor.setLocation(p); + testEvents(1, 0); + Assert.assertEquals(new Point(Math.max(0, Math.min(width - 1, i)), height - 1), cursor.getLocation()); testEvents(0, 0); - Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); - testEvents(0, 0); - Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); - testEvents(0, 0); } - for (int i = -2; i < gridSize.getHeight() + 2; i++) { + for (int i = -2; i < height + 2; i++) { p.setLocation(-1, i); cursor.setLocation(p); + testEvents(1, 0); + Assert.assertEquals(new Point(0, Math.max(0, Math.min(height - 1, i))), cursor.getLocation()); testEvents(0, 0); - Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); - testEvents(0, 0); - Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); - testEvents(0, 0); - p.setLocation(gridSize.getWidth(), i); + p.setLocation(width, i); cursor.setLocation(p); + testEvents(1, 0); + Assert.assertEquals(new Point(width - 1, Math.max(0, Math.min(height - 1, i))), cursor.getLocation()); testEvents(0, 0); - Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); - testEvents(0, 0); - Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); - testEvents(0, 0); } } @@ -123,21 +130,12 @@ public void setInside() { final MapGrid grid = new MapGrid(gridSize); final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = createCursor(grid); - boolean first = true; final Point p = new Point(); for (int j = 0; j < gridSize.getHeight(); j++) { for (int i = 0; i < gridSize.getWidth(); i++) { p.setLocation(i, j); cursor.setLocation(p); - if (first) { - // Only the first after activation should fire a change mode event - testEvents(1, 1); - first = false; - } else { - testEvents(1, 0); - } - Assert.assertTrue("MapCursor should be active after setLocation(" + p + ")", cursor.isActive()); - testEvents(0, 0); + testEvents(1, 0); final Point res = cursor.getLocation(); testEvents(0, 0); Assert.assertEquals("getLocation()", p, res); @@ -153,29 +151,20 @@ public void setSameLocation() { final MapGrid grid = new MapGrid(gridSize); final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = createCursor(grid); - final Point p = new Point(-1, -1); - cursor.setLocation(null); + cursor.setLocation(new Point(3, 4)); + testEvents(1, 0); + cursor.setLocation(new Point(3, 4)); testEvents(0, 0); - Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + cursor.setLocation(new Point(1, 0)); + testEvents(1, 0); + cursor.setLocation(new Point(1, -1)); testEvents(0, 0); - cursor.setLocation(p); + cursor.setLocation(new Point(-3, -2)); + testEvents(1, 0); + cursor.setLocation(new Point(-2, -1)); testEvents(0, 0); - Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + cursor.setLocation(new Point(0, 0)); testEvents(0, 0); - p.setLocation(3, 4); - cursor.setLocation(p); - testEvents(1, 1); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); - cursor.setLocation(p); - testEvents(0, 0); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); - p.setLocation(-1, -1); - cursor.setLocation(p); - testEvents(1, 1); - Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); - testEvents(0, 0); } /** @@ -188,30 +177,18 @@ final Point p = new Point(-1, -1); Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); testEvents(0, 0); - Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); - testEvents(0, 0); Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); testEvents(0, 0); - Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); - testEvents(0, 0); p.setLocation(3, 4); Assert.assertTrue("setLocationSafe(" + p + ") should return true", cursor.setLocationSafe(p)); - testEvents(1, 1); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); + testEvents(1, 0); Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); testEvents(0, 0); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); p.setLocation(-1, -1); Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); testEvents(0, 0); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); testEvents(0, 0); - Assert.assertTrue("MapCursor should be active", cursor.isActive()); - testEvents(0, 0); } /** @@ -242,14 +219,10 @@ public void testGoTo() { final MapGrid grid = new MapGrid(gridSize); final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = createCursor(grid); - for (final Direction dir : Direction.values()) { - Assert.assertFalse("go(" + dir + ") should return false.", cursor.goTo(true, dir)); - testEvents(0, 0); - } final Point pStart = new Point(2, 3); final Point p = new Point(pStart); cursor.setLocation(p); - testEvents(1, 1); + testEvents(1, 0); for (final Direction dir : Direction.values()) { Assert.assertTrue("go(" + dir + ") should return true. (Maybe the grid was too small.)", cursor.goTo(true, dir)); testEvents(1, 0); @@ -269,24 +242,23 @@ final MapCursor<TestGameObject, TestMapArchObject, TestArchetype> cursor = createCursor(grid); Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); cursor.dragStart(); - testEvents(0, 0); - Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); - Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); + testEvents(0, 1); + Assert.assertEquals(new Dimension(0, 0), cursor.getDragOffset()); final Point dragStart = new Point(3, 4); final Point p = new Point(dragStart); final Dimension offset = new Dimension(0, 0); cursor.setLocation(dragStart); - testEvents(1, 1); + testEvents(1, 0); cursor.dragStart(); - testEvents(0, 1); + testEvents(0, 0); Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); cursor.deactivate(); - testEvents(1, 1); + testEvents(0, 1); Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); cursor.setLocation(dragStart); - testEvents(1, 1); + testEvents(0, 0); cursor.dragStart(); testEvents(0, 1); Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); @@ -386,7 +358,7 @@ cursor.dragRelease(); testEvents(0, 0); cursor.setLocation(start); - testEvents(1, 1); + testEvents(1, 0); cursor.dragStart(); te... [truncated message content] |
From: <aki...@us...> - 2013-12-04 20:51:20
|
Revision: 9520 http://sourceforge.net/p/gridarta/code/9520 Author: akirschbaum Date: 2013-12-04 20:51:14 +0000 (Wed, 04 Dec 2013) Log Message: ----------- Switch to adjacent map if the map cursor attempts to move off map on a tiled map set. Modified Paths: -------------- trunk/src/atrinik/ChangeLog trunk/src/crossfire/ChangeLog trunk/src/daimonin/ChangeLog trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java Modified: trunk/src/atrinik/ChangeLog =================================================================== --- trunk/src/atrinik/ChangeLog 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/atrinik/ChangeLog 2013-12-04 20:51:14 UTC (rev 9520) @@ -1,3 +1,8 @@ +2013-12-04 Andreas Kirschbaum + + * Switch to adjacent map if the map cursor attempts to move off + map on a tiled map set. + 2013-12-03 Andreas Kirschbaum * Always show the map cursor. For newly opened maps place the map Modified: trunk/src/crossfire/ChangeLog =================================================================== --- trunk/src/crossfire/ChangeLog 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/crossfire/ChangeLog 2013-12-04 20:51:14 UTC (rev 9520) @@ -1,3 +1,8 @@ +2013-12-04 Andreas Kirschbaum + + * Switch to adjacent map if the map cursor attempts to move off + map on a tiled map set. + 2013-12-03 Andreas Kirschbaum * Always show the map cursor. For newly opened maps place the map Modified: trunk/src/daimonin/ChangeLog =================================================================== --- trunk/src/daimonin/ChangeLog 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/daimonin/ChangeLog 2013-12-04 20:51:14 UTC (rev 9520) @@ -1,3 +1,8 @@ +2013-12-04 Andreas Kirschbaum + + * Switch to adjacent map if the map cursor attempts to move off + map on a tiled map set. + 2013-12-03 Andreas Kirschbaum * Always show the map cursor. For newly opened maps place the map Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/map/mapactions/MapActions.java 2013-12-04 20:51:14 UTC (rev 9520) @@ -944,7 +944,7 @@ * @param direction the direction to enter * @return whether the action was or can be performed */ - private boolean doEnterMap(final boolean performAction, @NotNull final Direction direction) { + public boolean doEnterMap(final boolean performAction, @NotNull final Direction direction) { final MapView<G, A, R> mapView = currentMapView; if (mapView == null) { return false; Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2013-12-04 20:51:14 UTC (rev 9520) @@ -23,6 +23,7 @@ import java.io.File; import java.util.Set; import javax.swing.Action; +import net.sf.gridarta.gui.map.mapactions.MapActions; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; @@ -60,6 +61,9 @@ @NotNull private static final Direction[] directions = Direction.values(); + @NotNull + private final MapActions<G, A, R> mapActions; + /** * Actions for "move cursor". */ @@ -170,7 +174,8 @@ * Create a new instance. * @param mapViewManager the map view manager */ - public MapCursorActions(@NotNull final MapViewManager<G, A, R> mapViewManager) { + public MapCursorActions(@NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapActions<G, A, R> mapActions) { + this.mapActions = mapActions; aMoveCursor = new Action[directions.length]; mapViewManager.addMapViewManagerListener(mapViewManagerListener); currentMapView = mapViewManager.getActiveMapView(); @@ -267,10 +272,10 @@ final MapCursor<G, A, R> mapCursor = mapView.getMapCursor(); if (!mapCursor.goTo(performAction, direction)) { - return false; - } - - if (performAction) { + if (!mapActions.doEnterMap(performAction, direction)) { + return false; + } + } else if (performAction) { final MapRenderer renderer = mapView.getRenderer(); final Point location = mapCursor.getLocation(); location.translate(BORDER * direction.getDx(), BORDER * direction.getDy()); Modified: trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-12-04 18:00:21 UTC (rev 9519) +++ trunk/src/gridarta/src/main/java/net/sf/gridarta/maincontrol/GUIMainControl.java 2013-12-04 20:51:14 UTC (rev 9520) @@ -383,7 +383,7 @@ newMapDialogFactory.setObjectChooser(objectChooser); final MapDesktop<G, A, R> mapDesktop = new MapDesktop<G, A, R>(mapViewManager, projectModel.getMapManager(), mapImageCache, mapViewsManager); final EnterMap<G, A, R> enterMap = new EnterMap<G, A, R>(parent, editorFactory.getDirectionMap(), mapPathNormalizer, fileControl, mapViewsManager); - final EditorAction mapActions = new MapActions<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, editorFactory.isAllowRandomMapParameters(), mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); + final MapActions<G, A, R> mapActions = new MapActions<G, A, R>(parent, projectModel.getMapManager(), mapViewManager, exitMatcher, GuiFileFilters.mapFileFilter, selectedSquareModel, editorFactory.isAllowRandomMapParameters(), mapPropertiesDialogFactory, mapViewSettings, mapViewsManager, enterMap); final MapFolderTreeActions<G, A, R> mapFolderTreeActions = new MapFolderTreeActions<G, A, R>(mapFolderTree, pickmapSettings, newMapDialogFactory, "createPickmapFolder", "deletePickmapFolder", "confirmDeletePickmapFolder", "deletePickmapFolderNotEmpty"); final ViewActions<G, A, R> viewActions = new ViewActions<G, A, R>(mapViewSettings, projectModel.getMapManager()); final EditorAction mapFileActions = new MapFileActions<G, A, R>(imageCreator2, projectModel.getMapManager(), mapViewsManager, mapViewManager, fileControl, parent); @@ -401,7 +401,7 @@ pluginParameters.addPluginParameter("rendererFactory", rendererFactory); final PluginController<G, A, R> pluginControl = new PluginController<G, A, R>(filterControl, projectModel.getPluginModel(), pluginParameters, parent, pluginParameterViewFactory, scriptsFile, resourceIcons); final EditorAction mainActions = new MainActions<G, A, R>(findDialogManager, replaceDialogManager, mainViewFrame, mapViewSettings, projectModel.getArchetypeSet(), copyBuffer, objectChooser, projectModel.getMapManager(), mapViewManager, insertionModeSet); - final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(mapViewManager); + final EditorAction mapCursorActions = new MapCursorActions<G, A, R>(mapViewManager, mapActions); final Action moveSquareDownAction = createAction("moveSquareDown", "Selected Square View", new MoveSquareDownAction<G, A, R>(selectedSquareModel, projectModel.getMapManager())); final Action moveSquareUpAction = createAction("moveSquareUp", "Selected Square View", new MoveSquareUpAction<G, A, R>(selectedSquareModel, projectModel.getMapManager())); final Action moveSquareBottomAction = createAction("moveSquareBottom", "Selected Square View", new MoveSquareBottomAction<G, A, R>(selectedSquareModel, projectModel.getMapManager())); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |