/[schmitzm]/branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java
ViewVC logotype

Diff of /branches/2.0-RC2/src/skrueger/geotools/XMapPaneAction_Zoom.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 649 by alfonx, Thu Jan 28 17:24:15 2010 UTC revision 650 by mojays, Thu Jan 28 17:43:54 2010 UTC
# Line 4  import java.awt.Point; Line 4  import java.awt.Point;
4  import java.awt.Rectangle;  import java.awt.Rectangle;
5  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
6  import java.awt.event.MouseWheelEvent;  import java.awt.event.MouseWheelEvent;
7    import java.awt.geom.Point2D;
8    
9  import org.opengis.geometry.DirectPosition;  import org.opengis.geometry.DirectPosition;
10    
# Line 38  public abstract class XMapPaneAction_Zoo Line 39  public abstract class XMapPaneAction_Zoo
39                  public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,                  public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,
40                                  DirectPosition coord) {                                  DirectPosition coord) {
41    
42                          final int units = wheelEvt.getUnitsToScroll();                  int units = wheelEvt.getUnitsToScroll();
43                          if (units > 0)                  // Positiver Wert --> Zoom in --> Faktor < 1
44                                  mapPane.zoomTo(wheelEvt.getPoint(), 1. + .11 * units);                  // Negativer Wert --> Zoom out --> Faktir > 1
45                          else  
46                                  mapPane.zoomTo(wheelEvt.getPoint(), 2. / -units);                  // SK: 9.9.2007 zoom jetzt wie bei GoogleEarth
47                    double zFactor = units > 0 ? 1.3 : 1 / 1.3;
48                    // vorher double zFactor = units > 0 ? 1/1.2 : 1.2;
49    
50                    // Fenster-Koordinaten zu Karten-Koordinaten transformieren
51                    Point2D mapCoord = XMapPane.getMapCoordinatesFromEvent(wheelEvt);
52                    // Relative Position des Mauszeigers zum Kartenausschnitt
53                    // -> Nach Zoom soll dieselbe Kartenposition unterhalb des Mauszeigers
54                    // erscheinen, wie vor dem Zoom
55                    double relX = (mapCoord.getX() - mapPane.getMapArea().getMinX())
56                            / mapPane.getMapArea().getWidth();
57                    double relY = (mapCoord.getY() - mapPane.getMapArea().getMinY())
58                            / mapPane.getMapArea().getHeight();
59    
60                    // Neuen Karten-Ausschnitt berechnen
61                    Coordinate ll = new Coordinate(mapCoord.getX()
62                            - mapPane.getMapArea().getWidth() * relX * zFactor, mapCoord.getY()
63                            - mapPane.getMapArea().getHeight() * relY * zFactor);
64                    Coordinate ur = new Coordinate(mapCoord.getX()
65                            + mapPane.getMapArea().getWidth() * (1 - relX) * zFactor, mapCoord
66                            .getY()
67                            + mapPane.getMapArea().getHeight() * (1 - relY) * zFactor);
68                    mapPane.setMapArea(new Envelope(ll, ur));
69                  }                  }
70    
71                  @Override                  @Override
# Line 103  public abstract class XMapPaneAction_Zoo Line 126  public abstract class XMapPaneAction_Zoo
126                  @Override                  @Override
127                  public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,                  public void performWheel(XMapPane mapPane, MouseWheelEvent wheelEvt,
128                                  DirectPosition coord) {                                  DirectPosition coord) {
129              int units = wheelEvt.getUnitsToScroll();
130                          final int units = wheelEvt.getUnitsToScroll();            // Positiver Wert --> Zoom in --> Faktor < 1
131                          if (units <= 0)            // Negativer Wert --> Zoom out --> Faktir > 1
132                                  mapPane.zoomTo(wheelEvt.getPoint(), 1. + .11 * units);  
133                          else            // SK: 9.9.2007 zoom jetzt wie bei GoogleEarth
134                                  mapPane.zoomTo(wheelEvt.getPoint(), 2. / -units);            double zFactor = units > 0 ? 1.3 : 1 / 1.3;
135              // vorher double zFactor = units > 0 ? 1/1.2 : 1.2;
136    
137              // Fenster-Koordinaten zu Karten-Koordinaten transformieren
138              Point2D mapCoord = XMapPane.getMapCoordinatesFromEvent(wheelEvt);
139              // Relative Position des Mauszeigers zum Kartenausschnitt
140              // -> Nach Zoom soll dieselbe Kartenposition unterhalb des Mauszeigers
141              // erscheinen, wie vor dem Zoom
142              double relX = (mapCoord.getX() - mapPane.getMapArea().getMinX())
143                      / mapPane.getMapArea().getWidth();
144              double relY = (mapCoord.getY() - mapPane.getMapArea().getMinY())
145                      / mapPane.getMapArea().getHeight();
146    
147              // Neuen Karten-Ausschnitt berechnen
148              Coordinate ll = new Coordinate(mapCoord.getX()
149                      - mapPane.getMapArea().getWidth() * relX * zFactor, mapCoord.getY()
150                      - mapPane.getMapArea().getHeight() * relY * zFactor);
151              Coordinate ur = new Coordinate(mapCoord.getX()
152                      + mapPane.getMapArea().getWidth() * (1 - relX) * zFactor, mapCoord
153                      .getY()
154                      + mapPane.getMapArea().getHeight() * (1 - relY) * zFactor);
155              mapPane.setMapArea(new Envelope(ll, ur));
156                  }                  }
157    
158    

Legend:
Removed from v.649  
changed lines
  Added in v.650

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26