A generalized plotting program
This module develops a generalized plotting program, which is easy to connect to other programs, (whether they are simple or complex) , in order to display the output from those programs in two-dimensional Cartesian coordinates .. The plotting program is specifically designed to be useful to persons having very little knowledge of Java programming.
(Actually, the module develops two very similar plotting programs each designed to display the data in a different format.)
Viewing tip
I recommend that you open another copy of this module in a separate browser window and use the following links to easily find and view the Figuresand Listings while you are reading about them.
Figures
- Figure 1 . Sample Display.
- Figure 2 . Sample Display for Same Data with Different Plotting Parameters.
- Figure 3 . A Digital Signal Processing (DSP) Example.
- Figure 4 . Graphic Display for Self-Test Class.
- Figure 5 . Sample output format from Graph02.
Listings
- Listing 1 . Source code for GraphIntfc01.java.
- Listing 2 . Beginning of the class named Graph01Demo.
- Listing 3 . The method named getNmbr.
- Listing 4 . The method named f1.
- Listing 5 . The method named f2.
- Listing 6 . The method named f3.
- Listing 7 . The method named f4.
- Listing 8 . The method named f5.
- Listing 9 . Beginning of the class named Dsp002.
- Listing 10 . Create data arrays.
- Listing 11 . Beginning of the constructor.
- Listing 12 . Create the convolution operator.
- Listing 13 . Apply the convolution operator.
- Listing 14 . Compute spectrum of each of two traces.
- Listing 15 . The getNmbr method.
- Listing 16 . The method named f1.
- Listing 17 . The class named Convolve01.
- Listing 18 . The discrete Fourier transform (DFT).
- Listing 19 . The class named Graph01.
- Listing 20 . Beginning of the class named GUI.
- Listing 21 . Beginning of the constructor for the GUI class.
- Listing 22 . Array to hold Canvas objects.
- Listing 23 . Routine GUI construction code.
- Listing 24 . The Canvas objects.
- Listing 25 . More routine construction code.
- Listing 26 . Force a repaint.
- Listing 27 . Beginning of the re-plot code.
- Listing 28 . The remainder of the event handler.
- Listing 29 . Beginning of the class named MyCanvas.
- Listing 30 . Beginning of the overridden paint method.
- Listing 31 . Get old coordinate values.
- Listing 32 . Plot the points.
- Listing 33 . The drawAxes method.
- Listing 34 . Drawing tic marks.
- Listing 35 . The getTheX and getTheY methods.
- Listing 36 . The test class named junk.
- Listing 37 . Graph01Demo.java.
- Listing 38 . Dsp002.java,
- Listing 39 . Graph01.java.
- Listing 40 . Graph02.java.
Preview
Figure 1 shows a typical display produced by one of the plotting programs that I will develop in this module. (The other program superimposes all of the curves on the same set of axes instead of spacing them vertically as shownin Figure 1 .)
Figure 1. Sample Display. |
---|
|
While the plotting program itself is quite complex, the code required to produce the data to be plotted can be very simple. For example, because of theuse of the Java Math library, only fourteen lines of simple Java code were required to produce the data plotted in Figure 1 .