X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altoslib%2FAltosMap.java;h=762054a33f158fcefb0698a00091359b97c6e5bd;hp=b54c66cf7a9d44e8f496f90b89b71ed3ef114f1b;hb=103a50db50be55c2293468d273dd94472dd89d94;hpb=501fa41111b93cc213a1114a33612858e1e93ab5 diff --git a/altoslib/AltosMap.java b/altoslib/AltosMap.java index b54c66cf..762054a3 100644 --- a/altoslib/AltosMap.java +++ b/altoslib/AltosMap.java @@ -58,8 +58,9 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { LinkedList marks = new LinkedList(); - AltosMapPath path; - AltosMapLine line; + AltosMapPath path; + AltosMapLine line; + public AltosLatLon last_position; boolean have_boost = false; boolean have_landed = false; @@ -195,8 +196,6 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { if (!gps.locked && gps.nsat < 4) return; - AltosMapRectangle damage = path.add(gps.lat, gps.lon, state.state); - switch (state.state) { case AltosLib.ao_flight_boost: if (!have_boost) { @@ -212,8 +211,15 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { break; } - if (damage != null) - repaint(damage, AltosMapPath.stroke_width); + if (path != null) { + AltosMapRectangle damage = path.add(gps.lat, gps.lon, state.state); + + if (damage != null) + repaint(damage, AltosMapPath.stroke_width); + } + + last_position = new AltosLatLon(gps.lat, gps.lon); + maybe_centre(gps.lat, gps.lon); } @@ -287,7 +293,7 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { AltosLatLon ul = transform.lat_lon(new AltosPointDouble(x, y)); AltosLatLon center = transform.lat_lon(new AltosPointDouble(x + AltosMap.px_size/2, y + AltosMap.px_size/2)); AltosMapTile tile = map_interface.new_tile(this, ul, center, zoom, maptype, - AltosMap.px_size); + px_size); tiles.put(point, tile); } } @@ -323,9 +329,11 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { mark.paint(transform); } - path.paint(transform); + if (path != null) + path.paint(transform); - line.paint(transform); + if (line != null) + line.paint(transform); } /* AltosMapTileListener methods */ @@ -368,13 +376,17 @@ public class AltosMap implements AltosMapTileListener, AltosMapStoreListener { } private void line_start(int x, int y) { - line.pressed(new AltosPointInt(x, y), transform); - repaint(); + if (line != null) { + line.pressed(new AltosPointInt(x, y), transform); + repaint(); + } } private void line(int x, int y) { - line.dragged(new AltosPointInt(x, y), transform); - repaint(); + if (line != null) { + line.dragged(new AltosPointInt(x, y), transform); + repaint(); + } } public void touch_start(int x, int y, boolean is_drag) {