6160: Dot rendering

This commit is contained in:
Ethan Roseman 2020-04-13 15:37:19 -04:00
parent 45d98486dc
commit 3be19e717e
2 changed files with 47 additions and 5 deletions

View File

@ -19,11 +19,13 @@
package org.sleuthkit.autopsy.geolocation; package org.sleuthkit.autopsy.geolocation;
import java.awt.AlphaComposite; import java.awt.AlphaComposite;
import java.awt.BasicStroke;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Point; import java.awt.Point;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ComponentAdapter; import java.awt.event.ComponentAdapter;
@ -71,6 +73,7 @@ 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 javax.swing.SwingUtilities;
import org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE;
/** /**
* The map panel. This panel contains the jxmapviewer MapViewer * The map panel. This panel contains the jxmapviewer MapViewer
@ -691,7 +694,8 @@ final public class MapPanel extends javax.swing.JPanel {
*/ */
private class MapWaypointRenderer implements WaypointRenderer<MapWaypoint> { private class MapWaypointRenderer implements WaypointRenderer<MapWaypoint> {
private final Map<Color, BufferedImage> imageCache = new HashMap<>(); private final Map<Color, BufferedImage> dotImageCache = new HashMap<>();
private final Map<Color, BufferedImage> waypointImageCache = new HashMap<>();
/** /**
* *
@ -710,6 +714,28 @@ final public class MapPanel extends javax.swing.JPanel {
} }
} }
/**
* Creates a dot image with the specified color
*
* @param color the color of the new image
* @return the new dot image
*/
private BufferedImage createTrackDotImage(Color color) {
int w = 10;
int h = 10;
BufferedImage ret = new BufferedImage(w + 2, h + 2, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = ret.createGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(color);
g.fillOval(1, 1, w, h);
g.setColor(Color.BLACK);
g.setStroke(new BasicStroke(1));
g.drawOval(1, 1, w, h);
g.dispose();
return ret;
}
/** /**
* Creates a waypoint image with the specified color * Creates a waypoint image with the specified color
* *
@ -736,11 +762,20 @@ final public class MapPanel extends javax.swing.JPanel {
@Override @Override
public void paintWaypoint(Graphics2D gd, JXMapViewer jxmv, MapWaypoint waypoint) { public void paintWaypoint(Graphics2D gd, JXMapViewer jxmv, MapWaypoint waypoint) {
Color color = getColor(waypoint, currentlySelectedWaypoint); Color color = getColor(waypoint, currentlySelectedWaypoint);
BufferedImage image;
int artifactType = waypoint.getArtifactTypeID();
if (artifactType == ARTIFACT_TYPE.TSK_GPS_TRACKPOINT.getTypeID() ||
artifactType == ARTIFACT_TYPE.TSK_GPS_TRACK.getTypeID()) {
image = dotImageCache.computeIfAbsent(color, k -> {
return createTrackDotImage(color);
});
} else {
// Store computed images in cache for later use // Store computed images in cache for later use
BufferedImage image = imageCache.computeIfAbsent(color, k -> { image = waypointImageCache.computeIfAbsent(color, k -> {
return createWaypointImage(color); return createWaypointImage(color);
}); });
}
Point2D point = jxmv.getTileFactory().geoToPixel(waypoint.getPosition(), jxmv.getZoom()); Point2D point = jxmv.getTileFactory().geoToPixel(waypoint.getPosition(), jxmv.getZoom());

View File

@ -199,6 +199,13 @@ final class MapWaypoint extends KdTree.XYZPoint implements org.jxmapviewer.viewe
return getFormattedDetails(dataModelWaypoint); return getFormattedDetails(dataModelWaypoint);
} }
/**
* Returns the artifact type for this waypoint's data source
*/
int getArtifactTypeID() {
return dataModelWaypoint.getArtifact().getArtifactTypeID();
}
/** /**
* Returns a list of JMenuItems for the waypoint. The list list may contain * Returns a list of JMenuItems for the waypoint. The list list may contain
* nulls which should be removed or replaced with JSeparators. * nulls which should be removed or replaced with JSeparators.