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
-
connectHostName
-
-
connectHostPort
-
-
dataAddr
- The name of the data directory for the application.
-
done
- A flag that will be set true when we handle an EXIT request.
-
DUMP_ALL_NODES
-
-
DUMP_NON_ORPHAN_NODES
-
-
DUMP_ORPHAN_NODES
-
-
eventQueue
- A vector of ActionEvents from menu invocations
-
FILE_INPUT
-
-
fileDirectory
-
-
fileSize
-
-
frame
- The main window of the application or applet.
-
hostName
- The name of the data collection host.
-
hostPort
- The port number for connecting to the data collection host.
-
inputType
- An indication of the type of input being read.
-
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
-
muHandler
- The thread responsible for reading ModelUpdates and posting
them to this thread.
-
NO_INPUT
-
-
SOCKET_INPUT
-
-
updateQueue
- A vector of ModelUpdates from the collection process.
-
userConfigName
-
-
userFileName
-
-
VisiMain(String, String, int, boolean)
- Constructs the processing thread.
-
addEvent(ActionEvent)
- Add an action event to the queue.
-
addException(Exception)
- Add an exception to the queue.
-
addUpdate(ModelUpdate)
- Add a model update to the queue.
-
clearUpdateQueue()
- Clear the update queue.
-
closeReader(InputStreamReader)
- Close an input stream reader.
-
displayErrors(Vector, Vector)
- Display error messages returned by a parser.
-
dumpNodes(Network, int)
- Dump network nodes to the console for debugging.
-
handleException(Object)
- Handle exceptions from the update handling thread
-
handleUpdate(ModelUpdate)
- Handle model updates
-
netInfo(Network)
- Display information about the network being displayed.
-
openConfig(VisiConfig, String, CancelDialog)
- Handle a CONFIG request.
-
openConnection(String, int)
- Open a connection to a data collection process.
-
openFileStream(String)
- Open a file reader.
-
openStream(String)
- Let the user choose a URL or file and open it.
-
openUpdateFile()
- Open a file of serialized ModelUpdates.
-
openURLStream(String)
- Open a URL stream.
-
performAction(ActionEvent)
- Handle menu choices.
-
promptForAreaName(VisiFrame, VisiConfig, Area, String, String, Point)
- Get an area name from the user.
-
renameSelectedArea()
- Rename the selected area.
-
run()
- Main line code.
-
saveConfig(VisiConfig, boolean)
- Handle a CONFIG SAVE or CONFIG SAVE AS request.
-
saveImage(DisplayCanvas, String, CancelDialog, int)
- Save the current image as a GIF or JPEG file.
-
setFrame(VisiFrame)
- Set the frame.
frame
private VisiFrame frame
- The main window of the application or applet.
muHandler
private UpdateHandler muHandler
- The thread responsible for reading ModelUpdates and posting
them to this thread.
dataAddr
private String dataAddr
- The name of the data directory for the application.
hostName
private String hostName
- The name of the data collection host.
hostPort
private int hostPort
- The port number for connecting to the data collection host.
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
eventQueue
private Vector eventQueue
- A vector of ActionEvents from menu invocations
updateQueue
private Vector updateQueue
- A vector of ModelUpdates from the collection process.
done
private boolean done
- A flag that will be set true when we handle an EXIT request.
inputType
private int inputType
- An indication of the type of input being read.
NO_INPUT
private static final int NO_INPUT
FILE_INPUT
private static final int FILE_INPUT
SOCKET_INPUT
private static final int SOCKET_INPUT
fileDirectory
private String fileDirectory
userFileName
private String userFileName
userConfigName
private String userConfigName
fileSize
private long fileSize
connectHostName
private String connectHostName
connectHostPort
private int connectHostPort
DUMP_ALL_NODES
private static final int DUMP_ALL_NODES
DUMP_ORPHAN_NODES
private static final int DUMP_ORPHAN_NODES
DUMP_NON_ORPHAN_NODES
private static final int DUMP_NON_ORPHAN_NODES
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.
addEvent
public void addEvent(ActionEvent event)
- Add an action event to the queue.
- Parameters:
- event - the event to be added.
addUpdate
public void addUpdate(ModelUpdate update)
- Add a model update to the queue.
- Parameters:
- update - the update to be added.
clearUpdateQueue
public void clearUpdateQueue()
- Clear the update queue.
addException
public void addException(Exception exception)
- Add an exception to the queue.
- Parameters:
- exception - the exception to be added.
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
performAction
private void performAction(ActionEvent e)
- Handle menu choices.
- Parameters:
- e - the event to be handled.
handleUpdate
private void handleUpdate(ModelUpdate update)
- Handle model updates
- Parameters:
- update - the update to be handled.
handleException
private void handleException(Object ex)
- Handle exceptions from the update handling thread
- Parameters:
- ex - the exception to be handled.
renameSelectedArea
public void renameSelectedArea()
- Rename the selected area.
netInfo
private void netInfo(Network net)
- Display information about the network being displayed.
- Parameters:
- net - the network we want information about.
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.
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.
openConnection
private void openConnection(String name,
int port)
- Open a connection to a data collection process.
openUpdateFile
private void openUpdateFile()
- Open a file of serialized ModelUpdates.
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.
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.
openURLStream
private InputStream openURLStream(String name)
- Open a URL stream.
- Returns:
- an InputStream for the chosen URL;
null if it could not be opened.
openFileStream
private InputStream openFileStream(String name)
- Open a file reader.
- Returns:
- an InputStream for the chosen file;
null if it could not be opened.
closeReader
private void closeReader(InputStreamReader reader)
- Close an input stream reader.
- Parameters:
- reader - the input stream reader to be closed.
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.
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.
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.
setFrame
public void setFrame(VisiFrame frame)
- Set the frame.
- Parameters:
- frame - the application's main display frame.