/Users/lyon/j4p/src/j2d/ImageTabbedPane.java

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Mar 3, 2003 
5     * Time: 6:17:06 PM 
6     */ 
7    package j2d; 
8     
9    import j2d.animation.AnimationPanel; 
10   import j2d.color.ColorSpacePanel; 
11   import j2d.color.ColorizerPanel; 
12   import j2d.edge.*; 
13   import j2d.hpp.*; 
14   import j2d.filters.GaussianPanel; 
15    
16   import javax.swing.*; 
17   import java.awt.*; 
18    
19   import utils.StringUtils; 
20    
21   public class ImageTabbedPane extends JTabbedPane { 
22       ImageProcessListener ipl = null; 
23    
24       public static void addTab(JTabbedPane jtp, 
25                                 String title, 
26                                 Icon icon, Component component) { 
27           int i1 = title.indexOf('['); 
28           if (i1 == -1) { 
29               (jtp).addTab(title, icon, component); 
30               return; 
31           } 
32    
33           String newTitle = StringUtils.replaceFirstInstance( 
34                   title, "[", ""); 
35           addTab(jtp, newTitle, icon, component); 
36           int location = jtp.getTabCount(); 
37           jtp.setMnemonicAt(location, title.charAt(i1 + 1)); 
38       } 
39    
40    
41       public JFrame getFrame() { 
42           Container c = this.getParent(); 
43           while (c != null && !(c instanceof JFrame)) { 
44               c = this.getParent(); 
45           } 
46           if (c == null) return null; 
47           return (JFrame) c; 
48       } 
49    
50       public ImageTabbedPane(ImageProcessListener _ipl) { 
51           ipl = _ipl; 
52    
53           addTab(this, "FilePanel", null, 
54                   new FilePanel(ipl)); 
55           addTab(this, "Animation", null, 
56                   new AnimationPanel(ipl)); 
57    
58           addTab(this, "Gaussian", null, 
59                   new GaussianPanel(ipl)); 
60           addTab(this, "Hpp", null, 
61                   getHppPane()); 
62           addTab(this, "Edge", null, 
63                   getEdgePane()); 
64       } 
65    
66    
67       public JTabbedPane getEdgePane() { 
68           JTabbedPane jtp = new JTabbedPane(); 
69           jtp.addTab("MagDOG", null, 
70                   new MagDOGPanel(ipl)); 
71           jtp.addTab("SobelPanel", null, 
72                   new SobelPanel(ipl)); 
73           jtp.addTab("LoGSobelPanel", null, 
74                   new LoGSobelPanel(ipl)); 
75           jtp.addTab("LoGPanel", null, 
76                   new LoGPanel(ipl)); 
77           jtp.addTab("MehrotraAndZhangPanel", null, 
78                   new MehrotraAndZhangPanel(ipl)); 
79    
80           jtp.addTab("Canny", null, 
81                   new CannyPanel(ipl)); 
82           jtp.addTab("Threshold", null, 
83                   new ThresholdPanel(ipl)); 
84           jtp.addTab("TemplatePanel", null, 
85                   new TemplatePanel(ipl)); 
86           return jtp; 
87       } 
88    
89       public JTabbedPane getHppPane() { 
90           JTabbedPane jtp = new JTabbedPane(); 
91           jtp.addTab("ColorizerPanel", null, 
92                   new ColorizerPanel(ipl)); 
93           jtp.addTab("ColorSpacePanel", null, 
94                   new ColorSpacePanel(ipl)); 
95           jtp.addTab("ContrastPanel", null, 
96                   new ContrastPanel(ipl)); 
97           jtp.addTab("GreyHppFilter3Panel", null, 
98                   new GreyHppFilter3Panel(ipl)); 
99           jtp.addTab("ThresholdFilter3Panel", null, 
100                  new ThresholdFilter3Panel(ipl)); 
101          jtp.addTab("HistogramPanel", null, 
102                  new HistogramPanel(ipl)); 
103   
104          return jtp; 
105      } 
106  } 
107