Gridarta Editor
CleanCompletelyBlockedSquaresAction.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 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.action;
21 
22 import javax.swing.Action;
32 import net.sf.japi.swing.action.ActionMethod;
33 import org.jetbrains.annotations.NotNull;
34 
38 public class CleanCompletelyBlockedSquaresAction<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>> implements EditorAction {
39 
40  @NotNull
42 
46  public CleanCompletelyBlockedSquaresAction(@NotNull final MapManager<G, A, R> mapManager) {
47  this.mapManager = mapManager;
48  }
49 
55  @ActionMethod
57  final MapControl<G, A, R> mapControl = mapManager.getCurrentMap();
58  if (mapControl == null) {
59  return;
60  }
61 
62  final MapModel<G, A, R> mapModel = mapControl.getMapModel();
63  mapModel.beginTransaction("cleanCompletelyBlockedSquares"); // TODO: I18N/L10N
64  try {
65  for (final GameObjectContainer<G, A, R> completelyBlockedSquare : BlockedSquareChecker.findCompletelyBlockedSquares(mapModel)) {
66  completelyBlockedSquare.removeAll();
67  }
68  } finally {
69  mapModel.endTransaction();
70  }
71  }
72 
73  @Override
74  public void setAction(@NotNull final Action action, @NotNull final String name) {
75  }
76 
77 }
A MapModel reflects the data of a map.
Definition: MapModel.java:75
A MapManager manages all opened maps.
Definition: MapManager.java:37
This package contains the framework for validating maps.
void endTransaction()
End a transaction.
Base class for classes that contain GameObjects as children in the sense of containment.
MapModel< G, A, R > getMapModel()
Returns the map model.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Definition: GameObject.java:36
A global editor action.
CleanCompletelyBlockedSquaresAction(@NotNull final MapManager< G, A, R > mapManager)
Creates a new instance.
GameObjects are the objects based on Archetypes found on maps.
void cleanCompletelyBlockedSquares()
The action method for "cleanCompletelyBlockedSquares".
MapControl< G, A, R > getCurrentMap()
Returns the current map.
Currently nothing more than a marker interface for unification.
Definition: MapControl.java:35
This package contains the checks for validating maps.
void beginTransaction(@NotNull String name)
Starts a new transaction.
A MapValidator to assert that a square that&#39;s blocked and no_pass is not surrounded by blocked and no...
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.