1   /*
2    * @(#)DistributionsGUIInspector.java Mar 21, 2004
3    * 
4    * Copyright (c) 2003 Delft University of Technology Jaffalaan 5, 2628 BX Delft,
5    * the Netherlands All rights reserved.
6    * 
7    * This software is proprietary information of Delft University of Technology
8    * The code is published under the General Public License
9    */
10  package nl.tudelft.simulation.jstats.streams;
11  
12  import java.awt.Dimension;
13  import java.awt.Graphics;
14  import java.awt.Graphics2D;
15  
16  import javax.swing.JFrame;
17  import javax.swing.JPanel;
18  import javax.swing.JTabbedPane;
19  
20  /***
21   * The DistributionsGUIInspector provides graphical insight in the randomness of
22   * different streams.
23   * <p>
24   * (c) copyright 2003-2004 <a href="http://www.simulation.tudelft.nl">Delft
25   * University of Technology </a>, the Netherlands. <br>
26   * See for project information <a
27   * href="http://www.simulation.tudelft.nl">www.simulation.tudelft.nl </a> <br>
28   * License of use: <a href="http://www.gnu.org/copyleft/gpl.html">General Public
29   * License (GPL) </a>, no warranty <br>
30   * 
31   * @author <a href="http://www.simulation.tudelft.nl/people/jacobs.html">Peter
32   *         Jacobs </a>
33   * @version 1.0, 2004-03-18
34   * @since 1.2
35   */
36  public class StreamsGuiInspector extends JPanel
37  {
38  	/*** the stream of the frame */
39  	private StreamInterface stream = null;
40  
41  	/***
42  	 * constructs a new DistributionsGUIInspector
43  	 * 
44  	 * @param stream the stream to display
45  	 */
46  	public StreamsGuiInspector(final StreamInterface stream)
47  	{
48  		this.setPreferredSize(new Dimension(500, 500));
49  		this.stream = stream;
50  	}
51  
52  	/***
53  	 * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
54  	 */
55  	protected void paintComponent(final Graphics g)
56  	{
57  		super.paintComponent(g);
58  		Graphics2D g2 = (Graphics2D) g;
59  		for (int i = 0; i < 10000; i++)
60  		{
61  			g2.fillOval(this.stream.nextInt(0, 500), this.stream
62  					.nextInt(0, 500), 1, 1);
63  		}
64  	}
65  
66  	/***
67  	 * executes the main program
68  	 * 
69  	 * @param args the commandline arguments
70  	 */
71  	public static void main(final String[] args)
72  	{
73  		JFrame app = new JFrame("Stream gui tester");
74  		app.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
75  
76  		JTabbedPane contentPane = new JTabbedPane();
77  		contentPane.add("Java2Random", new StreamsGuiInspector(
78  				new Java2Random()));
79  		contentPane.add("MersenneTwister", new StreamsGuiInspector(
80  				new MersenneTwister()));
81  		contentPane.add("DX120Generator", new StreamsGuiInspector(
82  				new DX120Generator()));
83  
84  		app.getContentPane().add(contentPane);
85  		app.pack();
86  		app.setVisible(true);
87  	}
88  }