jade.tools.sniffer
Class TreeData

java.lang.Object
  |
  +--javax.swing.tree.DefaultMutableTreeNode
        |
        +--jade.tools.sniffer.TreeData
Direct Known Subclasses:
Agent

public class TreeData
extends javax.swing.tree.DefaultMutableTreeNode
implements java.io.Serializable

Class TreeData represents Agents, Containers and Agent-platforms in the Gui. The Object "TreeData" is a local representation of all the knowledge we have about an agent TreeData are FSM with only two states (RUNNING and SUSPENDED) and with four different levels (SUPER_NODE, AGENT_PLATFORM, CONTAINER, AGENT). The graphic representation of the state is given only for Agents, but Platforms and containers have their own state, too. The method loadChildren() must be rewritten to work properly

Author:
Gianluca Tanca
See Also:
Serialized Form

Field Summary
protected  java.lang.String[] addresses
           
static java.lang.String AddSeparator
           
static int AGENT
           
static int AGENT_PLATFORM
           
static int CONTAINER
           
protected static java.lang.String ContainerToolTip
           
protected  int currentState
           
protected  boolean hasLoaded
           
protected static javax.swing.Icon[] icons
           
protected  int Level
           
protected static java.lang.String[] LevelsNames
           
protected  java.lang.String name
           
static int RUNNING
           
protected static java.lang.String[] statesNames
           
static int SUPER_NODE
           
protected static java.lang.String SuperNodeToolTip
           
static int SUSPENDED
           
protected  java.lang.String type
           
 
Fields inherited from class javax.swing.tree.DefaultMutableTreeNode
allowsChildren, children, EMPTY_ENUMERATION, parent, userObject
 
Constructor Summary
TreeData(java.lang.String t)
          Defines a Agent with specific name
TreeData(java.lang.String t, int LevelP)
          Defines a Node with specific name, addresses, type and Level
TreeData(java.lang.String nameP, java.lang.String[] addressesP, java.lang.String typeP)
          Defines a Node with specific name, addresses, type and Level
TreeData(java.lang.String nameP, java.lang.String[] addressesP, java.lang.String typeP, int LevelP)
          Defines a Node with specific name, addresses, type and Level
 
Method Summary
 void addAddress(java.lang.String newAdd)
          Adds an address to a node
 java.lang.String getAddressesAsString()
          Returns the addresses of a node as a string
 int getChildCount()
          If the children have not yet been loaded, loadChildren is messaged and super is messaged for the return value.
 javax.swing.Icon getIcon()
          Returns an icon represententing the Level or the state if this is an Agent
 int getLevel()
          Returns the level of a node
 java.lang.String getName()
          Returns the name of the agent
 java.lang.String getStateName()
          Returns the state name of a node
 java.lang.String getToolTipText()
          Returns the ToolTipText of a node
 java.lang.String getType()
          Returns the type of a node of a node
 boolean isLeaf()
          A node is a Leaf only if it is an agent
protected  void loadChildren()
          Messaged the first time getChildCount is messaged.
 void setAddresses(java.lang.String[] aP)
          Sets the address of a node
 boolean setLevel(int LevelP)
          Sets the level of a node
 void setName(java.lang.String nameP)
          Sets a name of a node
 boolean setState(int state)
          Sets the state of an agent in a node
 void setType(java.lang.String r)
          Sets the type of a node
 java.lang.String toString()
           
 void transState()
          forces the Agent to go from current state to the other state
 
Methods inherited from class javax.swing.tree.DefaultMutableTreeNode
add, breadthFirstEnumeration, children, clone, depthFirstEnumeration, getAllowsChildren, getChildAfter, getChildAt, getChildBefore, getDepth, getFirstChild, getFirstLeaf, getIndex, getLastChild, getLastLeaf, getLeafCount, getNextLeaf, getNextNode, getNextSibling, getParent, getPath, getPathToRoot, getPreviousLeaf, getPreviousNode, getPreviousSibling, getRoot, getSharedAncestor, getSiblingCount, getUserObject, getUserObjectPath, insert, isNodeAncestor, isNodeChild, isNodeDescendant, isNodeRelated, isNodeSibling, isRoot, pathFromAncestorEnumeration, postorderEnumeration, preorderEnumeration, remove, remove, removeAllChildren, removeFromParent, setAllowsChildren, setParent, setUserObject
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

SUSPENDED

public static final int SUSPENDED

RUNNING

public static final int RUNNING

AddSeparator

public static final java.lang.String AddSeparator

SUPER_NODE

public static final int SUPER_NODE

AGENT_PLATFORM

public static final int AGENT_PLATFORM

CONTAINER

public static final int CONTAINER

AGENT

public static final int AGENT

ContainerToolTip

protected static java.lang.String ContainerToolTip

SuperNodeToolTip

protected static java.lang.String SuperNodeToolTip

statesNames

protected static java.lang.String[] statesNames

LevelsNames

protected static java.lang.String[] LevelsNames

icons

protected static javax.swing.Icon[] icons

name

protected java.lang.String name

type

protected java.lang.String type

currentState

protected int currentState

Level

protected int Level

addresses

protected java.lang.String[] addresses

hasLoaded

protected boolean hasLoaded
Constructor Detail

TreeData

public TreeData(java.lang.String nameP,
                java.lang.String[] addressesP,
                java.lang.String typeP,
                int LevelP)
Defines a Node with specific name, addresses, type and Level
Parameters:
nameP - name of the node
addressesP - array of addresses
typeP - type of the node
LevelP - level of the node

TreeData

public TreeData(java.lang.String nameP,
                java.lang.String[] addressesP,
                java.lang.String typeP)
Defines a Node with specific name, addresses, type and Level
Parameters:
nameP - name of the node
addressesP - array of addresses
typeP - type of the node

TreeData

public TreeData(java.lang.String t,
                int LevelP)
Defines a Node with specific name, addresses, type and Level
Parameters:
t - name of the node
LevelP - level of the node

TreeData

public TreeData(java.lang.String t)
Defines a Agent with specific name
Parameters:
t - name of the node
Method Detail

getIcon

public javax.swing.Icon getIcon()
Returns an icon represententing the Level or the state if this is an Agent
Returns:
icon of the node

getName

public java.lang.String getName()
Returns the name of the agent
Returns:
Name of the agent

setName

public void setName(java.lang.String nameP)
Sets a name of a node
Parameters:
nameP - name of the node

setAddresses

public void setAddresses(java.lang.String[] aP)
Sets the address of a node
Parameters:
aP - array of addresses for the node

getAddressesAsString

public java.lang.String getAddressesAsString()
Returns the addresses of a node as a string
Returns:
string of addresses of a node

getType

public java.lang.String getType()
Returns the type of a node of a node
Returns:
type of the node

setType

public void setType(java.lang.String r)
Sets the type of a node
Parameters:
r - type of the node

setState

public boolean setState(int state)
Sets the state of an agent in a node
Parameters:
state - state of the agent

transState

public void transState()
forces the Agent to go from current state to the other state

getStateName

public java.lang.String getStateName()
Returns the state name of a node
Returns:
state name of the node

getLevel

public int getLevel()
Returns the level of a node
Returns:
level of the node
Overrides:
getLevel in class javax.swing.tree.DefaultMutableTreeNode

setLevel

public boolean setLevel(int LevelP)
Sets the level of a node
Parameters:
levelP - level of the node

toString

public java.lang.String toString()
Overrides:
toString in class javax.swing.tree.DefaultMutableTreeNode

getToolTipText

public java.lang.String getToolTipText()
Returns the ToolTipText of a node
Returns:
ToolTipText of a node

addAddress

public void addAddress(java.lang.String newAdd)
Adds an address to a node
Parameters:
newAdd - new address to add to a node

isLeaf

public boolean isLeaf()
A node is a Leaf only if it is an agent
Overrides:
isLeaf in class javax.swing.tree.DefaultMutableTreeNode

getChildCount

public int getChildCount()
If the children have not yet been loaded, loadChildren is messaged and super is messaged for the return value.
Overrides:
getChildCount in class javax.swing.tree.DefaultMutableTreeNode

loadChildren

protected void loadChildren()
Messaged the first time getChildCount is messaged. Creates children asking to the agent platform. This method loads agents on the tree.