19 package org.sleuthkit.autopsy.filequery;
21 import java.awt.Color;
22 import java.awt.Component;
23 import java.awt.Dimension;
24 import java.awt.Point;
25 import java.awt.event.MouseEvent;
26 import javax.swing.ImageIcon;
27 import javax.swing.JComponent;
28 import javax.swing.JList;
29 import javax.swing.ListCellRenderer;
30 import org.openide.util.ImageUtilities;
31 import org.openide.util.NbBundle;
36 public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellRenderer<ImageThumbnailWrapper> {
42 private static final String
RED_CIRCLE_ICON_PATH =
"org/sleuthkit/autopsy/images/red-circle-exclamation.png";
44 private static final String
DELETE_ICON_PATH =
"/org/sleuthkit/autopsy/images/file-icon-deleted.png";
45 private static final ImageIcon
INTERESTING_SCORE_ICON =
new ImageIcon(ImageUtilities.loadImage(YELLOW_CIRCLE_ICON_PATH,
false));
46 private static final ImageIcon
NOTABLE_SCORE_ICON =
new ImageIcon(ImageUtilities.loadImage(RED_CIRCLE_ICON_PATH,
false));
47 private static final ImageIcon
DELETED_ICON =
new ImageIcon(ImageUtilities.loadImage(DELETE_ICON_PATH,
false));
61 @SuppressWarnings(
"unchecked")
65 javax.swing.JPanel thumbnailPanel =
new javax.swing.JPanel();
74 thumbnailPanel.setToolTipText(
"");
75 thumbnailPanel.setLayout(
new java.awt.GridBagLayout());
76 thumbnailPanel.add(
thumbnailLabel,
new java.awt.GridBagConstraints());
81 countLabel.setMaximumSize(
new java.awt.Dimension(159, 12));
82 countLabel.setMinimumSize(
new java.awt.Dimension(159, 12));
83 countLabel.setPreferredSize(
new java.awt.Dimension(159, 12));
85 isDeletedLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/file-icon-deleted.png")));
89 isDeletedLabel.setPreferredSize(
new Dimension(ICON_SIZE,ICON_SIZE));
91 scoreLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/red-circle-exclamation.png")));
93 scoreLabel.setMaximumSize(
new Dimension(ICON_SIZE,ICON_SIZE));
94 scoreLabel.setMinimumSize(
new Dimension(ICON_SIZE,ICON_SIZE));
95 scoreLabel.setPreferredSize(
new Dimension(ICON_SIZE,ICON_SIZE));
97 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
98 this.setLayout(layout);
99 layout.setHorizontalGroup(
100 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
101 .addGroup(layout.createSequentialGroup()
103 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
104 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING,
false)
105 .addComponent(thumbnailPanel, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
106 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
107 .addGroup(layout.createSequentialGroup()
108 .addComponent(
countLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
109 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
110 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
111 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
112 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
115 layout.setVerticalGroup(
116 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
117 .addGroup(layout.createSequentialGroup()
119 .addComponent(thumbnailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
120 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
121 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
122 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
123 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
124 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
125 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
126 .addComponent(
countLabel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
141 "# {0} - numberOfInstances",
142 "ImageThumbnailPanel.countLabel.text=Number of Instances: {0}",
143 "ImageThumbnailPanel.isDeleted.text=All instances of file are deleted."})
147 countLabel.setText(Bundle.ImageThumbnailPanel_countLabel_text(value.getResultFile().getAllInstances().size()));
149 if (value.getResultFile().isDeleted()) {
151 isDeletedLabel.setToolTipText(Bundle.ImageThumbnailPanel_isDeleted_text());
156 switch (value.getResultFile().getScore()) {
160 case INTERESTING_SCORE:
168 scoreLabel.setToolTipText(value.getResultFile().getScoreDescription());
169 setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
174 @NbBundle.Messages({
"# {0} - fileSize",
176 "ImageThumbnailPanel.sizeLabel.text=Size: {0} {1}",
177 "ImageThumbnailPanel.bytes.text=bytes",
178 "ImageThumbnailPanel.kiloBytes.text=KB",
179 "ImageThumbnailPanel.megaBytes.text=MB",
180 "ImageThumbnailPanel.gigaBytes.text=GB",
181 "ImageThumbnailPanel.terraBytes.text=TB"})
192 int unitsSwitchValue = 0;
193 while (size > BYTE_UNIT_CONVERSION && unitsSwitchValue < 4) {
198 switch (unitsSwitchValue) {
200 units = Bundle.ImageThumbnailPanel_kiloBytes_text();
203 units = Bundle.ImageThumbnailPanel_megaBytes_text();
206 units = Bundle.ImageThumbnailPanel_gigaBytes_text();
209 units = Bundle.ImageThumbnailPanel_terraBytes_text();
212 units = Bundle.ImageThumbnailPanel_bytes_text();
215 return Bundle.ImageThumbnailPanel_sizeLabel_text(size, units);
222 Point point =
event.getPoint();
223 for (Component comp : getComponents()) {
225 String toolTip = ((JComponent) comp).getToolTipText();
226 if (toolTip == null || toolTip.isEmpty()) {
246 return comp instanceof JComponent && point.x >= comp.getX() && point.x <= comp.getX() + ICON_SIZE && point.y >= comp.getY() && point.y <= comp.getY() +
ICON_SIZE;
Component getListCellRendererComponent(JList<?extends ImageThumbnailWrapper > list, ImageThumbnailWrapper value, int index, boolean isSelected, boolean cellHasFocus)
static final String DELETE_ICON_PATH
javax.swing.JLabel fileSizeLabel
static final int ICON_SIZE
static final int BYTE_UNIT_CONVERSION
boolean isPointOnIcon(Component comp, Point point)
javax.swing.JLabel isDeletedLabel
String getToolTipText(MouseEvent event)
javax.swing.JLabel scoreLabel
static final String YELLOW_CIRCLE_ICON_PATH
static final Color SELECTION_COLOR
static final String RED_CIRCLE_ICON_PATH
javax.swing.JLabel thumbnailLabel
String getFileSizeString(long bytes)
static final ImageIcon DELETED_ICON
javax.swing.JLabel countLabel
static final long serialVersionUID
static final ImageIcon INTERESTING_SCORE_ICON
static final ImageIcon NOTABLE_SCORE_ICON