Gridarta Editor
ShrinkMapSizeUtilsTest.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.gui.dialog.shrinkmapsize;
21 
22 import java.awt.Point;
30 import net.sf.gridarta.utils.Size2D;
31 import org.junit.Assert;
32 import org.junit.Test;
33 
37 @SuppressWarnings("JavaDoc")
38 public class ShrinkMapSizeUtilsTest {
39 
40  @Test
42  final TestMapControlCreator testMapControlCreator = new TestMapControlCreator();
43  final MapControl<TestGameObject, TestMapArchObject, TestArchetype> mapControl = testMapControlCreator.newMapControl(null, "test", new Size2D(3, 3));
45  mapView.setCursorLocation(new Point(1, 2));
46 
48 
49  Assert.assertEquals(new Size2D(1, 1), mapControl.getMapModel().getMapArchObject().getMapSize());
50  Assert.assertEquals(new Size2D(1, 1), mapView.getMapGrid().getGridSize());
51  Assert.assertEquals(new Point(0, 0), mapView.getMapCursor().getLocation());
52  }
53 
54 }
net.sf.gridarta.model.archetype.TestArchetype
An Archetype implementation for testing purposes.
Definition: TestArchetype.java:30
net.sf.gridarta.gui.map.mapview.MapView.setCursorLocation
void setCursorLocation(@NotNull Point point)
Sets the cursor location.
net.sf.gridarta.gui.map.mapview.MapView.getMapGrid
MapGrid getMapGrid()
Returns the MapGrid of this view.
net.sf.gridarta.model.mapmodel.MapModel.getMapArchObject
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.gameobject.TestGameObject
A GameObject implementation for testing purposes.
Definition: TestGameObject.java:34
net.sf
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.mapcontrol
Definition: DefaultMapControl.java:20
net.sf.gridarta.gui.map.test.TestMapControlCreatorUtils.newMapView
static MapView< TestGameObject, TestMapArchObject, TestArchetype > newMapView(@NotNull final MapControl< TestGameObject, TestMapArchObject, TestArchetype > mapControl)
Creates a new MapView instance.
Definition: TestMapControlCreatorUtils.java:64
net.sf.gridarta.gui
Graphical User Interface of Gridarta.
net.sf.gridarta.gui.map.mapview.MapView.getMapCursor
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
net.sf.gridarta.model.mapcontrol.TestMapControlCreator
Helper class for creating MapControl instances for regression tests.
Definition: TestMapControlCreator.java:68
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.gui.map.mapview
Definition: AbstractMapView.java:20
net.sf.gridarta.model.mapcursor.MapCursor.getLocation
Point getLocation()
Get position of cursor.
Definition: MapCursor.java:227
net.sf.gridarta.gui.map.mapview.MapView
A map view consists of a map grid and a map cursor, and is attached to a map control.
Definition: MapView.java:43
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtils.SHRINK_SOUTH
static final int SHRINK_SOUTH
Flag value: remove empty space from south border.
Definition: ShrinkMapSizeUtils.java:40
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtils.SHRINK_EAST
static final int SHRINK_EAST
Flag value: remove empty space from east border.
Definition: ShrinkMapSizeUtils.java:35
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtilsTest.shrinkMap_cursorInClippedOffArea_cursorIsMoved
void shrinkMap_cursorInClippedOffArea_cursorIsMoved()
Definition: ShrinkMapSizeUtilsTest.java:41
net.sf.gridarta.gui.map.test.TestMapControlCreatorUtils
Helper class for creating MapControl instances for regression tests.
Definition: TestMapControlCreatorUtils.java:50
net.sf.gridarta.model
net.sf.gridarta.gui.map
Base classes for rendering maps.
Definition: AbstractPerMapDialogManager.java:20
net.sf.gridarta.model.mapcontrol.TestMapControlCreator.newMapControl
MapControl< TestGameObject, TestMapArchObject, TestArchetype > newMapControl(@Nullable final MapFile mapFile, @NotNull final String mapName, @NotNull final Size2D mapSize)
Creates a new map control.
Definition: TestMapControlCreator.java:176
net.sf.gridarta.model.mapcontrol.MapControl
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
net.sf.gridarta.model.mapcontrol.MapControl.getMapModel
MapModel< G, A, R > getMapModel()
Returns the map model.
net.sf.gridarta.model.maparchobject.TestMapArchObject
A MapArchObject implementation for testing purposes.
Definition: TestMapArchObject.java:28
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.utils.Size2D
The class Size2D represents a 2d rectangular area.
Definition: Size2D.java:30
net.sf.gridarta.utils
Definition: ActionBuilderUtils.java:20
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtilsTest
Regression tests for ShrinkMapSizeUtils.
Definition: ShrinkMapSizeUtilsTest.java:38
net.sf.gridarta.gui.map.test
Definition: TestMapControlCreatorUtils.java:20
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtils
Utility class to remove empty squares from a map's border.
Definition: ShrinkMapSizeUtils.java:30
net.sf.gridarta.gui.dialog.shrinkmapsize.ShrinkMapSizeUtils.shrinkMap
static void shrinkMap(@NotNull final MapModel<?, ?, ?> mapModel, final int shrinkFlags)
Removes empty squares from a map's border.
Definition: ShrinkMapSizeUtils.java:53