[Schmitzm-commits] r654 - in branches/2.0-RC2/src: schmitzm/geotools/gui schmitzm/swing schmitzm/swing/resource/cursor skrueger/geotools skrueger/geotools/resource/locales

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


Author: alfonx
Date: 2010-02-01 19:13:14 +0100 (Mon, 01 Feb 2010)
New Revision: 654

Added:
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.png
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.xcf
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.png
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.xcf
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.png
   branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.xcf
Modified:
   branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java
   branches/2.0-RC2/src/schmitzm/swing/SwingUtil.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/XMapPaneAction_Zoom.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
   branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar.properties
   branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_de.properties
   branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_fr.properties
Log:
* GP-Cleanup: Moved SelectionTOol to new XMapTool concept.
* GPAV-Feature: Added keyboard stroke support to XMapPane

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:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/schmitzm/geotools/gui/SelectableXMapPane.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -427,16 +427,6 @@
 				.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);
-	// }
 
 	/**
 	 * Ermittelt die Raster-Werte, die an einem Punkt liegen und erzeugt
@@ -809,21 +799,23 @@
 	 * 
 	 * @param filterGenerator
 	 *            adapts a filter to a concrete {@link FeatureSource}
-	 * @param mode
+	 * @param selectionMode
 	 *            Suchmodus
 	 * @param env
 	 *            Bereich der durchsucht wird (fuer das Filtern irrelevant; wird
 	 *            nur fuer Events benoetigt!)
 	 */
 	public boolean findFeaturesAndFireEvents(
-			GeomFilterGenerator filterGenerator, int mode, Envelope env) {
+			GeomFilterGenerator filterGenerator, int selectionMode, Envelope env) {
 		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = findVisibleFeatures(
-				filterGenerator, mode, env);
+				filterGenerator, selectionMode, env);
 
 		// Events ausloesen fuer jedes Layer
 		for (final Enumeration<MapLayer> e = result.keys(); e.hasMoreElements();) {
 
 			final MapLayer layer = e.nextElement();
+			
+			System.out.println("cheing in "+layer.getTitle());
 
 			final FeatureCollection<SimpleFeatureType, SimpleFeature> fc = result
 					.get(layer);
@@ -841,13 +833,13 @@
 	 * 
 	 * @param env
 	 *            Bounding-Box
-	 * @param state
+	 * @param selectionMode
 	 *            Suchmodus
 	 * @return eine leere {@link Hashtable} falls die Bounding-Box {@code null}
 	 *         ist
 	 */
 	protected Hashtable<MapLayer, GridCoverage2D> findGridCoverageSubsets(
-			Envelope env, int state) {
+			Envelope env, int selectionMode) {
 		Hashtable<MapLayer, GridCoverage2D> result = new Hashtable<MapLayer, GridCoverage2D>();
 		if (env == null)
 			return result;
@@ -867,7 +859,7 @@
 			// wenn nur im obersten (sichtbaren) Layer gesucht wird.
 			// Ansonsten Nicht-Raster-Layer einfach uebergehen.
 			if (!(layerObj instanceof GridCoverage2D)) {
-				if ((state == XMapPane.SELECT_TOP || state == XMapPane.SELECT_ONE_FROM_TOP)
+				if ((selectionMode == XMapPane.SELECT_TOP || selectionMode == XMapPane.SELECT_ONE_FROM_TOP)
 						&& featureLayerIntersectsEnvelope(layer, env))
 					break;
 				continue;
@@ -887,7 +879,7 @@
 			if (subsetGrid != null)
 				result.put(layer, subsetGrid);
 			// Beim Modus "oberstes Layer selektieren" die Schleife beenden
-			if (state == SELECT_TOP || state == SELECT_ONE_FROM_TOP)
+			if (selectionMode == SELECT_TOP || selectionMode == SELECT_ONE_FROM_TOP)
 				break;
 		}
 		return result;
@@ -934,12 +926,12 @@
 	 * 
 	 * @param filterGenerator
 	 *            adapts the filter to a concrete FeatureSource
-	 * @param mode
+	 * @param selectionMode
 	 *            Suchmodus
 	 * @return eine leere {@link Hashtable} falls der Filter {@code null} ist
 	 */
 	public Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> findVisibleFeatures(
-			GeomFilterGenerator filterGenerator, int mode, Envelope env) {
+			GeomFilterGenerator filterGenerator, int selectionMode, Envelope env) {
 		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = new Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>>();
 		if (filterGenerator == null)
 			throw new IllegalArgumentException(
@@ -950,9 +942,13 @@
 		MapLayer[] layerList = context.getLayers();
 		for (int i = layerList.length - 1; i >= 0; i--) {
 			MapLayer layer = layerList[i];
-			if (!layer.isVisible())
+			System.out.println("searching in "+layer.getTitle());
+			if (!layer.isVisible()) {
+				System.out.println("   not visible!");
 				continue;
+			}
 
+			
 			// This should never happen, because the check should be performed
 			// earlier already
 			if (!isMapLayerSelectable(layer)) {
@@ -967,7 +963,7 @@
 			// im obersten (sichtbaren) Layer gesucht wird.
 			// Ansonsten Raster-Layer einfach uebergehen.
 			if (isGridCoverageLayer(layer)) {
-				if ((mode == SELECT_TOP || mode == SELECT_ONE_FROM_TOP)
+				if ((selectionMode == SELECT_TOP || selectionMode == SELECT_ONE_FROM_TOP)
 						&& layerIntersectsEnvelope(layer, env))
 					break;
 				continue;
@@ -1012,13 +1008,13 @@
 						result.put(layer, fc);
 						// Beim Modus "oberstes Layer selektieren" die Schleife
 						// beenden
-						if (mode == SELECT_TOP || mode == SELECT_ONE_FROM_TOP)
+						if (selectionMode == SELECT_TOP || selectionMode == SELECT_ONE_FROM_TOP)
 							break;
 					}
 
 				}
 			} catch (IOException err) {
-				LOGGER.error("applying the distanceWithin filter", err);
+				LOGGER.error("applying the distanceWithin filter ", err);
 			}
 		}
 		return result;

Modified: branches/2.0-RC2/src/schmitzm/swing/SwingUtil.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/swing/SwingUtil.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/schmitzm/swing/SwingUtil.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -125,6 +125,14 @@
 	/** Cursor in Form eines Zielkreuzes mit kleinem i **/
 	public static final Cursor INFO_CURSOR = createCursorFromResourcePath(
 			"resource/cursor/crosshair_i.png", 10, 10, null);
+	public static final Cursor SELECTION_ADD_CURSOR = createCursorFromResourcePath(
+			"resource/cursor/selection_add.png", 10, 10, null);
+	public static final Cursor SELECTION_SET_CURSOR = createCursorFromResourcePath(
+			"resource/cursor/selection_set.png", 10, 10, null);
+	public static final Cursor SELECTION_REMOVE_CURSOR = createCursorFromResourcePath(
+			"resource/cursor/selection_remove.png", 10, 10, null);
+	
+	
 
 	// public static final ImageIcon ICON_RASTER =
 	// createImageIconFromResourcePath("resource/icon/small/raster.png","");

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.png
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.xcf
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_add.xcf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.png
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.xcf
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_remove.xcf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.png
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.png
___________________________________________________________________
Name: svn:mime-type
   + image/png

Added: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.xcf
===================================================================
(Binary files differ)


Property changes on: branches/2.0-RC2/src/schmitzm/swing/resource/cursor/selection_set.xcf
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/MapPaneToolBar.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -461,11 +461,11 @@
 //			mapPane.setState(SelectableXMapPane.ZOOM_OUT);
 //			mapPane.setNormalCursor(SwingUtil.ZOOMOUT_CURSOR);
 			break;
-		default:
+//		default:
 			// Set map actions to default
-			mapPane.setState(SelectableXMapPane.NONE);
+//			mapPane.setState(SelectableXMapPane.NONE);
 //			mapPane.setNormalCursor(null);
-			break;
+//			break;
 		}
 //		mapPane.updateCursorAndRepaintTimer();
 	}

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -1014,7 +1014,7 @@
 	 */
 	protected void drawRectangle(final Graphics graphics, final Point startPos,
 			final Point e) {
-		drawRectangle(graphics, startPos, e, Color.WHITE);
+		drawRectangle(graphics, startPos, e, Color.WHITE, false);
 	}
 
 	/**
@@ -1022,7 +1022,7 @@
 	 * given point. All in screen coordinates.
 	 */
 	protected void drawRectangle(final Graphics graphics, final Point startPos,
-			final Point e, Color color) {
+			final Point e, Color color, boolean fill) {
 
 		if (!isWellDefined())
 			return;
@@ -1039,6 +1039,13 @@
 			return;
 
 		graphics.setXORMode(color);
+		
+		if (fill) {
+			graphics.fillRect(left, bottom, width, height);
+			graphics.setXORMode(Color.WHITE);	
+		}
+		
+		
 		graphics.drawRect(left, bottom, width, height);
 	}
 
@@ -2005,6 +2012,9 @@
 		xMapPaneMouseListener.actions.put(type, action);
 	}
 	
+	/**
+	 * Configure the tool that active on the map 
+	 */
 	public void setTool(XMapPaneTool tool) {
 		this.tool = tool;
 		xMapPaneMouseListener.configure(tool);

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Select.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -54,7 +54,7 @@
 		PointFilterGenerator filterGenerator = new PointFilterGenerator(
 				geoCoord, radius);
 		Hashtable<MapLayer, FeatureCollection<SimpleFeatureType, SimpleFeature>> result = sexMapPane
-				.findVisibleFeatures(filterGenerator, selectionMode,
+				.findVisibleFeatures(filterGenerator, getSelectionMode(),
 						new Envelope(geoPoint.getX(), geoPoint.getX(), geoPoint
 								.getY(), geoPoint.getY()));
 
@@ -122,9 +122,9 @@
 
 		// 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()) {
+		if (getSelectionMode() == XMapPane.SELECT_ALL || result.isEmpty()) {
 			sexMapPane.findGridCoverageValuesAndFireEvents(geoPoint,
-					selectionMode);
+					getSelectionMode());
 		}
 	}
 
@@ -145,8 +145,6 @@
 	 */
 	public static final double DEFAULT_DISTANCE_FRACTION = 0.01d;
 
-	private static int selectionMode;
-
 	// @Override
 	// public void performClick(XMapPane xMapPane, MouseEvent ev,
 	// DirectPosition geoCoord) {
@@ -166,24 +164,26 @@
 		// 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);
+					.getPoint(), Color.BLUE.brighter(), true);
 		}
 
 		// SELECTION!
 		sexMapPane.performSelectionEvent(dragStartPos.x, dragStartPos.y, mp.x,
-				mp.y, selectionMode);
+				mp.y, getSelectionMode());
 	}
 
+	abstract int getSelectionMode();
+
 	@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);
+					dragLastPos, Color.BLUE.brighter(), true);
 
 		mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, ev
-				.getPoint(), Color.YELLOW);
+				.getPoint(), Color.BLUE.brighter(), true);
 	}
 
 	@Override
@@ -193,22 +193,22 @@
 
 	public static class All extends XMapPaneAction_Select {
 
-		public All() {
-			selectionMode = XMapPane.SELECT_ALL;
+		int getSelectionMode() {
+			return XMapPane.SELECT_ALL;
 		}
 	}
 
 	public static class OneFromTop extends XMapPaneAction_Select {
 
-		public OneFromTop() {
-			selectionMode = XMapPane.SELECT_ONE_FROM_TOP;
+		int getSelectionMode() {
+			return XMapPane.SELECT_ONE_FROM_TOP;
 		}
 	}
 
 	public static class Top extends XMapPaneAction_Select {
 
-		public Top() {
-			selectionMode = XMapPane.SELECT_TOP;
+		int getSelectionMode() {
+			return XMapPane.SELECT_TOP;
 		}
 	}
 

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:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -8,6 +8,8 @@
 
 import org.opengis.geometry.DirectPosition;
 
+import schmitzm.geotools.JTSUtil;
+
 import com.vividsolutions.jts.geom.Coordinate;
 import com.vividsolutions.jts.geom.Envelope;
 
@@ -118,21 +120,20 @@
 		 */
 		@Override
 		public void performKeyboard(XMapPane mapPane, Object param) {
-			// TODO Zoom IN and keep the center
+			mapPane.setMapArea( JTSUtil.expandEnvelope(mapPane.getMapArea(), -.10) );
 		}
 
 	}
 
 	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
-		}
+			mapPane.setMapArea( JTSUtil.expandEnvelope(mapPane.getMapArea(), .10) );
+			}
 
 		@Override
 		public void performClick(XMapPane mapPane, MouseEvent ev,

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -48,8 +48,7 @@
 
 		// Adding configured keyboard actions
 		for (final KeyStroke stroke : tool.keyAction.keySet()) {
-			if (xMapPane.getRootPane() == null) continue;
-			xMapPane.getRootPane().registerKeyboardAction(new ActionListener() {
+			xMapPane.registerKeyboardAction(new ActionListener() {
 
 				public void actionPerformed(final ActionEvent e) {
 					XMapPaneAction action = tool.keyAction.get(stroke);

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneTool.java	2010-02-01 18:13:14 UTC (rev 654)
@@ -1,6 +1,7 @@
 package skrueger.geotools;
 
 import java.awt.Cursor;
+import java.awt.event.InputEvent;
 import java.awt.event.KeyEvent;
 import java.util.HashMap;
 import java.util.Locale;
@@ -10,8 +11,6 @@
 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;
@@ -23,6 +22,9 @@
  */
 public class XMapPaneTool {
 
+	public XMapPaneTool() {
+		addDefaultKeyboardAssignments(this);
+	}
 
 	public static ResourceProvider RESOURCE = new ResourceProvider(LangUtil
 			.extendPackagePath(MapPaneToolBar.class,
@@ -35,7 +37,7 @@
 	/** The cursor of the mouse if the tool is active **/
 	Cursor cursor = null;
 
-	/** A tool-tip for the tool , optinal **/
+	/** A tool-tip for the tool , optional **/
 	String toolTip = null;
 
 	/** The icon for the button **/
@@ -84,11 +86,6 @@
 		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} **/
@@ -115,13 +112,8 @@
 		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 {
@@ -131,31 +123,21 @@
 		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);
+		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);
+		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);
+		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"));
@@ -165,22 +147,139 @@
 		// 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.LDrag,
+		// XMapPaneAction.SELECT_ONE_FROM_TOP);
 
-		INFO.mouseActions.put(MouseInputType.RDrag,
+		INFO.mouseActions.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		INFO.mouseActions
+				.put(MouseInputType.Wheel, XMapPaneAction_Zoom.ZOOM_IN);
+
+	}
+
+	public static final XMapPaneTool SELECTION_ADD = new XMapPaneTool();
+	static {
+		SELECTION_ADD.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_add.png"));
+		SELECTION_ADD.toolTip = R("MapPaneButtons.Selection.AddSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_ADD.cursor = SwingUtil.SELECTION_ADD_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_ADD.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ALL);
+		SELECTION_ADD.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_ALL);
+
+		SELECTION_ADD.mouseActions
+				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		SELECTION_ADD.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// TODO Strg-A shoud select all
+	}
+
+	public static final XMapPaneTool SELECTION_REMOVE = new XMapPaneTool();
+	static {
+		SELECTION_REMOVE.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_remove.png"));
+		SELECTION_REMOVE.toolTip = R("MapPaneButtons.Selection.RemoveSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_REMOVE.cursor = SwingUtil.SELECTION_REMOVE_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_REMOVE.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ALL);
+		SELECTION_REMOVE.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_ALL);
+
+		SELECTION_REMOVE.mouseActions.put(MouseInputType.RDrag,
 				XMapPaneAction.PAN);
 
 		// Mousewheel can zoom
-		INFO.mouseActions.put(MouseInputType.Wheel,
+		SELECTION_REMOVE.mouseActions.put(MouseInputType.Wheel,
 				XMapPaneAction_Zoom.ZOOM_IN);
 
+		// TODO Strg-A shoud select all
+	}
+
+	public static final XMapPaneTool SELECTION_SET = new XMapPaneTool();
+	static {
+		SELECTION_SET.icon = new ImageIcon(MapView.class
+				.getResource("resource/icons/selection_set.png"));
+		SELECTION_SET.toolTip = R("MapPaneButtons.Selection.SetSelection.TT"); // TODO
+		// move
+		// to
+		// schmitzm
+
+		SELECTION_SET.cursor = SwingUtil.SELECTION_SET_CURSOR;
+
+		// Left mouse click & drag zoom in
+		SELECTION_SET.mouseActions.put(MouseInputType.LClick,
+				XMapPaneAction.SELECT_ALL);
+		SELECTION_SET.mouseActions.put(MouseInputType.LDrag,
+				XMapPaneAction.SELECT_ALL);
+
+		SELECTION_SET.mouseActions
+				.put(MouseInputType.RDrag, XMapPaneAction.PAN);
+
+		// Mousewheel can zoom
+		SELECTION_SET.mouseActions.put(MouseInputType.Wheel,
+				XMapPaneAction_Zoom.ZOOM_IN);
+
+		// TODO Strg-A shoud select all
+	}
+
+	/**
+	 * Adds default Keyboard actions to a given {@link XMapPaneTool}
+	 */
+	public static void addDefaultKeyboardAssignments(XMapPaneTool tool) {
+
 		// + and - keys zoom
-		INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
+		tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_PLUS, 0),
 				XMapPaneAction_Zoom.ZOOM_IN);
-		INFO.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
+		tool.keyAction.put(KeyStroke.getKeyStroke(KeyEvent.VK_MINUS, 0),
 				XMapPaneAction_Zoom.ZOOM_OUT);
-		
+
+		KeyStroke keyStroke;
+
+		for (int modifier : new int[] { InputEvent.ALT_DOWN_MASK,
+				InputEvent.ALT_GRAPH_DOWN_MASK, InputEvent.CTRL_DOWN_MASK,
+				InputEvent.SHIFT_DOWN_MASK, InputEvent.META_DOWN_MASK }) {
+
+			// RIGHT button pan
+			keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, modifier);
+			tool.keyAction.put(keyStroke, XMapPaneAction.PAN);
+			tool.keyActionParams.put(keyStroke,
+					XMapPaneAction_Pan.Direction.RIGHT);
+
+			// LEFT button pan
+			keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, modifier);
+			tool.keyAction.put(keyStroke, XMapPaneAction.PAN);
+			tool.keyActionParams.put(keyStroke,
+					XMapPaneAction_Pan.Direction.LEFT);
+
+			// UP button pan
+			keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_DOWN, modifier);
+			tool.keyAction.put(keyStroke, XMapPaneAction.PAN);
+			tool.keyActionParams
+					.put(keyStroke, XMapPaneAction_Pan.Direction.UP);
+
+			// DOWN button pan
+			keyStroke = KeyStroke.getKeyStroke(KeyEvent.VK_UP, modifier);
+			tool.keyAction.put(keyStroke, XMapPaneAction.PAN);
+			tool.keyActionParams.put(keyStroke,
+					XMapPaneAction_Pan.Direction.DOWN);
+		}
+
 	}
-
 }

Modified: branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar.properties
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar.properties	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar.properties	2010-02-01 18:13:14 UTC (rev 654)
@@ -59,3 +59,7 @@
 MapPaneButtons.ZoomOut.TT=Zoom away from the map
 MapPaneButtons.LastZoom.TT=Go to last map extend
 MapPaneButtons.NextZoom.TT=Go to next map extend
+
+MapPaneButtons.Selection.SetSelection.TT=Select objects to be selected
+MapPaneButtons.Selection.AddSelection.TT=Add objects to current selection
+MapPaneButtons.Selection.RemoveSelection.TT=Remove objects from current selection 

Modified: branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_de.properties
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_de.properties	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_de.properties	2010-02-01 18:13:14 UTC (rev 654)
@@ -59,3 +59,7 @@
 MapPaneButtons.ZoomOut.TT=Aus der Karte herauszoomen
 MapPaneButtons.LastZoom.TT=Letzten Kartenausschnitt wiederherstellen 
 MapPaneButtons.NextZoom.TT=N\u00e4chsten Kartenausschnitt wiederherstellen
+
+MapPaneButtons.Selection.AddSelection.TT=F\u00fcgt Objekte zur Selektion hinzu
+MapPaneButtons.Selection.RemoveSelection.TT=Entfernt Objekte aus der Selektion 
+MapPaneButtons.Selection.SetSelection.TT=Setzt die Selektion auf die ausgew\u00e4hlten Objekte

Modified: branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_fr.properties
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_fr.properties	2010-02-01 15:09:18 UTC (rev 653)
+++ branches/2.0-RC2/src/skrueger/geotools/resource/locales/mapPaneToolbar_fr.properties	2010-02-01 18:13:14 UTC (rev 654)
@@ -59,3 +59,7 @@
 MapPaneButtons.ZoomOut.TT=Effectuer un zoom d'un extrait de la carte oder faire un gros plan d'un extrait de carte.
 MapPaneButtons.LastZoom.TT=Restaurer le dernier extrait de la carte.
 MapPaneButtons.NextZoom.TT=Restaurer le prochain extrait de la carte.
+
+MapPaneButtons.Selection.SetSelection.TT=Marquer les objects \u00e0 s\u00e9lectionner
+MapPaneButtons.Selection.AddSelection.TT=Ajouter des objets \u00e0 la s\u00e9lection actuelle 
+MapPaneButtons.Selection.RemoveSelection.TT=D\u00e9placer les objects de la s\u00e9lection actuelle 



More information about the Schmitzm-commits mailing list