20 package net.sf.gridarta.gui.panel.tools;
22 import java.awt.BorderLayout;
23 import java.awt.CardLayout;
24 import java.awt.Component;
25 import java.awt.Container;
26 import java.awt.FlowLayout;
27 import java.awt.Insets;
28 import java.awt.event.ActionEvent;
29 import java.util.HashMap;
31 import javax.swing.AbstractAction;
32 import javax.swing.AbstractButton;
33 import javax.swing.Action;
34 import javax.swing.ButtonGroup;
35 import javax.swing.JPanel;
36 import javax.swing.JToggleButton;
47 import net.
sf.japi.swing.action.ActionBuilder;
48 import net.
sf.japi.swing.action.ActionBuilderFactory;
49 import org.jetbrains.annotations.NotNull;
50 import org.jetbrains.annotations.Nullable;
68 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta.gui.panel.tools");
92 private final Container
optionsPane =
new JPanel(optionCards);
104 private final Map<String, Tool<G, A, R>>
tools =
new HashMap<>();
123 public ToolSelector(@NotNull
final String defaultTool, @NotNull
final MapViewSettings mapViewSettings, @NotNull
final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull
final ObjectChooser<G, A, R> objectChooser, @NotNull
final PickmapSettings pickmapSettings, @Nullable
final GameObjectMatcher floorGameObjectMatcher, @Nullable
final GameObjectMatcher wallGameObjectMatcher, @Nullable
final GameObjectMatcher monsterGameObjectMatcher, @NotNull
final InsertionModeSet<G, A, R> insertionModeSet) {
127 addTool(
new DeletionTool<>(mapViewSettings, objectChooser, pickmapSettings, floorGameObjectMatcher, wallGameObjectMatcher, monsterGameObjectMatcher), defaultTool);
128 addTool(
new InsertionTool<>(selectedSquareModel, objectChooser, pickmapSettings, insertionModeSet, mapViewSettings), defaultTool);
137 add(tool, tool.getId().equals(defaultTool));
144 setLayout(
new BorderLayout());
145 add(selectionPane, BorderLayout.NORTH);
146 add(optionsPane, BorderLayout.CENTER);
153 @SuppressWarnings(
"MethodOverloadsMethodOfSuperclass")
154 public
void add(@NotNull final
Tool<G, A, R> tool) {
165 @NotNull
final Action selectionAction =
new SelectionAction(tool);
166 @NotNull
final AbstractButton toggleButton =
new JToggleButton(selectionAction);
168 @NotNull
final Component optionsView = createOptionsView(tool);
170 selectionPane.add(toggleButton);
171 final Container panel =
new JPanel(
new BorderLayout());
172 panel.add(optionsView, BorderLayout.NORTH);
174 toggleButton.setSelected(selected);
175 tools.put(tool.getId(), tool);
192 @Nullable
final Component optionsView = tool.createOptionsView();
193 return optionsView != null ? optionsView :
new JPanel();
237 private static final long serialVersionUID = 1L;
251 ACTION_BUILDER.initAction(
false,
this, tool.getId());
261 public Object
clone() throws CloneNotSupportedException {
262 return super.clone();
Graphical User Interface of Gridarta.
Interface for classes that match GameObjects.
This package contains classes related to matching GameObjects, so called GameObjectMatchers.
Base package of all Gridarta classes.
Reflects a game object (object on a map).
Container for settings that affect the rendering of maps.
GameObjects are the objects based on Archetypes found on maps.
Displays the contents of the currently selected map square.
Base classes for rendering maps.
Interface for Mouse Operations.
Common base interface for ObjectChoosers.
The model component of the selected square control.
Interface for MapArchObjects.
Container for settings that affect pickmaps.