Changeset 9619 in osm for applications/viewer/jmapviewer/src/org/openstreetmap
- Timestamp:
- 2008-08-10T18:06:29+02:00 (16 years ago)
- Location:
- applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
r9494 r9619 43 43 * Vectors for clock-wise tile painting 44 44 */ 45 protected static final Point[] move = 46 { new Point(1, 0), new Point(0, 1),new Point(-1, 0), new Point(0, -1) };45 protected static final Point[] move = { new Point(1, 0), new Point(0, 1), 46 new Point(-1, 0), new Point(0, -1) }; 47 47 48 48 public static final int MAX_ZOOM = 18; … … 102 102 setPreferredSize(new Dimension(400, 400)); 103 103 try { 104 loadingImage = 105 ImageIO.read(JMapViewer.class.getResourceAsStream("images/hourglass.png"));104 loadingImage = ImageIO.read(JMapViewer.class 105 .getResourceAsStream("images/hourglass.png")); 106 106 } catch (Exception e1) { 107 107 loadingImage = null; … … 123 123 int size = 18; 124 124 try { 125 ImageIcon icon = new ImageIcon(getClass().getResource("images/plus.png")); 125 ImageIcon icon = new ImageIcon(getClass().getResource( 126 "images/plus.png")); 126 127 zoomInButton = new JButton(icon); 127 128 } catch (Exception e) { … … 139 140 add(zoomInButton); 140 141 try { 141 ImageIcon icon = new ImageIcon(getClass().getResource("images/minus.png")); 142 ImageIcon icon = new ImageIcon(getClass().getResource( 143 "images/minus.png")); 142 144 zoomOutButton = new JButton(icon); 143 145 } catch (Exception e) { … … 168 170 */ 169 171 public void setDisplayPositionByLatLon(double lat, double lon, int zoom) { 170 setDisplayPositionByLatLon(new Point(getWidth() / 2, getHeight() / 2), lat, lon, zoom); 172 setDisplayPositionByLatLon(new Point(getWidth() / 2, getHeight() / 2), 173 lat, lon, zoom); 171 174 } 172 175 … … 186 189 * {@link #MIN_ZOOM} <= zoom level <= {@link #MAX_ZOOM} 187 190 */ 188 public void setDisplayPositionByLatLon(Point mapPoint, double lat, double lon, int zoom) { 191 public void setDisplayPositionByLatLon(Point mapPoint, double lat, 192 double lon, int zoom) { 189 193 int x = OsmMercator.LonToX(lon, zoom); 190 194 int y = OsmMercator.LatToY(lat, zoom); … … 193 197 194 198 public void setDisplayPosition(int x, int y, int zoom) { 195 setDisplayPosition(new Point(getWidth() / 2, getHeight() / 2), x, y, zoom); 199 setDisplayPosition(new Point(getWidth() / 2, getHeight() / 2), x, y, 200 zoom); 196 201 } 197 202 … … 329 334 x++; 330 335 for (int z = 0; z < x; z++) { 331 if (x_min <= posx && posx <= x_max && y_min <= posy && posy <= y_max) { // tile 336 if (x_min <= posx && posx <= x_max && y_min <= posy 337 && posy <= y_max) { // tile 332 338 // is 333 339 // visible … … 444 450 } 445 451 if (!tile.isLoaded()) { 446 tileLoader.addLoadRequest(tilex, tiley, zoom); 452 jobDispatcher.addJob(tileLoader.createTileLoaderJob(tilex, tiley, 453 zoom)); 447 454 } 448 455 return tile; -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmFileCacheTileLoader.java
r9618 r9619 14 14 import java.net.URLConnection; 15 15 16 import org.openstreetmap.gui.jmapviewer.interfaces.Job; 16 17 import org.openstreetmap.gui.jmapviewer.interfaces.TileCache; 17 18 import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; … … 56 57 } 57 58 58 public void addLoadRequest(final int tilex, final int tiley, final int zoom) {59 map.jobDispatcher.addJob(new FileLoadJob(tilex, tiley, zoom));60 } 61 62 protected class FileLoadJob implements Runnable{59 public Job createTileLoaderJob(final int tilex, final int tiley, final int zoom) { 60 return new FileLoadJob(tilex, tiley, zoom); 61 } 62 63 protected class FileLoadJob implements Job { 63 64 InputStream input = null; 64 65 … … 210 211 } 211 212 } 213 214 public void stop() { 215 } 212 216 } 213 217 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
r9618 r9619 35 35 } 36 36 37 public void addLoadRequest(final int tilex, final int tiley, final int zoom) { 38 map.jobDispatcher.addJob(new Job() { 37 public Job createTileLoaderJob(final int tilex, final int tiley, 38 final int zoom) { 39 return new Job() { 39 40 40 41 InputStream input = null; … … 77 78 } 78 79 } 79 } );80 }; 80 81 } 81 82 -
applications/viewer/jmapviewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoader.java
r9494 r9619 5 5 /** 6 6 * Interface for implementing a tile loader. Tiles are usually loaded via HTTP 7 * or from a file. The {@link TileLoader} implementation is responsible for 8 * performing the loading action asynchronously by creating a new 9 * {@link Runnable} or {@link Job}. 7 * or from a file. 10 8 * 11 9 * @author Jan Peter Stotz … … 14 12 15 13 /** 16 * A typical {@link #addLoadRequest(int, int, int)} implementation should 17 * create a new {@link Job} instance that performs the load action. This 18 * {@link Job} instance is then handed over to 19 * <code>map.jobDispatcher</code>. 14 * A typical {@link #createTileLoaderJob(int, int, int)} implementation 15 * should create and return a new {@link Job} instance that performs the 16 * load action. 20 17 * 21 18 * @param tilex 22 19 * @param tiley 23 20 * @param zoom 21 * @returns {@link Job} implementation that performs the desired load 22 * action. 24 23 */ 25 public void addLoadRequest(int tilex, int tiley, int zoom);24 public Job createTileLoaderJob(int tilex, int tiley, int zoom); 26 25 }
Note:
See TracChangeset
for help on using the changeset viewer.