<< Chapter < Page
  Digital signal processing - dsp     Page 11 / 27
Chapter >> Page >

Plot the data

The statement in Listing 3 calls the overloaded plotData method to cause all of the pages belonging to the plotting object titled "A" to be stacked in alocation where the upper left corner of the stack is 401 pixels to the right of the upper left corner of the screen.

Listing 3. Plot the data.
plotObjectA.plotData(401,0);

As described earlier, page 0 containing the earliest data fed to the plotting object is on the top of the stack. Figure 1 shows the two pages belonging to this plotting object after they have been manually rearranged to make them bothvisible.

Feed and plot the object titled "B"

Listing 4 feeds 2600 random white noise values to the object titled "B" and displays the pages in the default location in the upper left corner of thescreen. Listing 4 also signals the end of the main method.

Listing 4. Feed and plot the object titled "B".
for(int cnt = 0;cnt<2600;cnt++){ plotObjectB.feedData((Math.random() - 0.5)*25); }//end for loopplotObjectB.plotData();}//end main

Listing 4 (plus one of the statements in Listing 1 ) is much more typical of the amount of code required to use this plotting class than was thecase with Listing 2 .

(Almost all of the code in Listing 2 was required to set the special data values used to test the transitions discussed earlier.)

The three steps

To recap, the three steps required to use this class for plotting nearly unlimited amounts of data are:

  1. Instantiate a plotting object of the class named PlotALot01 , as in Listing 1 .
  2. Call the feedData method once for each data value that is to be plotted, as in Listing 4 .
  3. Call the plotData method on the plotting object afterall of the data has been fed to the plotting object, as in Listing 3 or Listing 4 .

Some instance variables

Continuing with the class definition for the class named PlotALot01 , Listing 5 shows several instance variables that belong to a plotting object instantiatedfrom this class.

Listing 5. Some instance variables.
String title; int frameWidth;int frameHeight; int traceSpacing;//pixels between tracesint sampSpacing;//pixels between samples int ovalWidth;//width of sample marking ovalint ovalHeight;//height of sample marking ovalint tracesPerPage; int samplesPerPage;int pageCounter = 0; int sampleCounter = 0;ArrayList<Page>pageLinks = new ArrayList<Page>();

The purpose of each of these instance variables is indicated by the name of the variable, and in some cases by the comments following the variabledeclaration. In addition, I will have more to say about some of these variables later when I discuss the code that uses them.

(Note the use of generics in the declaration and initialization of the variable named pageLinks . The use of generics dictates that this class requires J2SE 5.0 or later.)

The first overloaded constructor

As mentioned earlier, there are two overloaded versions of the constructor for this class. The overloaded version that begins in Listing 6 accepts several incoming parameters allowing the user to control various aspects of the plottingformat.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Digital signal processing - dsp. OpenStax CNX. Jan 06, 2016 Download for free at https://legacy.cnx.org/content/col11642/1.38
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Digital signal processing - dsp' conversation and receive update notifications?

Ask