You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(103) |
Jun
(121) |
Jul
(16) |
Aug
(67) |
Sep
(126) |
Oct
(161) |
Nov
(164) |
Dec
(588) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(394) |
Feb
(181) |
Mar
(131) |
Apr
(180) |
May
(255) |
Jun
(11) |
Jul
(79) |
Aug
(70) |
Sep
(274) |
Oct
(138) |
Nov
(195) |
Dec
(8) |
2008 |
Jan
(3) |
Feb
(142) |
Mar
(162) |
Apr
(124) |
May
(148) |
Jun
(157) |
Jul
(425) |
Aug
(373) |
Sep
(264) |
Oct
(315) |
Nov
(225) |
Dec
(6) |
2009 |
Jan
(67) |
Feb
(78) |
Mar
(279) |
Apr
(294) |
May
(92) |
Jun
(65) |
Jul
(134) |
Aug
(41) |
Sep
(138) |
Oct
(125) |
Nov
(126) |
Dec
(122) |
2010 |
Jan
(15) |
Feb
(48) |
Mar
(9) |
Apr
(195) |
May
(373) |
Jun
(507) |
Jul
(42) |
Aug
(16) |
Sep
(38) |
Oct
(81) |
Nov
(64) |
Dec
(18) |
2011 |
Jan
(13) |
Feb
(12) |
Mar
(39) |
Apr
(1) |
May
(2) |
Jun
(27) |
Jul
(27) |
Aug
(31) |
Sep
(14) |
Oct
(102) |
Nov
(20) |
Dec
(37) |
2012 |
Jan
(22) |
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(2) |
Jun
(18) |
Jul
(6) |
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
2013 |
Jan
(1) |
Feb
(2) |
Mar
(1) |
Apr
(1) |
May
(47) |
Jun
(7) |
Jul
(107) |
Aug
|
Sep
|
Oct
(112) |
Nov
(31) |
Dec
(17) |
2014 |
Jan
(29) |
Feb
(111) |
Mar
(34) |
Apr
|
May
(1) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
(18) |
Dec
(10) |
From: <aki...@us...> - 2011-10-18 16:45:28
|
Revision: 9060 http://gridarta.svn.sourceforge.net/gridarta/?rev=9060&view=rev Author: akirschbaum Date: 2011-10-18 16:45:21 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Extract ExitIterator from MapActions. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/mapactions/ExitIterator.java Added: trunk/src/app/net/sf/gridarta/gui/map/mapactions/ExitIterator.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/ExitIterator.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/ExitIterator.java 2011-10-18 16:45:21 UTC (rev 9060) @@ -0,0 +1,159 @@ +/* + * 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.gui.map.mapactions; + +import java.awt.Point; +import java.util.Iterator; +import java.util.NoSuchElementException; +import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.exitconnector.ExitMatcher; +import net.sf.gridarta.model.gameobject.GameObject; +import net.sf.gridarta.model.maparchobject.MapArchObject; +import net.sf.gridarta.model.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * An {@link Iterator} that returns all map squares containing an exit game + * object. + * @author Andreas Kirschbaum + */ +public class ExitIterator<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements Iterator<G> { + + /** + * The {@link ExitMatcher} for selecting exit game objects. + */ + @NotNull + private final ExitMatcher<G, A, R> exitMatcher; + + /** + * The {@link MapModel} begin searched. + */ + @NotNull + private final MapModel<G, A, R> mapModel; + + /** + * The search direction: <code>-1</code> for backward or <code>+1</code> for + * forward. + */ + private final int direction; + + /** + * The current location on the map. + */ + @NotNull + private final Point point; + + /** + * The starting exit game object or <code>null</code>. + */ + @Nullable + private final G start; + + /** + * The number of map squares remaining to be searched. + */ + private int remainingMapSquares; + + /** + * Whether {@link #next} is valid. + */ + private boolean findNextPending = true; + + /** + * The next exit game object to return from {@link #next()}. + */ + @Nullable + private G next; + + /** + * Creates a new instance. + * @param exitMatcher the exit matcher for selecting exit game objects + * @param mapModel the map model to search + * @param xStart the x coordinate to start seacrhing + * @param yStart the y coordinate to start seacrhing + * @param direction the search direction: <code>-1</code> for backward or + * <code>+1</code> for forward + */ + public ExitIterator(@NotNull final ExitMatcher<G, A, R> exitMatcher, @NotNull final MapModel<G, A, R> mapModel, final int xStart, final int yStart, final int direction) { + if (direction != -1 && direction != 1) { + throw new IllegalArgumentException(); + } + this.exitMatcher = exitMatcher; + this.mapModel = mapModel; + this.direction = direction; + point = new Point(xStart, yStart); + start = exitMatcher.getValidExit(mapModel, point); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + remainingMapSquares = mapSize.getWidth() * mapSize.getHeight(); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean hasNext() { + findNext(); + return next != null; + } + + /** + * {@inheritDoc} + */ + @Override + public G next() { + findNext(); + if (next == null) { + throw new NoSuchElementException(); + } + findNextPending = true; + return next; + } + + /** + * {@inheritDoc} + */ + @Override + public void remove() { + throw new UnsupportedOperationException(); + } + + /** + * Updates {@link #next} to the next match. + */ + private void findNext() { + if (!findNextPending) { + return; + } + findNextPending = false; + + //noinspection WhileLoopSpinsOnField + while (remainingMapSquares-- > 0) { + mapModel.nextPoint(point, direction); + next = exitMatcher.getValidExit(mapModel, point); + if (next != null && next != start) { + return; + } + } + next = null; + } + +} Property changes on: trunk/src/app/net/sf/gridarta/gui/map/mapactions/ExitIterator.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 16:44:23 UTC (rev 9059) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 16:45:21 UTC (rev 9060) @@ -45,6 +45,7 @@ import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.model.mapmanager.MapManagerListener; 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.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.ActionUtils; @@ -576,18 +577,13 @@ */ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); - final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); - final Point point = new Point(xStart, yStart); - final G currentExit = exitMatcher.getValidExit(mapModel, point); - for (int i = mapSize.getWidth() * mapSize.getHeight(); i > 0; i--) { - mapModel.nextPoint(point, direction); - final G exit = exitMatcher.getValidExit(mapModel, point); - if (exit != null && exit != currentExit) { - mapView.setCursorLocation(point); - return; - } - } - if (currentExit == null) { + final ExitIterator<G, A, R> exitIterator = new ExitIterator<G, A, R>(exitMatcher, mapModel, xStart, yStart, direction); + if (exitIterator.hasNext()) { + final G exit = exitIterator.next(); + final MapSquare<G,A,R> mapSquare = exit.getMapSquare(); + assert mapSquare != null; + mapView.setCursorLocation(mapSquare.getMapLocation()); + } else { mapView.setCursorLocation(null); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-18 16:44:30
|
Revision: 9059 http://gridarta.svn.sourceforge.net/gridarta/?rev=9059&view=rev Author: akirschbaum Date: 2011-10-18 16:44:23 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Fix Next Exit not finding all exits. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2011-10-18 07:58:17 UTC (rev 9058) +++ trunk/atrinik/ChangeLog 2011-10-18 16:44:23 UTC (rev 9059) @@ -1,3 +1,7 @@ +2011-10-18 Andreas Kirschbaum + + * Fix Next Exit not finding all exits. + 2011-09-22 Andreas Kirschbaum * Remove "Exits" panel from main window. It is redundant with Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2011-10-18 07:58:17 UTC (rev 9058) +++ trunk/crossfire/ChangeLog 2011-10-18 16:44:23 UTC (rev 9059) @@ -1,3 +1,7 @@ +2011-10-18 Andreas Kirschbaum + + * Fix Next Exit not finding all exits. + 2011-09-22 Andreas Kirschbaum * Remove "Exits" panel from main window. It is redundant with Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2011-10-18 07:58:17 UTC (rev 9058) +++ trunk/daimonin/ChangeLog 2011-10-18 16:44:23 UTC (rev 9059) @@ -1,3 +1,7 @@ +2011-10-18 Andreas Kirschbaum + + * Fix Next Exit not finding all exits. + 2011-09-22 Andreas Kirschbaum * Remove "Exits" panel from main window. It is redundant with Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-18 07:58:17 UTC (rev 9058) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-18 16:44:23 UTC (rev 9059) @@ -152,8 +152,8 @@ } else if (point.x < 0) { point.x = 0; } - if (point.x >= mapSize.getHeight()) { - point.x = mapSize.getHeight() - 1; + if (point.y >= mapSize.getHeight()) { + point.y = mapSize.getHeight() - 1; } else if (point.y < 0) { point.y = 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-18 07:58:24
|
Revision: 9058 http://gridarta.svn.sourceforge.net/gridarta/?rev=9058&view=rev Author: akirschbaum Date: 2011-10-18 07:58:17 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Inline variables. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 07:56:53 UTC (rev 9057) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 07:58:17 UTC (rev 9058) @@ -577,11 +577,9 @@ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); - final int width = mapSize.getWidth(); - final int height = mapSize.getHeight(); final Point point = new Point(xStart, yStart); final G currentExit = exitMatcher.getValidExit(mapModel, point); - for (int i = width * height; i > 0; i--) { + for (int i = mapSize.getWidth() * mapSize.getHeight(); i > 0; i--) { mapModel.nextPoint(point, direction); final G exit = exitMatcher.getValidExit(mapModel, point); if (exit != null && exit != currentExit) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-18 07:57:00
|
Revision: 9057 http://gridarta.svn.sourceforge.net/gridarta/?rev=9057&view=rev Author: akirschbaum Date: 2011-10-18 07:56:53 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Extract MpaModel.nextPoint() from MapActions. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModel.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-18 07:33:28 UTC (rev 9056) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-18 07:56:53 UTC (rev 9057) @@ -1045,6 +1045,34 @@ } /** + * {@inheritDoc} + */ + @Override + public void nextPoint(final Point point, final int direction) { + final Size2D mapSize = mapArchObject.getMapSize(); + if (direction > 0) { + point.x++; + if (point.x >= mapSize.getWidth()) { + point.x = 0; + point.y++; + if (point.y >= mapSize.getHeight()) { + point.y = 0; + } + } + } else { + point.x--; + final int mapHeight = mapSize.getHeight(); + if (point.x < 0) { + point.x = mapSize.getWidth() - 1; + point.y--; + if (point.y < 0) { + point.y = mapSize.getHeight() - 1; + } + } + } + } + + /** * Marks the map as being modified. */ private void setModified() { Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModel.java 2011-10-18 07:33:28 UTC (rev 9056) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapModel.java 2011-10-18 07:56:53 UTC (rev 9057) @@ -427,4 +427,11 @@ */ void facesReloaded(); + /** + * Moves the given point forward or backward one map square. + * @param point the point to start with and modify + * @param direction the direction (<code>-1</code> or <code>+1</code>) + */ + void nextPoint(Point point, int direction); + } // interface MapModel Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 07:33:28 UTC (rev 9056) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-18 07:56:53 UTC (rev 9057) @@ -582,26 +582,7 @@ final Point point = new Point(xStart, yStart); final G currentExit = exitMatcher.getValidExit(mapModel, point); for (int i = width * height; i > 0; i--) { - if (direction > 0) { - point.x++; - if (point.x >= width) { - point.x = 0; - point.y++; - if (point.y >= height) { - point.y = 0; - } - } - } else { - point.x--; - if (point.x < 0) { - point.x = width - 1; - point.y--; - if (point.y < 0) { - point.y = height - 1; - } - } - } - + mapModel.nextPoint(point, direction); final G exit = exitMatcher.getValidExit(mapModel, point); if (exit != null && exit != currentExit) { mapView.setCursorLocation(point); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-18 07:33:34
|
Revision: 9056 http://gridarta.svn.sourceforge.net/gridarta/?rev=9056&view=rev Author: akirschbaum Date: 2011-10-18 07:33:28 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Fix failing regression test. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-17 18:02:43 UTC (rev 9055) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-18 07:33:28 UTC (rev 9056) @@ -327,7 +327,7 @@ if (mapSize.getHeight() > newSize.getHeight()) { // clear out the bottom stripe (as far as being cut off) - mapGrid.collectHeads(0, newSize.getHeight(), mapSize.getWidth(), mapSize.getHeight(), objectsToDelete); + mapGrid.collectHeads(0, newSize.getHeight(), Math.min(mapSize.getWidth(), newSize.getWidth()), mapSize.getHeight(), objectsToDelete); } for (final GameObject<G, A, R> node : objectsToDelete) { @@ -335,9 +335,9 @@ } mapGrid.resize(newSize); - discardInvalidMapSquares(changedSquares, mapSize); - discardInvalidGameObjects(changedGameObjects, mapSize); - discardInvalidGameObjects(transientChangedGameObjects, mapSize); + discardInvalidMapSquares(changedSquares, newSize); + discardInvalidGameObjects(changedGameObjects, newSize); + discardInvalidGameObjects(transientChangedGameObjects, newSize); fireMapSizeChanged(newSize); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-17 18:02:53
|
Revision: 9055 http://gridarta.svn.sourceforge.net/gridarta/?rev=9055&view=rev Author: akirschbaum Date: 2011-10-17 18:02:43 +0000 (Mon, 17 Oct 2011) Log Message: ----------- Move code from AbstractMapArchObject to DefaultMapModel. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java trunk/model/src/app/net/sf/gridarta/model/maparchobject/MapArchObject.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java Modified: trunk/model/src/app/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2011-10-17 09:22:28 UTC (rev 9054) +++ trunk/model/src/app/net/sf/gridarta/model/maparchobject/AbstractMapArchObject.java 2011-10-17 18:02:43 UTC (rev 9055) @@ -21,14 +21,9 @@ import java.awt.Point; import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; import java.util.regex.Matcher; import java.util.regex.Pattern; -import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -627,35 +622,6 @@ /** * {@inheritDoc} */ - @Override - public <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidMapSquares(@NotNull final Collection<MapSquare<G, A, R>> mapSquares) { - final Iterator<MapSquare<G, A, R>> it = mapSquares.iterator(); - while (it.hasNext()) { - final MapSquare<G, A, R> mapSquare = it.next(); - if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { - it.remove(); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - public <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidGameObjects(@NotNull final Collection<G> gameObjects) { - final Iterator<G> it2 = gameObjects.iterator(); - while (it2.hasNext()) { - final GameObject<G, A, R> gameObject = it2.next(); - final G topGameObject = gameObject.getTopContainer(); - if (topGameObject.getContainer() == null || topGameObject.getMapX() >= mapSize.getWidth() || topGameObject.getMapY() >= mapSize.getHeight()) { - it2.remove(); - } - } - } - - /** - * {@inheritDoc} - */ @NotNull @Override @SuppressWarnings("unchecked") Modified: trunk/model/src/app/net/sf/gridarta/model/maparchobject/MapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/maparchobject/MapArchObject.java 2011-10-17 09:22:28 UTC (rev 9054) +++ trunk/model/src/app/net/sf/gridarta/model/maparchobject/MapArchObject.java 2011-10-17 18:02:43 UTC (rev 9055) @@ -21,11 +21,7 @@ import java.awt.Point; import java.io.Serializable; -import java.util.Collection; -import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.model.gameobject.GameObject; -import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -295,16 +291,4 @@ */ boolean isPointValid(@Nullable Point pos); - /** - * Discards map squares that are out of map bounds. - * @param mapSquares the map squares to check - */ - <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidMapSquares(@NotNull Collection<MapSquare<G, A, R>> mapSquares); - - /** - * Discards game objects that are out of map bounds. - * @param gameObjects the game objects to check - */ - <G extends GameObject<G, A, R>, R extends Archetype<G, A, R>> void discardInvalidGameObjects(@NotNull Collection<G> gameObjects); - } // interface MapArchObject Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-17 09:22:28 UTC (rev 9054) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-17 18:02:43 UTC (rev 9055) @@ -335,15 +335,46 @@ } mapGrid.resize(newSize); - mapArchObject.discardInvalidMapSquares(changedSquares); - mapArchObject.<G, R>discardInvalidGameObjects(changedGameObjects); - mapArchObject.<G, R>discardInvalidGameObjects(transientChangedGameObjects); + discardInvalidMapSquares(changedSquares, mapSize); + discardInvalidGameObjects(changedGameObjects, mapSize); + discardInvalidGameObjects(transientChangedGameObjects, mapSize); fireMapSizeChanged(newSize); } } /** + * Discards map squares that are out of map bounds. + * @param mapSquares the map squares to check + * @param mapSize the new map size + */ + private void discardInvalidMapSquares(@NotNull final Collection<MapSquare<G, A, R>> mapSquares, @NotNull final Size2D mapSize) { + final Iterator<MapSquare<G, A, R>> it = mapSquares.iterator(); + while (it.hasNext()) { + final MapSquare<G, A, R> mapSquare = it.next(); + if (mapSquare.getMapX() >= mapSize.getWidth() || mapSquare.getMapY() >= mapSize.getHeight()) { + it.remove(); + } + } + } + + /** + * Discards game objects that are out of map bounds. + * @param gameObjects the game objects to check + * @param mapSize the new map size + */ + private void discardInvalidGameObjects(@NotNull final Iterable<G> gameObjects, @NotNull final Size2D mapSize) { + final Iterator<G> it2 = gameObjects.iterator(); + while (it2.hasNext()) { + final GameObject<G, A, R> gameObject = it2.next(); + final G topGameObject = gameObject.getTopContainer(); + if (topGameObject.getContainer() == null || topGameObject.getMapX() >= mapSize.getWidth() || topGameObject.getMapY() >= mapSize.getHeight()) { + it2.remove(); + } + } + } + + /** * {@inheritDoc} */ @Override This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-17 09:22:38
|
Revision: 9054 http://gridarta.svn.sourceforge.net/gridarta/?rev=9054&view=rev Author: akirschbaum Date: 2011-10-17 09:22:28 +0000 (Mon, 17 Oct 2011) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-16 23:26:16 UTC (rev 9053) +++ trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2011-10-17 09:22:28 UTC (rev 9054) @@ -31,7 +31,6 @@ import net.sf.gridarta.model.exitconnector.ExitLocation; 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.mapcursor.MapCursorEvent; import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.utils.ActionUtils; @@ -236,13 +235,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapCursor(); - if (!mapCursor.isActive()) { - // no active cursor ==> no location to remember - return false; - } - - final Point location = mapCursor.getLocation(); + final Point location = mapView.getMapCursor().getLocation(); // no active cursor ==> no location to remember return location != null && exitConnectorActions.doExitCopy(performAction, mapView.getMapControl(), location); } @@ -258,12 +251,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapCursor(); - if (!mapCursor.isActive()) { - return false; - } - - final Point targetLocation = mapCursor.getLocation(); + final Point targetLocation = mapView.getMapCursor().getLocation(); return targetLocation != null && exitConnectorActions.doExitPaste(performAction, mapView.getMapControl(), targetLocation); } @@ -278,12 +266,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapCursor(); - if (!mapCursor.isActive()) { - return false; - } - - final Point targetLocation = mapCursor.getLocation(); + final Point targetLocation = mapView.getMapCursor().getLocation(); return targetLocation != null && exitConnectorActions.doExitConnect(performAction, mapView.getMapControl(), targetLocation); } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-16 23:26:16 UTC (rev 9053) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-17 09:22:28 UTC (rev 9054) @@ -40,7 +40,6 @@ import net.sf.gridarta.model.maparchobject.MapArchObject; import net.sf.gridarta.model.maparchobject.MapArchObjectListener; import net.sf.gridarta.model.mapcontrol.MapControl; -import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapcursor.MapCursorEvent; import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.model.mapmanager.MapManager; @@ -576,7 +575,6 @@ * @param direction the direction to search */ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { - final MapCursor mapCursor = mapView.getMapCursor(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int width = mapSize.getWidth(); @@ -879,8 +877,7 @@ } if (performAction) { - final MapCursor mapCursor = mapView.getMapCursor(); - final Point cursorLocation = mapCursor.getLocation(); + final Point cursorLocation = mapView.getMapCursor().getLocation(); if (cursorLocation == null) { selectExit(mapView, -1, 0, 1); } else { @@ -903,8 +900,7 @@ } if (performAction) { - final MapCursor mapCursor = mapView.getMapCursor(); - final Point cursorLocation = mapCursor.getLocation(); + final Point cursorLocation = mapView.getMapCursor().getLocation(); if (cursorLocation == null) { final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); selectExit(mapView, mapSize.getWidth(), mapSize.getHeight() - 1, -1); Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-16 23:26:16 UTC (rev 9053) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-17 09:22:28 UTC (rev 9054) @@ -45,7 +45,6 @@ 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.mapcursor.MapCursor; import net.sf.gridarta.model.mapmanager.MapManager; import net.sf.gridarta.model.mapmanager.MapManagerListener; import net.sf.gridarta.model.mapmodel.MapModel; @@ -113,11 +112,11 @@ private final MapViewsManager<G, A, R> mapViewsManager; /** - * The {@link MapCursor} for displaying map errors. Set to <code>null</code> + * The {@link MapView} for displaying map errors. Set to <code>null</code> * if no map is active. */ @Nullable - private MapCursor mapCursor = null; + private MapView<G, A, R> mapView = null; /** * The list selection listener to detect selected list entries. @@ -272,11 +271,11 @@ /** * Set the error for a map. - * @param mapCursor the map cursor or <code>null</code> + * @param mapView the map view or <code>null</code> * @param errors the errors */ - public void setErrors(@NotNull final MapCursor mapCursor, @NotNull final ErrorCollector<G, A, R> errors) { - this.mapCursor = mapCursor; + public void setErrors(@NotNull final MapView<G, A, R> mapView, @NotNull final ErrorCollector<G, A, R> errors) { + this.mapView = mapView; updateErrors(errors); } @@ -284,7 +283,7 @@ * Clears the displayed errors. */ public void unsetErrors() { - mapCursor = null; + mapView = null; errors = null; errorList.setModel(new DefaultListModel()); fireErrorsUpdated(false); @@ -351,14 +350,14 @@ } /** - * Updates the {@link #mapCursor}'s location. Does nothing if no map cursor + * Updates the {@link #mapView}'s location. Does nothing if no map cursor * is active. * @param point the location to set */ private void setMapCursorLocation(@Nullable final Point point) { - final MapCursor tmp = mapCursor; + final MapView<G, A, R> tmp = mapView; if (tmp != null) { - tmp.setLocation(point); + tmp.setCursorLocation(point); } } @@ -381,7 +380,7 @@ final MapView<G, A, R> mapView = mapViewsManager.getMapViewFrame(mapControl); if (mapView != null) { final ErrorCollector<G, A, R> errorCollector = mapControl.getMapModel().getErrors(); - setErrors(mapView.getMapCursor(), errorCollector); + setErrors(mapView, errorCollector); return; } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-16 23:26:16 UTC (rev 9053) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-17 09:22:28 UTC (rev 9054) @@ -47,7 +47,6 @@ 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.mapcursor.MapCursor; import net.sf.gridarta.model.mapcursor.MapCursorEvent; import net.sf.gridarta.model.mapcursor.MapCursorListener; import net.sf.gridarta.model.mapgrid.MapGrid; @@ -1085,8 +1084,7 @@ } if (performAction) { - final MapCursor mapCursor = mapView.getMapCursor(); - final Point cursorLocation = mapCursor.getLocation(); + final Point cursorLocation = mapView.getMapCursor().getLocation(); final Point origin = cursorLocation == null ? selectedRec.getLocation() : cursorLocation; copyBuffer.pasteTiled(mapView, selectedSquares, origin); } @@ -1242,8 +1240,7 @@ return false; } - final MapCursor mapCursor = mapView.getMapCursor(); - final Point mapCursorLocation = mapCursor.getLocation(); + final Point mapCursorLocation = mapView.getMapCursor().getLocation(); if (mapCursorLocation == null) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 23:26:22
|
Revision: 9053 http://gridarta.svn.sourceforge.net/gridarta/?rev=9053&view=rev Author: akirschbaum Date: 2011-10-16 23:26:16 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Always include debug information. Modified Paths: -------------- trunk/build.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2011-10-16 23:25:46 UTC (rev 9052) +++ trunk/build.xml 2011-10-16 23:26:16 UTC (rev 9053) @@ -29,7 +29,7 @@ <property name="build.source.encoding" value="utf-8"/> <property name="build.source.version" value="1.5"/> <property name="build.target.version" value="${build.source.version}"/> - <property name="debug" value="false"/> + <property name="debug" value="true"/> <property name="build.developer" value="unknown"/> <property name="javac.fork" value="no"/> <property name="javac.args" value="-Xlint:all,-path,-unchecked,-fallthrough,-serial,-deprecation"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 23:25:52
|
Revision: 9052 http://gridarta.svn.sourceforge.net/gridarta/?rev=9052&view=rev Author: akirschbaum Date: 2011-10-16 23:25:46 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Fix crash (lockup) introduced in r9042. [Crossfire] Revision Links: -------------- http://gridarta.svn.sourceforge.net/gridarta/?rev=9042&view=rev Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-16 09:48:50 UTC (rev 9051) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-16 23:25:46 UTC (rev 9052) @@ -229,7 +229,7 @@ final MapArchObject mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); for (int dx = -1; dx <= 1; dx++) { - for (int dy = -1; dy <= dy + 1; dy++) { + for (int dy = -1; dy <= 1; dy++) { mapSquare.getMapLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { toRepaint.add(mapModel.getMapSquare(point)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 09:48:56
|
Revision: 9051 http://gridarta.svn.sourceforge.net/gridarta/?rev=9051&view=rev Author: akirschbaum Date: 2011-10-16 09:48:50 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Add MapView.setCursorLocation(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java Modified: trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2011-10-16 09:35:59 UTC (rev 9050) +++ trunk/src/app/net/sf/gridarta/gui/dialog/golocation/GoLocationDialog.java 2011-10-16 09:48:50 UTC (rev 9051) @@ -222,7 +222,7 @@ return false; } - mapView.getMapCursor().setLocation(point); + mapView.setCursorLocation(point); return true; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-16 09:35:59 UTC (rev 9050) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-16 09:48:50 UTC (rev 9051) @@ -176,10 +176,9 @@ final Point point2 = point.x == -1 && point.y == -1 ? mapView.getMapControl().getMapModel().getMapArchObject().getEnter() : point; if (!mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(point2)) { ACTION_BUILDER.showMessageDialog(parent, "enterExitOutside"); - return; } - mapView.getMapCursor().setLocation(point2); + mapView.setCursorLocation(point2); } /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-16 09:35:59 UTC (rev 9050) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-16 09:48:50 UTC (rev 9051) @@ -606,12 +606,12 @@ final G exit = exitMatcher.getValidExit(mapModel, point); if (exit != null && exit != currentExit) { - mapCursor.setLocation(point); + mapView.setCursorLocation(point); return; } } if (currentExit == null) { - mapCursor.setLocation(null); + mapView.setCursorLocation(null); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-16 09:35:59 UTC (rev 9050) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/AbstractMapView.java 2011-10-16 09:48:50 UTC (rev 9051) @@ -31,6 +31,7 @@ import net.sf.gridarta.model.mapmodel.MapModel; import net.sf.gridarta.model.mapmodel.MapSquare; import net.sf.gridarta.utils.RandomUtils; +import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -139,4 +140,25 @@ return mapCursor; } + /** + * {@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.x >= mapSize.getHeight()) { + point.x = mapSize.getHeight() - 1; + } else if (point.y < 0) { + point.y = 0; + } + } + mapCursor.setLocation(point); + } + } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-16 09:35:59 UTC (rev 9050) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-16 09:48:50 UTC (rev 9051) @@ -20,6 +20,7 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Component; +import java.awt.Point; import java.util.List; import javax.swing.JInternalFrame; import javax.swing.JScrollPane; @@ -133,4 +134,12 @@ @NotNull JScrollPane getScrollPane(); + /** + * 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; + * will be modified to the actually set cursor location + */ + void setCursorLocation(@Nullable Point point); + } // interface MapView This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 09:36:06
|
Revision: 9050 http://gridarta.svn.sourceforge.net/gridarta/?rev=9050&view=rev Author: akirschbaum Date: 2011-10-16 09:35:59 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Rename function names. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -230,7 +230,7 @@ final Point point = new Point(); for (int dx = -1; dx <= 1; dx++) { for (int dy = -1; dy <= dy + 1; dy++) { - mapSquare.getLocation(point, dx, dy); + mapSquare.getMapLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { toRepaint.add(mapModel.getMapSquare(point)); } @@ -401,7 +401,7 @@ * @param square the square to paint */ private void paintSquare(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> square) { - final Point pos = square.getLocation(); + final Point pos = square.getMapLocation(); updateSquare(pos); repaint(0L, borderOffset.x + pos.x * IGUIConstants.SQUARE_WIDTH, borderOffset.y + pos.y * IGUIConstants.SQUARE_HEIGHT, IGUIConstants.SQUARE_WIDTH, IGUIConstants.SQUARE_HEIGHT); } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -312,12 +312,12 @@ if (filterControl.canShow(node) && mapViewSettings.isEditType(node)) { paintGameObject(g, x, y, node); if (node.getAttributeInt(GameObject.SMOOTHLEVEL, true) > 0) { - smoothingRenderer.paintSmooth(g, square.getLocation(), node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, borderOffsetX, borderOffsetY); + smoothingRenderer.paintSmooth(g, square.getMapLocation(), node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, borderOffsetX, borderOffsetY); } } } if (layer > -1) { - smoothingRenderer.paintSmooth(g, square.getLocation(), 1, layer + 1, true, borderOffsetX, borderOffsetY); + smoothingRenderer.paintSmooth(g, square.getMapLocation(), 1, layer + 1, true, borderOffsetX, borderOffsetY); } } else { for (final GameObject node : square) { Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -92,7 +92,7 @@ continue; } } - mapModel.insertBaseObject(gameObject, mapSquare.getLocation(), false, false, insertionMode); + mapModel.insertBaseObject(gameObject, mapSquare.getMapLocation(), false, false, insertionMode); } } finally { mapModel.endTransaction(); @@ -113,7 +113,7 @@ final Point pos = new Point(); for (int dy = -1; dy < h + 1; dy++) { for (int dx = -1; dx < w + 1; dx++) { - topLeftMapSquare.getLocation(pos, dx, dy); + topLeftMapSquare.getMapLocation(pos, dx, dy); final MapSquare<G, A, R> mapSquare; try { mapSquare = mapModel.getMapSquare(pos); Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -671,7 +671,7 @@ gameObject.remove(); if (join) { - autojoinLists.joinDelete(this, mapSquare.getLocation(), gameObject.getArchetype()); + autojoinLists.joinDelete(this, mapSquare.getMapLocation(), gameObject.getArchetype()); } } } Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -102,7 +102,7 @@ * @return the coordinate on the map */ @NotNull - public Point getLocation() { + public Point getMapLocation() { return new Point(mapX, mapY); } @@ -110,7 +110,7 @@ * Returns the coordinate on the map. * @param pos returns the coordinate on the map */ - public void getLocation(@NotNull final Point pos) { + public void getMapLocation(@NotNull final Point pos) { pos.x = mapX; pos.y = mapY; } @@ -121,7 +121,7 @@ * @param dx the x offset to add to the coordinate * @param dy the y offset to add to the coordinate */ - public void getLocation(@NotNull final Point pos, final int dx, final int dy) { + public void getMapLocation(@NotNull final Point pos, final int dx, final int dy) { pos.x = mapX + dx; pos.y = mapY + dy; } Modified: trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -95,7 +95,7 @@ final Point pos = new Point(); for (final MapSquare<G, A, R> mapSquare : mapModel) { for (final G gameObject : mapSquare) { - mapSquare.getLocation(pos); + mapSquare.getMapLocation(pos); checkSpawnPoint(gameObject, pos, blocked, errorCollector); for (final G invObject : gameObject.recursive()) { checkSpawnPoint(invObject, pos, blocked, errorCollector); Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -155,7 +155,7 @@ final Collection<G> gameObjectsToDelete = new HashSet<G>(); final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapView.getSelectedSquares()) { - square.getLocation(pos, -selectedRec.x, -selectedRec.y); + square.getMapLocation(pos, -selectedRec.x, -selectedRec.y); for (final G gameObject : square) { copyMode.process(mapModel, gameObject, mapViewSettings.isEditType(gameObject), gameObjectsToDelete, pos, gameObjectFactory, insertionModeSet); } @@ -184,7 +184,7 @@ try { final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapModel) { - square.getLocation(pos); + square.getMapLocation(pos); pos.translate(startLocation.x, startLocation.y); if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { @@ -196,7 +196,7 @@ } for (final MapSquare<G, A, R> square : mapModel) { - square.getLocation(pos); + square.getMapLocation(pos); pos.translate(startLocation.x, startLocation.y); if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { Modified: trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -822,7 +822,7 @@ throw new IllegalArgumentException(); } mapModel = mapSquare.getMapModel(); - mapPos = mapSquare.getLocation(); + mapPos = mapSquare.getMapLocation(); mapModel.addMapModelListener(mapModelListener); mapManager.addMapManagerListener(mapManagerListener); Modified: trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -511,9 +511,9 @@ } // insert replacement object if (randomArch.isMulti()) { - mapModel.insertBaseObject(randomArch, square.getLocation(), false, false, insertionModeSet.getTopmostInsertionMode()); + mapModel.insertBaseObject(randomArch, square.getMapLocation(), false, false, insertionModeSet.getTopmostInsertionMode()); } else { - mapModel.insertArchToMap(randomArch, prevArch, square.getLocation(), false); + mapModel.insertArchToMap(randomArch, prevArch, square.getMapLocation(), false); } } replaceCount++; Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -344,7 +344,7 @@ final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.getMapSquares().iterator(); if (mapSquareIterator.hasNext()) { final MapSquare<G, A, R> mapSquare = mapSquareIterator.next(); - setMapCursorLocation(mapSquare == null ? null : mapSquare.getLocation()); + setMapCursorLocation(mapSquare == null ? null : mapSquare.getMapLocation()); } } errorMsg.setCaretPosition(0); Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -604,7 +604,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Add to environment"); // TODO; I18N/L10N try { - final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); + final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getMapLocation(), true); if (insertedGameObject != null) { mapModel.removeGameObject(prevGameObject, true); insertedGameObject.addLast(prevGameObject); Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -115,7 +115,7 @@ */ public boolean validateMapSquare() { final MapSquare<G, A, R> currentMapSquare = mapSquare; // copy for concurrency reasons - return currentMapSquare != null && !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(currentMapSquare.getLocation()) && setMapSquare(null, null, 0); + return currentMapSquare != null && !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(currentMapSquare.getMapLocation()) && setMapSquare(null, null, 0); } /** Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -195,7 +195,7 @@ } final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - final Point pos = mapSquare.getLocation(); + final Point pos = mapSquare.getMapLocation(); if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { return false; } Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -728,7 +728,7 @@ final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("Insert"); // TODO; I18N/L10N try { - final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); + final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getMapLocation(), true); if (insertedGameObject != null) { setSelectedGameObject(insertedGameObject); } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-16 09:34:34 UTC (rev 9049) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-16 09:35:59 UTC (rev 9050) @@ -1328,7 +1328,7 @@ for (int dy = -1; dy <= 1; dy++) { for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { - mapSquare.getLocation(point, dx, dy); + mapSquare.getMapLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { final MapSquare<G, A, R> newMapSquare = mapModel.getMapSquare(point); if (newMapSquare.isEmpty() && !newSelection.containsKey(newMapSquare)) { @@ -1347,7 +1347,7 @@ try { mapGrid.unSelect(); for (final MapSquare<G, A, R> mapSquare : newSelection.keySet()) { - mapSquare.getLocation(point); + mapSquare.getMapLocation(point); mapGrid.select(point, SelectionMode.ADD); } } finally { @@ -1384,7 +1384,7 @@ for (final MapSquare<G, A, R> mapSquare : selectedSquares) { for (int dy = -1; dy <= 1; dy++) { for (int dx = -1; dx <= 1; dx++) { - mapSquare.getLocation(point, dx, dy); + mapSquare.getMapLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { mapGrid.select(point, SelectionMode.ADD); } @@ -1428,7 +1428,7 @@ for (int dy = -1; dy <= 1; dy++) { for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { - mapSquare.getLocation(point, dx, dy); + mapSquare.getMapLocation(point, dx, dy); if (mapArchObject.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { mapSquaresToShrink.put(mapSquare, null); break LOOP; @@ -1438,7 +1438,7 @@ } } for (final MapSquare<G, A, R> mapSquare : mapSquaresToShrink.keySet()) { - mapSquare.getLocation(point); + mapSquare.getMapLocation(point); mapGrid.select(point, SelectionMode.SUB); } } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 09:34:41
|
Revision: 9049 http://gridarta.svn.sourceforge.net/gridarta/?rev=9049&view=rev Author: akirschbaum Date: 2011-10-16 09:34:34 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java trunk/model/src/app/net/sf/gridarta/model/io/AbstractGameObjectParser.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/SavedSquares.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java Modified: trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2011-10-16 08:05:59 UTC (rev 9048) +++ trunk/model/src/app/net/sf/gridarta/model/baseobject/AbstractBaseObject.java 2011-10-16 09:34:34 UTC (rev 9049) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.baseobject; +import java.awt.Point; import javax.swing.ImageIcon; import net.sf.gridarta.model.anim.AnimationObject; import net.sf.gridarta.model.anim.AnimationObjects; @@ -555,6 +556,14 @@ * {@inheritDoc} */ @Override + public Point getMapLocation() { + return new Point(mapX, mapY); + } + + /** + * {@inheritDoc} + */ + @Override public void setMapX(final int mapX) { this.mapX = mapX; } Modified: trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2011-10-16 08:05:59 UTC (rev 9048) +++ trunk/model/src/app/net/sf/gridarta/model/baseobject/BaseObject.java 2011-10-16 09:34:34 UTC (rev 9049) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.baseobject; +import java.awt.Point; import java.io.Serializable; import javax.swing.ImageIcon; import net.sf.gridarta.model.archetype.Archetype; @@ -362,6 +363,15 @@ int getMapY(); /** + * Returns the coordinate of this GameObject on its map. This method only + * guarantees a reasonable value for GameObjects that are directly bound to + * a map. Implementations may also return reasonable values for GameObjects + * inside containers, but they are not required to do so. + * @return the coordinate on map + */ + Point getMapLocation(); + + /** * Sets the X coordinate of this GameObject on its map. * @param mapX the x coordinate * @warning Only use this method during the load process. Modified: trunk/model/src/app/net/sf/gridarta/model/io/AbstractGameObjectParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2011-10-16 08:05:59 UTC (rev 9048) +++ trunk/model/src/app/net/sf/gridarta/model/io/AbstractGameObjectParser.java 2011-10-16 09:34:34 UTC (rev 9049) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.io; +import java.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.util.ArrayList; @@ -281,12 +282,11 @@ } // do insertion for all non-head parts of the multi - final int posX = gameObject.getMapX(); - final int posY = gameObject.getMapY(); + final Point pos = gameObject.getMapLocation(); for (R oldPart = archetype.getMultiNext(); oldPart != null; oldPart = oldPart.getMultiNext()) { final G tailGameObject = gameObjectFactory.createGameObjectPart(oldPart, gameObject); - tailGameObject.setMapX(posX + oldPart.getMultiX()); - tailGameObject.setMapY(posY + oldPart.getMultiY()); + tailGameObject.setMapX(pos.x + oldPart.getMultiX()); + tailGameObject.setMapY(pos.y + oldPart.getMultiY()); objects.add(tailGameObject); } } Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/SavedSquares.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/SavedSquares.java 2011-10-16 08:05:59 UTC (rev 9048) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/SavedSquares.java 2011-10-16 09:34:34 UTC (rev 9049) @@ -212,11 +212,10 @@ for (final Iterable<G> square : col) { if (square != null) { for (final GameObject<G, A, R> gameObject : square) { - final int mapX = gameObject.getMapX(); - final int mapY = gameObject.getMapY(); + final Point map = gameObject.getMapLocation(); for (G tailGameObject = gameObject.getMultiNext(); tailGameObject != null; tailGameObject = tailGameObject.getMultiNext()) { - point2.x = mapX + tailGameObject.getArchetype().getMultiX(); - point2.y = mapY + tailGameObject.getArchetype().getMultiY(); + point2.x = map.x + tailGameObject.getArchetype().getMultiX(); + point2.y = map.y + tailGameObject.getArchetype().getMultiY(); final GameObjectContainer<G, A, R> mapSquare = mapModel.getMapSquare(point2); mapSquare.addLast(tailGameObject); } Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-16 08:05:59 UTC (rev 9048) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-16 09:34:34 UTC (rev 9049) @@ -338,7 +338,7 @@ if (gameObjectIterator.hasNext()) { final G gameObject = gameObjectIterator.next(); final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); - setMapCursorLocation(new Point(topContainer.getMapX(), topContainer.getMapY())); + setMapCursorLocation(topContainer.getMapLocation()); selectedSquareView.setSelectedGameObject(gameObject); } else { final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.getMapSquares().iterator(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 08:06:06
|
Revision: 9048 http://gridarta.svn.sourceforge.net/gridarta/?rev=9048&view=rev Author: akirschbaum Date: 2011-10-16 08:05:59 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Whitespace changes. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/validation/errors/MapDifficultyError.java trunk/model/src/app/net/sf/gridarta/model/validation/errors/SquareValidationError.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Modified: trunk/model/src/app/net/sf/gridarta/model/validation/errors/MapDifficultyError.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/validation/errors/MapDifficultyError.java 2011-10-16 00:16:28 UTC (rev 9047) +++ trunk/model/src/app/net/sf/gridarta/model/validation/errors/MapDifficultyError.java 2011-10-16 08:05:59 UTC (rev 9048) @@ -64,7 +64,7 @@ */ @Override public String getParameter(final int id) { - switch(id){ + switch (id) { default: return null; } Modified: trunk/model/src/app/net/sf/gridarta/model/validation/errors/SquareValidationError.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/validation/errors/SquareValidationError.java 2011-10-16 00:16:28 UTC (rev 9047) +++ trunk/model/src/app/net/sf/gridarta/model/validation/errors/SquareValidationError.java 2011-10-16 08:05:59 UTC (rev 9048) @@ -50,7 +50,7 @@ */ @Override public String getParameter(final int id) { - switch(id){ + switch (id) { default: return null; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-16 00:16:28 UTC (rev 9047) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-16 08:05:59 UTC (rev 9048) @@ -88,7 +88,7 @@ @NotNull @Override public MapView<G, A, R> newMapView(@NotNull final MapControl<G, A, R> mapControl, @Nullable final Point viewPosition, final int viewCounter) { - final MapModel<G,A,R> mapModel = mapControl.getMapModel(); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); 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); Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-16 00:16:28 UTC (rev 9047) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-16 08:05:59 UTC (rev 9048) @@ -42,7 +42,7 @@ @NotNull @Override 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 MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); return new TestMapView(mapControl, mapGrid, new MapCursor(mapGrid)); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-16 00:16:28 UTC (rev 9047) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-16 08:05:59 UTC (rev 9048) @@ -62,7 +62,7 @@ */ @NotNull public static MapView<TestGameObject, TestMapArchObject, TestArchetype> newMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl) { - final MapModel<TestGameObject,TestMapArchObject,TestArchetype> mapModel = mapControl.getMapModel(); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); final MapGrid mapGrid = new MapGrid(mapModel.getMapArchObject().getMapSize()); return new TestMapView(mapControl, mapGrid, new MapCursor(mapGrid)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 00:16:35
|
Revision: 9047 http://gridarta.svn.sourceforge.net/gridarta/?rev=9047&view=rev Author: akirschbaum Date: 2011-10-16 00:16:28 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Whitespace change. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 00:13:05 UTC (rev 9046) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 00:16:28 UTC (rev 9047) @@ -209,7 +209,6 @@ /** {@inheritDoc} */ @Override public void mapCreated(@NotNull final MapControl<G, A, R> mapControl, final boolean interactive) { - final MapModel<G, A, R> mapModel = mapControl.getMapModel(); final MapModelListener<G, A, R> mapModelListener = new MapModelListener<G, A, R>() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 00:13:12
|
Revision: 9046 http://gridarta.svn.sourceforge.net/gridarta/?rev=9046&view=rev Author: akirschbaum Date: 2011-10-16 00:13:05 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Remove SelectedSquareView.getModelSize(). Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 00:10:47 UTC (rev 9045) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 00:13:05 UTC (rev 9046) @@ -493,7 +493,7 @@ * @return the selected list index */ public int getListIndex(@NotNull final MouseEvent e) { - final int lastIndex = getModelSize() - 1; + final int lastIndex = model.getSize() - 1; if (lastIndex < 0) { return 0; } @@ -542,7 +542,7 @@ */ @Nullable @SuppressWarnings("TypeMayBeWeakened") - G getListGameObject(final int index) { + private G getListGameObject(final int index) { final int actualIndex = getValidIndex(index); if (actualIndex >= model.getSize()) { return null; @@ -555,14 +555,6 @@ } /** - * Return the number of currently shown game objects. - * @return the number of currently shown game objects - */ - int getModelSize() { - return model.getSize(); - } - - /** * Set the selected game object. * @param gameObject the game object to select, or <code>null</code> to * deselect it @@ -598,8 +590,9 @@ if (index < 0) { return 0; } - if (index >= getModelSize()) { - return Math.max(0, getModelSize() - 1); + final int size = model.getSize(); + if (index >= size) { + return Math.max(0, size - 1); } return index; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-16 00:10:55
|
Revision: 9045 http://gridarta.svn.sourceforge.net/gridarta/?rev=9045&view=rev Author: akirschbaum Date: 2011-10-16 00:10:47 +0000 (Sun, 16 Oct 2011) Log Message: ----------- Remove SelectedSquareControl. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java Modified: trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2011-10-15 23:53:55 UTC (rev 9044) +++ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java 2011-10-16 00:10:47 UTC (rev 9045) @@ -28,8 +28,8 @@ import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; +import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; @@ -131,10 +131,10 @@ private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; /** - * The selected square control. + * The selected square view. */ @NotNull - private final SelectedSquareControl<G, A, R> selectedSquareControl; + private final SelectedSquareView<G, A, R> selectedSquareView; /** * The selected square model. @@ -208,12 +208,12 @@ * @param gameObjectAttributesDialogFactory the factory for creating game * object attributes dialog instances * @param mapViewManager the map view manager - * @param selectedSquareControl the selected square control + * @param selectedSquareView the selected square view * @param selectedSquareModel the selected square model */ - public MapCursorActions(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final SelectedSquareControl<G, A, R> selectedSquareControl, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel) { + public MapCursorActions(@NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final SelectedSquareView<G, A, R> selectedSquareView, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel) { this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; - this.selectedSquareControl = selectedSquareControl; + this.selectedSquareView = selectedSquareView; this.selectedSquareModel = selectedSquareModel; goLocationDialogManager = new GoLocationDialogManager<G, A, R>(mapViewManager); final String[] directionsGo = { "goNorth", "goEast", "goSouth", "goWest", "goNorthEast", "goSouthEast", "goSouthWest", "goNorthWest" }; @@ -584,7 +584,7 @@ } if (performAction) { - selectedSquareControl.insertGameObjectFromObjectChooser(mapView); + selectedSquareView.insertGameObjectFromObjectChooser(mapView); } return true; @@ -606,7 +606,7 @@ } if (performAction) { - selectedSquareControl.deleteSelection(mapView); + selectedSquareView.deleteSelection(mapView); } return true; @@ -624,7 +624,7 @@ } if (performAction) { - selectedSquareControl.selectArch(true); + selectedSquareView.selectArch(true); } return true; @@ -642,7 +642,7 @@ } if (performAction) { - selectedSquareControl.selectArch(false); + selectedSquareView.selectArch(false); } return true; Deleted: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java 2011-10-15 23:53:55 UTC (rev 9044) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java 2011-10-16 00:10:47 UTC (rev 9045) @@ -1,240 +0,0 @@ -/* - * 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.gui.panel.selectedsquare; - -import java.awt.event.InputEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory; -import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; -import net.sf.gridarta.model.archetype.Archetype; -import net.sf.gridarta.model.baseobject.BaseObject; -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.mapmodel.MapModel; -import net.sf.gridarta.model.mapmodel.MapSquare; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * The panel that displays the game objects of the currently selected map - * square. Currently it uses a list but in future it will use a tree instead. - * @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> - * @todo turn this into a tree - */ -public class SelectedSquareControl<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * The factory for creating game object attributes dialog instances. - */ - @NotNull - private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; - - /** - * The object chooser. - */ - @NotNull - private final ObjectChooser<G, A, R> objectChooser; - - /** - * The {@link SelectedSquareView} for this controller. - */ - @NotNull - private final SelectedSquareView<G, A, R> selectedSquareView; - - /** - * The {@link SelectedSquareModel} for this controller. - */ - @NotNull - private final SelectedSquareModel<G, A, R> selectedSquareModel; - - /** - * The {@link MouseListener} attached to the view to process mouse actions. - */ - @NotNull - private final MouseListener mouseListener = new MouseAdapter() { - - /** - * {@inheritDoc} - * @noinspection RefusedBequest - */ - @Override - public void mousePressed(final MouseEvent e) { - if (isSelect(e)) { - if (e.getClickCount() > 1) { // LMB Double click - final G gameObject = selectedSquareModel.getSelectedGameObject(); - if (gameObject != null) { - gameObjectAttributesDialogFactory.showAttributeDialog(gameObject); - } - } - } else if (isInsert(e)) { - insertGameObjectFromObjectChooser(selectedSquareView.getListIndex(e)); - } else if (isDelete(e)) { - deleteIndex(selectedSquareView.getListIndex(e)); - } - } - - }; - - /** - * Creates a new instance. - * @param selectedSquareModel the model for this controller - * @param gameObjectAttributesDialogFactory the factory for creating game - * object attributes dialog instances - * @param objectChooser the object chooser - * @param selectedSquareView the selected square view - */ - public SelectedSquareControl(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final SelectedSquareView<G, A, R> selectedSquareView) { - this.selectedSquareModel = selectedSquareModel; - this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; - this.objectChooser = objectChooser; - this.selectedSquareView = selectedSquareView; - selectedSquareView.addListMouseListener(mouseListener); - } - - /** - * Deletes the currently selected game object. - */ - public void deleteSelection(@NotNull final MapView<G, A, R> mapView) { - deleteIndex(mapView, selectedSquareView.getSelectedIndex()); - } - - /** - * Deletes a {@link GameObject} with a specific list index. - * @param index the list index of the game object to delete - */ - private void deleteIndex(final int index) { - final MapView<G, A, R> currentMapView = selectedSquareModel.getCurrentMapView(); - if (currentMapView != null) { - deleteIndex(currentMapView, index); - } - } - - private void deleteIndex(@NotNull final MapView<G, A, R> mapView, final int index) { - if (index < 0 || index >= selectedSquareView.getModelSize()) { - return; - } - - final G entry = selectedSquareView.getListGameObject(index); - if (entry == null) { - return; - } - - final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); - mapModel.beginTransaction("Delete"); // TODO; I18N/L10N - try { - mapModel.removeGameObject(entry, true); - } finally { - mapModel.endTransaction(); - } - - @Nullable final G selectedGameObject; - if (index < selectedSquareView.getModelSize()) { - selectedGameObject = selectedSquareView.getListGameObject(index); - } else if (selectedSquareView.getModelSize() > 0) { - selectedGameObject = selectedSquareView.getListGameObject(selectedSquareView.getModelSize() - 1); - } else { - selectedGameObject = null; - } - selectedSquareView.setSelectedGameObject(selectedGameObject); - } - - public void insertGameObjectFromObjectChooser(@NotNull final MapView<G, A, R> mapView) { - insertGameObjectFromObjectChooser(mapView, selectedSquareView.getSelectedIndex()); - } - - /** - * Inserts a new game object. - * @param index the list index to insert at - */ - private void insertGameObjectFromObjectChooser(final int index) { - final MapView<G, A, R> currentMapView = selectedSquareModel.getCurrentMapView(); - if (currentMapView != null) { - insertGameObjectFromObjectChooser(currentMapView, index); - } - } - - /** - * Inserts a new game object. - * @param mapView the map to insert into - * @param index the list index to insert at - */ - private void insertGameObjectFromObjectChooser(@NotNull final MapView<G, A, R> mapView, final int index) { - final BaseObject<G, A, R, ?> baseObject = objectChooser.getSelection(); - if (baseObject == null) { - return; - } - - final MapSquare<G, A, R> mapSquare = selectedSquareModel.getCurrentMapSquare(); - if (mapSquare == null) { - return; - } - - final G prevGameObject = index >= selectedSquareView.getModelSize() ? null : selectedSquareView.getListGameObject(index); - final MapControl<G, A, R> mapControl = mapView.getMapControl(); - final MapModel<G, A, R> mapModel = mapControl.getMapModel(); - mapModel.beginTransaction("Insert"); // TODO; I18N/L10N - try { - final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); - if (insertedGameObject != null) { - selectedSquareView.setSelectedGameObject(insertedGameObject); - } - } finally { - mapModel.endTransaction(); - } - } - - public void selectArch(final boolean above) { - selectedSquareView.setSelectedIndex(selectedSquareView.getSelectedIndex() + (above ? 1 : -1)); - } - - /** - * Determines if "select" was selected. - * @param e the mouse event to check for "select" - * @return <code>true</code> is "select" was selected - */ - private static boolean isSelect(@NotNull final InputEvent e) { - return (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0; - } - - /** - * Determines if "insert" was selected. - * @param e the mouse event to check for "insert" - * @return <code>true</code> is "insert" was selected - */ - private static boolean isInsert(@NotNull final InputEvent e) { - return (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == InputEvent.BUTTON3_MASK; - } - - /** - * Determines if "delete" was selected. - * @param e the mouse event to check for "delete" - * @return <code>true</code> is "delete" was selected - */ - private static boolean isDelete(@NotNull final InputEvent e) { - return (e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 || (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK); - } - -} // class SelectedSquareControl Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-15 23:53:55 UTC (rev 9044) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareView.java 2011-10-16 00:10:47 UTC (rev 9045) @@ -26,6 +26,8 @@ import java.awt.GridLayout; import java.awt.Insets; import java.awt.Point; +import java.awt.event.InputEvent; +import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.geom.RectangularShape; @@ -50,10 +52,13 @@ import javax.swing.ScrollPaneConstants; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import net.sf.gridarta.gui.dialog.gameobjectattributes.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; +import net.sf.gridarta.gui.panel.objectchooser.ObjectChooser; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.face.FaceObjectProviders; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.maparchobject.MapArchObject; @@ -115,6 +120,18 @@ private final ModelUpdater modelUpdater; /** + * The factory for creating game object attributes dialog instances. + */ + @NotNull + private final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory; + + /** + * The object chooser. + */ + @NotNull + private final ObjectChooser<G, A, R> objectChooser; + + /** * The {@link DefaultListModel} of {@link #list}. */ private final DefaultListModel model = new DefaultListModel(); @@ -362,9 +379,40 @@ }; /** + * The {@link MouseListener} attached to the view to process mouse actions. + */ + @NotNull + private final MouseListener mouseListener = new MouseAdapter() { + + /** + * {@inheritDoc} + * @noinspection RefusedBequest + */ + @Override + public void mousePressed(final MouseEvent e) { + if (isSelect(e)) { + if (e.getClickCount() > 1) { // LMB Double click + final G gameObject = selectedSquareModel.getSelectedGameObject(); + if (gameObject != null) { + gameObjectAttributesDialogFactory.showAttributeDialog(gameObject); + } + } + } else if (isInsert(e)) { + insertGameObjectFromObjectChooser(getListIndex(e)); + } else if (isDelete(e)) { + deleteIndex(getListIndex(e)); + } + } + + }; + + /** * Create a new instance. * @param selectedSquareModel the model for this view * @param selectedSquareActions the selected square actions to use + * @param gameObjectAttributesDialogFactory the factory for creating game + * object attributes dialog instances + * @param objectChooser the object chooser * @param mapManager the map manager to use * @param mapViewManager the map view manager to use * @param mapViewSettings the map view settings instance @@ -374,10 +422,12 @@ * faces * @param unknownSquareIcon the icon for unknown squares */ - public SelectedSquareView(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final SelectedSquareActions<G, A, R> selectedSquareActions, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapViewSettings mapViewSettings, @Nullable final ImageIcon compassIcon, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final Icon unknownSquareIcon) { + public SelectedSquareView(@NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final SelectedSquareActions<G, A, R> selectedSquareActions, @NotNull final GameObjectAttributesDialogFactory<G, A, R> gameObjectAttributesDialogFactory, @NotNull final ObjectChooser<G, A, R> objectChooser, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, @NotNull final MapViewSettings mapViewSettings, @Nullable final ImageIcon compassIcon, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final Icon unknownSquareIcon) { this.selectedSquareModel = selectedSquareModel; this.selectedSquareActions = selectedSquareActions; mapSquareSelectionCache = new MapSquareSelectionCache<G, A, R>(mapViewManager); + this.gameObjectAttributesDialogFactory = gameObjectAttributesDialogFactory; + this.objectChooser = objectChooser; setLayout(new BorderLayout()); @@ -409,6 +459,7 @@ add(compass, BorderLayout.NORTH); } list.addListSelectionListener(listSelectionListener); + list.addMouseListener(mouseListener); list.setFocusable(false); // XXX Workaround for Mantis #0000154 This is not clean and should be removed as soon as cut/copy/paste of arches is possible mapManager.addMapManagerListener(mapManagerListener); @@ -434,14 +485,6 @@ } /** - * Adds a mouse listener. - * @param mouseListener the mouse listener - */ - public void addListMouseListener(@NotNull final MouseListener mouseListener) { - list.addMouseListener(mouseListener); - } - - /** * Determine the list index for a given mouse event. This function differs * from <code>list.locationTopIndex(e.getPoint())</code> in that it always * returns a valid list index, or the list size (i.e., one element past the @@ -531,19 +574,11 @@ } /** - * Return the currently selected list index. - * @return the currently selected list index - */ - int getSelectedIndex() { - return list.getSelectedIndex(); - } - - /** * Set the currently selected list index. If an invalid index is given, the * nearest valid index is used instead. * @param index the index to select */ - void setSelectedIndex(final int index) { + private void setSelectedIndex(final int index) { final int actualIndex = getValidIndex(index); if (list.getSelectedIndex() != actualIndex) { list.setSelectedIndex(actualIndex); @@ -618,4 +653,127 @@ selectedSquareActions.doMoveSquareInv(true); } + /** + * Deletes the currently selected game object. + */ + public void deleteSelection(@NotNull final MapView<G, A, R> mapView) { + deleteIndex(mapView, list.getSelectedIndex()); + } + + /** + * Deletes a {@link GameObject} with a specific list index. + * @param index the list index of the game object to delete + */ + private void deleteIndex(final int index) { + final MapView<G, A, R> currentMapView = selectedSquareModel.getCurrentMapView(); + if (currentMapView != null) { + deleteIndex(currentMapView, index); + } + } + + private void deleteIndex(@NotNull final MapView<G, A, R> mapView, final int index) { + if (index < 0 || index >= model.getSize()) { + return; + } + + final G entry = getListGameObject(index); + if (entry == null) { + return; + } + + final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + mapModel.beginTransaction("Delete"); // TODO; I18N/L10N + try { + mapModel.removeGameObject(entry, true); + } finally { + mapModel.endTransaction(); + } + + @Nullable final G selectedGameObject; + if (index < model.getSize()) { + selectedGameObject = getListGameObject(index); + } else if (model.getSize() > 0) { + selectedGameObject = getListGameObject(model.getSize() - 1); + } else { + selectedGameObject = null; + } + setSelectedGameObject(selectedGameObject); + } + + public void insertGameObjectFromObjectChooser(@NotNull final MapView<G, A, R> mapView) { + insertGameObjectFromObjectChooser(mapView, list.getSelectedIndex()); + } + + /** + * Inserts a new game object. + * @param index the list index to insert at + */ + private void insertGameObjectFromObjectChooser(final int index) { + final MapView<G, A, R> currentMapView = selectedSquareModel.getCurrentMapView(); + if (currentMapView != null) { + insertGameObjectFromObjectChooser(currentMapView, index); + } + } + + /** + * Inserts a new game object. + * @param mapView the map to insert into + * @param index the list index to insert at + */ + private void insertGameObjectFromObjectChooser(@NotNull final MapView<G, A, R> mapView, final int index) { + final BaseObject<G, A, R, ?> baseObject = objectChooser.getSelection(); + if (baseObject == null) { + return; + } + + final MapSquare<G, A, R> mapSquare = selectedSquareModel.getCurrentMapSquare(); + if (mapSquare == null) { + return; + } + + final G prevGameObject = index >= model.getSize() ? null : getListGameObject(index); + final MapControl<G, A, R> mapControl = mapView.getMapControl(); + final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + mapModel.beginTransaction("Insert"); // TODO; I18N/L10N + try { + final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); + if (insertedGameObject != null) { + setSelectedGameObject(insertedGameObject); + } + } finally { + mapModel.endTransaction(); + } + } + + public void selectArch(final boolean above) { + setSelectedIndex(list.getSelectedIndex() + (above ? 1 : -1)); + } + + /** + * Determines if "select" was selected. + * @param e the mouse event to check for "select" + * @return <code>true</code> is "select" was selected + */ + private static boolean isSelect(@NotNull final InputEvent e) { + return (e.getModifiers() & InputEvent.BUTTON1_MASK) != 0; + } + + /** + * Determines if "insert" was selected. + * @param e the mouse event to check for "insert" + * @return <code>true</code> is "insert" was selected + */ + private static boolean isInsert(@NotNull final InputEvent e) { + return (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == InputEvent.BUTTON3_MASK; + } + + /** + * Determines if "delete" was selected. + * @param e the mouse event to check for "delete" + * @return <code>true</code> is "delete" was selected + */ + private static boolean isDelete(@NotNull final InputEvent e) { + return (e.getModifiers() & InputEvent.BUTTON2_MASK) != 0 || (e.getModifiers() & (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK)) == (InputEvent.BUTTON3_MASK | InputEvent.CTRL_MASK); + } + } // class SelectedSquareView Modified: trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2011-10-15 23:53:55 UTC (rev 9044) +++ trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java 2011-10-16 00:10:47 UTC (rev 9045) @@ -106,7 +106,6 @@ import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserControl; import net.sf.gridarta.gui.panel.pickmapchooser.PickmapChooserModel; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareActions; -import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareModel; import net.sf.gridarta.gui.panel.selectedsquare.SelectedSquareView; import net.sf.gridarta.gui.panel.tools.ToolPalette; @@ -467,8 +466,7 @@ newMapDialogFactory.setObjectChooser(objectChooser); final SelectedSquareModel<G, A, R> selectedSquareModel = new SelectedSquareModel<G, A, R>(); final SelectedSquareActions<G, A, R> selectedSquareActions = new SelectedSquareActions<G, A, R>(selectedSquareModel); - final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, selectedSquareActions, mapManager, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon); - final SelectedSquareControl<G, A, R> selectedSquareControl = new SelectedSquareControl<G, A, R>(selectedSquareModel, gameObjectAttributesDialogFactory, objectChooser, selectedSquareView); + final SelectedSquareView<G, A, R> selectedSquareView = new SelectedSquareView<G, A, R>(selectedSquareModel, selectedSquareActions, gameObjectAttributesDialogFactory, objectChooser, mapManager, mapViewManager, mapViewSettings, compassIcon, faceObjectProviders, unknownSquareIcon); final GameObjectMatcher floorMatcher = gameObjectMatchers.getMatcher("system_floor", "floor"); final GameObjectMatcher wallMatcher = gameObjectMatchers.getMatcher("system_wall", "wall"); final ErrorViewCollector gameObjectMatchersErrorViewCollector = new ErrorViewCollector(errorView, new File(globalSettings.getConfigurationDirectory(), "GameObjectMatchers.xml")); @@ -530,7 +528,7 @@ ActionUtils.newActions(ACTION_BUILDER, "Map Navigation", goExitDialogManager, "goExit"); ActionUtils.newActions(ACTION_BUILDER, "Tool", this, "cleanCompletelyBlockedSquares", "collectSpells", "controlClient", "controlServer", "gc", "options", "shortcuts", "zoom"); //noinspection ResultOfObjectAllocationIgnored - new MapCursorActions<G, A, R>(gameObjectAttributesDialogFactory, mapViewManager, selectedSquareControl, selectedSquareModel); + new MapCursorActions<G, A, R>(gameObjectAttributesDialogFactory, mapViewManager, selectedSquareView, selectedSquareModel); ActionUtils.newAction(ACTION_BUILDER, "Script", scriptEditControl, "newScript"); ActionUtils.newAction(ACTION_BUILDER, "Script", fileControl, "editScript"); ActionUtils.newActions(ACTION_BUILDER, "Map", fileControl, "openFile", "saveAllMaps"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:54:02
|
Revision: 9044 http://gridarta.svn.sourceforge.net/gridarta/?rev=9044&view=rev Author: akirschbaum Date: 2011-10-15 23:53:55 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Simplify code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-15 23:51:44 UTC (rev 9043) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-15 23:53:55 UTC (rev 9044) @@ -115,11 +115,7 @@ */ public boolean validateMapSquare() { final MapSquare<G, A, R> currentMapSquare = mapSquare; // copy for concurrency reasons - if (currentMapSquare == null) { - return false; - } - - return !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(currentMapSquare.getLocation()) && setMapSquare(null, null, 0); + return currentMapSquare != null && !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(currentMapSquare.getLocation()) && setMapSquare(null, null, 0); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:51:50
|
Revision: 9043 http://gridarta.svn.sourceforge.net/gridarta/?rev=9043&view=rev Author: akirschbaum Date: 2011-10-15 23:51:44 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Disable warning. Modified Paths: -------------- trunk/gridarta.ipr Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2011-10-15 23:50:03 UTC (rev 9042) +++ trunk/gridarta.ipr 2011-10-15 23:51:44 UTC (rev 9043) @@ -300,7 +300,6 @@ <inspection_tool class="AbstractMethodCallInConstructor" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="AbstractMethodOverridesAbstractMethod" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="AbstractMethodOverridesConcreteMethod" enabled="true" level="WARNING" enabled_by_default="true" /> - <inspection_tool class="AbstractMethodWithMissingImplementations" enabled="true" level="WARNING" enabled_by_default="true" /> <inspection_tool class="AccessToNonThreadSafeStaticFieldFromInstance" enabled="true" level="WARNING" enabled_by_default="true"> <option name="nonThreadSafeTypes" value="java.text.DateFormat,java.util.Calendar" /> </inspection_tool> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:50:10
|
Revision: 9042 http://gridarta.svn.sourceforge.net/gridarta/?rev=9042&view=rev Author: akirschbaum Date: 2011-10-15 23:50:03 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Merge duplicated code. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -228,8 +228,9 @@ if (mapViewSettings.isSmoothing()) { final MapArchObject mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); - for (point.x = mapSquare.getMapX() - 1; point.x <= mapSquare.getMapX() + 1; point.x++) { - for (point.y = mapSquare.getMapY() - 1; point.y <= mapSquare.getMapY() + 1; point.y++) { + for (int dx = -1; dx <= 1; dx++) { + for (int dy = -1; dy <= dy + 1; dy++) { + mapSquare.getLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { toRepaint.add(mapModel.getMapSquare(point)); } @@ -400,10 +401,9 @@ * @param square the square to paint */ private void paintSquare(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> square) { - final int x = square.getMapX(); - final int y = square.getMapY(); - updateSquare(new Point(x, y)); - repaint(0L, borderOffset.x + x * IGUIConstants.SQUARE_WIDTH, borderOffset.y + y * IGUIConstants.SQUARE_HEIGHT, IGUIConstants.SQUARE_WIDTH, IGUIConstants.SQUARE_HEIGHT); + final Point pos = square.getLocation(); + updateSquare(pos); + repaint(0L, borderOffset.x + pos.x * IGUIConstants.SQUARE_WIDTH, borderOffset.y + pos.y * IGUIConstants.SQUARE_HEIGHT, IGUIConstants.SQUARE_WIDTH, IGUIConstants.SQUARE_HEIGHT); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -312,12 +312,12 @@ if (filterControl.canShow(node) && mapViewSettings.isEditType(node)) { paintGameObject(g, x, y, node); if (node.getAttributeInt(GameObject.SMOOTHLEVEL, true) > 0) { - smoothingRenderer.paintSmooth(g, square.getMapX(), square.getMapY(), node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, borderOffsetX, borderOffsetY); + smoothingRenderer.paintSmooth(g, square.getLocation(), node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, borderOffsetX, borderOffsetY); } } } if (layer > -1) { - smoothingRenderer.paintSmooth(g, square.getMapX(), square.getMapY(), 1, layer + 1, true, borderOffsetX, borderOffsetY); + smoothingRenderer.paintSmooth(g, square.getLocation(), 1, layer + 1, true, borderOffsetX, borderOffsetY); } } else { for (final GameObject node : square) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -166,11 +166,11 @@ } graphics.drawImage(img.getImage(), point.x * IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT, point.x * IGUIConstants.SQUARE_WIDTH + IGUIConstants.SQUARE_WIDTH, point.y * IGUIConstants.SQUARE_HEIGHT + IGUIConstants.SQUARE_HEIGHT, offset.x, offset.y, offset.x + IGUIConstants.SQUARE_WIDTH, offset.y + IGUIConstants.SQUARE_HEIGHT, this); if (node.getAttributeInt(GameObject.SMOOTHLEVEL, true) > 0) { - smoothingRenderer.paintSmooth(graphics, point.x, point.y, node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, 0, 0); + smoothingRenderer.paintSmooth(graphics, point, node.getAttributeInt(GameObject.SMOOTHLEVEL, true), layer, false, 0, 0); } } if (layer > -1) { - smoothingRenderer.paintSmooth(graphics, point.x, point.y, 1, layer + 1, true, 0, 0); + smoothingRenderer.paintSmooth(graphics, point, 1, layer + 1, true, 0, 0); } } Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -103,8 +103,7 @@ * limit smoothlevel, at a given layer. This operation may be recursive, if * all layer above current are to be drawn too. * @param graphics where to draw (graphics) - * @param x the x-coordinate of the map square to draw, in map coordinates - * @param y the y-coordinate of the map square to draw, in map coordinates + * @param pos the coordinate of the map square to draw, in map coordinates * @param level the limit smoothlevel (smooth levels above this are drawn) * @param firstLayer the layer (map z coordinate) to draw; note that * invisible objects are supposed to not use a layer, to stay coherent with @@ -113,16 +112,16 @@ * @param borderOffsetX the border x offset * @param borderOffsetY the border y offset */ - public void paintSmooth(@NotNull final Graphics graphics, final int x, final int y, final int level, final int firstLayer, final boolean allLayers, final int borderOffsetX, final int borderOffsetY) { + public void paintSmooth(@NotNull final Graphics graphics, @NotNull final Point pos, final int level, final int firstLayer, final boolean allLayers, final int borderOffsetX, final int borderOffsetY) { int layer = firstLayer; while (true) { final MapArchObject mapArchObject = mapModel.getMapArchObject(); boolean foundLayer = false; final Point where = new Point(); for (int deltaX = -1; deltaX <= 1; deltaX++) { - where.x = x + deltaX; + where.x = pos.x + deltaX; for (int deltaY = -1; deltaY <= 1; deltaY++) { - where.y = y + deltaY; + where.y = pos.y + deltaY; //false warning: cannot annotate with @Nullable //noinspection AssignmentToNull layerNode[deltaX + 1][deltaY + 1] = null; @@ -211,10 +210,10 @@ */ final ImageIcon img = faceObjectProviders.getDisplayIcon(smoothFace); if (weight > 0) { - drawImage(graphics, x, y, borderOffsetX, borderOffsetY, IGUIConstants.SQUARE_WIDTH * weight, 0, img); + drawImage(graphics, pos, borderOffsetX, borderOffsetY, IGUIConstants.SQUARE_WIDTH * weight, 0, img); } if (weightC > 0) { - drawImage(graphics, x, y, borderOffsetX, borderOffsetY, IGUIConstants.SQUARE_WIDTH * weightC, IGUIConstants.SQUARE_HEIGHT, img); + drawImage(graphics, pos, borderOffsetX, borderOffsetY, IGUIConstants.SQUARE_WIDTH * weightC, IGUIConstants.SQUARE_HEIGHT, img); } } /*while there's some smooth to do*/ @@ -226,8 +225,8 @@ } } - private void drawImage(@NotNull final Graphics graphics, final int x, final int y, final int borderOffsetX, final int borderOffsetY, final int srcX, final int srcY, @NotNull final ImageIcon img) { - graphics.drawImage(img.getImage(), borderOffsetX + x * IGUIConstants.SQUARE_WIDTH, borderOffsetY + y * IGUIConstants.SQUARE_HEIGHT, borderOffsetX + x * IGUIConstants.SQUARE_WIDTH + IGUIConstants.SQUARE_WIDTH, borderOffsetY + y * IGUIConstants.SQUARE_HEIGHT + IGUIConstants.SQUARE_HEIGHT, srcX, srcY, srcX + IGUIConstants.SQUARE_WIDTH, srcY + IGUIConstants.SQUARE_HEIGHT, null); + private void drawImage(@NotNull final Graphics graphics, @NotNull final Point pos, final int borderOffsetX, final int borderOffsetY, final int srcX, final int srcY, @NotNull final ImageIcon img) { + graphics.drawImage(img.getImage(), borderOffsetX + pos.x * IGUIConstants.SQUARE_WIDTH, borderOffsetY + pos.y * IGUIConstants.SQUARE_HEIGHT, borderOffsetX + pos.x * IGUIConstants.SQUARE_WIDTH + IGUIConstants.SQUARE_WIDTH, borderOffsetY + pos.y * IGUIConstants.SQUARE_HEIGHT + IGUIConstants.SQUARE_HEIGHT, srcX, srcY, srcX + IGUIConstants.SQUARE_WIDTH, srcY + IGUIConstants.SQUARE_HEIGHT, null); } } // class SmoothingRenderer Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -92,7 +92,7 @@ continue; } } - mapModel.insertBaseObject(gameObject, new Point(mapSquare.getMapX(), mapSquare.getMapY()), false, false, insertionMode); + mapModel.insertBaseObject(gameObject, mapSquare.getLocation(), false, false, insertionMode); } } finally { mapModel.endTransaction(); @@ -112,9 +112,8 @@ private static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> boolean containsArchetype(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Collection<String> archetypeNames, @NotNull final MapSquare<G, A, R> topLeftMapSquare, final int w, final int h) { final Point pos = new Point(); for (int dy = -1; dy < h + 1; dy++) { - pos.y = topLeftMapSquare.getMapY() + dy; for (int dx = -1; dx < w + 1; dx++) { - pos.x = topLeftMapSquare.getMapX() + dx; + topLeftMapSquare.getLocation(pos, dx, dy); final MapSquare<G, A, R> mapSquare; try { mapSquare = mapModel.getMapSquare(pos); Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/DefaultMapModel.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -671,7 +671,7 @@ gameObject.remove(); if (join) { - autojoinLists.joinDelete(this, new Point(mapSquare.getMapX(), mapSquare.getMapY()), gameObject.getArchetype()); + autojoinLists.joinDelete(this, mapSquare.getLocation(), gameObject.getArchetype()); } } } Modified: trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/model/src/app/net/sf/gridarta/model/mapmodel/MapSquare.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.mapmodel; +import java.awt.Point; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; @@ -97,6 +98,35 @@ } /** + * Returns the coordinate on the map. + * @return the coordinate on the map + */ + @NotNull + public Point getLocation() { + return new Point(mapX, mapY); + } + + /** + * Returns the coordinate on the map. + * @param pos returns the coordinate on the map + */ + public void getLocation(@NotNull final Point pos) { + pos.x = mapX; + pos.y = mapY; + } + + /** + * Returns the coordinate with an offset on the map. + * @param pos returns the coordinate on the map + * @param dx the x offset to add to the coordinate + * @param dy the y offset to add to the coordinate + */ + public void getLocation(@NotNull final Point pos, final int dx, final int dy) { + pos.x = mapX + dx; + pos.y = mapY + dy; + } + + /** * {@inheritDoc} */ @Override Modified: trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/model/src/app/net/sf/gridarta/model/validation/checks/BlockedSpawnPointChecker.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -95,8 +95,7 @@ final Point pos = new Point(); for (final MapSquare<G, A, R> mapSquare : mapModel) { for (final G gameObject : mapSquare) { - pos.x = mapSquare.getMapX(); - pos.y = mapSquare.getMapY(); + mapSquare.getLocation(pos); checkSpawnPoint(gameObject, pos, blocked, errorCollector); for (final G invObject : gameObject.recursive()) { checkSpawnPoint(invObject, pos, blocked, errorCollector); Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -153,11 +153,11 @@ mapModel2.beginTransaction("Cut / Clear"); // TODO: I18N/L10N try { final Collection<G> gameObjectsToDelete = new HashSet<G>(); + final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapView.getSelectedSquares()) { - final int posX = square.getMapX() - selectedRec.x; - final int posY = square.getMapY() - selectedRec.y; + square.getLocation(pos, -selectedRec.x, -selectedRec.y); for (final G gameObject : square) { - copyMode.process(mapModel, gameObject, mapViewSettings.isEditType(gameObject), gameObjectsToDelete, posX, posY, gameObjectFactory, insertionModeSet); + copyMode.process(mapModel, gameObject, mapViewSettings.isEditType(gameObject), gameObjectsToDelete, pos, gameObjectFactory, insertionModeSet); } } @@ -184,7 +184,8 @@ try { final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapModel) { - pos.setLocation(startLocation.x + square.getMapX(), startLocation.y + square.getMapY()); + square.getLocation(pos); + pos.translate(startLocation.x, startLocation.y); if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (!gameObject.isMulti()) { @@ -195,8 +196,8 @@ } for (final MapSquare<G, A, R> square : mapModel) { - pos.setLocation(startLocation); - pos.translate(square.getMapX(), square.getMapY()); + square.getLocation(pos); + pos.translate(startLocation.x, startLocation.y); if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (gameObject.isMulti()) { Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -50,7 +50,7 @@ /** {@inheritDoc} */ @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, final int posX, final int posY, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, @NotNull final Point pos, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { if (isEditType) { gameObjectsToDelete.add(gameObject.getHead()); } @@ -71,11 +71,11 @@ /** {@inheritDoc} */ @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, final int posX, final int posY, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, @NotNull final Point pos, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { if (isEditType) { if (gameObject.isHead() && !gameObject.isInContainer()) { final G clone = gameObjectFactory.cloneGameObject(gameObject); - mapModel.addGameObjectToMap(clone, new Point(posX, posY), insertionModeSet.getTopmostInsertionMode()); + mapModel.addGameObjectToMap(clone, pos, insertionModeSet.getTopmostInsertionMode()); } if (gameObject.getArchetype().getMultiX() >= 0 && gameObject.getArchetype().getMultiY() >= 0) { gameObjectsToDelete.add(gameObject.getHead()); @@ -98,10 +98,10 @@ /** {@inheritDoc} */ @Override - public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, final int posX, final int posY, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { + public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, @NotNull final Point pos, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { if (isEditType && gameObject.isHead() && !gameObject.isInContainer()) { final G clone = gameObjectFactory.cloneGameObject(gameObject); - mapModel.addGameObjectToMap(clone, new Point(posX, posY), insertionModeSet.getTopmostInsertionMode()); + mapModel.addGameObjectToMap(clone, pos, insertionModeSet.getTopmostInsertionMode()); } } @@ -122,11 +122,10 @@ * @param isEditType whether the game object matches the active edit type * @param gameObjectsToDelete a collection for game objects to delete after * the operation has finished - * @param posX the current map x-position - * @param posY the current map y-position + * @param pos the current map position * @param gameObjectFactory the game object factory to use * @param insertionModeSet the insertion mode set to use */ - public abstract <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, final int posX, final int posY, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet); + public abstract <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void process(@NotNull final MapModel<G, A, R> mapModel, @NotNull final G gameObject, final boolean isEditType, @NotNull final Collection<G> gameObjectsToDelete, @NotNull final Point pos, @NotNull final GameObjectFactory<G, A, R> gameObjectFactory, @NotNull final InsertionModeSet<G, A, R> insertionModeSet); } // enum CopyMode Modified: trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/dialog/gameobjectattributes/GameObjectAttributesDialog.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -822,7 +822,7 @@ throw new IllegalArgumentException(); } mapModel = mapSquare.getMapModel(); - mapPos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); + mapPos = mapSquare.getLocation(); mapModel.addMapModelListener(mapModelListener); mapManager.addMapManagerListener(mapManagerListener); Modified: trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/dialog/replace/ReplaceDialog.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -22,7 +22,6 @@ import java.awt.Component; import java.awt.Container; import java.awt.FlowLayout; -import java.awt.Point; import java.awt.event.ItemEvent; import java.awt.event.ItemListener; import java.util.ArrayList; @@ -512,9 +511,9 @@ } // insert replacement object if (randomArch.isMulti()) { - mapModel.insertBaseObject(randomArch, new Point(square.getMapX(), square.getMapY()), false, false, insertionModeSet.getTopmostInsertionMode()); + mapModel.insertBaseObject(randomArch, square.getLocation(), false, false, insertionModeSet.getTopmostInsertionMode()); } else { - mapModel.insertArchToMap(randomArch, prevArch, new Point(square.getMapX(), square.getMapY()), false); + mapModel.insertArchToMap(randomArch, prevArch, square.getLocation(), false); } } replaceCount++; Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/ErrorListView.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -344,7 +344,7 @@ final Iterator<MapSquare<G, A, R>> mapSquareIterator = error.getMapSquares().iterator(); if (mapSquareIterator.hasNext()) { final MapSquare<G, A, R> mapSquare = mapSquareIterator.next(); - setMapCursorLocation(mapSquare == null ? null : new Point(mapSquare.getMapX(), mapSquare.getMapY())); + setMapCursorLocation(mapSquare == null ? null : mapSquare.getLocation()); } } errorMsg.setCaretPosition(0); Modified: trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/panel/gameobjectattributes/GameObjectAttributesControl.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -23,7 +23,6 @@ import java.awt.Component; import java.awt.Container; import java.awt.GridLayout; -import java.awt.Point; import java.io.File; import java.util.Collection; import java.util.HashSet; @@ -605,7 +604,7 @@ final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); mapModel.beginTransaction("Add to environment"); // TODO; I18N/L10N try { - final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, new Point(mapSquare.getMapX(), mapSquare.getMapY()), true); + final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); if (insertedGameObject != null) { mapModel.removeGameObject(prevGameObject, true); insertedGameObject.addLast(prevGameObject); Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/MapSquareSelection.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.panel.selectedsquare; -import java.awt.Point; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -120,7 +119,7 @@ return false; } - return !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY())) && setMapSquare(null, null, 0); + return !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(currentMapSquare.getLocation()) && setMapSquare(null, null, 0); } /** Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareActions.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -195,7 +195,7 @@ } final MapModel<G, A, R> mapModel = mapSquare.getMapModel(); - final Point pos = new Point(mapSquare.getMapX(), mapSquare.getMapY()); + final Point pos = mapSquare.getLocation(); if (!envGameObject.isInContainer() && gameObject.getArchetype().isMulti() && !mapModel.isMultiArchFittingToMap(gameObject.getArchetype(), pos, true)) { return false; } Modified: trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/gui/panel/selectedsquare/SelectedSquareControl.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -19,7 +19,6 @@ package net.sf.gridarta.gui.panel.selectedsquare; -import java.awt.Point; import java.awt.event.InputEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; @@ -198,7 +197,7 @@ final MapModel<G, A, R> mapModel = mapControl.getMapModel(); mapModel.beginTransaction("Insert"); // TODO; I18N/L10N try { - final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, new Point(mapSquare.getMapX(), mapSquare.getMapY()), true); + final G insertedGameObject = mapModel.insertArchToMap(baseObject, prevGameObject, mapSquare.getLocation(), true); if (insertedGameObject != null) { selectedSquareView.setSelectedGameObject(insertedGameObject); } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 23:21:40 UTC (rev 9041) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 23:50:03 UTC (rev 9042) @@ -1326,10 +1326,9 @@ final Map<MapSquare<G, A, R>, Void> tmp = new IdentityHashMap<MapSquare<G, A, R>, Void>(); for (final MapSquare<G, A, R> mapSquare : todo.keySet()) { for (int dy = -1; dy <= 1; dy++) { - point.y = mapSquare.getMapY() + dy; for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { - point.x = mapSquare.getMapX() + dx; + mapSquare.getLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { final MapSquare<G, A, R> newMapSquare = mapModel.getMapSquare(point); if (newMapSquare.isEmpty() && !newSelection.containsKey(newMapSquare)) { @@ -1348,8 +1347,7 @@ try { mapGrid.unSelect(); for (final MapSquare<G, A, R> mapSquare : newSelection.keySet()) { - point.x = mapSquare.getMapX(); - point.y = mapSquare.getMapY(); + mapSquare.getLocation(point); mapGrid.select(point, SelectionMode.ADD); } } finally { @@ -1385,9 +1383,8 @@ try { for (final MapSquare<G, A, R> mapSquare : selectedSquares) { for (int dy = -1; dy <= 1; dy++) { - point.y = mapSquare.getMapY() + dy; for (int dx = -1; dx <= 1; dx++) { - point.x = mapSquare.getMapX() + dx; + mapSquare.getLocation(point, dx, dy); if (mapArchObject.isPointValid(point)) { mapGrid.select(point, SelectionMode.ADD); } @@ -1429,10 +1426,9 @@ for (final MapSquare<G, A, R> mapSquare : selectedSquares) { LOOP: for (int dy = -1; dy <= 1; dy++) { - point.y = mapSquare.getMapY() + dy; for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { - point.x = mapSquare.getMapX() + dx; + mapSquare.getLocation(point, dx, dy); if (mapArchObject.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { mapSquaresToShrink.put(mapSquare, null); break LOOP; @@ -1442,8 +1438,7 @@ } } for (final MapSquare<G, A, R> mapSquare : mapSquaresToShrink.keySet()) { - point.x = mapSquare.getMapX(); - point.y = mapSquare.getMapY(); + mapSquare.getLocation(point); mapGrid.select(point, SelectionMode.SUB); } } finally { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:21:47
|
Revision: 9041 http://gridarta.svn.sourceforge.net/gridarta/?rev=9041&view=rev Author: akirschbaum Date: 2011-10-15 23:21:40 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Fix compiler warning. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2011-10-15 23:18:59 UTC (rev 9040) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2011-10-15 23:21:40 UTC (rev 9041) @@ -219,7 +219,7 @@ public void setText(@NotNull final String text, final boolean keepRA) { textField.setText(text); if (keepRA) { - raSwitch.actionPerformed(null); + raSwitch.actionPerformed(null, false); } else { raSwitch.updateRAState(); } @@ -288,13 +288,17 @@ * {@inheritDoc} */ @Override - public void actionPerformed(@Nullable final ActionEvent e) { + public void actionPerformed(@NotNull final ActionEvent e) { + actionPerformed(e, true); + } + + public void actionPerformed(@Nullable final ActionEvent e, final boolean toggleRelative) { final String path = TilePanel.this.getText(); final File tmpRelativeReference = relativeReference; if (path.isEmpty() || tmpRelativeReference == null) { return; } - if (e != null) { + if (toggleRelative) { isRelative = !isRelative; updateText(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:19:05
|
Revision: 9040 http://gridarta.svn.sourceforge.net/gridarta/?rev=9040&view=rev Author: akirschbaum Date: 2011-10-15 23:18:59 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Fix incorrect check for empty input field. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2011-10-15 23:17:29 UTC (rev 9039) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/TilePanel.java 2011-10-15 23:18:59 UTC (rev 9040) @@ -291,7 +291,7 @@ public void actionPerformed(@Nullable final ActionEvent e) { final String path = TilePanel.this.getText(); final File tmpRelativeReference = relativeReference; - if (path == null || tmpRelativeReference == null) { + if (path.isEmpty() || tmpRelativeReference == null) { return; } if (e != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 23:17:35
|
Revision: 9039 http://gridarta.svn.sourceforge.net/gridarta/?rev=9039&view=rev Author: akirschbaum Date: 2011-10-15 23:17:29 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove unneeded code. Modified Paths: -------------- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 22:05:22 UTC (rev 9038) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 23:17:29 UTC (rev 9039) @@ -20,8 +20,6 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Component; -import java.util.Collections; -import java.util.List; import javax.swing.JInternalFrame; import javax.swing.JScrollPane; import net.sf.gridarta.gui.map.renderer.MapRenderer; @@ -32,7 +30,6 @@ import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapgrid.MapGrid; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; /** * A {@link MapView} implementation for regression tests. @@ -67,26 +64,8 @@ /** * {@inheritDoc} */ - @Nullable - @Override - public TestGameObject getSelectedGameObject() { - return null; - } - - /** - * {@inheritDoc} - */ @NotNull @Override - public List<TestGameObject> getSelectedGameObjects() { - return Collections.emptyList(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public String getWindowTitle() { return "title"; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 22:05:29
|
Revision: 9038 http://gridarta.svn.sourceforge.net/gridarta/?rev=9038&view=rev Author: akirschbaum Date: 2011-10-15 22:05:22 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Split MapGrid.select() into select() and selectArea(). Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java trunk/model/src/test/net/sf/gridarta/model/mapgrid/MapGridTest.java trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java Modified: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -283,7 +283,7 @@ mapGrid.beginTransaction(); try { dragRelease(); - mapGrid.select(dragStart, pos, selectionMode); + mapGrid.selectArea(dragStart, pos, selectionMode); } finally { mapGrid.endTransaction(); } Modified: trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/model/src/app/net/sf/gridarta/model/mapgrid/MapGrid.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -33,11 +33,11 @@ * errors. This class provides methods to modify these flags. Normally a map * cursor is used to access them. Selection flags are not changed directly. * First pre-selection flags have to be set with {@link #preSelect(Point, - * Point)}, then {@link #select(Point, Point, SelectionMode)} will change the - * selection flags according to {@link SelectionMode}. This allows visualisation - * of the dragging process when selecting an area. <p/> Every change of the grid - * size or flags fires a {@link MapGridEvent} and informs all registered {@link - * MapGridListener MapGridListeners}. + * Point)}, then {@link #selectArea(Point, Point, SelectionMode)} will change + * the selection flags according to {@link SelectionMode}. This allows + * visualisation of the dragging process when selecting an area. <p/> Every + * change of the grid size or flags fires a {@link MapGridEvent} and informs all + * registered {@link MapGridListener MapGridListeners}. * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> * @author Andreas Kirschbaum */ @@ -394,16 +394,24 @@ } /** - * All squares in the rectangle defined by dragStart and pos that are - * preselected get selected. - * @param dragStart the first corner of rectangle - * @param pos the opposite corner of rectangle - * @param selectionMode the method how to handle already selected squares + * Selects or deselects a single square. + * @param pos the square + * @param selectionMode the selection mode */ - public void select(@NotNull final Point dragStart, @NotNull final Point pos, @NotNull final SelectionMode selectionMode) { + public void select(@NotNull final Point pos, @NotNull final SelectionMode selectionMode) { + selectArea(pos, pos, selectionMode); + } + + /** + * Selects or deselects all squares in an area. + * @param pos1 the first corner of rectangle + * @param pos2 the opposite corner of rectangle + * @param selectionMode the selection mode + */ + public void selectArea(@NotNull final Point pos1, @NotNull final Point pos2, @NotNull final SelectionMode selectionMode) { beginTransaction(); try { - calculateRec(dragStart, pos); + calculateRec(pos1, pos2); switch (selectionMode) { case ADD: setFlags(cornerMin.x, cornerMin.y, cornerMax.x, cornerMax.y, GRID_FLAG_SELECTION); Modified: trunk/model/src/test/net/sf/gridarta/model/mapgrid/MapGridTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapgrid/MapGridTest.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/model/src/test/net/sf/gridarta/model/mapgrid/MapGridTest.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -38,28 +38,28 @@ final MapGrid mapGrid = new MapGrid(new Size2D(4, 3)); checkSelectionBorder(mapGrid, "0000" + "0000" + "0000"); - mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); + mapGrid.select(new Point(1, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0f00" + "0000"); - mapGrid.select(new Point(2, 1), new Point(2, 1), SelectionMode.ADD); + mapGrid.select(new Point(2, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); - mapGrid.select(new Point(3, 1), new Point(3, 1), SelectionMode.ADD); + mapGrid.select(new Point(3, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0d57" + "0000"); - mapGrid.select(new Point(3, 1), new Point(3, 1), SelectionMode.SUB); + mapGrid.select(new Point(3, 1), SelectionMode.SUB); checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); - mapGrid.select(new Point(0, 0), new Point(3, 2), SelectionMode.FLIP); + mapGrid.selectArea(new Point(0, 0), new Point(3, 2), SelectionMode.FLIP); checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); - mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.FLIP); + mapGrid.select(new Point(1, 1), SelectionMode.FLIP); checkSelectionBorder(mapGrid, "9153" + "820a" + "c456"); - mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.SUB); + mapGrid.select(new Point(1, 1), SelectionMode.SUB); checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); - mapGrid.select(new Point(0, 0), new Point(3, 2), SelectionMode.ADD); + mapGrid.selectArea(new Point(0, 0), new Point(3, 2), SelectionMode.ADD); checkSelectionBorder(mapGrid, "9113" + "8002" + "c446"); mapGrid.resize(new Size2D(2, 1)); @@ -68,7 +68,7 @@ mapGrid.resize(new Size2D(3, 4)); checkSelectionBorder(mapGrid, "d700" + "0000" + "0000"); - mapGrid.select(new Point(0, 0), new Point(2, 3), SelectionMode.ADD); + mapGrid.selectArea(new Point(0, 0), new Point(2, 3), SelectionMode.ADD); checkSelectionBorder(mapGrid, "913" + "802" + "802" + "c46"); mapGrid.resize(new Size2D(4, 3)); Modified: trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -282,7 +282,7 @@ assert mapGrid != null; final boolean thisSelection = (mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0; assert mapGrid != null; - mapGrid.select(prevPos, prevPos, thisSelection ? SelectionMode.ADD : SelectionMode.SUB); + mapGrid.select(prevPos, thisSelection ? SelectionMode.ADD : SelectionMode.SUB); gameObjectsToInsert.clear(); if (thisSelection) { if (isStart) { @@ -331,7 +331,7 @@ } assert startGameObjects.isEmpty(); assert mapGrid != null; - mapGrid.select(prevPos, prevPos, startSelection ? SelectionMode.ADD : SelectionMode.SUB); + mapGrid.select(prevPos, startSelection ? SelectionMode.ADD : SelectionMode.SUB); } /** Modified: trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/src/app/net/sf/gridarta/gui/panel/connectionview/Control.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -115,7 +115,7 @@ for (final GameObject<?, ?, ?> object : connection) { final BaseObject<?, ?, ?, ?> topObject = object.getTopContainer(); point.setLocation(topObject.getMapX(), topObject.getMapY()); - mapGrid.select(point, point, SelectionMode.ADD); + mapGrid.select(point, SelectionMode.ADD); } } } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -1350,7 +1350,7 @@ for (final MapSquare<G, A, R> mapSquare : newSelection.keySet()) { point.x = mapSquare.getMapX(); point.y = mapSquare.getMapY(); - mapGrid.select(point, point, SelectionMode.ADD); + mapGrid.select(point, SelectionMode.ADD); } } finally { mapGrid.endTransaction(); @@ -1389,7 +1389,7 @@ for (int dx = -1; dx <= 1; dx++) { point.x = mapSquare.getMapX() + dx; if (mapArchObject.isPointValid(point)) { - mapGrid.select(point, point, SelectionMode.ADD); + mapGrid.select(point, SelectionMode.ADD); } } } @@ -1444,7 +1444,7 @@ for (final MapSquare<G, A, R> mapSquare : mapSquaresToShrink.keySet()) { point.x = mapSquare.getMapX(); point.y = mapSquare.getMapY(); - mapGrid.select(point, point, SelectionMode.SUB); + mapGrid.select(point, SelectionMode.SUB); } } finally { mapGrid.endTransaction(); Modified: trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2011-10-15 21:57:17 UTC (rev 9037) +++ trunk/src/test/net/sf/gridarta/gui/copybuffer/CopyBufferTest.java 2011-10-15 22:05:22 UTC (rev 9038) @@ -77,7 +77,7 @@ // select + cut final CopyBuffer<TestGameObject, TestMapArchObject, TestArchetype> copyBuffer = TestMapControlCreatorUtils.newCopyBuffer(testMapControlCreator); final MapView<TestGameObject, TestMapArchObject, TestArchetype> mapView = TestMapControlCreatorUtils.newMapView(mapControl); - mapView.getMapGrid().select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); + mapView.getMapGrid().select(new Point(1, 1), SelectionMode.ADD); copyBuffer.cut(mapView, new Rectangle(1, 1, 1, 1)); TestMapModelHelper.checkMapContents(mapModel, "||", "||", "||"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:57:24
|
Revision: 9037 http://gridarta.svn.sourceforge.net/gridarta/?rev=9037&view=rev Author: akirschbaum Date: 2011-10-15 21:57:17 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Declare variables more local. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 21:54:59 UTC (rev 9036) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2011-10-15 21:57:17 UTC (rev 9037) @@ -1313,7 +1313,6 @@ } if (performAction) { - final MapGrid mapGrid = mapView.getMapGrid(); final Map<MapSquare<G, A, R>, Void> newSelection = new IdentityHashMap<MapSquare<G, A, R>, Void>(); Map<MapSquare<G, A, R>, Void> todo = new IdentityHashMap<MapSquare<G, A, R>, Void>(); for (final MapSquare<G, A, R> mapSquare : selectedSquares) { @@ -1344,6 +1343,7 @@ } todo = tmp; } + final MapGrid mapGrid = mapView.getMapGrid(); mapGrid.beginTransaction(); try { mapGrid.unSelect(); @@ -1377,10 +1377,10 @@ } if (performAction) { - final MapGrid mapGrid = mapView.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); + final MapGrid mapGrid = mapView.getMapGrid(); mapGrid.beginTransaction(); try { for (final MapSquare<G, A, R> mapSquare : selectedSquares) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2011-10-15 21:55:07
|
Revision: 9036 http://gridarta.svn.sourceforge.net/gridarta/?rev=9036&view=rev Author: akirschbaum Date: 2011-10-15 21:54:59 +0000 (Sat, 15 Oct 2011) Log Message: ----------- Remove MapViewBasic. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/EnterMap.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -156,7 +156,7 @@ if (destinationPoint != null) { showLocation(newMapView, destinationPoint); } else if (mapView != null) { - newMapView.getMapViewBasic().getScrollPane().getViewport().setViewPosition(calculateNewViewPosition(mapView.getMapViewBasic().getScrollPane(), newMapView.getMapViewBasic().getScrollPane(), direction)); + newMapView.getScrollPane().getViewport().setViewPosition(calculateNewViewPosition(mapView.getScrollPane(), newMapView.getScrollPane(), direction)); } if (mapView != null && ACTION_BUILDER.showOnetimeConfirmDialog(parent, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, "enterExitClose") == JOptionPane.YES_OPTION) { Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -794,7 +794,7 @@ } if (performAction) { - mapViewsManager.newMapView(mapView.getMapControl(), mapView.getMapViewBasic().getScrollPane().getViewport().getViewPosition(), null); + mapViewsManager.newMapView(mapView.getMapControl(), mapView.getScrollPane().getViewport().getViewPosition(), null); } return true; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapView.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -21,10 +21,12 @@ import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Point; import java.beans.PropertyVetoException; import java.io.File; import java.util.Set; import javax.swing.JInternalFrame; +import javax.swing.JScrollPane; import javax.swing.WindowConstants; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.MapRenderer; @@ -78,12 +80,6 @@ private final int number; /** - * The underlying map view object. - */ - @NotNull - private final MapViewBasic<G, A, R> mapViewBasic; - - /** * The {@link PathManager} for converting path names. */ @NotNull @@ -191,28 +187,30 @@ * Create a new instance. * @param mapControl the controller of this view * @param number each view of a map will get a number - * @param mapViewBasic the underlying map view object * @param pathManager the path manager for converting path names * @param mapGrid the map grid for this map view * @param mapCursor the map cursor for this map view * @param renderer the map renderer for rendering the map model + * @param viewPosition the initial view position to show; null=show top left + * corner + * @param xScrollDistance the x distance when scrolling + * @param yScrollDistance the y distance when scrolling */ - public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final MapViewBasic<G, A, R> mapViewBasic, @NotNull final PathManager pathManager, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor, final AbstractMapRenderer<G, A, R> renderer) { + public DefaultMapView(@NotNull final MapControl<G, A, R> mapControl, final int number, @NotNull final PathManager pathManager, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor, final AbstractMapRenderer<G, A, R> renderer, @Nullable final Point viewPosition, final int xScrollDistance, final int yScrollDistance) { super(mapControl.getMapModel(), mapGrid, mapCursor); internalFrame = new JInternalFrame(getWindowTitle(mapControl, number, pathManager), true, true, true, true); this.mapControl = mapControl; this.number = number; - this.mapViewBasic = mapViewBasic; this.pathManager = pathManager; this.renderer = renderer; final MapModel<G, A, R> mapModel = mapControl.getMapModel(); erroneousMapSquares = new ErroneousMapSquares<G, A, R>(mapModel, mapGrid, renderer); - mapCursorTracker = new MapCursorTracker<G, A, R>(mapCursor, renderer); + mapCursorTracker = new MapCursorTracker<G, A, R>(mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, mapCursor, renderer); mapModel.addMapModelListener(mapModelListener); mapModel.getMapArchObject().addMapArchObjectListener(mapArchObjectListener); mapControl.addMapControlListener(mapControlListener); internalFrame.getContentPane().setLayout(new BorderLayout()); - internalFrame.getContentPane().add(mapViewBasic.getScrollPane(), BorderLayout.CENTER); + internalFrame.getContentPane().add(mapCursorTracker.getScrollPane(), BorderLayout.CENTER); internalFrame.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); internalFrame.setAutoscrolls(true); } @@ -222,8 +220,7 @@ */ @Override public void closeNotify() { - internalFrame.getContentPane().remove(mapViewBasic.getScrollPane()); - mapViewBasic.closeNotify(); + internalFrame.getContentPane().remove(mapCursorTracker.getScrollPane()); mapCursorTracker.closeNotify(); erroneousMapSquares.closeNotify(); renderer.closeNotify(); @@ -285,16 +282,7 @@ /** * {@inheritDoc} */ - @NotNull @Override - public MapViewBasic<G, A, R> getMapViewBasic() { - return mapViewBasic; - } - - /** - * {@inheritDoc} - */ - @Override public void activate() { try { internalFrame.setSelected(true); @@ -324,4 +312,13 @@ return renderer; } + /** + * {@inheritDoc} + */ + @NotNull + @Override + public JScrollPane getScrollPane() { + return mapCursorTracker.getScrollPane(); + } + } // class MapView Deleted: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewBasic.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -1,90 +0,0 @@ -/* - * 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.gui.map.mapview; - -import java.awt.Component; -import java.awt.Point; -import javax.swing.JScrollPane; -import javax.swing.JViewport; -import javax.swing.ScrollPaneConstants; -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.utils.CommonConstants; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * Default {@link MapViewBasic} implementation. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public class DefaultMapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements MapViewBasic<G, A, R> { - - /** - * The {@link JScrollPane} for this instance. - */ - @NotNull - private final JScrollPane scrollPane; - - /** - * Creates a new instance. - * @param isPickmap whether the map model belongs to a pickmap - * @param initial the initial view position to show; null=show top left - * corner - * @param xScrollDistance the x distance when scrolling - * @param yScrollDistance the y distance when scrolling - * @param renderer the map renderer for rendering the map model - */ - public DefaultMapViewBasic(final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final Component renderer) { - scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - if (isPickmap) { - scrollPane.setBackground(CommonConstants.BG_COLOR); - } - - // set the pixel increment scrolling for clicking once on a scroll bar arrow - scrollPane.getVerticalScrollBar().setUnitIncrement(yScrollDistance); - scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance); - scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); - scrollPane.setViewportView(renderer); - if (initial != null) { - scrollPane.getViewport().setViewPosition(initial); - } - scrollPane.setFocusable(true); - } - - /** - * {@inheritDoc} - */ - @Override - public void closeNotify() { - scrollPane.setViewportView(null); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public JScrollPane getScrollPane() { - return scrollPane; - } - -} // class DefaultMapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/DefaultMapViewFactory.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -92,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, new DefaultMapViewBasic<G, A, R>(mapControl.isPickmap(), viewPosition, xScrollDistance, yScrollDistance, renderer), pathManager, mapGrid, new MapCursor(mapGrid), renderer); + final MapView<G, A, R> mapView = new DefaultMapView<G, A, R>(mapControl, viewCounter, pathManager, mapGrid, new MapCursor(mapGrid), renderer, viewPosition, xScrollDistance, yScrollDistance); mapView.getInternalFrame().setJMenuBar(ACTION_BUILDER.createMenuBar(false, "mapwindow")); return mapView; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapCursorTracker.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -20,6 +20,9 @@ package net.sf.gridarta.gui.map.mapview; import java.awt.Point; +import javax.swing.JScrollPane; +import javax.swing.JViewport; +import javax.swing.ScrollPaneConstants; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -27,7 +30,9 @@ import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapcursor.MapCursorEvent; import net.sf.gridarta.model.mapcursor.MapCursorListener; +import net.sf.gridarta.utils.CommonConstants; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Tracks the {@link MapCursor} of map and scrolls the {@link @@ -50,6 +55,12 @@ private final AbstractMapRenderer<G, A, R> renderer; /** + * The {@link JScrollPane} for this instance. + */ + @NotNull + private final JScrollPane scrollPane; + + /** * The {@link MapCursorListener} attached to {@link #mapCursor}. */ @NotNull @@ -71,13 +82,32 @@ /** * Creates a new instance. + * @param isPickmap whether the map model belongs to a pickmap + * @param viewPosition the initial view position to show; null=show top left + * corner + * @param xScrollDistance the x distance when scrolling + * @param yScrollDistance the y distance when scrolling * @param mapCursor the map cursor to track * @param renderer the map renderer to update */ - public MapCursorTracker(@NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { + public MapCursorTracker(final boolean isPickmap, @Nullable final Point viewPosition, final int xScrollDistance, final int yScrollDistance, @NotNull final MapCursor mapCursor, @NotNull final AbstractMapRenderer<G, A, R> renderer) { this.mapCursor = mapCursor; this.renderer = renderer; this.mapCursor.addMapCursorListener(mapCursorListener); + scrollPane = new JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + if (isPickmap) { + scrollPane.setBackground(CommonConstants.BG_COLOR); + } + + // set the pixel increment scrolling for clicking once on a scroll bar arrow + scrollPane.getVerticalScrollBar().setUnitIncrement(yScrollDistance); + scrollPane.getHorizontalScrollBar().setUnitIncrement(xScrollDistance); + scrollPane.getViewport().setScrollMode(JViewport.SIMPLE_SCROLL_MODE); + scrollPane.setViewportView(renderer); + if (viewPosition != null) { + scrollPane.getViewport().setViewPosition(viewPosition); + } + scrollPane.setFocusable(true); ensureVisibleMapCursor(); } @@ -86,6 +116,7 @@ * all listeners. */ public void closeNotify() { + scrollPane.setViewportView(null); mapCursor.removeMapCursorListener(mapCursorListener); } @@ -99,4 +130,13 @@ } } + /** + * Returns the {@link JScrollPane} of the renderer. + * @return the scroll pane + */ + @NotNull + public JScrollPane getScrollPane() { + return scrollPane; + } + } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -22,6 +22,7 @@ import java.awt.Component; import java.util.List; import javax.swing.JInternalFrame; +import javax.swing.JScrollPane; import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -86,13 +87,6 @@ MapControl<G, A, R> getMapControl(); /** - * Return the associated {@link MapViewBasic}. - * @return the associated <code>MapViewBasic</code> - */ - @NotNull - MapViewBasic<G, A, R> getMapViewBasic(); - - /** * Activate this map view. */ void activate(); @@ -132,4 +126,11 @@ @NotNull MapRenderer getRenderer(); + /** + * Returns the {@link JScrollPane} of this map view. + * @return the scroll pane + */ + @NotNull + JScrollPane getScrollPane(); + } // interface MapView Deleted: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -1,48 +0,0 @@ -/* - * 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.gui.map.mapview; - -import javax.swing.JScrollPane; -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; - -/** - * MapViewBasic is a view for maps. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @author Andreas Kirschbaum - */ -public interface MapViewBasic<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> { - - /** - * Must be called when this renderer is not used anymore. It un-registers - * all listeners. - */ - void closeNotify(); - - /** - * Returns the {@link JScrollPane} of this map view basic. - * @return the scroll pane - */ - @NotNull - JScrollPane getScrollPane(); - -} // interface MapViewBasic Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViews.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -116,7 +116,7 @@ } if (viewPosition == null && centerSquare != null) { final Rectangle squareBounds = mapView.getRenderer().getSquareBounds(centerSquare); - final JScrollPane scrollPane = mapView.getMapViewBasic().getScrollPane(); + final JScrollPane scrollPane = mapView.getScrollPane(); final Dimension extentSize = scrollPane.getViewport().getExtentSize(); final Point centerPoint = new Point(Math.max(0, squareBounds.x + squareBounds.width / 2 - extentSize.width / 2), Math.max(0, squareBounds.y + squareBounds.height / 2 - extentSize.height / 2)); scrollPane.getViewport().setViewPosition(centerPoint); @@ -135,7 +135,7 @@ public Point[] getViewPositions() { final Point[] result = new Point[mapViews.size()]; for (int i = 0; i < result.length; i++) { - result[i] = mapViews.get(i).getMapViewBasic().getScrollPane().getViewport().getViewPosition(); + result[i] = mapViews.get(i).getScrollPane().getViewport().getViewPosition(); } return result; } Modified: trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/mapfiles/MapFile.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.regex.Pattern; import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; @@ -154,19 +153,6 @@ } /** - * Returns the {@link MapViewBasic} instance for this pickmap. Returns - * <code>null</code> unless {@link #loadPickmap()} was successfully called. - * @return the <code>MapViewBasic</code> instance, or <code>null if the map - * file has not been loaded - */ - @Nullable - public MapViewBasic<G, A, R> getMapViewBasic() { - synchronized (sync) { - return pickmapView == null ? null : pickmapView.getMapViewBasic(); - } - } - - /** * Returns the {@link MapView} instance for this pickmap. Returns * <code>null</code> unless {@link #loadPickmap()} was successfully called. * @return the <code>MapView</code> instance, or <code>null if the map file Modified: trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/app/net/sf/gridarta/gui/panel/pickmapchooser/PickmapChooserView.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -26,7 +26,7 @@ import javax.swing.JTabbedPane; import javax.swing.SwingConstants; import javax.swing.event.ChangeListener; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; +import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.mapfiles.MapFile; import net.sf.gridarta.gui.mapfiles.MapFolder; import net.sf.gridarta.gui.mapfiles.MapFolderListener; @@ -211,8 +211,8 @@ } final int index = pickmapChooserModel.addMapFile(mapFile); - final MapViewBasic<G, A, R> mapViewBasic = mapFile.getMapViewBasic(); - pickmapPanel.insertTab(getTitle(mapFile), null, mapViewBasic == null ? null : mapViewBasic.getScrollPane(), null, index); + final MapView<G, A, R> mapView = mapFile.getMapView(); + pickmapPanel.insertTab(getTitle(mapFile), null, mapView == null ? null : mapView.getScrollPane(), null, index); } /** @@ -237,8 +237,8 @@ return; } pickmapPanel.setTitleAt(index, getTitle(mapFile)); - final MapViewBasic<G, A, R> mapViewBasic = mapFile.getMapViewBasic(); - pickmapPanel.setComponentAt(index, mapViewBasic == null ? null : mapViewBasic.getScrollPane()); + final MapView<G, A, R> mapView = mapFile.getMapView(); + pickmapPanel.setComponentAt(index, mapView == null ? null : mapView.getScrollPane()); } /** Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapView.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -23,6 +23,7 @@ import java.util.Collections; import java.util.List; import javax.swing.JInternalFrame; +import javax.swing.JScrollPane; import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; @@ -46,22 +47,14 @@ private final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl; /** - * The underlying map view object. - */ - @NotNull - private final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic; - - /** * Creates a new instance. * @param mapControl the controller of this view - * @param mapViewBasic the underlying map view object * @param mapGrid the map grid for this map view * @param mapCursor the map cursor for this map view */ - public TestMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { + public TestMapView(@NotNull final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl, @NotNull final MapGrid mapGrid, @NotNull final MapCursor mapCursor) { super(mapControl.getMapModel(), mapGrid, mapCursor); this.mapControl = mapControl; - this.mapViewBasic = mapViewBasic; } /** @@ -119,17 +112,17 @@ /** * {@inheritDoc} */ - @NotNull @Override - public MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> getMapViewBasic() { - return mapViewBasic; + public void activate() { } /** * {@inheritDoc} */ + @NotNull @Override - public void activate() { + public JInternalFrame getInternalFrame() { + throw new AssertionError(); } /** @@ -137,7 +130,7 @@ */ @NotNull @Override - public JInternalFrame getInternalFrame() { + public MapRenderer getRenderer() { throw new AssertionError(); } @@ -146,7 +139,7 @@ */ @NotNull @Override - public MapRenderer getRenderer() { + public JScrollPane getScrollPane() { throw new AssertionError(); } Deleted: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewBasic.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -1,50 +0,0 @@ -/* - * 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.gui.map.mapview; - -import javax.swing.JScrollPane; -import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.maparchobject.TestMapArchObject; -import org.jetbrains.annotations.NotNull; - -/** - * A {@link MapViewBasic} implementation for regression tests. - * @author Andreas Kirschbaum - */ -public class TestMapViewBasic implements MapViewBasic<TestGameObject,TestMapArchObject,TestArchetype> { - - /** - * {@inheritDoc} - */ - @Override - public void closeNotify() { - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public JScrollPane getScrollPane() { - throw new AssertionError(); - } - -} // class TestMapViewBasic Modified: trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/test/net/sf/gridarta/gui/map/mapview/TestMapViewFactory.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -44,8 +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()); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(); - return new TestMapView(mapControl, mapViewBasic, mapGrid, new MapCursor(mapGrid)); + return new TestMapView(mapControl, mapGrid, new MapCursor(mapGrid)); } } // class TestMapViewFactory Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 21:41:26 UTC (rev 9035) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreatorUtils.java 2011-10-15 21:54:59 UTC (rev 9036) @@ -23,11 +23,9 @@ import java.awt.image.BufferedImage; import net.sf.gridarta.gui.copybuffer.CopyBuffer; import net.sf.gridarta.gui.map.mapview.MapView; -import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewFactory; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.map.mapview.TestMapView; -import net.sf.gridarta.gui.map.mapview.TestMapViewBasic; import net.sf.gridarta.gui.map.mapview.TestMapViewFactory; import net.sf.gridarta.gui.map.renderer.RendererFactory; import net.sf.gridarta.gui.map.renderer.TestRendererFactory; @@ -66,8 +64,7 @@ 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()); - final MapViewBasic<TestGameObject, TestMapArchObject, TestArchetype> mapViewBasic = new TestMapViewBasic(); - return new TestMapView(mapControl, mapViewBasic, mapGrid, new MapCursor(mapGrid)); + return new TestMapView(mapControl, mapGrid, new MapCursor(mapGrid)); } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |