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.awt.event.InputEvent;
28 import javax.swing.JComboBox;
29 import javax.swing.JPanel;
43 import net.
sf.japi.swing.action.ActionBuilder;
44 import net.
sf.japi.swing.action.ActionBuilderFactory;
45 import net.
sf.japi.swing.action.ActionMethod;
46 import net.
sf.japi.swing.action.ToggleAction;
47 import org.jetbrains.annotations.NotNull;
48 import org.jetbrains.annotations.Nullable;
85 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta.gui.panel.tools");
91 private final ToggleAction
autoFillAction = (ToggleAction) ACTION_BUILDER.createToggle(
true,
"selectionToolAutoFill",
this);
130 final Point mapLoc = e.getMapLocation();
131 if (mapLoc == null) {
134 final int mod = e.getModifiers();
140 if ((mod & (InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK)) == 0) {
156 e.getMapCursor().dragTo(e.getMapLocation());
166 final int modifiers = e.getModifiers();
167 if (mapCursor.
isOnGrid(e.getMapLocation())) {
168 if ((modifiers & InputEvent.SHIFT_DOWN_MASK) != 0) {
169 if ((modifiers & InputEvent.CTRL_DOWN_MASK) == 0) {
174 }
else if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
183 if (selectionToolAutoFill) {
184 final int modeIndex = modeComboBox.getSelectedIndex();
208 throw new AssertionError();
218 final Container panel =
new JPanel();
219 panel.setLayout(
new GridBagLayout());
221 final GridBagConstraints gbcLabel =
new GridBagConstraints();
222 gbcLabel.anchor = GridBagConstraints.EAST;
224 final GridBagConstraints gbcComboBox =
new GridBagConstraints();
225 gbcComboBox.fill = GridBagConstraints.HORIZONTAL;
226 gbcComboBox.weightx = 1.0;
227 gbcComboBox.gridwidth = GridBagConstraints.REMAINDER;
229 final GridBagConstraints gbcCheckBox =
new GridBagConstraints();
230 gbcCheckBox.fill = GridBagConstraints.HORIZONTAL;
231 gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER;
233 panel.add(autoFillAction.createCheckBox(), gbcCheckBox);
235 panel.add(modeComboBox, gbcComboBox);
245 final String[] options = {
ActionBuilderUtils.
getString(ACTION_BUILDER,
"selectionTool.mode.auto"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"selectionTool.mode.topmost"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"selectionTool.mode.aboveFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"selectionTool.mode.belowFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"selectionTool.mode.bottommost"), };
246 final JComboBox<?> comboBox =
new JComboBox<>(options);
266 if (this.selectionToolAutoFill == selectionToolAutoFill) {
278 modeComboBox.setEnabled(selectionToolAutoFill);
void dragSelect(@NotNull final SelectionMode selectionMode, final boolean forceSelect)
Leave drag mode and select pre-selection using selectionMode.
InsertionMode< G, A, R > getAutoInsertionMode()
Returns the "auto" insertion mode.
List< MapSquare< G, A, R > > getSelectedSquares()
Returns the selected squares.
Graphical User Interface of Gridarta.
MapCursor provides methods to move and drag on map.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
final void beginTransaction()
Start a new transaction.
Utility class for Swing related functions.
final void endTransaction()
End a transaction.
boolean isOnGrid(@Nullable final Point p)
Check if point is on grid.
MapModel< G, A, R > getMapModel()
Returns the map model.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
void setLocation(@NotNull final Point p)
Move cursor to a new location.
Base package of all Gridarta classes.
InsertionMode< G, A, R > getAboveFloorInsertionMode()
Returns the "above floor" insertion mode.
Reflects a game object (object on a map).
InsertionMode< G, A, R > getBottommostInsertionMode()
Returns the "bottommost" insertion mode.
InsertionMode< G, A, R > getTopmostInsertionMode()
Returns the "topmost" insertion mode.
GameObjects are the objects based on Archetypes found on maps.
FLIP
All squares that are preselected change state of selection.
void dragRelease()
Leave drag mode and undo pre-selection.
List<? extends BaseObject< G, A, R, ?> > getSelections()
Returns the selected arches in the left-side panel.
Base classes for rendering maps.
final Point dragStart
Position where dragging has started.
Utility class for ActionBuilder related functions.
A MouseOpEvent is an event triggered for a MouseOpListener.
A map view consists of a map grid and a map cursor, and is attached to a map control.
static Component createLabel(@NotNull final String key, @Nullable final Component component)
Create a javax.swing.JLabel instance.
ADD
All squares that are preselected get selected.
Utility class implementing fill operations on map instances.
Modes that describe how squares get selected.
SUB
All squares that are preselected get unselected.
Common base interface for ObjectChoosers.
final void deactivate()
Cursor gets deactivated.
InsertionMode< G, A, R > getBelowFloorInsertionMode()
Returns the "below floor" insertion mode.
Interface for MapArchObjects.