Changeset 1518 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2009-03-30T16:26:45+02:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/gui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/MapMover.java
r1169 r1518 182 182 */ 183 183 public void mouseWheelMoved(MouseWheelEvent e) { 184 int w = nc.getWidth(); 185 int h = nc.getHeight(); 184 double newScale = nc.getScale() * Math.pow(0.8, - e.getWheelRotation()); 186 185 187 double zoom = Math.max(0.1, 1 + e.getWheelRotation()/5.0); 188 double zoomfactor = (zoom-1)/2+1; 189 190 double newHalfWidth = w*zoomfactor - w/2; 191 double newHalfHeight = h*zoomfactor - h/2; 192 double centerx = e.getX() - (e.getX()-w/2)*newHalfWidth*2/w; 193 double centery = e.getY() - (e.getY()-h/2)*newHalfHeight*2/h; 194 EastNorth newCenter = nc.getEastNorth((int)centerx, (int)centery); 195 196 nc.zoomTo(newCenter, nc.getScale()*zoom); 186 // New center position so that point under the mouse pointer stays the same place as it was before zooming 187 // You will get the formula by simplifying this expression: newCenter = oldCenter + mouseCoordinatesInNewZoom - mouseCoordinatesInOldZoom 188 double newX = nc.center.east() - (e.getX() - nc.getWidth()/2.0) * (newScale - nc.scale); 189 double newY = nc.center.north() + (e.getY() - nc.getHeight()/2.0) * (newScale - nc.scale); 190 191 nc.zoomTo(new EastNorth(newX, newY), newScale); 197 192 } 198 193 -
trunk/src/org/openstreetmap/josm/gui/MapView.java
r1418 r1518 89 89 @Override public void componentResized(ComponentEvent e) { 90 90 removeComponentListener(this); 91 92 MapSlider zoomSlider = new MapSlider(MapView.this); 93 add(zoomSlider); 94 zoomSlider.setBounds(3, 0, 114, 30); 95 96 MapScaler scaler = new MapScaler(MapView.this, Main.proj); 97 add(scaler); 98 scaler.setLocation(10,30); 91 99 92 100 if (!zoomToEditLayerBoundingBox()) … … 115 123 Main.contentPane.getActionMap().put("RIGHT", mv); 116 124 } 117 118 MapSlider zoomSlider = new MapSlider(MapView.this);119 add(zoomSlider);120 zoomSlider.setBounds(3, 0, 114, 30);121 122 MapScaler scaler = new MapScaler(MapView.this, Main.proj);123 add(scaler);124 scaler.setLocation(10,30);125 125 } 126 126 });
Note:
See TracChangeset
for help on using the changeset viewer.