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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Feb 1 16:09:26 CET 2010


Author: alfonx
Date: 2010-02-01 16:09:18 +0100 (Mon, 01 Feb 2010)
New Revision: 653

Added:
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java
Modified:
   branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/GeomFilterGenerator.java
   branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
   branches/2.0-RC2/src/skrueger/geotools/SelectXMapPaneMouseListener.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Pan.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java
Log:
GP-Cleanup: Implemented the XMapPaneAction and XMapPaneTool comcept for all GeoPublisher tools except for the SelectionTools

Modified: branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -33,8 +33,6 @@
 import java.awt.LayoutManager;
 import java.awt.Point;
 import java.awt.RenderingHints;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.Point2D;
 import java.io.IOException;
@@ -85,7 +83,6 @@
 import schmitzm.geotools.map.event.ScaleChangedEvent;
 import schmitzm.geotools.styling.StylingUtil;
 import skrueger.geotools.GeomFilterGenerator;
-import skrueger.geotools.SelectXMapPaneMouseListener;
 import skrueger.geotools.XMapPane;
 import skrueger.geotools.GeomFilterGenerator.BoundingBoxFilterGenerator;
 
@@ -191,11 +188,12 @@
 		this(null, null);
 	}
 
-//	/**
-//	 * This {@link MouseListener} is managing all selection related tasks
-//	 */
-//	protected final SelectXMapPaneMouseListener selectMapPaneMouseListener = new SelectXMapPaneMouseListener(
-//			this);
+	// /**
+	// * This {@link MouseListener} is managing all selection related tasks
+	// */
+	// protected final SelectXMapPaneMouseListener selectMapPaneMouseListener =
+	// new SelectXMapPaneMouseListener(
+	// this);
 
 	/**
 	 * Erzeugt ein neues MapPane.
@@ -288,12 +286,12 @@
 		// mapLayerSelectable.remove(e.getLayer());
 		// }
 		// });
-//		/**
-//		 * Adding the #selectionMapPaneMouseListener
-//		 */
-//		this.addMouseListener(selectMapPaneMouseListener);
-//		this.addMouseMotionListener(selectMapPaneMouseListener);
-//		this.addMouseWheelListener(selectMapPaneMouseListener);
+		// /**
+		// * Adding the #selectionMapPaneMouseListener
+		// */
+		// this.addMouseListener(selectMapPaneMouseListener);
+		// this.addMouseMotionListener(selectMapPaneMouseListener);
+		// this.addMouseWheelListener(selectMapPaneMouseListener);
 
 		setState(ZOOM_IN);
 
@@ -365,7 +363,6 @@
 		// });
 	}
 
-
 	/**
 	 * Liefert die Anzahl der Einheiten, die ein Bildschirm-Pixel darstellt. Die
 	 * Einheit ist die Grundeinheit des CRS
@@ -426,20 +423,21 @@
 	 * Liefert unterste Layer (sichtbar oder unsichtbar).
 	 */
 	public MapLayer getBottomLayer() {
-		return getMapContext().getLayerCount() > 0 ? getMapContext().getLayer(0)
-				: null;
+		return getMapContext().getLayerCount() > 0 ? getMapContext()
+				.getLayer(0) : null;
 	}
-//
-//	/**
-//	 * @param state
-//	 *            Modus fuer Window-Selektion
-//	 */
-//	public void setState(final int state) {
-//		selectMapPaneMouseListener.setEnabled((state == SELECT_ALL
-//				|| state == SELECT_ONE_FROM_TOP || state == SELECT_TOP));
-//		super.setState(state);
-//	}
 
+	//
+	// /**
+	// * @param state
+	// * Modus fuer Window-Selektion
+	// */
+	// public void setState(final int state) {
+	// selectMapPaneMouseListener.setEnabled((state == SELECT_ALL
+	// || state == SELECT_ONE_FROM_TOP || state == SELECT_TOP));
+	// super.setState(state);
+	// }
+
 	/**
 	 * Ermittelt die Raster-Werte, die an einem Punkt liegen und erzeugt
 	 * entsprechende {@link GridCoverageValueSelectedEvent
@@ -771,8 +769,12 @@
 	 *            X-Koordinate der BIS-Position
 	 * @param py
 	 *            Y-Koordinate der BIS-Position
+	 * 
+	 * @param selectionMode
+	 *            on of SELECT_TOP, SELECT_ONE_FROM_TOP, SELECT_ALL
 	 */
-	public void performSelectionEvent(int ox, int oy, int px, int py) {
+	public void performSelectionEvent(int ox, int oy, int px, int py,
+			int selectionMode) {
 
 		if (getMapContext().getLayerCount() == 0)
 			return;
@@ -783,23 +785,17 @@
 		// Generelles Event ausloesen
 		fireMapPaneEvent(new GeneralSelectionEvent(this, env));
 
-		int selectState = getState();
-		switch (selectState) {
-		// case ZOOM_IN: // Karte neu setzen
-		// LOGGER.error("WHEN IS THIS CALLED?!");
-		// this.setMapArea(env);
-		// refresh(); // WICHTIG!! Damit die veraenderte Form beruecksichtigt
-		// // wird!?
-		// break;
+		switch (selectionMode) {
 		case SELECT_TOP:
 		case SELECT_ONE_FROM_TOP:
 		case SELECT_ALL: // Features selektieren
 
 			boolean featuresFound = findFeaturesAndFireEvents(
 					new BoundingBoxFilterGenerator(env, getMapContext()
-							.getCoordinateReferenceSystem()), selectState, env);
-			if (selectState == SELECT_ALL || !featuresFound)
-				findGridCoverageSubsetsAndFireEvents(env, selectState);
+							.getCoordinateReferenceSystem()), selectionMode,
+					env);
+			if (selectionMode == SELECT_ALL || !featuresFound)
+				findGridCoverageSubsetsAndFireEvents(env, selectionMode);
 			break;
 		}
 	}

Modified: branches/2.0-RC2/src/skrueger/geotools/GeomFilterGenerator.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/GeomFilterGenerator.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/GeomFilterGenerator.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -13,6 +13,7 @@
 import org.opengis.feature.type.GeometryDescriptor;
 import org.opengis.filter.expression.Expression;
 import org.opengis.filter.spatial.BinarySpatialOperator;
+import org.opengis.geometry.DirectPosition;
 import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import schmitzm.geotools.FilterUtil;
@@ -203,8 +204,7 @@
 		 * Creates a new filter generator.
 		 * 
 		 * @param basePoint
-		 *            defNearPointFilterGeneratorines the point for the
-		 *            "near point" constraint
+		 *            defines the point for the "near point" constraint
 		 * @param dist
 		 *            defines the distance around the base point
 		 * @param crs
@@ -217,7 +217,6 @@
 			this.baseEnv = new ReferencedEnvelope(basePoint.getX() - radius,
 					basePoint.getX() + radius, basePoint.getY() - radius,
 					basePoint.getY() + radius, crs);
-
 		}
 
 		/**
@@ -236,8 +235,23 @@
 			this(GF.createPoint(new Coordinate(basePoint.getX(), basePoint
 					.getY())), dist, crs);
 		}
+		
 
 		/**
+		 * Creates a new filter generator.
+		 * 
+		 * @param basePoint
+		 *            defines the Position for the "near point" constraint
+		 * @param dist
+		 *            defines the distance around the base point in base point
+		 *            CRS
+		 */
+		public PointFilterGenerator(DirectPosition basePos, double dist) {
+			this(GF.createPoint(new Coordinate(basePos.getCoordinate()[0], basePos
+					.getCoordinate()[1])), dist, basePos.getCoordinateReferenceSystem());
+		}
+
+		/**
 		 * Prepares a filter with the base point and distance transformed to the
 		 * given {@link CoordinateReferenceSystem} as the "right" argument.
 		 * 

Modified: branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -59,6 +59,7 @@
 import schmitzm.lang.LangUtil;
 import schmitzm.lang.ResourceProvider;
 import schmitzm.swing.ButtonGroup;
+import schmitzm.swing.SwingUtil;
 import skrueger.swing.SmallButton;
 import skrueger.swing.SmallToggleButton;
 
@@ -306,22 +307,36 @@
 	 */
 	protected void initToolsAndActions() {
 		// Panning
-		addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon(
-				MapView.class.getResource("resource/icons/pan.png")),
-				R("MapPaneButtons.Pan.TT")), false);
+//		addTool(new MapPaneToolBarAction(TOOL_PAN, this, "", new ImageIcon(
+//				MapView.class.getResource("resource/icons/pan.png")),
+//				R("MapPaneButtons.Pan.TT")), false);
+
+		addTool(new MapPaneToolBarAction(TOOL_PAN, this, XMapPaneTool.PAN), false);
+		
 		// Info
-		addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon(
-				MapView.class.getResource("resource/icons/info.png")),
-				R("MapPaneButtons.Info.TT")), false);
-
+//		addTool(new MapPaneToolBarAction(TOOL_INFO, this, "", new ImageIcon(
+//				MapView.class.getResource("resource/icons/info.png")),
+//				R("MapPaneButtons.Info.TT")), false);
+		addTool(new MapPaneToolBarAction(TOOL_INFO, this, XMapPaneTool.INFO), false);
+		
 		// Zoom in
-		addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon(
-				MapView.class.getResource("resource/icons/zoom_in.png")),
-				R("MapPaneButtons.ZoomIn.TT")), false);
+		addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, XMapPaneTool.ZOOM_IN), false);
+		
 		// Zoom out
-		addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon(
-				MapView.class.getResource("resource/icons/zoom_out.png")),
-				R("MapPaneButtons.ZoomOut.TT")), false);
+		addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, XMapPaneTool.ZOOM_OUT), false);
+		
+		
+//		// Zoom in
+//		addTool(new MapPaneToolBarAction(TOOL_ZOOMIN, this, "", new ImageIcon(
+//				MapView.class.getResource("resource/icons/zoom_in.png")),
+//				R("MapPaneButtons.ZoomIn.TT")), false);
+//		
+//		// Zoom out
+//		addTool(new MapPaneToolBarAction(TOOL_ZOOMOUT, this, "", new ImageIcon(
+//				MapView.class.getResource("resource/icons/zoom_out.png")),
+//				R("MapPaneButtons.ZoomOut.TT")), false);
+		
+		
 
 		// Action button to revert the last zoom
 		addAction(new MapPaneToolBarAction(ACTION_ZOOM_BACK, this, "",
@@ -425,22 +440,25 @@
 		switch (tool) {
 		case TOOL_PAN:
 			// Set the mouse tool to "Panning"
-			mapPane.setState(SelectableXMapPane.PAN);
+//			mapPane.setState(SelectableXMapPane.PAN);
+			mapPane.setTool(XMapPaneTool.PAN);
 //			mapPane.setNormalCursor(SwingUtil.PAN_CURSOR);
 			break;
 		case TOOL_INFO:
 			// Set the mouse tool to "Info"
-			mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); 
+			mapPane.setTool(XMapPaneTool.INFO);
+//			mapPane.setState(SelectableXMapPane.SELECT_ONE_FROM_TOP); 
 //			mapPane.setNormalCursor(SwingUtil.CROSSHAIR_CURSOR);
 			break;
 		case TOOL_ZOOMIN:
 			// Set the mouse tool to "Zoom in"
-			mapPane.setState(SelectableXMapPane.ZOOM_IN);
+			mapPane.setTool(XMapPaneTool.ZOOM_IN);
 //			mapPane.setNormalCursor(SwingUtil.ZOOMIN_CURSOR);
 			break;
 		case TOOL_ZOOMOUT:
 			// Set the mouse tool to "Zoom out"
-			mapPane.setState(SelectableXMapPane.ZOOM_OUT);
+			mapPane.setTool(XMapPaneTool.ZOOM_OUT);
+//			mapPane.setState(SelectableXMapPane.ZOOM_OUT);
 //			mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
 			break;
 		default:
@@ -689,7 +707,7 @@
 			return -1;
 		return selectedTool;
 	}
-
+	
 	/**
 	 * Sets whether a tool or action is activated or not. The visible property
 	 * of the button is not affected.
@@ -888,6 +906,10 @@
 			this.toolBar = toolBar;
 		}
 
+		public MapPaneToolBarAction(int id, MapPaneToolBar toolBar, XMapPaneTool tool) {
+			this(id, toolBar, "", tool.icon, tool.toolTip);
+		}
+
 		/**
 		 * Calls {@link MapPaneToolBar#performToolButton(int, ActionEvent)} or
 		 * {@link MapPaneToolBar#performActionButton(int, ActionEvent)}

Modified: branches/2.0-RC2/src/skrueger/geotools/SelectXMapPaneMouseListener.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/SelectXMapPaneMouseListener.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -1,250 +1,250 @@
-package skrueger.geotools;
-
-import java.awt.Cursor;
-import java.awt.Point;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseWheelEvent;
-import java.awt.geom.Point2D;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.apache.log4j.Logger;
-import org.geotools.data.memory.MemoryFeatureCollection;
-import org.geotools.feature.FeatureCollection;
-import org.geotools.map.MapLayer;
-import org.opengis.feature.simple.SimpleFeature;
-import org.opengis.feature.simple.SimpleFeatureType;
-
-import schmitzm.geotools.gui.SelectableXMapPane;
-import schmitzm.geotools.map.event.FeatureSelectedEvent;
-import skrueger.geotools.GeomFilterGenerator.PointFilterGenerator;
-
-import com.vividsolutions.jts.geom.Coordinate;
-import com.vividsolutions.jts.geom.Envelope;
-import com.vividsolutions.jts.geom.Geometry;
-import com.vividsolutions.jts.geom.GeometryFactory;
-
-public class SelectXMapPaneMouseListener extends MouseAdapter {
-	private static Logger LOGGER = Logger
-	.getLogger(SelectXMapPaneMouseListener.class);
-
-	private final SelectableXMapPane xMapPane;
-	private boolean enabled;
-
-	public boolean isEnabled() {
-		if (!xMapPane.isWellDefined())
-			return false;
-		if ((xMapPane.getState() == XMapPane.ZOOM_IN
-				|| xMapPane.getState() == XMapPane.ZOOM_OUT || xMapPane
-				.getState() == XMapPane.PAN))
-			return false;
-		if (xMapPane.getState() == XMapPane.NONE)
-			return false;
-		return enabled;
-	}
-
-	/**
-	 * Default distance fraction used with line and point features. When the
-	 * user clicks on the map, this tool searches for features within a
-	 * rectangle of width w centred on the mouse location, where w is the
-	 * average map side length multiplied by the value of this constant.
-	 */
-	public static final double DEFAULT_DISTANCE_FRACTION = 0.01d;
-
-	/**
-	 * Reagiert auf Linksklick mit der ueber {@link #setState(int)}eingestellten
-	 * Aktion und auf Rechtsklick mit Zoom-Out (sofern {@link #ZOOM_IN}-State
-	 * fuer Linksklick eingestellt). Alle anderen Klicks werden ignoriert.
-	 * 
-	 * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
-	 *         (University of Bonn/Germany)
-	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
-	 *         Kr&uuml;ger</a>
-	 */
-	public void mouseClicked(MouseEvent e) {
-
-		if (!isEnabled())
-			return;
-
-		xMapPane.setCursor(Cursor
-				.getPredefinedCursor(Cursor.WAIT_CURSOR));
-
-		int state = xMapPane.getState();
-
-		/**
-		 * BEGIN StefanChange Dieser Block findet sichtbare Features im Umkreis
-		 * des Mausklicks und kümmert sich selbst um das verschicken der Events.
-		 * Dabei wird z.Zt. immer eine FeaterCollection mit nur einem
-		 * SimpleFeature verschickt. Und zwar jenes SimpleFeature, welches am
-		 * nächsten liegt.
-		 */
-
-		// Fenster-Koordinate in Geo-Koordinate umwandelt
-		Point2D geoCoord = xMapPane.getScreenToWorld().transform(e.getPoint(),
-				null);
-
-		double radius = DEFAULT_DISTANCE_FRACTION
-				* (xMapPane.getMapArea().getWidth() + xMapPane.getMapArea()
-						.getHeight()) / 2;
-
-		PointFilterGenerator filterGenerator = new PointFilterGenerator(geoCoord, radius,
-				xMapPane.getMapContext().getCoordinateReferenceSystem());
-		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = xMapPane
-				.findVisibleFeatures(filterGenerator,
-						state, new Envelope(geoCoord.getX(), geoCoord.getX(),
-								geoCoord.getY(), geoCoord.getY()));
-		
-		// Ein Event auslösen für das jeweils nächste Feature pro Layer
-		for (Enumeration<MapLayer> element = result.keys(); element
-				.hasMoreElements();) {
-
-			MapLayer layer = element.nextElement();
-			FeatureCollection<SimpleFeatureType, SimpleFeature> fc = result
-					.get(layer);
-			FeatureCollection<SimpleFeatureType, SimpleFeature> fcOne;
-
-			if (fc != null && !fc.isEmpty()) {
-
-				if (fc.size() > 1) {
-					// If the result contains more that one feature, we only
-					// return the nearest one.
-
-					SimpleFeature nearestFeature = null;
-					Double nearestDist = 0.0;
-
-					Iterator<SimpleFeature> fcIt = fc.iterator();
-					try {
-						com.vividsolutions.jts.geom.Point mousePoint = new GeometryFactory()
-						.createPoint(new Coordinate(geoCoord.getX(), geoCoord.getY()));
-
-						while (fcIt.hasNext()) {
-							SimpleFeature f = fcIt.next();
-							Geometry obj = (Geometry) f
-									.getDefaultGeometryProperty().getValue();
-
-							// TODO Hier muss doch irgendwie noch CRS
-							// umgewrechnet werden...
-
-							Geometry featureGeometry = (Geometry) obj;
-
-							double distance = featureGeometry
-									.distance(mousePoint);
-
-							if ((nearestFeature == null)
-									|| (distance < nearestDist)) {
-								nearestFeature = f;
-								nearestDist = distance;
-							}
-
-						}
-
-					} finally {
-						fc.close(fcIt);
-					}
-
-					fcOne = new MemoryFeatureCollection(fc.getSchema());
-					fc.clear();
-					fcOne.add(nearestFeature);
-				} else {
-					fcOne = fc;
-				}
-
-				// Fire the event with the one selected feature
-				xMapPane.fireMapPaneEvent(new FeatureSelectedEvent(xMapPane,
-						layer, fcOne.getBounds(), fcOne));
-			}
-		}
-		
-		// If no vector features were found, or we are in SELECT_ALL mode, we check the raster layers now
-		if (state == XMapPane.SELECT_ALL || result.isEmpty()) {
-			xMapPane.findGridCoverageValuesAndFireEvents(geoCoord, state);			
-		}
-
-		xMapPane.updateCursor();
-
-	}
-
-	/**
-	 * Verarbeitet die Mausrad-Aktion, indem gezoomed wird.
-	 * 
-	 * @param wheelEvt
-	 *            Mausrad-Event
-	 */
-	@Override
-	public void mouseWheelMoved(MouseWheelEvent wheelEvt) {
-		if (!isEnabled())
-			return;
-
-		final int units = wheelEvt.getUnitsToScroll();
-		if (units > 0)
-			xMapPane.zoomTo(wheelEvt.getPoint(), 1. + .11 * units);
-		else
-			xMapPane.zoomTo(wheelEvt.getPoint(), 2. / -units);
-	}
+//package skrueger.geotools;
 //
-//	@Override
-//	public void mouseDragged(final MouseEvent event) {
+//import java.awt.Cursor;
+//import java.awt.Point;
+//import java.awt.event.MouseAdapter;
+//import java.awt.event.MouseEvent;
+//import java.awt.event.MouseWheelEvent;
+//import java.awt.geom.Point2D;
+//import java.util.Enumeration;
+//import java.util.Hashtable;
+//import java.util.Iterator;
+//
+//import org.apache.log4j.Logger;
+//import org.geotools.data.memory.MemoryFeatureCollection;
+//import org.geotools.feature.FeatureCollection;
+//import org.geotools.map.MapLayer;
+//import org.opengis.feature.simple.SimpleFeature;
+//import org.opengis.feature.simple.SimpleFeatureType;
+//
+//import schmitzm.geotools.gui.SelectableXMapPane;
+//import schmitzm.geotools.map.event.FeatureSelectedEvent;
+//import skrueger.geotools.GeomFilterGenerator.PointFilterGenerator;
+//
+//import com.vividsolutions.jts.geom.Coordinate;
+//import com.vividsolutions.jts.geom.Envelope;
+//import com.vividsolutions.jts.geom.Geometry;
+//import com.vividsolutions.jts.geom.GeometryFactory;
+//
+//public class SelectXMapPaneMouseListener extends MouseAdapter {
+//	private static Logger LOGGER = Logger
+//	.getLogger(SelectXMapPaneMouseListener.class);
+//
+//	private final SelectableXMapPane xMapPane;
+//	private boolean enabled;
+//
+//	public boolean isEnabled() {
+//		if (!xMapPane.isWellDefined())
+//			return false;
+//		if ((xMapPane.getState() == XMapPane.ZOOM_IN
+//				|| xMapPane.getState() == XMapPane.ZOOM_OUT || xMapPane
+//				.getState() == XMapPane.PAN))
+//			return false;
+//		if (xMapPane.getState() == XMapPane.NONE)
+//			return false;
+//		return enabled;
+//	}
+//
+//	/**
+//	 * Default distance fraction used with line and point features. When the
+//	 * user clicks on the map, this tool searches for features within a
+//	 * rectangle of width w centred on the mouse location, where w is the
+//	 * average map side length multiplied by the value of this constant.
+//	 */
+//	public static final double DEFAULT_DISTANCE_FRACTION = 0.01d;
+//
+//	/**
+//	 * Reagiert auf Linksklick mit der ueber {@link #setState(int)}eingestellten
+//	 * Aktion und auf Rechtsklick mit Zoom-Out (sofern {@link #ZOOM_IN}-State
+//	 * fuer Linksklick eingestellt). Alle anderen Klicks werden ignoriert.
+//	 * 
+//	 * @author <a href="mailto:martin.schmitz at koeln.de">Martin Schmitz</a>
+//	 *         (University of Bonn/Germany)
+//	 * @author <a href="mailto:skpublic at wikisquare.de">Stefan Alfons
+//	 *         Kr&uuml;ger</a>
+//	 */
+//	public void mouseClicked(MouseEvent e) {
+//
 //		if (!isEnabled())
 //			return;
 //
-//		xMapPane.mouseDragged(startPos, lastPos, event);
+//		xMapPane.setCursor(Cursor
+//				.getPredefinedCursor(Cursor.WAIT_CURSOR));
 //
-//		lastPos = event.getPoint();
+//		int state = xMapPane.getState();
+//
+//		/**
+//		 * BEGIN StefanChange Dieser Block findet sichtbare Features im Umkreis
+//		 * des Mausklicks und kümmert sich selbst um das verschicken der Events.
+//		 * Dabei wird z.Zt. immer eine FeaterCollection mit nur einem
+//		 * SimpleFeature verschickt. Und zwar jenes SimpleFeature, welches am
+//		 * nächsten liegt.
+//		 */
+//
+//		// Fenster-Koordinate in Geo-Koordinate umwandelt
+//		Point2D geoCoord = xMapPane.getScreenToWorld().transform(e.getPoint(),
+//				null);
+//
+//		double radius = DEFAULT_DISTANCE_FRACTION
+//				* (xMapPane.getMapArea().getWidth() + xMapPane.getMapArea()
+//						.getHeight()) / 2;
+//
+//		PointFilterGenerator filterGenerator = new PointFilterGenerator(geoCoord, radius,
+//				xMapPane.getMapContext().getCoordinateReferenceSystem());
+//		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = xMapPane
+//				.findVisibleFeatures(filterGenerator,
+//						state, new Envelope(geoCoord.getX(), geoCoord.getX(),
+//								geoCoord.getY(), geoCoord.getY()));
+//		
+//		// Ein Event auslösen für das jeweils nächste Feature pro Layer
+//		for (Enumeration<MapLayer> element = result.keys(); element
+//				.hasMoreElements();) {
+//
+//			MapLayer layer = element.nextElement();
+//			FeatureCollection<SimpleFeatureType, SimpleFeature> fc = result
+//					.get(layer);
+//			FeatureCollection<SimpleFeatureType, SimpleFeature> fcOne;
+//
+//			if (fc != null && !fc.isEmpty()) {
+//
+//				if (fc.size() > 1) {
+//					// If the result contains more that one feature, we only
+//					// return the nearest one.
+//
+//					SimpleFeature nearestFeature = null;
+//					Double nearestDist = 0.0;
+//
+//					Iterator<SimpleFeature> fcIt = fc.iterator();
+//					try {
+//						com.vividsolutions.jts.geom.Point mousePoint = new GeometryFactory()
+//						.createPoint(new Coordinate(geoCoord.getX(), geoCoord.getY()));
+//
+//						while (fcIt.hasNext()) {
+//							SimpleFeature f = fcIt.next();
+//							Geometry obj = (Geometry) f
+//									.getDefaultGeometryProperty().getValue();
+//
+//							// TODO Hier muss doch irgendwie noch CRS
+//							// umgewrechnet werden...
+//
+//							Geometry featureGeometry = (Geometry) obj;
+//
+//							double distance = featureGeometry
+//									.distance(mousePoint);
+//
+//							if ((nearestFeature == null)
+//									|| (distance < nearestDist)) {
+//								nearestFeature = f;
+//								nearestDist = distance;
+//							}
+//
+//						}
+//
+//					} finally {
+//						fc.close(fcIt);
+//					}
+//
+//					fcOne = new MemoryFeatureCollection(fc.getSchema());
+//					fc.clear();
+//					fcOne.add(nearestFeature);
+//				} else {
+//					fcOne = fc;
+//				}
+//
+//				// Fire the event with the one selected feature
+//				xMapPane.fireMapPaneEvent(new FeatureSelectedEvent(xMapPane,
+//						layer, fcOne.getBounds(), fcOne));
+//			}
+//		}
+//		
+//		// If no vector features were found, or we are in SELECT_ALL mode, we check the raster layers now
+//		if (state == XMapPane.SELECT_ALL || result.isEmpty()) {
+//			xMapPane.findGridCoverageValuesAndFireEvents(geoCoord, state);			
+//		}
+//
+//		xMapPane.updateCursor();
+//
 //	}
-
-	/**
-	 * Stores beginning of a drag event in window coordinates
-	 */
-	protected Point startPos;
 //
 //	/**
-//	 * Stores last position of a drag event in window coordinates
+//	 * Verarbeitet die Mausrad-Aktion, indem gezoomed wird.
+//	 * 
+//	 * @param wheelEvt
+//	 *            Mausrad-Event
 //	 */
-//	protected Point lastPos;
-
-	public void mouseReleased(final MouseEvent event) {
-		if (!isEnabled())
-			return;
-
-//		if (xMapPane.getState() == XMapPane.PAN
-//				|| event.getButton() == MouseEvent.BUTTON3) {
-//			xMapPane.performPan();
-//		} else 
-//			
-			if (xMapPane.getState() == XMapPane.SELECT_ALL
-				|| xMapPane.getState() == XMapPane.SELECT_TOP
-				) {
-			
-			Point mp = event.getPoint();
-
-			// Ist es eine wirkliche Selektion, oder etwas nur ein Klick?
-			if (startPos.x != mp.x && startPos.y != mp.y) {
-				xMapPane.drawRectangle(xMapPane.getGraphics(), startPos, event
-						.getPoint());
-			}
-
-			// SELECTION!
-			xMapPane.performSelectionEvent(startPos.x, startPos.y, mp.x, mp.y);
-		}
-
-	}
-//
-//	public void mousePressed(final MouseEvent e) {
+//	@Override
+//	public void mouseWheelMoved(MouseWheelEvent wheelEvt) {
 //		if (!isEnabled())
 //			return;
-//		startPos = new Point(e.getPoint());
-//		lastPos = new Point(e.getPoint());
+//
+//		final int units = wheelEvt.getUnitsToScroll();
+//		if (units > 0)
+//			xMapPane.zoomTo(wheelEvt.getPoint(), 1. + .11 * units);
+//		else
+//			xMapPane.zoomTo(wheelEvt.getPoint(), 2. / -units);
 //	}
-
-	public SelectXMapPaneMouseListener(SelectableXMapPane xMapPane) {
-		this.xMapPane = xMapPane;
-	}
-
-	public void setEnabled(boolean enabled) {
-		this.enabled = enabled;
-	}
-
-
-}
+////
+////	@Override
+////	public void mouseDragged(final MouseEvent event) {
+////		if (!isEnabled())
+////			return;
+////
+////		xMapPane.mouseDragged(startPos, lastPos, event);
+////
+////		lastPos = event.getPoint();
+////	}
+//
+//	/**
+//	 * Stores beginning of a drag event in window coordinates
+//	 */
+//	protected Point startPos;
+////
+////	/**
+////	 * Stores last position of a drag event in window coordinates
+////	 */
+////	protected Point lastPos;
+////
+////	public void mouseReleased(final MouseEvent event) {
+////		if (!isEnabled())
+////			return;
+////
+//////		if (xMapPane.getState() == XMapPane.PAN
+//////				|| event.getButton() == MouseEvent.BUTTON3) {
+//////			xMapPane.performPan();
+//////		} else 
+//////			
+////			if (xMapPane.getState() == XMapPane.SELECT_ALL
+////				|| xMapPane.getState() == XMapPane.SELECT_TOP
+////				) {
+////			
+////			Point mp = event.getPoint();
+////
+////			// Ist es eine wirkliche Selektion, oder etwas nur ein Klick?
+////			if (startPos.x != mp.x && startPos.y != mp.y) {
+////				xMapPane.drawRectangle(xMapPane.getGraphics(), startPos, event
+////						.getPoint());
+////			}
+////
+////			// SELECTION!
+////			xMapPane.performSelectionEvent(startPos.x, startPos.y, mp.x, mp.y);
+////		}
+//
+////	}
+////
+////	public void mousePressed(final MouseEvent e) {
+////		if (!isEnabled())
+////			return;
+////		startPos = new Point(e.getPoint());
+////		lastPos = new Point(e.getPoint());
+////	}
+//
+//	public SelectXMapPaneMouseListener(SelectableXMapPane xMapPane) {
+//		this.xMapPane = xMapPane;
+//	}
+//
+//	public void setEnabled(boolean enabled) {
+//		this.enabled = enabled;
+//	}
+//
+//
+//}

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -301,7 +301,6 @@
 			final MapLayer layer = event.getLayer();
 			layer.addMapLayerListener(bgMapLayerListener);
 			requestStartRendering();
-
 		}
 
 		@Override
@@ -640,7 +639,7 @@
 				XMapPaneAction.ZOOM_IN);
 
 		xMapPaneMouseListener.actions.put(MouseInputType.RClick,
-				XMapPaneAction.ZOOM_OUT);
+				XMapPaneAction.SELECT_ALL);
 
 		xMapPaneMouseListener.actions.put(MouseInputType.RDrag,
 				XMapPaneAction.PAN);
@@ -1387,9 +1386,6 @@
 	 */
 	public void pan(final int dX, final int dY) {
 
-		// if ((getState() == XMapPane.PAN)
-		// || ((event.getModifiersEx() & InputEvent.BUTTON3_DOWN_MASK) != 0)) {
-
 		// Panning needs a panning coursor
 		if (getCursor() != SwingUtil.PANNING_CURSOR) {
 			setCursor(SwingUtil.PANNING_CURSOR);
@@ -1954,6 +1950,7 @@
 
 	// /** Stored the time used for the last real rendering in ms. **/
 	private long lastRenderingDuration = 1000;
+	private XMapPaneTool tool = XMapPaneTool.INFO;
 
 	/**
 	 * Set the minimum (nearest) allowed zoom scale. This is the bigger number
@@ -2007,6 +2004,12 @@
 	public void configureMouse(MouseInputType type, XMapPaneAction action) {
 		xMapPaneMouseListener.actions.put(type, action);
 	}
+	
+	public void setTool(XMapPaneTool tool) {
+		this.tool = tool;
+		xMapPaneMouseListener.configure(tool);
+		setCursor(tool.cursor);
+	}
 
 	/**
 	 * Standardmaessig wird der Cursor automatisch je nach MapPane-Aktion (Zoom,
@@ -2164,38 +2167,42 @@
 				repaint();
 			}
 		}
-
+		
+//
 		// wenn manueller Cursor gesetzt ist, dann diesen verwenden (unabhaengig
 		// von der aktuellen Aktion
 		if (this.staticCursor != null) {
 			setCursor(staticCursor);
 			return;
 		}
+		
 		if (getCursor() == SwingUtil.PANNING_CURSOR) {
 			// This cursor will reset itself
 			return;
 		}
-
-		// Set the cursor depending on what tool is in use...
-		switch (state) {
-		case SELECT_TOP:
-		case SELECT_ONE_FROM_TOP:
-		case SELECT_ALL:
-			setCursor(SwingUtil.CROSSHAIR_CURSOR);
-			break;
-		case ZOOM_IN:
-			setCursor(SwingUtil.ZOOMIN_CURSOR);
-			break;
-		case ZOOM_OUT:
-			setCursor(SwingUtil.ZOOMOUT_CURSOR);
-			break;
-		case PAN:
-			setCursor(SwingUtil.PAN_CURSOR);
-			break;
-		default:
-			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
-			break;
-		}
+		
+		setCursor(tool.cursor);
+//
+//		// Set the cursor depending on what tool is in use...
+//		switch (state) {
+//		case SELECT_TOP:
+//		case SELECT_ONE_FROM_TOP:
+//		case SELECT_ALL:
+//			setCursor(SwingUtil.CROSSHAIR_CURSOR);
+//			break;
+//		case ZOOM_IN:
+//			setCursor(SwingUtil.ZOOMIN_CURSOR);
+//			break;
+//		case ZOOM_OUT:
+//			setCursor(SwingUtil.ZOOMOUT_CURSOR);
+//			break;
+//		case PAN:
+//			setCursor(SwingUtil.PAN_CURSOR);
+//			break;
+//		default:
+//			setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+//			break;
+//		}
 	}
 
 	/**

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -29,7 +29,6 @@
  ******************************************************************************/
 package skrueger.geotools;
 
-import java.awt.Cursor;
 import java.awt.Point;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
@@ -63,9 +62,24 @@
 	 * This action can be assigned to any {@link MouseInputType} to perform
 	 * panning on a Map
 	 **/
-	public static XMapPaneAction_Pan PAN = new XMapPaneAction_Pan();	
+	public static XMapPaneAction_Pan PAN = new XMapPaneAction_Pan();
+	
+	/**
+	 * This action can be assigned to fire events for any number of feature from all layers.
+	 **/
+	public static XMapPaneAction_Select.All SELECT_ALL = new XMapPaneAction_Select.All();	
 
 	/**
+	 * This action can be assigned to fire selection events for one feature from the top layer.
+	 **/
+	public static XMapPaneAction_Select.OneFromTop SELECT_ONE_FROM_TOP = new XMapPaneAction_Select.OneFromTop();	
+
+	/**
+	 * This action can be assigned to fire events for any number of feature from the top layer. 
+	 **/
+	public static XMapPaneAction_Select.Top SELECT_TOP = new XMapPaneAction_Select.Top();	
+	
+	/**
 	 * Defines the action in case of a single click on the map. Called by ###
 	 * XMapPaneMouseAdapter ### on {@link MouseInputType#LClick} and
 	 * {@link MouseInputType#RClick}.
@@ -134,4 +148,15 @@
 	public void performWheel(XMapPane mapPane, MouseWheelEvent ev,
 			DirectPosition coord);
 
+	/**
+	 * Defines what happens if this action has been triggered by a keyboard-key.
+	 * 
+	 * @param mapPane
+	 *            map pane the action should be performed on
+	 *            
+	 * @param param
+	 *            An optinal paramter that can be defined.            
+	 */
+	public void performKeyboard(XMapPane mapPane, Object param);
+
 }

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Pan.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Pan.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Pan.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -42,34 +42,48 @@
 import com.vividsolutions.jts.geom.Envelope;
 
 public class XMapPaneAction_Pan implements XMapPaneAction {
-	
+
+	public static enum Direction {
+		UP, DOWN, RIGHT, LEFT
+	}
+
 	/**
+	 * If this action is triggered by keyboard, defines the amount of panning in
+	 * screen pixels
+	 **/
+	private static final int KEYBOARD_PAN_LENGTH = 15;
+
+	/**
 	 * This variable can be used to backup the active cursor of the mapPane, if
 	 * the actions changes the cursor during dragging
 	 */
 	public Cursor backupCursor = null;
-	
+
 	/**
-	 * Performs a pan action. During panning, the displacement is
-	 * stored in {@link #imageOrigin} object. Calling {@link #performPan()} will
-	 * reset the offset and call {@link #setMapArea(Envelope)}.
+	 * Performs a pan action. During panning, the displacement is stored in
+	 * {@link #imageOrigin} object. Calling {@link #performPan()} will reset the
+	 * offset and call {@link #setMapArea(Envelope)}.
 	 */
 	@Override
 	public void performDragged(XMapPane mapPane, MouseEvent ev,
 			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
 			DirectPosition endCoord) {
 
-		final Rectangle winBounds = mapPane.getVisibleRect();
+		Point translation = mapPane.getImageOrigin();
 
-		Point imageOrigin = mapPane.getImageOrigin();
+		doPan(mapPane, translation);
+	}
 
-		winBounds.translate(-imageOrigin.x, -imageOrigin.y);
+	private void doPan(XMapPane mapPane, Point translation) {
+
+		final Rectangle winBounds = mapPane.getVisibleRect();
+		winBounds.translate(-translation.x, -translation.y);
 		final Envelope newMapArea = mapPane.tranformWindowToGeo(winBounds.x,
 				winBounds.y, winBounds.x + winBounds.width, winBounds.y
 						+ winBounds.height);
 
-		imageOrigin.x = 0;
-		imageOrigin.y = 0;
+		translation.x = 0;
+		translation.y = 0;
 
 		if (!mapPane.setMapArea(newMapArea)) {
 			/**
@@ -99,6 +113,7 @@
 			mapPane.setCursor(SwingUtil.PANNING_CURSOR);
 		}
 
+		// Variables for the translation in screen pixels
 		int dX;
 		int dY;
 
@@ -119,11 +134,42 @@
 	public void performWheel(XMapPane mapPane, MouseWheelEvent ev,
 			DirectPosition coord) {
 	}
-	
+
 	@Override
 	public void performClick(XMapPane mapPane, MouseEvent ev,
 			DirectPosition coord) {
 	}
 
+	@Override
+	public void performKeyboard(XMapPane mapPane, Object param) {
+		if (param == null)
+			return;
 
+		if (!(param instanceof Direction)) {
+			throw new IllegalArgumentException("param = " + param
+					+ " is of expected type XMapPaneAction_Pan.Direction");
+		}
+
+		// Variables for the translation in screen pixels
+		int dX = 0;
+		int dY = 0;
+
+		switch ((Direction) param) {
+		case DOWN:
+			dY = KEYBOARD_PAN_LENGTH;
+			break;
+		case UP:
+			dY = -KEYBOARD_PAN_LENGTH;
+			break;
+		case LEFT:
+			dX = -KEYBOARD_PAN_LENGTH;
+			break;
+		case RIGHT:
+			dX = KEYBOARD_PAN_LENGTH;
+			break;
+		}
+
+		doPan(mapPane, new Point(dX, dY));
+	}
+
 }

Added: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -0,0 +1,215 @@
+package skrueger.geotools;
+
+import java.awt.Color;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.geom.Point2D;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.geotools.data.memory.MemoryFeatureCollection;
+import org.geotools.feature.FeatureCollection;
+import org.geotools.map.MapLayer;
+import org.opengis.feature.simple.SimpleFeature;
+import org.opengis.feature.simple.SimpleFeatureType;
+import org.opengis.geometry.DirectPosition;
+
+import schmitzm.geotools.gui.SelectableXMapPane;
+import schmitzm.geotools.map.event.FeatureSelectedEvent;
+import skrueger.geotools.GeomFilterGenerator.PointFilterGenerator;
+
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+import com.vividsolutions.jts.geom.Geometry;
+import com.vividsolutions.jts.geom.GeometryFactory;
+
+public abstract class XMapPaneAction_Select implements XMapPaneAction {
+	//	
+	// /**
+	// * Flag fuer Modus "SimpleFeature-Auswahl auf allen (sichtbaren) Layern".
+	// *
+	// * @see #setState(int)
+	// * @see #setState(int)
+	// */
+	// public static enum SelMode {
+	// SELECT_ALL
+	// }
+
+	public void performClick(XMapPane xMapPane, MouseEvent ev,
+			DirectPosition geoCoord) {
+
+		SelectableXMapPane sexMapPane = (SelectableXMapPane) xMapPane;
+
+		// calculate a circle radius around the mouse position
+		double radius = DEFAULT_DISTANCE_FRACTION
+				* (xMapPane.getMapArea().getWidth() + xMapPane.getMapArea()
+						.getHeight()) / 2;
+
+		// Fenster-Koordinate in Geo-Koordinate umwandelt
+		Point2D geoPoint = xMapPane.getScreenToWorld().transform(ev.getPoint(),
+				null);
+
+		PointFilterGenerator filterGenerator = new PointFilterGenerator(
+				geoCoord, radius);
+		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = sexMapPane
+				.findVisibleFeatures(filterGenerator, selectionMode,
+						new Envelope(geoPoint.getX(), geoPoint.getX(), geoPoint
+								.getY(), geoPoint.getY()));
+
+		// Ein Event auslösen für das jeweils nächste Feature pro Layer
+		for (Enumeration<MapLayer> element = result.keys(); element
+				.hasMoreElements();) {
+
+			MapLayer layer = element.nextElement();
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fc = result
+					.get(layer);
+			FeatureCollection<SimpleFeatureType, SimpleFeature> fcOne;
+
+			if (fc != null && !fc.isEmpty()) {
+
+				if (fc.size() > 1) {
+					// If the result contains more that one feature, we only
+					// return the nearest one.
+
+					SimpleFeature nearestFeature = null;
+					Double nearestDist = 0.0;
+
+					Iterator<SimpleFeature> fcIt = fc.iterator();
+					try {
+						com.vividsolutions.jts.geom.Point mousePoint = new GeometryFactory()
+								.createPoint(new Coordinate(geoPoint.getX(),
+										geoPoint.getY()));
+
+						while (fcIt.hasNext()) {
+							SimpleFeature f = fcIt.next();
+							Geometry obj = (Geometry) f
+									.getDefaultGeometryProperty().getValue();
+
+							// TODO Hier muss doch irgendwie noch CRS
+							// umgewrechnet werden...
+
+							Geometry featureGeometry = (Geometry) obj;
+
+							double distance = featureGeometry
+									.distance(mousePoint);
+
+							if ((nearestFeature == null)
+									|| (distance < nearestDist)) {
+								nearestFeature = f;
+								nearestDist = distance;
+							}
+
+						}
+
+					} finally {
+						fc.close(fcIt);
+					}
+
+					fcOne = new MemoryFeatureCollection(fc.getSchema());
+					fc.clear();
+					fcOne.add(nearestFeature);
+				} else {
+					fcOne = fc;
+				}
+
+				// Fire the event with the one selected feature
+				sexMapPane.fireMapPaneEvent(new FeatureSelectedEvent(
+						sexMapPane, layer, fcOne.getBounds(), fcOne));
+			}
+		}
+
+		// If no vector features were found, or we are in SELECT_ALL mode, we
+		// check the raster layers now
+		if (selectionMode == XMapPane.SELECT_ALL || result.isEmpty()) {
+			sexMapPane.findGridCoverageValuesAndFireEvents(geoPoint,
+					selectionMode);
+		}
+	}
+
+	/**
+	 * Does nothing if initiated by keyboard.
+	 * 
+	 * TODO select all features should be assignable to Strg-A
+	 */
+	@Override
+	public void performKeyboard(XMapPane mapPane, Object param) {
+	}
+
+	/**
+	 * Default distance fraction used with line and point features. When the
+	 * user clicks on the map, this tool searches for features within a
+	 * rectangle of width w centered on the mouse location, where w is the
+	 * average map side length multiplied by the value of this constant.
+	 */
+	public static final double DEFAULT_DISTANCE_FRACTION = 0.01d;
+
+	private static int selectionMode;
+
+	// @Override
+	// public void performClick(XMapPane xMapPane, MouseEvent ev,
+	// DirectPosition geoCoord) {
+	//			
+	// performSelectionClick(xMapPane, ev, geoCoord, XMapPane.SELECT_ALL);
+	// }
+
+	@Override
+	public void performDragged(XMapPane mapPane, MouseEvent ev,
+			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
+			DirectPosition endCoord) {
+
+		SelectableXMapPane sexMapPane = (SelectableXMapPane) mapPane;
+
+		Point mp = ev.getPoint();
+
+		// Ist es eine wirkliche Selektion, oder etwas nur ein Klick?
+		if (dragStartPos.x != mp.x && dragStartPos.y != mp.y) {
+			sexMapPane.drawRectangle(sexMapPane.getGraphics(), dragStartPos, ev
+					.getPoint(), Color.YELLOW);
+		}
+
+		// SELECTION!
+		sexMapPane.performSelectionEvent(dragStartPos.x, dragStartPos.y, mp.x,
+				mp.y, selectionMode);
+	}
+
+	@Override
+	public void performDragging(XMapPane mapPane, MouseEvent ev,
+			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
+			DirectPosition endCoord) {
+		if (dragLastPos != null)
+			mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos,
+					dragLastPos);
+
+		mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, ev
+				.getPoint(), Color.YELLOW);
+	}
+
+	@Override
+	public void performWheel(XMapPane mapPane, MouseWheelEvent ev,
+			DirectPosition coord) {
+	}
+
+	public static class All extends XMapPaneAction_Select {
+
+		public All() {
+			selectionMode = XMapPane.SELECT_ALL;
+		}
+	}
+
+	public static class OneFromTop extends XMapPaneAction_Select {
+
+		public OneFromTop() {
+			selectionMode = XMapPane.SELECT_ONE_FROM_TOP;
+		}
+	}
+
+	public static class Top extends XMapPaneAction_Select {
+
+		public Top() {
+			selectionMode = XMapPane.SELECT_TOP;
+		}
+	}
+
+}


Property changes on: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -112,11 +112,29 @@
 			mapPane.setMapArea(new Envelope(ll, ur));
 
 		}
+		
+		/**
+		 * @param param is ignored
+		 */
+		@Override
+		public void performKeyboard(XMapPane mapPane, Object param) {
+			// TODO Zoom IN and keep the center
+		}
+
 	}
 
 	public static class Out extends XMapPaneAction_Zoom {
+		
 
+		/**
+		 * @param param is ignored
+		 */
 		@Override
+		public void performKeyboard(XMapPane mapPane, Object param) {
+			// TODO Zoom OUT and keep the center
+		}
+
+		@Override
 		public void performClick(XMapPane mapPane, MouseEvent ev,
 				DirectPosition coord) {
 

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -1,5 +1,9 @@
 package skrueger.geotools;
 
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyEvent;
+import java.awt.event.KeyListener;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
 import java.awt.geom.AffineTransform;
@@ -7,6 +11,9 @@
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.swing.JComponent;
+import javax.swing.KeyStroke;
+
 import org.geotools.geometry.DirectPosition2D;
 
 import schmitzm.swing.event.MouseInputType;
@@ -31,6 +38,29 @@
 		this.xMapPane = xMapPane;
 	}
 
+	/**
+	 * Configures the instance with definitions from a {@link XMapPaneTool}
+	 */
+	public void configure(final XMapPaneTool tool) {
+		actions = tool.mouseActions;
+
+		// TODO Remove any KEYSrokes registered previously
+
+		// Adding configured keyboard actions
+		for (final KeyStroke stroke : tool.keyAction.keySet()) {
+			if (xMapPane.getRootPane() == null) continue;
+			xMapPane.getRootPane().registerKeyboardAction(new ActionListener() {
+
+				public void actionPerformed(final ActionEvent e) {
+					XMapPaneAction action = tool.keyAction.get(stroke);
+					action.performKeyboard(xMapPane, tool.keyActionParams
+							.get(stroke));
+				}
+
+			}, stroke, JComponent.WHEN_IN_FOCUSED_WINDOW);
+		}
+	}
+
 	@Override
 	public void performMouseClicked(MouseEvent mEv) {
 
@@ -92,8 +122,8 @@
 
 		/** Call the XMapPaneAction */
 		if (startCoord != null && endCoord != null)
-			action.performDragging(xMapPane, mEv, dragStartPos, dragLastPos, startCoord,
-					endCoord);
+			action.performDragging(xMapPane, mEv, dragStartPos, dragLastPos,
+					startCoord, endCoord);
 	}
 
 	@Override
@@ -114,7 +144,7 @@
 
 	public void performMouseReleased(MouseEvent mEv) {
 
-		if (mEv.getPoint().equals(dragStartPos)){
+		if (mEv.getPoint().equals(dragStartPos)) {
 			performMouseClicked(mEv);
 			return;
 		}
@@ -143,8 +173,8 @@
 		if (endCoord == null)
 			return;
 
-		action.performDragged(xMapPane, mEv, dragStartPos, dragLastPos, getDragStartCoord(),
-				endCoord);
+		action.performDragged(xMapPane, mEv, dragStartPos, dragLastPos,
+				getDragStartCoord(), endCoord);
 	}
 
 	/**

Added: branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -0,0 +1,186 @@
+package skrueger.geotools;
+
+import java.awt.Cursor;
+import java.awt.event.KeyEvent;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.swing.Icon;
+import javax.swing.ImageIcon;
+import javax.swing.KeyStroke;
+
+import com.sun.org.apache.bcel.internal.generic.NEW;
+
+import schmitzm.lang.LangUtil;
+import schmitzm.lang.ResourceProvider;
+import schmitzm.swing.SwingUtil;
+import schmitzm.swing.event.MouseInputType;
+
+/**
+ * This class combines the mapping of mouse-inputs and keyboard inputs to
+ * {@link XMapPaneAction}s and provides a tool icon and a default mouse cursor.
+ */
+public class XMapPaneTool {
+
+
+	public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
+			.extendPackagePath(MapPaneToolBar.class,
+					"resource.locales.mapPaneToolbar"), Locale.ENGLISH);
+
+	public static String R(String key, Object... values) {
+		return RESOURCE.getString(key, values);
+	}
+
+	/** The cursor of the mouse if the tool is active **/
+	Cursor cursor = null;
+
+	/** A tool-tip for the tool , optinal **/
+	String toolTip = null;
+
+	/** The icon for the button **/
+	Icon icon = null;
+
+	/**
+	 * Defines which {@link XMapPaneAction} should be should be called when a
+	 * {@link MouseInputType} is triggered
+	 **/
+	Map<MouseInputType, XMapPaneAction> mouseActions = new HashMap<MouseInputType, XMapPaneAction>();
+
+	/**
+	 * Defines which {@link XMapPaneAction#performKeyboard(XMapPane, Object)}
+	 * should be called when a {@link KeyStroke} is triggered
+	 **/
+	Map<KeyStroke, XMapPaneAction> keyAction = new HashMap<KeyStroke, XMapPaneAction>();
+
+	/**
+	 * Defines which optional parameter should be passed to
+	 * {@link XMapPaneAction#performKeyboard(XMapPane, Object)} if a
+	 * {@link KeyStroke} is triggered
+	 **/
+	Map<KeyStroke, Object> keyActionParams = new HashMap<KeyStroke, Object>();
+
+	/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
+	public static XMapPaneTool ZOOM_IN = new XMapPaneTool();
+	static {
+		ZOOM_IN.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/zoom_in.png"));
+		ZOOM_IN.toolTip = R("MapPaneButtons.ZoomIn.TT");
+		ZOOM_IN.cursor = SwingUtil.ZOOMIN_CURSOR;
+
+		// Left mouse click & drag zoom in
+		ZOOM_IN.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_IN.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// Right mouse click & drag zoom out
+		ZOOM_IN.mouseActions.put(MouseInputType.RClick,
+				XMapPaneAction_Zoom.ZOOM_OUT);
+		ZOOM_IN.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction_Zoom.ZOOM_OUT);
+
+		// Mousewheel can zoom too
+		ZOOM_IN.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// + and - keys zoom too
+		ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
+				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_IN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
+				XMapPaneAction_Zoom.ZOOM_OUT);
+	}
+
+	/** The configuration of the default ZOOM IN {@link XMapPaneTool} **/
+	public static XMapPaneTool ZOOM_OUT = new XMapPaneTool();
+	static {
+		ZOOM_OUT.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/zoom_out.png"));
+		ZOOM_OUT.toolTip = R("MapPaneButtons.ZoomOut.TT");
+		ZOOM_OUT.cursor = SwingUtil.ZOOMOUT_CURSOR;
+
+		// Left mouse click & drag zoom in
+		ZOOM_OUT.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction_Zoom.ZOOM_OUT);
+		ZOOM_OUT.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction_Zoom.ZOOM_OUT);
+
+		// Right mouse click & drag zoom out
+		ZOOM_OUT.mouseActions.put(MouseInputType.RClick,
+				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_OUT.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// Mousewheel can zoom
+		ZOOM_OUT.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// + and - keys zoom
+		ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
+				XMapPaneAction_Zoom.ZOOM_IN);
+		ZOOM_OUT.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
+				XMapPaneAction_Zoom.ZOOM_OUT);
+	}
+	
+	/** The configuration of the PAN {@link XMapPaneTool} **/
+	public static final XMapPaneTool PAN = new XMapPaneTool();
+	static {
+		PAN.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/pan.png"));
+		PAN.toolTip = R("MapPaneButtons.Pan.TT");
+		PAN.cursor = SwingUtil.PAN_CURSOR;
+
+		// Left mouse click & drag zoom in
+		PAN.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.PAN);
+		PAN.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.PAN);
+
+		// Right mouse click & drag zoom out
+		PAN.mouseActions.put(MouseInputType.RClick,
+				XMapPaneAction.PAN);
+		PAN.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		PAN.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// + and - keys zoom
+		PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
+				XMapPaneAction_Zoom.ZOOM_IN);
+		PAN.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
+				XMapPaneAction_Zoom.ZOOM_OUT);
+	}
+	
+
+	/** The configuration of the INFO {@link XMapPaneTool} **/
+	public static final XMapPaneTool INFO = new XMapPaneTool();
+	static {
+		INFO.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/info.png"));
+		INFO.toolTip = R("MapPaneButtons.Info.TT");
+		INFO.cursor = SwingUtil.INFO_CURSOR;
+
+		// Left mouse click & drag zoom in
+		INFO.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ONE_FROM_TOP);
+//		INFO.mouseActions.put(MouseInputType.LDrag,
+//				XMapPaneAction.SELECT_ONE_FROM_TOP);
+
+		INFO.mouseActions.put(MouseInputType.RDrag,
+				XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		INFO.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// + and - keys zoom
+		INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
+				XMapPaneAction_Zoom.ZOOM_IN);
+		INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
+				XMapPaneAction_Zoom.ZOOM_OUT);
+		
+	}
+
+}


Property changes on: branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native

Added: branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java	2010-02-01 15:04:52 UTC (rev 652)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java	2010-02-01 15:09:18 UTC (rev 653)
@@ -0,0 +1,7 @@
+package skrueger.geotools;
+
+import javax.swing.JToolBar;
+
+public class XMapPaneToolBar extends JToolBar {
+
+}


Property changes on: branches/2.0-RC2/src/skrueger/geotools/XMapPaneToolBar.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain
Name: svn:keywords
   + Id URL
Name: svn:eol-style
   + native



More information about the Schmitzm-commits mailing list