 |
Gridarta Editor
|
Go to the documentation of this file.
20 package net.sf.gridarta.gui.mapdesktop;
22 import java.awt.Component;
23 import java.beans.PropertyVetoException;
24 import java.util.IdentityHashMap;
25 import java.util.Iterator;
27 import javax.swing.Action;
28 import javax.swing.Icon;
29 import javax.swing.ImageIcon;
30 import javax.swing.JDesktopPane;
31 import javax.swing.JInternalFrame;
32 import javax.swing.JMenu;
33 import javax.swing.event.InternalFrameEvent;
34 import javax.swing.event.InternalFrameListener;
48 import net.
sf.japi.swing.action.ActionBuilder;
49 import net.
sf.japi.swing.action.ActionBuilderFactory;
50 import net.
sf.japi.swing.action.ActionMethod;
51 import org.apache.log4j.Category;
52 import org.apache.log4j.Logger;
53 import org.jetbrains.annotations.NotNull;
54 import org.jetbrains.annotations.Nullable;
73 private static final ActionBuilder
ACTION_BUILDER = ActionBuilderFactory.getInstance().getActionBuilder(
"net.sf.gridarta");
148 public void mapCreated(@NotNull
final MapControl<G, A, R> mapControl,
final boolean interactive) {
197 while (
it.hasNext()) {
211 public MapDesktop(@NotNull
final MapViewManager<G, A, R> mapViewManager, @NotNull
final MapManager<G, A, R> mapManager, @NotNull
final MapImageCache<G, A, R> mapImageCache, @NotNull
final MapViewsManager<G, A, R> mapViewsManager) {
237 final JInternalFrame internalFrame = mapView.getInternalFrame();
238 if (internalFrame.isIcon()) {
240 internalFrame.setIcon(
false);
241 }
catch (
final PropertyVetoException e) {
248 internalFrame.requestFocus();
249 internalFrame.restoreSubcomponentFocus();
257 final JInternalFrame internalFrame = mapView.getInternalFrame();
264 internalFrame.setSelected(
false);
265 }
catch (
final PropertyVetoException ignored) {
268 internalFrame.setClosed(
true);
269 }
catch (
final PropertyVetoException ignored) {
272 internalFrame.dispose();
288 final JInternalFrame internalFrame = mapView.getInternalFrame();
289 final MapViewFrameListener mapViewFrameListener =
new MapViewFrameListener(mapView);
293 internalFrame.addInternalFrameListener(mapViewFrameListener);
297 internalFrame.setVisible(
true);
300 internalFrame.setMaximum(
true);
301 }
catch (
final PropertyVetoException e) {
302 LOG.error(
"PropertyVetoException: " + e);
313 assert windowAction !=
null;
315 mapView.getInternalFrame().setFrameIcon(icon);
316 windowAction.putValue(Action.SMALL_ICON, icon);
327 assert windowAction !=
null;
329 menu.add(windowAction);
339 final JInternalFrame internalFrame = mapView.getInternalFrame();
340 internalFrame.moveToFront();
342 internalFrame.setSelected(
true);
343 }
catch (
final PropertyVetoException ignored) {
375 final JInternalFrame internalFrame = mapView.getInternalFrame();
376 if (internalFrame.isIcon()) {
377 if (!careAboutIconification) {
379 internalFrame.setIcon(
false);
380 }
catch (
final PropertyVetoException e) {
459 public void setAction(@NotNull
final Action action, @NotNull
final String
name) {
460 if (
name.equals(
"prevWindow")) {
462 }
else if (
name.equals(
"nextWindow")) {
465 throw new IllegalArgumentException(
"unsupported action name: " +
name);
void internalFrameActivated(@NotNull final InternalFrameEvent e)
void deactivateMapView(@NotNull final MapView< G, A, R > mapView)
Deactivates a map view.
final MapViewsManager< G, A, R > mapViewsManager
The MapViewsManager.
static final long serialVersionUID
The serial version UID.
final MapManagerListener< G, A, R > mapManagerListener
The MapManagerListener attached to mapManager.
A MapManager manages all opened maps.
final JDesktopPane desktopPane
The JDesktopPane that contains all map views.
Base package of all Gridarta classes.
Iterator< MapView< G, A, R > > getMapViewIterator(@NotNull final MapControl< G, A, R > mapControl)
Returns an Iterator returning all MapViews of a MapControl.
Interface for listeners listening to MapManager changes.
static final ActionBuilder ACTION_BUILDER
The action builder.
boolean doNextWindow(final boolean performAction)
Executes the "next window" action.
void removeMapViewsListener(@NotNull final MapControl< G, A, R > mapControl, @NotNull final MapViewsListener< G, A, R > listener)
Removes a MapViewsListener to be notified of events.
void updateFocus(final boolean careAboutIconification)
Updates the focus to the first non-iconified map window.
void addMapManagerListener(@NotNull MapManagerListener< G, A, R > listener)
Adds a MapManagerListener to be notified.
boolean doNextWindow(final boolean performAction)
Performs or checks availability of the "next window" action.
final MapManager< G, A, R > mapManager
The MapManager to use.
final MapView< G, A, R > mapView
The associated MapView.
Reflects a game object (object on a map).
The listener attached to map views.
final void setIndex(final int index)
Sets the index of this action so this Action knows what Mnemonic and Accelerator to use.
Action class for selecting this window.
void internalFrameIconified(@NotNull final InternalFrameEvent e)
final MapImageCacheListener< G, A, R > mapImageCacheListener
The MapImageCacheListener registered to mapImageCache.
void setCurrentMapView(@NotNull final MapView< G, A, R > mapView)
Sets the given level view as the current one.
Graphical User Interface of Gridarta.
void addMapView(@NotNull final MapView< G, A, R > mapView)
Adds a map view.
void internalFrameDeiconified(@NotNull final InternalFrameEvent e)
Caches icon and preview images for map files.
boolean doPrevWindow(final boolean performAction)
Performs or checks availability of the "prev window" action.
GameObjects are the objects based on Archetypes found on maps.
Image getOrCreateIcon(@NotNull final File mapFile)
Returns an icon Image for a given map file.
void mapViewFocusGainedNotify(@NotNull final MapView< G, A, R > mapView)
Notifies that the given map view is now set as the current one.
void closeMapView(@NotNull final MapView< G, A, R > mapView)
Invoked when the user wants to close a map view.
final MapViewManager< G, A, R > mapViewManager
All open map views.
void internalFrameClosing(@NotNull final InternalFrameEvent e)
static final Category LOG
The Logger for printing log messages.
void updateFrameIcon(@NotNull final MapView< G, A, R > mapView)
Updates the frame icon to the current icon image.
Interface for MapArchObjects.
MapDesktop(@NotNull final MapViewManager< G, A, R > mapViewManager, @NotNull final MapManager< G, A, R > mapManager, @NotNull final MapImageCache< G, A, R > mapImageCache, @NotNull final MapViewsManager< G, A, R > mapViewsManager)
Creates a new instance.
Interface for listeners interested in MapImageCache related events.
A map view consists of a map grid and a map cursor, and is attached to a map control.
void addWindowAction(@NotNull final JMenu menu, @NotNull final MapView< G, A, R > mapView, final int index)
Adds an action for selecting this window to a menu.
void internalFrameOpened(@NotNull final InternalFrameEvent e)
void addMapImageCacheListener(@NotNull final MapImageCacheListener< G, A, R > listener)
Adds a MapImageCacheListener to be notified.
Interface for listeners interested in MapViewsManager related events.
final MapViewsListener< G, A, R > mapViewsListener
The MapViewsListener attached to all existing MapControls for maps.
final Map< MapView< G, A, R >, MapViewFrameListener > mapViewFrameListeners
The MapViewFrameListeners associated with MapViews.
void activateAndRaiseMapView(@NotNull final MapView< G, A, R > mapView)
Activates and raises the given map view.
final Map< MapView< G, A, R >, WindowAction< G, A, R > > windowActions
The actions to select windows.
void setActiveMapView(@NotNull final MapView< G, A, R > mapView)
Sets the active map view.
void addMapViewsListener(@NotNull final MapControl< G, A, R > mapControl, @NotNull final MapViewsListener< G, A, R > listener)
Adds a MapViewsListener to be notified of events.
final MapImageCache< G, A, R > mapImageCache
The MapImageCache to use.
Action aPrevWindow
The action for "prev window".
The JDesktopPane containing all map views.
Base classes for rendering maps.
void nextWindow()
Gives focus to the previous window.
void removeMapView(@NotNull final MapView< G, A, R > mapView)
Removes (closes) the map view.
boolean doPrevWindow(final boolean performAction)
Executes the "prev window" action.
Component getComponent()
Returns the Component that shows all map views.
Currently nothing more than a marker interface for unification.
Action aNextWindow
The action for "next window".
void activateMapView(@NotNull final MapView< G, A, R > mapView)
Activates a map view.
void internalFrameClosed(@NotNull final InternalFrameEvent e)
void internalFrameDeactivated(@NotNull final InternalFrameEvent e)
void mapViewFocusLostNotify(@NotNull final MapView< G, A, R > mapView)
Notifies that the map views focus is lost it is inserted as the second in line to the map view vector...
void setFocus(@NotNull final MapView< G, A, R > mapView)
Sets a MapView as the main view.
void setCurrentMap(@Nullable MapControl< G, A, R > mapControl)
Sets the given map as the current one.
void refreshMenus()
Enables/disables the actions according to the current state.
Stores all existing MapViews.
void setAction(@NotNull final Action action, @NotNull final String name)
Sets the Action instance for this editor action.
void prevWindow()
Gives focus to the next window.
void removeMapView(@NotNull final MapView< G, A, R > mapView)
Removes a map view.
This document describes some hints and requirements for general development on the CrossfireEditor If you plan to make changes to the editor code or setup please read the following and keep it in derived from a basic editor application called Gridder by Pasi Ker�nen so please communicate with best through the cf devel mailing before considering any fundamental changes About code DO NOT USE TABS No matter what Java development platform you are please configure insert indent Tabs are displayed totally different in every editor and there are millions of different editors out there The insertion of tabs in the source code is messing up the syntax formatting in a way that is UNREPAIRABLE Apart from please keep code indentation accurate This is not just good it helps to keep code readable and in that way dramatically decreases the chance for overlooked bugs Everyone is welcomed to correct indentation errors wherever they are spotted Before you start to do this please double check that your editor is really configured to insert spaces Line feeds may be checked in either in windows or in unix linux style All reasonable text and java editors can deal with both linefeed formats Converting line feeds is but in this case please make sure that only linefeed characters are changed and nothing else is affected Due to the platform independent nature of the editor has the potential to run on almost any given operating system the build process differs greatly between systems as well as java environments In the several people have attempted to add build scripts along with structural changes to optimize the setup on one particular system environment which has led to conflict Please do *not *attempt to change the structure or any directories for the mere purpose of improving a build process or performance in a java environment Build scripts may be placed in the root it would be especially fine if it is just one or two files but the latter is not required Please excuse me for placing such restriction I and many users of the editor greatly appreciate build scripts We just had some real troubles over this issue in the past and I don t want to have them repeated the editor has relatively high performance requirements I ve spent a lot of extra work to keep everything as fast and memory efficient as possible when you add new data fields or calculations in the archetype please make sure they are as efficient as possible and worth both the time and space they consume Now don t be afraid too much No development would be possible without adding calculations and data at all Just bear in mind unlike for many other open source performance does make a difference for the CrossfireEditor The for as many systems as possible In case you are unexperienced with java and note that the graphics look different on every and with every font They also have different sizes proportions and behave different A seemingly trivial and effectless change can wreck havoc for the same GUI run on another system please don t be totally afraid of it
void addMapView(@NotNull final MapView< G, A, R > mapView)
Adds the map view.
MapViewFrameListener(@NotNull final MapView< G, A, R > mapView)
Creates a new instance.