[Schmitzm-commits] r655 - in branches/2.0-RC2/src: schmitzm/geotools schmitzm/geotools/gui skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 3 12:47:46 CET 2010


Author: alfonx
Date: 2010-02-03 12:47:44 +0100 (Wed, 03 Feb 2010)
New Revision: 655

Removed:
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java
Modified:
   branches/2.0-RC2/src/schmitzm/geotools/JTSUtil.java
   branches/2.0-RC2/src/schmitzm/geotools/gui/MapActionControlPane.java
   branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
Log:
Moving towards the new XMapPaneTool concept

Modified: branches/2.0-RC2/src/schmitzm/geotools/JTSUtil.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/geotools/JTSUtil.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/schmitzm/geotools/JTSUtil.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -29,12 +29,16 @@
  ******************************************************************************/
 package schmitzm.geotools;
 
+import it.geosolutions.imageio.utilities.Utilities;
+
 import java.awt.Rectangle;
 
 import org.apache.log4j.Logger;
 import org.geotools.geometry.jts.JTS;
 import org.geotools.geometry.jts.ReferencedEnvelope;
 import org.geotools.referencing.CRS;
+import org.geotools.resources.CRSUtilities;
+import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.FactoryException;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 import org.opengis.referencing.operation.MathTransform;
@@ -64,9 +68,10 @@
 	 * @return an JTS-Envelope
 	 */
 	public static Envelope createEnvelope(org.opengis.geometry.Envelope envelope) { // gt2-2.4.2
-	// public static Envelope
-	// createEnvelope(org.opengis.spatialschema.geometry.Envelope envelope) { //
-	// gt2-2.3.4
+		// public static Envelope
+		// createEnvelope(org.opengis.spatialschema.geometry.Envelope envelope)
+		// { //
+		// gt2-2.3.4
 		return new Envelope(envelope.getMinimum(0), // X1
 				envelope.getMaximum(0), // X2
 				envelope.getMinimum(1), // Y1
@@ -123,8 +128,8 @@
 	public static Envelope transformEnvelope(Envelope sourceEnv,
 			CoordinateReferenceSystem sourceCRS,
 			CoordinateReferenceSystem destCRS) {
-		
-		// Sometimes CRS only differ in their metadata... 
+
+		// Sometimes CRS only differ in their metadata...
 		if (CRS.equalsIgnoreMetadata(sourceCRS, destCRS))
 			return new Envelope(sourceEnv);
 
@@ -154,7 +159,7 @@
 	}
 
 	/**
-	 * Transformiert eine Koordinate von einem CRS in ein anderes. 
+	 * Transformiert eine Koordinate von einem CRS in ein anderes.
 	 * 
 	 * @param sourceCoord
 	 *            Koordinate
@@ -186,7 +191,7 @@
 		}
 		return destCoord;
 	}
-	
+
 	/**
 	 * Transformiert eine JTS {@link Geometry} von einem CRS in ein anderes. <br>
 	 * Wenn beide CRS semantisch gleich sind wird das selbe Geometrieobect
@@ -203,9 +208,10 @@
 	 */
 	public static Geometry transformGeometry(Geometry geometry,
 			CoordinateReferenceSystem srcCrs, CoordinateReferenceSystem destCrs) {
-		
-		if (CRS.equalsIgnoreMetadata(srcCrs, destCrs)) return geometry; 
 
+		if (CRS.equalsIgnoreMetadata(srcCrs, destCrs))
+			return geometry;
+
 		Geometry destGeometry = null;
 		MathTransform transform;
 		try {
@@ -221,7 +227,6 @@
 		return destGeometry;
 	}
 
-
 	/**
 	 * Returns an {@link Envelope} that has the same aspect ratio as the given
 	 * rectangle
@@ -293,4 +298,27 @@
 				.getCoordinateReferenceSystem(), destCRS), destCRS);
 	}
 
+	/**
+	 * Creates an referenced envelope from two referenced coordinates.
+	 * 
+	 * @param startCoord
+	 * @param endCoord
+	 */
+	public static ReferencedEnvelope createReferencedEnvelope(
+			DirectPosition startCoord, DirectPosition endCoord) {
+
+		if (!CRS.equalsIgnoreMetadata(
+				startCoord.getCoordinateReferenceSystem(), endCoord
+						.getCoordinateReferenceSystem()))
+			throw new IllegalArgumentException(
+					"The CRS of both coordinates have to be equal.");
+
+		ReferencedEnvelope re = new ReferencedEnvelope(startCoord
+				.getCoordinate()[0], endCoord.getCoordinate()[0], startCoord
+				.getCoordinate()[1], endCoord.getCoordinate()[1], startCoord
+				.getCoordinateReferenceSystem());
+
+		return re;
+	}
+
 }

Modified: branches/2.0-RC2/src/schmitzm/geotools/gui/MapActionControlPane.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/geotools/gui/MapActionControlPane.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/schmitzm/geotools/gui/MapActionControlPane.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -43,6 +43,7 @@
 import schmitzm.geotools.map.event.FeatureSelectedEvent;
 import schmitzm.swing.CaptionsChangeable;
 import schmitzm.swing.SwingUtil;
+import skrueger.geotools.XMapPaneTool;
 
 /**
  * Diese Klasse stellt einen {@link JToolBar} dar, mit dem zwischen den
@@ -184,38 +185,39 @@
     this(mapPane,orientation,ACTION_ALL);
   }
 
-  /**
-   * Setzt die Aktivierung der Aktionen entsprechend den Einstellungen
-   * des {@code JMapPane}.
-   * @see SelectableXMapPane#getWindowSelectionState()
-   */
-  public void resetActions() {
-    for (int i=0; i<getComponentCount(); i++) {
-      Component comp = getComponent(i);
-      if ( comp instanceof JButton )
-        ((JButton)comp).setSelected(false);
-    }
+	/**
+	 * Setzt die Aktivierung der Aktionen entsprechend den Einstellungen des
+	 * {@code JMapPane}.
+	 * 
+	 * @see SelectableXMapPane#getWindowSelectionState()
+	 */
+	public void resetActions() {
+		for (int i = 0; i < getComponentCount(); i++) {
+			Component comp = getComponent(i);
+			if (comp instanceof JButton)
+				((JButton) comp).setSelected(false);
+		}
 
-    // Buttons entsprechend dem MapPane-Status einstellen
-    infoState.doClick();
-    if ( mapPane != null ) {
-      switch( mapPane.getState() ) {
-        case SelectableXMapPane.ZOOM_IN:     if ( isActionVisible(ACTION_ZOOM_IN) )
-                                     zoomState.doClick();
-                                   break;
-        case SelectableXMapPane.SELECT_TOP:  if ( isActionVisible(ACTION_SELECT_TOP) )
-                                     selectTopState.doClick();
-                                   break;
-        case SelectableXMapPane.SELECT_ALL:  if ( isActionVisible(ACTION_SELECT_ALL) )
-                                     selectAllState.doClick();
-                                   break;
-        case SelectableXMapPane.NONE:        if ( isActionVisible(ACTION_INFO) )
-                                     infoState.doClick();
-                                   break;
-      }
-    }
-  }
+		// Buttons entsprechend dem MapPane-Status einstellen
+		infoState.doClick();
+		if (mapPane != null) {
+			if (mapPane.getTool() == XMapPaneTool.ZOOM_IN
+					|| mapPane.getTool() == XMapPaneTool.ZOOM_OUT) {
+				if (isActionVisible(ACTION_ZOOM_IN))
+					zoomState.doClick();
+			} else if (mapPane.getTool() == XMapPaneTool.SELECTION_TOP_LAYER) {
+				if (isActionVisible(ACTION_SELECT_TOP))
+					selectTopState.doClick();
+			} else if (mapPane.getTool() == XMapPaneTool.SELECTION_ALL_LAYERS) {
 
+				if (isActionVisible(ACTION_SELECT_ALL))
+					selectAllState.doClick();
+			} else if (mapPane.getTool() == XMapPaneTool.NO_ACTION)
+				if (isActionVisible(ACTION_INFO))
+					infoState.doClick();
+		}
+	}
+
   /**
    * Prueft, ob eine Aktion (Button) zur Verfuegung steht.
    * @param action Aktion codiert durch eine {@code ACTION}-Konstante
@@ -296,8 +298,7 @@
      * @param e das ActionEvent
      */
     public void actionPerformed(ActionEvent e) {
-      getMapPane().setState( SelectableXMapPane.NONE );
-      getMapPane().setState(SelectableXMapPane.NONE);
+      getMapPane().setTool( XMapPaneTool.NO_ACTION );
     }
   }
 
@@ -330,8 +331,7 @@
      * @param e das ActionEvent
      */
     public void actionPerformed(ActionEvent e) {
-      getMapPane().setState( SelectableXMapPane.ZOOM_IN );
-      getMapPane().setState(SelectableXMapPane.ZOOM_IN);
+      getMapPane().setTool( XMapPaneTool.ZOOM_IN);
     }
   }
 
@@ -365,8 +365,7 @@
      * @param e das ActionEvent
      */
     public void actionPerformed(ActionEvent e) {
-      getMapPane().setState( SelectableXMapPane.SELECT_TOP );
-      getMapPane().setState(SelectableXMapPane.SELECT_TOP);
+      getMapPane().setTool( XMapPaneTool.SELECTION_TOP_LAYER);
     }
   }
 
@@ -399,8 +398,7 @@
      * @param e das ActionEvent
      */
     public void actionPerformed(ActionEvent e) {
-      getMapPane().setState( SelectableXMapPane.SELECT_ALL );
-      getMapPane().setState(SelectableXMapPane.SELECT_ALL);
+      getMapPane().setTool( XMapPaneTool.SELECTION_ALL_LAYERS);
     }
   }
 

Modified: branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -133,7 +133,22 @@
  * @version 1.0
  */
 public class SelectableXMapPane extends XMapPane {
+	
 
+	/**
+	 * "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
+	 */
+	public static final int SELECT_ALL = 103;
+	/**
+	 * "Auswahl nur eines Features, das erste sichtbare von Oben".
+	 */
+	public static final int SELECT_ONE_FROM_TOP = 104;
+	/**
+	 * "SimpleFeature-Auswahl auf dem obersten (sichtbaren) Layer".
+	 */
+	public static final int SELECT_TOP = 4;
+
+
 	/** Logger for debug messages. */
 	protected static final Logger LOGGER = Logger
 			.getLogger(SelectableXMapPane.class);
@@ -293,7 +308,7 @@
 		// this.addMouseMotionListener(selectMapPaneMouseListener);
 		// this.addMouseWheelListener(selectMapPaneMouseListener);
 
-		setState(ZOOM_IN);
+//		setState(ZOOM_IN);
 
 		//
 		// // CRS wird immer vom ersten in die Karte eingefuegten Layer
@@ -859,7 +874,7 @@
 			// wenn nur im obersten (sichtbaren) Layer gesucht wird.
 			// Ansonsten Nicht-Raster-Layer einfach uebergehen.
 			if (!(layerObj instanceof GridCoverage2D)) {
-				if ((selectionMode == XMapPane.SELECT_TOP || selectionMode == XMapPane.SELECT_ONE_FROM_TOP)
+				if ((selectionMode == SELECT_TOP || selectionMode == SELECT_ONE_FROM_TOP)
 						&& featureLayerIntersectsEnvelope(layer, env))
 					break;
 				continue;

Modified: branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -641,6 +641,10 @@
 	 *         {@linkplain #getToolButton(int) tool button}
 	 */
 	public AbstractButton getButton(int id) {
+		
+		//ACHUTNG: Das ist ein SK QUICK FIX! TODO 
+		if (!(toolAndActionButtons.get(id) instanceof AbstractButton)) return null;
+		
 		AbstractButton button = (AbstractButton) toolAndActionButtons.get(id);
 		if (button == null)
 			LOGGER.warn("Unknown tool or action ID: " + id);
@@ -782,10 +786,13 @@
 	 *            is {@code false}
 	 */
 	public void setAllToolsEnabled(boolean enabled, boolean hideOnDisable) {
-		for (int tool : toolAndActionButtons.keySet())
-			setButtonEnabled(tool, enabled, hideOnDisable);
+		for (int id : toolAndActionButtons.keySet()) {
+			if (toolAndActionButtons.get(id) instanceof JToggleButton) {
+			setButtonEnabled(id, enabled, hideOnDisable);
+			}
+		}
 	}
-
+	
 	/**
 	 * Sets the activation for all actions.
 	 * 

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -104,6 +104,10 @@
 	// private static final int IMAGETYPE_withAlpha =
 	// BufferedImage.TYPE_INT_ARGB;
 	private static final int IMAGETYPE = BufferedImage.TYPE_3BYTE_BGR;
+	public XMapPaneTool getTool() {
+		return tool;
+	}
+
 	private static final int IMAGETYPE_withAlpha = BufferedImage.TYPE_4BYTE_ABGR;
 
 	private final static Logger LOGGER = Logger.getLogger(XMapPane.class);
@@ -174,55 +178,31 @@
 	 * Flag for no-tool.
 	 */
 	public static final int NONE = -123;
+//
+//	/**
+//	 * Flag fuer Modus "Kartenausschnitt bewegen". Nicht fuer Window-Auswahl
+//	 * moeglich!
+//	 * 
+//	 * @see #setState(int)
+//	 */
+//	public static final int PAN = 1;
+//
+//	/**
+//	 * Flag fuer Modus "Heran zoomen".
+//	 * 
+//	 * @see #setState(int)
+//	 * @see #setState(int)
+//	 */
+//	public static final int ZOOM_IN = 2;
+//
+//	/**
+//	 * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
+//	 * 
+//	 * @see #setState(int)
+//	 */
+//	public static final int ZOOM_OUT = 3;
 
 	/**
-	 * Flag fuer Modus "Kartenausschnitt bewegen". Nicht fuer Window-Auswahl
-	 * moeglich!
-	 * 
-	 * @see #setState(int)
-	 */
-	public static final int PAN = 1;
-
-	/**
-	 * Flag fuer Modus "Heran zoomen".
-	 * 
-	 * @see #setState(int)
-	 * @see #setState(int)
-	 */
-	public static final int ZOOM_IN = 2;
-
-	/**
-	 * Flag fuer Modus "Heraus zoomen". Nicht fuer Window-Auswahl moeglich!
-	 * 
-	 * @see #setState(int)
-	 */
-	public static final int ZOOM_OUT = 3;
-
-	/**
-	 * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
-	 * 
-	 * @see #setState(int)
-	 * @see #setState(int)
-	 */
-	public static final int SELECT_ALL = 103;
-	/**
-	 * Flag fuer Modus
-	 * "Auswahl nur eines Features, das erste sichtbare von Oben".
-	 * 
-	 * @see #setState(int)
-	 * @see #setState(int)
-	 */
-	public static final int SELECT_ONE_FROM_TOP = 104;
-	/**
-	 * Flag fuer Modus
-	 * "SimpleFeature-Auswahl auf dem obersten (sichtbaren) Layer".
-	 * 
-	 * @see #setState(int)
-	 * @see #setState(int)
-	 */
-	public static final int SELECT_TOP = 4;
-
-	/**
 	 * {@link Font} used to paint the wait messages into the map
 	 * 
 	 * @see #addGadgets(Graphics2D, boolean)
@@ -561,14 +541,14 @@
 	 * thread.
 	 */
 	final private Timer startRenderThreadsTimer;
+//
+//	/**
+//	 * The default state is ZOOM_IN, hence by default the
+//	 * {@link #xMapPaneMouseListener} is also enabled.
+//	 **/
+//	private int state = ZOOM_IN;
 
 	/**
-	 * The default state is ZOOM_IN, hence by default the
-	 * {@link #xMapPaneMouseListener} is also enabled.
-	 **/
-	private int state = ZOOM_IN;
-
-	/**
 	 * Manuell gesetzter statischer Cursor, unabhaengig von der aktuellen
 	 * MapPane-Funktion
 	 */
@@ -631,19 +611,10 @@
 		this.addMouseListener(xMapPaneMouseListener);
 		this.addMouseMotionListener(xMapPaneMouseListener);
 		this.addMouseWheelListener(xMapPaneMouseListener);
-		xMapPaneMouseListener.actions.put(MouseInputType.LClick,
-				XMapPaneAction.ZOOM_IN);
-		xMapPaneMouseListener.actions.put(MouseInputType.LDrag,
-				XMapPaneAction.ZOOM_IN);
-		xMapPaneMouseListener.actions.put(MouseInputType.Wheel,
-				XMapPaneAction.ZOOM_IN);
-
-		xMapPaneMouseListener.actions.put(MouseInputType.RClick,
-				XMapPaneAction.SELECT_ALL);
-
-		xMapPaneMouseListener.actions.put(MouseInputType.RDrag,
-				XMapPaneAction.PAN);
-
+		
+		// By default the XMapPAne uses the ZOOM_IN tool.
+		setTool(XMapPaneTool.ZOOM_IN);
+		
 		/*
 		 * We use a Timer object to avoid rendering delays and flickering when
 		 * the user is drag-resizing the parent container of this map pane.
@@ -1317,9 +1288,9 @@
 		return new AffineTransform(screenToWorld);
 	}
 
-	public int getState() {
-		return state;
-	}
+//	public int getState() {
+//		return state;
+//	}
 
 	/**
 	 * Liefert den statisch eingestellten Cursor, der unabhaengig von der
@@ -1957,7 +1928,7 @@
 
 	// /** Stored the time used for the last real rendering in ms. **/
 	private long lastRenderingDuration = 1000;
-	private XMapPaneTool tool = XMapPaneTool.INFO;
+	private XMapPaneTool tool = null;
 
 	/**
 	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
@@ -1989,33 +1960,30 @@
 			this.rendererHints = rendererHints;
 	}
 
-	/**
-	 * Enables/Disables the ZOOM Mouse Listener. Upates the Cursor and stops the
-	 * repaint Timer if
-	 * 
-	 * @param state
-	 */
-	@Deprecated
-	public void setState(final int state) {
-		this.state = state;
+//	@Deprecated
+//	public void setState(final int state) {
+//		this.state = state;
+//
+//		// throw new RuntimeException("Old concept.. migrate to new concept!");
+//
+//		// xMapPaneMouseListener.setEnabled((state == ZOOM_IN
+//		// || state == ZOOM_OUT || state == PAN));
+//
+//		// Je nach Aktion den Cursor umsetzen
+//		updateCursor();
+//	}
 
-		// throw new RuntimeException("Old concept.. migrate to new concept!");
-
-		// xMapPaneMouseListener.setEnabled((state == ZOOM_IN
-		// || state == ZOOM_OUT || state == PAN));
-
-		// Je nach Aktion den Cursor umsetzen
-		updateCursor();
-	}
-
 	public void configureMouse(MouseInputType type, XMapPaneAction action) {
 		xMapPaneMouseListener.actions.put(type, action);
 	}
 	
 	/**
-	 * Configure the tool that active on the map 
+	 * Configure the {@link XMapPaneTool} that active on the map. Passing
+	 * <code>null</code> will set the NO_ACTION tool.
 	 */
 	public void setTool(XMapPaneTool tool) {
+		if (tool == null)
+			tool = XMapPaneTool.NO_ACTION;
 		this.tool = tool;
 		xMapPaneMouseListener.configure(tool);
 		setCursor(tool.cursor);
@@ -2192,6 +2160,7 @@
 		}
 		
 		setCursor(tool.cursor);
+		
 //
 //		// Set the cursor depending on what tool is in use...
 //		switch (state) {

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -122,7 +122,7 @@
 
 		// If no vector features were found, or we are in SELECT_ALL mode, we
 		// check the raster layers now
-		if (getSelectionMode() == XMapPane.SELECT_ALL || result.isEmpty()) {
+		if (getSelectionMode() == SelectableXMapPane.SELECT_ALL || result.isEmpty()) {
 			sexMapPane.findGridCoverageValuesAndFireEvents(geoPoint,
 					getSelectionMode());
 		}
@@ -194,21 +194,21 @@
 	public static class All extends XMapPaneAction_Select {
 
 		int getSelectionMode() {
-			return XMapPane.SELECT_ALL;
+			return SelectableXMapPane.SELECT_ALL;
 		}
 	}
 
 	public static class OneFromTop extends XMapPaneAction_Select {
 
 		int getSelectionMode() {
-			return XMapPane.SELECT_ONE_FROM_TOP;
+			return SelectableXMapPane.SELECT_ONE_FROM_TOP;
 		}
 	}
 
 	public static class Top extends XMapPaneAction_Select {
 
 		int getSelectionMode() {
-			return XMapPane.SELECT_TOP;
+			return SelectableXMapPane.SELECT_TOP;
 		}
 	}
 

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -22,6 +22,54 @@
  */
 public class XMapPaneTool {
 
+	public Cursor getCursor() {
+		return cursor;
+	}
+
+	public void setCursor(Cursor cursor) {
+		this.cursor = cursor;
+	}
+
+	public String getToolTip() {
+		return toolTip;
+	}
+
+	public void setToolTip(String toolTip) {
+		this.toolTip = toolTip;
+	}
+
+	public Icon getIcon() {
+		return icon;
+	}
+
+	public void setIcon(Icon icon) {
+		this.icon = icon;
+	}
+
+	public XMapPaneAction getMouseAction(MouseInputType type) {
+		return mouseActions.get(type);
+	}
+
+	public void setMouseAction(MouseInputType type, XMapPaneAction mouseAction) {
+		this.mouseActions.put(type, mouseAction);;
+	}
+
+	public XMapPaneAction getKeyAction(KeyStroke keyStroke) {
+		return keyAction.get(keyStroke);
+	}
+
+	public void setKeyAction(KeyStroke keyStroke, XMapPaneAction keyAction) {
+		this.keyAction.put(keyStroke,keyAction);
+	}
+
+	public Object getKeyActionParam(KeyStroke keyStroke) {
+		return keyActionParams.get(keyStroke);
+	}
+
+	public void setKeyActionParam(KeyStroke keyStroke, Object param) {
+		this.keyActionParams.put(keyStroke, param);
+	}
+
 	public XMapPaneTool() {
 		addDefaultKeyboardAssignments(this);
 	}
@@ -61,7 +109,15 @@
 	 * {@link KeyStroke} is triggered
 	 **/
 	Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>();
-
+	
+	/** This {@link XMapPaneTool} does nothing **/
+	public static XMapPaneTool NO_ACTION = new XMapPaneTool() ;
+	static {
+		// Remove the keyboard mapping that are defined by the default constructor
+		NO_ACTION.keyAction.clear();
+		NO_ACTION.keyActionParams.clear();
+	}
+	
 	/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
 	public static XMapPaneTool ZOOM_IN = new XMapPaneTool();
 	static {
@@ -134,7 +190,97 @@
 		PAN.mouseActions.put(MouseInputType.Wheel, XMapPaneAction_Zoom.ZOOM_IN);
 
 	}
+	
+	
 
+	/** A tool that will do a select_top action on the left mouse button **/
+	public static final XMapPaneTool SELECTION_TOP_LAYER = new XMapPaneTool();
+	static {
+//		SELECTION_TOP_LAYER.icon = new ImageIcon(MapView.class
+//				.getResource("resource/icons/selection_add.png"));
+//		SELECTION_TOP_LAYER.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_TOP);
+		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_TOP);
+
+		SELECTION_TOP_LAYER.mouseActions
+				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		SELECTION_TOP_LAYER.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// TODO Strg-A shoud select all
+	}
+	
+
+	/** A tool that will do a select_top action on the left mouse button **/
+	public static final XMapPaneTool SELECTION_ONE_FROM_TOP_LAYER = new XMapPaneTool();
+	static {
+//		SELECTION_ONE_FROM_TOP.icon = new ImageIcon(MapView.class
+//				.getResource("resource/icons/selection_add.png"));
+//		SELECTION_ONE_FROM_TOP.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_ONE_FROM_TOP_LAYER.cursor = SwingUtil.SELECTION_SET_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ONE_FROM_TOP);
+		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_ONE_FROM_TOP);
+
+		SELECTION_ONE_FROM_TOP_LAYER.mouseActions
+				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		SELECTION_ONE_FROM_TOP_LAYER.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// TODO Strg-A shoud select all
+	}
+
+	
+
+	/** A tool that will do a select_top action on the left mouse button **/
+	public static final XMapPaneTool SELECTION_ALL_LAYERS = new XMapPaneTool();
+	static {
+//		SELECTION_ALL_LAYERS.icon = new ImageIcon(MapView.class
+//				.getResource("resource/icons/selection_add.png"));
+//		SELECTION_ALL_LAYERS.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_ALL_LAYERS.cursor = SwingUtil.SELECTION_SET_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ALL);
+		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_ALL);
+
+		SELECTION_ALL_LAYERS.mouseActions
+				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		SELECTION_ALL_LAYERS.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// TODO Strg-A shoud select all
+	}
+
+
 	/** The configuration of the INFO {@link XMapPaneTool} **/
 	public static final XMapPaneTool INFO = new XMapPaneTool();
 

Deleted: branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java	2010-02-01 18:13:14 UTC (rev 654)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java	2010-02-03 11:47:44 UTC (rev 655)
@@ -1,7 +0,0 @@
-package skrueger.geotools;
-
-import javax.swing.JToolBar;
-
-public class XMapPaneToolBar extends JToolBar {
-
-}



More information about the Schmitzm-commits mailing list