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 Node
s -- 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
-
MonitorCanvas()
-
-
add(String, Monitorable, int)
- A new Monitorable agent has registered with the monitor.
-
clearEvents()
- Clear all the display Events that are currently logged.
-
crossOutMessage(String, String, Message)
- Cross out the Link representing the given message.
-
currentStep()
- The current visualisation step
-
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).
-
getContextString()
- Get a current string that is relevant to the
current state of the visualisation.
-
getMessages()
-
-
getMinimumSize()
-
-
gotoStep(int)
- Go to the step 'val' in the visualisation, if it exists.
-
nextStep()
- Go to the next step in the visualisation, if there is one.
-
paint(Graphics)
- Display the visualisation.
-
previousStep()
- Go to the previous step in the visualisation, if there is one.
-
remove(String)
- Removes the Node with the given name from the Nodes displayed
on the canvas.
-
statusChange(String, String, DisplayMonitor)
- Indicate a change in an agent's status.
-
totalSteps()
- The current number of visualisation steps (display events)
-
update(Graphics)
-
MonitorCanvas
public MonitorCanvas()
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
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.
getMessages
public String[] getMessages()
update
public void update(Graphics g)
- Overrides:
- update in class Component
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
nextStep
public void nextStep()
- Go to the next step in the visualisation, if there is one.
previousStep
public void previousStep()
- Go to the previous step in the visualisation, if there is one.
gotoStep
public void gotoStep(int val)
- Go to the step 'val' in the visualisation, if it exists.
getMinimumSize
public Dimension getMinimumSize()
- Overrides:
- getMinimumSize in class Component
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.
totalSteps
public int totalSteps()
- The current number of visualisation steps (display events)
currentStep
public int currentStep()
- The current visualisation step
getContextString
public String getContextString()
- Get a current string that is relevant to the
current state of the visualisation.
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.
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.
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