 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.panel.objectchooser;
22 import java.awt.BorderLayout;
23 import java.awt.Point;
24 import java.util.ArrayList;
25 import java.util.Collection;
26 import java.util.Collections;
27 import java.util.List;
28 import javax.swing.JPanel;
29 import javax.swing.JTabbedPane;
30 import javax.swing.SwingConstants;
31 import javax.swing.event.ChangeListener;
52 import org.jetbrains.annotations.NotNull;
53 import org.jetbrains.annotations.Nullable;
89 private final JTabbedPane
tabbedPane =
new JTabbedPane(SwingConstants.TOP);
95 private final List<ObjectChooserTab<G, A, R>>
tabs =
new ArrayList<>();
101 private final Collection<ObjectChooserListener<G, A, R>>
listeners =
new ArrayList<>();
139 public void mapCursorChangedPos(@NotNull
final Point location) {
144 public void mapCursorChangedMode() {
149 public void mapCursorChangedGameObject(@Nullable
final MapSquare<G, A, R> mapSquare, @Nullable
final G gameObject) {
154 public void mapCursorChangedSize() {
168 public DefaultObjectChooser(@NotNull
final ObjectChooserTab<G, A, R> archetypeChooserControl, @NotNull
final ObjectChooserTab<G, A, R> pickmapChooserControl, @NotNull
final ArchetypeChooserModel<G, A, R> archetypeChooserModel, @NotNull
final PickmapChooserModel<G, A, R> pickmapChooserModel, @NotNull
final ArchetypeTypeSet archetypeTypeSet) {
169 super(
new BorderLayout());
176 addTab(archetypeChooserControl);
199 public void selectedArchetypeChanged(@Nullable
final R selectedArchetype) {
206 public void directionChanged(@Nullable
final Integer direction) {
235 public void pickmapModifiedChanged(
final int index, @NotNull
final PickmapState<G, A, R> pickmapState) {
240 pickmapChooserModel.addPickmapChooserListener(pickmapChooserModelListener);
251 tabbedPane.addTab(tab.getTitle(), tab.getComponent());
261 tab =
tabs.get(index);
262 }
catch (
final IndexOutOfBoundsException ignored) {
344 final int index =
tabbedPane.getSelectedIndex();
381 if (mapCursor ==
null) {
384 final Point location = mapCursor.getLocation();
389 if (pickmap ==
null) {
412 listener.selectionChanged(gameObject);
Defines types of GameObjects with corresponding attributes.
List<? extends BaseObject< G, A, R, ?> > getSelections()
Returns the selected game objects.
A MapModel reflects the data of a map.
boolean isMatching(@NotNull final G gameObject)
Returns whether a given game object matches the selection.
void addTab(@NotNull final ObjectChooserTab< G, A, R > tab)
Adds a tab.
void setActive(boolean active)
Called whenever this tab becomes active or inactive.
Classes implementing the pickmap chooser.
void addObjectChooserListener(@NotNull final ObjectChooserListener< G, A, R > listener)
The view of the archetype chooser.
MapView< G, A, R > activePickmapView
The MapView of activePickmapState.
Base package of all Gridarta classes.
MapView< G, A, R > getMapView()
Returns the MapView instance for this pickmap.
G getFirst(@NotNull final GameObjectMatcher gameObjectMatcher)
Returns the first occurrence of a matching game object.
final List< ObjectChooserTab< G, A, R > > tabs
The tabs in the same order as tabbedPane.
ObjectChooserTab< G, A, R > activeTab
The active tab or.
final ObjectChoiceDisplay objectChoiceDisplay
The ObjectChoiceDisplay that display information about the currently selected object.
Interface for listeners for pickmap related events.
final ObjectChooserTab< G, A, R > pickmapChooserControl
The pickmap chooser control.
void removeObjectChooserListener(@NotNull final ObjectChooserListener< G, A, R > listener)
Reflects a game object (object on a map).
Manages ArchetypeType instances, list, and bitmask definitions.
Interface for listeners listening to MapCursor related events.
final ArchetypeChooserModel< G, A, R > archetypeChooserModel
The ArchetypeChooserModel.
Graphical User Interface of Gridarta.
void movePickmapChooserToFront()
A named folder within the ArchetypeChooserModel.
MapCursor< G, A, R > getMapCursor()
Returns the MapCursor of this view.
void moveArchetypeChooserToFront()
ArchetypeChooserPanel< G, A, R > getSelectedPanel()
Returns the selected ArchetypeChooserPanel.
GameObjects are the objects based on Archetypes found on maps.
final boolean isPickmapActive()
Interface for MapArchObjects.
A named panel within the ArchetypeChooserModel.
A map view consists of a map grid and a map cursor, and is attached to a map control.
void updateSelectedIndex()
Updates selectedIndex.
void removeMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Remove a MapCursorListener.
Maintains loaded PickmapState instances.
MapCursor provides methods to move and drag on map.
DefaultObjectChooser(@NotNull final ObjectChooserTab< G, A, R > archetypeChooserControl, @NotNull final ObjectChooserTab< G, A, R > pickmapChooserControl, @NotNull final ArchetypeChooserModel< G, A, R > archetypeChooserModel, @NotNull final PickmapChooserModel< G, A, R > pickmapChooserModel, @NotNull final ArchetypeTypeSet archetypeTypeSet)
Creates a new instance.
Common base interface for ObjectChoosers.
Maintains the state of a pickmap file.
List<? extends BaseObject< G, A, R, ?> > getSelections()
void addArchetypeChooserModelListener(@NotNull final ArchetypeChooserModelListener< G, A, R > listener)
Adds a listener to be notified of changes.
void addMapCursorListener(@NotNull final MapCursorListener< G, A, R > listener)
Register a MapCursorListener.
void updatePickmapInfo(@Nullable final MapCursor< G, A, R > mapCursor)
Updates the display information for the active pickmap.
MapSquare< G, A, R > getMapSquare(@NotNull Point pos)
Get the square at a specified location.
final Collection< ObjectChooserListener< G, A, R > > listeners
The registered listeners.
void showObjectChooserQuickObject(@Nullable final BaseObject<?, ?, ?, ?> gameObject, final boolean isPickmapActive)
Displays information about the selected game object.
final JTabbedPane tabbedPane
Panel holding both archetype chooser and pickmap chooser.
final MapCursorListener< G, A, R > mapCursorListener
The map cursor listener attached to activePickmapView.
void fireSelectionChanged(@Nullable final BaseObject< G, A, R, ?> gameObject)
Notifies all listeners that the selection may have changed.
The object Chooser implementation.
Base classes for rendering maps.
boolean isMatching(@NotNull G gameObject)
Returns whether the current selection matches the given game object.
R getSelectedArchetype()
Returns the selected Archetype.
int selectedIndex
The current state of selection.
void updateActivePickmap()
Updates the display state after activePickmapState has changed.
Currently nothing more than a marker interface for unification.
MapModel< G, A, R > getMapModel()
Returns the map model.
final BaseObject< G, A, R, ?> getSelection()
Abstract base class for classes implementing display modes of the archetype chooser.
void setActiveTab(final int index)
Records whether the archetype chooser or the pickmap chooser is active.
The object choice display shows information about the selected object in the object chooser.
BaseObject< G, A, R, ?> cursorSelection
The last reported selection.
PickmapState< G, A, R > activePickmapState
The last known active PickmapState.
Interface for listeners interested in ArchetypeChooserModel related events.
BaseObject< G, A, R, ?> getSelection()
Returns the selected game object.
ArchetypeChooserFolder< G, A, R > getSelectedFolder()
Returns the selected ArchetypeChooserFolder.
BaseObject< G, A, R, ?> getCursorSelection()
static final long serialVersionUID
The serial version UID.
MapControl< G, A, R > getPickmap()
Returns the MapControl representing this pickmap.
void updateActivePickmap(@Nullable final PickmapState< G, A, R > pickmapState)
Records an active pickmap.