/Users/lyon/j4p/src/j2d/edge/MagDOGPanel.java

1    package j2d.edge; 
2     
3    import gui.run.RunButton; 
4    import gui.run.RunSlider; 
5    import j2d.ImageProcessListener; 
6     
7    import javax.swing.*; 
8    import java.awt.*; 
9     
10    
11   public class MagDOGPanel extends JPanel { 
12    
13    
14       private int widGaussianKernel = 15; 
15       private double sigma = 2.0; 
16    
17       ImageProcessListener ipl = null; 
18    
19       /**Construct the frame*/ 
20       public MagDOGPanel(ImageProcessListener _ipl) { 
21           ipl = _ipl; 
22           initGuiElements(); 
23    
24       } 
25    
26       /**Component initialization*/ 
27       private void initGuiElements() { 
28           setLayout(new FlowLayout()); 
29    
30           add(new RunButton("apply") { 
31               public void run() { 
32                   updateImage(); 
33               } 
34           }); 
35           add(new RunButton("Reset") { 
36               public void run() { 
37                   ipl.update(null); 
38               } 
39           }); 
40           add(new JLabel("kernel width")); 
41           add(new RunSlider(3, 40, 15) { 
42               public void run() { 
43                   widGaussianKernel = getValue(); 
44                   updateImage(); 
45               } 
46           }); 
47           add(new JLabel("sigma")); 
48           add(new RunSlider(1, 9) { 
49               public void run() { 
50                   sigma = getValue(); 
51                   updateImage(); 
52               } 
53           }); 
54       } 
55    
56       public void updateImage() { 
57           ipl.update(new MagDOGProcessor( 
58                   widGaussianKernel, 
59                   sigma 
60           )); 
61       } 
62    
63    
64   } 
65