[Schmitzm-commits] r644 - in branches/2.0-RC2/src: schmitzm/swing/event skrueger/geotools

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 28 17:28:37 CET 2010


Author: alfonx
Date: 2010-01-28 17:28:36 +0100 (Thu, 28 Jan 2010)
New Revision: 644

Modified:
   branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
Log:


Modified: branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java
===================================================================
--- branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 16:14:34 UTC (rev 643)
+++ branches/2.0-RC2/src/schmitzm/swing/event/SelectiveMouseAdapter.java	2010-01-28 16:28:36 UTC (rev 644)
@@ -161,7 +161,7 @@
   @Override
   public final void mousePressed(MouseEvent e) {
     dragStartPos = e.getPoint();
-    dragLastPos  = e.getPoint();
+    dragLastPos  = null;
     if ( isMouseClickEnabled(e) )
       performMouseClicked(e);
   }

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-01-28 16:14:34 UTC (rev 643)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-01-28 16:28:36 UTC (rev 644)
@@ -628,6 +628,8 @@
 		this.addMouseListener(xMapPaneMouseListener);
 		this.addMouseMotionListener(xMapPaneMouseListener);
 		this.addMouseWheelListener(xMapPaneMouseListener);
+		xMapPaneMouseListener.actions.put(MouseInputType.RClick, XMapPaneAction.ZOOM_IN);
+		xMapPaneMouseListener.actions.put(MouseInputType.RDrag, XMapPaneAction.ZOOM_IN);
 
 		/*
 		 * We use a Timer object to avoid rendering delays and flickering when
@@ -1983,13 +1985,13 @@
 	public void setState(final int state) {
 		this.state = state;
 		
-		throw new RuntimeException("Old concept.. migrate to new concept!");
+//		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();
+		updateCursor();
 	}
 	
 	public void configureMouse(MouseInputType type, XMapPaneAction action){

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java	2010-01-28 16:14:34 UTC (rev 643)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java	2010-01-28 16:28:36 UTC (rev 644)
@@ -1,32 +1,25 @@
 package skrueger.geotools;
 
 import java.awt.Point;
+import java.awt.Rectangle;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
 
 import org.opengis.geometry.DirectPosition;
 
+import com.vividsolutions.jts.geom.Coordinate;
+import com.vividsolutions.jts.geom.Envelope;
+
 public class XMapPaneAction_ZoomIn implements XMapPaneAction {
-	
+
 	@Override
 	public void performClick(XMapPane mapPane, MouseEvent ev,
 			DirectPosition coord) {
-		
+
 		mapPane.zoomTo(ev.getPoint(), 1 / 2.);
 	}
 
 	@Override
-	public void performDragging(XMapPane mapPane, MouseEvent ev,
-			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
-			DirectPosition endCoord) {
-		
-		if (dragLastPos != null)
-			mapPane.drawRectangle(mapPane.getGraphics(), dragLastPos, ev.getPoint());
-		
-		mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, ev.getPoint());
-	}
-
-	@Override
 	public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,
 			DirectPosition coord) {
 
@@ -38,11 +31,61 @@
 	}
 
 	@Override
+	public void performDragging(XMapPane mapPane, MouseEvent ev,
+			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
+			DirectPosition endCoord) {
+
+		if (dragLastPos != null)
+			mapPane.drawRectangle(mapPane.getGraphics(), dragLastPos, ev
+					.getPoint());
+
+		mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, ev
+				.getPoint());
+	}
+
+	@Override
 	public void performDragged(XMapPane mapPane, MouseEvent ev,
 			Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
 			DirectPosition endCoord) {
-		// TODO Auto-generated method stub
 
+		if (dragLastPos != null)
+			mapPane.drawRectangle(mapPane.getGraphics(), dragLastPos, ev
+					.getPoint());
+
+		// If this is similar to a click, let mouseClicked handle it!
+		if ((Math.abs(dragStartPos.x - ev.getPoint().x) * Math.abs(ev
+				.getPoint().y
+				- dragStartPos.y)) < 160) {
+			// performClick(mapPane, ev, coord)
+			return;
+		}
+
+		final Rectangle bounds = mapPane.getBounds();
+
+		Envelope mapArea = mapPane.getMapArea();
+
+		// Replace with transform and translate
+		final double mapWidth = mapArea.getWidth();
+		final double mapHeight = mapArea.getHeight();
+
+		final double startX = ((dragStartPos.x * mapWidth) / (double) bounds.width)
+				+ mapArea.getMinX();
+		final double startY = (((bounds.getHeight() - dragStartPos.y) * mapHeight) / (double) bounds.height)
+				+ mapArea.getMinY();
+		final double endX = ((ev.getPoint().x * mapWidth) / (double) bounds.width)
+				+ mapArea.getMinX();
+		final double endY = (((bounds.getHeight() - ev.getPoint().y) * mapHeight) / (double) bounds.height)
+				+ mapArea.getMinY();
+
+		final double left = Math.min(startX, endX);
+		final double right = Math.max(startX, endX);
+		final double bottom = Math.min(startY, endY);
+		final double top = Math.max(startY, endY);
+		final Coordinate ll = new Coordinate(left, bottom);
+		final Coordinate ur = new Coordinate(right, top);
+
+		mapPane.setMapArea(new Envelope(ll, ur));
+
 	}
 
 }



More information about the Schmitzm-commits mailing list