Print

Print


Commit in lcsim/test/org/lcsim/aida on MAIN
AidaGraphicsOutputTest.java+50added 1.1
test that AIDA output works for various graphics formats

lcsim/test/org/lcsim/aida
AidaGraphicsOutputTest.java added at 1.1
diff -N AidaGraphicsOutputTest.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ AidaGraphicsOutputTest.java	15 Apr 2013 22:45:40 -0000	1.1
@@ -0,0 +1,50 @@
+package org.lcsim.aida;
+
+import hep.aida.IAnalysisFactory;
+import hep.aida.IHistogram1D;
+import hep.aida.IHistogramFactory;
+import hep.aida.IPlotter;
+import hep.aida.ITree;
+import hep.aida.ITreeFactory;
+
+import java.util.Random;
+
+import junit.framework.TestCase;
+import de.schlichtherle.io.File;
+
+/**
+ * @author Jeremy McCormick <[log in to unmask]>
+ * @version $Id: AidaGraphicsOutputTest.java,v 1.1 2013/04/15 22:45:40 jeremy Exp $
+ */
+public class AidaGraphicsOutputTest extends TestCase {
+    
+    String[] formats = new String[] { "png", "pdf", "ps", "svg", "swf" };
+    
+    public void testAidaGraphicsOutput() throws Exception {
+        
+        IAnalysisFactory analysisFactory = IAnalysisFactory.create();
+        ITreeFactory treeFactory = analysisFactory.createTreeFactory();
+        ITree tree = treeFactory.create();
+        IHistogramFactory histogramFactory = analysisFactory.createHistogramFactory(tree);
+        
+        IHistogram1D histogram = histogramFactory.createHistogram1D("hist", 50, -5.0, 5.0);
+        
+        Random random = new Random();
+        for (int i=0; i<1000; i++) {
+            histogram.fill(random.nextGaussian());
+        }
+        
+        IPlotter plotter = analysisFactory.createPlotterFactory().create();
+        plotter.createRegion();
+        plotter.region(0).plot(histogram);
+                        
+        String fileName = "target" + File.separator + "test-output" + File.separator 
+                + this.getClass().getSimpleName();
+               
+        for (String format : formats) {
+            String fullPath = fileName + "." + format;
+            System.out.println("writing histogram to " + fullPath);
+            plotter.writeToFile(fileName + "." + format);
+        }
+    }    
+}
CVSspam 0.2.12


Use REPLY-ALL to reply to list

To unsubscribe from the LCD-CVS list, click the following link:
https://listserv.slac.stanford.edu/cgi-bin/wa?SUBED1=LCD-CVS&A=1