/Users/lyon/j4p/src/j2d/color/ColorizerPanel.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.color; 
8     
9    import gui.run.RunSlider; 
10   import j2d.ImageProcessListener; 
11   import j2d.hpp.HppFilterImageProcessor; 
12    
13   import javax.swing.*; 
14   import java.awt.*; 
15    
16    
17   public class ColorizerPanel 
18           extends JPanel { 
19       private double ar = 0.01; 
20       private double ag = 0.01; 
21       private double ab = 0.01; 
22       ImageProcessListener ipl = null; 
23    
24    
25       public ColorizerPanel(ImageProcessListener _ipl) { 
26           ipl = _ipl; 
27    
28           setLayout(new FlowLayout()); 
29           add(new RunSlider() { 
30               public void run() { 
31                   ar = scaleSlider(getValue()); 
32                   updateImage(); 
33               } 
34           }); 
35           add(new RunSlider() { 
36               public void run() { 
37                   ag = scaleSlider(getValue()); 
38                   updateImage(); 
39               } 
40           }); 
41           add(new RunSlider() { 
42               public void run() { 
43                   ab = scaleSlider(getValue()); 
44                   updateImage(); 
45               } 
46           }); 
47       } 
48    
49       private void updateImage() { 
50           PseudoColorFilter pcf = new PseudoColorFilter(ar, ag, ab); 
51           ipl.update(new HppFilterImageProcessor(pcf)); 
52    
53       } 
54    
55       public static double scaleSlider(int t) { 
56           return 0.49 * (t / 100.0) + 0.01; 
57       } 
58   } 
59