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 javax.swing.JComboBox;
28 import javax.swing.JPanel;
45 import net.
sf.japi.swing.action.ActionBuilder;
46 import net.
sf.japi.swing.action.ActionBuilderFactory;
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");
131 public InsertionTool(@NotNull
final SelectedSquareModel<G, A, R> selectedSquareModel, @NotNull
final ObjectChooser<G, A, R> objectChooser, @NotNull
final PickmapSettings pickmapSettings, @NotNull
final InsertionModeSet<G, A, R> insertionModeSet, @NotNull
final MapViewSettings mapViewSettings) {
175 final Point p = e.getMapLocation();
198 @Nullable
final G insertedObject;
201 if (selectedGameObject != null) {
202 final G head = selectedGameObject.
getHead();
205 final Point point =
new Point();
206 for (R part = head.getArchetype(); part != null; part = part.getMultiNext()) {
207 point.x = p.x + part.getMultiX();
208 point.y = p.y + part.getMultiY();
216 insertedObject = null;
218 final int modeIndex = modeComboBox.getSelectedIndex();
242 throw new AssertionError();
245 insertedObject = selectedArchetype == null ? null : mapModel.
insertBaseObject(selectedArchetype, p, isPressed || modeIndex == MODE_AUTO, mapViewSettings.
isAutojoin(), insertionMode);
256 final Container panel =
new JPanel();
257 panel.setLayout(
new GridBagLayout());
259 final GridBagConstraints gbcLabel =
new GridBagConstraints();
260 gbcLabel.anchor = GridBagConstraints.EAST;
262 final GridBagConstraints gbcComboBox =
new GridBagConstraints();
263 gbcComboBox.fill = GridBagConstraints.HORIZONTAL;
264 gbcComboBox.weightx = 1.0;
265 gbcComboBox.gridwidth = GridBagConstraints.REMAINDER;
267 final GridBagConstraints gbcCheckBox =
new GridBagConstraints();
268 gbcCheckBox.fill = GridBagConstraints.HORIZONTAL;
269 gbcCheckBox.gridwidth = GridBagConstraints.REMAINDER;
272 panel.add(modeComboBox, gbcComboBox);
281 final String[] options = {
ActionBuilderUtils.
getString(ACTION_BUILDER,
"insertionTool.mode.auto"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"insertionTool.mode.topmost"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"insertionTool.mode.aboveFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"insertionTool.mode.belowFloor"),
ActionBuilderUtils.
getString(ACTION_BUILDER,
"insertionTool.mode.bottommost"), };
282 final JComboBox<?> comboBox =
new JComboBox<>(options);
T getHead()
Return the head part of a multi-part object.
G getSelectedGameObject()
Returns the currently selected GameObject within this list (currently selected MapSquare).
InsertionMode< G, A, R > getAutoInsertionMode()
Returns the "auto" insertion mode.
boolean isPointValid(@Nullable Point pos)
Checks whether the given coordinate is within map bounds.
A MapModel reflects the data of a map.
boolean isAutojoin()
Returns whether "autojoin" is enabled.
Graphical User Interface of Gridarta.
void endTransaction()
End a transaction.
BaseObject< G, A, R, ?> getSelection()
Returns the active arch in the left-side panel.
MapCursor provides methods to move and drag on map.
Utility class for Swing related functions.
boolean setLocationSafe(@Nullable final Point p)
Move cursor to a new location.
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.
G insertBaseObject(@NotNull BaseObject< G, A, R, ?> baseObject, @NotNull Point pos, boolean allowMany, boolean join, @NotNull InsertionMode< G, A, R > insertionMode)
Inserts a BaseObject to a map.
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).
boolean isPickmap()
Return flag that indicates whether this is a pickmap or not.
InsertionMode< G, A, R > getBottommostInsertionMode()
Returns the "bottommost" insertion mode.
Container for settings that affect the rendering of maps.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
InsertionMode< G, A, R > getTopmostInsertionMode()
Returns the "topmost" insertion mode.
GameObjects are the objects based on Archetypes found on maps.
Displays the contents of the currently selected map square.
Base classes for rendering maps.
Utility class for ActionBuilder related functions.
A getMapArchObject()
Returns the Map Arch Object with the meta information about the map.
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.
void setSelectedGameObject(@Nullable final G gameObject)
Sets the currently selected GameObject.
Common base interface for ObjectChoosers.
void beginTransaction(@NotNull String name)
Starts a new transaction.
The model component of the selected square control.
InsertionMode< G, A, R > getBelowFloorInsertionMode()
Returns the "below floor" insertion mode.
Interface for MapArchObjects.
Container for settings that affect pickmaps.