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 if (content instanceof AbstractFile) {
227 menuItems.add(DeleteFileContentTagAction.getInstance().getMenuForFiles(Arrays.asList((AbstractFile) content)));
229 menuItems.add(DeleteFileBlackboardArtifactTagAction.getInstance().getMenuForArtifacts(Arrays.asList(artifact)));
231 return menuItems.toArray(
new JMenuItem[0]);
242 List<JMenuItem> menuItems =
new ArrayList<>();
248 }
catch (TskCoreException ex) {
249 logger.log(Level.SEVERE, String.format(
"Error getting arttribute(s) from blackboard artifact %d.", artifact.getArtifactID()), ex);
266 "MayWaypoint_ExternalViewer_label=Open in ExternalViewer"
269 List<JMenuItem> menuItems =
new ArrayList<>();
272 for (Action action : actions) {
273 if (action == null) {
278 menuItems.add(((AddContentTagAction) action).getMenuForContent(Arrays.asList((AbstractFile) content)));
280 menuItems.add(((AddBlackboardArtifactTagAction) action).getMenuForContent(Arrays.asList(artifact)));
284 menuItems.add(
new JMenuItem(newAction));
286 menuItems.add(
new JMenuItem(
new WaypointExtractAction((AbstractFile) content)));
288 menuItems.add(
new JMenuItem(action));
302 StringBuilder result =
new StringBuilder();
304 result.append(
"<html>").append(formatAttribute(
"Name", point.
getLabel()));
307 if (timestamp != null) {
308 result.append(formatAttribute(
"Timestamp", getTimeStamp(timestamp)));
311 result.append(formatAttribute(
"Latitude", point.
getLatitude().toString()))
312 .append(formatAttribute(
"Longitude", point.
getLongitude().toString()));
315 result.append(formatAttribute(
"Altitude", point.
getAltitude().toString()));
319 for (Waypoint.Property prop : list) {
320 String value = prop.getValue();
321 if (value != null && !value.isEmpty()) {
322 result.append(formatAttribute(prop.getDisplayName(), value));
326 result.append(
"</html>");
328 return result.toString();
340 return String.format(HTML_PROP_FORMAT, title, value);
351 return DATE_FORMAT.format(
new java.util.Date(timeStamp * 1000));
358 static Color getColor(
int artifactTypeId) {
359 return artifactTypesToColors.getOrDefault(artifactTypeId, Color.GRAY);
367 return getColor(dataModelWaypoint.
getArtifact().getArtifactTypeID());
381 "WaypointExtractAction_label=Extract Files(s)"
383 final class WaypointExtractAction extends AbstractAction {
385 private static final long serialVersionUID = 1L;
386 final private AbstractFile file;
388 WaypointExtractAction(AbstractFile file) {
389 super(Bundle.WaypointExtractAction_label());
394 public void actionPerformed(ActionEvent e) {
395 ExtractActionHelper helper =
new ExtractActionHelper();
396 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)