• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

PLCallbackCT.javaH A D01-Jun-2019151 85

PLCallbackLabel.javaH A D01-Jun-2019112 85

PLCallbackMapform.javaH A D01-Jun-2019114 85

PLStream.javaH A D01-Jun-201942 KiB1,3721,118

README.javaAPIH A D01-Jun-20194.7 KiB9074

config.java.inH A D01-Jun-20191 KiB2825

plplotjavac.iH A D01-Jun-201967.4 KiB2,1391,743

README.javaAPI

1Here is how to generate the Java interface to PLplot using swig.
2
3PREREQUISITE: swig.  Version 1.3.36 works fine for me, but it has been a long
4time since we have had any version dependency problems for swig.
5
6(1) Install a Java SDK (Software Development Kit).  I use a free version
7from Debian Lenny consisting of gcj, gij, and fastjar, but apparently other
8free java versions and also proprietary versions of java work fine.
9
10(2) If the java include files are not in a default include directory then
11you need to tell CMake where they are.  I use (although I am not sure
12whether this is necessary any longer)
13
14export CMAKE_INCLUDE_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.3/include
15
16(3) The rest is highly automated.  We use a CMake-based build system
17so we run "cmake" to configure the build, "make" to build, and "make
18install" to install.  For more details see our wiki at
19<https://sourceforge.net/p/plplot/wiki>.
20
21For the curious, here are some more details about the 'make' and 'make
22install' steps above.
23
24'make' automatically runs swig on plplotjavac.i
25(which does an include of ../swig-support/plplotcapi.i) to generate all the
26interface files that are needed for further processing.  To understand these
27two *.i files and what they do, you should read the latest java interface
28documentation from swig.  The result is a complete
29interface (aside from the limitations mentioned below) for Java to the
30PLplot common API.
31
32The files generated by swig are necessary java files and plplotjavac_wrap.c.
33'make' builds the java interface shared object module (DLL)
34plplotjavac_wrap.SOBJEXT from plplotjavac_wrap.c. 'make' also builds the
35class files corresponding to the swig-generated java files, the configured
36config.java file, and the PLStream.java file which is hand-crafted (swig
37might be able to do this in future) so that calling a method in the class
38will ensure the stream is correctly set before calling the underlying API
39function.  The relevant java files and corresponding class files that are
40compiled from them make up the plplot.core package.
41
42'make install' installs the relevant java and class files that are part of
43the plplot.core package in $prefix/share/java/plplot/core,
44installs the shared object module (DLL) plplotjavac_wrap.SOBJEXT for the
45java PLplot interface in the $prefix/lib/jni, and also installs
46(from ../../examples/java) the example java scripts and corresponding class
47files that are part of the plplot.examples package into
48$prefix/share/plplot5.3.1/java/plplot/examples. For more details about the
49examples, please see ../../examples/java/README.javademos or the installed
50version of that file in $prefix/share/plplot$version/examples/java/. Copies of
51the java files are also in this directory for convenience.
52At the end of the install process all the files in
53$prefix/share/java/plplot/ are bundled into a jar file
54$prefix/share/java/plplot.jar and the plplot directory is
55deleted.
56
57Here is how to add a new function to the Java API for PLplot:
58
59Edit ../swig-support/plplotcapi.i.  (If you want just a Java interface to
60this PLplot function and not a python or any other interface, then wrap your
61entry with #ifdef SWIG_JAVA ... #endif, but ordinarily you will be adding
62functions for all swig-generated interfaces so you will not use a java-only
63#ifdef at all.) Find a function with the same argument types that you have
64in your new function, and copy those argument types and argument names
65*EXACTLY*.  The typedefs in plplotjavac.i process argument type and argument
66name patterns to produce the required java files and java interface code. So
67give it the same pattern (white space doesn't matter), and you will get the
68same argument processing that worked before for the old function. In the
69unlikely event that you have a new pattern of argument list, then it is time
70to dig into the Java interface documentation for swig.
71
72Finally, hand edit PLStream.java to add typically 3 lines of boiler-plate
73code for each added function copying the appropriate pattern from other
74functions.
75
76Limitation of the current swig-generated Java interface to PLplot:
77
78* A user-friendly (UF) wrapper to the raw java interface should be made to
79give us a variety of different simplified argument lists similarly to the
80way plplot.py wraps the plplotc extension module.  I assume that java is
81more powerful than C so that it makes sense to write the UF interface in
82java rather than C. Note the raw interface only allows two-dimensional xg,
83and yg arrays to plcont, plshades, and plshade. The options of no xg, yg,
84and one-dimensional xg, and yg should also be allowed for the UI interface.
85Also note the raw interface to plparseopts demands you must be explicit
86about ORing in pls.PL_PARSE_NOPROGRAM to the parse mode parameter.  This
87idiosyncrasy of Java should be hidden for the UF interface.
88
89Alan W. Irwin (2009-12-01)
90