From: <aki...@us...> - 2006-12-19 00:13:57
|
Revision: 1188 http://svn.sourceforge.net/gridarta/?rev=1188&view=rev Author: akirschbaum Date: 2006-12-18 16:13:57 -0800 (Mon, 18 Dec 2006) Log Message: ----------- Properly enable/disable edit menu entries. Modified Paths: -------------- trunk/crossfire/ChangeLog trunk/crossfire/src/cfeditor/CMainControl.java trunk/crossfire/src/cfeditor/CMainView.java trunk/crossfire/src/cfeditor/CMapViewBasic.java trunk/crossfire/src/cfeditor/MapViewIFrame.java trunk/crossfire/src/cfeditor/map/MapControl.java trunk/daimonin/src/daieditor/CMainControl.java trunk/daimonin/src/daieditor/CMainView.java trunk/daimonin/src/daieditor/CMapViewBasic.java trunk/daimonin/src/daieditor/MapViewIFrame.java trunk/daimonin/src/daieditor/map/MapControl.java Modified: trunk/crossfire/ChangeLog =================================================================== --- trunk/crossfire/ChangeLog 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/ChangeLog 2006-12-19 00:13:57 UTC (rev 1188) @@ -1,3 +1,7 @@ +2006-12-19 Andreas Kirschbaum + + * Properly enable/disable edit menu entries. + 2006-12-18 Andreas Kirschbaum * Fix crash when pasting multipart objects. Modified: trunk/crossfire/src/cfeditor/CMainControl.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/src/cfeditor/CMainControl.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -2,6 +2,7 @@ * Crossfire Java Editor. * Copyright (C) 2000 Michael Toennies * Copyright (C) 2001 Andreas Vogl + * Copyright (C) 2006 The Gridarta Developers * * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) * @@ -44,6 +45,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.List; +import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; @@ -56,6 +58,10 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gui.HideFileFilterProxy; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.MapGridEvent; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapType; import net.sf.gridarta.textedit.scripteditor.ScriptEditControl; import net.sf.japi.swing.ActionFactory; @@ -72,6 +78,7 @@ * The main controller of the level editor. Basically the main application. * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> + * @author Andreas Kirschbaum */ public final class CMainControl implements ThrowableHandler, MainControl { @@ -181,6 +188,9 @@ private final MapCursorControl mapCursorControl; + /** Actions used by this instance. */ + private final MainActions mainActions = new MainActions(this); + /** Constructs the main controller and its model and view. */ public CMainControl() { instance = this; @@ -461,6 +471,10 @@ mainView.openHelpWindow(); } + /** + * Return the CopyBuffer instance. + * @return the CopyBuffer instance + */ public CopyBuffer getCopyBuffer() { return copybuffer; } @@ -706,6 +720,8 @@ final MapControl map = new MapControl(this, objects, maparch, false, initial); if (view) { + map.addMapGridListener(mainActions); + map.addMapCursorListener(mainActions); setStatusText("Creating new map " + maparch.getMapDisplayName()); mainView.addLevelView(map.getMapViewFrame()); // one view... map.getMapViewFrame().setAutoscrolls(true); @@ -1448,6 +1464,8 @@ mapCursorControl.refreshMenus(); //CMainStatusbar.getInstance().setLevelInfo(level); + + mainActions.currentMapChanged(); } /** Invoked when user wants to revert the current map to previously saved state. */ @@ -1495,126 +1513,7 @@ } } - /** "Clear" was selected from the Edit menu. */ - public void clear() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.clear(currentMap); - } - - /** "Cut" was selected from the Edit menu. */ - public void cut() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.cut(currentMap); - } - - /** "Copy" was selected from the Edit menu. */ - public void copy() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.copy(currentMap); - } - - /** "Paste" was selected from the Edit menu. */ - public void paste() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.paste(currentMap); - } - - /** "Fill above" was selected from the Edit menu. */ - public void fillAbove() { - fillWanted(false); - } - - /** "Fill below" was selected from the Edit menu. */ - public void fillBelow() { - fillWanted(true); - } - /** - * "Fill" was selected from the Edit menu. - * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" - */ - private void fillWanted(final boolean fillBelow) { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.fill(currentMap, fillBelow, -1); - } - - /** "Random fill above" was selected from the Edit menu. */ - public void randFillAbove() { - fillRandomWanted(false); - } - - /** "Random fill below" was selected from the Edit menu. */ - public void randFillBelow() { - fillRandomWanted(true); - } - - /** - * "RandomFill" was selected from the Edit menu. - * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" - */ - private void fillRandomWanted(final boolean fillBelow) { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - String input = "100"; - for (;;) { - input = (String) JOptionPane.showInputDialog(mainView, "Enter a fill density between 1-100", fillBelow ? "Random fill below" : "Random fill above", JOptionPane.QUESTION_MESSAGE, null, null, input); - if (input == null) { - break; - } - - int rand; - try { - rand = Integer.parseInt(input); - } catch (final NumberFormatException e) { - rand = -1; - } - if (rand < 1 || rand > 100) { - JOptionPane.showMessageDialog(mainView, "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); - } else { - copybuffer.fill(currentMap, fillBelow, rand); - break; - } - } - } - - /** - * "Floodfill" was selected from the Edit menu. - */ - public void floodfill() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.floodfill(currentMap); - } - - /** "Replace" was selected from the Edit menu. */ - public void replace() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - ReplaceDialog.getInstance().display(currentMap); - } - - /** * Returns whether the CopyBuffer is empty. * @return <code>true</code> if the CopyBuffer is empty, otherwise <code>false</code>. */ @@ -1651,10 +1550,6 @@ CSettings.getInstance(IGUIConstants.APP_NAME).saveSettings(); } - public void refreshMenus() { - mainView.refreshMenus(); - } - /** Refreshes the state of menu items and toolbar buttons. */ public void refreshMenusAndToolbars() { mainView.refreshMenusAndToolbars(); @@ -1850,4 +1745,315 @@ refreshMenusAndToolbars(); } + /** + * Encapsulates actions and related functions. + */ + public static final class MainActions implements MapCursorListener, MapGridListener { + + /** The MainControl. */ + private final CMainControl mainControl; + + /** Action called for "clear". */ + private final Action aClear = ACTION_FACTORY.createAction(true, "clear", this); + + /** Action called for "cut". */ + private final Action aCut = ACTION_FACTORY.createAction(true, "cut", this); + + /** Action called for "copy". */ + private final Action aCopy = ACTION_FACTORY.createAction(true, "copy", this); + + /** Action called for "paste". */ + private final Action aPaste = ACTION_FACTORY.createAction(true, "paste", this); + + /** Action called for "replace". */ + private final Action aReplace = ACTION_FACTORY.createAction(true, "replace", this); + + /** Action called for "fill above". */ + private final Action aFillAbove = ACTION_FACTORY.createAction(true, "fillAbove", this); + + /** Action called for "fill below". */ + private final Action aFillBelow = ACTION_FACTORY.createAction(true, "fillBelow", this); + + /** Action called for "random fill above". */ + private final Action aRandFillAbove = ACTION_FACTORY.createAction(true, "randFillAbove", this); + + /** Action called for "random fill below". */ + private final Action aRandFillBelow = ACTION_FACTORY.createAction(true, "randFillBelow", this); + + /** Action called for "floodfill". */ + private final Action aFloodfill = ACTION_FACTORY.createAction(true, "floodfill", this); + + /** + * Create a new instance. + * + * @param mainControl the MainControl + */ + public MainActions(@NotNull final CMainControl mainControl) { + this.mainControl = mainControl; + } + + /** + * Enable/disable menu entries based on the current state. + */ + private void refreshMenus() { + aClear.setEnabled(isClearEnabled()); + aCut.setEnabled(isCutEnabled()); + aCopy.setEnabled(isCopyEnabled()); + aPaste.setEnabled(isPasteEnabled()); + aReplace.setEnabled(isReplaceEnabled()); + aFillAbove.setEnabled(isFillAboveEnabled()); + aFillBelow.setEnabled(isFillBelowEnabled()); + aRandFillAbove.setEnabled(isRandFillAboveEnabled()); + aRandFillBelow.setEnabled(isRandFillBelowEnabled()); + aFloodfill.setEnabled(isFloodfillEnabled()); + } + + /** + * Called when the current map of the attached MainControl has changed. + */ + public void currentMapChanged() { + refreshMenus(); + } + + /** {@inheritDoc} */ + public void mapGridChanged(@NotNull final MapGridEvent e) { + refreshMenus(); // selection state may have changed + } + + /** {@inheritDoc} */ + public void mapGridResized(@NotNull final MapGridEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + refreshMenus(); // cursor may have been activated or deactivated + } + + /** "Clear" was selected from the Edit menu. */ + public void clear() { + if (isClearEnabled()) { + mainControl.getCopyBuffer().clear(mainControl.getCurrentMap()); + } + } + + /** "Cut" was selected from the Edit menu. */ + public void cut() { + if (isCutEnabled()) { + mainControl.getCopyBuffer().cut(mainControl.getCurrentMap()); + } + } + + /** "Copy" was selected from the Edit menu. */ + public void copy() { + if (isCopyEnabled()) { + mainControl.getCopyBuffer().copy(mainControl.getCurrentMap()); + } + } + + /** "Paste" was selected from the Edit menu. */ + public void paste() { + if (isPasteEnabled()) { + mainControl.getCopyBuffer().paste(mainControl.getCurrentMap()); + } + } + + /** "Replace" was selected from the Edit menu. */ + public void replace() { + if (isReplaceEnabled()) { + ReplaceDialog.getInstance().display(mainControl.getCurrentMap()); + } + } + + /** "Fill above" was selected from the Edit menu. */ + public void fillAbove() { + if (isFillAboveEnabled()) { + fillWanted(false); + } + } + + /** "Fill below" was selected from the Edit menu. */ + public void fillBelow() { + if (isFillBelowEnabled()) { + fillWanted(true); + } + } + + /** + * "Fill" was selected from the Edit menu. + * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" + */ + private void fillWanted(final boolean fillBelow) { + mainControl.getCopyBuffer().fill(mainControl.getCurrentMap(), fillBelow, -1); + } + + /** "Random fill above" was selected from the Edit menu. */ + public void randFillAbove() { + if (isRandFillAboveEnabled()) { + fillRandomWanted(false); + } + } + + /** "Random fill below" was selected from the Edit menu. */ + public void randFillBelow() { + if (isRandFillBelowEnabled()) { + fillRandomWanted(true); + } + } + + /** + * "RandomFill" was selected from the Edit menu. + * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" + */ + private void fillRandomWanted(final boolean fillBelow) { + final MapControl currentMap = mainControl.getCurrentMap(); + + String input = "100"; + for (;;) { + input = (String) JOptionPane.showInputDialog(mainControl.getMainView(), "Enter a fill density between 1-100", fillBelow ? "Random fill below" : "Random fill above", JOptionPane.QUESTION_MESSAGE, null, null, input); + if (input == null) { + break; + } + + int rand; + try { + rand = Integer.parseInt(input); + } catch (final NumberFormatException e) { + rand = -1; + } + if (rand < 1 || rand > 100) { + JOptionPane.showMessageDialog(mainControl.getMainView(), "The fill density must be between 1-100.", "Illegal Value.", JOptionPane.ERROR_MESSAGE); + } else { + mainControl.getCopyBuffer().fill(currentMap, fillBelow, rand); + break; + } + } + } + + /** + * "Floodfill" was selected from the Edit menu. + */ + public void floodfill() { + if (isFloodfillEnabled()) { + mainControl.getCopyBuffer().floodfill(mainControl.getCurrentMap()); + } + } + + /** + * Determine if "clear" is enabled. + * @return <code>true</code> if "clear" is enabled, <code>false</code> + * otherwise + */ + private boolean isClearEnabled() { + return hasSelection(); + } + + /** + * Determine if "cut" is enabled. + * @return <code>true</code> if "cut" is enabled, <code>false</code> + * otherwise + */ + private boolean isCutEnabled() { + return hasSelection(); + } + + /** + * Determine if "copy" is enabled. + * @return <code>true</code> if "copy" is enabled, <code>false</code> + * otherwise + */ + private boolean isCopyEnabled() { + return hasSelection(); + } + + /** + * Determine if "paste" is enabled. + * @return <code>true</code> if "paste" is enabled, <code>false</code> + * otherwise + */ + private boolean isPasteEnabled() { + return hasCursor() && !mainControl.isCopyBufferEmpty(); + } + + /** + * Determine if "replace" is enabled. + * @return <code>true</code> if "replace" is enabled, + * <code>false</code> otherwise + */ + private boolean isReplaceEnabled() { + return mainControl.getCurrentMap() != null; + } + + /** + * Determine if "fill above" is enabled. + * @return <code>true</code> if "fill above" is enabled, + * <code>false</code> otherwise + */ + private boolean isFillAboveEnabled() { + return hasSelection(); + } + + /** + * Determine if "fill below" is enabled. + * @return <code>true</code> if "fill below" is enabled, + * <code>false</code> otherwise + */ + private boolean isFillBelowEnabled() { + return hasSelection(); + } + + /** + * Determine if "random fill above" is enabled. + * @return <code>true</code> if "random fill above" is enabled, + * <code>false</code> otherwise + */ + private boolean isRandFillAboveEnabled() { + return hasSelection(); + } + + /** + * Determine if "random fill below" is enabled. + * @return <code>true</code> if "random fill below" is enabled, + * <code>false</code> otherwise + */ + private boolean isRandFillBelowEnabled() { + return hasSelection(); + } + + /** + * Determine if "floodfill" is enabled. + * @return <code>true</code> if "floodfill" is enabled, + * <code>false</code> otherwise + */ + private boolean isFloodfillEnabled() { + return hasCursor(); + } + + /** + * Determine if the current map has a selection. + * @return <code>true</code> a selection exists, <code>false</code> + * otherwise + */ + private boolean hasSelection() { + final MapControl currentMap = mainControl.getCurrentMap(); + return currentMap != null && currentMap.hasSelection(); + } + + /** + * Determine if the current map has an active cursor. + * @return <code>true</code> a cursor exists, <code>false</code> + * otherwise + */ + private boolean hasCursor() { + final MapControl currentMap = mainControl.getCurrentMap(); + return currentMap != null && currentMap.hasCursor(); + } + + } // class MainActions + } // class CMainControl Modified: trunk/crossfire/src/cfeditor/CMainView.java =================================================================== --- trunk/crossfire/src/cfeditor/CMainView.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/src/cfeditor/CMainView.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -843,26 +843,6 @@ private final Action aCreateImg = ACTION_FACTORY.createAction(true, "createImg", mainControl); - private final Action aClear = ACTION_FACTORY.createAction(true, "clear", mainControl); - - private final Action aCut = ACTION_FACTORY.createAction(true, "cut", mainControl); - - private final Action aCopy = ACTION_FACTORY.createAction(true, "copy", mainControl); - - private final Action aPaste = ACTION_FACTORY.createAction(true, "paste", mainControl); - - private final Action aReplace = ACTION_FACTORY.createAction(true, "replace", mainControl); - - private final Action aFillAbove = ACTION_FACTORY.createAction(true, "fillAbove", mainControl); - - private final Action aFillBelow = ACTION_FACTORY.createAction(true, "fillBelow", mainControl); - - private final Action aRandFillAbove = ACTION_FACTORY.createAction(true, "randFillAbove", mainControl); - - private final Action aRandFillBelow = ACTION_FACTORY.createAction(true, "randFillBelow", mainControl); - - private final Action aFloodfill = ACTION_FACTORY.createAction(true, "floodfill", mainControl); - private final Action aEnterExit = ACTION_FACTORY.createAction(true, "enterExit", mainControl); private final Action aTileShow = ACTION_FACTORY.createToggle(true, "tileShow", mainControl); @@ -933,22 +913,12 @@ aSaveAs.setEnabled(mapState); //aTileShow.setEnabled(mapState); aMapProperties.setEnabled(mapState); - aReplace.setEnabled(mapState); for (int direction = 0; direction < directionsMap.length; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); } - aClear.setEnabled(selState); - aCut.setEnabled(selState); - aCopy.setEnabled(selState); - aFillAbove.setEnabled(selState); - aFillBelow.setEnabled(selState); - aRandFillAbove.setEnabled(selState); - aRandFillBelow.setEnabled(selState); - aFloodfill.setEnabled(selState); aEnterExit.setEnabled(selState); aRevert.setEnabled(mapState && fLevelEdited && mainControl.isPlainSaveEnabled()); - aPaste.setEnabled(selState && !mainControl.isCopyBufferEmpty()); aGridVisible.setEnabled(mapState); ((ToggleAction) aGridVisible).setSelected(mainControl.isGridVisible()); rebuildWindowMenu(); Modified: trunk/crossfire/src/cfeditor/CMapViewBasic.java =================================================================== --- trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/src/cfeditor/CMapViewBasic.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -50,6 +50,7 @@ import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -297,6 +298,14 @@ frame.updateTitle(); } + /** + * Get whether a selection exists. + * @return <code>true</code> if a selection exists, otherwise <code>false</code> + */ + public boolean hasSelection() { + return mapGrid.getSelectedRec() != null; + } + public Point[] getSelection() { final List<Point> selection = new ArrayList<Point>(); final Size2D mapSize = mapModel.getMapSize(); @@ -714,4 +723,30 @@ // Ignore mode change events } + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + mapGrid.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return mapCursor.isActive(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + mapCursor.addMapCursorListener(listener); + } + } // class CMapViewBasic Modified: trunk/crossfire/src/cfeditor/MapViewIFrame.java =================================================================== --- trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/src/cfeditor/MapViewIFrame.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -36,6 +36,8 @@ import javax.swing.JInternalFrame; import javax.swing.JViewport; import static javax.swing.KeyStroke.getKeyStroke; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.japi.swing.ActionFactory; /** @@ -201,6 +203,42 @@ return view; } + /** + * Determines if this map has an active selection. + * + * @return <code>true</code> if this map has an active selection, + * <code>false</code> otherwise + */ + public boolean hasSelection() { + return view.hasSelection(); + } + + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + view.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return view.hasCursor(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + view.addMapCursorListener(listener); + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/crossfire/src/cfeditor/map/MapControl.java =================================================================== --- trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/crossfire/src/cfeditor/map/MapControl.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -34,7 +34,9 @@ import java.util.List; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapGridListener; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -589,4 +591,40 @@ return mapModel.getMapArchObject(); } + /** + * Determines if this map has an active selection. + * + * @return <code>true</code> if this map has an active selection, + * <code>false</code> otherwise + */ + public boolean hasSelection() { + return mapViewFrame.hasSelection(); + } + + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + mapViewFrame.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return mapViewFrame.hasCursor(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + mapViewFrame.addMapCursorListener(listener); + } + } // class MapControl Modified: trunk/daimonin/src/daieditor/CMainControl.java =================================================================== --- trunk/daimonin/src/daieditor/CMainControl.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/daimonin/src/daieditor/CMainControl.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -3,6 +3,7 @@ * Copyright (C) 2000 Michael Toennies * Copyright (C) 2001 Andreas Vogl * Copyright (C) 2005 Christian Hujer + * Copyright (C) 2006 The Gridarta Developers * * (code based on: Gridder. 2D grid based level editor. (C) 2000 Pasi Keränen) * @@ -89,6 +90,7 @@ import java.util.prefs.Preferences; import static java.util.prefs.Preferences.userNodeForPackage; import javax.swing.AbstractAction; +import javax.swing.Action; import javax.swing.ImageIcon; import javax.swing.JFileChooser; import javax.swing.JOptionPane; @@ -98,6 +100,10 @@ import net.sf.gridarta.gameobject.Collectable; import net.sf.gridarta.gameobject.Collector; import net.sf.gridarta.gui.HideFileFilterProxy; +import net.sf.gridarta.gui.map.MapCursorEvent; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.MapGridEvent; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -121,6 +127,7 @@ * @author <a href="mailto:mic...@no...">Michael Toennies</a> * @author <a href="mailto:and...@gm...">Andreas Vogl</a> * @author <a href="mailto:ch...@ri...">Christian.Hujer</a> + * @author Andreas Kirschbaum * @fixme I'm 2200 lines long, therefor I suck. */ public final class CMainControl implements ThrowableHandler, MapModelListener, MainControl { @@ -289,6 +296,9 @@ private final MapCursorControl mapCursorControl; + /** Actions used by this instance. */ + private final MainActions mainActions = new MainActions(this); + /** Constructs the main controller and its model and view. */ public CMainControl() { instance = this; @@ -656,6 +666,14 @@ mainView.openHelpWindow(); } + /** + * Return the CopyBuffer instance. + * @return the CopyBuffer instance + */ + public CopyBuffer getCopyBuffer() { + return copybuffer; + } + /** Set all global settings from the preferences. */ private void readGlobalSettings() { initDirs(); @@ -865,6 +883,8 @@ final MapControl map = new MapControl(this, objects, maparch, false, view); levels.add(map); if (view) { + map.addMapGridListener(mainActions); + map.addMapCursorListener(mainActions); setCurrentLevel(map); refreshMenusAndToolbars(); } @@ -1443,14 +1463,6 @@ showMapProperties(currentMap); } - /** Invoked when the user wants to select all squares from a map. */ - public void selectAll() { - if (currentMap == null) { - throw new IllegalStateException("BUG: selectAll was enabled without a current map. Please report this."); - } - currentMap.selectAll(); - } - /** * Shows the given levels properties. * @param level The level whose properties we want. @@ -1679,6 +1691,8 @@ mapCursorControl.refreshMenus(); //CMainStatusbar.getInstance().setLevelInfo(level); + + mainActions.currentMapChanged(); } /** Invoked when user wants to revert the current map to previously saved state. */ @@ -1728,147 +1742,7 @@ } } - /** "Clear" was selected from the Edit menu. */ - public void clear() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.clear(currentMap); - } - - /** "Cut" was selected from the Edit menu. */ - public void cut() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.cut(currentMap); - } - - /** "Copy" was selected from the Edit menu. */ - public void copy() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.copy(currentMap); - } - - /** "Paste" was selected from the Edit menu. */ - public void paste() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.paste(currentMap); - } - - /** "Fill above" was selected from the Edit menu. */ - public void fillAbove() { - fillWanted(false); - } - - /** "Fill below" was selected from the Edit menu. */ - public void fillBelow() { - fillWanted(true); - } - /** - * "Fill" was selected from the Edit menu. - * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" - */ - private void fillWanted(final boolean fillBelow) { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.fill(currentMap, fillBelow, null, -1); - } - - /** "Random fill above" was selected from the Edit menu. */ - public void randFillAbove() { - fillRandomWanted(false); - } - - /** "Random fill below" was selected from the Edit menu. */ - public void randFillBelow() { - fillRandomWanted(true); - } - - /** - * "RandomFill" was selected from the Edit menu. - * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" - */ - private void fillRandomWanted(final boolean fillBelow) { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - final StringBuilder title = new StringBuilder("Random fill "); - final GameObject arch = instance.getArchPanelHighlight(); - MapControl pmap = null; - - /* if we have a single arch, use it as random seed. - * We can throw the arch with % chance over the selected area. - * If the arch is null, we look we have a selected pickmap. - * if so, use the pickmap as random arch seed for the filler. - */ - if (arch != null) { - title.append("with arch ").append(arch.getArchetypeName()); - } else { - pmap = CPickmapPanel.getInstance().getCurrentPickmap(); - if (pmap != null) { - title.append("with pickmap ").append(pmap.getMapArch().getMapName()); - } else { // ok ,we have a problem here: arch == null, pmap == null... - // XXX but shouldn't be something told to the user? - // Not even a logging? - return; - } - } - final String input = JOptionPane.showInputDialog(mainView, "Enter a fill seed value between 1-100\n(default is 100%)", title.toString(), JOptionPane.QUESTION_MESSAGE); - if (input != null) { - int rand = 100; - if (input.trim().length() == 0) { - rand = 100; - } else { - try { - rand = Integer.parseInt(input); - if (rand < 0) { - rand = 1; - } - if (rand > 100) { - rand = 100; - } - } catch (final NumberFormatException e) { - JOptionPane.showMessageDialog(mainView, "You entered an illegal value", "Illegal Value.", JOptionPane.ERROR_MESSAGE); - } - } - copybuffer.fill(currentMap, fillBelow, pmap, rand); - } - } - - /** - * "Floodfill" was selected from the Edit menu. - */ - public void floodfill() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - copybuffer.floodfill(currentMap); - } - - /** "Replace" was selected from the Edit menu. */ - public void replace() { - if (currentMap == null || currentMap.getMapViewFrame() == null) { - return; // this should never be possible, but I just wanna make sure... - } - - ReplaceDialog.getInstance().display(currentMap); - } - - /** * Returns whether the CopyBuffer is empty. * @return <code>true</code> if the CopyBuffer is empty, otherwise <code>false</code>. */ @@ -2214,4 +2088,355 @@ } // class Recent + /** + * Encapsulates actions and related functions. + */ + public static final class MainActions implements MapCursorListener, MapGridListener { + + /** The MainControl. */ + private final CMainControl mainControl; + + /** Action called for "clear". */ + private final Action aClear = ACTION_FACTORY.createAction(true, "clear", this); + + /** Action called for "cut". */ + private final Action aCut = ACTION_FACTORY.createAction(true, "cut", this); + + /** Action called for "copy". */ + private final Action aCopy = ACTION_FACTORY.createAction(true, "copy", this); + + /** Action called for "paste". */ + private final Action aPaste = ACTION_FACTORY.createAction(true, "paste", this); + + /** Action called for "replace". */ + private final Action aReplace = ACTION_FACTORY.createAction(true, "replace", this); + + /** Action called for "fill above". */ + private final Action aFillAbove = ACTION_FACTORY.createAction(true, "fillAbove", this); + + /** Action called for "fill below". */ + private final Action aFillBelow = ACTION_FACTORY.createAction(true, "fillBelow", this); + + /** Action called for "random fill above". */ + private final Action aRandFillAbove = ACTION_FACTORY.createAction(true, "randFillAbove", this); + + /** Action called for "random fill below". */ + private final Action aRandFillBelow = ACTION_FACTORY.createAction(true, "randFillBelow", this); + + /** Action called for "floodfill". */ + private final Action aFloodfill = ACTION_FACTORY.createAction(true, "floodfill", this); + + /** Action called for "select all". */ + private final Action aSelectAll = ACTION_FACTORY.createAction(true, "selectAll", this); + + /** + * Create a new instance. + * + * @param mainControl the MainControl + */ + public MainActions(@NotNull final CMainControl mainControl) { + this.mainControl = mainControl; + } + + /** + * Enable/disable menu entries based on the current state. + */ + private void refreshMenus() { + aClear.setEnabled(isClearEnabled()); + aCut.setEnabled(isCutEnabled()); + aCopy.setEnabled(isCopyEnabled()); + aPaste.setEnabled(isPasteEnabled()); + aReplace.setEnabled(isReplaceEnabled()); + aFillAbove.setEnabled(isFillAboveEnabled()); + aFillBelow.setEnabled(isFillBelowEnabled()); + aRandFillAbove.setEnabled(isRandFillAboveEnabled()); + aRandFillBelow.setEnabled(isRandFillBelowEnabled()); + aFloodfill.setEnabled(isFloodfillEnabled()); + aSelectAll.setEnabled(isSelectAllEnabled()); + } + + /** + * Called when the current map of the attached MainControl has changed. + */ + public void currentMapChanged() { + refreshMenus(); + } + + /** {@inheritDoc} */ + public void mapGridChanged(@NotNull final MapGridEvent e) { + refreshMenus(); // selection state may have changed + } + + /** {@inheritDoc} */ + public void mapGridResized(@NotNull final MapGridEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedPos(@NotNull final MapCursorEvent e) { + // ignore + } + + /** {@inheritDoc} */ + public void mapCursorChangedMode(@NotNull final MapCursorEvent e) { + refreshMenus(); // cursor may have been activated or deactivated + } + + /** "Clear" was selected from the Edit menu. */ + public void clear() { + if (isClearEnabled()) { + mainControl.getCopyBuffer().clear(mainControl.getCurrentMap()); + } + } + + /** "Cut" was selected from the Edit menu. */ + public void cut() { + if (isCutEnabled()) { + mainControl.getCopyBuffer().cut(mainControl.getCurrentMap()); + } + } + + /** "Copy" was selected from the Edit menu. */ + public void copy() { + if (isCopyEnabled()) { + mainControl.getCopyBuffer().copy(mainControl.getCurrentMap()); + } + } + + /** "Paste" was selected from the Edit menu. */ + public void paste() { + if (isPasteEnabled()) { + mainControl.getCopyBuffer().paste(mainControl.getCurrentMap()); + } + } + + /** "Replace" was selected from the Edit menu. */ + public void replace() { + if (isReplaceEnabled()) { + ReplaceDialog.getInstance().display(mainControl.getCurrentMap()); + } + } + + /** "Fill above" was selected from the Edit menu. */ + public void fillAbove() { + if (isFillAboveEnabled()) { + fillWanted(false); + } + } + + /** "Fill below" was selected from the Edit menu. */ + public void fillBelow() { + if (isFillBelowEnabled()) { + fillWanted(true); + } + } + + /** + * "Fill" was selected from the Edit menu. + * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" + */ + private void fillWanted(final boolean fillBelow) { + mainControl.getCopyBuffer().fill(mainControl.getCurrentMap(), fillBelow, null, -1); + } + + /** "Random fill above" was selected from the Edit menu. */ + public void randFillAbove() { + if (isRandFillAboveEnabled()) { + fillRandomWanted(false); + } + } + + /** "Random fill below" was selected from the Edit menu. */ + public void randFillBelow() { + if (isRandFillBelowEnabled()) { + fillRandomWanted(true); + } + } + + /** + * "RandomFill" was selected from the Edit menu. + * @param fillBelow true if "Fill Below" was activated, false if "Fill Above" + */ + private void fillRandomWanted(final boolean fillBelow) { + final MapControl currentMap = mainControl.getCurrentMap(); + final StringBuilder title = new StringBuilder("Random fill "); + final GameObject arch = instance.getArchPanelHighlight(); + MapControl pmap = null; + + /* if we have a single arch, use it as random seed. + * We can throw the arch with % chance over the selected area. + * If the arch is null, we look we have a selected pickmap. + * if so, use the pickmap as random arch seed for the filler. + */ + if (arch != null) { + title.append("with arch ").append(arch.getArchetypeName()); + } else { + pmap = CPickmapPanel.getInstance().getCurrentPickmap(); + if (pmap != null) { + title.append("with pickmap ").append(pmap.getMapArch().getMapName()); + } else { // ok ,we have a problem here: arch == null, pmap == null... + // XXX but shouldn't be something told to the user? + // Not even a logging? + return; + } + } + final String input = JOptionPane.showInputDialog(mainControl.getMainView(), "Enter a fill seed value between 1-100\n(default is 100%)", title.toString(), JOptionPane.QUESTION_MESSAGE); + if (input != null) { + int rand = 100; + if (input.trim().length() == 0) { + rand = 100; + } else { + try { + rand = Integer.parseInt(input); + if (rand < 0) { + rand = 1; + } + if (rand > 100) { + rand = 100; + } + } catch (final NumberFormatException e) { + JOptionPane.showMessageDialog(mainControl.getMainView(), "You entered an illegal value", "Illegal Value.", JOptionPane.ERROR_MESSAGE); + } + } + mainControl.getCopyBuffer().fill(currentMap, fillBelow, pmap, rand); + } + } + + /** + * "Floodfill" was selected from the Edit menu. + */ + public void floodfill() { + if (isFloodfillEnabled()) { + mainControl.getCopyBuffer().floodfill(mainControl.getCurrentMap()); + } + } + + /** Invoked when the user wants to select all squares from a map. */ + public void selectAll() { + if (isSelectAllEnabled()) { + mainControl.getCurrentMap().selectAll(); + } + } + + /** + * Determine if "clear" is enabled. + * @return <code>true</code> if "clear" is enabled, <code>false</code> + * otherwise + */ + private boolean isClearEnabled() { + return hasSelection(); + } + + /** + * Determine if "cut" is enabled. + * @return <code>true</code> if "cut" is enabled, <code>false</code> + * otherwise + */ + private boolean isCutEnabled() { + return hasSelection(); + } + + /** + * Determine if "copy" is enabled. + * @return <code>true</code> if "copy" is enabled, <code>false</code> + * otherwise + */ + private boolean isCopyEnabled() { + return hasSelection(); + } + + /** + * Determine if "paste" is enabled. + * @return <code>true</code> if "paste" is enabled, <code>false</code> + * otherwise + */ + private boolean isPasteEnabled() { + return hasCursor() && !mainControl.isCopyBufferEmpty(); + } + + /** + * Determine if "replace" is enabled. + * @return <code>true</code> if "replace" is enabled, + * <code>false</code> otherwise + */ + private boolean isReplaceEnabled() { + return mainControl.getCurrentMap() != null; + } + + /** + * Determine if "fill above" is enabled. + * @return <code>true</code> if "fill above" is enabled, + * <code>false</code> otherwise + */ + private boolean isFillAboveEnabled() { + return hasSelection(); + } + + /** + * Determine if "fill below" is enabled. + * @return <code>true</code> if "fill below" is enabled, + * <code>false</code> otherwise + */ + private boolean isFillBelowEnabled() { + return hasSelection(); + } + + /** + * Determine if "random fill above" is enabled. + * @return <code>true</code> if "random fill above" is enabled, + * <code>false</code> otherwise + */ + private boolean isRandFillAboveEnabled() { + return hasSelection(); + } + + /** + * Determine if "random fill below" is enabled. + * @return <code>true</code> if "random fill below" is enabled, + * <code>false</code> otherwise + */ + private boolean isRandFillBelowEnabled() { + return hasSelection(); + } + + /** + * Determine if "floodfill" is enabled. + * @return <code>true</code> if "floodfill" is enabled, + * <code>false</code> otherwise + */ + private boolean isFloodfillEnabled() { + return hasCursor(); + } + + /** + * Determine if "select all" is enabled. + * @return <code>true</code> if "select all" is enabled, + * <code>false</code> otherwise + */ + private boolean isSelectAllEnabled() { + return mainControl.getCurrentMap() != null; + } + + /** + * Determine if the current map has a selection. + * @return <code>true</code> a selection exists, <code>false</code> + * otherwise + */ + private boolean hasSelection() { + final MapControl currentMap = mainControl.getCurrentMap(); + return currentMap != null && currentMap.hasSelection(); + } + + /** + * Determine if the current map has an active cursor. + * @return <code>true</code> a cursor exists, <code>false</code> + * otherwise + */ + private boolean hasCursor() { + final MapControl currentMap = mainControl.getCurrentMap(); + return currentMap != null && currentMap.hasCursor(); + } + + } // class MainActions + } // class CMainControl Modified: trunk/daimonin/src/daieditor/CMainView.java =================================================================== --- trunk/daimonin/src/daieditor/CMainView.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/daimonin/src/daieditor/CMainView.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -748,28 +748,6 @@ private final Action aRedo = ACTION_FACTORY.createAction(true, "redo", mainControl); - private final Action aClear = ACTION_FACTORY.createAction(true, "clear", mainControl); - - private final Action aCut = ACTION_FACTORY.createAction(true, "cut", mainControl); - - private final Action aCopy = ACTION_FACTORY.createAction(true, "copy", mainControl); - - private final Action aPaste = ACTION_FACTORY.createAction(true, "paste", mainControl); - - private final Action aReplace = ACTION_FACTORY.createAction(true, "replace", mainControl); - - private final Action aFillAbove = ACTION_FACTORY.createAction(true, "fillAbove", mainControl); - - private final Action aFillBelow = ACTION_FACTORY.createAction(true, "fillBelow", mainControl); - - private final Action aRandFillAbove = ACTION_FACTORY.createAction(true, "randFillAbove", mainControl); - - private final Action aRandFillBelow = ACTION_FACTORY.createAction(true, "randFillBelow", mainControl); - - private final Action aFloodfill = ACTION_FACTORY.createAction(true, "floodfill", mainControl); - - private final Action aSelectAll = ACTION_FACTORY.createAction(true, "selectAll", mainControl); - private final Action aEnterExit = ACTION_FACTORY.createAction(true, "enterExit", mainControl); private final Action aMapCreateView = ACTION_FACTORY.createAction(true, "mapCreateView", mainControl); @@ -828,23 +806,12 @@ //aSaveAs.setEnabled(fLevelEdited); aMapCreateView.setEnabled(mapState); aMapProperties.setEnabled(mapState); - aReplace.setEnabled(mapState); - aSelectAll.setEnabled(mapState); for (int direction = 0; direction < 8; direction++) { final String mtp = mapState ? mainControl.getCurrentMap().getMapArch().getTilePath(direction) : null; ACTION_FACTORY.getAction(directionsMap[direction]).setEnabled(mtp != null && mtp.length() > 0); } - aClear.setEnabled(selState); - aCut.setEnabled(selState); - aCopy.setEnabled(selState); - aFillAbove.setEnabled(selState); - aFillBelow.setEnabled(selState); - aRandFillAbove.setEnabled(selState); - aRandFillBelow.setEnabled(selState); - aFloodfill.setEnabled(selState); aEnterExit.setEnabled(selState); //aRevert.setEnabled(mapState && mainControl.getCurrentMap().isLevelChanged()); - aPaste.setEnabled(selState && !mainControl.isCopyBufferEmpty()); //aGridToggle.setEnabled(mapState); //((ToggleAction) aGridToggle).setSelected(mapState && mainControl.isGridVisible()); // FIXME IMPORTANT!!! rebuildWindowMenu(); Modified: trunk/daimonin/src/daieditor/CMapViewBasic.java =================================================================== --- trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/daimonin/src/daieditor/CMapViewBasic.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -52,6 +52,7 @@ import net.sf.gridarta.gui.map.MapCursorEvent; import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -455,4 +456,30 @@ // Ignore mode change events } + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + mapGrid.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return mapCursor.isActive(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + mapCursor.addMapCursorListener(listener); + } + } // class CMapViewBasic Modified: trunk/daimonin/src/daieditor/MapViewIFrame.java =================================================================== --- trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/daimonin/src/daieditor/MapViewIFrame.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -37,6 +37,8 @@ import javax.swing.ImageIcon; import javax.swing.JInternalFrame; import static javax.swing.KeyStroke.getKeyStroke; +import net.sf.gridarta.gui.map.MapCursorListener; +import net.sf.gridarta.gui.map.MapGridListener; /** * The <code>MapViewIFrame</code> is mainly a wrapper class which creates a @@ -152,6 +154,42 @@ return view; } + /** + * Determines if this map has an active selection. + * + * @return <code>true</code> if this map has an active selection, + * <code>false</code> otherwise + */ + public boolean hasSelection() { + return view.hasSelection(); + } + + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + view.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return view.hasCursor(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + view.addMapCursorListener(listener); + } + /** Action class for selecting this window. */ public final class WindowAction extends AbstractAction { Modified: trunk/daimonin/src/daieditor/map/MapControl.java =================================================================== --- trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-18 21:29:13 UTC (rev 1187) +++ trunk/daimonin/src/daieditor/map/MapControl.java 2006-12-19 00:13:57 UTC (rev 1188) @@ -47,7 +47,9 @@ import javax.swing.ImageIcon; import net.sf.gridarta.Size2D; import net.sf.gridarta.gui.map.MapCursor; +import net.sf.gridarta.gui.map.MapCursorListener; import net.sf.gridarta.gui.map.MapGrid; +import net.sf.gridarta.gui.map.MapGridListener; import net.sf.gridarta.map.MapModelEvent; import net.sf.gridarta.map.MapModelListener; import net.sf.gridarta.map.MapSquare; @@ -683,4 +685,40 @@ changed = true; } + /** + * Determines if this map has an active selection. + * + * @return <code>true</code> if this map has an active selection, + * <code>false</code> otherwise + */ + public boolean hasSelection() { + return mapViewFrame.hasSelection(); + } + + /** + * Register a MapGridListener. + * @param listener MapGridListener to register + */ + public void addMapGridListener(final MapGridListener listener) { + mapViewFrame.addMapGridListener(listener); + } + + /** + * Determines if this map has an active cursor. + * + * @return <code>true</code> if this map has an active cursor, + * <code>false</code> otherwise + */ + public boolean hasCursor() { + return mapViewFrame.hasCursor(); + } + + /** + * Register a MapCursorListener. + * @param listener MapCursorListener to register + */ + public void addMapCursorListener(final MapCursorListener listener) { + mapViewFrame.addMapCursorListener(listener); + } + } // class MapControl This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |