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...> - 2010-06-09 11:02:44
|
Revision: 8310 http://gridarta.svn.sourceforge.net/gridarta/?rev=8310&view=rev Author: akirschbaum Date: 2010-06-09 11:02:33 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Fix warning on console about missing icon. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/action.properties Modified: trunk/src/app/net/sf/gridarta/action.properties =================================================================== --- trunk/src/app/net/sf/gridarta/action.properties 2010-06-09 11:00:38 UTC (rev 8309) +++ trunk/src/app/net/sf/gridarta/action.properties 2010-06-09 11:02:33 UTC (rev 8310) @@ -91,7 +91,7 @@ pickmapFolders.menu= editPlugins.icon=EditPluginSmallIcon -runPlugin.icon=RunPluginSmallIcon +runPlugin.icon=run_plugin_small_icon savePlugins.icon=SaveMapAsSmallIcon importPlugin.icon=ImportPluginSmallIcon This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 11:00:50
|
Revision: 8309 http://gridarta.svn.sourceforge.net/gridarta/?rev=8309&view=rev Author: akirschbaum Date: 2010-06-09 11:00:38 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.isPointValid(). 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/SmoothingRenderer.java trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java trunk/src/app/net/sf/gridarta/gui/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 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -225,10 +225,11 @@ */ private void getSquaresToRepaint(@NotNull final MapSquare<GameObject, MapArchObject, Archetype> mapSquare, @NotNull final Collection<MapSquare<GameObject, MapArchObject, Archetype>> toRepaint) { 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++) { - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { toRepaint.add(mapModel.getMapSquare(point)); } } 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 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/FlatMapRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -166,7 +166,7 @@ */ @Override protected void updateSquare(@NotNull final Point point) { - if (!mapModel.isPointValid(point)) { + if (!mapModel.getMapArchObject().isPointValid(point)) { return; } 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 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SmoothingRenderer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -86,11 +86,12 @@ */ public void paintSmooth(@NotNull final Graphics graphics, final int x, final int y, final int level, final int layer, final boolean allLayers, @NotNull final Point borderOffset) { final net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[][] layerNode = { new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3], new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3], new net.sf.gridarta.model.gameobject.GameObject<?, ?, ?>[3] }; + final MapArchObject mapArchObject = mapModel.getMapArchObject(); boolean foundLayer = false; for (int deltaX = -1; deltaX <= 1; deltaX++) { for (int deltaY = -1; deltaY <= 1; deltaY++) { final Point where = new Point(x + deltaX, y + deltaY); - if (mapModel.isPointValid(where)) { + if (mapArchObject.isPointValid(where)) { int currentLayer = -1; for (final net.sf.gridarta.model.gameobject.GameObject<GameObject, MapArchObject, Archetype> node : mapModel.getMapSquare(where)) { if (node.getAttributeInt("invisible", true) == 0) { Modified: trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/autojoin/AutojoinLists.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -113,7 +113,7 @@ } private int joinInsert(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir, final int reverseDir) { - if (!mapModel.isPointValid(new Point(point.x + dx, point.y + dy))) { + if (!mapModel.getMapArchObject().isPointValid(new Point(point.x + dx, point.y + dy))) { return 0; } @@ -156,7 +156,7 @@ } private void joinDelete(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point point, @NotNull final AutojoinList<G, A, R> autojoinList, final int dx, final int dy, final int dir) { - if (!mapModel.isPointValid(new Point(point.x + dx, point.y + dy))) { + if (!mapModel.getMapArchObject().isPointValid(new Point(point.x + dx, point.y + dy))) { return; } Modified: trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/exitconnector/ExitMatcher.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -59,7 +59,7 @@ */ @Nullable public G getValidExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { + if (point == null || !mapModel.getMapArchObject().isPointValid(point)) { return null; } for (final GameObject<G, A, R> part : mapModel.getMapSquare(point)) { @@ -99,7 +99,7 @@ */ @Nullable public BaseObject<G, A, R, ?> getExit(@NotNull final MapModel<G, A, R> mapModel, @Nullable final Point point) { - if (point == null || !mapModel.isPointValid(point)) { + if (point == null || !mapModel.getMapArchObject().isPointValid(point)) { return null; } for (final GameObject<G, A, R> part : mapModel.getMapSquare(point)) { Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FillUtils.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -86,7 +86,7 @@ return; } - if (!mapModel.isPointValid(start) || !mapModel.getMapSquare(start).isEmpty()) { + if (!mapModel.getMapArchObject().isPointValid(start) || !mapModel.getMapSquare(start).isEmpty()) { return; } Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -71,7 +71,8 @@ * @param insertionModeSet the insertion mode set to use */ public void floodFill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point start, @NotNull final List<? extends BaseObject<G, A, R, ?>> archList, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { - final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + final Size2D mapSize = mapArchObject.getMapSize(); final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[start.x][start.y] = BORDER; mapModel.beginTransaction("Flood Fill"); // TODO: I18N/L10N @@ -83,7 +84,7 @@ for (p.y = 0; p.y < mapSize.getHeight(); p.y++) { if (area[p.x][p.y] == BORDER) { border--; - if (mapModel.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { + if (mapArchObject.isPointValid(p) && mapModel.getMapSquare(p).isEmpty()) { area[p.x][p.y] = WAS_EMPTY; final BaseObject<G, A, R, ?> gameObject = archList.get(RandomUtils.rnd.nextInt(archList.size())); mapModel.insertBaseObject(gameObject, p, false, false, insertionModeSet.getTopmostInsertionMode()); Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -301,14 +301,6 @@ } /** - * {@inheritDoc} - */ - @Override - public boolean isPointValid(@Nullable final Point pos) { - return mapArchObject.isPointValid(pos); - } - - /** * Resizes the map grid after the map size has changed. * @param newSize the new map size */ @@ -680,7 +672,7 @@ final Point point = new Point(part.getMultiX(), part.getMultiY()); point.translate(pos.x, pos.y); // outside map - if (!isPointValid(point)) { + if (!mapArchObject.isPointValid(point)) { return false; } @@ -725,7 +717,7 @@ @Override public G insertArchToMap(@NotNull final BaseObject<G, A, R, ?> templateGameObject, @Nullable final G nextGameObject, @NotNull final Point pos, final boolean join) { // map coords must be valid - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { return null; } @@ -767,7 +759,7 @@ @Nullable @Override public G insertBaseObject(@NotNull final BaseObject<G, A, R, ?> baseObject, @NotNull final Point pos, final boolean allowMany, final boolean join, @NotNull final InsertionMode<G, A, R> insertionMode) { - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { return null; } @@ -826,7 +818,7 @@ */ @Override public void addGameObjectToMap(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final InsertionMode<G, A, R> insertionMode) { - if (!isPointValid(pos)) { + if (!mapArchObject.isPointValid(pos)) { log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapArchObject.getMapSize()); return; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -85,16 +85,6 @@ boolean isEmpty(); /** - * Check whether the given coordinate is within map bounds. - * @param pos the coordinates to check - * @return <code>true</code> if the given coordinates are on the map, - * otherwise <code>false</code> (also returns <code>false</code> if - * <code><var>pos</var> == null</code>) - */ - @Deprecated - boolean isPointValid(@Nullable Point pos); - - /** * Returns the Map Arch Object with the meta information about the map. * @return the Map Arch Object with the meta information about the map */ Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -179,12 +179,13 @@ */ public void paste(@NotNull final MapView<G, A, R> mapView, @NotNull final Point startLocation) { final MapModel<G, A, R> mapModel2 = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel2.getMapArchObject(); mapModel2.beginTransaction("Paste"); // TODO: I18N/L10N try { final Point pos = new Point(); for (final MapSquare<G, A, R> square : mapModel) { pos.setLocation(startLocation.x + square.getMapX(), startLocation.y + square.getMapY()); - if (mapModel2.isPointValid(pos)) { + if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (!gameObject.isMulti()) { mapModel2.insertBaseObject(gameObject, pos, true, false, insertionModeSet.getTopmostInsertionMode()); @@ -196,7 +197,7 @@ for (final MapSquare<G, A, R> square : mapModel) { pos.setLocation(startLocation); pos.translate(square.getMapX(), square.getMapY()); - if (mapModel2.isPointValid(pos)) { + if (mapArchObject.isPointValid(pos)) { for (final BaseObject<G, A, R, ?> gameObject : square) { if (gameObject.isMulti()) { mapModel2.insertBaseObject(gameObject, pos, true, false, insertionModeSet.getTopmostInsertionMode()); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -753,7 +753,7 @@ */ private void showLocation(@NotNull final MapView<G, A, R> mapView, @NotNull final Point point) { final Point point2 = point.x == -1 && point.y == -1 ? mapView.getMapControl().getMapModel().getMapArchObject().getEnter() : point; - if (!mapView.getMapControl().getMapModel().isPointValid(point2)) { + if (!mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(point2)) { ACTION_BUILDER.showMessageDialog(parent, "enterExitOutside"); return; } Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -183,6 +183,7 @@ } final MapModel<G, A, R> mapModel = mapControl.getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("Insert Object"); try { @Nullable final G insertedObject; @@ -196,7 +197,7 @@ for (R part = head.getArchetype(); part != null; part = part.getMultiNext()) { point.x = p.x + part.getMultiX(); point.y = p.y + part.getMultiY(); - if (!mapModel.isPointValid(point) || !mapModel.getMapSquare(point).isEmpty()) { + if (!mapArchObject.isPointValid(point) || !mapModel.getMapSquare(point).isEmpty()) { return; } } Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/MapSquareSelection.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -119,7 +119,7 @@ return false; } - return !mapView.getMapControl().getMapModel().isPointValid(new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY())) && setMapSquare(null, null, 0); + return !mapView.getMapControl().getMapModel().getMapArchObject().isPointValid(new Point(currentMapSquare.getMapX(), currentMapSquare.getMapY())) && setMapSquare(null, null, 0); } /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -289,7 +289,7 @@ final MapControl<G, A, R> mapControl = mapView.getMapControl(); final Point cursorPos = e.getSource().getLocation(); - if (cursorPos == null || !mapControl.getMapModel().isPointValid(cursorPos)) { + if (cursorPos == null || !mapControl.getMapModel().getMapArchObject().isPointValid(cursorPos)) { if (selectedSquareModel.setSelectedMapSquare(null, null, 0)) { refresh(); } Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:53:11 UTC (rev 8308) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 11:00:38 UTC (rev 8309) @@ -1300,6 +1300,7 @@ newSelection.put(mapSquare, null); } final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); while (!todo.isEmpty()) { final Map<MapSquare<G, A, R>, Void> tmp = new IdentityHashMap<MapSquare<G, A, R>, Void>(); @@ -1309,7 +1310,7 @@ for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { final MapSquare<G, A, R> newMapSquare = mapModel.getMapSquare(point); if (newMapSquare.isEmpty() && !newSelection.containsKey(newMapSquare)) { tmp.put(newMapSquare, null); @@ -1358,6 +1359,7 @@ if (performAction) { final MapGrid mapGrid = mapViewBasic.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); mapGrid.beginTransaction(); try { @@ -1366,7 +1368,7 @@ point.y = mapSquare.getMapY() + dy; for (int dx = -1; dx <= 1; dx++) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point)) { + if (mapArchObject.isPointValid(point)) { mapGrid.select(point, point, SelectionMode.ADD); } } @@ -1400,6 +1402,7 @@ if (performAction) { final MapGrid mapGrid = mapViewBasic.getMapGrid(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); + final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); final Point point = new Point(); final Map<MapSquare<G, A, R>, Void> mapSquaresToShrink = new IdentityHashMap<MapSquare<G, A, R>, Void>(); mapGrid.beginTransaction(); @@ -1411,7 +1414,7 @@ for (int dx = -1; dx <= 1; dx++) { if (dx != 0 || dy != 0) { point.x = mapSquare.getMapX() + dx; - if (mapModel.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { + if (mapArchObject.isPointValid(point) && (mapGrid.getFlags(point) & MapGrid.GRID_FLAG_SELECTION) == 0) { mapSquaresToShrink.put(mapSquare, null); break LOOP; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:53:23
|
Revision: 8308 http://gridarta.svn.sourceforge.net/gridarta/?rev=8308&view=rev Author: akirschbaum Date: 2010-06-09 10:53:11 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.resizeMap(). Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java trunk/src/app/net/sf/gridarta/actions/UndoActions.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -655,7 +655,7 @@ final MapArchObject mapArchObject = mapModel.getMapArchObject(); mapArchObject.beginTransaction(); try { - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setMapName(mapName.getText()); mapArchObject.setRegion(mapRegion.getText()); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -701,7 +701,7 @@ mapArchObject.beginTransaction(); try { final String mapNameString = mapName.getText(); - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setLore(mapLore.getText()); mapArchObject.setMapName(mapNameString); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -646,7 +646,7 @@ final MapArchObject mapArchObject = mapModel.getMapArchObject(); mapArchObject.beginTransaction(); try { - mapModel.resizeMap(mapSize); + mapArchObject.setMapSize(mapSize); mapArchObject.setText(mapDescription.getText()); mapArchObject.setMapName(mapName.getText()); mapArchObject.setBackgroundMusic(mapBackgroundMusic.getText()); Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -309,14 +309,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void resizeMap(@NotNull final Size2D newSize) { - mapArchObject.setMapSize(newSize); - } - - /** * Resizes the map grid after the map size has changed. * @param newSize the new map size */ Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -28,7 +28,6 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -86,15 +85,6 @@ boolean isEmpty(); /** - * Resize this map to the new size. If any bounds are smaller than before, - * the map gets cut on the right and bottom side. Accordingly, new space is - * attached to right and bottom. - * @param newSize new map size - */ - @Deprecated - void resizeMap(@NotNull Size2D newSize); - - /** * Check whether the given coordinate is within map bounds. * @param pos the coordinates to check * @return <code>true</code> if the given coordinates are on the map, Modified: trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -186,57 +186,61 @@ } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); Assert.assertEquals("", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap3() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); result.setLength(0); mapModel.beginTransaction("TEST"); addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); - mapModel.resizeMap(new Size2D(1, 2)); // cancels square changed event + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } /** - * Test case for {@link DefaultMapModel#resizeMap(Size2D)}. + * Test case for {@link + * net.sf.gridarta.model.map.maparchobject.MapArchObject#setMapSize(Size2D)}. */ @Test public void testResizeMap4() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -246,7 +250,7 @@ gameObject.setAttributeString("key", "value"); } addGameObjectToMap(mapModel, "1", 2, 2, insertionModeSet.getAutoInsertionMode()); - mapModel.resizeMap(new Size2D(1, 2)); // cancels square changed event + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); // cancels square changed event mapModel.endTransaction(); Assert.assertEquals("mapSizeChanged:\n" + "no squares\n" + "no game objects\n", result.toString()); } @@ -258,7 +262,7 @@ @Test public void testAddGameObjectToMap1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); @@ -275,7 +279,7 @@ @Test public void testAddGameObjectToMap2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); mapModel.endTransaction(); result.setLength(0); @@ -293,7 +297,7 @@ @Test public void testModifiedGameObject1() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -312,7 +316,7 @@ @Test public void testModifiedGameObject2() { mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(4, 3)); + mapModel.getMapArchObject().setMapSize(new Size2D(4, 3)); addGameObjectToMap(mapModel, "1", 1, 2, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); @@ -340,7 +344,7 @@ archetype.addTailPart(archetype2); mapModel.beginTransaction("TEST"); - mapModel.resizeMap(new Size2D(1, 2)); + mapModel.getMapArchObject().setMapSize(new Size2D(1, 2)); final TestGameObject gameObject = mapModel.insertBaseObject(archetype, new Point(0, 0), true, false, insertionModeSet.getAutoInsertionMode()); mapModel.endTransaction(); Modified: trunk/src/app/net/sf/gridarta/actions/UndoActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/actions/UndoActions.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/actions/UndoActions.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -50,8 +50,8 @@ mapModel.beginTransaction(undoState.getName()); try { final A newMapArchObject = undoState.getMapArchObject(); - mapModel.resizeMap(newMapArchObject.getMapSize()); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.setMapSize(newMapArchObject.getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(newMapArchObject); @@ -78,8 +78,8 @@ mapModel.beginTransaction(undoState.getName()); try { final A newMapArchObject = undoState.getMapArchObject(); - mapModel.resizeMap(newMapArchObject.getMapSize()); final MapArchObject<A> mapArchObject = mapModel.getMapArchObject(); + mapArchObject.setMapSize(newMapArchObject.getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(newMapArchObject); Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyMode.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -67,7 +67,7 @@ /** {@inheritDoc} */ @Override public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void prepare(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D mapSize) { - mapModel.resizeMap(mapSize); + mapModel.getMapArchObject().setMapSize(mapSize); mapModel.clearMap(); } @@ -95,7 +95,7 @@ /** {@inheritDoc} */ @Override public <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> void prepare(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D mapSize) { - mapModel.resizeMap(mapSize); + mapModel.getMapArchObject().setMapSize(mapSize); mapModel.clearMap(); } Modified: trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -66,7 +66,7 @@ } mapModel.beginTransaction("Shrink Map Size"); try { - mapModel.resizeMap(new Size2D(filledWidth, filledHeight)); + mapModel.getMapArchObject().setMapSize(new Size2D(filledWidth, filledHeight)); } finally { mapModel.endTransaction(); } Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -351,7 +351,7 @@ final A mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("revert"); try { - mapModel.resizeMap(decoder.getMapArchObject().getMapSize()); + mapArchObject.setMapSize(decoder.getMapArchObject().getMapSize()); mapArchObject.beginTransaction(); try { mapArchObject.setState(decoder.getMapArchObject()); Modified: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:43:47 UTC (rev 8307) +++ trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:53:11 UTC (rev 8308) @@ -65,7 +65,7 @@ mapModel.beginTransaction("test"); try { - mapModel.resizeMap(newSize); + mapModel.getMapArchObject().setMapSize(newSize); } finally { mapModel.endTransaction(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:43:58
|
Revision: 8307 http://gridarta.svn.sourceforge.net/gridarta/?rev=8307&view=rev Author: akirschbaum Date: 2010-06-09 10:43:47 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Rename variable. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java Modified: trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:43:14 UTC (rev 8306) +++ trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:43:47 UTC (rev 8307) @@ -72,7 +72,7 @@ public boolean isBlocked(final int x, final int y) { try { return blocked[x][y]; - } catch (final IndexOutOfBoundsException ex) { + } catch (final IndexOutOfBoundsException ignored) { return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:43:24
|
Revision: 8306 http://gridarta.svn.sourceforge.net/gridarta/?rev=8306&view=rev Author: akirschbaum Date: 2010-06-09 10:43:14 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Suppress warnings. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:43:14 UTC (rev 8306) @@ -761,6 +761,7 @@ r = Integer.parseInt(s); // trying to parse } catch (final NumberFormatException ignored) { // 's' is not a number + //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new IllegalArgumentException(label + ": '" + s + "' is not a numerical integer value."); } @@ -790,6 +791,7 @@ r = Double.parseDouble(s); // trying to parse } catch (final NumberFormatException ignored) { // 's' is not a number + //noinspection ThrowInsideCatchBlockWhichIgnoresCaughtException throw new IllegalArgumentException(label + ": '" + s + "' is not a numerical double value."); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:42:25
|
Revision: 8305 http://gridarta.svn.sourceforge.net/gridarta/?rev=8305&view=rev Author: akirschbaum Date: 2010-06-09 10:42:13 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove MapModel.getMapSize(). Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 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/SimpleFlatMapRenderer.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -467,14 +467,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapSize().getWidth()); + mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapSize().getHeight()); + mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); 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 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -321,7 +321,7 @@ this.mapViewSettings = mapViewSettings; this.mapModel = mapModel; this.gridMapSquarePainter = gridMapSquarePainter; - mapSize = this.mapModel.getMapSize(); + mapSize = this.mapModel.getMapArchObject().getMapSize(); this.mapGrid = mapGrid; mapViewSettings.addMapViewSettingsListener(mapViewSettingsListener); 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 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -102,7 +102,7 @@ @NotNull @Override public BufferedImage getFullImage() { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int viewWidth = mapSize.getWidth() * IGUIConstants.SQUARE_WIDTH; final int viewHeight = mapSize.getHeight() * IGUIConstants.SQUARE_HEIGHT; final BufferedImage image = new BufferedImage(viewWidth, viewHeight, BufferedImage.TYPE_INT_ARGB); @@ -123,7 +123,7 @@ */ @Override protected void paintComponent(@NotNull final Graphics g) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); g.setColor(Color.white); g.fillRect(0, 0, mapSize.getWidth() * IGUIConstants.SQUARE_WIDTH, mapSize.getHeight() * IGUIConstants.SQUARE_HEIGHT); final Point point = new Point(); Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -430,7 +430,7 @@ @NotNull private Component createMapPanel(@NotNull final MapArchObject map) { final Container panel = new JPanel(new GridBagLayout()); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); addInputFieldLine(panel, mapName, 16, map.getMapName(), "mapName"); addInputFieldLine(panel, mapRegion, 16, map.getRegion(), "mapRegion"); addInputFieldLine(panel, mapWidthField, 10, String.valueOf(mapSize.getWidth()), "mapWidth"); Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/gui/mappropertiesdialog/MapPropertiesDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -459,14 +459,14 @@ mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapWidth")), labelGbc); mapWidthField.setColumns(5); - mapWidthField.setValue(mapModel.getMapSize().getWidth()); + mapWidthField.setValue(mapModel.getMapArchObject().getMapSize().getWidth()); gbc.gridwidth = 1; gbc.weightx = 1.0; mapPanel.add(mapWidthField, gbc); mapPanel.add(new JLabel(ACTION_BUILDER.getString("mapHeight")), labelGbc); mapHeightField.setColumns(5); - mapHeightField.setValue(mapModel.getMapSize().getHeight()); + mapHeightField.setValue(mapModel.getMapArchObject().getMapSize().getHeight()); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.weightx = 1.0; mapPanel.add(mapHeightField, gbc); Modified: trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/floodfill/FloodFill.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -71,7 +71,7 @@ * @param insertionModeSet the insertion mode set to use */ public void floodFill(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Point start, @NotNull final List<? extends BaseObject<G, A, R, ?>> archList, @NotNull final InsertionModeSet<G, A, R> insertionModeSet) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final byte[][] area = new byte[mapSize.getWidth()][mapSize.getHeight()]; area[start.x][start.y] = BORDER; mapModel.beginTransaction("Flood Fill"); // TODO: I18N/L10N Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -258,16 +258,7 @@ /** * {@inheritDoc} */ - @NotNull @Override - public Size2D getMapSize() { - return mapArchObject.getMapSize(); - } - - /** - * {@inheritDoc} - */ - @Override public Iterator<MapSquare<G, A, R>> iterator() { return new MapSquareIterator<G, A, R>(this); } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -73,14 +73,6 @@ void mapClosed(); /** - * Return the map size of this map. - * @return map size of this map - */ - @Deprecated - @NotNull - Size2D getMapSize(); - - /** * Clears this map completely. After invoking this method, no objects will * remain on this map. */ Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareIterator.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -64,7 +64,7 @@ */ MapSquareIterator(@NotNull final MapModel<G, A, R> mapModel) { this.mapModel = mapModel; - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); mapWidth = mapSize.getWidth(); mapHeight = mapSize.getHeight(); } Modified: trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/copybuffer/CopyBuffer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -219,7 +219,7 @@ final Point sourcePoint = new Point(); final Point destinationPoint = new Point(); final MapModel<G, A, R> mapModel2 = mapView.getMapControl().getMapModel(); - final Size2D mapModelSize = mapModel.getMapSize(); + final Size2D mapModelSize = mapModel.getMapArchObject().getMapSize(); mapModel2.beginTransaction("Paste"); // TODO: I18N/L10N try { for (final MapSquare<G, A, R> destinationMapSquare : selectedSquares) { Modified: trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/golocationdialog/GoLocationDialog.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -45,6 +45,7 @@ import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; +import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -210,10 +211,11 @@ * the coordinates were wrong */ private boolean goLocation() { + final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); final Point point = new Point(); try { - point.x = parseCoordinate(xCoordinateField, mapView.getMapControl().getMapModel().getMapSize().getWidth()); - point.y = parseCoordinate(yCoordinateField, mapView.getMapControl().getMapModel().getMapSize().getHeight()); + point.x = parseCoordinate(xCoordinateField, mapSize.getWidth()); + point.y = parseCoordinate(yCoordinateField, mapSize.getHeight()); } catch (final IllegalArgumentException ignored) { return false; } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -585,7 +585,7 @@ private void selectExit(@NotNull final MapView<G, A, R> mapView, final int xStart, final int yStart, final int direction) { final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); final MapModel<G, A, R> mapModel = mapView.getMapControl().getMapModel(); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int width = mapSize.getWidth(); final int height = mapSize.getHeight(); final Point point = new Point(xStart, yStart); @@ -1043,7 +1043,7 @@ final MapCursor mapCursor = mapView.getMapViewBasic().getMapCursor(); final Point cursorLocation = mapCursor.getLocation(); if (cursorLocation == null) { - final Size2D mapSize = mapView.getMapControl().getMapModel().getMapSize(); + final Size2D mapSize = mapView.getMapControl().getMapModel().getMapArchObject().getMapSize(); selectExit(mapView, mapSize.getWidth(), mapSize.getHeight() - 1, -1); } else { selectExit(mapView, cursorLocation.x, cursorLocation.y, -1); Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -189,7 +189,7 @@ public MapViewBasic(@NotNull final MapModel<G, A, R> mapModel, final boolean isPickmap, @Nullable final Point initial, final int xScrollDistance, final int yScrollDistance, @NotNull final RendererFactory<G, A, R> rendererFactory) { super(VERTICAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_AS_NEEDED); this.mapModel = mapModel; - mapGrid = new MapGrid(this.mapModel.getMapSize()); + mapGrid = new MapGrid(this.mapModel.getMapArchObject().getMapSize()); mapCursor = new MapCursor(mapGrid); if (isPickmap) { setBackground(CommonConstants.BG_COLOR); Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -328,7 +328,7 @@ this.gridMapSquarePainter = gridMapSquarePainter; borderOffset = new Point(borderOffsetX, borderOffsetY); this.mapModel = mapModel; - mapSize = this.mapModel.getMapSize(); + mapSize = this.mapModel.getMapArchObject().getMapSize(); this.mapGrid = mapGrid; this.unknownSquareIcon = unknownSquareIcon; Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -84,7 +84,7 @@ * @param graphics The graphics context to paint to. */ protected void paintComponent2(@NotNull final Graphics2D graphics) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final Rectangle rec = new Rectangle(0, 0, mapSize.getWidth(), mapSize.getHeight()); final Point pos = new Point(); final Point endPos = rec.getLocation(); @@ -125,7 +125,7 @@ * calculated. On non-pickmaps there is an extra border. */ protected void calculateOrigin() { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); origin.setLocation(mapSize.getHeight() * isoMapSquareInfo.getXLen2(), 0); } @@ -146,7 +146,7 @@ public BufferedImage getFullImage() { // set map dimensions for iso view calculateOrigin(); - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int sum = mapSize.getWidth() + mapSize.getHeight(); final int viewWidth = sum * isoMapSquareInfo.getXLen2(); final int viewHeight = sum * isoMapSquareInfo.getYLen2(); Modified: trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeUtils.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -51,7 +51,7 @@ * @param shrinkFlags the borders to modify */ public static void shrinkMap(@NotNull final MapModel<?, ?, ?> mapModel, final int shrinkFlags) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); int filledWidth = mapSize.getWidth(); int filledHeight = mapSize.getHeight(); if ((shrinkFlags & SHRINK_EAST) != 0) { @@ -78,7 +78,7 @@ * @return the borders having empty squares */ public static int getShrinkFlags(@NotNull final MapModel<?, ?, ?> mapModel) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); int shrinkFlags = 0; Modified: trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/AbstractShopSquareChecker.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -56,7 +56,7 @@ */ @NotNull protected boolean[][] findMatchingSquares(@NotNull final MapModel<G, A, R> mapModel, @NotNull final GameObjectMatcher matcher) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); final boolean[][] matchingSquares = new boolean[mapWidth][mapHeight]; Modified: trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/BlockedMatrix.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -25,6 +25,7 @@ import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; /** @@ -45,8 +46,9 @@ * @param mapModel the map model to operate on */ public BlockedMatrix(@NotNull final MapModel<G, A, R> mapModel) { - final int width = mapModel.getMapSize().getWidth(); - final int height = mapModel.getMapSize().getHeight(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); + final int width = mapSize.getWidth(); + final int height = mapSize.getHeight(); blocked = new boolean[width][height]; final Point pos = new Point(); for (pos.y = 0; pos.y < height; pos.y++) { Modified: trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java =================================================================== --- trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java 2010-06-09 10:30:30 UTC (rev 8304) +++ trunk/src/app/net/sf/gridarta/validation/checks/BlockedSquareChecker.java 2010-06-09 10:42:13 UTC (rev 8305) @@ -67,7 +67,7 @@ * @return list with all completely blocked squares */ public static <G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> Iterable<MapSquare<G, A, R>> findCompletelyBlockedSquares(@NotNull final MapModel<G, A, R> mapModel) { - final Size2D mapSize = mapModel.getMapSize(); + final Size2D mapSize = mapModel.getMapArchObject().getMapSize(); final int mapWidth = mapSize.getWidth(); final int mapHeight = mapSize.getHeight(); // The blockedMatrix is 1 row larger than the map on each border to ease two things: This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:30:41
|
Revision: 8304 http://gridarta.svn.sourceforge.net/gridarta/?rev=8304&view=rev Author: akirschbaum Date: 2010-06-09 10:30:30 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Merge duplicated fields AbstractMapArchObject.mapSize and DefaultMapModel.mapSize. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java trunk/src/app/net/sf/gridarta/gui/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 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -250,6 +250,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<GameObject, MapArchObject, Archetype> errors) { // ignore } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -21,9 +21,14 @@ 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.map.mapmodel.MapSquare; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -179,6 +184,9 @@ this.mapSize = mapSize; setModified(); + for (final MapArchObjectListener<A> listener : listenerList.getListeners()) { + listener.mapSizeChanged(mapSize); + } } /** @@ -606,6 +614,43 @@ /** * {@inheritDoc} */ + @Override + public boolean isPointValid(@Nullable final Point pos) { + return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + } + + /** + * {@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/map/maparchobject/MapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -21,9 +21,14 @@ 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.map.mapmodel.MapSquare; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** * Interface for MapArchObjects. <h4>Enter coordinates</h4> Enter coordinates @@ -281,4 +286,25 @@ */ void updateModifiedAttribute(@NotNull String userName); + /** + * Check whether the given coordinate is within map bounds. + * @param pos the coordinates to check + * @return <code>true</code> if the given coordinates are on the map, + * otherwise <code>false</code> (also returns <code>false</code> if + * <code><var>pos</var> == null</code>) + */ + 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/map/maparchobject/MapArchObjectListener.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObjectListener.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -20,6 +20,8 @@ package net.sf.gridarta.model.map.maparchobject; import java.util.EventListener; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; /** * Interface for listeners listening on map arch object changes. @@ -32,4 +34,10 @@ */ void mapMetaChanged(); + /** + * The map size has changed. This callback ignores active map transactions. + * @param mapSize the new map size + */ + void mapSizeChanged(@NotNull Size2D mapSize); + } // interface MapArchObjectListener Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/DefaultMapModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -92,12 +92,6 @@ private final ArchetypeChooserModel<G, A, R> archetypeChooserModel; /** - * Size of this map. - */ - @NotNull - private Size2D mapSize; - - /** * The map, containing all arches grid-wise. Index: [width][height] */ @NotNull @@ -209,6 +203,14 @@ setModified(); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + resizeMapInt(mapSize); + } + }; /** @@ -231,9 +233,8 @@ this.gameObjectMatchers = gameObjectMatchers; this.topmostInsertionMode = topmostInsertionMode; savedSquares = new SavedSquares<G, A, R>(gameObjectFactory, gameObjectMatchers); - mapSize = mapArchObject.getMapSize(); mapArchObject.addMapArchObjectListener(mapArchObjectListener); - mapGrid = new MapSquareGrid<G, A, R>(this, mapSize); + mapGrid = new MapSquareGrid<G, A, R>(this, mapArchObject.getMapSize()); modified = false; } @@ -260,7 +261,7 @@ @NotNull @Override public Size2D getMapSize() { - return mapSize; + return mapArchObject.getMapSize(); } /** @@ -313,7 +314,7 @@ */ @Override public boolean isPointValid(@Nullable final Point pos) { - return pos != null && pos.x >= 0 && pos.y >= 0 && pos.x < mapSize.getWidth() && pos.y < mapSize.getHeight(); + return mapArchObject.isPointValid(pos); } /** @@ -321,6 +322,15 @@ */ @Override public void resizeMap(@NotNull final Size2D newSize) { + mapArchObject.setMapSize(newSize); + } + + /** + * Resizes the map grid after the map size has changed. + * @param newSize the new map size + */ + private void resizeMapInt(@NotNull final Size2D newSize) { + final Size2D mapSize = mapGrid.getMapSize(); if (newSize.equals(mapSize)) { return; } @@ -346,52 +356,16 @@ node.remove(); } - // Now the critical step: create an GameObject array of new dimension, - // copy all objects and set it to replace the current one. mapGrid.resize(newSize); + mapArchObject.discardInvalidMapSquares(changedSquares); + mapArchObject.discardInvalidGameObjects(changedGameObjects); + mapArchObject.discardInvalidGameObjects(transientChangedGameObjects); - // adjust the map and model attributes - mapSize = newSize; - mapArchObject.setMapSize(newSize); - - discardInvalidMapSquares(changedSquares); - discardInvalidGameObjects(changedGameObjects); - discardInvalidGameObjects(transientChangedGameObjects); - fireMapSizeChanged(newSize); } } /** - * Discards map squares that are out of map bounds. - * @param mapSquares the map squares to check - */ - private 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(); - } - } - } - - /** - * Discards game objects that are out of map bounds. - * @param gameObjects the game objects to check - */ - private 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} */ @Override @@ -870,7 +844,7 @@ @Override public void addGameObjectToMap(@NotNull final G gameObject, @NotNull final Point pos, @NotNull final InsertionMode<G, A, R> insertionMode) { if (!isPointValid(pos)) { - log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapSize); + log.error("addGameObjectToMap: trying to insert game object out of map bounds at " + pos.x + "/" + pos.y + ", map bounds is " + mapArchObject.getMapSize()); return; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -76,6 +76,7 @@ * Return the map size of this map. * @return map size of this map */ + @Deprecated @NotNull Size2D getMapSize(); @@ -98,6 +99,7 @@ * attached to right and bottom. * @param newSize new map size */ + @Deprecated void resizeMap(@NotNull Size2D newSize); /** @@ -107,6 +109,7 @@ * otherwise <code>false</code> (also returns <code>false</code> if * <code><var>pos</var> == null</code>) */ + @Deprecated boolean isPointValid(@Nullable Point pos); /** Modified: trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/app/net/sf/gridarta/model/map/mapmodel/MapSquareGrid.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -169,4 +169,13 @@ } } + /** + * Returns the size of this map grid in map squares. + * @return the size + */ + @NotNull + public Size2D getMapSize() { + return mapSize; + } + } // class MapSquareGrid Modified: trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/model/src/test/net/sf/gridarta/model/map/mapmodel/DefaultMapModelTest.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -138,6 +138,14 @@ result.append("mapMetaChanged"); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/delayedmapmodel/DelayedMapModelListenerManager.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -372,6 +372,14 @@ scheduleMapModel(mapModel); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + } } // class DelayedMapModelListenerManager Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -718,6 +718,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -187,6 +187,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/GameObjectAttributesControl.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -244,6 +244,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { Modified: trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/MapFileActions.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -183,6 +183,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -117,6 +117,14 @@ updateTitle(); } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -166,6 +166,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -246,6 +246,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/mapdesktop/WindowAction.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -154,6 +154,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/mapmenu/MapMenuManager.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -282,6 +282,14 @@ * {@inheritDoc} */ @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + + /** + * {@inheritDoc} + */ + @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { // ignore } Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserControl.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -270,6 +270,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserModel.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -115,6 +115,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + }; /** Modified: trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -150,6 +150,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { Modified: trunk/src/app/net/sf/gridarta/mainactions/MainActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:23:00 UTC (rev 8303) +++ trunk/src/app/net/sf/gridarta/mainactions/MainActions.java 2010-06-09 10:30:30 UTC (rev 8304) @@ -571,6 +571,14 @@ // ignore } + /** + * {@inheritDoc} + */ + @Override + public void mapSizeChanged(@NotNull final Size2D mapSize) { + // ignore + } + /** {@inheritDoc} */ @Override public void mapSizeChanged(@NotNull final MapModel<G, A, R> mapModel, @NotNull final Size2D newSize) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 10:23:11
|
Revision: 8303 http://gridarta.svn.sourceforge.net/gridarta/?rev=8303&view=rev Author: akirschbaum Date: 2010-06-09 10:23:00 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Do not crash when reverting a resized map. Properly revert attributes from map property dialog. Modified Paths: -------------- trunk/atrinik/ChangeLog trunk/crossfire/ChangeLog trunk/daimonin/ChangeLog trunk/gridarta.ipr trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java Added Paths: ----------- trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java Removed Paths: ------------- trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java Modified: trunk/atrinik/ChangeLog =================================================================== --- trunk/atrinik/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/atrinik/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/crossfire/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/daimonin/ChangeLog =================================================================== --- trunk/daimonin/ChangeLog 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/daimonin/ChangeLog 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,3 +1,8 @@ +2010-06-09 Andreas Kirschbaum + + * Do not crash when reverting a resized map. Properly revert + attributes from map property dialog. + 2010-06-07 Andreas Kirschbaum * Remove tooltips from archetype chooser. Modified: trunk/gridarta.ipr =================================================================== --- trunk/gridarta.ipr 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/gridarta.ipr 2010-06-09 10:23:00 UTC (rev 8303) @@ -1277,6 +1277,7 @@ <w>resized</w> <w>resizes</w> <w>rethrown</w> + <w>revertable</w> <w>revivable</w> <w>riedquat</w> <w>rsync</w> Added: trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,58 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import java.util.LinkedHashMap; +import java.util.Map; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.GameObjectFactory; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.match.GameObjectMatchers; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link GameObjectParser} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestGameObjectParser extends AbstractGameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> { + + /** + * Create a new instance. + * @param gameObjectFactory the game object factory for creating new game + * object instances + * @param gameObjectMatchers the game object matchers to use + */ + public TestGameObjectParser(@NotNull final GameObjectFactory<TestGameObject, TestMapArchObject, TestArchetype> gameObjectFactory, @NotNull final GameObjectMatchers gameObjectMatchers) { + super(gameObjectFactory, gameObjectMatchers); + } + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public Map<String, String> getModifiedFields(@NotNull final TestGameObject gameObject) { + final Map<String, String> fields = new LinkedHashMap<String, String>(); + addModifiedFields(gameObject, fields); + return fields; + } + +} // class TestGameObjectParser Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestGameObjectParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,89 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import java.io.IOException; +import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectParser} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectParser extends AbstractMapArchObjectParser<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @Override + protected boolean parseLine(@NotNull final String line, @NotNull final TestMapArchObject mapArchObject) { + return false; + } + + /** + * {@inheritDoc} + */ + @Override + public void save(@NotNull final Appendable appendable, @NotNull final TestMapArchObject mapArchObject) throws IOException { + final Formatter format = new Formatter(appendable); + appendable.append("arch map\n"); + if (mapArchObject.getMapName().length() > 0) { + format.format("name %s\n", mapArchObject.getMapName()); + } + if (mapArchObject.getSwapTime() != 0) { + format.format("swap_time %d\n", mapArchObject.getSwapTime()); + } + if (mapArchObject.getResetTimeout() != 0) { + format.format("reset_timeout %d\n", mapArchObject.getResetTimeout()); + } + if (mapArchObject.isFixedReset()) { + appendable.append("fixed_resettime 1\n"); + } + if (mapArchObject.getDifficulty() != 0) { + format.format("difficulty %d\n", mapArchObject.getDifficulty()); + } + if (mapArchObject.getDarkness() != 0) { + format.format("darkness %d\n", mapArchObject.getDarkness()); + } + format.format("width %d\n", mapArchObject.getMapSize().getWidth()); + format.format("height %d\n", mapArchObject.getMapSize().getHeight()); + if (mapArchObject.getEnterX() != 0) { + format.format("enter_x %d\n", mapArchObject.getEnterX()); + } + if (mapArchObject.getEnterY() != 0) { + format.format("enter_y %d\n", mapArchObject.getEnterY()); + } + if (mapArchObject.getText().trim().length() > 0) { + format.format("msg\n" + "%s\n" + "endmsg\n", mapArchObject.getText().trim()); + } + if (mapArchObject.isOutdoor()) { + appendable.append("outdoor 1\n"); + } + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); + } + } + appendable.append("end\n"); + } + +} // class TestMapArchObjectParser Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParser.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Added: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,40 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.io; + +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import org.jetbrains.annotations.NotNull; + +/** + * A {@link MapArchObjectParserFactory} for regression tests. + * @author Andreas Kirschbaum + */ +public class TestMapArchObjectParserFactory implements MapArchObjectParserFactory<TestMapArchObject> { + + /** + * {@inheritDoc} + */ + @NotNull + @Override + public MapArchObjectParser<TestMapArchObject> newMapArchObjectParser() { + return new TestMapArchObjectParser(); + } + +} // class TestMapArchObjectParserFactory Property changes on: trunk/model/src/test/net/sf/gridarta/model/io/TestMapArchObjectParserFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapReaderFactory.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -21,8 +21,12 @@ import java.io.File; import java.io.IOException; +import net.sf.gridarta.model.archetype.ArchetypeSet; +import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import org.jetbrains.annotations.NotNull; /** @@ -32,12 +36,59 @@ public class TestMapReaderFactory implements MapReaderFactory<TestGameObject, TestMapArchObject> { /** + * The {@link MapArchObjectParserFactory} instance. + */ + @NotNull + private final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory; + + /** + * The {@link MapArchObjectFactory} instance. + */ + @NotNull + private final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory; + + /** + * The {@link GameObjectParser} instance. + */ + @NotNull + private final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser; + + /** + * The {@link ArchetypeSet} instance. + */ + @NotNull + private final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet; + + /** + * The {@link MapViewSettings} instance. + */ + @NotNull + private final MapViewSettings mapViewSettings; + + /** + * Creates a new instance. + * @param mapArchObjectParserFactory the map arch object parser factory + * instance + * @param mapArchObjectFactory the map arch object factory instance + * @param gameObjectParser the game object parser instance + * @param archetypeSet the archetype set + * @param mapViewSettings the map view settings instance + */ + public TestMapReaderFactory(@NotNull final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory, @NotNull final MapArchObjectFactory<TestMapArchObject> mapArchObjectFactory, @NotNull final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser, @NotNull final ArchetypeSet<TestGameObject, TestMapArchObject, TestArchetype> archetypeSet, @NotNull final MapViewSettings mapViewSettings) { + this.mapArchObjectParserFactory = mapArchObjectParserFactory; + this.mapArchObjectFactory = mapArchObjectFactory; + this.gameObjectParser = gameObjectParser; + this.archetypeSet = archetypeSet; + this.mapViewSettings = mapViewSettings; + } + + /** * {@inheritDoc} */ @NotNull @Override public MapReader<TestGameObject, TestMapArchObject> newMapReader(@NotNull final File file) throws IOException { - throw new AssertionError(); + return new DefaultMapReader<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, archetypeSet, mapViewSettings, file); } } // class TestMapReaderFactory Deleted: trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/io/TestMapWriter.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -1,43 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.model.io; - -import java.io.IOException; -import java.io.Writer; -import net.sf.gridarta.model.archetype.TestArchetype; -import net.sf.gridarta.model.gameobject.TestGameObject; -import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; -import net.sf.gridarta.model.map.mapmodel.MapModel; -import org.jetbrains.annotations.NotNull; - -/** - * An {@link MapWriter} implementation for testing purposes. - * @author Andreas Kirschbaum - */ -public class TestMapWriter implements MapWriter<TestGameObject, TestMapArchObject, TestArchetype> { - - /** - * {@inheritDoc} - */ - @Override - public void encodeMapFile(@NotNull final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel, @NotNull final Writer writer) throws IOException { - } - -} // class TestMapWriter Modified: trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -19,16 +19,13 @@ package net.sf.gridarta.model.map.maparchobject; -import java.awt.Point; -import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; /** * A {@link MapArchObject} implementation for testing purposes. * @author Andreas Kirschbaum */ -public class TestMapArchObject implements MapArchObject<TestMapArchObject> { +public class TestMapArchObject extends AbstractMapArchObject<TestMapArchObject> { /** * The serial version UID. @@ -36,302 +33,20 @@ private static final long serialVersionUID = 1L; /** - * The current map size. - */ - private Size2D mapSize = Size2D.ONE; - - /** - * The map name. - */ - private String mapName = "*unset map name*"; - - /** * {@inheritDoc} */ - @Override - public void setState(@NotNull final TestMapArchObject mapArchObject) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setMapSize(@NotNull final Size2D mapSize) { - this.mapSize = mapSize; - } - - /** - * {@inheritDoc} - */ @NotNull @Override - public Size2D getMapSize() { - return mapSize; - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getMapName() { - return mapName; - } - - /** - * {@inheritDoc} - */ - @Override - public void setMapName(@NotNull final String name) { - mapName = name; - } - - /** - * {@inheritDoc} - */ - @Override - public int getEnterX() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEnterX(final int enterX) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getEnterY() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setEnterY(final int enterY) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public Point getEnter() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isOutdoor() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setOutdoor(final boolean outdoor) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getResetTimeout() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setResetTimeout(final int resetTimeout) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getSwapTime() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setSwapTime(final int swapTime) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getDifficulty() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDifficulty(final int difficulty) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean isFixedReset() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setFixedReset(final boolean fixedReset) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getDarkness() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setDarkness(final int darkness) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public int getTilePaths() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getTilePath(@NotNull final Direction direction) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override public TestMapArchObject clone() { - try { - return (TestMapArchObject) super.clone(); - } catch (final CloneNotSupportedException ex) { - throw new AssertionError(ex); - } + return super.clone(); } /** * {@inheritDoc} */ @Override - public void addMapArchObjectListener(@NotNull final MapArchObjectListener<TestMapArchObject> listener) { - // ignore + protected TestMapArchObject getThis() { + return this; } - /** - * {@inheritDoc} - */ - @Override - public void removeMapArchObjectListener(@NotNull final MapArchObjectListener<TestMapArchObject> listener) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void beginTransaction() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void endTransaction() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void endTransaction(final boolean fireEvent) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void addText(@NotNull final String text) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void setText(final String text) { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @NotNull - @Override - public String getText() { - throw new AssertionError(); - } - - /** - * {@inheritDoc} - */ - @Override - public void updateModifiedAttribute(@NotNull final String userName) { - } - } // class TestMapArchObject Modified: trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/model/src/test/net/sf/gridarta/model/settings/TestGlobalSettings.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -278,7 +278,7 @@ @NotNull @Override public String getUserName() { - throw new AssertionError(); + return "user"; } /** Modified: trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java =================================================================== --- trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/src/app/net/sf/gridarta/mapmanager/AbstractMapManager.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -351,10 +351,10 @@ final A mapArchObject = mapModel.getMapArchObject(); mapModel.beginTransaction("revert"); try { - mapModel.resizeMap(mapArchObject.getMapSize()); + mapModel.resizeMap(decoder.getMapArchObject().getMapSize()); mapArchObject.beginTransaction(); try { - mapArchObject.setState(mapArchObject); + mapArchObject.setState(decoder.getMapArchObject()); } finally { mapArchObject.endTransaction(); } Modified: trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-09 08:43:03 UTC (rev 8302) +++ trunk/src/test/net/sf/gridarta/gui/map/test/TestMapControlCreator.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -60,11 +60,15 @@ import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.gameobject.TestGameObjectFactory; import net.sf.gridarta.model.io.CacheFiles; +import net.sf.gridarta.model.io.DefaultMapWriter; +import net.sf.gridarta.model.io.GameObjectParser; +import net.sf.gridarta.model.io.MapArchObjectParserFactory; import net.sf.gridarta.model.io.MapReaderFactory; import net.sf.gridarta.model.io.MapWriter; import net.sf.gridarta.model.io.PathManager; +import net.sf.gridarta.model.io.TestGameObjectParser; +import net.sf.gridarta.model.io.TestMapArchObjectParserFactory; import net.sf.gridarta.model.io.TestMapReaderFactory; -import net.sf.gridarta.model.io.TestMapWriter; import net.sf.gridarta.model.map.maparchobject.MapArchObjectFactory; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObjectFactory; @@ -232,15 +236,17 @@ final ArchetypeFactory<TestGameObject, TestMapArchObject, TestArchetype> archetypeFactory = new TestArchetypeFactory(); final FaceObjectProviders faceObjectProviders = newFaceObjectProviders(); archetypeSet = new TestArchetypeSet(archetypeFactory, "archetypes", faceObjectProviders); - final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(); + final MapArchObjectParserFactory<TestMapArchObject> mapArchObjectParserFactory = new TestMapArchObjectParserFactory(); + mapViewSettings = new TestMapViewSettings(); + gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); + final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); + final GameObjectParser<TestGameObject, TestMapArchObject, TestArchetype> gameObjectParser = new TestGameObjectParser(gameObjectFactory, gameObjectMatchers); + final MapReaderFactory<TestGameObject, TestMapArchObject> mapReaderFactory = new TestMapReaderFactory(mapArchObjectParserFactory, mapArchObjectFactory, gameObjectParser, archetypeSet, mapViewSettings); globalSettings = new TestGlobalSettings(); - mapViewSettings = new TestMapViewSettings(); - final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new TestMapWriter(); + final MapWriter<TestGameObject, TestMapArchObject, TestArchetype> mapWriter = new DefaultMapWriter<TestGameObject, TestMapArchObject, TestArchetype>(mapArchObjectParserFactory, gameObjectParser); final AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype> autojoinLists = new AutojoinLists<TestGameObject, TestMapArchObject, TestArchetype>(mapViewSettings); final ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype> archetypeChooserModel = new ArchetypeChooserModel<TestGameObject, TestMapArchObject, TestArchetype>(); pathManager = new PathManager(globalSettings); - gameObjectFactory = new TestGameObjectFactory(faceObjectProviders, animationObjects); - final GameObjectMatchers gameObjectMatchers = new GameObjectMatchers(); topmostInsertionMode = new TopmostInsertionMode<TestGameObject, TestMapArchObject, TestArchetype>(); insertionModeSet = new InsertionModeSet<TestGameObject, TestMapArchObject, TestArchetype>(topmostInsertionMode); insertionModeSet.init(new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher(), new TypeNrsGameObjectMatcher()); Added: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java (rev 0) +++ trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java 2010-06-09 10:23:00 UTC (rev 8303) @@ -0,0 +1,93 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.mapmanager; + +import java.awt.Point; +import java.io.File; +import java.io.IOException; +import net.sf.gridarta.gui.map.test.TestMapControlCreator; +import net.sf.gridarta.model.archetype.DuplicateArchetypeException; +import net.sf.gridarta.model.archetype.TestArchetype; +import net.sf.gridarta.model.gameobject.TestGameObject; +import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; +import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.utils.Size2D; +import org.junit.Test; + +/** + * Regression tests for {@link DefaultMapManager}. + * @author Andreas Kirschbaum + */ +public class DefaultMapManagerTest { + + /** + * A map that has been resized must still be revertable. + * @throws IOException if an I/O error occurs + * @throws DuplicateArchetypeException if the test fails + */ + @Test + public void testRevertResizedMap() throws DuplicateArchetypeException, IOException { + final File file = File.createTempFile("gridarta", null); + try { + final TestMapControlCreator testMapControlCreator = new TestMapControlCreator(); + final Size2D originalSize = new Size2D(2, 1); + final Size2D newSize = new Size2D(1, 2); + final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(file, "test", originalSize); + final MapModel<TestGameObject, TestMapArchObject, TestArchetype> mapModel = mapControl.getMapModel(); + final MapManager<TestGameObject, TestMapArchObject, TestArchetype> mapManager = testMapControlCreator.getMapManager(); + + mapModel.beginTransaction("test"); + try { + testMapControlCreator.insertFloor(mapModel, new Point(1, 0)); + } finally { + mapModel.endTransaction(); + } + mapControl.save(); + TestMapControlCreator.checkMapContents(mapModel, "|floor"); + + mapModel.beginTransaction("test"); + try { + mapModel.resizeMap(newSize); + } finally { + mapModel.endTransaction(); + } + mapModel.beginTransaction("test"); + try { + testMapControlCreator.insertFloor(mapModel, new Point(0, 1)); + } finally { + mapModel.endTransaction(); + } + TestMapControlCreator.checkMapContents(mapModel, "", "floor"); + + mapModel.beginTransaction("test"); + try { + mapManager.revert(mapControl); + } finally { + mapModel.endTransaction(); + } + TestMapControlCreator.checkMapContents(mapModel, "|floor"); + } finally { + //noinspection ResultOfMethodCallIgnored + file.delete(); + } + } + +} // class DefaultMapManagerTest Property changes on: trunk/src/test/net/sf/gridarta/mapmanager/DefaultMapManagerTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 08:43:09
|
Revision: 8302 http://gridarta.svn.sourceforge.net/gridarta/?rev=8302&view=rev Author: akirschbaum Date: 2010-06-09 08:43:03 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Accelerate painting of maps with validation errors. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:34:20 UTC (rev 8301) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:43:03 UTC (rev 8302) @@ -293,18 +293,22 @@ */ private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { erroneousMapSquares.clear(); - mapGrid.clearErrors(); - for (final ValidationError<G, A, R> validationError : errors.getErrors()) { - for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { - erroneousMapSquares.put(mapSquare, validationError); - mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); + mapGrid.beginTransaction(); + try { + mapGrid.clearErrors(); + for (final ValidationError<G, A, R> validationError : errors.getErrors()) { + for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { + erroneousMapSquares.put(mapSquare, validationError); + mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); + } + for (final G gameObject : validationError.getGameObjects()) { + final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); + mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); + } } - for (final G gameObject : validationError.getGameObjects()) { - final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); - mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); - } + } finally { + mapGrid.endTransaction(); } - renderer.repaint(); } } // class MapViewBasic This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 08:34:26
|
Revision: 8301 http://gridarta.svn.sourceforge.net/gridarta/?rev=8301&view=rev Author: akirschbaum Date: 2010-06-09 08:34:20 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove unused code. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:33:11 UTC (rev 8300) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:34:20 UTC (rev 8301) @@ -88,12 +88,6 @@ private final Map<MapSquare<G, A, R>, ValidationError<G, A, R>> erroneousMapSquares = new HashMap<MapSquare<G, A, R>, ValidationError<G, A, R>>(); /** - * The erroneous {@link GameObject}s. - */ - @NotNull - private final Map<G, ValidationError<G, A, R>> erroneousGameObjects = new HashMap<G, ValidationError<G, A, R>>(); - - /** * The {@link AbstractMapRenderer} for rendering {@link #mapModel}. */ @NotNull @@ -299,7 +293,6 @@ */ private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { erroneousMapSquares.clear(); - erroneousGameObjects.clear(); mapGrid.clearErrors(); for (final ValidationError<G, A, R> validationError : errors.getErrors()) { for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { @@ -307,7 +300,6 @@ mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); } for (final G gameObject : validationError.getGameObjects()) { - erroneousGameObjects.put(gameObject, validationError); final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 08:33:18
|
Revision: 8300 http://gridarta.svn.sourceforge.net/gridarta/?rev=8300&view=rev Author: akirschbaum Date: 2010-06-09 08:33:11 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove unused 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/SimpleFlatMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.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 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/AbstractFlatMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -28,7 +28,6 @@ import java.io.File; import java.util.Collection; import java.util.HashSet; -import java.util.Map; import java.util.Set; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.GridMapSquarePainter; @@ -40,7 +39,6 @@ import net.sf.gridarta.model.map.mapmodel.MapModelListener; import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.Size2D; @@ -582,12 +580,4 @@ */ protected abstract void updateAll(); - /** - * {@inheritDoc} - */ - @Override - public void setErroneousArchObjects(@NotNull final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { - //XXX: save erroneousArchObjects - } - } // class AbstractFlatMapRenderer 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 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/gui/map/renderer/SimpleFlatMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -24,12 +24,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import javax.swing.ImageIcon; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.model.baseobject.BaseObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.SystemIcons; import net.sf.gridarta.var.crossfire.IGUIConstants; @@ -175,13 +173,6 @@ * {@inheritDoc} */ @Override - public void setErroneousArchObjects(@NotNull final Map<GameObject, ValidationError<GameObject, MapArchObject, Archetype>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ - @Override public void closeNotify() { } Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -91,7 +91,7 @@ * The erroneous {@link GameObject}s. */ @NotNull - private final Map<G, ValidationError<G, A, R>> erroneousArchObjects = new HashMap<G, ValidationError<G, A, R>>(); + private final Map<G, ValidationError<G, A, R>> erroneousGameObjects = new HashMap<G, ValidationError<G, A, R>>(); /** * The {@link AbstractMapRenderer} for rendering {@link #mapModel}. @@ -209,7 +209,6 @@ mapModel.addMapModelListener(mapModelListener); renderer.setErroneousMapSquares(erroneousMapSquares); - renderer.setErroneousArchObjects(erroneousArchObjects); renderer.setFocusable(true); setFocusable(true); } @@ -300,16 +299,16 @@ */ private void errorsChanged(@NotNull final ErrorCollector<G, A, R> errors) { erroneousMapSquares.clear(); - erroneousArchObjects.clear(); + erroneousGameObjects.clear(); mapGrid.clearErrors(); for (final ValidationError<G, A, R> validationError : errors.getErrors()) { for (final MapSquare<G, A, R> mapSquare : validationError.getMapSquares()) { erroneousMapSquares.put(mapSquare, validationError); mapGrid.setError(mapSquare.getMapX(), mapSquare.getMapY()); } - for (final G archObject : validationError.getGameObjects()) { - erroneousArchObjects.put(archObject, validationError); - final BaseObject<G, A, R, ?> topContainer = archObject.getTopContainer(); + for (final G gameObject : validationError.getGameObjects()) { + erroneousGameObjects.put(gameObject, validationError); + final BaseObject<G, A, R, ?> topContainer = gameObject.getTopContainer(); mapGrid.setError(topContainer.getMapX(), topContainer.getMapY()); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractIsoMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -27,7 +27,6 @@ import java.awt.Rectangle; import java.awt.image.BufferedImage; import java.io.File; -import java.util.Map; import java.util.Set; import javax.swing.Icon; import net.sf.gridarta.model.archetype.Archetype; @@ -44,7 +43,6 @@ import net.sf.gridarta.model.map.mapmodel.MapModelListener; import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.Size2D; @@ -649,14 +647,6 @@ } /** - * {@inheritDoc} - */ - @Override - public void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects) { - //XXX: save erroneousArchObjects - } - - /** * Refreshes the data in the view from the model. */ private void resizeFromModel() { Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -94,13 +94,6 @@ } /** - * Sets the ArchObjects that are known to contain errors. - * @param erroneousArchObjects the ArchObjects that are known to contain - * errors - */ - public abstract void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects); - - /** * Sets the MapSquares that are known to contain errors. * @param erroneousMapSquares the MapSquares that are known to contain * errors Modified: trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/app/net/sf/gridarta/gui/map/renderer/AbstractSimpleIsoMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -25,7 +25,6 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.baseobject.GameObjectContainer; import net.sf.gridarta.model.gameobject.GameObject; @@ -33,7 +32,6 @@ import net.sf.gridarta.model.io.GameObjectParser; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -183,13 +181,6 @@ /** * {@inheritDoc} */ - @Override - public void setErroneousArchObjects(@NotNull final Map<G, ValidationError<G, A, R>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ @NotNull @Override public Rectangle getSquareBounds(@NotNull final Point p) { Modified: trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java 2010-06-09 08:07:22 UTC (rev 8299) +++ trunk/src/test/net/sf/gridarta/gui/map/renderer/TestMapRenderer.java 2010-06-09 08:33:11 UTC (rev 8300) @@ -22,12 +22,10 @@ import java.awt.Point; import java.awt.Rectangle; import java.awt.image.BufferedImage; -import java.util.Map; import net.sf.gridarta.model.archetype.TestArchetype; import net.sf.gridarta.model.gameobject.TestGameObject; import net.sf.gridarta.model.map.maparchobject.TestMapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; -import net.sf.gridarta.model.map.validation.errors.ValidationError; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -80,13 +78,6 @@ * {@inheritDoc} */ @Override - public void setErroneousArchObjects(@NotNull final Map<TestGameObject, ValidationError<TestGameObject, TestMapArchObject, TestArchetype>> erroneousArchObjects) { - } - - /** - * {@inheritDoc} - */ - @Override public void closeNotify() { throw new AssertionError(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-09 08:07:30
|
Revision: 8299 http://gridarta.svn.sourceforge.net/gridarta/?rev=8299&view=rev Author: akirschbaum Date: 2010-06-09 08:07:22 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Move MapCursor and related classes to different packages or modules. Modified Paths: -------------- trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/misc/StatusBar.java trunk/src/app/net/sf/gridarta/gui/objectchooser/DefaultObjectChooser.java trunk/src/app/net/sf/gridarta/gui/selectedsquare/SelectedSquareView.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/mapcursor/ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java trunk/model/src/test/net/sf/gridarta/model/mapcursor/ trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java trunk/src/app/net/sf/gridarta/gui/mapcursor/ trunk/src/test/net/sf/gridarta/gui/mapcursor/ Removed Paths: ------------- trunk/src/app/net/sf/gridarta/gui/map/cursor/ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorEvent.java trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursorListener.java trunk/src/test/net/sf/gridarta/gui/map/cursor/ trunk/src/test/net/sf/gridarta/gui/mapcursor/MapCursorTest.java Modified: trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/model/src/app/net/sf/gridarta/model/map/grid/MapGrid.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -29,7 +29,7 @@ /** * 2D-Grid containing flags for selection, pre-selection, cursor, warnings and * errors. This class provides methods to modify these flags. Normally a {@link - * net.sf.gridarta.gui.map.cursor.MapCursor} is used to access them. Selection + * net.sf.gridarta.gui.mapcursor.MapCursor} 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 Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,424 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapcursor; + +import java.awt.Dimension; +import java.awt.Point; +import java.awt.Rectangle; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.grid.MapGrid; +import net.sf.gridarta.model.map.grid.MapGridEvent; +import net.sf.gridarta.model.map.grid.MapGridListener; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.utils.EventListenerList2; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * MapCursor provides methods to move and drag on map. The MapCursor is bound to + * a {@link MapGrid} which will change it flags depending on MapCursor + * movement/selection. <p/> There are three different states for MapCursor: <ul> + * <li>Deactivated</li> <li>On the map</li> <li>Dragging</li> </ul> When + * coordinates or state of MapCursor changes a {@link MapCursorEvent} is fired. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public class MapCursor implements MapGridListener { + + /** + * Current cursor position. When cursor is active it is highlighted on the + * MapGrid. + */ + private final Point pos = new Point(); + + /** + * Position where dragging has started. + */ + private final Point dragStart = new Point(); + + /** + * Offset of dragging. (0, 0) when drag is on the starting position. + */ + private final Dimension dragOffset = new Dimension(); + + /** + * Whether the cursor is currently on map. + */ + private boolean onMap; + + /** + * Gets set to <code>true</code> when in drag mode. + */ + private boolean dragging; + + /** + * Grid where cursor is bound to. + */ + private final MapGrid mapGrid; + + /** + * Used to test if coordinates are on the map. Created by MapGrid. + */ + private final Rectangle mapRec; + + /** + * Temporary point used in some methods. Placed as instance var to prevent + * creation of temporary objects. + */ + private final Point tmpPoint = new Point(); + + /** + * The MapCursorListeners to inform of changes. + */ + private final EventListenerList2<MapCursorListener> listenerList = new EventListenerList2<MapCursorListener>(MapCursorListener.class); + + /** + * Construct a MapCursor. The cursor will be deactivated after + * construction. + * @param mapGrid Cursor is bound to this grid + */ + public MapCursor(final MapGrid mapGrid) { + this.mapGrid = mapGrid; + mapRec = mapGrid.getMapRec(); + mapGrid.addMapGridListener(this); + deactivate(); + } + + /** + * Get position of cursor. + * @return coordinates of cursor or <code>null</code> if cursor is not + * active + */ + @Nullable + public Point getLocation() { + return onMap ? pos : null; + } + + /** + * Move cursor to a new location. If new location is not on map, cursor gets + * disabled. + * @param p New location. If <code>p == null</code> cursor gets disabled + * @return <code>true</code> if cursor position changed or if it gets + * disabled + */ + public boolean setLocation(@Nullable final Point p) { + mapGrid.beginTransaction(); + try { + final boolean hasChanged; + if (p != null && mapRec.contains(p)) { + if (onMap) { + if (pos.equals(p)) { + hasChanged = false; + } else { + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.setCursor(pos); + fireMapCursorChangedPosEvent(); + hasChanged = true; + } + } else { + pos.setLocation(p); + mapGrid.setCursor(pos); + onMap = true; + fireMapCursorChangedModeEvent(); + fireMapCursorChangedPosEvent(); + hasChanged = true; + } + } else if (onMap) { + deactivate(); + hasChanged = true; + } else { + hasChanged = false; + } + return hasChanged; + } finally { + mapGrid.endTransaction(); + } + } + + /** + * Move cursor to a new location. If new location is not on map, cursor does + * not change. + * @param p New location. If <code>p == null</code> nothing happens + * @return <code>true</code> if cursor position changed + */ + public boolean setLocationSafe(@Nullable final Point p) { + mapGrid.beginTransaction(); + final boolean hasChanged; + try { + if (p != null && mapRec.contains(p)) { + if (onMap) { + if (pos.equals(p)) { + hasChanged = false; + } else { + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.setCursor(pos); + hasChanged = true; + } + } else { + pos.setLocation(p); + onMap = true; + fireMapCursorChangedModeEvent(); + hasChanged = true; + } + } else { + hasChanged = false; + } + } finally { + mapGrid.endTransaction(); + } + if (hasChanged) { + fireMapCursorChangedPosEvent(); + } + return hasChanged; + } + + /** + * Set cursor to drag mode when it is active. + */ + public void dragStart() { + if (onMap && !dragging) { + mapGrid.beginTransaction(); + try { + dragStart.setLocation(pos); + mapGrid.preSelect(dragStart, pos); + dragging = true; + dragOffset.setSize(0, 0); + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedModeEvent(); + } + } + + /** + * When in drag mode and the point is on the map cursor is moved to this + * position. {@link MapGrid} changes pre-selection accordingly. + * @param p new coordinates + * @return <code>true</code> when dragging position changed successfully + */ + public boolean dragTo(@Nullable final Point p) { + if (p != null && mapRec.contains(p) && dragging && !pos.equals(p)) { + mapGrid.beginTransaction(); + try { + final Point oldPos = new Point(pos); + mapGrid.unSetCursor(pos); + pos.setLocation(p); + mapGrid.updatePreSelect(dragStart, oldPos, pos); + mapGrid.setCursor(pos); + dragOffset.setSize(pos.x - dragStart.x, pos.y - dragStart.y); + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedPosEvent(); + return true; + } + return false; + } + + /** + * Leave drag mode and undo pre-selection. + */ + public void dragRelease() { + if (dragging) { + mapGrid.beginTransaction(); + try { + mapGrid.unPreSelect(dragStart, pos); + dragging = false; + } finally { + mapGrid.endTransaction(); + } + fireMapCursorChangedModeEvent(); + } + } + + /** + * Leave drag mode and select pre-selection using selectionMode. + * @param selectionMode Mode how to change selection state + * @see SelectionMode + */ + public void dragSelect(final SelectionMode selectionMode) { + if (dragging) { + mapGrid.beginTransaction(); + try { + dragRelease(); + mapGrid.select(dragStart, pos, selectionMode); + } finally { + mapGrid.endTransaction(); + } + } + } + + /** + * Cursor gets deactivated. All selections get lost. + */ + public final void deactivate() { + final boolean hasChanged = onMap; + mapGrid.beginTransaction(); + try { + onMap = false; + dragging = false; + mapGrid.unSetCursor(pos); + mapGrid.unSelect(); + } finally { + mapGrid.endTransaction(); + } + if (hasChanged) { + fireMapCursorChangedModeEvent(); + fireMapCursorChangedPosEvent(); + } + } + + /** + * Get cursor state. + * @return <code>true</code> if cursor is on the map + */ + public boolean isActive() { + return onMap; + } + + /** + * Get offset from start position of dragging. + * @return offset or <code>null</code> when not in drag mode + */ + @Nullable + public Dimension getDragOffset() { + return dragging ? dragOffset : null; + } + + /** + * Check if point is on grid. + * @param p Coordinates of point + * @return <code>true</code> if <code>p != null</code> and point is on grid + */ + public boolean isOnGrid(@Nullable final Point p) { + return p != null && mapRec.contains(p); + } + + /** + * Moves the cursor one square relative to current position. + * @param dir the direction + * @return <code>true</code> if cursor really moved + * @noinspection TypeMayBeWeakened + */ + public boolean goTo(@NotNull final Direction dir) { + if (onMap) { + tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); + if (dragging) { + return dragTo(tmpPoint); + } else { + return setLocationSafe(tmpPoint); + } + } + return false; + } + + /** + * Returns whether the cursor is currently being dragged. + * @return <code>true</code> if dragging is active, otherwise + * <code>false</code>. + */ + public boolean isDragging() { + return dragging; + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + listenerList.add(listener); + } + + /** + * Remove a MapCursorListener. + * @param listener MapCursorListener to remove + */ + public void removeMapCursorListener(final MapCursorListener listener) { + listenerList.remove(listener); + } + + /** + * Inform all registered listeners that the MapCursor's mode has changed. + */ + private void fireMapCursorChangedModeEvent() { + final MapCursorEvent e = new MapCursorEvent(this); + for (final MapCursorListener listener : listenerList.getListeners()) { + listener.mapCursorChangedMode(e); + } + } + + /** + * Inform all registered listeners that the MapCursor's position has + * changed. + */ + private void fireMapCursorChangedPosEvent() { + final MapCursorEvent e = new MapCursorEvent(this); + for (final MapCursorListener listener : listenerList.getListeners()) { + listener.mapCursorChangedPos(e); + } + } + + /** + * {@inheritDoc} + */ + @Override + public void mapGridChanged(@NotNull final MapGridEvent e) { + // We can ignore this event. Normally this MapCursor has caused it. + } + + /** + * {@inheritDoc} + */ + @Override + public void mapGridResized(@NotNull final MapGridEvent e) { + // Test if drag start point is outside map -> move inside + if (dragging && !mapRec.contains(dragStart)) { + dragStart.x = Math.min(dragStart.x, mapRec.width - 1); + dragStart.y = Math.min(dragStart.y, mapRec.height - 1); + } + // Test if cursor position is outside map -> move inside + if (onMap && !mapRec.contains(pos)) { + pos.x = Math.min(pos.x, mapRec.width - 1); + pos.y = Math.min(pos.y, mapRec.height - 1); + mapGrid.setCursor(pos); + fireMapCursorChangedPosEvent(); + } + } + + /** + * Start a new transaction. Transactions may be nested. Transactions serve + * the purpose of firing events to the views when more changes are known to + * come before the view is really required to update. Each invocation of + * this function requires its own invocation of {@link #endTransaction()}. + */ + public void beginTransaction() { + mapGrid.beginTransaction(); + } + + /** + * End a transaction. Invoking this method will reduce the transaction depth + * by 1. <p/> If the last transaction is ended, the changes are committed. + */ + public void endTransaction() { + mapGrid.endTransaction(); + } + +} // class MapCursor Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursor.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorEvent.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,54 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapcursor; + +import java.util.EventObject; +import org.jetbrains.annotations.NotNull; + +/** + * This Event is created by {@link MapCursor}. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public class MapCursorEvent extends EventObject { + + /** + * The serial version UID. + */ + private static final long serialVersionUID = 1L; + + /** + * Constructs a MapCursorEvent. + * @param source The object on which the Event initially occurred. + * @throws IllegalArgumentException if source is null. + */ + public MapCursorEvent(@NotNull final MapCursor source) { + super(source); + } + + /** + * {@inheritDoc} + */ + @Override + @NotNull + public MapCursor getSource() { + return (MapCursor) super.getSource(); + } + +} // class MapCursorEvent Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorEvent.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java (from rev 8297, trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorListener.java) =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,45 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapcursor; + +import java.util.EventListener; +import org.jetbrains.annotations.NotNull; + +/** + * Interface for listeners listening to {@link MapCursorEvent}s. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public interface MapCursorListener extends EventListener { + + /** + * This event handler is called when {@link MapCursor} has moved, appeared + * or disappeared. + * @param e MapCursorEvent + */ + void mapCursorChangedPos(@NotNull MapCursorEvent e); + + /** + * This event handler is called when {@link MapCursor} changes mode (drag, + * select). + * @param e MapCursorEvent + */ + void mapCursorChangedMode(@NotNull MapCursorEvent e); + +} // interface MapCursorListener Property changes on: trunk/model/src/app/net/sf/gridarta/model/mapcursor/MapCursorListener.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Copied: trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java (from rev 8297, trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java) =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java (rev 0) +++ trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -0,0 +1,503 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.mapcursor; + +import java.awt.Dimension; +import java.awt.Point; +import junit.framework.JUnit4TestAdapter; +import net.sf.gridarta.model.direction.Direction; +import net.sf.gridarta.model.map.grid.MapGrid; +import net.sf.gridarta.model.map.grid.SelectionMode; +import net.sf.gridarta.utils.Size2D; +import org.jetbrains.annotations.NotNull; +import org.junit.Assert; +import org.junit.Test; + +/** + * Unit test for {@link MapCursor}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + * @author Andreas Kirschbaum + */ +public class MapCursorTest { + + /** + * The size of the map grid for the tested cursor. + */ + @NotNull + private static final Size2D gridSize = new Size2D(6, 7); + + /** + * A {@link MapCursorListener} that counts the number of callbacks. + */ + @NotNull + private static final TestMapCursorListener listener = new TestMapCursorListener(); + + /** + * Creates a new {@link MapCursor} instance. No more than one instance may + * exist concurrently. + * @param grid the underlying map grid + * @return the new map cursor instance + */ + @NotNull + public static MapCursor createCursor(@NotNull final MapGrid grid) { + final MapCursor cursor = new MapCursor(grid); + cursor.addMapCursorListener(listener); + Assert.assertFalse("MapCursor has to be disabled when created.", cursor.isActive()); + listener.changedPosCounter = 0; + listener.changedModeCounter = 0; + return cursor; + } + + /** + * Checks that settings the cursor outside of the grid behaves as expected. + */ + @Test + public void setOutside() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(); + for (int i = -2; i < gridSize.getWidth() + 2; i++) { + p.setLocation(i, -1); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + p.setLocation(i, gridSize.getHeight()); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + } + for (int i = -2; i < gridSize.getHeight() + 2; i++) { + p.setLocation(-1, i); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + p.setLocation(gridSize.getWidth(), i); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be disabled after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + Assert.assertNull("getLocation() should return null after setLocation(" + p + ")", cursor.getLocation()); + testEvents(0, 0); + } + } + + /** + * Checks that settings the cursor within the map grid behaves as expected. + */ + @Test + public void setInside() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + boolean first = true; + final Point p = new Point(); + for (int j = 0; j < gridSize.getHeight(); j++) { + for (int i = 0; i < gridSize.getWidth(); i++) { + p.setLocation(i, j); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + if (first) { + // Only the first after activation should fire a change mode event + testEvents(1, 1); + first = false; + } else { + testEvents(1, 0); + } + Assert.assertTrue("MapCursor should be active after setLocation(" + p + ")", cursor.isActive()); + testEvents(0, 0); + final Point res = cursor.getLocation(); + testEvents(0, 0); + Assert.assertEquals("getLocation()", p, res); + } + } + } + + /** + * Checks that settings the cursor to the same location does not generate + * excess events. + */ + @Test + public void setSameLocation() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(-1, -1); + Assert.assertFalse("setLocation(null) should return false", cursor.setLocation(null)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + p.setLocation(3, 4); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + testEvents(1, 1); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocation(" + p + ") should return false", cursor.setLocation(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + p.setLocation(-1, -1); + Assert.assertTrue("setLocation(" + p + ") should return true", cursor.setLocation(p)); + testEvents(1, 1); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + } + + /** + * Checks {@link MapCursor#setLocationSafe(Point)}. + */ + @Test + public void setLocationSafe() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(-1, -1); + Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertFalse("MapCursor should be deactivated", cursor.isActive()); + testEvents(0, 0); + p.setLocation(3, 4); + Assert.assertTrue("setLocationSafe(" + p + ") should return true", cursor.setLocationSafe(p)); + testEvents(1, 1); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + p.setLocation(-1, -1); + Assert.assertFalse("setLocationSafe(" + p + ") should return false", cursor.setLocationSafe(p)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + Assert.assertFalse("setLocationSafe(null) should return false", cursor.setLocationSafe(null)); + testEvents(0, 0); + Assert.assertTrue("MapCursor should be active", cursor.isActive()); + testEvents(0, 0); + } + + /** + * Checks {@link MapCursor#isOnGrid(Point)}. + */ + @Test + public void testIsOnGrid() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point p = new Point(); + for (int j = -2; j < gridSize.getHeight() + 2; j++) { + for (int i = -2; i < gridSize.getWidth() + 2; i++) { + p.setLocation(i, j); + if (i >= 0 && i < gridSize.getWidth() && j >= 0 && j < gridSize.getHeight()) { + Assert.assertTrue(p + " should be on the grid.", cursor.isOnGrid(p)); + } else { + Assert.assertFalse(p + " should not be on the grid.", cursor.isOnGrid(p)); + } + } + } + Assert.assertFalse("Null should not be on the grid.", cursor.isOnGrid(null)); + } + + /** + * Checks {@link MapCursor#goTo(Direction)}. + */ + @Test + public void testGoTo() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + for (final Direction dir : Direction.values()) { + Assert.assertFalse("go(" + dir + ") should return false.", cursor.goTo(dir)); + testEvents(0, 0); + } + final Point pStart = new Point(2, 3); + final Point p = new Point(pStart); + cursor.setLocation(p); + testEvents(1, 1); + for (final Direction dir : Direction.values()) { + Assert.assertTrue("go(" + dir + ") should return true. (Maybe the grid was too small.)", cursor.goTo(dir)); + testEvents(1, 0); + p.x += dir.getDx(); + p.y += dir.getDy(); + Assert.assertEquals("Moving cursor.", p, cursor.getLocation()); + } + Assert.assertEquals("Moving in a circle.", pStart, cursor.getLocation()); + } + + /** + * Checks the dragging related functions of {@link MapCursor}. + */ + @Test + public void dragging() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + cursor.dragStart(); + testEvents(0, 0); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); + final Point dragStart = new Point(3, 4); + final Point p = new Point(dragStart); + final Dimension offset = new Dimension(0, 0); + cursor.setLocation(dragStart); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + cursor.deactivate(); + testEvents(1, 1); + Assert.assertFalse("MapCursor should not drag while deactivated.", cursor.isDragging()); + Assert.assertNull("Drag offset should be null", cursor.getDragOffset()); + cursor.setLocation(dragStart); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + dragTo(cursor, grid, Direction.WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.EAST, dragStart, p, offset); + dragTo(cursor, grid, Direction.EAST, dragStart, p, offset); + dragTo(cursor, grid, Direction.NORTH_WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.SOUTH, dragStart, p, offset); + dragTo(cursor, grid, Direction.SOUTH, dragStart, p, offset); + dragTo(cursor, grid, Direction.WEST, dragStart, p, offset); + dragTo(cursor, grid, Direction.NORTH_EAST, dragStart, p, offset); + } + + /** + * Calls {@link MapCursor#dragTo(Point)} and checks for expected results. + * @param cursor the map cursor to affect + * @param grid the associated map grid + * @param dir the direction to drag + * @param start the starting location + * @param p the destination location + * @param offset the expected dragging offset + */ + private static void dragTo(@NotNull final MapCursor cursor, @NotNull final MapGrid grid, @NotNull final Direction dir, @NotNull final Point start, @NotNull final Point p, @NotNull final Dimension offset) { + final Point d = new Point(dir.getDx(), dir.getDy()); + p.x += d.x; + p.y += d.y; + Assert.assertTrue("dragTo(" + p + ")", cursor.dragTo(p)); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + Assert.assertEquals("Wrong position", p, cursor.getLocation()); + offset.width = p.x - start.x; + offset.height = p.y - start.y; + Assert.assertEquals("Wrong offset", offset, cursor.getDragOffset()); + assertPreSelection(grid, start, p); + } + + /** + * Checks that a {@link MapGrid} includes a rectangle of {@link + * MapGrid#GRID_FLAG_SELECTING}. + * @param grid the map grid to check + * @param start one corner of the rectangle + * @param end the diagonally opposite corner of the rectangle + */ + private static void assertPreSelection(@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + final int height = gridSize.getHeight(); + final int width = gridSize.getWidth(); + for (int j = 0; j < height; j++) { + for (int i = 0; i < width; i++) { + if (i < minX || i > maxX || j < minY || j > maxY) { + //Not preselected + Assert.assertFalse("Pre-selection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); + } else { + //Preselected + Assert.assertTrue("Pre-selection", (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTING) > 0); + } + } + + } + } + + /** + * Checks that a {@link MapGrid} includes a rectangle of {@link + * MapGrid#GRID_FLAG_SELECTION}. Squares outside the rectangle are not + * checked. + * @param grid the map grid to check + * @param start one corner of the rectangle + * @param end the diagonally opposite corner of the rectangle + * @param flag the expected selection state + */ + private static void assertSelection(@NotNull final MapGrid grid, @NotNull final Point start, @NotNull final Point end, final boolean flag) { + final int minX = Math.min(start.x, end.x); + final int maxX = Math.max(start.x, end.x); + final int minY = Math.min(start.y, end.y); + final int maxY = Math.max(start.y, end.y); + for (int j = minY; j <= maxY; j++) { + for (int i = minX; i <= maxX; i++) { + Assert.assertSame("Selection", flag, (grid.getFlags(i, j) & MapGrid.GRID_FLAG_SELECTION) > 0); + } + } + } + + /** + * Checks for correct behavior of {@link MapGrid#GRID_FLAG_SELECTING} flags + * during selecting. + */ + @Test + public void selecting() { + final MapGrid grid = new MapGrid(gridSize); + final MapCursor cursor = createCursor(grid); + final Point start = new Point(2, 3); + final Point end = new Point(4, 5); + final Point gridMaxIndex = new Point(gridSize.getWidth() - 1, gridSize.getHeight() - 1); + cursor.dragRelease(); + testEvents(0, 0); + cursor.setLocation(start); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + cursor.dragRelease(); + testEvents(0, 1); + Assert.assertFalse("MapCursor should not be in drag mode.", cursor.isDragging()); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + cursor.setLocation(null); + testEvents(1, 1); + Assert.assertFalse("MapCursor should not be in drag mode.", cursor.isDragging()); + cursor.setLocation(start); + testEvents(1, 1); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + cursor.dragSelect(SelectionMode.ADD); + testEvents(0, 1); + assertSelection(grid, start, end, true); + //Check if nothing is preselected + assertPreSelection(grid, new Point(-1, -1), new Point(-1, -1)); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.SUB); + testEvents(0, 1); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.FLIP); + testEvents(0, 1); + assertSelection(grid, start, end, true); + start.setLocation(3, 4); + end.setLocation(5, 1); + cursor.setLocation(start); + testEvents(1, 0); + cursor.dragStart(); + testEvents(0, 1); + cursor.dragTo(end); + testEvents(1, 0); + cursor.dragSelect(SelectionMode.FLIP); + testEvents(0, 1); + assertSelection(grid, start, new Point(4, 4), false); + assertSelection(grid, new Point(3, 2), end, true); + assertSelection(grid, new Point(5, 3), new Point(5, 4), true); + cursor.deactivate(); + testEvents(1, 1); + assertSelection(grid, new Point(0, 0), gridMaxIndex, false); + } + + /** + * Checks if the number of events fired is correct. + * @param nPos the expected number of position events + * @param nMode the expected number of mode events + */ + private static void testEvents(final int nPos, final int nMode) { + Assert.assertEquals("Position change event", nPos, listener.changedPosCounter); + listener.changedPosCounter = 0; + Assert.assertEquals("Mode change event", nMode, listener.changedModeCounter); + listener.changedModeCounter = 0; + } + + /** + * Returns a new test suite containing this test. + * @return the new test suite + */ + @NotNull + public static junit.framework.Test suite() { + return new JUnit4TestAdapter(MapCursorTest.class); + } + + /** + * A {@link MapCursorListener} that counts the number of event callbacks. + */ + private static class TestMapCursorListener implements MapCursorListener { + + /** + * The number of calls to {@link #mapCursorChangedPos(MapCursorEvent)}. + */ + private int changedPosCounter = 0; + + /** + * The number of calls to {@link #mapCursorChangedMode(MapCursorEvent)}. + */ + private int changedModeCounter = 0; + + /** + * {@inheritDoc} + */ + @Override + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + changedPosCounter++; + } + + /** + * {@inheritDoc} + */ + @Override + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + changedModeCounter++; + } + + } // class TestMapCursorListener + +} // class MapCursorTest Property changes on: trunk/model/src/test/net/sf/gridarta/model/mapcursor/MapCursorTest.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/exitconnector/ExitConnectorController.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -22,9 +22,6 @@ import java.awt.Point; import javax.swing.Action; import net.sf.gridarta.exitconnector.ExitConnectorActions; -import net.sf.gridarta.gui.map.cursor.MapCursor; -import net.sf.gridarta.gui.map.cursor.MapCursorEvent; -import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewBasic; import net.sf.gridarta.gui.map.mapview.MapViewManager; @@ -35,6 +32,9 @@ import net.sf.gridarta.model.exitconnector.ExitLocation; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.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; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributespanel/ErrorListView.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -37,7 +37,6 @@ import javax.swing.JSplitPane; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewsManager; import net.sf.gridarta.gui.selectedsquare.SelectedSquareView; @@ -53,6 +52,7 @@ import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.map.validation.errors.ValidationError; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/event/MouseOpEvent.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -21,12 +21,12 @@ import java.awt.Point; import java.util.EventObject; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.model.archetype.Archetype; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; +import net.sf.gridarta.model.mapcursor.MapCursor; import org.jetbrains.annotations.NotNull; /** Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -32,9 +32,6 @@ import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.filechooser.FileFilter; -import net.sf.gridarta.gui.map.cursor.MapCursor; -import net.sf.gridarta.gui.map.cursor.MapCursorEvent; -import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; @@ -57,6 +54,9 @@ import net.sf.gridarta.model.map.normalizer.MapPathNormalizer; import net.sf.gridarta.model.map.normalizer.RelativePathOnUnsavedMapException; import net.sf.gridarta.model.map.normalizer.SameMapException; +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.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.ActionUtils; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/mapview/MapViewBasic.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -29,9 +29,6 @@ import java.util.Set; import javax.swing.JScrollPane; import javax.swing.JViewport; -import net.sf.gridarta.gui.map.cursor.MapCursor; -import net.sf.gridarta.gui.map.cursor.MapCursorEvent; -import net.sf.gridarta.gui.map.cursor.MapCursorListener; import net.sf.gridarta.gui.map.renderer.AbstractMapRenderer; import net.sf.gridarta.gui.map.renderer.MapRenderer; import net.sf.gridarta.gui.map.renderer.RendererFactory; @@ -45,6 +42,9 @@ import net.sf.gridarta.model.map.mapmodel.MapSquare; import net.sf.gridarta.model.map.validation.ErrorCollector; import net.sf.gridarta.model.map.validation.errors.ValidationError; +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 net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/DeletionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -28,7 +28,6 @@ import java.util.HashSet; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; @@ -39,6 +38,7 @@ import net.sf.gridarta.model.map.mapcontrol.MapControl; import net.sf.gridarta.model.map.mapmodel.MapModel; import net.sf.gridarta.model.map.mapmodel.MapSquare; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.match.GameObjectMatcher; import net.sf.japi.swing.action.ActionBuilder; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/InsertionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -26,7 +26,6 @@ import java.awt.Point; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.pickmapchooser.PickmapChooserControl; @@ -41,6 +40,7 @@ import net.sf.gridarta.model.map.mapmodel.InsertionMode; import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; import net.sf.gridarta.model.map.mapmodel.MapModel; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import org.jetbrains.annotations.NotNull; Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-06-09 08:05:51 UTC (rev 8298) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -27,7 +27,6 @@ import java.awt.event.InputEvent; import javax.swing.JComboBox; import javax.swing.JPanel; -import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.objectchooser.ObjectChooser; @@ -39,6 +38,7 @@ import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.InsertionMode; import net.sf.gridarta.model.map.mapmodel.InsertionModeSet; +import net.sf.gridarta.model.mapcursor.MapCursor; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; Deleted: trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 23:45:41 UTC (rev 8297) +++ trunk/src/app/net/sf/gridarta/gui/mapcursor/MapCursor.java 2010-06-09 08:07:22 UTC (rev 8299) @@ -1,424 +0,0 @@ -/* - * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. - * Copyright (C) 2000-2010 The Gridarta Developers. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -package net.sf.gridarta.gui.map.cursor; - -import java.awt.Dimension; -import java.awt.Point; -import java.awt.Rectangle; -import net.sf.gridarta.model.direction.Direction; -import net.sf.gridarta.model.map.grid.MapGrid; -import net.sf.gridarta.model.map.grid.MapGridEvent; -import net.sf.gridarta.model.map.grid.MapGridListener; -import net.sf.gridarta.model.map.grid.SelectionMode; -import net.sf.gridarta.utils.EventListenerList2; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -/** - * MapCursor provides methods to move and drag on map. The MapCursor is bound to - * a {@link MapGrid} which will change it flags depending on MapCursor - * movement/selection. <p/> There are three different states for MapCursor: <ul> - * <li>Deactivated</li> <li>On the map</li> <li>Dragging</li> </ul> When - * coordinates or state of MapCursor changes a {@link MapCursorEvent} is fired. - * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> - */ -public class MapCursor implements MapGridListener { - - /** - * Current cursor position. When cursor is active it is highlighted on the - * MapGrid. - */ - private final Point pos = new Point(); - - /** - * Position where dragging has started. - */ - private final Point dragStart = new Point(); - - /** - * Offset of dragging. (0, 0) when drag is on the starting position. - */ - private final Dimension dragOffset = new Dimension(); - - /** - * Whether the cursor is currently on map. - */ - private boolean onMap; - - /** - * Gets set to <code>true</code> when in drag mode. - */ - private boolean dragging; - - /** - * Grid where cursor is bound to. - */ - private final MapGrid mapGrid; - - /** - * Used to test if coordinates are on the map. Created by MapGrid. - */ - private final Rectangle mapRec; - - /** - * Temporary point used in some methods. Placed as instance var to prevent - * creation of temporary objects. - */ - private final Point tmpPoint = new Point(); - - /** - * The MapCursorListeners to inform of changes. - */ - private final EventListenerList2<MapCursorListener> listenerList = new EventListenerList2<MapCursorListener>(MapCursorListener.class); - - /** - * Construct a MapCursor. The cursor will be deactivated after - * construction. - * @param mapGrid Cursor is bound to this grid - */ - public MapCursor(final MapGrid mapGrid) { - this.mapGrid = mapGrid; - mapRec = mapGrid.getMapRec(); - mapGrid.addMapGridListener(this); - deactivate(); - } - - /** - * Get position of cursor. - * @return coordinates of cursor or <code>null</code> if cursor is not - * active - */ - @Nullable - public Point getLocation() { - return onMap ? pos : null; - } - - /** - * Move cursor to a new location. If new location is not on map, cursor gets - * disabled. - * @param p New location. If <code>p == null</code> cursor gets disabled - * @return <code>true</code> if cursor position changed or if it gets - * disabled - */ - public boolean setLocation(@Nullable final Point p) { - mapGrid.beginTransaction(); - try { - final boolean hasChanged; - if (p != null && mapRec.contains(p)) { - if (onMap) { - if (pos.equals(p)) { - hasChanged = false; - } else { - mapGrid.unSetCursor(pos); - pos.setLocation(p); - mapGrid.setCursor(pos); - fireMapCursorChangedPosEvent(); - hasChanged = true; - } - } else { - pos.setLocation(p); - mapGrid.setCursor(pos); - onMap = true; - fireMapCursorChangedModeEvent(); - fireMapCursorChangedPosEvent(); - hasChanged = true; - } - } else if (onMap) { - deactivate(); - hasChanged = true; - } else { - hasChanged = false; - } - return hasChanged; - } finally { - mapGrid.endTransaction(); - } - } - - /** - * Move cursor to a new location. If new location is not on map, cursor does - * not change. - * @param p New location. If <code>p == null</code> nothing happens - * @return <code>true</code> if cursor position changed - */ - public boolean setLocationSafe(@Nullable final Point p) { - mapGrid.beginTransaction(); - final boolean hasChanged; - try { - if (p != null && mapRec.contains(p)) { - if (onMap) { - if (pos.equals(p)) { - hasChanged = false; - } else { - mapGrid.unSetCursor(pos); - pos.setLocation(p); - mapGrid.setCursor(pos); - hasChanged = true; - } - } else { - pos.setLocation(p); - onMap = true; - fireMapCursorChangedModeEvent(); - hasChanged = true; - } - } else { - ... [truncated message content] |
From: <aki...@us...> - 2010-06-09 08:05:58
|
Revision: 8298 http://gridarta.svn.sourceforge.net/gridarta/?rev=8298&view=rev Author: akirschbaum Date: 2010-06-09 08:05:51 +0000 (Wed, 09 Jun 2010) Log Message: ----------- Remove unused import statement. Modified Paths: -------------- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 23:45:41 UTC (rev 8297) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-09 08:05:51 UTC (rev 8298) @@ -90,7 +90,6 @@ import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; import net.sf.gridarta.script.parameter.PluginParameterFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.ConfigFileUtils; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.SystemIcons; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:45:47
|
Revision: 8297 http://gridarta.svn.sourceforge.net/gridarta/?rev=8297&view=rev Author: akirschbaum Date: 2010-06-08 23:45:41 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Remove redundant condition. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/preferences/Storage.java Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:45:12 UTC (rev 8296) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:45:41 UTC (rev 8297) @@ -304,7 +304,7 @@ break; } final String line = Codec.decode(line2.trim()); - if (line == null || line.startsWith("#") || line.length() == 0) { + if (line.startsWith("#") || line.length() == 0) { continue; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:45:20
|
Revision: 8296 http://gridarta.svn.sourceforge.net/gridarta/?rev=8296&view=rev Author: akirschbaum Date: 2010-06-08 23:45:12 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Extract code into function. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/preferences/Storage.java Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:42:53 UTC (rev 8295) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:45:12 UTC (rev 8296) @@ -272,35 +272,9 @@ try { final InputStreamReader isr = new InputStreamReader(fis, "UTF-8"); try { - String path = defaultPath; final LineNumberReader lnr = new LineNumberReader(isr); try { - while (true) { - final String line2 = lnr.readLine(); - if (line2 == null) { - break; - } - final String line = Codec.decode(line2.trim()); - if (line == null || line.startsWith("#") || line.length() == 0) { - continue; - } - - if (line.startsWith("[") && line.endsWith("]")) { - path = line.substring(1, line.length() - 1); - continue; - } - - final String[] tmp = line.split("=", 2); - if (tmp.length != 2) { - log.warn(file + ":" + lnr.getLineNumber() + ": syntax error"); - continue; - } - final String key = tmp[0]; - final String value = tmp[1]; - - newNode(path); - putValue(path, key, value); - } + loadValues(lnr); } finally { lnr.close(); } @@ -318,6 +292,41 @@ } /** + * Load the values from a {@link LineNumberReader}. + * @param lnr the line number reader + * @throws IOException if an I/O error occurs + */ + private void loadValues(@NotNull final LineNumberReader lnr) throws IOException { + String path = defaultPath; + while (true) { + final String line2 = lnr.readLine(); + if (line2 == null) { + break; + } + final String line = Codec.decode(line2.trim()); + if (line == null || line.startsWith("#") || line.length() == 0) { + continue; + } + + if (line.startsWith("[") && line.endsWith("]")) { + path = line.substring(1, line.length() - 1); + continue; + } + + final String[] tmp = line.split("=", 2); + if (tmp.length != 2) { + log.warn(file + ":" + lnr.getLineNumber() + ": syntax error"); + continue; + } + final String key = tmp[0]; + final String value = tmp[1]; + + newNode(path); + putValue(path, key, value); + } + } + + /** * Save the values to the backing file. * @throws IOException if the values cannot be saved */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:42:59
|
Revision: 8295 http://gridarta.svn.sourceforge.net/gridarta/?rev=8295&view=rev Author: akirschbaum Date: 2010-06-08 23:42:53 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Suppress warnings. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java trunk/src/app/net/sf/gridarta/preferences/Storage.java Modified: trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java 2010-06-08 23:41:08 UTC (rev 8294) +++ trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java 2010-06-08 23:42:53 UTC (rev 8295) @@ -113,6 +113,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void flush() throws BackingStoreException { @@ -125,6 +126,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Nullable @Override @@ -138,6 +140,7 @@ throw new IllegalStateException("removed node"); } + //noinspection CatchGenericClass try { final String value = getSpi(key); if (value != null) { @@ -275,6 +278,7 @@ /** * {@inheritDoc} + * @noinspection RefusedBequest */ @Override public void sync() throws BackingStoreException { Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:41:08 UTC (rev 8294) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:42:53 UTC (rev 8295) @@ -357,6 +357,7 @@ fos.close(); } + //noinspection ResultOfMethodCallIgnored file.delete(); // Windows cannot overwrite destination file on rename if (!tmpFile.renameTo(file)) { throw new IOException("cannot rename " + tmpFile + " to " + file); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:41:14
|
Revision: 8294 http://gridarta.svn.sourceforge.net/gridarta/?rev=8294&view=rev Author: akirschbaum Date: 2010-06-08 23:41:08 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Rename variable names. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java trunk/src/app/net/sf/gridarta/preferences/Storage.java Modified: trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java 2010-06-08 23:36:45 UTC (rev 8293) +++ trunk/src/app/net/sf/gridarta/preferences/FilePreferences.java 2010-06-08 23:41:08 UTC (rev 8294) @@ -143,7 +143,7 @@ if (value != null) { return value; } - } catch (final Exception e) { + } catch (final Exception ignored) { // ignore } Modified: trunk/src/app/net/sf/gridarta/preferences/Storage.java =================================================================== --- trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:36:45 UTC (rev 8293) +++ trunk/src/app/net/sf/gridarta/preferences/Storage.java 2010-06-08 23:41:08 UTC (rev 8294) @@ -310,7 +310,7 @@ } finally { fis.close(); } - } catch (final FileNotFoundException ex) { + } catch (final FileNotFoundException ignored) { // ignore } catch (final IOException ex) { log.warn(file + ": " + ex.getMessage()); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 23:36:53
|
Revision: 8293 http://gridarta.svn.sourceforge.net/gridarta/?rev=8293&view=rev Author: akirschbaum Date: 2010-06-08 23:36:45 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Replace int constants with enum. Modified Paths: -------------- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java trunk/src/app/net/sf/gridarta/gui/misc/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/shrinkmapsizedialog/ShrinkMapSizeDialog.java trunk/src/app/net/sf/gridarta/gui/utils/DirectionLayout.java trunk/src/app/net/sf/gridarta/mainactions/MainActions.java trunk/src/app/net/sf/gridarta/maincontrol/DefaultMainControl.java trunk/src/app/net/sf/gridarta/maincontrol/GUIMainControl.java trunk/src/app/net/sf/gridarta/validation/checks/TilePathsChecker.java trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java Added Paths: ----------- trunk/model/src/app/net/sf/gridarta/model/direction/ trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/IGUIConstants.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.atrinik; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.SystemIcons; /** @@ -37,13 +36,6 @@ int DEF_MAPDIFFICULTY = 1; /** - * All tile paths in an array, e.g. for iterations. This doesn't make sense - * at first sight, but this way iterating code is independent of the - * definition of the tile path values. - */ - int[] ALL_TILE_PATHS = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Default map size (both height and width). */ int DEF_MAPSIZE = 24; Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -60,6 +60,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -97,7 +98,6 @@ import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; import net.sf.gridarta.script.parameter.PluginParameterFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; @@ -539,7 +539,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "AtrinikEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java =================================================================== --- trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/atrinik/src/app/net/sf/gridarta/var/atrinik/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.atrinik.model.maparchobject.MapArchObject; @@ -103,9 +104,9 @@ if (mapArchObject.isPlugins()) { appendable.append("plugins 1\n"); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.getTilesetId() != 0) { Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -55,6 +55,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCollector; import net.sf.gridarta.model.exitconnector.ExitConnectorModel; @@ -406,7 +407,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new int[] { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.pythonFileFilter, ".py", false, mapManager, pickmapManager, archetypeSet, mapControlFactory, null, "CrossfireEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_TRIGGER_ALTAR, Archetype.TYPE_DETECTOR, Archetype.TYPE_TRIGGER_MARKER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, null, this, errorView, new DirectoryCacheFiles(ConfigFileUtils.getHomeFile("thumbnails"), ".png"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, 0, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, true, scriptedEventEditor, new Direction[] { Direction.NORTH, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java =================================================================== --- trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/crossfire/src/app/net/sf/gridarta/var/crossfire/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -22,6 +22,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.crossfire.model.maparchobject.MapArchObject; @@ -133,9 +134,9 @@ if (mapArchObject.getSky() != 0) { format.format("sky %d\n", mapArchObject.getSky()); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.isNoSmooth()) { Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/IGUIConstants.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,7 +20,6 @@ package net.sf.gridarta.var.daimonin; import net.sf.gridarta.gui.utils.GUIConstants; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.SystemIcons; /** @@ -37,13 +36,6 @@ int DEF_MAPDIFFICULTY = 1; /** - * All tile paths in an array, e.g. for iterations. This doesn't make sense - * at first sight, but this way iterating code is independent of the - * definition of the tile path values. - */ - int[] ALL_TILE_PATHS = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Default map size (both height and width). */ int DEF_MAPSIZE = 24; Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/maincontrol/DefaultEditorFactory.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -60,6 +60,7 @@ import net.sf.gridarta.model.archetypetype.ArchetypeTypeSet; import net.sf.gridarta.model.autojoin.AutojoinLists; import net.sf.gridarta.model.configsource.ConfigSourceFactory; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.errorview.ErrorView; import net.sf.gridarta.model.errorview.ErrorViewCategory; import net.sf.gridarta.model.errorview.ErrorViewCollector; @@ -97,7 +98,6 @@ import net.sf.gridarta.script.ScriptModel; import net.sf.gridarta.script.ScriptParameters; import net.sf.gridarta.script.parameter.PluginParameterFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.GUIUtils; import net.sf.gridarta.utils.IOUtils; import net.sf.gridarta.utils.StringUtils; @@ -540,7 +540,7 @@ @NotNull @Override public GUIMainControl<GameObject, MapArchObject, Archetype> createGUIMainControl(@NotNull final DefaultMainControl<GameObject, MapArchObject, Archetype> mainControl, @NotNull final ErrorView errorView, @NotNull final GUIUtils guiUtils, @NotNull final ConfigSourceFactory configSourceFactory, @NotNull final RendererFactory<GameObject, MapArchObject, Archetype> rendererFactory, @NotNull final FilterControl<GameObject, MapArchObject, Archetype> filterControl, @NotNull final ScriptExecutor<GameObject, MapArchObject, Archetype> scriptExecutor, @NotNull final ScriptParameters scriptParameters, @NotNull final AbstractMapManager<GameObject, MapArchObject, Archetype> mapManager, @NotNull final MapManager<GameObject, MapArchObject, Archetype> pickmapManager, @NotNull final MapControlFactory<GameObject, MapArchObject, Archetype> mapControlFactory, @NotNull final net.sf.gridarta.model.archetype.ArchetypeSet<GameObject, MapArchObject, Archetype> archetypeSet, @NotNull final FaceObjects faceObjects, @NotNull final GlobalSettings globalSettings, @NotNull final MapViewSettings mapViewSettings, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final PathManager pathManager, @NotNull final InsertionMode<GameObject, MapArchObject, Archetype> topmostInsertionMode, @NotNull final GameObjectFactory<GameObject, MapArchObject, Archetype> gameObjectFactory, @NotNull final SystemIcons systemIcons, @NotNull final ArchetypeTypeSet archetypeTypeSet, @NotNull final MapArchObjectFactory<MapArchObject> mapArchObjectFactory, @NotNull final DefaultMapReaderFactory<GameObject, MapArchObject, Archetype> mapReaderFactory, @NotNull final DelegatingMapValidator<GameObject, MapArchObject, Archetype> validators, @NotNull final GameObjectMatchers gameObjectMatchers, @NotNull final ScriptModel<GameObject, MapArchObject, Archetype> scriptModel, @NotNull final AnimationObjects animationObjects, @NotNull final ArchetypeChooserModel<GameObject, MapArchObject, Archetype> archetypeChooserModel, @NotNull final ScriptedEventEditor<GameObject, MapArchObject, Archetype> scriptedEventEditor, @NotNull final AbstractResources<GameObject, MapArchObject, Archetype> resources, @NotNull final Spells<NumberSpell> numberSpells, @NotNull final Spells<GameObjectSpell<GameObject, MapArchObject, Archetype>> gameObjectSpells, @NotNull final AttributeRangeChecker<GameObject, MapArchObject, Archetype> attributeRangeChecker, @NotNull final PluginParameterFactory<GameObject, MapArchObject, Archetype> pluginParameterFactory) { - return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new int[] { CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); + return mainControl.createGUIMainControl(FileFilters.luaFileFilter, ".lua", true, mapManager, pickmapManager, archetypeSet, mapControlFactory, guiUtils.getResourceIcon(IGUIConstants.TILE_NORTH), "DaimoninEditor.jar", new int[] { Archetype.TYPE_LOCKED_DOOR, Archetype.TYPE_SPECIAL_KEY, Archetype.TYPE_ALTAR_TRIGGER, Archetype.TYPE_MARKER, Archetype.TYPE_INVENTORY_CHECKER, Archetype.TYPE_SPAWN_POINT, Archetype.TYPE_CONTAINER, }, PREFERENCES_VALIDATOR_AUTO_DEFAULT, IGUIConstants.SPELL_FILE, this, errorView, new SubDirectoryCacheFiles(".dedit"), configSourceFactory, rendererFactory, filterControl, scriptExecutor, scriptParameters, faceObjects, globalSettings, mapViewSettings, faceObjectProviders, pathManager, topmostInsertionMode, gameObjectFactory, systemIcons, -1, archetypeTypeSet, mapArchObjectFactory, mapReaderFactory, validators, gameObjectMatchers, IGUIConstants.SCRIPTS_DIR, scriptModel, animationObjects, archetypeChooserModel, false, scriptedEventEditor, new Direction[] { Direction.NORTH_EAST, Direction.SOUTH_EAST, Direction.SOUTH_WEST, Direction.NORTH_WEST, Direction.EAST, Direction.SOUTH, Direction.WEST, Direction.NORTH, }, resources, gameObjectSpells, numberSpells, attributeRangeChecker, pluginParameterFactory); } /** Modified: trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java =================================================================== --- trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/daimonin/src/app/net/sf/gridarta/var/daimonin/model/io/MapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.IOException; import java.util.Formatter; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.io.AbstractMapArchObjectParser; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.var.daimonin.model.maparchobject.MapArchObject; @@ -100,9 +101,9 @@ if (mapArchObject.isPvp()) { appendable.append("pvp 1\n"); } - for (int i = 0; i < 8; i++) { - if (mapArchObject.getTilePath(i).length() > 0) { - format.format("tile_path_%d %s\n", i + 1, mapArchObject.getTilePath(i)); + for (final Direction direction : Direction.values()) { + if (mapArchObject.getTilePath(direction).length() > 0) { + format.format("tile_path_%d %s\n", direction.ordinal() + 1, mapArchObject.getTilePath(direction)); } } if (mapArchObject.getTilesetId() != 0) { Added: trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java (rev 0) +++ trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -0,0 +1,104 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2010 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.model.direction; + +/** + * A direction. + * @author Andreas Kirschbaum + */ +public enum Direction { + + /** + * North. + */ + NORTH(0, -1), + + /** + * East. + */ + EAST(1, 0), + + /** + * South. + */ + SOUTH(0, 1), + + /** + * West. + */ + WEST(-1 , 0), + + /** + * North east. + */ + NORTH_EAST(1, -1), + + /** + * South east. + */ + SOUTH_EAST(1, 1), + + /** + * South west. + */ + SOUTH_WEST(-1, 1), + + /** + * North west. + */ + NORTH_WEST(-1, -1); + + /** + * The relative x direction. + */ + private final int dx; + + /** + * The relative y direction. + */ + private final int dy; + + /** + * Creates a new instance. + * @param dx the relative x direction + * @param dy the relative y direction + */ + Direction(final int dx, final int dy) { + this.dx = dx; + this.dy = dy; + } + + /** + * Returns the relative x direction. + * @return the relative x direction + */ + public int getDx() { + return dx; + } + + /** + * Returns the relative y direction. + * @return the relative y direction + */ + public int getDy() { + return dy; + } + +} // enum Direction Property changes on: trunk/model/src/app/net/sf/gridarta/model/direction/Direction.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/io/AbstractMapArchObjectParser.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.io.BufferedReader; import java.io.IOException; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.NumberUtils; import net.sf.gridarta.utils.Size2D; @@ -105,8 +106,8 @@ // get tile path try { final int i = Integer.valueOf(line.substring(10, 11)); - if (i > 0 && i <= mapArchObject.getTilePaths() && line.length() >= 12 && line.charAt(11) == ' ') { - mapArchObject.setTilePath(i - 1, line.substring(12)); + if (i > 0 && i <= Direction.values().length && line.length() >= 12 && line.charAt(11) == ' ') { + mapArchObject.setTilePath(Direction.values()[i - 1], line.substring(12)); } else { throw new InvalidMapFormatException("unexpected map attribute: '" + line + "'"); } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/AbstractMapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pattern; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.EventListenerList2; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -124,7 +125,7 @@ * The map tile paths used for map tiling. 0 = north, 1 = east, 2 = south, 3 * = west. 4 = northeast, 5 = southeast, 6 = southwest, 7 = northwest */ - private String[] tilePaths = new String[8]; + private String[] tilePaths = new String[Direction.values().length]; /** * The registered event listeners. @@ -393,20 +394,20 @@ */ @NotNull @Override - public String getTilePath(final int direction) { - return tilePaths[direction]; + public String getTilePath(@NotNull final Direction direction) { + return tilePaths[direction.ordinal()]; } /** * {@inheritDoc} */ @Override - public void setTilePath(final int direction, @NotNull final String tilePath) { - if (tilePaths[direction].equals(tilePath)) { + public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { + if (tilePaths[direction.ordinal()].equals(tilePath)) { return; } - tilePaths[direction] = tilePath; + tilePaths[direction.ordinal()] = tilePath; setModified(); } @@ -427,8 +428,8 @@ setDifficulty(abstractMapArchObject.difficulty); setFixedReset(abstractMapArchObject.fixedReset); setDarkness(abstractMapArchObject.darkness); - for (int i = 0; i < tilePaths.length; i++) { - setTilePath(i, abstractMapArchObject.tilePaths[i]); + for (final Direction direction : Direction.values()) { + setTilePath(direction, abstractMapArchObject.tilePaths[direction.ordinal()]); } } Modified: trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/maparchobject/MapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -21,6 +21,7 @@ import java.awt.Point; import java.io.Serializable; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -184,14 +185,14 @@ * @return The tile path. */ @NotNull - String getTilePath(int direction); + String getTilePath(@NotNull Direction direction); /** * Set a tile path. * @param direction The tile path direction. * @param tilePath The new tile path. */ - void setTilePath(int direction, @NotNull String tilePath); + void setTilePath(@NotNull Direction direction, @NotNull String tilePath); /** * Create a copy of this object. Modified: trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/tiles/MapLink.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -19,25 +19,32 @@ package net.sf.gridarta.model.map.tiles; +import net.sf.gridarta.model.direction.Direction; +import org.jetbrains.annotations.NotNull; + /** * @author Andreas Kirschbaum */ public class MapLink { - private final int mapDirection; + @NotNull + private final Direction mapDirection; - private final int linkDirection; + @NotNull + private final Direction linkDirection; - public MapLink(final int mapDirection, final int linkDirection) { + public MapLink(@NotNull final Direction mapDirection, @NotNull final Direction linkDirection) { this.mapDirection = mapDirection; this.linkDirection = linkDirection; } - public int getMapDirection() { + @NotNull + public Direction getMapDirection() { return mapDirection; } - public int getLinkDirection() { + @NotNull + public Direction getLinkDirection() { return linkDirection; } Modified: trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java =================================================================== --- trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/app/net/sf/gridarta/model/map/tiles/TileLink.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -19,6 +19,7 @@ package net.sf.gridarta.model.map.tiles; +import net.sf.gridarta.model.direction.Direction; import org.jetbrains.annotations.NotNull; /** @@ -35,13 +36,14 @@ /** * Direction for reverse map linking. */ - private final int revLink; + @NotNull + private final Direction revLink; /** * Creates a new instance. * @param revLink direction for reverse map linking */ - public TileLink(@NotNull final String name, @NotNull final MapLink[] mapLinks, final int revLink) { + public TileLink(@NotNull final String name, @NotNull final MapLink[] mapLinks, @NotNull final Direction revLink) { this.name = name; this.mapLinks = mapLinks; this.revLink = revLink; @@ -61,7 +63,8 @@ * Returns the index for reverse map linking. * @return the index */ - public int getRevLink() { + @NotNull + public Direction getRevLink() { return revLink; } Modified: trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java =================================================================== --- trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/model/src/test/net/sf/gridarta/model/map/maparchobject/TestMapArchObject.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -20,6 +20,7 @@ package net.sf.gridarta.model.map.maparchobject; import java.awt.Point; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -236,7 +237,7 @@ */ @NotNull @Override - public String getTilePath(final int direction) { + public String getTilePath(@NotNull final Direction direction) { throw new AssertionError(); } @@ -244,7 +245,7 @@ * {@inheritDoc} */ @Override - public void setTilePath(final int direction, @NotNull final String tilePath) { + public void setTilePath(@NotNull final Direction direction, @NotNull final String tilePath) { throw new AssertionError(); } Modified: trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java =================================================================== --- trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/actions/AttachTiledMaps.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -24,6 +24,7 @@ import java.util.regex.Matcher; import net.sf.gridarta.mapmanager.MapManager; 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.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapcontrol.MapControl; @@ -182,12 +183,12 @@ final TileLink tileLink = tileLinks[i]; final MapLink[] mapLinks = tileLink.getMapLinks(); for (final MapLink mapLink : mapLinks) { - final int index = mapLink.getMapDirection(); - if (mapControls[index] == null) { + final Direction direction = mapLink.getMapDirection(); + if (mapControls[direction.ordinal()] == null) { final String tilePath = mapControl.getMapModel().getMapArchObject().getTilePath(mapLink.getLinkDirection()); if (tilePath.length() > 0) { try { - mapControls[index] = loadMapControl(mapControl.getMapModel(), tilePath); + mapControls[direction.ordinal()] = loadMapControl(mapControl.getMapModel(), tilePath); repeatFlag = true; } catch (final IOException ex) { throw new CannotLoadMapFileException(tilePath, ex); Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -22,6 +22,7 @@ import java.awt.Dimension; import java.awt.Point; import java.awt.Rectangle; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.map.grid.MapGrid; import net.sf.gridarta.model.map.grid.MapGridEvent; import net.sf.gridarta.model.map.grid.MapGridListener; @@ -77,19 +78,6 @@ private final Rectangle mapRec; /** - * Relative coordinates of directions. - */ - public static final int[][] direction = { { 0, -1 }, // N - { 1, 0 }, // E - { 0, 1 }, // S - { -1, 0 }, // W - { 1, -1 }, // NE - { 1, 1 }, // SE - { -1, 1 }, // SW - { -1, -1 } // NW - }; - - /** * Temporary point used in some methods. Placed as instance var to prevent * creation of temporary objects. */ @@ -326,13 +314,13 @@ /** * Moves the cursor one square relative to current position. - * @param dir Index of {@link #direction} + * @param dir the direction * @return <code>true</code> if cursor really moved + * @noinspection TypeMayBeWeakened */ - public boolean goTo(final int dir) { - assert dir >= 0 && dir < 8; + public boolean goTo(@NotNull final Direction dir) { if (onMap) { - tmpPoint.setLocation(pos.x + direction[dir][0], pos.y + direction[dir][1]); + tmpPoint.setLocation(pos.x + dir.getDx(), pos.y + dir.getDy()); if (dragging) { return dragTo(tmpPoint); } else { Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -31,11 +31,11 @@ import net.sf.gridarta.gui.selectedsquare.SelectedSquareControl; import net.sf.gridarta.gui.selectedsquare.SelectedSquareModel; 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.map.grid.SelectionMode; import net.sf.gridarta.model.map.maparchobject.MapArchObject; import net.sf.gridarta.utils.ActionUtils; -import net.sf.gridarta.utils.CommonConstants; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -221,7 +221,7 @@ */ @ActionMethod public void goNorth() { - doGo(true, CommonConstants.NORTH); + doGo(true, Direction.NORTH); } /** @@ -229,7 +229,7 @@ */ @ActionMethod public void goSouth() { - doGo(true, CommonConstants.SOUTH); + doGo(true, Direction.SOUTH); } /** @@ -237,7 +237,7 @@ */ @ActionMethod public void goEast() { - doGo(true, CommonConstants.EAST); + doGo(true, Direction.EAST); } /** @@ -245,7 +245,7 @@ */ @ActionMethod public void goWest() { - doGo(true, CommonConstants.WEST); + doGo(true, Direction.WEST); } /** @@ -253,7 +253,7 @@ */ @ActionMethod public void goNorthEast() { - doGo(true, CommonConstants.NORTH_EAST); + doGo(true, Direction.NORTH_EAST); } /** @@ -261,7 +261,7 @@ */ @ActionMethod public void goNorthWest() { - doGo(true, CommonConstants.NORTH_WEST); + doGo(true, Direction.NORTH_WEST); } /** @@ -269,7 +269,7 @@ */ @ActionMethod public void goSouthEast() { - doGo(true, CommonConstants.SOUTH_EAST); + doGo(true, Direction.SOUTH_EAST); } /** @@ -277,7 +277,7 @@ */ @ActionMethod public void goSouthWest() { - doGo(true, CommonConstants.SOUTH_WEST); + doGo(true, Direction.SOUTH_WEST); } /** @@ -395,7 +395,7 @@ * Enable/disable menu entries based on the current cursor state. */ private void refreshActions() { - final boolean goEnabled = doGo(false, CommonConstants.NORTH); + final boolean goEnabled = doGo(false, Direction.NORTH); for (final Action action : aGo) { action.setEnabled(goEnabled); } @@ -423,7 +423,7 @@ * @param direction the direction to go * @return whether the action was or can be performed */ - private boolean doGo(final boolean performAction, final int direction) { + private boolean doGo(final boolean performAction, @NotNull final Direction direction) { final MapCursor mapCursor = getActiveMapCursor(); if (mapCursor == null) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/mapactions/MapActions.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -46,6 +46,7 @@ import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.mapmanager.MapManagerListener; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.exitconnector.ExitMatcher; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridarta.model.map.maparchobject.MapArchObject; @@ -59,7 +60,6 @@ import net.sf.gridarta.model.mapviewsettings.MapViewSettings; import net.sf.gridarta.model.mapviewsettings.MapViewSettingsListener; import net.sf.gridarta.utils.ActionUtils; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; @@ -86,12 +86,6 @@ private final String[] directionsMap = { "enterNorthMap", "enterEastMap", "enterSouthMap", "enterWestMap", "enterNorthEastMap", "enterSouthEastMap", "enterSouthWestMap", "enterNorthWestMap" }; /** - * Possible directions for "enter xxx map". - */ - @NotNull - private final int[] directionsDir = { CommonConstants.NORTH, CommonConstants.EAST, CommonConstants.SOUTH, CommonConstants.WEST, CommonConstants.NORTH_EAST, CommonConstants.SOUTH_EAST, CommonConstants.SOUTH_WEST, CommonConstants.NORTH_WEST }; - - /** * Action for "grid visible". */ @NotNull @@ -215,7 +209,7 @@ * Maps map relative direction to map window direction. */ @NotNull - private final int[] directionMap; + private final Direction[] directionMap; /** * Whether exit paths may point to random maps. @@ -405,7 +399,7 @@ * @param mapViewsManager the map views * @param fileControl the file control */ - public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final int[] directionMap, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapPathNormalizer mapPathNormalizer, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final FileControl<G, A, R> fileControl) { + public MapActions(@NotNull final Component parent, @NotNull final JFrame helpParent, @NotNull final MapManager<G, A, R> mapManager, @NotNull final MapViewManager<G, A, R> mapViewManager, final ExitMatcher<G, A, R> exitMatcher, final FileFilter mapFileFilter, @NotNull final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull final Direction[] directionMap, final boolean allowRandomMapParameters, @NotNull final MapPropertiesDialogFactory<G, A, R> mapPropertiesDialogFactory, @NotNull final MapViewSettings mapViewSettings, @NotNull final MapPathNormalizer mapPathNormalizer, @NotNull final MapViewsManager<G, A, R> mapViewsManager, @NotNull final FileControl<G, A, R> fileControl) { this.parent = parent; this.helpParent = helpParent; this.exitMatcher = exitMatcher; @@ -633,7 +627,7 @@ */ @ActionMethod public void enterNorthMap() { - doEnterMap(true, CommonConstants.NORTH); + doEnterMap(true, Direction.NORTH); } /** @@ -641,7 +635,7 @@ */ @ActionMethod public void enterNorthEastMap() { - doEnterMap(true, CommonConstants.NORTH_EAST); + doEnterMap(true, Direction.NORTH_EAST); } /** @@ -649,7 +643,7 @@ */ @ActionMethod public void enterEastMap() { - doEnterMap(true, CommonConstants.EAST); + doEnterMap(true, Direction.EAST); } /** @@ -657,7 +651,7 @@ */ @ActionMethod public void enterSouthEastMap() { - doEnterMap(true, CommonConstants.SOUTH_EAST); + doEnterMap(true, Direction.SOUTH_EAST); } /** @@ -665,7 +659,7 @@ */ @ActionMethod public void enterSouthMap() { - doEnterMap(true, CommonConstants.SOUTH); + doEnterMap(true, Direction.SOUTH); } /** @@ -673,7 +667,7 @@ */ @ActionMethod public void enterSouthWestMap() { - doEnterMap(true, CommonConstants.SOUTH_WEST); + doEnterMap(true, Direction.SOUTH_WEST); } /** @@ -681,7 +675,7 @@ */ @ActionMethod public void enterWestMap() { - doEnterMap(true, CommonConstants.WEST); + doEnterMap(true, Direction.WEST); } /** @@ -689,7 +683,7 @@ */ @ActionMethod public void enterNorthWestMap() { - doEnterMap(true, CommonConstants.NORTH_WEST); + doEnterMap(true, Direction.NORTH_WEST); } /** @@ -709,7 +703,7 @@ * 0|0 if unknown, and note that the point gets modified) * @return whether the destination map has been entered */ - private boolean enterMap(@NotNull final MapView<G, A, R> currentMapView, @NotNull final String path, final int direction, @Nullable final Point destinationPoint) { + private boolean enterMap(@NotNull final MapView<G, A, R> currentMapView, @NotNull final String path, @NotNull final Direction direction, @Nullable final Point destinationPoint) { final File canonicalNewFile; try { canonicalNewFile = mapPathNormalizer.normalizeMapPath(currentMapView.getMapControl().getMapModel(), path); @@ -787,8 +781,8 @@ aNextExit.setEnabled(doNextExit(false)); aPrevExit.setEnabled(doPrevExit(false)); aDeleteUnknownObjects.setEnabled(doDeleteUnknownObjects(false)); - for (int i = 0; i < directionsDir.length; i++) { - aDirections[i].setEnabled(doEnterMap(false, directionsDir[i])); + for (final Direction direction : Direction.values()) { + aDirections[direction.ordinal()].setEnabled(doEnterMap(false, direction)); } aShrinkMapSize.setEnabled(doShrinkMapSize(false)); } @@ -801,41 +795,41 @@ * @return the new view position */ @NotNull - private Point calculateNewViewPosition(@NotNull final JScrollPane oldMapView, @NotNull final JScrollPane newMapView, final int direction) { + private Point calculateNewViewPosition(@NotNull final JScrollPane oldMapView, @NotNull final JScrollPane newMapView, @NotNull final Direction direction) { final Dimension newViewSize = newMapView.getViewport().getViewSize(); final Rectangle oldViewRectangle = oldMapView.getViewport().getViewRect(); final Rectangle scrollTo; - switch (directionMap[direction]) { - case CommonConstants.SOUTH: + switch (directionMap[direction.ordinal()]) { + case SOUTH: scrollTo = new Rectangle(oldViewRectangle.x, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH: + case NORTH: scrollTo = new Rectangle(oldViewRectangle.x, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.EAST: + case EAST: scrollTo = new Rectangle(0, oldViewRectangle.y, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.WEST: + case WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, oldViewRectangle.y, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH_EAST: + case NORTH_EAST: scrollTo = new Rectangle(0, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.SOUTH_EAST: + case SOUTH_EAST: scrollTo = new Rectangle(0, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.SOUTH_WEST: + case SOUTH_WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, 0, oldViewRectangle.width, oldViewRectangle.height); break; - case CommonConstants.NORTH_WEST: + case NORTH_WEST: scrollTo = new Rectangle(newViewSize.width - oldViewRectangle.width, newViewSize.height - oldViewRectangle.height, oldViewRectangle.width, oldViewRectangle.height); break; @@ -1002,7 +996,7 @@ return false; } - if (!enterMap(mapView, mapLocation.getMapPath(), 0, mapLocation.getMapCoordinate())) { + if (!enterMap(mapView, mapLocation.getMapPath(), Direction.NORTH, mapLocation.getMapCoordinate())) { return false; } } @@ -1102,7 +1096,7 @@ * @param direction the direction to enter * @return whether the action was or can be performed */ - private boolean doEnterMap(final boolean performAction, final int direction) { + private boolean doEnterMap(final boolean performAction, @NotNull final Direction direction) { final MapView<G, A, R> mapView = currentMapView; if (mapView == null) { return false; Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/AbstractMapTilePane.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -38,6 +38,7 @@ import net.sf.gridarta.gui.utils.GUIConstants; import net.sf.gridarta.mapmanager.MapManager; 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.map.maparchobject.MapArchObject; import net.sf.gridarta.model.map.mapmodel.MapModel; @@ -45,7 +46,6 @@ import net.sf.gridarta.model.map.tiles.MapLink; import net.sf.gridarta.model.map.tiles.TileLink; import net.sf.gridarta.model.settings.GlobalSettings; -import net.sf.gridarta.utils.CommonConstants; import net.sf.japi.swing.action.ActionBuilder; import net.sf.japi.swing.action.ActionBuilderFactory; import net.sf.japi.swing.action.ActionMethod; @@ -142,7 +142,7 @@ this.nextFocus = nextFocus; this.mapFileFilter = mapFileFilter; assert tileLink.length == 8; - tileLinks = new TileLink[] { newTileLink("mapNorth", tileLink[0], CommonConstants.SOUTH), newTileLink("mapEast", tileLink[1], CommonConstants.WEST), newTileLink("mapSouth", tileLink[2], CommonConstants.NORTH), newTileLink("mapWest", tileLink[3], CommonConstants.EAST), newTileLink("mapNorthEast", tileLink[4], CommonConstants.SOUTH_WEST), newTileLink("mapSouthEast", tileLink[5], CommonConstants.NORTH_WEST), newTileLink("mapSouthWest", tileLink[6], CommonConstants.NORTH_EAST), newTileLink("mapNorthWest", tileLink[7], CommonConstants.SOUTH_EAST), }; + tileLinks = new TileLink[] { newTileLink("mapNorth", tileLink[0], Direction.SOUTH), newTileLink("mapEast", tileLink[1], Direction.WEST), newTileLink("mapSouth", tileLink[2], Direction.NORTH), newTileLink("mapWest", tileLink[3], Direction.EAST), newTileLink("mapNorthEast", tileLink[4], Direction.SOUTH_WEST), newTileLink("mapSouthEast", tileLink[5], Direction.NORTH_WEST), newTileLink("mapSouthWest", tileLink[6], Direction.NORTH_EAST), newTileLink("mapNorthWest", tileLink[7], Direction.SOUTH_EAST), }; attachTiledMaps = new AttachTiledMaps<G, A, R>(mapManager, tileLinks, mapPathNormalizer); canAttachMaps = tileLink[0].length + tileLink[1].length + tileLink[2].length + tileLink[3].length + tileLink[4].length + tileLink[5].length + tileLink[6].length + tileLink[7].length > 0; mapArchObject = mapModel.getMapArchObject(); @@ -156,7 +156,7 @@ * @return the new instance */ @NotNull - private static TileLink newTileLink(@NotNull final String key, @NotNull final MapLink[] mapLinks, final int revLink) { + private static TileLink newTileLink(@NotNull final String key, @NotNull final MapLink[] mapLinks, @NotNull final Direction revLink) { final String name = ACTION_BUILDER.getString(key); if (name == null) { throw new IllegalArgumentException("resource key '" + key + "' does not exist"); @@ -192,7 +192,7 @@ for (int index = 0; index < tilePanels.length; index++) { final File mapDir = globalSettings.getMapsDirectory(); final File mapFile = mapModel.getMapFile(); - final TilePanel tilePanel = new TilePanel(mapFileFilter, mapArchObject.getTilePath(index), mapFile, mapDir); + final TilePanel tilePanel = new TilePanel(mapFileFilter, mapArchObject.getTilePath(Direction.values()[index]), mapFile, mapDir); tilePanels[index] = new MapTilePanel(index, nextFocus, tilePanel, tileLinks[index].getName()); } return tilePanels; @@ -283,7 +283,7 @@ */ public void modifyMapProperties() { for (int i = 0; i < tilePaths.length; i++) { - mapArchObject.setTilePath(i, tilePaths[i].getTilePanel().getText()); + mapArchObject.setTilePath(Direction.values()[i], tilePaths[i].getTilePanel().getText()); } } Modified: trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java 2010-06-08 22:51:00 UTC (rev 8292) +++ trunk/src/app/net/sf/gridarta/gui/map/maptilepane/IsoMapTilePane.java 2010-06-08 23:36:45 UTC (rev 8293) @@ -23,13 +23,13 @@ import net.sf.gridarta.gui.utils.DirectionLayout; import net.sf.gridarta.mapmanager.MapManager; import net.sf.gridarta.model.archetype.Archetype; +import net.sf.gridarta.model.direction.Direction; import net.sf.gridarta.model.gameobject.GameObject; import net.sf.gridar... [truncated message content] |
From: <aki...@us...> - 2010-06-08 22:51:06
|
Revision: 8292 http://gridarta.svn.sourceforge.net/gridarta/?rev=8292&view=rev Author: akirschbaum Date: 2010-06-08 22:51:00 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Move constants to correct class. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java Modified: trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-08 22:44:06 UTC (rev 8291) +++ trunk/src/app/net/sf/gridarta/gui/gameobjectattributesdialog/GameObjectAttributesDialog.java 2010-06-08 22:51:00 UTC (rev 8292) @@ -132,7 +132,6 @@ import net.sf.gridarta.textedit.textarea.SyntaxDocument; import net.sf.gridarta.textedit.textarea.TextAreaDefaults; import net.sf.gridarta.textedit.textarea.tokenmarker.TokenMarkerFactory; -import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import net.sf.gridarta.utils.StringUtils; import net.sf.japi.swing.action.ActionBuilder; @@ -150,6 +149,18 @@ public class GameObjectAttributesDialog<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> extends JOptionPane { /** + * Color for float values. + */ + @NotNull + public static final Color FLOAT_COLOR = new Color(19, 134, 0); + + /** + * Color for int values. + */ + @NotNull + public static final Color INT_COLOR = new Color(74, 70, 156); + + /** * The serial version UID. */ private static final long serialVersionUID = 1L; @@ -481,7 +492,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeFloat archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.FLOAT_COLOR); + cLabel.setForeground(FLOAT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final DecimalFormat format = new DecimalFormat("#0.0#"); format.setMaximumFractionDigits(10); @@ -500,7 +511,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeInt archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final NumberFormat format = NumberFormat.getIntegerInstance(); format.setGroupingUsed(false); @@ -517,7 +528,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeInvSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildInvSpellBox(gameObjectSpells, gameObject, archetypeAttribute.isOptionalSpell(), archetypeAttribute.getAttributeName()); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeInvSpell>(new DialogAttributeInvSpell<G, A, R>(archetypeAttribute.isOptionalSpell(), archetypeAttribute, input, gameObjectSpells), cLabel, input, null, null, false); @@ -527,7 +538,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeList archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection final JComponent cComp; @Nullable final JComboBox input; @@ -548,7 +559,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeLong archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); final int fieldLength = archetypeAttribute.getInputLength() == 0 ? ArchetypeAttribute.TEXTFIELD_COLUMNS : archetypeAttribute.getInputLength(); final NumberFormat format = NumberFormat.getIntegerInstance(); format.setGroupingUsed(false); @@ -587,7 +598,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, false, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeSpell>(new DialogAttributeSpell<G, A, R>(archetypeAttribute, input, numberSpells), cLabel, input, null, null, false); @@ -644,7 +655,7 @@ @Override public void visit(@NotNull final ArchetypeAttributeZSpell archetypeAttribute) { final JLabel cLabel = new JLabel(archetypeAttribute.getAttributeName() + ": "); - cLabel.setForeground(CommonConstants.INT_COLOR); + cLabel.setForeground(INT_COLOR); // create ComboBox with parsed selection @Nullable final JComboBox input = buildSpellBox(gameObject, numberSpells, undefinedSpellIndex, true, archetypeAttribute); guiInfo = new GuiInfo<G, A, R, ArchetypeAttributeZSpell>(new DialogAttributeZSpell<G, A, R>(archetypeAttribute, input, numberSpells, undefinedSpellIndex), cLabel, input, null, null, false); Modified: trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:44:06 UTC (rev 8291) +++ trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:51:00 UTC (rev 8292) @@ -38,13 +38,6 @@ public static final Color BG_COLOR = new Color(100, 219, 169); /** - * Color for float/int values (AttributeDialog). - */ - public static final Color FLOAT_COLOR = new Color(19, 134, 0); - - public static final Color INT_COLOR = new Color(74, 70, 156); - - /** * Name of the file that contains the type definitions. */ public static final String TYPEDEF_FILE = "types.xml"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:44:13
|
Revision: 8291 http://gridarta.svn.sourceforge.net/gridarta/?rev=8291&view=rev Author: akirschbaum Date: 2010-06-08 22:44:06 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Rename icon file names. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java Added Paths: ----------- trunk/atrinik/resource/icons/app_icon.gif trunk/atrinik/resource/system/no_arch.png trunk/atrinik/resource/system/no_face.png trunk/atrinik/resource/system/pre_selected_square.png trunk/atrinik/resource/system/selected_square.png trunk/atrinik/resource/system/selected_square_e.png trunk/atrinik/resource/system/selected_square_n.png trunk/atrinik/resource/system/selected_square_s.png trunk/atrinik/resource/system/selected_square_w.png trunk/crossfire/resource/icons/app_icon.gif trunk/crossfire/resource/system/no_arch.png trunk/crossfire/resource/system/no_face.png trunk/crossfire/resource/system/pre_selected_square.png trunk/crossfire/resource/system/selected_square.png trunk/crossfire/resource/system/selected_square_e.png trunk/crossfire/resource/system/selected_square_n.png trunk/crossfire/resource/system/selected_square_s.png trunk/crossfire/resource/system/selected_square_w.png trunk/daimonin/resource/icons/app_icon.gif trunk/daimonin/resource/system/no_arch.png trunk/daimonin/resource/system/no_face.png trunk/daimonin/resource/system/pre_selected_square.png trunk/daimonin/resource/system/selected_square.png trunk/daimonin/resource/system/selected_square_e.png trunk/daimonin/resource/system/selected_square_n.png trunk/daimonin/resource/system/selected_square_s.png trunk/daimonin/resource/system/selected_square_w.png trunk/resource/icons/auto_run_small_icon.gif trunk/resource/icons/close_tab_small_icon.gif trunk/resource/icons/filte_small_icon.gif trunk/resource/icons/run_plugin_small_icon.gif Removed Paths: ------------- trunk/atrinik/resource/icons/CFIcon.gif trunk/atrinik/resource/system/noarch.png trunk/atrinik/resource/system/noface.png trunk/atrinik/resource/system/preseltile.png trunk/atrinik/resource/system/seltile.png trunk/atrinik/resource/system/seltile_e.png trunk/atrinik/resource/system/seltile_n.png trunk/atrinik/resource/system/seltile_s.png trunk/atrinik/resource/system/seltile_w.png trunk/crossfire/resource/icons/CFIcon.gif trunk/crossfire/resource/system/noarch.png trunk/crossfire/resource/system/noface.png trunk/crossfire/resource/system/preseltile.png trunk/crossfire/resource/system/seltile.png trunk/crossfire/resource/system/seltile_e.png trunk/crossfire/resource/system/seltile_n.png trunk/crossfire/resource/system/seltile_s.png trunk/crossfire/resource/system/seltile_w.png trunk/daimonin/resource/icons/CFIcon.gif trunk/daimonin/resource/system/noarch.png trunk/daimonin/resource/system/noface.png trunk/daimonin/resource/system/preseltile.png trunk/daimonin/resource/system/seltile.png trunk/daimonin/resource/system/seltile_e.png trunk/daimonin/resource/system/seltile_n.png trunk/daimonin/resource/system/seltile_s.png trunk/daimonin/resource/system/seltile_w.png trunk/resource/icons/AutorunSmallIcon.gif trunk/resource/icons/CloseTabSmallIcon.gif trunk/resource/icons/FilterSmallIcon.gif trunk/resource/icons/RunPluginSmallIcon.gif Deleted: trunk/atrinik/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/icons/app_icon.gif (from rev 8272, trunk/atrinik/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/no_arch.png (from rev 8272, trunk/atrinik/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/no_face.png (from rev 8272, trunk/atrinik/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/pre_selected_square.png (from rev 8272, trunk/atrinik/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square.png (from rev 8272, trunk/atrinik/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_e.png (from rev 8272, trunk/atrinik/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_n.png (from rev 8272, trunk/atrinik/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_s.png (from rev 8272, trunk/atrinik/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/atrinik/resource/system/selected_square_w.png (from rev 8272, trunk/atrinik/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/atrinik/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/icons/app_icon.gif (from rev 8272, trunk/crossfire/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/no_arch.png (from rev 8272, trunk/crossfire/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/no_face.png (from rev 8272, trunk/crossfire/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/pre_selected_square.png (from rev 8272, trunk/crossfire/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square.png (from rev 8272, trunk/crossfire/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_e.png (from rev 8272, trunk/crossfire/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_n.png (from rev 8272, trunk/crossfire/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_s.png (from rev 8272, trunk/crossfire/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/crossfire/resource/system/selected_square_w.png (from rev 8272, trunk/crossfire/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/crossfire/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/icons/CFIcon.gif =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/icons/app_icon.gif (from rev 8272, trunk/daimonin/resource/icons/CFIcon.gif) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/no_arch.png (from rev 8272, trunk/daimonin/resource/system/noarch.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/no_face.png (from rev 8272, trunk/daimonin/resource/system/noface.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/noarch.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/noface.png =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/pre_selected_square.png (from rev 8272, trunk/daimonin/resource/system/preseltile.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/preseltile.png =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square.png (from rev 8272, trunk/daimonin/resource/system/seltile.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_e.png (from rev 8272, trunk/daimonin/resource/system/seltile_e.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_n.png (from rev 8272, trunk/daimonin/resource/system/seltile_n.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_s.png (from rev 8272, trunk/daimonin/resource/system/seltile_s.png) =================================================================== (Binary files differ) Copied: trunk/daimonin/resource/system/selected_square_w.png (from rev 8272, trunk/daimonin/resource/system/seltile_w.png) =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_e.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_n.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_s.png =================================================================== (Binary files differ) Deleted: trunk/daimonin/resource/system/seltile_w.png =================================================================== (Binary files differ) Deleted: trunk/resource/icons/AutorunSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/CloseTabSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/FilterSmallIcon.gif =================================================================== (Binary files differ) Deleted: trunk/resource/icons/RunPluginSmallIcon.gif =================================================================== (Binary files differ) Copied: trunk/resource/icons/auto_run_small_icon.gif (from rev 8272, trunk/resource/icons/AutorunSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/close_tab_small_icon.gif (from rev 8272, trunk/resource/icons/CloseTabSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/filte_small_icon.gif (from rev 8272, trunk/resource/icons/FilterSmallIcon.gif) =================================================================== (Binary files differ) Copied: trunk/resource/icons/run_plugin_small_icon.gif (from rev 8272, trunk/resource/icons/RunPluginSmallIcon.gif) =================================================================== (Binary files differ) Modified: trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:33:20 UTC (rev 8290) +++ trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:44:06 UTC (rev 8291) @@ -45,17 +45,17 @@ */ public static final String SYSTEM_DIR = "system/"; - public static final String SQUARE_SELECTED_SQUARE = SYSTEM_DIR + "seltile.png"; + public static final String SQUARE_SELECTED_SQUARE = SYSTEM_DIR + "selected_square.png"; - public static final String SQUARE_SELECTED_SQUARE_NORTH = SYSTEM_DIR + "seltile_n.png"; + public static final String SQUARE_SELECTED_SQUARE_NORTH = SYSTEM_DIR + "selected_square_n.png"; - public static final String SQUARE_SELECTED_SQUARE_EAST = SYSTEM_DIR + "seltile_e.png"; + public static final String SQUARE_SELECTED_SQUARE_EAST = SYSTEM_DIR + "selected_square_e.png"; - public static final String SQUARE_SELECTED_SQUARE_SOUTH = SYSTEM_DIR + "seltile_s.png"; + public static final String SQUARE_SELECTED_SQUARE_SOUTH = SYSTEM_DIR + "selected_square_s.png"; - public static final String SQUARE_SELECTED_SQUARE_WEST = SYSTEM_DIR + "seltile_w.png"; + public static final String SQUARE_SELECTED_SQUARE_WEST = SYSTEM_DIR + "selected_square_w.png"; - public static final String SQUARE_PRE_SELECTED_SQUARE = SYSTEM_DIR + "preseltile.png"; + public static final String SQUARE_PRE_SELECTED_SQUARE = SYSTEM_DIR + "pre_selected_square.png"; public static final String SQUARE_CURSOR = SYSTEM_DIR + "cursor.png"; @@ -65,9 +65,9 @@ public static final String SQUARE_WARNING = SYSTEM_DIR + "warning.png"; - public static final String SQUARE_NO_FACE = SYSTEM_DIR + "noface.png"; + public static final String SQUARE_NO_FACE = SYSTEM_DIR + "no_face.png"; - public static final String SQUARE_NO_ARCH = SYSTEM_DIR + "noarch.png"; + public static final String SQUARE_NO_ARCH = SYSTEM_DIR + "no_arch.png"; private static final String TREASURE_LIST = SYSTEM_DIR + "treasure_list.png"; @@ -87,18 +87,18 @@ */ public static final String DEFAULT_PREVIEW = SYSTEM_DIR + "default_preview.png"; - private static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "CloseTabSmallIcon.gif"; + private static final String CLOSE_TAB_SMALL_ICON = ICON_DIR + "close_tab_small_icon.gif"; - private static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "AutorunSmallIcon.gif"; + private static final String AUTO_RUN_SMALL_ICON = ICON_DIR + "auto_run_small_icon.gif"; - private static final String FILTER_SMALL_ICON = ICON_DIR + "FilterSmallIcon.gif"; + private static final String FILTER_SMALL_ICON = ICON_DIR + "filter_small_icon.gif"; - private static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "RunPluginSmallIcon.gif"; + private static final String RUN_PLUGIN_SMALL_ICON = ICON_DIR + "run_plugin_small_icon.gif"; /** * Application icon definitions (icon-dir). */ - private static final String APP_ICON = ICON_DIR + "CFIcon.gif"; + private static final String APP_ICON = ICON_DIR + "app_icon.gif"; /** * The {@link GUIUtils} for creating icons. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:33:26
|
Revision: 8290 http://gridarta.svn.sourceforge.net/gridarta/?rev=8290&view=rev Author: akirschbaum Date: 2010-06-08 22:33:20 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Fix typos. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java Modified: trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/src/app/net/sf/gridarta/gui/archetypechooser/ArchetypeChooserView.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -213,7 +213,7 @@ break; } fireDisplayObjectNamesChangedEvent(); - tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); + tabDesktop.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKMAP_ARCHETYPE_TOP, 0, 0, 0)); add(tabDesktop); if (createDirectionPane) { add(new DirectionPane<G, A, R>(archetypeChooserModel, true), BorderLayout.SOUTH); Modified: trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/src/app/net/sf/gridarta/gui/pickmapchooser/PickmapChooserView.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -172,7 +172,7 @@ this.pickmapChooserModel = pickmapChooserModel; this.mapFolderTree = mapFolderTree; pickmapChooserModel.addPickmapChooserListener(pickmapChooserModelListener); - pickmapPanel.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKARCH_TOP, 0, 0, 0)); + pickmapPanel.setBorder(BorderFactory.createEmptyBorder(CommonConstants.SPACE_PICKMAP_ARCHETYPE_TOP, 0, 0, 0)); mapFolderTree.addModelListener(mapFolderTreeListener); synchronized (mapFolderTree) { mapFolderTreeListener.activeMapFolderChanged(mapFolderTree.getActiveMapFolder()); Modified: trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/CommonConstants.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -58,7 +58,7 @@ * The height of rigid area between the two tab-panes on the pickmap- and * arch-panel. */ - public static final int SPACE_PICKARCH_TOP = 10; + public static final int SPACE_PICKMAP_ARCHETYPE_TOP = 10; /** * Default file name for new maps. Modified: trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -43,8 +43,8 @@ /** * Return the filename to use when dealing with this application's and * current users' home directory. For example, if called like this - * <code>CResourceLoader.getHomeFile("myfile");</code> will return something - * like /home/someuser/.gridarta/myfile under Linux. + * <code>CResourceLoader.getHomeFile("file");</code> will return something + * like /home/user/.gridarta/file under Linux. * @param filename the name of requested file. * @return the full to user home directory, appended with application * directory and the filename. Modified: trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:31:26 UTC (rev 8289) +++ trunk/utils/src/app/net/sf/gridarta/utils/SystemIcons.java 2010-06-08 22:33:20 UTC (rev 8290) @@ -137,10 +137,10 @@ private ImageIcon warningSquareIcon = null; @Nullable - private ImageIcon nofaceSquareIcon = null; + private ImageIcon noFaceSquareIcon = null; @Nullable - private ImageIcon noarchSquareIcon = null; + private ImageIcon noArchSquareIcon = null; /** * The default icon {@link Image} for map previews. @@ -232,18 +232,18 @@ @NotNull public ImageIcon getNoFaceSquareIcon() { - if (nofaceSquareIcon == null) { - nofaceSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_FACE); + if (noFaceSquareIcon == null) { + noFaceSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_FACE); } - return nofaceSquareIcon; + return noFaceSquareIcon; } @NotNull public ImageIcon getNoArchSquareIcon() { - if (noarchSquareIcon == null) { - noarchSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_ARCH); + if (noArchSquareIcon == null) { + noArchSquareIcon = guiUtils.getResourceIcon(SQUARE_NO_ARCH); } - return noarchSquareIcon; + return noArchSquareIcon; } @NotNull This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:31:32
|
Revision: 8289 http://gridarta.svn.sourceforge.net/gridarta/?rev=8289&view=rev Author: akirschbaum Date: 2010-06-08 22:31:26 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Suppress warning. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java Modified: trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:30:28 UTC (rev 8288) +++ trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:31:26 UTC (rev 8289) @@ -56,6 +56,7 @@ buf.append(File.separator).append(APP_SETTINGS_DIR); final File rc = new File(buf.toString()); if (!rc.isDirectory()) { + //noinspection ResultOfMethodCallIgnored rc.mkdirs(); } buf.append(File.separator); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:30:34
|
Revision: 8288 http://gridarta.svn.sourceforge.net/gridarta/?rev=8288&view=rev Author: akirschbaum Date: 2010-06-08 22:30:28 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Add @NotNull annotations. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java Modified: trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:29:58 UTC (rev 8287) +++ trunk/utils/src/app/net/sf/gridarta/utils/ConfigFileUtils.java 2010-06-08 22:30:28 UTC (rev 8288) @@ -31,6 +31,7 @@ /** * Name of directory with settings file. */ + @NotNull private static final String APP_SETTINGS_DIR = ".gridarta"; /** @@ -48,7 +49,8 @@ * @return the full to user home directory, appended with application * directory and the filename. */ - public static File getHomeFile(final String filename) { + @NotNull + public static File getHomeFile(@NotNull final String filename) { final StringBuilder buf = new StringBuilder(); buf.append(getHomeDir()); buf.append(File.separator).append(APP_SETTINGS_DIR); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:30:04
|
Revision: 8287 http://gridarta.svn.sourceforge.net/gridarta/?rev=8287&view=rev Author: akirschbaum Date: 2010-06-08 22:29:58 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Suppress warning. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java Modified: trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java 2010-06-08 22:29:18 UTC (rev 8286) +++ trunk/utils/src/app/net/sf/gridarta/gui/utils/GUIConstants.java 2010-06-08 22:29:58 UTC (rev 8287) @@ -28,6 +28,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author Andreas Kirschbaum + * @noinspection InterfaceNeverImplemented */ public interface GUIConstants { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aki...@us...> - 2010-06-08 22:29:26
|
Revision: 8286 http://gridarta.svn.sourceforge.net/gridarta/?rev=8286&view=rev Author: akirschbaum Date: 2010-06-08 22:29:18 +0000 (Tue, 08 Jun 2010) Log Message: ----------- Rename variables. Modified Paths: -------------- trunk/utils/src/app/net/sf/gridarta/utils/IOUtils.java Modified: trunk/utils/src/app/net/sf/gridarta/utils/IOUtils.java =================================================================== --- trunk/utils/src/app/net/sf/gridarta/utils/IOUtils.java 2010-06-08 22:28:57 UTC (rev 8285) +++ trunk/utils/src/app/net/sf/gridarta/utils/IOUtils.java 2010-06-08 22:29:18 UTC (rev 8286) @@ -68,7 +68,7 @@ if (file.exists()) { return file.toURI().toURL(); } - } catch (final MalformedURLException e) { + } catch (final MalformedURLException ignored) { // ignore } try { // 2nd try binary file relative to user's current working directory @@ -76,7 +76,7 @@ if (file.exists()) { return file.toURI().toURL(); } - } catch (final MalformedURLException e) { + } catch (final MalformedURLException ignored) { // ignore } final URI currentDir = new File(System.getProperty("user.dir")).toURI(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |