[Schmitzm-commits] r646 - branches/2.0-RC2/src/skrueger/geotools
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Jan 28 17:47:13 CET 2010
Author: alfonx
Date: 2010-01-28 17:47:13 +0100 (Thu, 28 Jan 2010)
New Revision: 646
Added:
branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java
Removed:
branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
Modified:
branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
Log:
Modified: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java 2010-01-28 16:38:39 UTC (rev 645)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction.java 2010-01-28 16:47:13 UTC (rev 646)
@@ -87,6 +87,6 @@
*/
public void performWheel(XMapPane mapPane, MouseWheelEvent ev, DirectPosition coord);
- public static XMapPaneAction_ZoomIn ZOOM_IN = new XMapPaneAction_ZoomIn();
+ public static XMapPaneAction_Zoom ZOOM_IN = new XMapPaneAction_Zoom.In();
}
Copied: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java (from rev 644, branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java)
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java 2010-01-28 16:28:36 UTC (rev 644)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java 2010-01-28 16:47:13 UTC (rev 646)
@@ -0,0 +1,93 @@
+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 abstract class XMapPaneAction_Zoom implements XMapPaneAction {
+
+public static class In extends XMapPaneAction_Zoom {
+
+ @Override
+ public void performClick(XMapPane mapPane, MouseEvent ev,
+ DirectPosition coord) {
+
+ mapPane.zoomTo(ev.getPoint(), 1 / 2.);
+ }
+
+ @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 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());
+ }
+
+ @Override
+ public void performDragged(XMapPane mapPane, MouseEvent ev,
+ Point dragStartPos, Point dragLastPos, DirectPosition startCoord,
+ DirectPosition endCoord) {
+
+ if (dragLastPos != null)
+ mapPane.drawRectangle(mapPane.getGraphics(), dragStartPos, dragLastPos );
+
+ // 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));
+
+ }
+
+}
+
+}
\ No newline at end of file
Property changes on: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Id URL
Name: svn:eol-style
+ native
Deleted: branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java
===================================================================
--- branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java 2010-01-28 16:38:39 UTC (rev 645)
+++ branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_ZoomIn.java 2010-01-28 16:47:13 UTC (rev 646)
@@ -1,91 +0,0 @@
-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 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 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) {
-
- 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