Class DisplayCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----DisplayCanvas

public class DisplayCanvas
extends Canvas
Class definition for a canvas for drawing an IP/ATM network.

Version:
$Revision: 1.7 $, $Date: 2000/10/12 14:07:48 $
Author:
John Cavanaugh

Variable Index

 o actualSize
The actual size of the display canvas.
 o defaultCursor
The default cursor.
 o definedSize
The size of the display canvas desired by the applet.
 o frame
The parent frame.
 o FRAME_MARGIN
 o mode
The display mode.
 o mouseListener
The active mouse listener.
 o net
The IP/ATM network being displayed.
 o NEW_AREA_MODE
 o NORMAL_MODE
 o SEL_SQ_SIZE
 o view
The view settings that control the display.
 o WAIT_MODE

Constructor Index

 o DisplayCanvas(Dimension, VisiFrame, Network, ViewSettings)
Constructs a display canvas.

Method Index

 o clearCanvas(Graphics)
Prepares the drawing area by clearing it to the background color.
 o frameCanvas(Graphics)
Draws a frame around the display canvas.
 o getBandwidthString(long)
Converts a bandwidth in cells per second to a string giving the bandwidth in Kbps or Mbps.
 o getDisplaySize()
Gets the size to use when drawing on the canvas.
 o getImage()
Gets an image of the display.
 o getMode()
Gets the display mode
 o getNetwork()
Gets the network being displayed.
 o getTimeString(long)
Converts a time in hundredths of a second to a string giving days, hours, minutes, and seconds.
 o getView()
Gets the view settings.
 o paint(Graphics)
Paints the display canvas.
 o rectInside(Rectangle, Rectangle)
Check whether one rectangle is inside another.
 o setMode(int)
Sets the display mode.
 o setSizes()
Gets the current size of the display canvas and sets the size attributes.
 o setView(ViewSettings)
Sets the view settings.
 o update(Graphics)
Updates the display.

Variables

 o NORMAL_MODE
 public static final int NORMAL_MODE
 o WAIT_MODE
 public static final int WAIT_MODE
 o NEW_AREA_MODE
 public static final int NEW_AREA_MODE
 o SEL_SQ_SIZE
 public static final int SEL_SQ_SIZE
 o FRAME_MARGIN
 public static final int FRAME_MARGIN
 o actualSize
 private Dimension actualSize
The actual size of the display canvas.

 o definedSize
 private Dimension definedSize
The size of the display canvas desired by the applet.

 o net
 private Network net
The IP/ATM network being displayed.

 o view
 private ViewSettings view
The view settings that control the display.

 o mode
 private int mode
The display mode.

 o frame
 private VisiFrame frame
The parent frame.

 o mouseListener
 private VisiMouseListener mouseListener
The active mouse listener.

 o defaultCursor
 public Cursor defaultCursor
The default cursor.

Constructors

 o DisplayCanvas
 public DisplayCanvas(Dimension definedSize,
                      VisiFrame frame,
                      Network net,
                      ViewSettings view)
Constructs a display canvas.

Parameters:
definedSize - the size for the display canvas.
frame - the parent frame.
net - the network to display.
view - the view settings.

Methods

 o getNetwork
 public Network getNetwork()
Gets the network being displayed.

Returns:
the network being displayed.
 o getDisplaySize
 public Dimension getDisplaySize()
Gets the size to use when drawing on the canvas.

Returns:
the size of the canvas.
 o getView
 public ViewSettings getView()
Gets the view settings.

Returns:
the view settings.
 o setView
 public void setView(ViewSettings view)
Sets the view settings.

Parameters:
view - the view settings.
 o getMode
 public int getMode()
Gets the display mode

Returns:
the display mode.
 o setMode
 public void setMode(int mode)
Sets the display mode.

Parameters:
mode - the new display mode.
 o getImage
 public Image getImage()
Gets an image of the display.

Returns:
an image of the display canvas.
 o update
 public void update(Graphics g)
Updates the display.

Parameters:
g - the graphics context for the display.
Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Paints the display canvas.

Parameters:
g - the graphics context for the display.
Overrides:
paint in class Canvas
 o clearCanvas
 private void clearCanvas(Graphics g)
Prepares the drawing area by clearing it to the background color.

Parameters:
g - the graphics context for the display.
 o frameCanvas
 private void frameCanvas(Graphics g)
Draws a frame around the display canvas.

Parameters:
g - the graphics context for the display.
 o setSizes
 public void setSizes()
Gets the current size of the display canvas and sets the size attributes.

 o rectInside
 public static boolean rectInside(Rectangle a,
                                  Rectangle b)
Check whether one rectangle is inside another.

Parameters:
a - the containing rectangle.
b - the contained rectangle.
Returns:
true if A contains all four corners of B; false otherwise.
 o getTimeString
 public static String getTimeString(long t)
Converts a time in hundredths of a second to a string giving days, hours, minutes, and seconds.

Parameters:
t - The time interval, in hundredths of a second.
Returns:
A string giving the time interval in readable units.
 o getBandwidthString
 public static String getBandwidthString(long b)
Converts a bandwidth in cells per second to a string giving the bandwidth in Kbps or Mbps.

Parameters:
b - The bandwidth, in cells per second.
Returns:
A string giving the bandwidth in readable units.