20 package net.sf.gridarta.gui.panel.tools;
22 import java.awt.Component;
23 import java.awt.Container;
24 import java.awt.GridBagConstraints;
25 import java.awt.GridBagLayout;
26 import java.awt.Point;
27 import java.util.Collection;
28 import java.util.HashSet;
29 import javax.swing.JComboBox;
30 import javax.swing.JPanel;
45 import net.
sf.japi.swing.action.ActionBuilder;
46 import net.
sf.japi.swing.action.ActionBuilderFactory;
47 import net.
sf.japi.swing.action.ActionMethod;
48 import net.
sf.japi.swing.action.ToggleAction;
49 import org.jetbrains.annotations.NotNull;
50 import org.jetbrains.annotations.Nullable;
108 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta.gui.panel.tools");
150 private final ToggleAction
ignoreWallsAction = (ToggleAction) ACTION_BUILDER.createToggle(
true,
"deletionToolExceptionsIgnoreWalls",
this);
156 private final ToggleAction
ignoreFloorsAction = (ToggleAction) ACTION_BUILDER.createToggle(
true,
"deletionToolExceptionsIgnoreFloors",
this);
162 private final ToggleAction
ignoreMonstersAction = (ToggleAction) ACTION_BUILDER.createToggle(
true,
"deletionToolExceptionsIgnoreMonsters",
this);
212 final Point mapLoc = e.getMapLocation();
216 if (mapLoc != null) {
233 final Point mapLoc = e.getMapLocation();
253 if (mapControl.isPickmap() && pickmapSettings.
isLocked()) {
258 final int scopeType = scopeComboBox.getSelectedIndex();
259 final int deleteType = deleteComboBox.getSelectedIndex();
270 start = floorGameObjectMatcher == null ? null : mapSquare.
getAfterLast(floorGameObjectMatcher);
276 end = floorGameObjectMatcher == null ? null : mapSquare.
getBeforeFirst(floorGameObjectMatcher);
297 if (start == null || end == null) {
300 final Collection<G> gameObjectsToDelete =
new HashSet<>();
301 boolean foundFirst =
false;
305 if (gameObject == start2) {
309 final G head = gameObject.
getHead();
311 boolean insert =
false;
326 if (wallGameObjectMatcher != null && wallGameObjectMatcher.
isMatching(head)) {
332 if (floorGameObjectMatcher != null && floorGameObjectMatcher.
isMatching(head)) {
338 if (deletionToolExceptionsIgnoreWalls && wallGameObjectMatcher != null && wallGameObjectMatcher.
isMatching(head)) {
340 }
else if (deletionToolExceptionsIgnoreFloors && floorGameObjectMatcher != null && floorGameObjectMatcher.
isMatching(head)) {
342 }
else if (deletionToolExceptionsIgnoreMonsters && monsterGameObjectMatcher != null && monsterGameObjectMatcher.
isMatching(head)) {
345 gameObjectsToDelete.add(head);
346 if (deleteType != DELETE_ALL) {
352 if (gameObject == end2) {
357 if (!gameObjectsToDelete.isEmpty()) {
361 for (
final G gameObjectToDelete : gameObjectsToDelete) {
373 final Container panel =
new JPanel();
374 panel.setLayout(
new GridBagLayout());
376 final GridBagConstraints gbcLabel =
new GridBagConstraints();
377 gbcLabel.anchor = GridBagConstraints.EAST;
379 final GridBagConstraints gbcComboBox =
new GridBagConstraints();
380 gbcComboBox.fill = GridBagConstraints.HORIZONTAL;
381 gbcComboBox.weightx = 1.0;
382 gbcComboBox.gridwidth = GridBagConstraints.REMAINDER;
384 final GridBagConstraints gbcCheckBox =
new GridBagConstraints();
385 gbcCheckBox.fill = GridBagConstraints.HORIZONTAL;
386 gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER;
389 panel.add(deleteComboBox, gbcComboBox);
392 panel.add(scopeComboBox, gbcComboBox);
394 panel.add(ignoreWallsAction.createCheckBox(), gbcCheckBox);
395 panel.add(ignoreFloorsAction.createCheckBox(), gbcCheckBox);
396 panel.add(ignoreMonstersAction.createCheckBox(), gbcCheckBox);
407 final JComboBox<?> comboBox =
new JComboBox<>(options);
418 final String[] options = {
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.square"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.aboveFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.belowFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.selectedObject"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.wall"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"deletionTool.scope.floor"), };
419 final JComboBox<?> comboBox =
new JComboBox<>(options);
T getHead()
Return the head part of a multi-part object.
Iterable< G > reverse()
Return an object that is the reverse representation.
A MapModel reflects the data of a map.
boolean isAutojoin()
Returns whether "autojoin" is enabled.
Graphical User Interface of Gridarta.
Interface for classes that match GameObjects.
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
boolean isMatching(@NotNull G gameObject)
Returns whether the current selection matches a given game object.
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
void endTransaction()
End a transaction.
void removeGameObject(@NotNull G gameObject, boolean join)
Delete an existing GameObject from the map.
boolean isEditType(int editType)
Get information on the current state of edit type.
MapCursor provides methods to move and drag on map.
G getAfterLast(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the game object after the last occurrence of a matching game object.
Utility class for Swing related functions.
boolean setLocationSafe(@Nullable final Point p)
Move cursor to a new location.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Container for settings that affect the rendering of maps.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
GameObjects are the objects based on Archetypes found on maps.
G getFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
G getBeforeFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the game object before the first occurrence of a matching game object.
Base classes for rendering maps.
Utility class for ActionBuilder related functions.
Currently nothing more than a marker interface for unification.
A MouseOpEvent is an event triggered for a MouseOpListener.
static Component createLabel(@NotNull final String key, @Nullable final Component component)
Create a javax.swing.JLabel instance.
boolean isLocked()
Returns whether pickmaps are immutable.
Common base interface for ObjectChoosers.
void beginTransaction(@NotNull String name)
Starts a new transaction.
G getLast(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the last occurrence of a matching game object.
Interface for MapArchObjects.
boolean isMatching(@NotNull GameObject<?, ?, ?> gameObject)
Matches an GameObject.
Container for settings that affect pickmaps.