JWAVE

Java™ Graphic Components


Using JWAVE Components in your IFC applet or application

To include a JWAVE component in your IFC applet or application, follow the steps below:
  1. Create an instance of the component, which is a subclass of the Netscape IFC ContainerView, and specify the position and size of the view:
          plot = new WavePlot( 25, 30, 400, 300 );
    
  2. Now call one of the following methods to define where the PV-WAVE based graphic server is to be accessed:
          plot.setServer( "http://vrml.boulder.vni.com.:9000" );
      or
          plot.setLocalServer("C:\\jwave\\waveserver");
    
    (Note that a double backslash is needed to place a backslash in a string object in Java)

    The setServer() method specifies the URL of the server which has a "waveserver" script in its cgi-bin directory. Communications with the PV-WAVE graphic server is performed through this CGI script.

    The setLocalServer() method specifies a local directory which a PV-WAVE process running the "LocalServer" procedure uses to communicate with the applet via files.

  3. You can now set attributes of the plot, usually with "set" methods which use the same name as the corresponding PV-WAVE positional or keyword parameters. Here are some examples of attributes you can set:
          plot.reset();                       // Reset all attributes
          plot.setTitle( "WavePlot Test" );   // Set the title
          plot.setXTitle( "X Axes" );         // Set axes titles
          plot.setYTitle( "Y Axes" );         
          plot.TEK_COLOR();                   // Use the 32 Tectronix colors
          plot.setBackground("blue");         // Set background color
          plot.setColor( 3 );                 // Set plot color
          plot.setLinestyle( 2 );             // Set line style
    
    Keep in mind that PV-WAVE is using a 256 color palette and all of its color handling functions apply, and that colors are specified by an index into this palette (although some JWAVE methods are overloaded to also accept the standard java color names). You can call methods like LOADCT() and TEK_COLOR() to change Wave's color palette.

  4. To define the data to plot, you can call a method like setY():
          double[] data = new double[200];
          for(int i =0; i<200; i++) data[i]=Math.sin(i*0.1);
          plot.setY( data );
    
    Methods like setY() are overloaded to accept data of type int, float, double, Vector, and even String (where the data is assumed to be tab separated numbers).

    The setZ() method is also overloaded to accept a variable followed by two integers which define a two dimensional grid represented by the data. This is required for Surface and Contour plots.

    An important point to remember is that calling methods like setY() does NOT create a new copy of your data, but just a reference to it (i.e. using the assignment operator "=" in Java). Thus be careful not to change the data between the setY() method call and the plot() method call, as the data sent to PV-WAVE will be affected.

  5. Finally, when you are ready to create the plot just call the plot() method:
          plot.plot();
    
    This causes PV-WAVE to be contacted, the plot produced, and the plot displayed in your applet/application. In the case of a VRML world, as with the Wave VRMLSurface() class, a new instance of your browser is invoked and the VRML world displayed in it.

  6. After the plot is displayed, you are free to change attributes and data, and to re-display the plot by calling the plot() method again. Also, if you have created an animation, as with the WaveSurfAnim() class, you can call methods like start(), stop(), setFrameRate(), and setPlaybackMode() to control the animation.

Please refer to the JWAVE Reference Documentation for specific API information. See the Simple Example for a minimal applet using the WavePlot() class, or refer to the JWAVE Examples for examples of using all of the JWAVE components in more complicated interfaces.


JWAVE Home Page
Copyright © 1996 - Visual Numerics, Inc.®