Changeset 9421 in osm for applications
- Timestamp:
- 2008-08-01T17:21:11+02:00 (16 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
r9095 r9421 42 42 int diffx = lastDragPoint.x - p.x; 43 43 int diffy = lastDragPoint.y - p.y; 44 map.move (diffx, diffy);44 map.moveMap(diffx, diffy); 45 45 } 46 46 lastDragPoint = e.getPoint(); … … 52 52 public void mouseClicked(MouseEvent e) { 53 53 if (doubleClickZoomEnabled && e.getClickCount() == 2 && e.getButton() == MouseEvent.BUTTON1) 54 map. setZoom(map.getZoom() + 1,e.getPoint());54 map.zoomIn(e.getPoint()); 55 55 } 56 56 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapController.java
r9095 r9421 3 3 //License: GPL. Copyright 2008 by Jan Peter Stotz 4 4 5 import java.awt.event.MouseAdapter; 5 6 import java.awt.event.MouseListener; 6 7 import java.awt.event.MouseMotionListener; … … 19 20 * @author Jan Peter Stotz 20 21 */ 21 public abstract class JMapController {22 public abstract class JMapController extends MouseAdapter { 22 23 23 24 JMapViewer map; … … 25 26 public JMapController(JMapViewer map) { 26 27 this.map = map; 27 if (this instanceof MouseListener) 28 map.addMouseListener((MouseListener) this); 29 if (this instanceof MouseWheelListener) 30 map.addMouseWheelListener((MouseWheelListener) this); 31 if (this instanceof MouseMotionListener) 32 map.addMouseMotionListener((MouseMotionListener) this); 28 map.addMouseListener((MouseListener) this); 29 map.addMouseWheelListener((MouseWheelListener) this); 30 map.addMouseMotionListener((MouseMotionListener) this); 33 31 } 34 32 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r9289 r9421 12 12 import java.awt.geom.Point2D; 13 13 import java.awt.image.BufferedImage; 14 import java.io.IOException;15 14 import java.io.InputStream; 16 15 import java.net.HttpURLConnection; … … 101 100 setPreferredSize(new Dimension(400, 400)); 102 101 try { 103 loadingImage = ImageIO.read(getClass().getResourceAsStream("images/hourglass.png")); 104 } catch (IOException e1) { 102 loadingImage = 103 ImageIO.read(JMapViewer.class.getResourceAsStream("images/hourglass.png")); 104 } catch (Exception e1) { 105 loadingImage = null; 105 106 } 106 107 setDisplayPositionByLatLon(50, 9, 3); … … 346 347 } 347 348 } 348 // g.drawString("Tiles in cache: " + tileCache.getTileCount(), 50, 20);349 // g.drawString("Tiles in cache: " + tileCache.getTileCount(), 50, 20); 349 350 if (!mapMarkersVisible || mapMarkerList == null) 350 351 return; … … 365 366 * vertical movement in pixel 366 367 */ 367 public void move (int x, int y) {368 public void moveMap(int x, int y) { 368 369 center.x += x; 369 370 center.y += y; … … 386 387 387 388 /** 389 * Increases the current zoom level by one 390 */ 391 public void zoomIn(Point mapPoint) { 392 setZoom(zoom + 1, mapPoint); 393 } 394 395 /** 388 396 * Decreases the current zoom level by one 389 397 */ 390 398 public void zoomOut() { 391 399 setZoom(zoom - 1); 400 } 401 402 /** 403 * Decreases the current zoom level by one 404 */ 405 public void zoomOut(Point mapPoint) { 406 setZoom(zoom - 1, mapPoint); 392 407 } 393 408 … … 436 451 return; 437 452 try { 438 // Thread.sleep(500);453 // Thread.sleep(500); 439 454 URL url; 440 455 url = new URL("http://tile.openstreetmap.org/" + tile.getKey() + ".png"); 441 456 HttpURLConnection urlConn = (HttpURLConnection) url.openConnection(); 442 457 urlConn.setReadTimeout(30000); // 30 seconds read 443 458 // timeout 444 459 input = urlConn.getInputStream(); 445 460 tile.setImage(ImageIO.read(input));
Note:
See TracChangeset
for help on using the changeset viewer.