note | Refer to the PV-WAVE Reference for information on the EXECUTE, PLOT, and OPLOT commands. These PV‑WAVE commands are used in the following example. |
; JWAVE wrapper that unpacks positional and keyword parameters
; and builds a command string.
FUNCTION JWAVE_PLOT_SIMPLE, client_data
; Determine plot type (Can also be done with [XY]Type)
CASE GETPARAM(client_data, 'SCALING', /Value, Default=0) OF
1: cmd = 'PLOT_OI'
2: cmd = 'PLOT_IO'
3: cmd = 'PLOT_OO'
ELSE: cmd = 'PLOT'
ENDCASE
; Get colors -- default is black lines on white background.
back = GET_NAMED_COLOR('BACKGROUND', Default='000000'xL)
fore = GET_NAMED_COLOR('COLOR', Default = 'ffffff'xL)
acol = GET_NAMED_COLOR('AXIS', Default = fore)
color_kwds = ', Background=back, Color=fore'
; Get allowed keywords for the PLOT command.
plot_kwds = GETPARAM(client_data, $
[ 'Box', 'Charsize', 'Charthick', 'Clip', 'Grid style', $
'Linestyle', 'Noclip', 'Nsum', 'Polar', 'Position', $
'Psym', 'Solid_Psym', 'Subtitle', 'Symsize', 'Thick', $
'Tick format', 'Ticklen', 'Title', 'XCharsize', $
'XGridstyle', 'XMar gin', 'XMinor', 'XRange', 'XStyle', $
'XTickformat', 'XTicklen', 'XTickname', 'XTicks', $
'XTickv', 'XTitle', 'XType', 'YCharsize', 'YGridstyle', $
'YMargin', 'YMinor', 'YNozero', 'YRange', 'YStyle', $
'YTickformat', 'YTicklen', 'YTickname', 'YTicks', $
'YTickv', 'YTitle', 'YType' ] )
; Get positional data.
y = GETPARAM(client_data, 'Y', /Positional) ; REQUIRED
IF y EQ '' THEN $
MESSAGE, 'Parameter Y is required.'
x = GETPARAM(client_data, 'X', /Positional) ; Optional
; Execute the plotting function to draw the axes.
status = EXECUTE( cmd + x + y + color_kwds + plot_kwds )
RETURN, 0
END
note | Parameter names are not case sensitive. They must begin with a letter, and can contain only alphanumeric characters and the underscore character (_). |
note | A client application that provides controls for generating and modifying the appearance of plots or other kinds of graphics probably needs to communicate positional and keyword parameter information to the server. The client user might use option menus to change the colors used in a plot, text fields to add plot titles, push buttons to add axes, and so on. The client developer must retrieve the parameter names and values from the user interface, package those parameters (with setParam and setNamedColor method calls), and send them to the server. As shown here, the JWAVE wrapper function then unpacks the parameters, generates the plot, and sends back a graphic for display on the client. |
CASE GETPARAM(client_data, 'SCALING', /Value, Default=0) OF
1: cmd = 'PLOT_OI'
2: cmd = 'PLOT_IO'
3: cmd = 'PLOT_OO'
ELSE: cmd = 'PLOT'
ENDCASE
plot_kwds = GETPARAM(client_data, $
[ 'Box', 'Charsize', 'Charthick', 'Clip', 'Gridstyle', $
'Linestyle', 'Noclip', 'Nsum', 'Polar', 'Position', 'Psym', $
'Solid_Psym', 'Subtitle', 'Symsize', 'Thick', 'Tickformat', $
'Ticklen', 'Title', 'XCharsize', 'XGridstyle', 'XMargin', $
'XMinor', 'XRange', 'XStyle', 'XTickformat', 'XTicklen', $
'XTickname', 'XTicks', 'XTickv', 'XTitle', 'XType', $
'YCharsize', 'YGridstyle', 'YMargin', 'YMinor', 'YNozero', $
'YRange', 'YStyle', 'YTickformat', 'YTicklen', 'YTickname', $
'YTicks', 'YTickv', 'YTitle', 'YType' ] )
”, keyname_1=value_reference, keyname_2=value_reference, ... ”
” , Title=title_ref, Ticklen=tick_ref, Charsize=charsize_ref ”
note | The list of keywords given in this GETPARAM function example represents all of the keywords that can be extracted. Any keywords in the list that are not sent by the client are simply ignored by GETPARAM. If no keywords are sent, this GETPARAM function would return a null (empty) string. |
tip | We recommend that you use a string array (as was done in this example) to specify which keywords you wish to retrieve with GETPARAM. By specifying a string of names in GETPARAM, rather than using the /All keyword, you prevent your program from failing if the client sends unexpected information. |
y = GETPARAM(client_data, 'Y', /Positional) ; REQUIRED
IF y EQ '' THEN $
MESSAGE, 'Parameter Y is required.'
x = GETPARAM(client_data, 'X', /Positional)
PLOT, y, Title='CO2 Content', Charsize=3
note | For more information on JWAVE graphics and color parameters, see
JWAVE Graphics. See also
"Managing the Color Table". |
JWAVE wrapper calls retrieve colors sent from the client.
back = GET_NAMED_COLOR('BACKGROUND', Default='000000'xL)
fore = GET_NAMED_COLOR('COLOR', Default = 'ffffff'xL)
axis = GET_NAMED_COLOR('AXIS', Default = fore)
myJWaveView.setNamedColor(”BACKGROUND”, java.awt.Color.lightGray)
myJWaveView.setNamedColor(”COLOR”, java.awt.Color.red)
myJWaveView.setNamedColor(”AXIS”, java.awt.Color.black)