Java Application and JAIDA

The following example illustrates how to embed one (or more) JAIDA plotters into your own Java application. The example makes use of the hep.aida.ref.plotter.PlotterUtilities class which contains several methods for assisting in interfacing JAIDA to other Java applications.


import hep.aida.*;
import hep.aida.ref.plotter.PlotterUtilities;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.util.Random;

import javax.swing.*;

 * An example of how to embed a JAIDA IPlotter into your own application.
public class AIDAEmbed extends JPanel
   /** Creates a new instance of AIDAEmbed */
   public AIDAEmbed()
      super(new BorderLayout());

      IAnalysisFactory af = IAnalysisFactory.create();
      ITree tree = af.createTreeFactory().create();
      IHistogramFactory hf = af.createHistogramFactory(tree);
      IHistogram1D h1d = hf.createHistogram1D("Test", 50, -3, 3);

      // Fill with junk
      Random rand = new Random();
      for (int i = 0; i < 10000; i++)

      // Create an IPlotter 
      IPlotter plotter = af.createPlotterFactory().create();

      // Now embed the plotter
      add(PlotterUtilities.componentForPlotter(plotter), BorderLayout.CENTER);

    * @param args the command line arguments
   public static void main(String[] args)
      JFrame frame = new JFrame("Embedded AIDA");

      JMenuBar bar = new JMenuBar();
      JMenu menu = new JMenu("File");
      JMenuItem item = new JMenuItem(new ExitAction());

      frame.setContentPane(new AIDAEmbed());
   private static class ExitAction extends AbstractAction
      ExitAction() { super("Exit"); }
      public void actionPerformed(ActionEvent e) { System.exit(0); }