~ubuntu-branches/ubuntu/intrepid/plplot/intrepid

« back to all changes in this revision

Viewing changes to examples/java/x16.java

  • Committer: Bazaar Package Importer
  • Author(s): Rafael Laboissiere
  • Date: 2006-11-04 10:19:34 UTC
  • mfrom: (2.1.8 edgy)
  • Revision ID: james.westby@ubuntu.com-20061104101934-mlirvdg4gpwi6i5q
Tags: 5.6.1-10
* Orphaning the package
* debian/control: Changed the maintainer to the Debian QA Group

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//---------------------------------------------------------------------------//
2
 
// $Id: x16.java,v 1.8 2004/01/17 16:41:39 rlaboiss Exp $
 
2
// $Id: x16.java,v 1.16 2006/05/17 22:47:07 airwin Exp $
3
3
//---------------------------------------------------------------------------//
4
4
 
5
5
//---------------------------------------------------------------------------//
6
6
// Copyright (C) 2001  Geoffrey Furnish
7
7
// Copyright (C) 2002  Alan W. Irwin
 
8
// Copyright (C) 2004  Andrew Ross
8
9
//
9
10
// This file is part of PLplot.
10
11
//
19
20
//
20
21
// You should have received a copy of the GNU Library General Public License
21
22
// along with PLplot; if not, write to the Free Software
22
 
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
 
23
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
23
24
//---------------------------------------------------------------------------//
24
25
 
25
26
//---------------------------------------------------------------------------//
35
36
class x16 {
36
37
 
37
38
   // number of shade levels, x data points, y data points, and perimeter points.
38
 
   final int NSHADES = 20;
39
 
   final int XPTS = 35;
40
 
   final int YPTS = 46;
41
 
   final int PERIMETERPTS = 100;
 
39
   static final int NSHADES = 20;
 
40
   static final int XPTS = 35;
 
41
   static final int YPTS = 46;
 
42
   static final int PERIMETERPTS = 100;
42
43
 
43
44
   // calculated constants and array that depends on them
44
 
   final double XSPA =  2./(XPTS-1);
45
 
   final double YSPA =  2./(YPTS-1);
 
45
   static final double XSPA =  2./(XPTS-1);
 
46
   static final double YSPA =  2./(YPTS-1);
46
47
   final double tr[] = {XSPA, 0.0, -1.0, 0.0, YSPA, -1.0};
47
48
 
48
 
   PLStreamc plsdummy = new PLStreamc();
49
 
   plplotjavac pls = new plplotjavac();
 
49
   PLStream pls = new PLStream();
50
50
 
51
51
   double fmin, fmax;
52
52
 
90
90
        final int fill_width = 2, cont_color = 0, cont_width = 0;
91
91
 
92
92
        // Parse and process command line arguments.
93
 
        pls.plParseOpts( args, pls.PL_PARSE_FULL | pls.PL_PARSE_NOPROGRAM );
 
93
        pls.parseopts( args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM );
94
94
 
95
95
        // Reduce colors in cmap 0 so that cmap 1 is useful on a 
96
96
        //16-color display
97
 
        pls.plscmap0n(3);
 
97
        pls.scmap0n(3);
98
98
 
99
99
        //Initialize plplot
100
100
         
101
 
          pls.plinit();
 
101
          pls.init();
102
102
        // Set up data array
103
103
 
104
104
        for (i = 0; i < XPTS; i++) {
148
148
 
149
149
        // Plot using identity transform
150
150
 
151
 
        pls.pladv(0);
152
 
        pls.plvpor(0.1, 0.9, 0.1, 0.9);
153
 
        pls.plwind(-1.0, 1.0, -1.0, 1.0);
154
 
 
155
 
        pls.plpsty(0);
156
 
 
157
 
        pls.plshades(z, -1., 1., -1., 1., 
 
151
        pls.adv(0);
 
152
        pls.vpor(0.1, 0.9, 0.1, 0.9);
 
153
        pls.wind(-1.0, 1.0, -1.0, 1.0);
 
154
 
 
155
        pls.psty(0);
 
156
 
 
157
        pls.shades(z, -1., 1., -1., 1., 
158
158
                 shedge, fill_width,
159
159
                 cont_color, cont_width,
160
 
                 1, xg0, yg0);
 
160
                 true, xg0, yg0);
161
161
 
162
 
        pls.plcol0(1);
163
 
        pls.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
164
 
        pls.plcol0(2);
165
 
        pls.pllab("distance", "altitude", "Bogon density");
 
162
        pls.col0(1);
 
163
        pls.box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
 
164
        pls.col0(2);
 
165
        pls.lab("distance", "altitude", "Bogon density");
166
166
 
167
167
        // Plot using 1d coordinate transform
168
168
    
169
 
        pls.pladv(0);
170
 
        pls.plvpor(0.1, 0.9, 0.1, 0.9);
171
 
        pls.plwind(-1.0, 1.0, -1.0, 1.0);
172
 
 
173
 
        pls.plpsty(0);
174
 
 
175
 
        pls.plshades(z, -1., 1., -1., 1., 
 
169
        pls.adv(0);
 
170
        pls.vpor(0.1, 0.9, 0.1, 0.9);
 
171
        pls.wind(-1.0, 1.0, -1.0, 1.0);
 
172
 
 
173
        pls.psty(0);
 
174
 
 
175
        pls.shades(z, -1., 1., -1., 1., 
176
176
             shedge, fill_width,
177
177
             cont_color, cont_width,
178
 
             1, xg1, yg1);
179
 
 
180
 
        pls.plcol0(1);
181
 
        pls.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
182
 
        pls.plcol0(2);
183
 
 
184
 
        pls.pllab("distance", "altitude", "Bogon density");
 
178
             true, xg1, yg1);
 
179
 
 
180
        pls.col0(1);
 
181
        pls.box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
 
182
        pls.col0(2);
 
183
 
 
184
        pls.lab("distance", "altitude", "Bogon density");
185
185
 
186
186
        // Plot using 2d coordinate transform
187
187
 
188
 
        pls.pladv(0);
189
 
        pls.plvpor(0.1, 0.9, 0.1, 0.9);
190
 
        pls.plwind(-1.0, 1.0, -1.0, 1.0);
191
 
 
192
 
        pls.plpsty(0);
193
 
 
194
 
        pls.plshades(z, -1., 1., -1., 1., 
 
188
        pls.adv(0);
 
189
        pls.vpor(0.1, 0.9, 0.1, 0.9);
 
190
        pls.wind(-1.0, 1.0, -1.0, 1.0);
 
191
 
 
192
        pls.psty(0);
 
193
 
 
194
        pls.shades(z, -1., 1., -1., 1., 
195
195
                 shedge, fill_width,
196
196
                 cont_color, cont_width,
197
 
                 0, xg2, yg2);
198
 
 
199
 
        pls.plcol0(1);
200
 
        pls.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
201
 
        pls.plcol0(2);
202
 
        pls.plcont(w, 1, XPTS, 1, YPTS, clevel, xg2, yg2);
203
 
 
204
 
        pls.pllab("distance", "altitude", "Bogon density, with streamlines");
 
197
                 false, xg2, yg2);
 
198
 
 
199
        pls.col0(1);
 
200
        pls.box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
 
201
        pls.col0(2);
 
202
        pls.cont(w, 1, XPTS, 1, YPTS, clevel, xg2, yg2);
 
203
 
 
204
        pls.lab("distance", "altitude", "Bogon density, with streamlines");
205
205
 
206
206
        // Plot using 2d coordinate transform
207
207
 
208
 
        pls.pladv(0);
209
 
        pls.plvpor(0.1, 0.9, 0.1, 0.9);
210
 
        pls.plwind(-1.0, 1.0, -1.0, 1.0);
211
 
 
212
 
        pls.plpsty(0);
213
 
 
214
 
        pls.plshades(z, -1., 1., -1., 1., 
 
208
        pls.adv(0);
 
209
        pls.vpor(0.1, 0.9, 0.1, 0.9);
 
210
        pls.wind(-1.0, 1.0, -1.0, 1.0);
 
211
 
 
212
        pls.psty(0);
 
213
 
 
214
        pls.shades(z, -1., 1., -1., 1., 
215
215
                 shedge, fill_width,
216
216
                 2, 3,
217
 
                 0, xg2, yg2);
218
 
 
219
 
        pls.plcol0(1);
220
 
        pls.plbox("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
221
 
        pls.plcol0(2);
222
 
 
223
 
        pls.pllab("distance", "altitude", "Bogon density");
 
217
                 false, xg2, yg2);
 
218
 
 
219
        pls.col0(1);
 
220
        pls.box("bcnst", 0.0, 0, "bcnstv", 0.0, 0);
 
221
        pls.col0(2);
 
222
 
 
223
        pls.lab("distance", "altitude", "Bogon density");
224
224
 
225
225
        // Note this exclusion API will probably change so don't bother
226
226
        // with it for x16.java example.
228
228
 
229
229
        //Example with polar coordinates.
230
230
 
231
 
        pls.pladv(0);
232
 
        pls.plvpor( .1, .9, .1, .9 );
233
 
        pls.plwind( -1., 1., -1., 1. );
 
231
        pls.adv(0);
 
232
        pls.vpor( .1, .9, .1, .9 );
 
233
        pls.wind( -1., 1., -1., 1. );
234
234
 
235
 
        pls.plpsty(0);
 
235
        pls.psty(0);
236
236
 
237
237
        // Build new coordinate matrices.
238
238
    
255
255
        for (i = 0; i < NSHADES+1; i++)
256
256
          shedge[i] = zmin + (zmax - zmin) * (double) i / (double) NSHADES;
257
257
 
258
 
        pls.plshades(z, -1., 1., -1., 1., 
 
258
        pls.shades(z, -1., 1., -1., 1., 
259
259
                 shedge, fill_width,
260
260
                 cont_color, cont_width,
261
 
                 0, xg2, yg2);
 
261
                 false, xg2, yg2);
262
262
 
263
263
// Now we can draw the perimeter.  (If do before, shade stuff may overlap.)
264
264
        for (i = 0; i < PERIMETERPTS; i++) {
266
266
           px[i] = Math.cos(t);
267
267
           py[i] = Math.sin(t);
268
268
        }
269
 
        pls.plcol0(1);
270
 
        pls.plline(px, py);
 
269
        pls.col0(1);
 
270
        pls.line(px, py);
271
271
                  
272
272
        // And label the plot.
273
273
 
274
 
        pls.plcol0(2);
275
 
        pls.pllab( "", "",  "Tokamak Bogon Instability" );
 
274
        pls.col0(2);
 
275
        pls.lab( "", "",  "Tokamak Bogon Instability" );
276
276
 
277
277
        // Clean up 
278
278
 
279
 
        pls.plend();
 
279
        pls.end();
280
280
 
281
281
     }
282
282
}