1 package org.lcsim.util.aida;
2
3 import hep.aida.ref.plotter.Plotter;
4 import hep.aida.ref.plotter.PlotterUtilities;
5
6 import java.awt.BorderLayout;
7
8 import javax.swing.JFrame;
9 import javax.swing.JLabel;
10 import javax.swing.JPanel;
11 import javax.swing.JTabbedPane;
12
13
14
15
16
17
18
19 public class TabbedPlotter extends Plotter {
20
21 JTabbedPane tabbedPane;
22 JFrame frame;
23
24
25
26
27 public TabbedPlotter() {
28 super(null);
29 }
30
31
32
33
34
35 public TabbedPlotter(String name) {
36 super(name);
37 }
38
39
40
41
42
43
44 public void setTabbedPane(JTabbedPane tabbedPane) {
45 this.tabbedPane = tabbedPane;
46 }
47
48
49
50
51
52 public void setFrame(JFrame frame) {
53 this.frame = frame;
54 }
55
56
57
58
59
60 public void show() {
61 if (!isShowing()) {
62
63 addPlotterTab();
64 if (!frame.isVisible()) {
65
66 frame.setVisible(true);
67 }
68 }
69 }
70
71
72
73
74 private void addPlotterTab() {
75 String title = title();
76 if (title == null)
77 title = " ";
78 JPanel plotterPanel = new JPanel(new BorderLayout());
79 plotterPanel.add(PlotterUtilities.componentForPlotter(this), BorderLayout.CENTER);
80 tabbedPane.addTab(title, plotterPanel);
81 tabbedPane.setTabComponentAt(tabbedPane.getTabCount() - 1, new JLabel(title));
82 }
83 }