19 package org.sleuthkit.autopsy.filequery;
21 import java.awt.Component;
22 import java.awt.Point;
23 import javax.swing.ImageIcon;
24 import javax.swing.JComponent;
25 import org.openide.util.ImageUtilities;
26 import org.openide.util.NbBundle;
31 final class DiscoveryUiUtils {
33 private static final int BYTE_UNIT_CONVERSION = 1000;
34 private static final int ICON_SIZE = 16;
35 private static final String RED_CIRCLE_ICON_PATH =
"org/sleuthkit/autopsy/images/red-circle-exclamation.png";
36 private static final String YELLOW_CIRCLE_ICON_PATH =
"org/sleuthkit/autopsy/images/yellow-circle-yield.png";
37 private static final String DELETE_ICON_PATH =
"/org/sleuthkit/autopsy/images/file-icon-deleted.png";
38 private static final String UNSUPPORTED_DOC_PATH =
"/org/sleuthkit/autopsy/images/image-extraction-not-supported.png";
39 private static final ImageIcon INTERESTING_SCORE_ICON =
new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH,
false));
40 private static final ImageIcon NOTABLE_SCORE_ICON =
new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH,
false));
41 private static final ImageIcon DELETED_ICON =
new ImageIcon(ImageUtilities.loadImage(DELETE_ICON_PATH,
false));
42 private static final ImageIcon UNSUPPORTED_DOCUMENT_THUMBNAIL =
new ImageIcon(ImageUtilities.loadImage(UNSUPPORTED_DOC_PATH,
false));
44 @NbBundle.Messages({
"# {0} - fileSize",
46 "DiscoveryUiUtility.sizeLabel.text=Size: {0} {1}",
47 "DiscoveryUiUtility.bytes.text=bytes",
48 "DiscoveryUiUtility.kiloBytes.text=KB",
49 "DiscoveryUiUtility.megaBytes.text=MB",
50 "DiscoveryUiUtility.gigaBytes.text=GB",
51 "DiscoveryUiUtility.terraBytes.text=TB"})
60 static String getFileSizeString(
long bytes) {
62 int unitsSwitchValue = 0;
63 while (size > BYTE_UNIT_CONVERSION && unitsSwitchValue < 4) {
64 size /= BYTE_UNIT_CONVERSION;
68 switch (unitsSwitchValue) {
70 units = Bundle.DiscoveryUiUtility_kiloBytes_text();
73 units = Bundle.DiscoveryUiUtility_megaBytes_text();
76 units = Bundle.DiscoveryUiUtility_gigaBytes_text();
79 units = Bundle.DiscoveryUiUtility_terraBytes_text();
82 units = Bundle.DiscoveryUiUtility_bytes_text();
85 return Bundle.DiscoveryUiUtility_sizeLabel_text(size, units);
94 static ImageIcon getUnsupportedImageThumbnail() {
95 return UNSUPPORTED_DOCUMENT_THUMBNAIL;
106 static boolean isPointOnIcon(Component comp, Point point) {
107 return comp instanceof JComponent && point.x >= comp.getX() && point.x <= comp.getX() + ICON_SIZE && point.y >= comp.getY() && point.y <= comp.getY() + ICON_SIZE;
118 static void setDeletedIcon(
boolean isDeleted, javax.swing.JLabel isDeletedLabel) {
120 isDeletedLabel.setIcon(DELETED_ICON);
121 isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text());
123 isDeletedLabel.setIcon(null);
124 isDeletedLabel.setToolTipText(null);
135 static void setScoreIcon(ResultFile resultFile, javax.swing.JLabel scoreLabel) {
136 switch (resultFile.getScore()) {
138 scoreLabel.setIcon(NOTABLE_SCORE_ICON);
140 case INTERESTING_SCORE:
141 scoreLabel.setIcon(INTERESTING_SCORE_ICON);
145 scoreLabel.setIcon(null);
148 scoreLabel.setToolTipText(resultFile.getScoreDescription());
156 static int getIconSize() {
163 private DiscoveryUiUtils() {