X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fgui%2FMapChart.java;h=e705f843aab3c74eb688f173766d5bbb5e7c8820;hp=1236f130558630c4278b7a8cc31762ec34630ad4;hb=5625a1abadb5f2ca5f017fe7dbda1d5141cb637b;hpb=23959e65a6a0d581e657b07186d18b7a1ac5afeb diff --git a/tim/prune/gui/MapChart.java b/tim/prune/gui/MapChart.java index 1236f13..e705f84 100644 --- a/tim/prune/gui/MapChart.java +++ b/tim/prune/gui/MapChart.java @@ -49,7 +49,6 @@ public class MapChart extends GenericChart implements MouseWheelListener, KeyLis private BufferedImage _image = null; private JPopupMenu _popup = null; private JCheckBoxMenuItem _autoPanMenuItem = null; - private String _trackString = null; private int _numPoints = -1; private double _scale; private double _offsetX, _offsetY, _zoomScale; @@ -153,10 +152,14 @@ public class MapChart extends GenericChart implements MouseWheelListener, KeyLis } _lastSelectedPoint = selectedPoint; + // Create background if necessary if (_image == null || width != _image.getWidth() || height != _image.getHeight()) { createBackgroundImage(); } + // return if image has been set to null by other thread + if (_image == null) {return;} + // draw buffered image onto g g.drawImage(_image, 0, 0, width, height, COLOR_BG, null); @@ -208,7 +211,7 @@ public class MapChart extends GenericChart implements MouseWheelListener, KeyLis } // Attempt to grab keyboard focus if possible - this.requestFocus(); + //this.requestFocus(); } @@ -250,8 +253,11 @@ public class MapChart extends GenericChart implements MouseWheelListener, KeyLis { DataPoint point = _track.getPoint(i); String waypointName = point.getWaypointName(); - if (waypointName != null && !waypointName.equals("") && numWaypointNamesShown < LIMIT_WAYPOINT_NAMES) + if (waypointName != null && !waypointName.equals("")) { + // escape if nothing more to do + if (numWaypointNamesShown >= LIMIT_WAYPOINT_NAMES || _image == null) {break;} + // calculate coordinates of point x = halfWidth + (int) ((_track.getX(i) - _offsetX) / _scale * _zoomScale); y = halfHeight - (int) ((_track.getY(i) - _offsetY) / _scale * _zoomScale); if (x > BORDER_WIDTH && x < (width - BORDER_WIDTH) @@ -305,15 +311,22 @@ public class MapChart extends GenericChart implements MouseWheelListener, KeyLis */ private boolean overlapsPoints(int inX, int inY, int inWidth, int inHeight) { - // if (true) return true; - for (int x=0; x