Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
ImageThumbnailViewer.java
Go to the documentation of this file.
1/*
2 * Autopsy
3 *
4 * Copyright 2019 Basis Technology Corp.
5 * Contact: carrier <at> sleuthkit <dot> org
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 */
19package org.sleuthkit.autopsy.discovery.ui;
20
21import java.util.ArrayList;
22import java.util.List;
23import javax.swing.DefaultListModel;
24import javax.swing.event.ListSelectionListener;
25import org.sleuthkit.autopsy.coreutils.ThreadConfined;
26import org.sleuthkit.datamodel.AbstractFile;
27
32final class ImageThumbnailViewer extends javax.swing.JPanel {
33
34 private static final long serialVersionUID = 1L;
35
36 private final DefaultListModel<ImageThumbnailWrapper> thumbnailListModel = new DefaultListModel<>();
37
41 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
42 ImageThumbnailViewer() {
43 initComponents();
44
45 }
46
52 @SuppressWarnings("unchecked")
53 // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
54 private void initComponents() {
55
56 thumbnailListScrollPane = new javax.swing.JScrollPane();
57 thumbnailList = new javax.swing.JList<>();
58
59 setLayout(new java.awt.BorderLayout());
60
61 thumbnailList.setModel(thumbnailListModel);
62 thumbnailList.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
63 thumbnailList.setCellRenderer(new ImageThumbnailPanel());
64 thumbnailList.setLayoutOrientation(javax.swing.JList.HORIZONTAL_WRAP);
65 thumbnailList.setVisibleRowCount(0);
66 thumbnailListScrollPane.setViewportView(thumbnailList);
67
68 add(thumbnailListScrollPane, java.awt.BorderLayout.CENTER);
69 }// </editor-fold>//GEN-END:initComponents
70
71
72 // Variables declaration - do not modify//GEN-BEGIN:variables
73 private javax.swing.JList<ImageThumbnailWrapper> thumbnailList;
74 private javax.swing.JScrollPane thumbnailListScrollPane;
75 // End of variables declaration//GEN-END:variables
76
82 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
83 void addListSelectionListener(ListSelectionListener listener) {
84 thumbnailList.getSelectionModel().addListSelectionListener(listener);
85 }
86
94 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
95 List<AbstractFile> getInstancesForSelected() {
96 if (thumbnailList.getSelectedIndex() == -1) {
97 return new ArrayList<>();
98 } else {
99 return thumbnailListModel.getElementAt(thumbnailList.getSelectedIndex()).getResultFile().getAllInstances();
100 }
101 }
102
106 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
107 void clearViewer() {
108 thumbnailListModel.removeAllElements();
109 thumbnailListScrollPane.getVerticalScrollBar().setValue(0);
110
111 }
112
119 @ThreadConfined(type = ThreadConfined.ThreadType.AWT)
120 void addImage(ImageThumbnailWrapper thumbnailWrapper) {
121 thumbnailListModel.addElement(thumbnailWrapper);
122 }
123}

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.