Autopsy  4.21.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
HidingPane.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
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  */
19 package org.sleuthkit.autopsy.geolocation;
20 
21 import java.awt.BorderLayout;
22 import java.awt.Font;
23 import java.awt.Point;
24 import java.awt.event.MouseAdapter;
25 import java.awt.event.MouseEvent;
26 import javax.swing.Icon;
27 import javax.swing.JLabel;
28 import javax.swing.JPanel;
29 import javax.swing.JScrollPane;
30 import javax.swing.JTabbedPane;
31 import org.openide.util.NbBundle.Messages;
32 
40 public final class HidingPane extends JTabbedPane {
41 
42  private static final long serialVersionUID = 1L;
43 
44  private final JScrollPane scrollPane;
45  private final JPanel panel;
46  private final JLabel tabLabel;
47 
48  private boolean panelVisible = true;
49 
53  @Messages({
54  "HidingPane_default_title=Filters"
55  })
56  public HidingPane() {
57  super();
58 
59  scrollPane = new JScrollPane();
60  panel = new JPanel();
61  panel.setLayout(new BorderLayout());
62  panel.add(scrollPane, BorderLayout.CENTER);
63  tabLabel = new JLabel(Bundle.HidingPane_default_title());
64  tabLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/sleuthkit/autopsy/images/funnel.png")));
65  tabLabel.setUI(new VerticalLabelUI(true));
66  tabLabel.setOpaque(false);
67  tabLabel.setFont(tabLabel.getFont().deriveFont(Font.BOLD, tabLabel.getFont().getSize()+7));
68 
69  addTab(null, panel);
70  setTabComponentAt(0, tabLabel);
71 
72  this.addMouseListener(new MouseAdapter() {
73  @Override
74  public void mouseClicked(MouseEvent evt) {
75  handleMouseClick(evt.getPoint());
76  }
77  });
78 
79  this.setTabPlacement(JTabbedPane.RIGHT);
80  }
81 
87  void setTitle(String title) {
88  tabLabel.setText(title);
89  }
90 
96  void setIcon(Icon icon) {
97  tabLabel.setIcon(icon);
98  }
99 
105  void setPanel(JPanel panel) {
106  scrollPane.setViewportView(panel);
107  }
108 
114  private void handleMouseClick(Point point) {
115  int index = indexAtLocation(point.x, point.y);
116 
117  if(index == -1) {
118  return;
119  }
120 
121  if(panelVisible) {
122  panel.removeAll();
123  panel.revalidate();
124  panelVisible = false;
125  } else {
126  panel.add(scrollPane, BorderLayout.CENTER);
127  panel.revalidate();
128  panelVisible = true;
129  }
130  }
131 
132 }

Copyright © 2012-2022 Basis Technology. Generated on: Tue Feb 6 2024
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.