altosuilib: Have map preload respond to units and font size changes
[fw/altos] / altosuilib / AltosUIMapNew.java
index 3efffb00ddb37316ab8e5518924172d0d168a279..42c9aa7a128090e61fda5333fd1b62e29d44444e 100644 (file)
@@ -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,8 +270,8 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt
                                if (t.has_location()) {
                                        String  message = null;
                                        switch (status) {
-                                       case AltosMapTile.loading:
-                                               message = "Loading...";
+                                       case AltosMapTile.fetching:
+                                               message = "Fetching...";
                                                break;
                                        case AltosMapTile.bad_request:
                                                message = "Internal error";
@@ -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,10 +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() {