From ac22f90046f764476b801635f84dbfe37f804661 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Tue, 17 Dec 2019 13:24:52 -0500 Subject: [PATCH 1/3] Fixed cursor issue --- .../geolocation/GeolocationTopComponent.java | 1 + .../geolocation/MapPanMouseInputListener.java | 115 ++++++++++++++++++ .../autopsy/geolocation/MapPanel.java | 7 +- 3 files changed, 122 insertions(+), 1 deletion(-) create mode 100755 Core/src/org/sleuthkit/autopsy/geolocation/MapPanMouseInputListener.java diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java index b1dee1cbb4..858082911d 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java @@ -194,6 +194,7 @@ public final class GeolocationTopComponent extends TopComponent { @Override public void open() { super.open(); + mapPanel.clearWaypoints(); geoFilterPanel.clearDataSourceList(); geoFilterPanel.updateDataSourceList(); try { diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanMouseInputListener.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanMouseInputListener.java new file mode 100755 index 0000000000..9f75b13d2a --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanMouseInputListener.java @@ -0,0 +1,115 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2019 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.geolocation; + +import java.awt.Cursor; +import java.awt.Point; +import java.awt.event.MouseEvent; +import java.awt.geom.Point2D; +import javax.swing.SwingUtilities; +import javax.swing.event.MouseInputAdapter; +import org.jxmapviewer.JXMapViewer; + +/** + * MouseInputListener for panning a JXMapViewer + * + * This class is adapted from org.jxmapviewer.input.PanMouseInputListener. + */ +final class MapPanMouseInputListener extends MouseInputAdapter { + + private Point prev; + private final JXMapViewer viewer; + private Cursor priorCursor; + private boolean dragging = false; + + /** + * Construct a new listener. + * + * @param viewer + */ + MapPanMouseInputListener(JXMapViewer viewer) { + this.viewer = viewer; + } + + @Override + public void mousePressed(MouseEvent evt) { + if (!SwingUtilities.isLeftMouseButton(evt)) { + return; + } + if (!viewer.isPanningEnabled()) { + return; + } + + // Store the current click point and current cursor + prev = evt.getPoint(); + priorCursor = viewer.getCursor(); + } + + @Override + public void mouseDragged(MouseEvent evt) { + if (!SwingUtilities.isLeftMouseButton(evt)) { + return; + } + + if (!viewer.isPanningEnabled()) { + return; + } + + // If the map wasn't previously being dragged, set the cursor + if (!dragging) { + viewer.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR)); + dragging = true; + } + + // Figure out the new map center + Point current = evt.getPoint(); + double x = viewer.getCenter().getX(); + double y = viewer.getCenter().getY(); + + if (prev != null) { + x += prev.x - current.x; + y += prev.y - current.y; + } + + int maxHeight = (int) (viewer.getTileFactory().getMapSize(viewer.getZoom()).getHeight() * viewer + .getTileFactory().getTileSize(viewer.getZoom())); + if (y > maxHeight) { + y = maxHeight; + } + + prev = current; + viewer.setCenter(new Point2D.Double(x, y)); + viewer.repaint(); + } + + @Override + public void mouseReleased(MouseEvent evt) { + if (!SwingUtilities.isLeftMouseButton(evt)) { + return; + } + + prev = null; + + // If we were dragging set the cursor back + if (dragging) { + viewer.setCursor(priorCursor); + dragging = false; + } + } +} diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java index a90dac796b..fcf3f4f527 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.geolocation; +import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -71,6 +72,7 @@ import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; import org.sleuthkit.datamodel.TskCoreException; import javax.imageio.ImageIO; import javax.swing.SwingUtilities; +import javax.swing.event.MouseInputAdapter; import org.jxmapviewer.viewer.DefaultWaypointRenderer; /** @@ -140,6 +142,8 @@ final public class MapPanel extends javax.swing.JPanel { } } }); + + } /** @@ -172,7 +176,8 @@ final public class MapPanel extends javax.swing.JPanel { mapViewer.setTileFactory(tileFactory); // Add Mouse interactions - MouseInputListener mia = new PanMouseInputListener(mapViewer); +// MouseInputListener mia = new PanMouseInputListener(mapViewer); + MouseInputListener mia = new MapPanMouseInputListener(mapViewer); mapViewer.addMouseListener(mia); mapViewer.addMouseMotionListener(mia); From 8616bbda276cf763ffff6604681f03d20f18d311 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Tue, 17 Dec 2019 14:19:23 -0500 Subject: [PATCH 2/3] Fixed typo --- .../sleuthkit/autopsy/geolocation/GeolocationTopComponent.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java index c2491f1d12..e1a02339e4 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/GeolocationTopComponent.java @@ -289,7 +289,7 @@ public final class GeolocationTopComponent extends TopComponent { DateFormat dateFormat = new SimpleDateFormat("MM-dd-yyyy-HH-mm-ss", Locale.US); Date date = new Date(); String dateNoTime = dateFormat.format(date); - String reportPath = String.format(REPORT_PATH_FMT_STR, currentCase.getReportDirectory(), currentCase.getDisplayName(), "Goggle Earth KML", dateNoTime); + String reportPath = String.format(REPORT_PATH_FMT_STR, currentCase.getReportDirectory(), currentCase.getDisplayName(), "Google Earth KML", dateNoTime); // Create the root reports directory. try { FileUtil.createFolder(new File(reportPath)); From 21421fe7404830df60cbdadef7535ddbcc446d54 Mon Sep 17 00:00:00 2001 From: Kelly Kelly Date: Tue, 17 Dec 2019 14:50:57 -0500 Subject: [PATCH 3/3] Removed unused imports and commented out code --- Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java index e1e1d8ef24..eec5e8a7a0 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java @@ -18,7 +18,6 @@ */ package org.sleuthkit.autopsy.geolocation; -import java.awt.Cursor; import java.awt.Dimension; import java.awt.Graphics2D; import java.awt.Point; @@ -27,7 +26,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.ComponentAdapter; import java.awt.event.ComponentEvent; -import java.awt.event.MouseEvent; import java.awt.geom.Point2D; import java.awt.image.BufferedImage; import java.beans.PropertyChangeEvent; @@ -55,7 +53,6 @@ import org.jxmapviewer.JXMapViewer; import org.jxmapviewer.OSMTileFactoryInfo; import org.jxmapviewer.VirtualEarthTileFactoryInfo; import org.jxmapviewer.input.CenterMapListener; -import org.jxmapviewer.input.PanMouseInputListener; import org.jxmapviewer.input.ZoomMouseWheelListenerCursor; import org.jxmapviewer.viewer.DefaultTileFactory; import org.jxmapviewer.viewer.GeoPosition; @@ -72,7 +69,6 @@ import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; import org.sleuthkit.datamodel.TskCoreException; import javax.imageio.ImageIO; import javax.swing.SwingUtilities; -import javax.swing.event.MouseInputAdapter; import org.jxmapviewer.viewer.DefaultWaypointRenderer; /** @@ -176,7 +172,6 @@ final public class MapPanel extends javax.swing.JPanel { mapViewer.setTileFactory(tileFactory); // Add Mouse interactions -// MouseInputListener mia = new PanMouseInputListener(mapViewer); MouseInputListener mia = new MapPanMouseInputListener(mapViewer); mapViewer.addMouseListener(mia); mapViewer.addMouseMotionListener(mia);