Autopsy  4.13.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  Font font = tabLabel.getFont().deriveFont(18).deriveFont(Font.BOLD);
68  tabLabel.setFont(font);
69 
70  addTab(null, panel);
71  setTabComponentAt(0, tabLabel);
72 
73  this.addMouseListener(new MouseAdapter() {
74  @Override
75  public void mouseClicked(MouseEvent evt) {
76  handleMouseClick(evt.getPoint());
77  }
78  });
79 
80  this.setTabPlacement(JTabbedPane.RIGHT);
81  }
82 
88  void setTitle(String title) {
89  tabLabel.setText(title);
90  }
91 
97  void setIcon(Icon icon) {
98  tabLabel.setIcon(icon);
99  }
100 
106  void setPanel(JPanel panel) {
107  scrollPane.setViewportView(panel);
108  }
109 
115  private void handleMouseClick(Point point) {
116  int index = indexAtLocation(point.x, point.y);
117 
118  if(index == -1) {
119  return;
120  }
121 
122  if(panelVisible) {
123  panel.removeAll();
124  panel.revalidate();
125  panelVisible = false;
126  } else {
127  panel.add(scrollPane, BorderLayout.CENTER);
128  panel.revalidate();
129  panelVisible = true;
130  }
131  }
132 
133 }

Copyright © 2012-2019 Basis Technology. Generated on: Tue Jan 7 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.