20 package net.sf.gridarta.gui.map;
22 import java.awt.Component;
23 import java.io.IOException;
25 import javax.swing.Action;
45 import net.
sf.japi.swing.action.ActionMethod;
46 import org.jetbrains.annotations.NotNull;
47 import org.jetbrains.annotations.Nullable;
136 public void mapSizeChanged(@NotNull
final Size2D newSize) {
146 public void mapObjectsChanged(@NotNull
final Set<G> gameObjects, @NotNull
final Set<G> transientGameObjects) {
156 public void mapFileChanged(@Nullable
final MapFile oldMapFile) {
161 public void modifiedChanged() {
176 if (currentMapControl != null) {
179 currentMapControl = mapControl;
180 if (currentMapControl != null) {
187 public void mapCreated(@NotNull
final MapControl<G, A, R> mapControl,
final boolean interactive) {
212 public MapFileActions(@NotNull
final ImageCreator2<G, A, R> imageCreator2, @NotNull
final MapManager<G, A, R> mapManager, @NotNull
final MapViewsManager<G, A, R> mapViewsManager, @NotNull
final MapViewManager<G, A, R> mapViewManager, @NotNull
final FileControl<G, A, R> fileControl, @NotNull
final Component mainView) {
218 mapManager.addMapManagerListener(mapManagerListener);
219 currentMapControl = mapManager.getCurrentMap();
220 if (currentMapControl != null) {
226 public void activeMapViewChanged(@Nullable
final MapView<G, A, R> mapView) {
227 currentMapView = mapView;
242 mapViewManager.addMapViewManagerListener(mapViewManagerListener);
243 currentMapView = mapViewManager.getActiveMapView();
252 if (currentMapControl != null) {
261 if (aSaveMap != null) {
265 if (aSaveMapAs != null) {
269 if (aCreateImage != null) {
273 if (aReloadMap != null) {
277 if (aCloseMap != null) {
329 private boolean doSaveMap(
final boolean performAction) {
336 if (!fileControl.
save(mapControl)) {
351 if (mapControl == null) {
356 if (!fileControl.
saveAs(mapControl)) {
371 if (mapView == null) {
390 if (mapControl == null) {
395 if (mapFile == null) {
401 mapManager.
revert(mapControl);
402 }
catch (
final IOException ex) {
418 if (mapView == null) {
430 public void setAction(@NotNull
final Action action, @NotNull
final String name) {
431 if (name.equals(
"saveMap")) {
433 }
else if (name.equals(
"saveMapAs")) {
435 }
else if (name.equals(
"createImage")) {
436 aCreateImage = action;
437 }
else if (name.equals(
"reloadMap")) {
439 }
else if (name.equals(
"closeMap")) {
442 throw new IllegalArgumentException();
void removeMapManagerListener(@NotNull MapManagerListener< G, A, R > listener)
Removes a MapManagerListener to be notified.
A MapModel reflects the data of a map.
Action aSaveMap
The action for "save map".
A MapManager manages all opened maps.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
void closeMapView(@NotNull final MapView< G, A, R > mapView)
Invoked when the user wants to close a map view.
Graphical User Interface of Gridarta.
boolean saveAs(@NotNull MapControl< G, A, R > mapControl)
Asks the user for a filename, then saves the map.
final ImageCreator2< G, A, R > imageCreator2
The ImageCreator2 to forwards actions to.
Action aCloseMap
The action for "close map".
MapFileActions(@NotNull final ImageCreator2< G, A, R > imageCreator2, @NotNull final MapManager< G, A, R > mapManager, @NotNull final MapViewsManager< G, A, R > mapViewsManager, @NotNull final MapViewManager< G, A, R > mapViewManager, @NotNull final FileControl< G, A, R > fileControl, @NotNull final Component mainView)
Create a new instance that tracks the map state.
This package contains the framework for validating maps.
final MapModelListener< G, A, R > mapModelListener
The MapModelListener which is attached to currentMapControl's map model.
MapControl< G, A, R > currentMapControl
The currently tracked map, or.
Interface for listeners listening on MapModel events.
void updateActions()
Update the enabled/disabled state of all actions.
Implements actions for the "file" menu attached to maps.
boolean doCloseMap(final boolean performAction)
Executes the "close map" action.
boolean isModified()
Return whether the map has been modified from the on-disk state.
Stores all existing MapViews.
MapControl< G, A, R > getMapControl()
Return the controller of this view.
void addMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Register a map listener.
void createImage()
Invoked when the user wants to create an image file of the map.
MapModel< G, A, R > getMapModel()
Returns the map model.
void revert(@NotNull MapControl< G, A, R > mapControl)
Reverts one map.
Base package of all Gridarta classes.
final FileControl< G, A, R > fileControl
The file control to forward actions to.
Reflects a game object (object on a map).
void reportLoadError(@Nullable File file, @NotNull String message)
final MapViewsManager< G, A, R > mapViewsManager
The MapViewsManager.
void closeMap()
Invoked when the user wants to close the map.
Interface for listeners listening to MapManager changes.
GameObjects are the objects based on Archetypes found on maps.
final Component mainView
The main view Component.
Creates images from map instances.
Interface for listeners interested in events related to MapViewManager instances. ...
Action aSaveMapAs
The action for "save map as".
MapView< G, A, R > currentMapView
The current map view, or.
boolean save(@NotNull MapControl< G, A, R > mapControl)
Save one map.
boolean doSaveMapAs(final boolean performAction)
Executes the "save map as" action.
Base classes for rendering maps.
void removeMapModelListener(@NotNull MapModelListener< G, A, R > listener)
Unregister a map listener.
Action aCreateImage
The action for "create image".
void closeNotify()
Unregister all registered listeners.
void createImage(@NotNull final MapModel< G, A, R > mapModel, @NotNull final Component component)
Create an image of a map and save it as a file.
boolean doCreateImage(final boolean performAction)
Executes the "create image" action.
Currently nothing more than a marker interface for unification.
final MapManagerListener< G, A, R > mapManagerListener
The map manager listener which is attached to the current map if the current map is tracked...
A map view consists of a map grid and a map cursor, and is attached to a map control.
MapFile getMapFile()
Returns the map file.
File getFile()
Returns a File for this map file.
final MapManager< G, A, R > mapManager
The map manager.
An interface for classes that collect errors.
void reloadMap()
Invoked when the user wants to reload the map to the previously saved state.
boolean doSaveMap(final boolean performAction)
Executes the "save map" action.
boolean doReloadMap(final boolean performAction)
Executes the "reload map" action.
void saveMap()
Invoked when the user wants to save the map.
void saveMapAs()
Invoked when the user wants to save the map to a file.
The location of a map file with a map directory.
Action aReloadMap
The action for "reload map".
Interface for MapArchObjects.
The class Size2D represents a 2d rectangular area.