jade.tools.sniffer
Class MMCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--javax.swing.JPanel
                          |
                          +--jade.tools.sniffer.MMCanvas

public class MMCanvas
extends javax.swing.JPanel
implements java.awt.event.MouseListener, java.io.Serializable

Manages agents and messages on both canvas. It holds an agent list, a message list and all necessary methods for adding, removing and drawing these object. It also registers ad handles events from mouse

Author:
Gianluca Tanca
See Also:
JPanel, MouseListener, Serialized Form

Inner classes inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
 
Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Field Summary
static AgentList al
           
static MessageList ml
           
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
MMCanvas(boolean type, SnifferGUI theGui, javax.swing.JPanel thePanel)
          Crates a new canvas: it can be an Agent Canvas or a Message Canvas
 
Method Summary
 void addAgent(Agent agent)
          Adds an agent to canvas agent then repaints it
 void addMessage(Message mess)
          Adds a message to canvas message then repaints the canvas
 AgentList getAgentList()
          Returns an handler to the agent list.
 MessageList getMessageList()
          Returns an handler to the message list.
 boolean isPresent(java.lang.String agName)
          Looks if an agent is present on Agent Canvas
 void mouseClicked(java.awt.event.MouseEvent evt)
          This method is invoked every time a user double-click on an agent on the agent canvas or on a blue arrow in the message canvas: if the double-click event occurs on an agent, this one is removed from the agent canvas; if the double-click occurs on a blue arrow in the message canavs, a dialog box is displayed with the entire message.
 void mouseEntered(java.awt.event.MouseEvent evt)
           
 void mouseExited(java.awt.event.MouseEvent evt)
           
 void mousePressed(java.awt.event.MouseEvent evt)
          Method invoked everytime the use clicks on a blue arrow: it updates the TextMessage component displaying the type of the message.
 void mouseReleased(java.awt.event.MouseEvent evt)
           
 void paintComponent(java.awt.Graphics g)
          Default method for custom painting.
 void recMessage(Message newMess)
          Returns new messages and put them into canvas agent
 void removeAgent(java.lang.String agentName)
          Removes an agent from the canvas agent then repaints it
 void removeAllAgents()
          Removes all the agents and messages from their lists then repaints the canvas
 void removeAllMessages()
          Removes all the messages in the message list then repaints the canvas
 Agent selAgent(java.awt.event.MouseEvent evt)
          Returns an Agent if an Agent has been selected form the user, otherwise returns null.
 Message selMessage(java.awt.event.MouseEvent evt)
          Returns a Message if a message has been selected form the user, otherwise returns null.
 void setAgentList(AgentList savedList)
          Set the agent list handler as the parameter passed then repaints the canvas
 void setMessageList(MessageList savedList)
          Set the message list handler as the parameter passed then repaints the canvas
 
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUIClassID, paramString, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInsets, getInsets, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintImmediately, paintImmediately, processComponentKeyEvent, processFocusEvent, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hide, imageUpdate, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

al

public static AgentList al

ml

public static MessageList ml
Constructor Detail

MMCanvas

public MMCanvas(boolean type,
                SnifferGUI theGui,
                javax.swing.JPanel thePanel)
Crates a new canvas: it can be an Agent Canvas or a Message Canvas
Parameters:
type - this has to be true for the Agent Canvas and false for the Message Canvas
theGui - handler to the main windows (for callback purpose)
thePanel - handler to the panel (Container) in which the canavs is created
Method Detail

paintComponent

public void paintComponent(java.awt.Graphics g)
Default method for custom painting. Every statement that paint something on both canvas is included here.
Parameters:
g - graphic context
Overrides:
paintComponent in class javax.swing.JComponent

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Method invoked everytime the use clicks on a blue arrow: it updates the TextMessage component displaying the type of the message.
Specified by:
mousePressed in interface java.awt.event.MouseListener
Parameters:
evt - mouse event

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
This method is invoked every time a user double-click on an agent on the agent canvas or on a blue arrow in the message canvas: if the double-click event occurs on an agent, this one is removed from the agent canvas; if the double-click occurs on a blue arrow in the message canavs, a dialog box is displayed with the entire message.
Specified by:
mouseClicked in interface java.awt.event.MouseListener
Parameters:
evt - mouse event

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

selMessage

public Message selMessage(java.awt.event.MouseEvent evt)
Returns a Message if a message has been selected form the user, otherwise returns null.
Parameters:
evt - mouse event
Returns:
Message selected or null if no Message was selected

selAgent

public Agent selAgent(java.awt.event.MouseEvent evt)
Returns an Agent if an Agent has been selected form the user, otherwise returns null.
Parameters:
evt - mouse event
Returns:
Agent selected or null if no Agent was selected

addAgent

public void addAgent(Agent agent)
Adds an agent to canvas agent then repaints it
Parameters:
agent - agent to be add

removeAgent

public void removeAgent(java.lang.String agentName)
Removes an agent from the canvas agent then repaints it
Parameters:
agentName - agent to be removed

removeAllAgents

public void removeAllAgents()
Removes all the agents and messages from their lists then repaints the canvas

addMessage

public void addMessage(Message mess)
Adds a message to canvas message then repaints the canvas
Parameters:
mess - message to be added

removeAllMessages

public void removeAllMessages()
Removes all the messages in the message list then repaints the canvas

isPresent

public boolean isPresent(java.lang.String agName)
Looks if an agent is present on Agent Canvas
Parameters:
agName - agent name to look for
Returns:
true if agent is present, false otherwise

getAgentList

public AgentList getAgentList()
Returns an handler to the agent list. The agent list contains all the agents contained in the Agent Canvas displayed by grey or red boxes
Returns:
handler to agent list

getMessageList

public MessageList getMessageList()
Returns an handler to the message list. The message list contains all sniffed messages displayed on the Message Canavs as blue arrows
Returns:
handler to the message list

setAgentList

public void setAgentList(AgentList savedList)
Set the agent list handler as the parameter passed then repaints the canvas
Parameters:
savedList - new list of agents

setMessageList

public void setMessageList(MessageList savedList)
Set the message list handler as the parameter passed then repaints the canvas
Parameters:
savedList - new list of messages

recMessage

public void recMessage(Message newMess)
Returns new messages and put them into canvas agent
Parameters:
newMess - new message