 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.utils;
22 import java.awt.Component;
23 import java.awt.GridBagConstraints;
24 import java.awt.GridBagLayout;
25 import java.awt.Insets;
26 import java.util.ArrayList;
27 import java.util.Collection;
28 import java.util.HashMap;
30 import javax.swing.AbstractButton;
31 import javax.swing.ButtonGroup;
32 import javax.swing.JPanel;
33 import javax.swing.JToggleButton;
34 import net.
sf.japi.swing.action.ActionBuilder;
35 import net.
sf.japi.swing.action.ActionBuilderFactory;
36 import net.
sf.japi.swing.action.ActionMethod;
37 import org.jetbrains.annotations.NotNull;
38 import org.jetbrains.annotations.Nullable;
59 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
83 private final Map<Integer, JToggleButton>
directions =
new HashMap<>(9);
95 super(
new GridBagLayout());
96 final GridBagConstraints gbc =
new GridBagConstraints();
97 gbc.fill = GridBagConstraints.BOTH;
98 gbc.anchor = GridBagConstraints.CENTER;
99 gbc.insets =
new Insets(1, 1, 1, 1);
109 if (includeDefault) {
132 if (selectedButton !=
null) {
133 selectedButton.setSelected(
true);
144 private void createButton(@Nullable
final Integer
direction, @NotNull
final GridBagConstraints gbc,
final int x,
final int y) {
145 final JToggleButton button =
new JToggleButton(
ACTION_BUILDER.createAction(
false,
"direction" +
direction,
this));
147 button.setFocusable(
false);
154 button.setSelected(
true);
246 super.setEnabled(enabled);
256 button.setEnabled(enabled);
final Map< Integer, JToggleButton > directions
Maps direction to button.
final Collection< JToggleButton > directionButtons
The buttons in directionButtonGroup.
void direction7()
Action method for direction.
boolean enableButtons
Whether the buttons are currently enabled.
static final ActionBuilder ACTION_BUILDER
The ActionBuilder instance.
void direction8()
Action method for direction.
void direction2()
Action method for direction.
final void updateEnabled(final boolean enableButtons)
Enables/disables the direction buttons for a given archetype.
static final long serialVersionUID
The serial version UID.
void setEnabled(final boolean enabled)
void createButton(@Nullable final Integer direction, @NotNull final GridBagConstraints gbc, final int x, final int y)
Creates a direction button.
void direction5()
Action method for direction.
void direction6()
Action method for direction.
void direction4()
Action method for direction.
A GUI component for selecting a direction.
final ButtonGroup directionButtonGroup
The ButtonGroup for the direction buttons.
void direction3()
Action method for direction.
static final Insets EMPTY_INSETS
Empty Insets.
final void updateDirection(@Nullable final Integer direction)
Sets the selected direction.
void direction1()
Action method for direction.
void updateEnabled()
Enables/disables the buttons.
abstract void direction(@Nullable Integer direction)
Called whenever a direction button has been selected.
void direction0()
Action method for direction.
DirectionComponent(final boolean includeDefault)
Creates a new instance.
void directionnull()
Action method for default direction.