ElVis Java Interface

sv.graph
Class GraphWindow

java.lang.Object
  extended bysv.graph.GraphWindow
All Implemented Interfaces:
java.io.Serializable

public class GraphWindow
extends java.lang.Object
implements java.io.Serializable

The GraphWindow is the object interface to ElVis. Application programs that can use Java objects and methods can send data to ElVis using the GraphWindow object.

The GraphWindow class defines the methods and data for defining a grid of graphs. Each cell of the grid contains one graph. A graph contains one or more datasets.

The cells can be interactively resized using the mouse. Dragging the right edge of a graph changes the width of all the graphs in a column. Dragging the bottom edge of a graph changes the height of all the graphs in the row. Dragging the lower right corner of a graph with mouse button 1 simultaneously changes column width and row height. Dragging the lower right corner with mouse button 3 resizes the graph while maintaining its aspect ratio.

A GraphWindow contains other Java classes which encapsulate the elements of a graph. A GraphWindow contains one or more graphs defined by the Fx, Fxi, Fxt, Surface, or Contour class. Each graph contains one or more datasets defined by the Data1D class. An Fx graph has an X axis and a Y axis. A graph has built in labels for the title, X Axis, Y Axis, and index. Additional labels can be drawn using the GLabel class or the addLabel method.

A program that sends GraphWindows to ElVis is a data source. The program creates a DataSource object to identify itself and send data to ElVis where it is displayed. An example program for drawing a graph:

  import sv.graph.*;
  import java.awt.*;

  public class ESample {
       static DataSource dataSource;

       public static void main(String[] args) {
               dataSource = new DataSource();

               boolean status = dataSource.register();

               if (!status) {
                       System.out.println("Could not register with ElVis");
                       System.exit(1); 
               }

               drawGraph();

               dataSource.exit();
       }

       public static void drawGraph() {
               GraphWindow gw = new GraphWindow("Label Example");

               Fx graph = new Fx("Graph Comparison");

               int nPoints = 20; 
               float [] x = new float [nPoints];
               float [] x2 = new float [nPoints];
               float [] fx = new float [nPoints];
               float [] gx = new float [nPoints];

               for (int i=0; i<nPoints; i++) {
                       x[i] = (float) i;
                       x2[i] = (float) i/2;
                       fx[i] = (float) i;
                       gx[i] = (float) 3*i;
               }

               Data1D dataset = new Data1D("linear", nPoints, x, fx);
               Data1D dataset2 = new Data1D("scaled", nPoints, x2, gx);

               graph.addDataset(dataset);
               graph.addDataset(dataset2);

               graph.setXLabel("Distance");
               graph.setYLabel("Speed");

               Color blue = new Color(0.f, 0.f, 1.f);

               graph.addLabel("Serif", .15f, .8f, "Serif", "Plain", .06f, blue, 0.f);
               graph.addLabel("Bold", .46f, .8f, "Serif", "Bold", .06f, blue, 0.f);
               graph.addLabel("Italic", .60f, .8f, "Serif", "Italic", .06f, blue, 0.f);

               graph.addLabel("Symbol", .15f, .5f, "Symbol", "Plain", .06f, blue, 0.f);
               graph.addLabel("??", .46f, .5f, "Symbol", "Bold", .06f, blue, 0.f);
               graph.addLabel("?", .60f, .5f, "Symbol", "Italic", .06f, blue, 0.f);

               gw.addGraph(graph, 0, 0);

               dataSource.write(gw);
       }
  }
 

See Also:
Serialized Form

Field Summary
 int currentFrame
           
static int DATATABLE
          data table
static int FX
          f(x) graph, datasets are not indexed.
static int FXI
          f(x,i) graph, datasets with arbitrary index.
static int FXT
          f(x,t) graph, datasets indexed by time.
static int FXT_ADD_POINTS
          f(x,t) graph, datasets indexed by time.
static int FXY
          f(x,y) graph
 Interaction interaction
           
 boolean isInteraction
           
static int MIXED
          The GraphWindow contains more than 1 type of graph.
 java.lang.String name
           
 int originalClient
           
 int shot
           
static int SURFACE
          The graph is a surface plot
 WhiteBoard whiteboard
           
 
Constructor Summary
GraphWindow(java.lang.String gwName)
           
 
Method Summary
 void addFxt(GraphWindow graphWindow)
          Add an Fxt dataset to an existing graph that is already displayed.
 int addGraph(DataTable table, int row, int column)
          Add a table to a specific cell in the GraphWindow.
 int addGraph(Fx graph)
          Add a graph to the first empty cell in the GraphWindow.
 int addGraph(Fx graph, int row, int column)
          Add a graph to a specific cell in the GraphWindow.
 void addPoints(GraphWindow gw)
          Add points to an existing dataset that is already displayed.
 int appendGraph(Fx graph, boolean growth)
          Append an Fx graph to the GraphWindow.
 GraphWindow definition()
           
 int display(java.io.DataOutputStream out, int handle)
           
 void fxtAddPoints(GraphWindow graphWindow)
          Add points to existing time steps already displayed
 int getColumns()
          Return the number of columns of graphs in the GraphWindow.
 java.lang.String getName()
          Get the name of the GraphWindow.
 int getRows()
          Return the number of rows of graphs in the GraphWindow.
 int getType()
           
 int printGraph(java.lang.String server, int port, int row, int column, java.lang.String fileName)
          Print a graph.
 int read(java.io.DataInputStream in)
           
 GraphWindow readSerial(java.io.DataInputStream in)
           
 void setLayout(int rows, int columns)
          Set the number of rows and columns for the grid of graphs.
 void setName(java.lang.String windowName)
          Set the name of the GraphWindow.
 void setType(int type)
          Specify the type of graphs that will be in the GraphWindow.
 int write(java.io.DataOutputStream out)
          Write the GraphWindow to a socket stream
 int writeNetCDF(java.lang.String filename)
          Write the GraphWindow to a NetCDF file
 int writeSequential(java.io.DataOutputStream out)
          Write the GraphWindow to a stream
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

public java.lang.String name

originalClient

public int originalClient

shot

public int shot

isInteraction

public boolean isInteraction

interaction

public Interaction interaction

whiteboard

public WhiteBoard whiteboard

currentFrame

public int currentFrame

FX

public static final int FX
f(x) graph, datasets are not indexed.

See Also:
Constant Field Values

FXI

public static final int FXI
f(x,i) graph, datasets with arbitrary index.

See Also:
Constant Field Values

FXT

public static final int FXT
f(x,t) graph, datasets indexed by time.

See Also:
Constant Field Values

MIXED

public static final int MIXED
The GraphWindow contains more than 1 type of graph.

See Also:
Constant Field Values

SURFACE

public static final int SURFACE
The graph is a surface plot

See Also:
Constant Field Values

FXY

public static final int FXY
f(x,y) graph

See Also:
Constant Field Values

DATATABLE

public static final int DATATABLE
data table

See Also:
Constant Field Values

FXT_ADD_POINTS

public static final int FXT_ADD_POINTS
f(x,t) graph, datasets indexed by time. Can add points to all time steps

See Also:
Constant Field Values
Constructor Detail

GraphWindow

public GraphWindow(java.lang.String gwName)
Method Detail

display

public int display(java.io.DataOutputStream out,
                   int handle)

write

public int write(java.io.DataOutputStream out)
Write the GraphWindow to a socket stream

Parameters:
out - - The stream to another socket
Returns:
-

writeSequential

public int writeSequential(java.io.DataOutputStream out)
Write the GraphWindow to a stream

Parameters:
out - - The output stream
Returns:
-

writeNetCDF

public int writeNetCDF(java.lang.String filename)
Write the GraphWindow to a NetCDF file

Parameters:
filename - - The name of the file to create.
Returns:
-

printGraph

public int printGraph(java.lang.String server,
                      int port,
                      int row,
                      int column,
                      java.lang.String fileName)
Print a graph. Print a graph that is displayed in ElVis. The graph is printed to a PostScript file.

Parameters:
server - - The name of the computer running the ElVis display program.
port - - The number of the port on the server computer that ElVis is reading.
row - - The row in the GraphWindow containg the graph to be printed. The top row is row 0.
column - - The column in the GraphWindow containg the graph to be printed. The left most column is column 0.
fileName - - The name of the PostScript file to create.
Returns:
-

setType

public void setType(int type)
Specify the type of graphs that will be in the GraphWindow. A GraphWindow contains 1 or more graphs. Specifying the type of the graphs facilitates user interaction on a group of graphs.

Parameters:
type - - The type of graph(s) that will be in the GraphWindow. The types are: GraphWindow.FX (default), GraphWindow.FXI, GraphWindow.FXT, GraphWindow.MIXED.

getType

public int getType()

setName

public void setName(java.lang.String windowName)
Set the name of the GraphWindow. The name of the GraphWindow is shown in the title bar of the frame.

Parameters:
windowName - - The name of the GraphWindow.

getName

public java.lang.String getName()
Get the name of the GraphWindow. The name of the GraphWindow is shown in the title bar of the frame.

Returns:
windowName - The name of the GraphWindow.

setLayout

public void setLayout(int rows,
                      int columns)
Set the number of rows and columns for the grid of graphs. A GraphWindow is initially created with 1 row and 1 column. Use this method to set the desired layout.

Parameters:
rows - - The number of rows.
columns - - The number of columns.

getRows

public int getRows()
Return the number of rows of graphs in the GraphWindow.

Returns:
The number of rows in the GraphWindow.

getColumns

public int getColumns()
Return the number of columns of graphs in the GraphWindow.

Returns:
The number of columns in the GraphWindow.

appendGraph

public int appendGraph(Fx graph,
                       boolean growth)
Append an Fx graph to the GraphWindow. NOT IMPLEMENTED. The graph is inserted into the first empty cell in row major order. If all cells already contain a graph then the growth parameter determines whether a new row is added to the GraphWindow or the first graph is removed.

Parameters:
graph - - The graph to add to the GraphWindow.
growth - - If true and all cells contain a graph then add a row to the GraphWindow. If false and all cells contain a graph then delete the graph from the first cell, shift all graphsback by 1 cell, insert this graph in the last cell.

addGraph

public int addGraph(Fx graph,
                    int row,
                    int column)
Add a graph to a specific cell in the GraphWindow. The graph is inserted in the specified row and column. If a graph is already in the cell, then it is replaced by this graph.

Parameters:
graph - - The graph to insert. The graph can be Fx, Fxi, Fxt, or a Surface.
row - - The row in the GraphWindow where the graph will be inserted. The top row is row 0.
column - - The column in the GraphWindow where the graph will be inserted. The left most column is column 0.

addGraph

public int addGraph(Fx graph)
Add a graph to the first empty cell in the GraphWindow. NOT IMPLEMENTED. The graph is added to the first empty cell in row major order. If all the cells contain a graph, then a new row is added and the graph is added to the new row.

Parameters:
graph - - The graph to insert. The graph can be Fx, Fxi, Fxt, or a Surface.

addGraph

public int addGraph(DataTable table,
                    int row,
                    int column)
Add a table to a specific cell in the GraphWindow. The table is inserted in the specified row and column. If a graph or table is already in the cell, then it is replaced by this table.

Parameters:
table - - The table to insert.
row - - The row in the GraphWindow where the table will be inserted. The top row is row 0.
column - - The column in the GraphWindow where the table will be inserted. The left most column is column 0.

addFxt

public void addFxt(GraphWindow graphWindow)
Add an Fxt dataset to an existing graph that is already displayed.

Parameters:
graphWindow - - This GraphWindow should consist of an Fxt graph that contains the dataset to be added. The name of this Fxt must match the name of the graph already displayed.

fxtAddPoints

public void fxtAddPoints(GraphWindow graphWindow)
Add points to existing time steps already displayed

Parameters:
graphWindow - - This GraphWindow should consist of an Fxt graph that contains the points to be added. Add points to each of the timesteps in the provided graph.

addPoints

public void addPoints(GraphWindow gw)
Add points to an existing dataset that is already displayed.


read

public int read(java.io.DataInputStream in)

readSerial

public GraphWindow readSerial(java.io.DataInputStream in)

definition

public GraphWindow definition()

ElVis Java Interface