Merge remote-tracking branch 'kelly/5884-geolocation-waypoint-selection-issues' into 5821_geoDoc

This commit is contained in:
Ann Priestman 2019-12-17 11:02:50 -05:00
commit c9c6ec0502
2 changed files with 23 additions and 11 deletions

View File

@ -417,8 +417,6 @@ public class KdTree<T extends KdTree.XYZPoint> implements Iterable<T> {
} }
Double nodeDistance = node.id.euclideanDistance(value); Double nodeDistance = node.id.euclideanDistance(value);
if (nodeDistance.compareTo(lastDistance) < 0) { if (nodeDistance.compareTo(lastDistance) < 0) {
if (results.size() == K && lastNode != null)
results.remove(lastNode);
results.add(node); results.add(node);
} else if (nodeDistance.equals(lastDistance)) { } else if (nodeDistance.equals(lastDistance)) {
results.add(node); results.add(node);

View File

@ -70,6 +70,7 @@ import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException;
import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskCoreException;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.SwingUtilities;
import org.jxmapviewer.viewer.DefaultWaypointRenderer; import org.jxmapviewer.viewer.DefaultWaypointRenderer;
/** /**
@ -204,13 +205,14 @@ final public class MapPanel extends javax.swing.JPanel {
Iterator<MapWaypoint> iterator = waypointTree.iterator(); Iterator<MapWaypoint> iterator = waypointTree.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
MapWaypoint point = iterator.next(); MapWaypoint point = iterator.next();
if (point != currentlySelectedWaypoint) { // if (point != currentlySelectedWaypoint) {
set.add(point); set.add(point);
} // }
} }
// Add the currentlySelectedWaypoint to the end so that // Add the currentlySelectedWaypoint to the end so that
// it will be painted last. // it will be painted last.
if (currentlySelectedWaypoint != null) { if (currentlySelectedWaypoint != null) {
set.remove(currentlySelectedWaypoint);
set.add(currentlySelectedWaypoint); set.add(currentlySelectedWaypoint);
} }
} }
@ -342,7 +344,11 @@ final public class MapPanel extends javax.swing.JPanel {
*/ */
private void showPopupMenu(Point point) { private void showPopupMenu(Point point) {
try { try {
MapWaypoint waypoint = findClosestWaypoint(point); List<MapWaypoint> waypoints = findClosestWaypoint(point);
MapWaypoint waypoint = null;
if(waypoints.size() > 0) {
waypoint = waypoints.get(0);
}
showPopupMenu(waypoint, point); showPopupMenu(waypoint, point);
// Change the details popup to the currently selected point only if // Change the details popup to the currently selected point only if
// it the popup is currently visible // it the popup is currently visible
@ -410,6 +416,7 @@ final public class MapPanel extends javax.swing.JPanel {
currentPopup = popupFactory.getPopup(this, detailPane, popupLocation.x, popupLocation.y); currentPopup = popupFactory.getPopup(this, detailPane, popupLocation.x, popupLocation.y);
currentPopup.show(); currentPopup.show();
mapViewer.revalidate();
mapViewer.repaint(); mapViewer.repaint();
} }
} }
@ -437,7 +444,7 @@ final public class MapPanel extends javax.swing.JPanel {
* @return A waypoint that is within 10 pixels of the given point, or null * @return A waypoint that is within 10 pixels of the given point, or null
* if none was found. * if none was found.
*/ */
private MapWaypoint findClosestWaypoint(Point mouseClickPoint) { private List<MapWaypoint> findClosestWaypoint(Point mouseClickPoint) {
if (waypointTree == null) { if (waypointTree == null) {
return null; return null;
} }
@ -446,7 +453,7 @@ final public class MapPanel extends javax.swing.JPanel {
GeoPosition geopos = mapViewer.getTileFactory().pixelToGeo(mouseClickPoint, mapViewer.getZoom()); GeoPosition geopos = mapViewer.getTileFactory().pixelToGeo(mouseClickPoint, mapViewer.getZoom());
// Get the 5 nearest neightbors to the point // Get the 5 nearest neightbors to the point
Collection<MapWaypoint> waypoints = waypointTree.nearestNeighbourSearch(20, MapWaypoint.getDummyWaypoint(geopos)); Collection<MapWaypoint> waypoints = waypointTree.nearestNeighbourSearch(10, MapWaypoint.getDummyWaypoint(geopos));
if (waypoints == null || waypoints.isEmpty()) { if (waypoints == null || waypoints.isEmpty()) {
return null; return null;
@ -456,6 +463,7 @@ final public class MapPanel extends javax.swing.JPanel {
// These maybe the points closest to lat/log was clicked but // These maybe the points closest to lat/log was clicked but
// that doesn't mean they are close in terms of pixles. // that doesn't mean they are close in terms of pixles.
List<MapWaypoint> closestPoints = new ArrayList<>();
while (iterator.hasNext()) { while (iterator.hasNext()) {
MapWaypoint nextWaypoint = iterator.next(); MapWaypoint nextWaypoint = iterator.next();
@ -466,11 +474,11 @@ final public class MapPanel extends javax.swing.JPanel {
(int) point.getY() - rect.y); (int) point.getY() - rect.y);
if (converted_gp_pt.distance(mouseClickPoint) < 10) { if (converted_gp_pt.distance(mouseClickPoint) < 10) {
return nextWaypoint; closestPoints.add(nextWaypoint);
} }
} }
return null; return closestPoints;
} }
/** /**
@ -629,8 +637,14 @@ final public class MapPanel extends javax.swing.JPanel {
}//GEN-LAST:event_mapViewerMouseMoved }//GEN-LAST:event_mapViewerMouseMoved
private void mapViewerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapViewerMouseClicked private void mapViewerMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_mapViewerMouseClicked
if(!evt.isPopupTrigger() && (evt.getButton() == MouseEvent.BUTTON1)) { if(!evt.isPopupTrigger() && SwingUtilities.isLeftMouseButton(evt)) {
currentlySelectedWaypoint = findClosestWaypoint(evt.getPoint()); List<MapWaypoint> waypoints = findClosestWaypoint(evt.getPoint());
if(waypoints.size() > 0) {
currentlySelectedWaypoint = waypoints.get(0);
}
// currentlySelectedWaypoint = findClosestWaypoint(evt.getPoint());
showDetailsPopup(); showDetailsPopup();
} }
}//GEN-LAST:event_mapViewerMouseClicked }//GEN-LAST:event_mapViewerMouseClicked