X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosuilib%2FAltosUIMapNew.java;h=42c9aa7a128090e61fda5333fd1b62e29d44444e;hp=4191a562ffef8c7d0230179ff423c3258094c266;hb=59a9bdd73b580a9c934a574be7bf45c5033e14b5;hpb=501fa41111b93cc213a1114a33612858e1e93ab5 diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java index 4191a562..42c9aa7a 100644 --- a/altosuilib/AltosUIMapNew.java +++ b/altosuilib/AltosUIMapNew.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altosuilib_7; +package org.altusmetrum.altosuilib_11; import java.awt.*; import java.awt.event.*; @@ -27,7 +27,7 @@ import java.awt.geom.*; import java.util.*; import java.util.concurrent.*; import javax.imageio.*; -import org.altusmetrum.altoslib_7.*; +import org.altusmetrum.altoslib_11.*; public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, AltosMapInterface { @@ -139,18 +139,7 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt public void mouseWheelMoved(MouseWheelEvent e) { int zoom_change = e.getWheelRotation(); - map.notice_user_input(); - AltosLatLon mouse_lat_lon = map.transform.screen_lat_lon(new AltosPointInt(e.getPoint().x, e.getPoint().y)); - map.set_zoom(map.get_zoom() - zoom_change); - - AltosPointDouble new_mouse = map.transform.screen(mouse_lat_lon); - - int dx = getWidth()/2 - e.getPoint().x; - int dy = getHeight()/2 - e.getPoint().y; - - AltosLatLon new_centre = map.transform.screen_lat_lon(new AltosPointInt((int) new_mouse.x + dx, (int) new_mouse.y + dy)); - - map.centre(new_centre); + map.set_zoom_centre(map.get_zoom() - zoom_change, new AltosPointInt(e.getPoint().x, e.getPoint().y)); } /* ComponentListener methods */ @@ -252,8 +241,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt } class MapTile extends AltosMapTile { - public MapTile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - super(listener, upper_left, center, zoom, maptype, px_size); + public MapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { + super(cache, upper_left, center, zoom, maptype, px_size, scale); } public void paint(AltosMapTransform t) { @@ -265,11 +254,9 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt if (!g.hitClip(point.x, point.y, px_size, px_size)) return; - AltosImage altos_image = cache.get(this, store, px_size, px_size); - + AltosImage altos_image = get_image(); AltosUIImage ui_image = (AltosUIImage) altos_image; - - Image image = null; + Image image = null; if (ui_image != null) image = ui_image.image; @@ -283,16 +270,16 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt if (t.has_location()) { String message = null; switch (status) { - case AltosUIMapCache.loading: - message = "Loading..."; + case AltosMapTile.fetching: + message = "Fetching..."; break; - case AltosUIMapCache.bad_request: + case AltosMapTile.bad_request: message = "Internal error"; break; - case AltosUIMapCache.failed: + case AltosMapTile.failed: message = "Network error, check connection"; break; - case AltosUIMapCache.forbidden: + case AltosMapTile.forbidden: message = "Too many requests, try later"; break; } @@ -345,8 +332,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt return new MapMark(lat, lon, state); } - public AltosMapTile new_tile(AltosMapTileListener listener, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new MapTile(listener, upper_left, center, zoom, maptype, px_size); + public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { + return new MapTile(cache, upper_left, center, zoom, maptype, px_size, scale); } public int width() { @@ -369,6 +356,15 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt zoom_label.setText(label); } + public void select_object(AltosLatLon latlon) { + debug("select at %f,%f\n", latlon.lat, latlon.lon); + } + + public void debug(String format, Object ... arguments) { + System.out.printf(format, arguments); + } + + /* AltosFlightDisplay interface */ public void set_font() { @@ -419,15 +415,16 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt return "Map"; } + /* AltosGraphUI interface */ + public void centre(AltosState state) { + map.centre(state); + } + /* internal layout bits */ private GridBagLayout layout = new GridBagLayout(); JComboBox maptype_combo; - public void set_load_params(double lat, double lon, int radius, AltosMapTileListener listener) { - map.set_load_params(lat, lon, radius, listener); - } - MapView view; public AltosUIMapNew() {