/Users/lyon/j4p/src/j2d/hpp/ContrastPanel.java

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Mar 2, 2003 
5     * Time: 5:12:56 PM 
6     */ 
7    package j2d.hpp; 
8     
9    import gui.run.RunSlider; 
10   import j2d.ImageProcessListener; 
11    
12   import javax.swing.*; 
13   import java.awt.*; 
14    
15   public class ContrastPanel 
16           extends JPanel { 
17       private double c = 1; 
18       private double b = 0; 
19       ImageProcessListener ipl = null; 
20    
21    
22       public ContrastPanel(ImageProcessListener _ipl) { 
23           ipl = _ipl; 
24    
25           setLayout(new FlowLayout()); 
26           add(new RunSlider(0, 100) { 
27               public void run() { 
28                   c = getValue(); 
29                   updateImage(); 
30               } 
31           }); 
32           add(new RunSlider(-255, 255) { 
33               public void run() { 
34                   b = getValue(); 
35                   updateImage(); 
36               } 
37           }); 
38    
39       } 
40    
41       private void updateImage() { 
42           ContrastFilter cf = new ContrastFilter(c, b); 
43           ipl.update(new HppFilterImageProcessor(cf)); 
44    
45       } 
46    
47   } 
48