1
1
//---------------------------------------------------------------------------//
2
// $Id: x01.java,v 1.21 2004/06/17 12:41:02 andrewross Exp $
2
// $Id: x01.java,v 1.31 2006/05/17 22:51:20 airwin Exp $
3
3
//---------------------------------------------------------------------------//
5
5
//---------------------------------------------------------------------------//
23
23
// You should have received a copy of the GNU Library General Public License
24
24
// along with PLplot; if not, write to the Free Software
25
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
26
26
//---------------------------------------------------------------------------//
28
28
//---------------------------------------------------------------------------//
40
40
double xscale, yscale, xoff, yoff;
41
PLStreamc plsdummy = new PLStreamc();
42
plplotjavac pls = new plplotjavac();
41
PLStream pls = new PLStream();
43
// Set this to true to test the xormod method
44
static boolean test_xor = false;
46
static boolean locate_mode = false;
47
static int fontset = 1;
48
static String f_name = null;
44
50
public static void main( String[] args )
52
58
// plplot initialization
53
59
// Divide page into 2x2 plots unless user overrides.
57
63
// Parse and process command line arguments.
59
65
// plMergeOpts(options, "x01c options", notes);
60
pls.plParseOpts( args, pls.PL_PARSE_FULL|pls.PL_PARSE_NOPROGRAM );
66
pls.parseopts( args, PLStream.PL_PARSE_FULL|PLStream.PL_PARSE_NOPROGRAM );
62
68
// Print out version number.
64
70
StringBuffer version = new StringBuffer(80);
65
71
// plgver no longer works for unexplained reasons.
67
73
System.out.println("PLplot library version: " + version);
69
75
// Initialize PLplot.
72
78
// Select the multi-stroke font.
122
134
// Don't forget to call plend() to finish off!
126
void plot1( int do_test )
138
void plot1( boolean do_test )
129
141
double xmin, xmax, ymin, ymax;
131
143
double y[] = new double[60];
132
144
double xs[] = new double[6];
133
145
double ys[] = new double[6];
146
boolean st[] = new boolean[1];
147
double xx[] = new double[1];
148
double yy[] = new double[1];
135
150
for( i=0; i < 60; i++ )
153
168
// 6.0, and the range in Y is 0.0 to 30.0. The axes are scaled separately
154
169
// (just = 0), and we just draw a labelled box (axis = 0).
157
pls.plenv( xmin, xmax, ymin, ymax, 0, 0 );
159
pls.pllab( "(x)", "(y)", "#frPLplot Example 1 - y=x#u2" );
172
pls.env( xmin, xmax, ymin, ymax, 0, 0 );
174
pls.lab( "(x)", "(y)", "#frPLplot Example 1 - y=x#u2" );
161
176
// Plot the data points.
164
pls.plpoin( xs, ys, 9 );
179
pls.poin( xs, ys, 9 );
166
181
// Draw the line through the data.
186
// xor mode enable erasing a line/point/text by replotting it again
187
// it does not work in double buffering mode, however
189
if (do_test && test_xor ) {
190
pls.xormod(true, st); // enter xor mode
192
for (i=0; i<60; i++) {
195
pls.poin(xx, yy,9); // draw a point
197
Thread.sleep(50); // wait a little
199
catch (InterruptedException ie) {
201
pls.flush(); // force an update of the tk driver
202
pls.poin(xx, yy,9); // erase point
204
pls.xormod(false, st); // leave xor mode
179
217
// 10.0, and the range in Y is -0.4 to 2.0. The axes are scaled
180
218
// separately (just = 0), and we draw a box with axes (axis = 1).
183
pls.plenv(-2.0, 10.0, -0.4, 1.2, 0, 1);
185
pls.pllab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function");
221
pls.env(-2.0, 10.0, -0.4, 1.2, 0, 1);
223
pls.lab("(x)", "sin(x)/x", "#frPLplot Example 1 - Sinc Function");
187
225
// Fill up the arrays.
214
252
// For the final graph we wish to override the default tick intervals,
215
253
// and so do not use plenv().
219
257
// Use standard viewport, and define X range from 0 to 360 degrees, Y
220
258
// range from -1.2 to 1.2.
223
pls.plwind( 0.0, 360.0, -1.2, 1.2 );
261
pls.wind( 0.0, 360.0, -1.2, 1.2 );
225
263
// Draw a box with ticks spaced 60 degrees apart in X, and 0.2 in Y.
228
pls.plbox("bcnst", 60.0, 2, "bcnstv", 0.2, 2);
266
pls.box("bcnst", 60.0, 2, "bcnstv", 0.2, 2);
230
268
// Superimpose a dashed line grid, with 1.5 mm marks and spaces.
231
269
// plstyl expects a pointer!
233
pls.plstyl(mark1, space1);
235
pls.plbox("g", 30.0, 0, "g", 0.2, 0);
236
pls.plstyl(mark0, space0);
271
pls.styl(mark1, space1);
273
pls.box("g", 30.0, 0, "g", 0.2, 0);
274
pls.styl(mark0, space0);
239
pls.pllab( "Angle (degrees)", "sine",
277
pls.lab( "Angle (degrees)", "sine",
240
278
"#frPLplot Example 1 - Sine function" );
242
280
for (i = 0; i < 101; i++) {