From: <aki...@us...> - 2009-09-28 20:33:38
|
Revision: 6993 http://gridarta.svn.sourceforge.net/gridarta/?rev=6993&view=rev Author: akirschbaum Date: 2009-09-28 20:33:31 +0000 (Mon, 28 Sep 2009) Log Message: ----------- Move MapGrid.SelectionMode to top-level class. Modified Paths: -------------- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java trunk/src/app/net/sf/gridarta/gui/connectionview/Control.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/grid/MapGrid.java trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java trunk/src/test/net/sf/gridarta/gui/map/grid/MapGridTest.java Added Paths: ----------- trunk/src/app/net/sf/gridarta/gui/map/grid/SelectionMode.java Modified: trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/ShiftProcessor.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -28,6 +28,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapviewsettings.MapViewSettings; import net.sf.gridarta.map.maparchobject.MapArchObject; @@ -258,7 +259,7 @@ assert mapGrid != null; final boolean thisSelection = (mapGrid.getFlags(pos) & MapGrid.GRID_FLAG_SELECTION) > 0; assert mapGrid != null; - mapGrid.select(prevPos, prevPos, thisSelection ? MapGrid.SelectionMode.ADD : MapGrid.SelectionMode.SUB); + mapGrid.select(prevPos, prevPos, thisSelection ? SelectionMode.ADD : SelectionMode.SUB); if (thisSelection) { if (isStart) { isStart = false; @@ -311,7 +312,7 @@ } assert startGameObjects.isEmpty(); assert mapGrid != null; - mapGrid.select(prevPos, prevPos, startSelection ? MapGrid.SelectionMode.ADD : MapGrid.SelectionMode.SUB); + mapGrid.select(prevPos, prevPos, startSelection ? SelectionMode.ADD : SelectionMode.SUB); } } // class ShiftProcessor Modified: trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/connectionview/Control.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -29,6 +29,7 @@ import net.sf.gridarta.gameobject.Archetype; import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.map.maparchobject.MapArchObject; import org.jetbrains.annotations.NotNull; @@ -96,7 +97,7 @@ for (final GameObject<?, ?, ?> object : connection) { final GameObject<?, ?, ?> topObject = object.getTopContainer(); point.setLocation(topObject.getMapX(), topObject.getMapY()); - mapGrid.select(point, point, MapGrid.SelectionMode.ADD); + mapGrid.select(point, point, SelectionMode.ADD); } } } Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursor.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -25,6 +25,7 @@ import net.sf.gridarta.gui.map.grid.MapGrid; import net.sf.gridarta.gui.map.grid.MapGridEvent; import net.sf.gridarta.gui.map.grid.MapGridListener; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.gui.utils.EventListenerList2; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -246,9 +247,9 @@ /** * Leave drag mode and select preselection using selectionMode. * @param selectionMode Mode how to change selection state - * @see MapGrid.SelectionMode + * @see SelectionMode */ - public void dragSelect(final MapGrid.SelectionMode selectionMode) { + public void dragSelect(final SelectionMode selectionMode) { if (dragging) { mapGrid.beginTransaction(); try { Modified: trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/map/cursor/MapCursorActions.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -25,7 +25,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.gameobjectattributesdialog.GameObjectAttributesDialogFactory; import net.sf.gridarta.gui.golocationdialog.GoLocationDialogManager; -import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.gui.map.mapview.MapView; import net.sf.gridarta.gui.map.mapview.MapViewManager; import net.sf.gridarta.gui.map.mapview.MapViewManagerListener; @@ -254,7 +254,7 @@ public void selectSquare() { final MapCursor mapCursor = getSelectSquareEnabled(); if (mapCursor != null) { - selectSquare(mapCursor, MapGrid.SelectionMode.FLIP); + selectSquare(mapCursor, SelectionMode.FLIP); } } @@ -262,7 +262,7 @@ public void addToSelection() { final MapCursor mapCursor = getAddToSelectionEnabled(); if (mapCursor != null) { - selectSquare(mapCursor, MapGrid.SelectionMode.ADD); + selectSquare(mapCursor, SelectionMode.ADD); } } @@ -270,7 +270,7 @@ public void subFromSelection() { final MapCursor mapCursor = getSubFromSelectionEnabled(); if (mapCursor != null) { - selectSquare(mapCursor, MapGrid.SelectionMode.SUB); + selectSquare(mapCursor, SelectionMode.SUB); } } @@ -487,14 +487,14 @@ aArchAttributes.setEnabled(getArchAttributesEnabled() != null); } - private static void selectSquare(@NotNull final MapCursor mapCursor, final MapGrid.SelectionMode mode) { + private static void selectSquare(@NotNull final MapCursor mapCursor, final SelectionMode mode) { mapCursor.dragStart(); mapCursor.dragSelect(mode); } private static void startStopDrag(@NotNull final MapCursor mapCursor) { if (mapCursor.isDragging()) { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + mapCursor.dragSelect(SelectionMode.FLIP); } else { mapCursor.dragStart(); } Modified: trunk/src/app/net/sf/gridarta/gui/map/grid/MapGrid.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/grid/MapGrid.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/map/grid/MapGrid.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -728,18 +728,4 @@ } } - /** Modes that describe how squares get selected. */ - public enum SelectionMode { - - /** All squares that are preselected get selected. */ - ADD, - - /** All squares that are preselected get unselected. */ - SUB, - - /** All squares that are preselected change state of selection. */ - FLIP - - } // enum SelectionMode - } // class MapGrid Added: trunk/src/app/net/sf/gridarta/gui/map/grid/SelectionMode.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/grid/SelectionMode.java (rev 0) +++ trunk/src/app/net/sf/gridarta/gui/map/grid/SelectionMode.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -0,0 +1,37 @@ +/* + * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games. + * Copyright (C) 2000-2007 The Gridarta Developers. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +package net.sf.gridarta.gui.map.grid; + +/** + * Modes that describe how squares get selected. + * @author <a href="mailto:dlv...@gm...">Daniel Viegas</a> + */ +public enum SelectionMode { + + /** All squares that are preselected get selected. */ + ADD, + + /** All squares that are preselected get unselected. */ + SUB, + + /** All squares that are preselected change state of selection. */ + FLIP + +} // enum SelectionMode Property changes on: trunk/src/app/net/sf/gridarta/gui/map/grid/SelectionMode.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:eol-style + LF Modified: trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java =================================================================== --- trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/app/net/sf/gridarta/gui/map/tools/SelectionTool.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -32,7 +32,7 @@ import net.sf.gridarta.gameobject.GameObject; import net.sf.gridarta.gui.map.cursor.MapCursor; import net.sf.gridarta.gui.map.event.MouseOpEvent; -import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.gui.objectchooser.ObjectChooser; import net.sf.gridarta.gui.undo.SwingUtils; import net.sf.gridarta.map.maparchobject.MapArchObject; @@ -141,14 +141,14 @@ if (mapCursor.isOnGrid(e.getMapLocation())) { if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) { if ((modifiers & InputEvent.CTRL_DOWN_MASK) == 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + mapCursor.dragSelect(SelectionMode.ADD); } else { - mapCursor.dragSelect(MapGrid.SelectionMode.FLIP); + mapCursor.dragSelect(SelectionMode.FLIP); } } else if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) { - mapCursor.dragSelect(MapGrid.SelectionMode.SUB); + mapCursor.dragSelect(SelectionMode.SUB); } else { - mapCursor.dragSelect(MapGrid.SelectionMode.ADD); + mapCursor.dragSelect(SelectionMode.ADD); } } else { mapCursor.dragRelease(); Modified: trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/test/net/sf/gridarta/gui/map/cursor/MapCursorTest.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -23,6 +23,7 @@ import java.awt.Point; import junit.framework.JUnit4TestAdapter; import net.sf.gridarta.gui.map.grid.MapGrid; +import net.sf.gridarta.gui.map.grid.SelectionMode; import net.sf.gridarta.utils.CommonConstants; import net.sf.gridarta.utils.Size2D; import org.jetbrains.annotations.NotNull; @@ -340,7 +341,7 @@ testEvents(1, 0); Assert.assertTrue("MapCursor should be in drag mode.", cursor.isDragging()); assertSelection(new Point(0, 0), gridMaxIndex, false); - cursor.dragSelect(MapGrid.SelectionMode.ADD); + cursor.dragSelect(SelectionMode.ADD); testEvents(0, 1); assertSelection(start, end, true); //Check if nothing is preselected @@ -351,7 +352,7 @@ testEvents(0, 1); cursor.dragTo(end); testEvents(1, 0); - cursor.dragSelect(MapGrid.SelectionMode.SUB); + cursor.dragSelect(SelectionMode.SUB); testEvents(0, 1); assertSelection(new Point(0, 0), gridMaxIndex, false); cursor.setLocation(start); @@ -360,7 +361,7 @@ testEvents(0, 1); cursor.dragTo(end); testEvents(1, 0); - cursor.dragSelect(MapGrid.SelectionMode.FLIP); + cursor.dragSelect(SelectionMode.FLIP); testEvents(0, 1); assertSelection(start, end, true); start.setLocation(3, 4); @@ -371,7 +372,7 @@ testEvents(0, 1); cursor.dragTo(end); testEvents(1, 0); - cursor.dragSelect(MapGrid.SelectionMode.FLIP); + cursor.dragSelect(SelectionMode.FLIP); testEvents(0, 1); assertSelection(start, new Point(4, 4), false); assertSelection(new Point(3, 2), end, true); Modified: trunk/src/test/net/sf/gridarta/gui/map/grid/MapGridTest.java =================================================================== --- trunk/src/test/net/sf/gridarta/gui/map/grid/MapGridTest.java 2009-09-28 20:31:40 UTC (rev 6992) +++ trunk/src/test/net/sf/gridarta/gui/map/grid/MapGridTest.java 2009-09-28 20:33:31 UTC (rev 6993) @@ -36,28 +36,28 @@ final MapGrid mapGrid = new MapGrid(new Size2D(4, 3)); checkSelectionBorder(mapGrid, "0000" + "0000" + "0000"); - mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.ADD); + mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0f00" + "0000"); - mapGrid.select(new Point(2, 1), new Point(2, 1), MapGrid.SelectionMode.ADD); + mapGrid.select(new Point(2, 1), new Point(2, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); - mapGrid.select(new Point(3, 1), new Point(3, 1), MapGrid.SelectionMode.ADD); + mapGrid.select(new Point(3, 1), new Point(3, 1), SelectionMode.ADD); checkSelectionBorder(mapGrid, "0000" + "0d57" + "0000"); - mapGrid.select(new Point(3, 1), new Point(3, 1), MapGrid.SelectionMode.SUB); + mapGrid.select(new Point(3, 1), new Point(3, 1), SelectionMode.SUB); checkSelectionBorder(mapGrid, "0000" + "0d70" + "0000"); - mapGrid.select(new Point(0, 0), new Point(3, 2), MapGrid.SelectionMode.FLIP); + mapGrid.select(new Point(0, 0), new Point(3, 2), SelectionMode.FLIP); checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); - mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.FLIP); + mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.FLIP); checkSelectionBorder(mapGrid, "9153" + "820a" + "c456"); - mapGrid.select(new Point(1, 1), new Point(1, 1), MapGrid.SelectionMode.SUB); + mapGrid.select(new Point(1, 1), new Point(1, 1), SelectionMode.SUB); checkSelectionBorder(mapGrid, "9553" + "a00a" + "c556"); - mapGrid.select(new Point(0, 0), new Point(3, 2), MapGrid.SelectionMode.ADD); + mapGrid.select(new Point(0, 0), new Point(3, 2), SelectionMode.ADD); checkSelectionBorder(mapGrid, "9113" + "8002" + "c446"); mapGrid.resize(new Size2D(2, 1)); @@ -66,7 +66,7 @@ mapGrid.resize(new Size2D(3, 4)); checkSelectionBorder(mapGrid, "d700" + "0000" + "0000"); - mapGrid.select(new Point(0, 0), new Point(2, 3), MapGrid.SelectionMode.ADD); + mapGrid.select(new Point(0, 0), new Point(2, 3), SelectionMode.ADD); checkSelectionBorder(mapGrid, "913" + "802" + "802" + "c46"); mapGrid.resize(new Size2D(4, 3)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |