From: <and...@us...> - 2007-09-27 21:07:10
|
Revision: 7892 http://plplot.svn.sourceforge.net/plplot/?rev=7892&view=rev Author: andrewross Date: 2007-09-27 14:07:12 -0700 (Thu, 27 Sep 2007) Log Message: ----------- Add plmtex3 and plptex3 to java bindings. Implement example 28 in java to demonstrate these functions. Modified Paths: -------------- trunk/bindings/java/PLStream.java trunk/bindings/swig-support/plplotcapi.i trunk/examples/java/CMakeLists.txt trunk/test/test_java.sh.in Added Paths: ----------- trunk/examples/java/x28.java Property Changed: ---------------- trunk/examples/c++/x28.cc Modified: trunk/bindings/java/PLStream.java =================================================================== --- trunk/bindings/java/PLStream.java 2007-09-27 11:32:09 UTC (rev 7891) +++ trunk/bindings/java/PLStream.java 2007-09-27 21:07:12 UTC (rev 7892) @@ -446,6 +446,11 @@ plplotjavac.plmtex(side, disp, pos, just, text); } +public void mtex3(String side, double disp, double pos, double just, String text) { + if (set_stream() == -1) return; + plplotjavac.plmtex3(side, disp, pos, just, text); +} + public void plot3d(double[] x, double[] y, double[][] z, int opt, boolean side) { if (set_stream() == -1) return; plplotjavac.plot3d(x, y, z, opt, side); @@ -513,6 +518,11 @@ plplotjavac.plptex(x, y, dx, dy, just, text); } +public void ptex3(double x, double y, double z, double dx, double dy, double dz, double sx, double sy, double sz, double just, String text) { + if (set_stream() == -1) return; + plplotjavac.plptex3(x, y, z, dx, dy, dz, sx, sy, sz, just, text); +} + public void replot() { if (set_stream() == -1) return; plplotjavac.plreplot(); Modified: trunk/bindings/swig-support/plplotcapi.i =================================================================== --- trunk/bindings/swig-support/plplotcapi.i 2007-09-27 11:32:09 UTC (rev 7891) +++ trunk/bindings/swig-support/plplotcapi.i 2007-09-27 21:07:12 UTC (rev 7892) @@ -475,6 +475,11 @@ plmtex(const char *side, PLFLT disp, PLFLT pos, PLFLT just, const char *text); +%feature("autodoc", "Print \"text\" at specified position relative to viewport.") plmtex3; +void +plmtex3(const char *side, PLFLT disp, PLFLT pos, PLFLT just, + const char *text); + %feature("autodoc", "Plot a 3-d representation of the function z[x][y].") plot3d; void plot3d(PLFLT *ArrayX, PLFLT *ArrayY, PLFLT **MatrixCk, @@ -535,6 +540,10 @@ void plptex(PLFLT x, PLFLT y, PLFLT dx, PLFLT dy, PLFLT just, const char *text); +%feature("autodoc", "Print \"text\" at world cooordinate (x,y).") plptex3; +void +plptex3(PLFLT x, PLFLT y, PLFLT z, PLFLT dx, PLFLT dy, PLFLT dz, PLFLT sx, PLFLT sy, PLFLT sz, PLFLT just, const char *text); + %feature("autodoc", "Replay contents of plot buffer to current device/file.") plreplot; void plreplot(void); Property changes on: trunk/examples/c++/x28.cc ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/examples/java/CMakeLists.txt =================================================================== --- trunk/examples/java/CMakeLists.txt 2007-09-27 11:32:09 UTC (rev 7891) +++ trunk/examples/java/CMakeLists.txt 2007-09-27 21:07:12 UTC (rev 7892) @@ -48,6 +48,7 @@ "24" "25" "26" +"28" ) # This information is duplicated from bindings/java/CMakeLists.txt Added: trunk/examples/java/x28.java =================================================================== --- trunk/examples/java/x28.java (rev 0) +++ trunk/examples/java/x28.java 2007-09-27 21:07:12 UTC (rev 7892) @@ -0,0 +1,370 @@ +// $Id:$ +// +// plmtex3, plptex3 demo. +// +// Copyright (C) 2007 Alan W. Irwin +// Copyright (C) 2007 Andrew Ross + +//---------------------------------------------------------------------------// +// Implementation of PLplot example 28 in Java. +//---------------------------------------------------------------------------// + +package plplot.examples; + +import plplot.core.*; + +import java.lang.Math; + +class x28 { + + PLStream pls = new PLStream(); + + static int XPTS = 2; + static int YPTS = 2; + static int NREVOLUTION = 16; + static int NROTATION = 8; + static int NSHEAR = 8; + + x28(String[] args) + { + double xmin=0., xmax=1.0, xmid = 0.5*(xmax + xmin), xrange = xmax - xmin, + ymin=0., ymax=1.0, ymid = 0.5*(ymax + ymin), yrange = ymax - ymin, + zmin=0., zmax=1.0, zmid = 0.5*(zmax + zmin), zrange = zmax - zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + omega, sin_omega, cos_omega, domega; + int i,j; + double radius, pitch, xpos, ypos, zpos; + /* p1string must be exactly one character + the null termination + * character. */ + String pstring = "The future of our civilization depends on software freedom."; + + /* Allocate and define the minimal x, y, and z to insure 3D box */ + double[] x = new double[XPTS]; + double[] y = new double[YPTS]; + double[][] z = new double[XPTS][YPTS]; + + for (i = 0; i < XPTS; i++) { + x[i] = xmin + (double) i * (xmax-xmin)/ (double) (XPTS-1); + } + + for (j = 0; j < YPTS; j++) + y[j] = ymin + (double) j * (ymax-ymin)/ (double) (YPTS-1); + + for (i = 0; i < XPTS; i++) { + for (j = 0; j < YPTS; j++) { + z[i][j] = 0.; + } + } + + /* Parse and process command line arguments */ + + pls.parseopts(args, PLStream.PL_PARSE_FULL | PLStream.PL_PARSE_NOPROGRAM); + + pls.init(); + + /* Page 1: Demonstrate inclination and shear capability pattern. */ + + pls.adv(0); + pls.vpor(-0.15, 1.15, -0.05, 1.05); + pls.wind(-1.2, 1.2, -0.8, 1.5); + pls.w3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, + 20., 45.); + + pls.col0(2); + pls.box3("b", "", xmax-xmin, 0, + "b", "", ymax-ymin, 0, + "bcd", "", zmax-zmin, 0); + + /* z = zmin. */ + pls.schr(0., 1.0); + for (i = 0; i < NREVOLUTION; i++) { + omega = 2.*Math.PI*((double)i/(double)NREVOLUTION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + x_inclination = 0.5*xrange*cos_omega; + y_inclination = 0.5*yrange*sin_omega; + z_inclination = 0.; + x_shear = -0.5*xrange*sin_omega; + y_shear = 0.5*yrange*cos_omega; + z_shear = 0.; + pls.ptex3( + xmid, ymid, zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + + /* x = xmax. */ + pls.schr(0., 1.0); + for (i = 0; i < NREVOLUTION; i++) { + omega = 2.*Math.PI*((double)i/(double)NREVOLUTION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + x_inclination = 0.; + y_inclination = -0.5*yrange*cos_omega; + z_inclination = 0.5*zrange*sin_omega; + x_shear = 0.; + y_shear = 0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmax, ymid, zmid, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + + /* y = ymax. */ + pls.schr(0., 1.0); + for (i = 0; i < NREVOLUTION; i++) { + omega = 2.*Math.PI*((double)i/(double)NREVOLUTION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + x_inclination = 0.5*xrange*cos_omega; + y_inclination = 0.; + z_inclination = 0.5*zrange*sin_omega; + x_shear = -0.5*xrange*sin_omega; + y_shear = 0.; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmid, ymax, zmid, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.0, " revolution"); + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + pls.mesh(x, y, z, PLStream.DRAW_LINEXY); + + /* Page 2: Demonstrate rotation of string around its axis. */ + pls.adv(0); + pls.vpor(-0.15, 1.15, -0.05, 1.05); + pls.wind(-1.2, 1.2, -0.8, 1.5); + pls.w3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, + 20., 45.); + + pls.col0(2); + pls.box3("b", "", xmax-xmin, 0, + "b", "", ymax-ymin, 0, + "bcd", "", zmax-zmin, 0); + + /* y = ymax. */ + pls.schr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + x_shear = 0.; + for (i = 0; i < NROTATION; i++) { + omega = 2.*Math.PI*((double)i/(double)NROTATION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + y_shear = 0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmid, ymax, zmax -(zmax-0.2)*((double)i/(double)(NROTATION-1)), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for y = y#dmax#u"); + } + + /* x = xmax. */ + pls.schr(0., 1.0); + x_inclination = 0.; + y_inclination = -1.; + z_inclination = 0.; + y_shear = 0.; + for (i = 0; i < NROTATION; i++) { + omega = 2.*Math.PI*((double)i/(double)NROTATION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + x_shear = 0.5*xrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmax, ymid, zmax -(zmax-0.2)*((double)i/(double)(NROTATION-1)), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for x = x#dmax#u"); + } + + /* z = zmin. */ + pls.schr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + x_shear = 0.; + for (i = 0; i < NROTATION; i++) { + omega = 2.*Math.PI*((double)i/(double)NROTATION); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + y_shear = 0.5*yrange*cos_omega; + z_shear = 0.5*zrange*sin_omega; + pls.ptex3( + xmid, ymax -(ymax-0.2)*((double)i/(double)(NROTATION-1)), zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "rotation for z = z#dmin#u"); + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + pls.mesh(x, y, z, PLStream.DRAW_LINEXY); + + /* Page 3: Demonstrate shear of string along its axis. */ + /* Work around xcairo and pngcairo (but not pscairo) problems for + * shear vector too close to axis of string. (N.B. no workaround + * would be domega = 0.) */ + domega = 0.05; + pls.adv(0); + pls.vpor(-0.15, 1.15, -0.05, 1.05); + pls.wind(-1.2, 1.2, -0.8, 1.5); + pls.w3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, + 20., 45.); + + pls.col0(2); + pls.box3("b", "", xmax-xmin, 0, + "b", "", ymax-ymin, 0, + "bcd", "", zmax-zmin, 0); + + /* y = ymax. */ + pls.schr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + y_shear = 0.; + for (i = 0; i < NSHEAR; i++) { + omega = domega + 2.*Math.PI*((double)i/(double)NSHEAR); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + x_shear = 0.5*yrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmid, ymax, zmax -(zmax-0.2)*((double)i/(double)(NSHEAR-1)), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for y = y#dmax#u"); + } + + /* x = xmax. */ + pls.schr(0., 1.0); + x_inclination = 0.; + y_inclination = -1.; + z_inclination = 0.; + x_shear = 0.; + for (i = 0; i < NSHEAR; i++) { + omega = domega + 2.*Math.PI*((double)i/(double)NSHEAR); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + y_shear = -0.5*xrange*sin_omega; + z_shear = 0.5*zrange*cos_omega; + pls.ptex3( + xmax, ymid, zmax -(zmax-0.2)*((double)i/(double)(NSHEAR-1)), + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for x = x#dmax#u"); + } + + /* z = zmin. */ + pls.schr(0., 1.0); + x_inclination = 1.; + y_inclination = 0.; + z_inclination = 0.; + z_shear = 0.; + for (i = 0; i < NSHEAR; i++) { + omega = domega + 2.*Math.PI*((double)i/(double)NSHEAR); + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + y_shear = 0.5*yrange*cos_omega; + x_shear = 0.5*zrange*sin_omega; + pls.ptex3( + xmid, ymax -(ymax-0.2)*((double)i/(double)(NSHEAR-1)), zmin, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, "shear for z = z#dmin#u"); + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + pls.mesh(x, y, z, PLStream.DRAW_LINEXY); + + /* Page 4: Demonstrate drawing a string on a 3D path. */ + pls.adv(0); + pls.vpor(-0.15, 1.15, -0.05, 1.05); + pls.wind(-1.2, 1.2, -0.8, 1.5); + pls.w3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, + 40., -30.); + + pls.col0(2); + pls.box3("b", "", xmax-xmin, 0, + "b", "", ymax-ymin, 0, + "bcd", "", zmax-zmin, 0); + + pls.schr(0., 1.2); + /* domega controls the spacing between the various characters of the + * string and also the maximum value of omega for the given number + * of characters in *pstring. */ + domega = 2.*Math.PI/pstring.length(); + omega = 0.; + /* 3D function is a helix of the given radius and pitch */ + radius = 0.5; + pitch = 1./(2.*Math.PI); + for(i=0;i<pstring.length();i++) { + sin_omega = Math.sin(omega); + cos_omega = Math.cos(omega); + xpos = xmid + radius*sin_omega; + ypos = ymid - radius*cos_omega; + zpos = zmin + pitch*omega; + /* In general, the inclination is proportional to the derivative of + * the position wrt theta. */ + x_inclination = radius*cos_omega;; + y_inclination = radius*sin_omega; + z_inclination = pitch; + /* The shear vector should be perpendicular to the 3D line with Z + * component maximized, but for low pitch a good approximation is + * a constant vector that is parallel to the Z axis. */ + x_shear = 0.; + y_shear = 0.; + z_shear = 1.; + pls.ptex3( + xpos, ypos, zpos, + x_inclination, y_inclination, z_inclination, + x_shear, y_shear, z_shear, + 0.5, pstring.substring(i,i+1)); + omega += domega; + } + /* Draw minimal 3D grid to finish defining the 3D box. */ + pls.mesh(x, y, z, PLStream.DRAW_LINEXY); + + /* Page 5: Demonstrate plmtex3 axis labelling capability */ + pls.adv(0); + pls.vpor(-0.15, 1.15, -0.05, 1.05); + pls.wind(-1.2, 1.2, -0.8, 1.5); + pls.w3d(1.0, 1.0, 1.0, xmin, xmax, ymin, ymax, zmin, zmax, + 20., 45.); + + pls.col0(2); + pls.box3("b", "", xmax-xmin, 0, + "b", "", ymax-ymin, 0, + "bcd", "", zmax-zmin, 0); + + pls.schr(0., 1.0); + pls.mtex3("xp", 3.0, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("xp", 4.5, 0.5, 0.5, "primary X-axis label"); + pls.mtex3("xs", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("xs", -1.0, 0.5, 0.5, "secondary X-axis label"); + pls.mtex3("yp", 3.0, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("yp", 4.5, 0.5, 0.5, "primary Y-axis label"); + pls.mtex3("ys", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("ys", -1.0, 0.5, 0.5, "secondary Y-axis label"); + pls.mtex3("zp", 4.5, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("zp", 3.0, 0.5, 0.5, "primary Z-axis label"); + pls.mtex3("zs", -2.5, 0.5, 0.5, "Arbitrarily displaced"); + pls.mtex3("zs", -1.0, 0.5, 0.5, "secondary Z-axis label"); + /* Draw minimal 3D grid to finish defining the 3D box. */ + pls.mesh(x, y, z, PLStream.DRAW_LINEXY); + + pls.end(); + + } + + + public static void main( String[] args ) + { + new x28( args ); + } + +}; Property changes on: trunk/examples/java/x28.java ___________________________________________________________________ Name: svn:keywords + Author Date Id Revision Modified: trunk/test/test_java.sh.in =================================================================== --- trunk/test/test_java.sh.in 2007-09-27 11:32:09 UTC (rev 7891) +++ trunk/test/test_java.sh.in 2007-09-27 21:07:12 UTC (rev 7892) @@ -42,7 +42,7 @@ PLPLOT_CLASSPATH=@JAVADATA_HARDDIR@/plplot.jar fi -for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 20 21 22 23 24 25 26; do +for index in 01 02 03 04 05 06 07 08 09 10 11 12 13 15 16 18 20 21 22 23 24 25 26 28; do if test "@WIN32@" = "1"; then java -classpath ${PLPLOT_CLASSPATH} ${JAVA_TEST_OPTS} plplot.examples.x${index} -dev $device -o ${OUTPUT_DIR}/x${index}j.$dsuffix $options 2> test.error else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |