View Javadoc

1   package org.lcsim.util.aida;
2   
3   import hep.aida.IAnalysisFactory;
4   import hep.aida.IHistogram1D;
5   import hep.aida.IPlotter;
6   import hep.aida.IPlotterFactory;
7   
8   import java.util.Random;
9   
10  import junit.framework.TestCase;
11  
12  /**
13   * This is a basic test of the {@link TabbedPlotterFactory} class.
14   * 
15   * @author Jeremy McCormick <jeremym@slac.stanford.edu>
16   */
17  public class TabbedPlotterFactoryTest extends TestCase {
18      
19      static {
20          // Register the default analysis factory.
21          LCSimAnalysisFactory.register();
22      }
23      
24      /**
25       * Test the <tt>TabbedPlotterFactory</tt>.
26       */
27      public void testTabbedPlotterFactory() {
28          AIDA aida = AIDA.defaultInstance();
29          IAnalysisFactory analysisFactory = aida.analysisFactory();
30          IPlotterFactory plotterFactory = analysisFactory.createPlotterFactory(this.getClass().getSimpleName());
31          
32          IHistogram1D histogram = aida.histogram1D("Fancy Histogram", 100, 0., 10.);
33          Random random = new Random();
34          for (int i=0; i<1000; i++) {
35              histogram.fill(random.nextDouble() * 10);
36          }        
37                                        
38          IPlotter plotter = plotterFactory.create("Test Plot");
39          plotter.createRegions();
40          plotter.region(0).plot(histogram);
41          plotter.show();
42          
43          IPlotter plotter2 = plotterFactory.create("Test Plot 2");
44          plotter.createRegion();
45          plotter2.region(0).plot(histogram);
46          plotter2.show();
47          
48          IPlotter plotter3 = plotterFactory.create();
49          plotter.createRegion();
50          plotter3.region(0).plot(histogram);
51          plotter3.show();
52                          
53          synchronized(this) {
54              try {
55                  wait(10000);
56              } catch (InterruptedException e) {
57                  e.printStackTrace();
58              }
59          }
60      }
61  }