[Schmitzm-commits] r639 - branches/2.0-RC2/src/skrueger/geotools

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


Author: alfonx
Date: 2010-01-28 17:07:22 +0100 (Thu, 28 Jan 2010)
New Revision: 639

Added:
   branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
Modified:
   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/XMapPaneMouseListener.java
   branches/2.0-RC2/src/skrueger/geotools/ZoomXMapPaneMouseListener.java
Log:


Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPane.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-01-28 15:38:33 UTC (rev 638)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPane.java	2010-01-28 16:07:22 UTC (rev 639)
@@ -992,14 +992,23 @@
 
 		removeAll();
 	}
-
+	
 	/**
 	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
 	 * given point. All in screen coordinates.
 	 */
 	protected void drawRectangle(final Graphics graphics, final Point startPos,
 			final Point e) {
+		drawRectangle(graphics, startPos, e, Color.WHITE);
+	}
 
+	/**
+	 * Draws a rectangle in XOR mode from the origin at {@link #startPos} to the
+	 * given point. All in screen coordinates.
+	 */
+	protected void drawRectangle(final Graphics graphics, final Point startPos,
+			final Point e, Color color) {
+
 		if (!isWellDefined())
 			return;
 
@@ -1014,7 +1023,7 @@
 		if (width == 0 && height == 0)
 			return;
 
-		graphics.setXORMode(Color.WHITE);
+		graphics.setXORMode(color);
 		graphics.drawRect(left, bottom, width, height);
 	}
 

Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-01-28 15:38:33 UTC (rev 638)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java	2010-01-28 16:07:22 UTC (rev 639)
@@ -29,9 +29,9 @@
  ******************************************************************************/
 package skrueger.geotools;
 
+import java.awt.Point;
 import java.awt.event.MouseEvent;
 import java.awt.event.MouseWheelEvent;
-import java.awt.geom.Point2D;
 
 import org.opengis.geometry.DirectPosition;
 
@@ -64,7 +64,7 @@
    * @param startCoord   geo coordinate the drag was started
    * @param endCoord     geo coordinate the drag is currently moved over
    */
-  public void performDragging(XMapPane mapPane, MouseEvent ev, Point2D dragStartPos, DirectPosition startCoord, DirectPosition endCoord);
+  public void performDragging(XMapPane mapPane, MouseEvent ev, Point dragStartPos, DirectPosition startCoord, DirectPosition endCoord);
 
   /**
    * Defines the action in case of a window selection on the map (the moment
@@ -76,7 +76,7 @@
    * @param startCoord   geo coordinate the window starts
    * @param endCoord     geo coordinate the window ends
    */
-  public void performWindow(XMapPane mapPane, MouseEvent ev, Point2D dragStartPos, DirectPosition startCoord, DirectPosition endCoord);
+  public void performDragged(XMapPane mapPane, MouseEvent ev, Point dragStartPos, DirectPosition startCoord, DirectPosition endCoord);
 
   /**
    * Defines the action in case of a mouse wheel action on the map (the moment
@@ -86,5 +86,7 @@
    * @param coord        geo coordinate the wheel is turned on
    */
   public void performWheel(XMapPane mapPane, MouseWheelEvent ev, DirectPosition coord);
+  
+  public static XMapPaneAction_ZoomIn ZOOM_IN = new XMapPaneAction_ZoomIn();
 
 }

Added: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java	2010-01-28 15:38:33 UTC (rev 638)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java	2010-01-28 16:07:22 UTC (rev 639)
@@ -0,0 +1,53 @@
+package skrueger.geotools;
+
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Point;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseWheelEvent;
+import java.awt.geom.Point2D;
+
+import org.opengis.geometry.DirectPosition;
+
+public class XMapPaneAction_ZoomIn implements XMapPaneAction {
+	
+	/**
+	 * Stores last position of a drag event in window coordinates
+	 */
+	protected Point lastPos;
+	
+	@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, DirectPosition startCoord,
+			DirectPosition endCoord) {
+		
+		mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, ev.getPoint());
+	}
+
+	@Override
+	public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,
+			DirectPosition coord) {
+
+		final int units = wheelEvt.getUnitsToScroll();
+		if (units > 0)
+			mapPane.zoomTo(wheelEvt.getPoint(), 1. + .11 * units);
+		else
+			mapPane.zoomTo(wheelEvt.getPoint(), 2. / -units);
+	}
+
+	@Override
+	public void performDragged(XMapPane mapPane, MouseEvent ev,
+			Point dragStartPos, DirectPosition startCoord,
+			DirectPosition endCoord) {
+		// TODO Auto-generated method stub
+
+	}
+
+}


Property changes on: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.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/XMapPaneMouseListener.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-01-28 15:38:33 UTC (rev 638)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneMouseListener.java	2010-01-28 16:07:22 UTC (rev 639)
@@ -114,16 +114,18 @@
 
 	public void performMouseReleased(MouseEvent mEv) {
 
-		if (mEv.getPoint().equals(dragStartPos))
+		if (mEv.getPoint().equals(dragStartPos)){
 			performMouseClicked(mEv);
+			return;
+		}
 
 		MouseInputType key;
 		switch (mEv.getButton()) {
 		case MouseEvent.BUTTON1:
-			key = MouseInputType.LWin;
+			key = MouseInputType.LDrag;
 			break;
 		case MouseEvent.BUTTON3:
-			key = MouseInputType.RWin;
+			key = MouseInputType.RDrag;
 			break;
 		default:
 			return;
@@ -141,7 +143,7 @@
 		if (endCoord == null)
 			return;
 
-		action.performWindow(xMapPane, mEv, dragStartPos, getDragStartCoord(),
+		action.performDragged(xMapPane, mEv, dragStartPos, getDragStartCoord(),
 				endCoord);
 	}
 

Modified: branches/2.0-RC2/src/skrueger/geotools/ZoomXMapPaneMouseListener.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/ZoomXMapPaneMouseListener.java	2010-01-28 15:38:33 UTC (rev 638)
+++ branches/2.0-RC2/src/skrueger/geotools/ZoomXMapPaneMouseListener.java	2010-01-28 16:07:22 UTC (rev 639)
@@ -174,6 +174,8 @@
 	public void mouseWheelMoved(MouseWheelEvent wheelEvt) {
 		if (!isEnabled())
 			return;
+		
+		//DONE
 
 		final int units = wheelEvt.getUnitsToScroll();
 		if (units > 0)
@@ -185,6 +187,8 @@
 	@Override
 	public void mouseClicked(final MouseEvent e) {
 
+		// DONE
+		
 		if (!isEnabled())
 			return;
 



More information about the Schmitzm-commits mailing list