Class VisiMain

java.lang.Object
   |
   +----java.lang.Thread
           |
           +----VisiMain

public class VisiMain
extends Thread
Class definition for the main VisiDisplay processing thread.

Version:
$Revision: 1.17 $, $Date: 2000/10/30 17:10:27 $
Author:
John Cavanaugh

Variable Index

 o connectHostName
 o connectHostPort
 o dataAddr
The name of the data directory for the application.
 o done
A flag that will be set true when we handle an EXIT request.
 o DUMP_ALL_NODES
 o DUMP_NON_ORPHAN_NODES
 o DUMP_ORPHAN_NODES
 o eventQueue
A vector of ActionEvents from menu invocations
 o FILE_INPUT
 o fileDirectory
 o fileSize
 o frame
The main window of the application or applet.
 o hostName
The name of the data collection host.
 o hostPort
The port number for connecting to the data collection host.
 o inputType
An indication of the type of input being read.
 o isApplet
A flag that is true if we are running as an applet in a browser, false if we are running as a Java application
 o muHandler
The thread responsible for reading ModelUpdates and posting them to this thread.
 o NO_INPUT
 o SOCKET_INPUT
 o updateQueue
A vector of ModelUpdates from the collection process.
 o userConfigName
 o userFileName

Constructor Index

 o VisiMain(String, String, int, boolean)
Constructs the processing thread.

Method Index

 o addEvent(ActionEvent)
Add an action event to the queue.
 o addException(Exception)
Add an exception to the queue.
 o addUpdate(ModelUpdate)
Add a model update to the queue.
 o clearUpdateQueue()
Clear the update queue.
 o closeReader(InputStreamReader)
Close an input stream reader.
 o displayErrors(Vector, Vector)
Display error messages returned by a parser.
 o dumpNodes(Network, int)
Dump network nodes to the console for debugging.
 o handleException(Object)
Handle exceptions from the update handling thread
 o handleUpdate(ModelUpdate)
Handle model updates
 o netInfo(Network)
Display information about the network being displayed.
 o openConfig(VisiConfig, String, CancelDialog)
Handle a CONFIG request.
 o openConnection(String, int)
Open a connection to a data collection process.
 o openFileStream(String)
Open a file reader.
 o openStream(String)
Let the user choose a URL or file and open it.
 o openUpdateFile()
Open a file of serialized ModelUpdates.
 o openURLStream(String)
Open a URL stream.
 o performAction(ActionEvent)
Handle menu choices.
 o promptForAreaName(VisiFrame, VisiConfig, Area, String, String, Point)
Get an area name from the user.
 o renameSelectedArea()
Rename the selected area.
 o run()
Main line code.
 o saveConfig(VisiConfig, boolean)
Handle a CONFIG SAVE or CONFIG SAVE AS request.
 o saveImage(DisplayCanvas, String, CancelDialog, int)
Save the current image as a GIF or JPEG file.
 o setFrame(VisiFrame)
Set the frame.

Variables

 o frame
 private VisiFrame frame
The main window of the application or applet.

 o muHandler
 private UpdateHandler muHandler
The thread responsible for reading ModelUpdates and posting them to this thread.

 o dataAddr
 private String dataAddr
The name of the data directory for the application.

 o hostName
 private String hostName
The name of the data collection host.

 o hostPort
 private int hostPort
The port number for connecting to the data collection host.

 o isApplet
 private boolean isApplet
A flag that is true if we are running as an applet in a browser, false if we are running as a Java application

 o eventQueue
 private Vector eventQueue
A vector of ActionEvents from menu invocations

 o updateQueue
 private Vector updateQueue
A vector of ModelUpdates from the collection process.

 o done
 private boolean done
A flag that will be set true when we handle an EXIT request.

 o inputType
 private int inputType
An indication of the type of input being read.

 o NO_INPUT
 private static final int NO_INPUT
 o FILE_INPUT
 private static final int FILE_INPUT
 o SOCKET_INPUT
 private static final int SOCKET_INPUT
 o fileDirectory
 private String fileDirectory
 o userFileName
 private String userFileName
 o userConfigName
 private String userConfigName
 o fileSize
 private long fileSize
 o connectHostName
 private String connectHostName
 o connectHostPort
 private int connectHostPort
 o DUMP_ALL_NODES
 private static final int DUMP_ALL_NODES
 o DUMP_ORPHAN_NODES
 private static final int DUMP_ORPHAN_NODES
 o DUMP_NON_ORPHAN_NODES
 private static final int DUMP_NON_ORPHAN_NODES

Constructors

 o VisiMain
 public VisiMain(String dataAddr,
                 String hostName,
                 int hostPort,
                 boolean isApplet)
Constructs the processing thread.

Parameters:
dataAddr - the name of the data directory for the application.
hostName - the name of the data collection host.
hostPort - the port number for connecting to the data collection host.
isApplet - true if we're running as an applet.

Methods

 o addEvent
 public void addEvent(ActionEvent event)
Add an action event to the queue.

Parameters:
event - the event to be added.
 o addUpdate
 public void addUpdate(ModelUpdate update)
Add a model update to the queue.

Parameters:
update - the update to be added.
 o clearUpdateQueue
 public void clearUpdateQueue()
Clear the update queue.

 o addException
 public void addException(Exception exception)
Add an exception to the queue.

Parameters:
exception - the exception to be added.
 o run
 public void run()
Main line code. Handle pending updates and events. When all events are taken care of, wait for something to happen.

Overrides:
run in class Thread
 o performAction
 private void performAction(ActionEvent e)
Handle menu choices.

Parameters:
e - the event to be handled.
 o handleUpdate
 private void handleUpdate(ModelUpdate update)
Handle model updates

Parameters:
update - the update to be handled.
 o handleException
 private void handleException(Object ex)
Handle exceptions from the update handling thread

Parameters:
ex - the exception to be handled.
 o renameSelectedArea
 public void renameSelectedArea()
Rename the selected area.

 o netInfo
 private void netInfo(Network net)
Display information about the network being displayed.

Parameters:
net - the network we want information about.
 o openConfig
 private void openConfig(VisiConfig config,
                         String file,
                         CancelDialog mon)
Handle a CONFIG request.

Parameters:
net - the network to read the file or configuration into.
file - the name of the file to open.
mon - a progress monitor dialog for the open.
 o saveConfig
 private void saveConfig(VisiConfig config,
                         boolean saveAs)
Handle a CONFIG SAVE or CONFIG SAVE AS request.

Parameters:
config - the configuration being displayed.
saveAs - true if this is a SAVE AS request; false if it is a SAVE request.
 o openConnection
 private void openConnection(String name,
                             int port)
Open a connection to a data collection process.

 o openUpdateFile
 private void openUpdateFile()
Open a file of serialized ModelUpdates.

 o saveImage
 private void saveImage(DisplayCanvas canvas,
                        String file,
                        CancelDialog mon,
                        int type)
Save the current image as a GIF or JPEG file.

Parameters:
canvas - the display canvas to be saved.
file - the image file name.
mon - a cancel dialog.
type - the type of image to save.
 o openStream
 private InputStream openStream(String name)
Let the user choose a URL or file and open it.

Returns:
an InputStream for the chose URL or file; null if it could not be opened.
 o openURLStream
 private InputStream openURLStream(String name)
Open a URL stream.

Returns:
an InputStream for the chosen URL; null if it could not be opened.
 o openFileStream
 private InputStream openFileStream(String name)
Open a file reader.

Returns:
an InputStream for the chosen file; null if it could not be opened.
 o closeReader
 private void closeReader(InputStreamReader reader)
Close an input stream reader.

Parameters:
reader - the input stream reader to be closed.
 o displayErrors
 private void displayErrors(Vector fatal,
                            Vector warning)
Display error messages returned by a parser.

Parameters:
fatal - a vector of fatal error messages.
warning - a vector of warning messages.
 o promptForAreaName
 public static String promptForAreaName(VisiFrame frame,
                                        VisiConfig config,
                                        Area area,
                                        String query,
                                        String startName,
                                        Point cursorLoc)
Get an area name from the user.

Parameters:
area - the area that needs a name.
query - the query to be posed to the user.
startName - the current or default name for the area.
cursorLoc - the location of the cursor in the display window.
Returns:
the name the user entered for the area.
 o dumpNodes
 private void dumpNodes(Network net,
                        int sel)
Dump network nodes to the console for debugging.

Parameters:
net - the network whose nodes are to be dumped.
sel - a selector choosing which nodes to dump.
 o setFrame
 public void setFrame(VisiFrame frame)
Set the frame.

Parameters:
frame - the application's main display frame.