diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java index 16f999bdc4..326d33f23e 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapPanel.java @@ -33,6 +33,7 @@ import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Set; +import java.util.logging.Level; import javax.swing.JMenuItem; import javax.swing.JPopupMenu; import javax.swing.JSeparator; @@ -66,9 +67,9 @@ final class MapPanel extends javax.swing.JPanel { private Popup currentPopup; private final PopupFactory popupFactory; - private final int POPUP_WIDTH = 300; - private final int POPUP_HEIGHT = 200; - private final int POPUP_MARGIN = 10; + private static final int POPUP_WIDTH = 300; + private static final int POPUP_HEIGHT = 200; + private static final int POPUP_MARGIN = 10; private MapWaypoint currentlySelectedWaypoint; @@ -199,12 +200,12 @@ final class MapPanel extends javax.swing.JPanel { showPopupMenu(waypoint, point); // Change the details popup to the currently selected point only if // it the popup is currently visible - if (waypoint != null && waypoint != currentlySelectedWaypoint) { + if (waypoint != null && !waypoint.equals(currentlySelectedWaypoint)) { currentlySelectedWaypoint = waypoint; showDetailsPopup(); } - } catch (TskCoreException e) { - + } catch (TskCoreException ex) { + logger.log(Level.WARNING, "Failed to show popup for waypoint", ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java b/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java index 31366dd19a..7eb765151a 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/MapWaypoint.java @@ -20,9 +20,11 @@ package org.sleuthkit.autopsy.geolocation; import java.awt.event.ActionEvent; import java.awt.image.BufferedImage; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Locale; import java.util.logging.Level; import javax.swing.AbstractAction; import javax.swing.Action; @@ -47,7 +49,6 @@ import org.sleuthkit.autopsy.geolocation.datamodel.GeoLocationDataException; import org.sleuthkit.autopsy.geolocation.datamodel.Route; import org.sleuthkit.datamodel.SleuthkitCase; import org.sleuthkit.autopsy.geolocation.datamodel.Waypoint; -import org.sleuthkit.autopsy.geolocation.datamodel.WaypointDetailsFormatter; import org.sleuthkit.autopsy.timeline.actions.ViewArtifactInTimelineAction; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -62,6 +63,8 @@ import org.sleuthkit.datamodel.TskCoreException; final class MapWaypoint extends KdTree.XYZPoint implements org.jxmapviewer.viewer.Waypoint { private static final Logger logger = Logger.getLogger(MapWaypoint.class.getName()); + private final static String HTML_PROP_FORMAT = "%s: %s
"; + static private final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX", Locale.US); private final Waypoint dataModelWaypoint; private final GeoPosition position; @@ -131,11 +134,9 @@ final class MapWaypoint extends KdTree.XYZPoint implements org.jxmapviewer.viewe * @return the image for this waypoint */ ImageIcon getImage() { - if (dataModelWaypoint.getImage() != null) { - if (ImageUtils.isImageThumbnailSupported(dataModelWaypoint.getImage())) { - BufferedImage buffImage = ImageUtils.getThumbnail(dataModelWaypoint.getImage(), 150); - return new ImageIcon(buffImage); - } + if (dataModelWaypoint.getImage() != null && ImageUtils.isImageThumbnailSupported(dataModelWaypoint.getImage())) { + BufferedImage buffImage = ImageUtils.getThumbnail(dataModelWaypoint.getImage(), 150); + return new ImageIcon(buffImage); } return null; @@ -164,7 +165,7 @@ final class MapWaypoint extends KdTree.XYZPoint implements org.jxmapviewer.viewe * @return HTML formatted string */ String getHTMLFormattedWaypointDetails() { - return WaypointDetailsFormatter.getFormattedDetails(dataModelWaypoint, null); + return getFormattedDetails(dataModelWaypoint); } /** @@ -247,6 +248,68 @@ final class MapWaypoint extends KdTree.XYZPoint implements org.jxmapviewer.viewe } return menuItems; } + + /** + * Get the nicely formatted details for the given waypoint. + * + * @param point Waypoint object + * @param header String details header + * + * @return HTML formatted String of details for given waypoint + */ + private String getFormattedDetails(Waypoint point) { + StringBuilder result = new StringBuilder(); //NON-NLS + + result.append("").append(formatAttribute("Name", point.getLabel())); + + Long timestamp = point.getTimestamp(); + if (timestamp != null) { + result.append(formatAttribute("Timestamp", getTimeStamp(timestamp))); + } + + result.append(formatAttribute("Latitude", point.getLatitude().toString())) + .append(formatAttribute("Longitude", point.getLongitude().toString())); + + if (point.getAltitude() != null) { + result.append(formatAttribute("Altitude", point.getAltitude().toString())); + } + + List list = point.getOtherProperties(); + for(Waypoint.Property prop: list) { + String value = prop.getValue(); + if(value != null && !value.isEmpty()) { + result.append(formatAttribute(prop.getDisplayName(), value)); + } + } + + result.append(""); + + return result.toString(); + } + + /** + * Format a title value pair. + * + * @param title Title of the property + * @param value Value of the property + * + * @return Formatted string with the title and value + */ + private String formatAttribute(String title, String value) { + return String.format(HTML_PROP_FORMAT, title, value); + } + + /** + * Format a point time stamp (in seconds) to the report format. + * + * @param timeStamp The timestamp in epoch seconds. + * + * @return The formatted timestamp + */ + private String getTimeStamp(long timeStamp) { + return DATE_FORMAT.format(new java.util.Date(timeStamp * 1000)); + } + /** * An action class for Extracting artifact files. diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/WaypointDetailPanel.java b/Core/src/org/sleuthkit/autopsy/geolocation/WaypointDetailPanel.java index 2217f5d24b..939ae81247 100755 --- a/Core/src/org/sleuthkit/autopsy/geolocation/WaypointDetailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/geolocation/WaypointDetailPanel.java @@ -113,7 +113,7 @@ final class WaypointDetailPanel extends JPanel { } popupMenu.show(this, point.x, point.y); } - + /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always diff --git a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointDetailsFormatter.java b/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointDetailsFormatter.java deleted file mode 100755 index ccb96d68b1..0000000000 --- a/Core/src/org/sleuthkit/autopsy/geolocation/datamodel/WaypointDetailsFormatter.java +++ /dev/null @@ -1,150 +0,0 @@ -/* - * 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.datamodel; - -import java.text.SimpleDateFormat; -import java.util.List; - -/** - * Common class for the KMLReport and the UI to generate HTML formatted - * waypoint details. - */ -public class WaypointDetailsFormatter { - private final static String HTML_PROP_FORMAT = "%s: %s
"; - - static private final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX"); - - /** - * Returns an HTML formatted string of all the - * - * @param route - * - * @return A HTML formatted list of the Route attributes - */ - - static public String getFormattedDetails(Route route, String header) { - List points = route.getRoute(); - StringBuilder result = new StringBuilder(); //NON-NLS - - result.append(""); - - if(header != null && !header.isEmpty()) { - result.append(String.format("

%s

", header)); - } - - result.append(formatAttribute("Name", route.getLabel())); - - Long timestamp = route.getTimestamp(); - if (timestamp != null) { - result.append(formatAttribute("Timestamp", getTimeStamp(timestamp))); - } - - if (points.size() > 1) { - Waypoint start = points.get(0); - Waypoint end = points.get(1); - - result.append(formatAttribute("Start Latitude", start.getLatitude().toString())) - .append(formatAttribute("Start Longitude", start.getLongitude().toString())); - - Double altitude = start.getAltitude(); - if(altitude != null) { - result.append(formatAttribute("Start Altitude", altitude.toString())); - } - - result.append(formatAttribute("End Latitude", end.getLatitude().toString())) - .append(formatAttribute("End Longitude", end.getLongitude().toString())); - - altitude = end.getAltitude(); - if(altitude != null) { - result.append(formatAttribute("End Altitude", altitude.toString())); - } - - result.append(""); - } - - List list = route.getOtherProperties(); - for(Waypoint.Property prop: list) { - String value = prop.getValue(); - if(value != null && !value.isEmpty()) { - result.append(formatAttribute(prop.getDisplayName(), value)); - } - } - - return result.toString(); - } - - /** - * Get the nicely formatted details for the given waypoint. - * - * @param point Waypoint object - * @param header String details header - * - * @return HTML formatted String of details for given waypoint - */ - static public String getFormattedDetails(Waypoint point, String header) { - StringBuilder result = new StringBuilder(); //NON-NLS - - result.append(""); - - if(header != null && !header.isEmpty()) { - result.append(String.format("

%s

", header)); - } - result.append(formatAttribute("Name", point.getLabel())); - - - Long timestamp = point.getTimestamp(); - if (timestamp != null) { - result.append(formatAttribute("Timestamp", getTimeStamp(timestamp))); - } - - result.append(formatAttribute("Latitude", point.getLatitude().toString())) - .append(formatAttribute("Longitude", point.getLongitude().toString())); - - if (point.getAltitude() != null) { - result.append(formatAttribute("Altitude", point.getAltitude().toString())); - } - - List list = point.getOtherProperties(); - for(Waypoint.Property prop: list) { - String value = prop.getValue(); - if(value != null && !value.isEmpty()) { - result.append(formatAttribute(prop.getDisplayName(), value)); - } - } - - result.append(""); - - return result.toString(); - } - - static private String formatAttribute(String title, String value) { - return String.format(HTML_PROP_FORMAT, title, value); - } - - /** - * Format a point time stamp (in seconds) to the report format. - * - * @param timeStamp The timestamp in epoch seconds. - * - * @return The formatted timestamp - */ - static private String getTimeStamp(long timeStamp) { - return dateFormat.format(new java.util.Date(timeStamp * 1000)); - } -}