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 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;
242 throw new AssertionError();
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;
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);
boolean isPointValid(@Nullable Point pos)
InsertionMode getTopmostInsertionMode()
boolean setLocationSafe(@Nullable final Point p)
void beginTransaction(@NotNull String name)
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
InsertionMode getAutoInsertionMode()
G getSelectedGameObject()
static Component createLabel(@NotNull final String key, @Nullable final Component component)
static String getString(@NotNull final ActionBuilder actionBuilder, @NotNull final String key, @NotNull final String defaultValue)
void setSelectedGameObject(@Nullable final G gameObject)
BaseObject< G, A, R, ?> getSelection()
G insertBaseObject(@NotNull BaseObject< G, A, R, ?> baseObject, @NotNull Point pos, boolean allowMany, boolean join, @NotNull InsertionMode insertionMode)
InsertionMode getBottommostInsertionMode()
InsertionMode getBelowFloorInsertionMode()
void setLocation(@NotNull final Point p)
MapModel< G, A, R > getMapModel()
InsertionMode getAboveFloorInsertionMode()