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.NbBundle;
35 public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellRenderer<ImageThumbnailWrapper> {
53 @SuppressWarnings(
"unchecked")
57 javax.swing.JPanel thumbnailPanel =
new javax.swing.JPanel();
66 thumbnailPanel.setToolTipText(
"");
67 thumbnailPanel.setLayout(
new java.awt.GridBagLayout());
68 thumbnailPanel.add(
thumbnailLabel,
new java.awt.GridBagConstraints());
73 nameLabel.setMaximumSize(
new java.awt.Dimension(159, 12));
74 nameLabel.setMinimumSize(
new java.awt.Dimension(159, 12));
75 nameLabel.setPreferredSize(
new java.awt.Dimension(159, 12));
77 isDeletedLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/file-icon-deleted.png")));
83 scoreLabel.setIcon(
new javax.swing.ImageIcon(getClass().getResource(
"/org/sleuthkit/autopsy/images/red-circle-exclamation.png")));
89 javax.swing.GroupLayout layout =
new javax.swing.GroupLayout(
this);
90 this.setLayout(layout);
91 layout.setHorizontalGroup(
92 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93 .addGroup(layout.createSequentialGroup()
95 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
96 .addGroup(layout.createSequentialGroup()
97 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
98 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
99 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
100 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
101 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
102 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING,
false)
103 .addComponent(
nameLabel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
104 .addComponent(thumbnailPanel, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)))
107 layout.setVerticalGroup(
108 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
109 .addGroup(layout.createSequentialGroup()
111 .addComponent(
nameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
112 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
113 .addComponent(thumbnailPanel, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)
114 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
115 .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
116 .addComponent(
scoreLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
117 .addComponent(
isDeletedLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
118 .addComponent(
fileSizeLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE))
133 "# {0} - otherInstanceCount",
134 "ImageThumbnailPanel.nameLabel.more.text= and {0} more",
135 "ImageThumbnailPanel.isDeleted.text=All instances of file are deleted."})
138 fileSizeLabel.setText(DiscoveryUiUtils.getFileSizeString(value.getResultFile().getFirstInstance().getSize()));
139 String nameText = value.getResultFile().getFirstInstance().getParentPath() + value.getResultFile().getFirstInstance().getName();
140 if (value.getResultFile().getAllInstances().size() > 1) {
141 nameText += Bundle.ImageThumbnailPanel_nameLabel_more_text(value.getResultFile().getAllInstances().size() - 1);
144 nameText =
"..." + nameText.substring(nameText.length() - (MAX_NAME_STRING - 3));
148 DiscoveryUiUtils.setDeletedIcon(value.getResultFile().isDeleted(),
isDeletedLabel);
149 DiscoveryUiUtils.setScoreIcon(value.getResultFile(),
scoreLabel);
150 setBackground(isSelected ? SELECTION_COLOR : list.getBackground());
159 Point point =
event.getPoint();
160 for (Component comp : getComponents()) {
161 if (DiscoveryUiUtils.isPointOnIcon(comp, point)) {
162 String toolTip = ((JComponent) comp).getToolTipText();
163 if (toolTip == null || toolTip.isEmpty()) {
static final int MAX_NAME_STRING
javax.swing.JLabel nameLabel
Component getListCellRendererComponent(JList<?extends ImageThumbnailWrapper > list, ImageThumbnailWrapper value, int index, boolean isSelected, boolean cellHasFocus)
javax.swing.JLabel fileSizeLabel
javax.swing.JLabel isDeletedLabel
String getToolTipText(MouseEvent event)
javax.swing.JLabel scoreLabel
static final Color SELECTION_COLOR
javax.swing.JLabel thumbnailLabel
static final long serialVersionUID