diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/DefaultMapController.java
|
old
|
new
|
MouseWheelListener {
|
| 26 | 26 | |
| 27 | 27 | private Point lastDragPoint; |
| 28 | 28 | |
| 29 | | private boolean isMoving; |
| | 29 | private boolean isMoving = false; |
| 30 | 30 | |
| 31 | 31 | private boolean movementEnabled = true; |
| 32 | 32 | |
| 33 | | private int movementMouseButton = MouseEvent.BUTTON3; |
| 34 | | private int movementMouseButtonMask = MouseEvent.BUTTON3_DOWN_MASK; |
| | 33 | private int movementMouseButton = MouseEvent.BUTTON1; |
| | 34 | private int movementMouseButtonMask = MouseEvent.BUTTON1_DOWN_MASK; |
| 35 | 35 | |
| 36 | 36 | private boolean wheelZoomEnabled = true; |
| 37 | 37 | private boolean doubleClickZoomEnabled = true; |
| … |
… |
MouseWheelListener {
|
| 49 | 49 | if (!movementEnabled || !isMoving) |
| 50 | 50 | return; |
| 51 | 51 | // Is only the selected mouse button pressed? |
| 52 | | if ((e.getModifiersEx() & MOUSE_BUTTONS_MASK) == movementMouseButtonMask |
| | 52 | if ((e.getModifiersEx() & MOUSE_BUTTONS_MASK) == movementMouseButtonMask |
| 53 | 53 | || (isPlatformOsx() && e.getModifiersEx() == MAC_MOUSE_BUTTON3_MASK)) { |
| 54 | 54 | Point p = e.getPoint(); |
| 55 | 55 | if (lastDragPoint != null) { |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/Demo.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/Demo.java
|
old
|
new
|
public class Demo extends JFrame impleme
|
| 75 | 75 | add(helpPanel, BorderLayout.SOUTH); |
| 76 | 76 | panel.add(panelTop, BorderLayout.NORTH); |
| 77 | 77 | panel.add(panelBottom, BorderLayout.SOUTH); |
| 78 | | JLabel helpLabel = new JLabel("Use right mouse button to move,\n " |
| | 78 | JLabel helpLabel = new JLabel("Use left mouse button to move,\n " |
| 79 | 79 | + "left double click or mouse wheel to zoom."); |
| 80 | 80 | helpPanel.add(helpLabel); |
| 81 | 81 | JButton button = new JButton("setDisplayToFitMapMarkers"); |
| … |
… |
public class Demo extends JFrame impleme
|
| 88 | 88 | JComboBox<TileSource> tileSourceSelector = new JComboBox<>(new TileSource[] { |
| 89 | 89 | new OsmTileSource.Mapnik(), |
| 90 | 90 | new OsmTileSource.CycleMap(), |
| 91 | | new BingAerialTileSource(), |
| | 91 | new BingAerialTileSource() |
| 92 | 92 | }); |
| 93 | 93 | tileSourceSelector.addItemListener(new ItemListener() { |
| 94 | 94 | @Override |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/JMapViewer.java
|
old
|
new
|
import org.openstreetmap.gui.jmapviewer.
|
| 44 | 44 | */ |
| 45 | 45 | public class JMapViewer extends JPanel implements TileLoaderListener { |
| 46 | 46 | |
| | 47 | private static final long serialVersionUID = 1L; |
| | 48 | |
| 47 | 49 | /** whether debug mode is enabled or not */ |
| 48 | 50 | public static boolean debug; |
| 49 | 51 | |
| … |
… |
public class JMapViewer extends JPanel i
|
| 502 | 504 | return (int) marker.getRadius(); |
| 503 | 505 | else if (p != null) { |
| 504 | 506 | Integer radius = getLatOffset(marker.getLat(), marker.getLon(), marker.getRadius(), false); |
| 505 | | radius = radius == null ? null : p.y - radius.intValue(); |
| | 507 | radius = radius == null ? null : p.y - radius; |
| 506 | 508 | return radius; |
| 507 | 509 | } else |
| 508 | 510 | return null; |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/OsmTileLoader.java
|
old
|
new
|
import java.net.URLConnection;
|
| 9 | 9 | import java.util.HashMap; |
| 10 | 10 | import java.util.Map; |
| 11 | 11 | import java.util.Map.Entry; |
| 12 | | import java.util.concurrent.Executors; |
| 13 | | import java.util.concurrent.ThreadPoolExecutor; |
| | 12 | import java.util.concurrent.*; |
| 14 | 13 | |
| 15 | 14 | import org.openstreetmap.gui.jmapviewer.interfaces.TileJob; |
| 16 | 15 | import org.openstreetmap.gui.jmapviewer.interfaces.TileLoader; |
| … |
… |
import org.openstreetmap.gui.jmapviewer.
|
| 22 | 21 | * @author Jan Peter Stotz |
| 23 | 22 | */ |
| 24 | 23 | public class OsmTileLoader implements TileLoader { |
| 25 | | private static final ThreadPoolExecutor jobDispatcher = (ThreadPoolExecutor) Executors.newFixedThreadPool(3); |
| | 24 | |
| | 25 | private static final ThreadPoolExecutor jobDispatcher = new ThreadPoolExecutor(8, 24, 30, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(2_000)); |
| 26 | 26 | |
| 27 | 27 | private final class OsmTileJob implements TileJob { |
| 28 | 28 | private final Tile tile; |
| … |
… |
public class OsmTileLoader implements Ti
|
| 178 | 178 | |
| 179 | 179 | @Override |
| 180 | 180 | public void cancelOutstandingTasks() { |
| 181 | | jobDispatcher.getQueue().clear(); |
| | 181 | for (Runnable item : jobDispatcher.getQueue()) { |
| | 182 | jobDispatcher.remove(item); |
| | 183 | } |
| 182 | 184 | } |
| 183 | 185 | |
| 184 | 186 | /** |
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_large.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_large.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_medium_1.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_medium_1.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_medium_2.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_medium_2.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_small.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_gray_small.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_large.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_large.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_medium_1.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_medium_1.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_medium_2.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_medium_2.png differ
Binary files JMapViewer/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_small.png and JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/images/bing_maps_logo_white_small.png differ
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/interfaces/TileLoaderListener.java
|
old
|
new
|
import org.openstreetmap.gui.jmapviewer.
|
| 6 | 6 | /** |
| 7 | 7 | * This listener listens to successful tile loads. |
| 8 | 8 | */ |
| 9 | | @FunctionalInterface |
| | 9 | //@FunctionalInterface |
| 10 | 10 | public interface TileLoaderListener { |
| 11 | 11 | |
| 12 | 12 | /** |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/tilesources/BingAerialTileSource.java
|
old
|
new
|
import java.util.concurrent.ExecutionExc
|
| 14 | 14 | import java.util.concurrent.Future; |
| 15 | 15 | import java.util.concurrent.FutureTask; |
| 16 | 16 | import java.util.concurrent.TimeUnit; |
| 17 | | import java.util.concurrent.TimeoutException; |
| 18 | 17 | import java.util.regex.Pattern; |
| 19 | 18 | |
| 20 | 19 | import javax.imageio.ImageIO; |
| … |
… |
public class BingAerialTileSource extend
|
| 57 | 56 | * Constructs a new {@code BingAerialTileSource}. |
| 58 | 57 | */ |
| 59 | 58 | public BingAerialTileSource() { |
| 60 | | super(new TileSourceInfo("Bing", null, null)); |
| | 59 | super(new TileSourceInfo("Bing Aerial Maps", null, null)); |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | /** |
| … |
… |
public class BingAerialTileSource extend
|
| 192 | 191 | @Override |
| 193 | 192 | public Image getAttributionImage() { |
| 194 | 193 | try { |
| 195 | | final InputStream imageResource = JMapViewer.class.getResourceAsStream("images/bing_maps.png"); |
| | 194 | final InputStream imageResource = JMapViewer.class.getResourceAsStream("images/bing_maps_logo_white_small.png"); |
| 196 | 195 | if (imageResource != null) { |
| 197 | 196 | return ImageIO.read(imageResource); |
| 198 | 197 | } else { |
| … |
… |
public class BingAerialTileSource extend
|
| 239 | 238 | try { |
| 240 | 239 | InputSource xml = new InputSource(getAttributionUrl().openStream()); |
| 241 | 240 | List<Attribution> r = parseAttributionText(xml); |
| 242 | | System.out.println("Successfully loaded Bing attribution data."); |
| 243 | 241 | return r; |
| 244 | 242 | } catch (IOException ex) { |
| 245 | 243 | System.err.println("Could not connect to Bing API. Will retry in " + waitTimeSec + " seconds."); |
| … |
… |
public class BingAerialTileSource extend
|
| 263 | 261 | } |
| 264 | 262 | } |
| 265 | 263 | try { |
| 266 | | return attributions.get(0, TimeUnit.MILLISECONDS); |
| 267 | | } catch (TimeoutException ex) { |
| 268 | | System.err.println("Bing: attribution data is not yet loaded."); |
| | 264 | return attributions.get(); |
| 269 | 265 | } catch (ExecutionException ex) { |
| 270 | 266 | throw new RuntimeException(ex.getCause()); |
| 271 | 267 | } catch (InterruptedException ign) { |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/tilesources/OsmTileSource.java
|
old
|
new
|
|
| 1 | 1 | // License: GPL. For details, see Readme.txt file. |
| 2 | 2 | package org.openstreetmap.gui.jmapviewer.tilesources; |
| 3 | 3 | |
| | 4 | import java.io.IOException; |
| | 5 | import org.openstreetmap.gui.jmapviewer.interfaces.ICoordinate; |
| | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * OSM Tile source. |
| 6 | 9 | */ |
| … |
… |
public class OsmTileSource {
|
| 11 | 14 | */ |
| 12 | 15 | public static class Mapnik extends AbstractOsmTileSource { |
| 13 | 16 | |
| 14 | | private static final String PATTERN = "https://%s.tile.openstreetmap.org"; |
| | 17 | private static final String PATTERN = "http://%s.tile.openstreetmap.org"; |
| 15 | 18 | |
| 16 | 19 | private static final String[] SERVER = {"a", "b", "c"}; |
| 17 | 20 | |
| … |
… |
public class OsmTileSource {
|
| 37 | 40 | */ |
| 38 | 41 | public static class CycleMap extends AbstractOsmTileSource { |
| 39 | 42 | |
| 40 | | private static final String PATTERN = "http://%s.tile.opencyclemap.org/cycle"; |
| | 43 | private static final String API_KEY = "API_KEY"; |
| 41 | 44 | |
| 42 | | private static final String[] SERVER = {"a", "b", "c"}; |
| | 45 | private static final String PATTERN = "http://%s.tile.thunderforest.com/cycle"; |
| | 46 | |
| | 47 | private static final String[] SERVER = { "a", "b", "c" }; |
| 43 | 48 | |
| 44 | 49 | private int serverNum; |
| 45 | 50 | |
| … |
… |
public class OsmTileSource {
|
| 47 | 52 | * Constructs a new {@code CycleMap} tile source. |
| 48 | 53 | */ |
| 49 | 54 | public CycleMap() { |
| 50 | | super("Cyclemap", PATTERN, "opencyclemap"); |
| | 55 | super("OSM Cycle Map", PATTERN, "opencyclemap"); |
| 51 | 56 | } |
| 52 | 57 | |
| 53 | 58 | @Override |
| … |
… |
public class OsmTileSource {
|
| 61 | 66 | public int getMaxZoom() { |
| 62 | 67 | return 18; |
| 63 | 68 | } |
| | 69 | |
| | 70 | @Override |
| | 71 | public String getTileUrl(int zoom, int tilex, int tiley) throws IOException { |
| | 72 | return this.getBaseUrl() + getTilePath(zoom, tilex, tiley); // + "?apikey=" + API_KEY; |
| | 73 | } |
| | 74 | |
| | 75 | @Override |
| | 76 | public String getAttributionText(int zoom, ICoordinate topLeft, ICoordinate botRight) { |
| | 77 | return "Maps © Thunderforest, Data © OpenStreetMap contributors"; |
| | 78 | } |
| | 79 | |
| | 80 | @Override |
| | 81 | public String getAttributionLinkURL() { |
| | 82 | return "http://www.thunderforest.com/"; |
| | 83 | } |
| 64 | 84 | } |
| | 85 | |
| 65 | 86 | } |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/tilesources/ScanexTileSource.java
|
old
|
new
|
public class ScanexTileSource extends TM
|
| 116 | 116 | @Override |
| 117 | 117 | public Point latLonToXY(double lat, double lon, int zoom) { |
| 118 | 118 | return new Point( |
| 119 | | (int) osmMercator.lonToX(lon, zoom), |
| 120 | | (int) latToTileY(lat, zoom) |
| | 119 | (int) Math.round(osmMercator.lonToX(lon, zoom)), |
| | 120 | (int) Math.round(latToTileY(lat, zoom)) |
| 121 | 121 | ); |
| 122 | 122 | } |
| 123 | 123 | |
diff -rupN JMapViewer/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java JMapViewer.patched/src/org/openstreetmap/gui/jmapviewer/tilesources/TMSTileSource.java
|
old
|
new
|
public class TMSTileSource extends Abstr
|
| 50 | 50 | @Override |
| 51 | 51 | public Point latLonToXY(double lat, double lon, int zoom) { |
| 52 | 52 | return new Point( |
| 53 | | (int) osmMercator.lonToX(lon, zoom), |
| 54 | | (int) osmMercator.latToY(lat, zoom) |
| 55 | | ); |
| | 53 | (int) Math.round(osmMercator.lonToX(lon, zoom)), |
| | 54 | (int) Math.round(osmMercator.latToY(lat, zoom))); |
| 56 | 55 | } |
| 57 | 56 | |
| 58 | 57 | @Override |
| 59 | 58 | public ICoordinate xyToLatLon(int x, int y, int zoom) { |
| 60 | 59 | return new Coordinate( |
| 61 | | osmMercator.yToLat(y, zoom), |
| 62 | | osmMercator.xToLon(x, zoom) |
| 63 | | ); |
| | 60 | osmMercator.yToLat(y, zoom), |
| | 61 | osmMercator.xToLon(x, zoom) |
| | 62 | ); |
| 64 | 63 | } |
| 65 | 64 | |
| 66 | 65 | @Override |
| 67 | 66 | public TileXY latLonToTileXY(double lat, double lon, int zoom) { |
| 68 | 67 | return new TileXY( |
| 69 | | osmMercator.lonToX(lon, zoom) / getTileSize(), |
| 70 | | osmMercator.latToY(lat, zoom) / getTileSize() |
| 71 | | ); |
| | 68 | osmMercator.lonToX(lon, zoom) / getTileSize(), |
| | 69 | osmMercator.latToY(lat, zoom) / getTileSize() |
| | 70 | ); |
| 72 | 71 | } |
| 73 | 72 | |
| 74 | 73 | @Override |
| 75 | 74 | public ICoordinate tileXYToLatLon(int x, int y, int zoom) { |
| 76 | 75 | return new Coordinate( |
| 77 | | osmMercator.yToLat(y * getTileSize(), zoom), |
| 78 | | osmMercator.xToLon(x * getTileSize(), zoom) |
| 79 | | ); |
| | 76 | osmMercator.yToLat(y * getTileSize(), zoom), |
| | 77 | osmMercator.xToLon(x * getTileSize(), zoom) |
| | 78 | ); |
| 80 | 79 | } |
| 81 | 80 | |
| 82 | 81 | @Override |