 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.panel.pickmapchooser;
22 import java.awt.Component;
24 import java.io.IOException;
25 import javax.swing.BorderFactory;
26 import javax.swing.JPopupMenu;
27 import javax.swing.JTabbedPane;
28 import javax.swing.SwingConstants;
29 import javax.swing.event.ChangeListener;
49 import org.apache.log4j.Category;
50 import org.apache.log4j.Logger;
51 import org.jetbrains.annotations.NotNull;
52 import org.jetbrains.annotations.Nullable;
100 private final JTabbedPane
pickmapPanel =
new JTabbedPane(SwingConstants.TOP);
186 public void pickmapModifiedChanged(
final int index, @NotNull
final PickmapState<G, A, R> pickmapState) {
200 public PickmapChooserView(@NotNull
final PickmapChooserModel<G, A, R> pickmapChooserModel, @NotNull
final MapFolderTree<G, A, R> mapFolderTree, @NotNull
final MapArchObjectFactory<A> mapArchObjectFactory, @NotNull
final MapReaderFactory<G, A> mapReaderFactory, @NotNull
final MapManager<G, A, R> pickmapManager) {
238 pickmapState.loadPickmap();
239 }
catch (
final IOException ex) {
240 LOG.warn(
"cannot load pickmap " + pickmapState.getFile() +
": " + ex.getMessage());
294 final String
name = pickmapState.getFile().getName();
297 return modified ?
name +
" *" :
name;
326 if (activeMapFolder ==
null) {
331 throw new IOException(
"invalid pickmap name: " + pickmapName);
335 if (pickmapName.equals(pickmapState.getFile().getName())) {
341 if (mapFile2.
getFile().isDirectory()) {
342 throw new IOException(
"pickmap file is a directory: " + mapFile2);
344 if (mapFile2.
getFile().exists()) {
345 throw new IOException(
"pickmap file exists: " + mapFile2);
348 final File dir = mapFile2.
getFile().getParentFile();
351 throw new IOException(
"cannot create directory: " + dir);
356 mapArchObject.setMapSize(mapSize);
357 mapArchObject.setMapName(pickmapName);
369 throw new AssertionError(ex);
A View for choosing pickmaps.
String getTitle(@NotNull final PickmapState< G, A, R > pickmapState)
Returns the title of a pickmap to use as the tab name.
Interface for listeners interested in events of MapFolderTrees.
A MapManager manages all opened maps.
void setPopupMenu(@NotNull final JPopupMenu popupMenu)
Sets the popup menu to show.
final MapManager< G, A, R > pickmapManager
The MapManager instance for loading pickmaps.
Base package of all Gridarta classes.
A factory for creating MapReader instances.
Stores all known MapFiles.
static boolean isValidPickmapName(@NotNull final CharSequence name)
Returns whether a pickmap name is valid.
void addFolderListener(@NotNull final MapFolderListener< G, A, R > listenerMap)
Adds a MapFolderListener to be notified of events.
void setActivePickmap(@NotNull final PickmapState< G, A, R > pickmapState)
Sets the active pickmap.
int indexOf(@NotNull final PickmapState< G, A, R > pickmapState)
Returns the index of a map file.
void removeFolderListener(@NotNull final MapFolderListener< G, A, R > listenerMap)
Removes a MapFolderListener to be notified of events.
Class with constants used in Gridarta and derivates.
MapControl< G, A, R > newMap(@Nullable List< G > objects, @NotNull A mapArchObject, @Nullable MapFile mapFile, boolean interactive)
Creates a new map control without view.
final PickmapChooserModel< G, A, R > pickmapChooserModel
The attached PickmapChooserModel.
Interface for listeners interested in events of MapFolders.
static MapPath newMapPath(@NotNull final String string)
Creates a MapPath instance from string representation.
Reflects a game object (object on a map).
Utility class for MapPath related functions.
int removeMapFile(@NotNull final PickmapState< G, A, R > pickmapState)
Removes a map file.
boolean isModified()
Return whether the map has been modified from the on-disk state.
Indicates that a pickmap name is not unique within its folder.
final MapArchObjectFactory< A > mapArchObjectFactory
The MapArchObjectFactory instance.
Graphical User Interface of Gridarta.
final MapFolderTree< G, A, R > mapFolderTree
The model to display.
File getDir()
Returns the base directory.
int revertMapFile(@NotNull final MapControl< G, A, R > oldPickmap, @NotNull final PickmapState< G, A, R > pickmapState)
Reverts a map file.
GameObjects are the objects based on Archetypes found on maps.
PickmapChooserView(@NotNull final PickmapChooserModel< G, A, R > pickmapChooserModel, @NotNull final MapFolderTree< G, A, R > mapFolderTree, @NotNull final MapArchObjectFactory< A > mapArchObjectFactory, @NotNull final MapReaderFactory< G, A > mapReaderFactory, @NotNull final MapManager< G, A, R > pickmapManager)
Creates a new instance.
static final Category LOG
The Logger for printing log messages.
Indicates that a folder or pickmap name is invalid.
Interface for MapArchObjects.
void activeMapFolderChanged(@Nullable MapFolder< G, A, R > mapFolder)
The active folder has changed.
File getFile()
Returns a File for this map file.
final JTabbedPane pickmapPanel
Panel with pickmaps.
Model class representing a folder of MapFiles.
PickmapState< G, A, R > addPickmap(@NotNull final String name, @NotNull final MapReaderFactory< G, A > mapReaderFactory, @NotNull final MapManager< G, A, R > pickmapManager)
Adds a new PickmapState to this folder.
A map view consists of a map grid and a map cursor, and is attached to a map control.
int getSelectedIndex()
Returns the selected index.
JScrollPane getScrollPane()
Returns the JScrollPane of this map view.
void save()
Saves the map to a file.
The location of a map file with a map directory.
Component getPickmapPanel()
Returns the JTabbedPane with all pickmaps.
Reading and writing of maps, handling of paths.
Maintains the state of a pickmap file.
void release(@NotNull MapControl< G, A, R > mapControl)
Releases a MapControl instance.
MapFolder< G, A, R > activeMapFolder
The last known active folder.
void addPickmapChooserListener(@NotNull final PickmapChooserModelListener< G, A, R > pickmapChooserModelListener)
Adds a PickmapChooserModelListener to be notified.
void clear()
Removes all map files.
final MapFolderTreeListener< G, A, R > mapFolderTreeListener
The listener attached to mapFolderTree.
final MapFolderListener< G, A, R > mapFolderListener
The listener attached to activeMapFolder.
int addMapFile(@NotNull final PickmapState< G, A, R > pickmapState)
Adds a map file.
void newPickmap(@NotNull final Size2D mapSize, @NotNull final String pickmapName)
Add a new pickmap.
void addModelListener(@NotNull final MapFolderTreeListener< G, A, R > listener)
Adds a MapFolderTreeListener to be informed about changes.
Base classes for rendering maps.
void addChangeListener(@NotNull final ChangeListener changeListener)
Adds a ChangeListener to be notified when the selected pickmap tab changes.
final MapReaderFactory< G, A > mapReaderFactory
The map reader factory instance.
Currently nothing more than a marker interface for unification.
final PickmapChooserModelListener< G, A, R > pickmapChooserModelListener
The PickmapChooserModelListener attached to {} to detect modified pickmaps.
void revertPickmap(@NotNull final PickmapState< G, A, R > pickmapState, @NotNull final MapControl< G, A, R > oldPickmap)
Called when a pickmap in the model has been reverted.
MapModel< G, A, R > getMapModel()
Returns the map model.
MapFolder< G, A, R > getActiveMapFolder()
Returns the active map folder.
void removePickmap(@NotNull final PickmapState< G, A, R > pickmapState)
Called when a pickmap has been removed from the model.
A newMapArchObject(boolean addDefaultAttributes)
Creates a new MapArchObject instance.
The class Size2D represents a 2d rectangular area.
static final int SPACE_PICKMAP_ARCHETYPE_TOP
The height of rigid area between the two tab-panes on the pickmap- and archetype-panel.
Factory for creating MapArchObject instances.
void addPickmap(@NotNull final PickmapState< G, A, R > pickmapState)
Called when a new pickmap has been added to the model.