19 package org.sleuthkit.autopsy.geolocation;
21 import java.awt.Color;
22 import java.awt.event.ActionEvent;
23 import java.awt.image.BufferedImage;
24 import java.text.SimpleDateFormat;
25 import java.util.ArrayList;
26 import java.util.Arrays;
27 import java.util.HashMap;
28 import java.util.LinkedHashSet;
29 import java.util.List;
30 import java.util.Locale;
33 import java.util.logging.Level;
34 import javax.swing.AbstractAction;
35 import javax.swing.Action;
36 import javax.swing.ImageIcon;
37 import javax.swing.JMenuItem;
38 import org.jxmapviewer.viewer.GeoPosition;
39 import org.openide.util.NbBundle.Messages;
65 @SuppressWarnings(
"deprecation")
69 private final static String HTML_PROP_FORMAT =
"<b>%s: </b>%s<br>";
70 static private final SimpleDateFormat DATE_FORMAT =
new SimpleDateFormat(
"yyyy-MM-dd'T'HH:mm:ssX", Locale.US);
72 private static final Map<Integer, Color> artifactTypesToColors =
new HashMap<>();
75 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_BOOKMARK.getTypeID(), Color.BLUE);
76 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_LAST_KNOWN_LOCATION.getTypeID(), Color.RED);
77 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_ROUTE.getTypeID(), Color.CYAN);
78 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_SEARCH.getTypeID(), Color.GREEN);
79 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACK.getTypeID(), Color.ORANGE);
80 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_TRACKPOINT.getTypeID(), Color.ORANGE);
81 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF.getTypeID(), Color.MAGENTA);
82 artifactTypesToColors.put(BlackboardArtifact.ARTIFACT_TYPE.TSK_GPS_AREA.getTypeID(),
new Color(0x8a2be2));
97 static Set<MapWaypoint> getWaypoints(List<Waypoint> dmWaypoints) {
98 Set<MapWaypoint> mapPoints =
new LinkedHashSet<>();
100 if (dmWaypoints != null) {
102 for (Waypoint point : dmWaypoints) {
119 static List<Waypoint> getDataModelWaypoints(List<MapWaypoint> mapWaypoints) {
120 List<Waypoint> waypoints =
new ArrayList<>();
122 if (mapWaypoints != null) {
124 waypoints.add(point.dataModelWaypoint);
138 static MapWaypoint getDummyWaypoint(GeoPosition position) {
139 return new MapWaypoint(position);
149 this.dataModelWaypoint = dataModelWaypoint;
150 position =
new GeoPosition(dataModelWaypoint.getLatitude(), dataModelWaypoint.getLongitude());
159 super(position.getLatitude(), position.getLongitude());
160 dataModelWaypoint = null;
161 this.position = position;
169 ImageIcon getImage() {
172 return new ImageIcon(buffImage);
192 return dataModelWaypoint.
getLabel();
200 String getHTMLFormattedWaypointDetails() {
201 return getFormattedDetails(dataModelWaypoint);
207 int getArtifactTypeID() {
208 return dataModelWaypoint.
getArtifact().getArtifactTypeID();
219 JMenuItem[] getMenuItems() throws TskCoreException {
220 List<JMenuItem> menuItems =
new ArrayList<>();
221 BlackboardArtifact artifact = dataModelWaypoint.
getArtifact();
222 Content content = dataModelWaypoint.
getContent();
224 menuItems.addAll(getTimelineMenuItems(dataModelWaypoint.
getArtifact()));
225 menuItems.addAll(getDataModelActionFactoryMenuItems(artifact, content));
226 menuItems.add(DeleteFileContentTagAction.getInstance().getMenuForFiles(Arrays.asList((AbstractFile) content)));
227 menuItems.add(DeleteFileBlackboardArtifactTagAction.getInstance().getMenuForArtifacts(Arrays.asList(artifact)));
229 return menuItems.toArray(
new JMenuItem[0]);
240 List<JMenuItem> menuItems =
new ArrayList<>();
246 }
catch (TskCoreException ex) {
247 logger.log(Level.SEVERE, String.format(
"Error getting arttribute(s) from blackboard artifact %d.", artifact.getArtifactID()), ex);
264 "MayWaypoint_ExternalViewer_label=Open in ExternalViewer"
267 List<JMenuItem> menuItems =
new ArrayList<>();
270 for (Action action : actions) {
271 if (action == null) {
276 menuItems.add(((AddContentTagAction) action).getMenuForContent(Arrays.asList((AbstractFile) content)));
278 menuItems.add(((AddBlackboardArtifactTagAction) action).getMenuForContent(Arrays.asList(artifact)));
282 menuItems.add(
new JMenuItem(newAction));
284 menuItems.add(
new JMenuItem(
new WaypointExtractAction((AbstractFile) content)));
286 menuItems.add(
new JMenuItem(action));
300 StringBuilder result =
new StringBuilder();
302 result.append(
"<html>").append(formatAttribute(
"Name", point.
getLabel()));
305 if (timestamp != null) {
306 result.append(formatAttribute(
"Timestamp", getTimeStamp(timestamp)));
309 result.append(formatAttribute(
"Latitude", point.
getLatitude().toString()))
310 .append(formatAttribute(
"Longitude", point.
getLongitude().toString()));
313 result.append(formatAttribute(
"Altitude", point.
getAltitude().toString()));
317 for (Waypoint.Property prop : list) {
318 String value = prop.getValue();
319 if (value != null && !value.isEmpty()) {
320 result.append(formatAttribute(prop.getDisplayName(), value));
324 result.append(
"</html>");
326 return result.toString();
338 return String.format(HTML_PROP_FORMAT, title, value);
349 return DATE_FORMAT.format(
new java.util.Date(timeStamp * 1000));
356 static Color getColor(
int artifactTypeId) {
357 return artifactTypesToColors.getOrDefault(artifactTypeId, Color.GRAY);
365 return getColor(dataModelWaypoint.
getArtifact().getArtifactTypeID());
379 "WaypointExtractAction_label=Extract Files(s)"
381 final class WaypointExtractAction extends AbstractAction {
383 private static final long serialVersionUID = 1L;
384 final private AbstractFile file;
386 WaypointExtractAction(AbstractFile file) {
387 super(Bundle.WaypointExtractAction_label());
392 public void actionPerformed(ActionEvent e) {
393 ExtractActionHelper helper =
new ExtractActionHelper();
394 helper.extract(e, Arrays.asList(file));
final Waypoint dataModelWaypoint
String getFormattedDetails(Waypoint point)
static boolean hasSupportedTimeStamp(BlackboardArtifact artifact)
List< Waypoint.Property > getOtherProperties()
static List< Action > getActions(File file, boolean isArtifactSource)
String formatAttribute(String title, String value)
List< JMenuItem > getDataModelActionFactoryMenuItems(BlackboardArtifact artifact, Content content)
final GeoPosition position
BlackboardArtifact getArtifact()
String getTimeStamp(long timeStamp)
List< JMenuItem > getTimelineMenuItems(BlackboardArtifact artifact)
synchronized static Logger getLogger(String name)
static boolean isImageThumbnailSupported(AbstractFile file)
static BufferedImage getThumbnail(Content content, int iconSize)
MapWaypoint(GeoPosition position)
GeoPosition getPosition()
MapWaypoint(Waypoint dataModelWaypoint)