llnl.visit
Class ViewerProxy

java.lang.Object
  extended by llnl.visit.ViewerProxy
All Implemented Interfaces:
ProxyInterface, SimpleObserver

public class ViewerProxy
extends java.lang.Object
implements SimpleObserver, ProxyInterface

ViewerProxy is the main class that users of the Java VisIt Interface need to use in order to control VisIt from Java. This class provides methods to launch VisIt's viewer and control it.
Example usage:

ViewerProxy proxy = new ViewerProxy();
// Set the path to the visit launch script
proxy.SetBinPath("/usr/local/apps/visit/bin");
// Add arguments before we launch the viewer.
proxy.AddArgument("-debug");
proxy.AddArgument("5");
// Launch the viewer, listening on port 5600
if(proxy.Create(5600))
{
    // Now that the viewer is running, do stuff.
    proxy.GetViewerMethods().OpenDatabase(proxy.GetDataPath()+"globe.silo");
    proxy.AddPlots("Pseudocolor", "speed");
    proxy.DrawPlots();
    proxy.SaveWindow();
    // We're done so close the viewer.
    proxy.Close();
}


Constructor Summary
ViewerProxy()
          Contructor for the ViewerProxy class.
 
Method Summary
 void AddArgument(java.lang.String arg)
          Adds extra arguments to the viewer's command line so you can launch VisIt with arguments that you provide.
 boolean Close()
          Tells the ViewerProxy to close the viewer.
 boolean Create(int port)
          Launches VisIt's viewer and performs the rest of the initialization of the ViewerProxy class, including loading plugins, starting a listener thread to read from the viewer.
protected  void finalize()
          Closes VisIt's viewer when the object is garbage collected.
 java.lang.String GetDataPath()
          Gets the data path directory, which is often a "data" directory peer to the "bin" directory provided via SetBinPath.
 EventLoop GetEventLoop()
          Get the event loop object.
 java.lang.String GetLastError()
          Gets the last error message that was encountered.
 int GetNumOperatorPlugins()
          Returns the number of operator plugins that were loaded.
 int GetNumPlotPlugins()
          Returns the number of plot plugins that were loaded.
 Plugin GetOperatorAttributes(int index)
          Convenience method that returns the state object for the operator plugin.
 Plugin GetOperatorAttributes(java.lang.String operatorName)
          Convenience method that returns the state object for the operator plugin.
 int GetOperatorIndex(java.lang.String operatorName)
          Convenience method that looks up the index of the named operator plugin in the operator plugin manager.
 java.lang.String GetOperatorName(int index)
          Convenience methods that looks up the name of the operator plugin in the operator plugin manager, given an index.
 java.lang.String GetOperatorVersion(int index)
          Convenience methods that returns the Operator plugin version for the specified plugin index.
 Plugin GetPlotAttributes(int index)
          Convenience method that returns the state object for the plot plugin.
 Plugin GetPlotAttributes(java.lang.String plotName)
          Convenience method that returns the state object for the plot plugin.
 int GetPlotIndex(java.lang.String plotName)
          Convenience method that looks up the index of the named plot plugin in the plot plugin manager.
 java.lang.String GetPlotName(int index)
          Convenience method that looks up the name of the plot plugin in the plot plugin manager, given an index.
 java.lang.String GetPlotVersion(int index)
          Convenience method that returns the plot plugin version for the specified plugin index.
 boolean GetSynchronous()
          Return whether the proxy is running with synchronization.
 boolean GetUpdate()
          This method implements the SimpleObserver interface and is called when we want to determine whether updates to a state object should cause this object's Update method to be called.
 ViewerMethods GetViewerMethods()
          Returns the ViewerMethods object, which is the container object that maps all method calls through it into ViewerRPC calls to the viewer.
 ViewerState GetViewerState()
          Returns the ViewerState object, which is the container object that holds all of the state objects that can be observed or manipulated in VisIt.
 boolean PluginsLoaded()
          Returns whether plugins have been loaded.
 void PrintMessage(java.lang.String msg)
          Prints a message to the console if the ViewerProxy object is in verbose mode.
 void SendInterruption()
          Sends an interruption message to the viewer, which can be used to interrupt processing of multiple domain datasets in the compute engine.
 void SetBinPath(java.lang.String path)
          Sets the location of the visit binary that Java will launch.
 void SetDataPath(java.lang.String path)
          Sets the data path directory.
 void SetSynchronous(boolean val)
          Sets whether the ViewerProxy will force synchronization with the viewer after calling methods from the ViewerMethods object.
 void SetUpdate(boolean val)
          This method implements the SimpleObserver interface and is called when we want to prevent updates from an observed state object to have an effect on this observer.
 void SetVerbose(boolean val)
          Sets a flag that determines if messages from the viewer are printed to the console.
 boolean Synchronize()
          Sends a synchronization message to the viewer and blocks until the viewer's reply to that message is read on the listener thread.
 void Update(AttributeSubject s)
          This method implements the SimpleObserver interface and is called when an observed state object changes, in this case, the plugin manager attributes state object.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ViewerProxy

public ViewerProxy()
Contructor for the ViewerProxy class. Basic initialization is performed.

Method Detail

finalize

protected void finalize()
                 throws java.lang.Throwable
Closes VisIt's viewer when the object is garbage collected.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

SetBinPath

public void SetBinPath(java.lang.String path)
Sets the location of the visit binary that Java will launch. The version of VisIt must be the same version as the Java client.

Parameters:
path - An absolute path to the "bin" directory containing the "visit" script.

GetDataPath

public java.lang.String GetDataPath()
Gets the data path directory, which is often a "data" directory peer to the "bin" directory provided via SetBinPath.

Returns:
The data path directory that you can use to access VisIt's built-in data files.

SetDataPath

public void SetDataPath(java.lang.String path)
Sets the data path directory.

Parameters:
path - An absolute path to the "data" directory.

AddArgument

public void AddArgument(java.lang.String arg)
Adds extra arguments to the viewer's command line so you can launch VisIt with arguments that you provide.

Parameters:
arg - A command line option to be added to the viewer command line. Note that once the viewer is launched, this method has no effect.

PrintMessage

public void PrintMessage(java.lang.String msg)
Prints a message to the console if the ViewerProxy object is in verbose mode.

Specified by:
PrintMessage in interface ProxyInterface
Parameters:
msg - The message to print.

Create

public boolean Create(int port)
Launches VisIt's viewer and performs the rest of the initialization of the ViewerProxy class, including loading plugins, starting a listener thread to read from the viewer.

Parameters:
port - The default port that will be used to listen for the viewer when it wants to connect back to the ViewerProxy. VisIt usually defaults to port 5600.
Returns:
true on success; false on failure.

SetSynchronous

public void SetSynchronous(boolean val)
Sets whether the ViewerProxy will force synchronization with the viewer after calling methods from the ViewerMethods object. Simple applications applications should perform synchronous processing since it makes the values returned from ViewerMethods functions take into account any errors that may have occurred while processing a request. Event-based applications should disable synchronous processing so they can send off commands to the viewer without blocking for return values. In the event that synchronization is truely needed in that case, you can always call the Synchronize() method.

Specified by:
SetSynchronous in interface ProxyInterface
Parameters:
val - true for synchronous processing; false for asynchronous.

GetSynchronous

public boolean GetSynchronous()
Return whether the proxy is running with synchronization.

Specified by:
GetSynchronous in interface ProxyInterface
Returns:
true for synchronous processing; false for asynchronous.

SetVerbose

public void SetVerbose(boolean val)
Sets a flag that determines if messages from the viewer are printed to the console.

Parameters:
val - True to make the ViewerProxy print verbose output.

Close

public boolean Close()
Tells the ViewerProxy to close the viewer. The ViewerProxy should not be used after calling this method since calling Create() again will not currently relaunch the viewer properly.

Returns:
true

SendInterruption

public void SendInterruption()
Sends an interruption message to the viewer, which can be used to interrupt processing of multiple domain datasets in the compute engine.

Specified by:
SendInterruption in interface ProxyInterface

Synchronize

public boolean Synchronize()
Sends a synchronization message to the viewer and blocks until the viewer's reply to that message is read on the listener thread.

Specified by:
Synchronize in interface ProxyInterface
Returns:
true if there were no errors; false otherwise.

GetEventLoop

public EventLoop GetEventLoop()
Get the event loop object.

Returns:
The event loop object.

GetLastError

public java.lang.String GetLastError()
Gets the last error message that was encountered. This method can be called after a Synchronize() call to get any errors that were posted.

Returns:
The last error message.

GetViewerState

public ViewerState GetViewerState()
Returns the ViewerState object, which is the container object that holds all of the state objects that can be observed or manipulated in VisIt. One will commonly get the viewer state and then get one of its state objects and make changes to it before calling the Notify() method on that state object to affect changes in the viewer.

Specified by:
GetViewerState in interface ProxyInterface
Returns:
The ViewerState object.
See Also:
ViewerState

GetViewerMethods

public ViewerMethods GetViewerMethods()
Returns the ViewerMethods object, which is the container object that maps all method calls through it into ViewerRPC calls to the viewer. There are a lot of methods that can be called and it improves maintainability to have the methods separated out.

Returns:
The ViewerMethods object.

GetPlotIndex

public int GetPlotIndex(java.lang.String plotName)
Convenience method that looks up the index of the named plot plugin in the plot plugin manager.

Specified by:
GetPlotIndex in interface ProxyInterface
Parameters:
plotName - The name of the plot to look for.
Returns:
The index of the plot in the plugin manager.

GetPlotName

public java.lang.String GetPlotName(int index)
                             throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that looks up the name of the plot plugin in the plot plugin manager, given an index.

Parameters:
index - The index of the plot.
Returns:
The name of the plot in the plugin manager.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetPlotVersion

public java.lang.String GetPlotVersion(int index)
                                throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that returns the plot plugin version for the specified plugin index.

Parameters:
index - The index of the plot.
Returns:
The version of the plot in the plugin manager.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetPlotAttributes

public Plugin GetPlotAttributes(int index)
                         throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that returns the state object for the plot plugin. You can access the state object via ViewerState too.

Parameters:
index - The index of the plot.
Returns:
The plot's state object. This is the object that you'd use to make changes in the plot's attributes, programmatically or through a GUI window, etc.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetPlotAttributes

public Plugin GetPlotAttributes(java.lang.String plotName)
                         throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that returns the state object for the plot plugin. You can access the state object via ViewerState too.

Parameters:
plotName - The name of the plot.
Returns:
The plot's state object. This is the object that you'd use to make changes in the plot's attributes, programmatically or through a GUI window, etc.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetNumPlotPlugins

public int GetNumPlotPlugins()
Returns the number of plot plugins that were loaded.

Returns:
The number of plot plugins that were loaded.

GetOperatorIndex

public int GetOperatorIndex(java.lang.String operatorName)
Convenience method that looks up the index of the named operator plugin in the operator plugin manager.

Specified by:
GetOperatorIndex in interface ProxyInterface
Parameters:
operatorName - The name of the plot to look for.
Returns:
The index of the operator in the plugin manager.

GetOperatorName

public java.lang.String GetOperatorName(int index)
                                 throws java.lang.ArrayIndexOutOfBoundsException
Convenience methods that looks up the name of the operator plugin in the operator plugin manager, given an index.

Parameters:
index - The index of the operator.
Returns:
The name of the operator in the plugin manager.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetOperatorVersion

public java.lang.String GetOperatorVersion(int index)
                                    throws java.lang.ArrayIndexOutOfBoundsException
Convenience methods that returns the Operator plugin version for the specified plugin index.

Parameters:
index - The index of the Operator.
Returns:
The version of the Operator in the plugin manager.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetOperatorAttributes

public Plugin GetOperatorAttributes(int index)
                             throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that returns the state object for the operator plugin. You can access the state object via ViewerState too.

Parameters:
index - The index of the operator.
Returns:
The operator's state object. This is the object that you'd use to make changes in the operator's attributes, programmatically or through a GUI window, etc.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetOperatorAttributes

public Plugin GetOperatorAttributes(java.lang.String operatorName)
                             throws java.lang.ArrayIndexOutOfBoundsException
Convenience method that returns the state object for the operator plugin. You can access the state object via ViewerState too.

Parameters:
operatorName - The name of the plot.
Returns:
The operator's state object. This is the object that you'd use to make changes in the operator's attributes, programmatically or through a GUI window, etc.
Throws:
java.lang.ArrayIndexOutOfBoundsException

GetNumOperatorPlugins

public int GetNumOperatorPlugins()
Returns the number of operator plugins that were loaded.

Returns:
The number of operator plugins that were loaded.

Update

public void Update(AttributeSubject s)
This method implements the SimpleObserver interface and is called when an observed state object changes, in this case, the plugin manager attributes state object. We use this method to load plugins when we get the list of loaded plugins from the viewer.

Specified by:
Update in interface SimpleObserver
Parameters:
s - The state object that was modified - in this case the plugin manager attributes.

SetUpdate

public void SetUpdate(boolean val)
This method implements the SimpleObserver interface and is called when we want to prevent updates from an observed state object to have an effect on this observer.

Specified by:
SetUpdate in interface SimpleObserver
Parameters:
val - True to make the update have an effect; false otherwise.

GetUpdate

public boolean GetUpdate()
This method implements the SimpleObserver interface and is called when we want to determine whether updates to a state object should cause this object's Update method to be called.

Specified by:
GetUpdate in interface SimpleObserver
Returns:
True if updates are enabled; false otherwise.

PluginsLoaded

public boolean PluginsLoaded()
Returns whether plugins have been loaded.

Returns:
True if have been loaded; false otherwise.