All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class kraft.monitor.display.MonitorCanvas

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Canvas
                   |
                   +----kraft.monitor.display.MonitorCanvas

public class MonitorCanvas
extends Canvas
Provides the heart of the Monitor program. Deals with actually graphically displaying visualisable events onto a graphical canvas.

E.g. an agent registering itself with the Monitor is represented as a red circle...
a message passed between two agents is represented as a blue arrow between to circles.

All these events are treated as much as possible in the same way by the MonitorCanvas, as a DisplayEvent -- an event to be displayed.

The two DisplayEvents used in this canvas are:
Node : to represent a Monitorable agent
Link : to represent a Message passed between two Monitorable agents

Mouse events are passed from this canvas to the correct DisplayEvents (e.g. when a Node is clicked on) to allow the DisplayEvent to show more information if appropriate.

To aid comprehension, the canvas is split into various areas -- represented by Area objects which contain a number of Nodes -- the correct area for a node is chosen according to the Monitorable type of the agent (e.g. Monitorable.BROKER ).

Author:
Ted Francis
See Also:
MonitorGUI, DisplayEvent, mousePressedHasEffect, Node, Link, Area

Constructor Index

 o MonitorCanvas()

Method Index

 o add(String, Monitorable, int)
A new Monitorable agent has registered with the monitor.
 o clearEvents()
Clear all the display Events that are currently logged.
 o crossOutMessage(String, String, Message)
Cross out the Link representing the given message.
 o currentStep()
The current visualisation step
 o displayMessage(String, String, Message, Date, DisplayMonitor)
Stores the given message in preparation for it to be displayed on the canvas (as a Link between two Nodes).
 o getContextString()
Get a current string that is relevant to the current state of the visualisation.
 o getMessages()
 o getMinimumSize()
 o gotoStep(int)
Go to the step 'val' in the visualisation, if it exists.
 o nextStep()
Go to the next step in the visualisation, if there is one.
 o paint(Graphics)
Display the visualisation.
 o previousStep()
Go to the previous step in the visualisation, if there is one.
 o remove(String)
Removes the Node with the given name from the Nodes displayed on the canvas.
 o statusChange(String, String, DisplayMonitor)
Indicate a change in an agent's status.
 o totalSteps()
The current number of visualisation steps (display events)
 o update(Graphics)

Constructors

 o MonitorCanvas
 public MonitorCanvas()

Methods

 o add
 public void add(String name,
                 Monitorable agent,
                 int type)
A new Monitorable agent has registered with the monitor. Add it to the canvas and handle the visualisation of it.

(Creates a new Node object to deal with this Monitorable)

Parameters:
type - the Monitorable type
See Also:
BROKER
 o remove
 public void remove(String name)
Removes the Node with the given name from the Nodes displayed on the canvas. Used when an agent deRegisters.

 o getMessages
 public String[] getMessages()
 o update
 public void update(Graphics g)
Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Display the visualisation. Calls paint(g) on all the Areas and the current DisplayEvent so that they display on the canvas.

Overrides:
paint in class Canvas
See Also:
Area, DisplayEvent
 o nextStep
 public void nextStep()
Go to the next step in the visualisation, if there is one.

 o previousStep
 public void previousStep()
Go to the previous step in the visualisation, if there is one.

 o gotoStep
 public void gotoStep(int val)
Go to the step 'val' in the visualisation, if it exists.

 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class Component
 o clearEvents
 public void clearEvents()
Clear all the display Events that are currently logged. Effect will be to reduce the visualisation to just a picture of the currently registered Monitorables. The number of visualisation steps will then be zero.

 o totalSteps
 public int totalSteps()
The current number of visualisation steps (display events)

 o currentStep
 public int currentStep()
The current visualisation step

 o getContextString
 public String getContextString()
Get a current string that is relevant to the current state of the visualisation.

 o statusChange
 public void statusChange(String name,
                          String comment,
                          DisplayMonitor dispmon)
Indicate a change in an agent's status.

Parameters:
name - the name of the Monitorable agent
comment - the status 'comment' that should be used
dispmon - the setDisplayed(true) method will be called once this change has been visualised -- allows the caller to keep track of this happening.
 o crossOutMessage
 public void crossOutMessage(String from,
                             String to,
                             Message msg)
Cross out the Link representing the given message. Indicates that the Message was not correctly delivered.

 o displayMessage
 public void displayMessage(String from,
                            String to,
                            Message msg,
                            Date time,
                            DisplayMonitor dispmon)
Stores the given message in preparation for it to be displayed on the canvas (as a Link between two Nodes).

Parameters:
from - The name of the Node this msg originates from
to - The name of the Node this msg is destined for
msg - The Message that is to be represented on screen
time - The time the message was received
dispmon - To allow the calling object to keep track of the message and determine when it is displayed

All Packages  Class Hierarchy  This Package  Previous  Next  Index