1 //--------------------------------------------------------------------------
2 // Copyright (C) 2001  Geoffrey Furnish
3 // Copyright (C) 2001-2014  Alan W. Irwin
4 // Copyright (C) 2004  Andrew Ross
5 //
6 // This file is part of PLplot.
7 //
8 // PLplot is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU Library General Public License as published by
10 // the Free Software Foundation; version 2 of the License.
11 //
12 // PLplot is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 // GNU Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public License
18 // along with PLplot; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
20 //--------------------------------------------------------------------------
21 
22 //--------------------------------------------------------------------------
23 // Implementation of PLplot example 5 in Java.
24 //--------------------------------------------------------------------------
25 
26 package plplot.examples;
27 
28 import plplot.core.*;
29 import static plplot.core.plplotjavacConstants.*;
30 
31 import java.lang.Math;
32 
33 class x05 {
34     static final int NPTS = 2047;
35 
main( String[] args )36     public static void main( String[] args )
37     {
38         new x05( args );
39     }
40 
x05( String[] args )41     public x05( String[] args )
42     {
43         PLStream pls = new PLStream();
44 
45         int      i;
46         double[] data = new double[NPTS];
47         double   delta;
48 
49         // Parse and process command line arguments.
50 
51         pls.parseopts( args, PL_PARSE_FULL | PL_PARSE_NOPROGRAM );
52 
53         // Initialize plplot.
54 
55         pls.init();
56 
57         // Fill up data points.
58 
59         delta = 2.0 * Math.PI / NPTS;
60         for ( i = 0; i < NPTS; i++ )
61             data[i] = Math.sin( i * delta );
62 
63         pls.col0( 1 );
64         pls.hist( data, -1.1, 1.1, 44, PL_HIST_DEFAULT );
65         pls.col0( 2 );
66         pls.lab( "#frValue", "#frFrequency",
67             "#frPLplot Example 5 - Probability function of Oscillator" );
68 
69         pls.end();
70     }
71 }
72 
73 //--------------------------------------------------------------------------
74 //                              End of x05.java
75 //--------------------------------------------------------------------------
76