 |
Gridarta Editor
|
Go to the documentation of this file.
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");
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) {
170 }
else if ((modifiers & InputEvent.CTRL_DOWN_MASK) != 0) {
204 throw new AssertionError();
214 final Container panel =
new JPanel();
215 panel.setLayout(
new GridBagLayout());
217 final GridBagConstraints gbcLabel =
new GridBagConstraints();
218 gbcLabel.anchor = GridBagConstraints.EAST;
220 final GridBagConstraints gbcComboBox =
new GridBagConstraints();
221 gbcComboBox.fill = GridBagConstraints.HORIZONTAL;
222 gbcComboBox.weightx = 1.0;
223 gbcComboBox.gridwidth = GridBagConstraints.REMAINDER;
225 final GridBagConstraints gbcCheckBox =
new GridBagConstraints();
226 gbcCheckBox.fill = GridBagConstraints.HORIZONTAL;
227 gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER;
241 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"), };
242 final JComboBox<?> comboBox =
new JComboBox<>(options);
InsertionMode getTopmostInsertionMode()
Returns the "topmost" insertion mode.
A MouseOpEvent is an event triggered for a MouseOpListener.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
Base package of all Gridarta classes.
final void deactivate()
Cursor gets deactivated.
void dragSelect(@NotNull final SelectionMode selectionMode, final boolean forceSelect)
Leave drag mode and select pre-selection using selectionMode.
final Point dragStart
Position where dragging has started.
SUB
All squares that are preselected get unselected.
FLIP
All squares that are preselected change state of selection.
Reflects a game object (object on a map).
InsertionMode getBelowFloorInsertionMode()
Returns the "below floor" insertion mode.
Graphical User Interface of Gridarta.
InsertionMode getAutoInsertionMode()
Returns the "auto" insertion mode.
GameObjects are the objects based on Archetypes found on maps.
List<? extends BaseObject< G, A, R, ?> > getSelections()
Returns the selected arches in the left-side panel.
Utility class for Swing related functions.
Interface for MapArchObjects.
A map view consists of a map grid and a map cursor, and is attached to a map control.
Modes that describe how squares get selected.
MapCursor provides methods to move and drag on map.
InsertionMode getBottommostInsertionMode()
Returns the "bottommost" insertion mode.
void setLocation(@NotNull final Point p)
Move cursor to a new location.
boolean isOnGrid(@Nullable final Point p)
Check if point is on grid.
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
Returns the value of a key.
Common base interface for ObjectChoosers.
final void beginTransaction()
Start a new transaction.
ADD
All squares that are preselected get selected.
Utility class implementing fill operations on map instances.
Base classes for rendering maps.
static Component createLabel(@NotNull final String key, @Nullable final Component component)
Creates a javax.swing.JLabel instance.
InsertionMode getAboveFloorInsertionMode()
Returns the "above floor" insertion mode.
Utility class for ActionBuilder related functions.
MapModel< G, A, R > getMapModel()
Returns the map model.
List< MapSquare< G, A, R > > getSelectedSquares()
Returns the selected squares.
void dragRelease()
Leave drag mode and undo pre-selection.
static< G extends GameObject< G, A, R > A extends R extends Archetype< G, A, R > void fill(@NotNull final MapModel< G, A, R > mapModel, @NotNull final Collection< MapSquare< G, A, R >> selection, @NotNull final InsertionMode insertionMode, @NotNull final List<? extends BaseObject< G, A, R, ?>> gameObjects, final int density, final boolean noAdjacent)
final void endTransaction()
End a transaction.