JWAVE

Java™ Graphic Components


Annotated example of the PV-WAVE procedure for a component

See the source code for other procedures for templates for creating the server code for new components, as there are a numer of special cases like animations which require that a strip of images be created rather than a single image.

The basic components of a new server procedure are explained in this annotated source for wavebar3d.pro:


The server procedure must have two arguments, an associative array
containing all of the tag names and data, and the path/filename
of the resulting image to be produced.
   PRO WAVEBAR3D, kw, file
   ON_ERROR, 2
Extract the tag names from the associative array
   tags = ASKEYS(kw)
Initialize strings to hold the positional parameter names (key) and a string to hold the name of the Z positional parameter (which will be kw("Z") in this case.)
   key  = ''
   posz = ''
Loop through each tag and either add the keyword to the "key" string or to the "posz" string if it is the Z data array
   FOR i=0,N_ELEMENTS(tags)-1 DO BEGIN
      CASE tags(i) OF
The "WaveBar3D" tag contains the size of the plot to produce. Here we call the convenience routine "OpenZBuff" to open and clear the Z buffer device and set it to the desired size.

Also, particular to the Bar3D procedure, we will force the TEK_COLOR palette to be loaded.

         'WaveBar3D' : BEGIN
                          OpenZBuff, kw(tags(i))
                          SET_PLOT, 'PS'
                          TEK_COLOR
                          SET_PLOT, 'Z'
                       END
Because the Z parameter is a positional parameter, we must store it in a separate string so that when we assemble the call to Bar3D we can place it in the right order. (This is a big issue if there are more than one positional parameters)
         'Z'        : posz = 'kw("' + tags(i) + '")'
All other keywords just get appended to the "key" string
         ELSE       : key = key + ', ' + tags(i) + '=kw("' + tags(i) + '")'
      ENDCASE
   ENDFOR
Now use EXECUTE to actually create the 3D Bar chart in the Z buffer
   status = EXECUTE('BAR3D, ' + posz + key)
We use the convenience routine "CloseZBuff" to copy the contents of the Z buffer to a variable and call the "WriteImage" procedure to save it as a gif file.
   CloseZBuff, file
The optional "UpdateLog" procedure will update a file with a log entry for this plot.
   dt_to_str, today(), d, t, date=1, time=-1
   desc = 'Plot created '+d+' '+t
   UpdateLog, desc, file, 0

END

Back
Copyright © 1996 - Visual Numerics, Inc.®