summaryrefslogtreecommitdiff
path: root/altosuilib
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2015-06-20 11:54:20 -0700
committerKeith Packard <keithp@keithp.com>2015-06-22 21:04:43 -0700
commit4a33336b8f468c5b0f2e14c0ee0242c9a24a8b90 (patch)
tree09700e3a50f313e92bb60affb728060993776d32 /altosuilib
parent3882e358b6f2970cb1afebcf2a71da34a57002df (diff)
altosuilib: Allow for no transform in map mouse wheel function
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosuilib')
-rw-r--r--altosuilib/AltosUIMapNew.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/altosuilib/AltosUIMapNew.java b/altosuilib/AltosUIMapNew.java
index 3efffb00..5f63a3c2 100644
--- a/altosuilib/AltosUIMapNew.java
+++ b/altosuilib/AltosUIMapNew.java
@@ -140,17 +140,23 @@ public class AltosUIMapNew extends JComponent implements AltosFlightDisplay, Alt
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));
+ AltosLatLon mouse_lat_lon = null;
+
+ if (map.transform != null)
+ 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);
+ if (mouse_lat_lon != null) {
+ AltosPointDouble new_mouse = map.transform.screen(mouse_lat_lon);
- int dx = getWidth()/2 - e.getPoint().x;
- int dy = getHeight()/2 - e.getPoint().y;
+ 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));
+ 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.centre(new_centre);
+ }
}
/* ComponentListener methods */