/Users/lyon/j4p/src/j2d/gui/HistogramEQToolbox.java

1    // Glenn Josefiak 
2    // Fairfield University 
3    // SW513 
4    // Spring 2003 
5     
6    package j2d.gui; 
7     
8    import gui.run.ObservableSlider; 
9     
10   import javax.swing.*; 
11   import java.awt.*; 
12   import java.awt.event.ActionEvent; 
13   import java.awt.event.ActionListener; 
14    
15   /** 
16    * A JInternalFrame containing controls for histogram 
17    * equalization. 
18    */ 
19   public class HistogramEQToolbox extends JInternalFrame { 
20       private JRadioButton rbtUniform; 
21       private JRadioButton rbtExponential; 
22       private ButtonGroup bgpOptions; 
23       private JPanel pnlOptions; 
24       private ObservableSlider sliAlpha; 
25       private boolean blnExponential; 
26       private JButton btnApply; 
27    
28       /** 
29        * Construct a new HistogramEQToolbox 
30        */ 
31       public HistogramEQToolbox() { 
32           Container c; 
33    
34           setTitle("Histogram EQ"); 
35    
36           rbtUniform = new JRadioButton("Uniform non-adaptive", true); 
37           rbtExponential = new JRadioButton("Exponential non-adaptive", false); 
38           bgpOptions = new ButtonGroup(); 
39           bgpOptions.add(rbtUniform); 
40           bgpOptions.add(rbtExponential); 
41           pnlOptions = new JPanel(new GridLayout(0, 1)); 
42           pnlOptions.add(rbtUniform); 
43           btnApply = new JButton("apply"); 
44           pnlOptions.add(btnApply); 
45           pnlOptions.add(rbtExponential); 
46    
47           sliAlpha = new ObservableSlider(0.001f, 10f); 
48           sliAlpha.setTickLabel(0.001f, "0.001"); 
49           sliAlpha.setTickLabel(1f, "1"); 
50           sliAlpha.setTickLabel(5f, "5"); 
51           sliAlpha.setTickLabel(10f, "10"); 
52           sliAlpha.setLabel("alpha"); 
53           sliAlpha.setEnabled(false); 
54           blnExponential = false; 
55    
56           c = getContentPane(); 
57           c.setLayout(new FlowLayout()); 
58           c.add(pnlOptions); 
59           c.add(sliAlpha); 
60    
61           rbtUniform.addActionListener(new ActionListener() { 
62               public void actionPerformed(ActionEvent e) { 
63                   sliAlpha.setEnabled(false); 
64                   btnApply.setEnabled(true); 
65                   blnExponential = false; 
66               } 
67           }); 
68           rbtExponential.addActionListener(new ActionListener() { 
69               public void actionPerformed(ActionEvent e) { 
70                   sliAlpha.setEnabled(true); 
71                   btnApply.setEnabled(false); 
72                   blnExponential = true; 
73               } 
74           }); 
75    
76           setMinimumSize(new Dimension(150, 150)); 
77           pack(); 
78           setClosable(true); 
79           setMaximizable(false); 
80           setResizable(false); 
81       } 
82    
83       /** 
84        * Return a handle to the Apply button on the control panel. 
85        * 
86        * @return A reference to a JButton 
87        */ 
88       public JButton getButton() { 
89           return btnApply; 
90       } 
91    
92       /** 
93        * Return a handle to the Alpha slider on the control panel. 
94        * 
95        * @return A reference to an ObservableSlider 
96        */ 
97       public ObservableSlider getSlider() { 
98           return sliAlpha; 
99       } 
100   
101      /** 
102       * Return the user's selection of exponential or linear 
103       * histogram EQ. 
104       * 
105       * @return True = exponential, false = linear 
106       */ 
107      public boolean getExponential() { 
108          return blnExponential; 
109      } 
110  } 
111