20 package net.sf.gridarta.gui.dialog.shrinkmapsize;
24 import org.jetbrains.annotations.NotNull;
54 final Size2D mapSize = mapModel.getMapArchObject().getMapSize();
55 int filledWidth = mapSize.
getWidth();
57 if ((shrinkFlags & SHRINK_EAST) != 0) {
58 while (filledWidth > 1 && mapModel.isAreaEmpty(filledWidth - 1, 0, 1, filledHeight)) {
62 if ((shrinkFlags & SHRINK_SOUTH) != 0) {
63 while (filledHeight > 1 && mapModel.isAreaEmpty(0, filledHeight - 1, filledWidth, 1)) {
67 mapModel.beginTransaction(
"Shrink Map Size");
69 mapModel.getMapArchObject().setMapSize(
new Size2D(filledWidth, filledHeight));
71 mapModel.endTransaction();
81 final Size2D mapSize = mapModel.getMapArchObject().getMapSize();
82 final int mapWidth = mapSize.
getWidth();
83 final int mapHeight = mapSize.
getHeight();
90 if (mapModel.isAreaEmpty(mapWidth - 1, 0, 1, mapHeight)) {
93 if (mapModel.isAreaEmpty(0, mapHeight - 1, mapWidth, 1)) {
A MapModel reflects the data of a map.
Utility class to remove empty squares from a map's border.
Base package of all Gridarta classes.
static void shrinkMap(@NotNull final MapModel<?, ?, ?> mapModel, final int shrinkFlags)
Removes empty squares from a map's border.
int getWidth()
Returns the width of the area.
static final int SHRINK_EAST
Flag value: remove empty space from east border.
static int getShrinkFlags(@NotNull final MapModel<?, ?, ?> mapModel)
Returns which borders contain empty squares.
int getHeight()
Returns the height of the area.
static final int SHRINK_SOUTH
Flag value: remove empty space from south border.
The class Size2D represents a 2d rectangular area.
ShrinkMapSizeUtils()
Private constructor to prevent instantiation.