lcsim/test/org/lcsim/aida
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);
+ }
+ }
+}