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

1    /* 
2     * Created by DocJava, Inc. 
3     * User: lyon 
4     * Date: Mar 19, 2003 
5     * Time: 11:13:42 AM 
6     */ 
7    package j2d; 
8     
9    import javax.swing.*; 
10   import java.awt.*; 
11    
12   public class ComparisonUtils { 
13       public static void showComparisonFrame(JPanel jp) { 
14           JFrame jf = new JFrame(); 
15           Container c = jf.getContentPane(); 
16    
17           c.setLayout(new BorderLayout()); 
18    
19           c.add(jp, BorderLayout.CENTER); 
20    
21           jf.setDefaultCloseOperation( 
22                   WindowConstants.DISPOSE_ON_CLOSE); 
23           jf.pack(); 
24           jf.setSize(400, 400); 
25           jf.setVisible(true); 
26    
27       } 
28    
29       public static JPanel getComparisonPanel(Image sourceImage, 
30                                               ImageProcessorFactory ipf) { 
31           ShortImageBeans sib = new ShortImageBeans(); 
32           ShortImageBeans comparisons = 
33                   sib.computeComparisons(sourceImage, ipf, 9); 
34           //showOrientationSubBands(comparisons); 
35           ShortImageBean max = comparisons.getMaxBean(); 
36           ShortImageBean oMax = max.getImageFlowBean(); 
37           comparisons.add(max); 
38           comparisons.add(oMax); 
39           //showComparisonFrame(getComparisonPanel( 
40           //        sib.getOrientationSubBands(),0,4)); 
41           return getComparisonPanel(comparisons, 0, 3); 
42       } 
43    
44       private static void showOrientationSubBands(ShortImageBeans sib) { 
45    
46           ShortImageBeans osb = sib.getOrientationSubBands(); 
47           showComparisonFrame(getComparisonPanel(osb, 0, 3)); 
48       } 
49    
50       private static void showMaxFlowFrame(ShortImageBeans sib) { 
51           ShortImageBean max = sib.getMaxBean(); 
52           ShortImageBeans maxFlow = new ShortImageBeans(); 
53           maxFlow.add(max); 
54           maxFlow.add(max.getImageFlowBean()); 
55           showComparisonFrame(getComparisonPanel(maxFlow, 1, 0)); 
56       } 
57    
58       public static JPanel getComparisonPanel(ShortImageBeans sibs, int r, int c) { 
59           JPanel jp = getComparisonPanel(r, c); 
60           ShortImageBean sib[] = sibs.getShortImageBeans(); 
61           for (int i = 0; i < sib.length; i++) 
62               jp.add(new ImageProcessButton(sib[i].getImage())); 
63           return jp; 
64       } 
65    
66    
67       public static JPanel getComparisonPanel2(Image sourceImage, 
68                                                ImageProcessorFactory ipf) { 
69           JPanel jp = getComparisonPanel(0, 3); 
70    
71           ImageProcessButton ipa[] = new ImageProcessButton[9]; 
72    
73           ipa[0] = new ImageProcessButton(sourceImage); 
74           jp.add(ipa[0]); 
75           for (int i = 1; i < 9; i++) { 
76               ipa[i] = new ImageProcessButton(sourceImage); 
77               ipa[i].update(ipf.getProcessor(i)); 
78               jp.add(ipa[i]); 
79           } 
80           return jp; 
81       } 
82    
83       public static JPanel getComparisonPanel(int r, int c) { 
84           JPanel jp = new JPanel(); 
85           gui.layouts.PreferredSizeGridLayout 
86                   lo = new gui.layouts.PreferredSizeGridLayout( 
87                           r, c, 0, 0); 
88           lo.setBoundableInterface(new 
89                   gui.layouts.AspectBoundable()); 
90           jp.setMinimumSize(new Dimension(100, 100)); 
91    
92           jp.setLayout(lo); 
93           return jp; 
94       } 
95   } 
96