cgl.narada.topology.viewer
Class Cluster

java.lang.Object
  extended by cgl.narada.topology.viewer.Node
      extended by cgl.narada.topology.viewer.Cluster

public class Cluster
extends Node

This class represents all the clusters consisting of nodes. The cluster is second level in the node address. If node's address is 1.2.3.4 then cluster id is 3


Field Summary
 List nodes
           
 
Fields inherited from class cgl.narada.topology.viewer.Node
clients, INVALID_VALUE, nodeId, nodeLocation, parentClusterId, parentSClusterId, parentSSClusterId
 
Constructor Summary
Cluster(int clusterId, int pSClusterId, int pSSClusterId)
          Only constructor.
 
Method Summary
 void deleteAllNodes(List nodesToBeDeleted)
          Deletes all the nodes in the cluster
 void deleteNode(int nodeId, List nodesToBeDeleted)
          Deletes an existing node inside the cluster.
 void drawCluster(Graphics g, int limitX1, int limitY1, int limitX2, int limitY2)
          Draws the cluster only if its part is visible on the screen.
 Node getNodeAtParticularCoordinates(int x, int y)
          Finds a node in the cluster, nearest to specified coordinates.
 Node getParticularNode(int nodeId)
          Returns a node in the cluster with specified node id
 void insertNode(int nodeId)
          Adds a new node to the list.
 void repositionNodes()
          Gets new positions and assigns then to all nodes inside the cluster.
 
Methods inherited from class cgl.narada.topology.viewer.Node
addClient, addTopic, canFitOnPanel, deleteAllClients, deleteAllTopics, deleteClient, deleteTopic, drawNode, getAllClients, getClient, getNodeAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

nodes

public List nodes
Constructor Detail

Cluster

public Cluster(int clusterId,
               int pSClusterId,
               int pSSClusterId)
Only constructor.

Method Detail

insertNode

public void insertNode(int nodeId)
Adds a new node to the list. Depending upon the total number of nodes in the list, recalculate the new positions for each node.

Parameters:
nodeId - id of a node

deleteNode

public void deleteNode(int nodeId,
                       List nodesToBeDeleted)
                throws TopologyException
Deletes an existing node inside the cluster. Recalculated the new position for each node.

Parameters:
nodeId - id of the node
nodesToBeDeleted - List which contains the node address of a node which needs to be deleted.
Throws:
TopologyException - if specified node is not found in the cluster.

deleteAllNodes

public void deleteAllNodes(List nodesToBeDeleted)
Deletes all the nodes in the cluster

Parameters:
nodesToBeDeleted - List which contains the node address of a node which needs to be deleted.

getNodeAtParticularCoordinates

public Node getNodeAtParticularCoordinates(int x,
                                           int y)
Finds a node in the cluster, nearest to specified coordinates.

Parameters:
x - X-coordinate.
y - Y-coordinate.
Returns:
Node null if no such node is found

getParticularNode

public Node getParticularNode(int nodeId)
Returns a node in the cluster with specified node id

Parameters:
nodeId - id of a node
Returns:
Node

drawCluster

public void drawCluster(Graphics g,
                        int limitX1,
                        int limitY1,
                        int limitX2,
                        int limitY2)
Draws the cluster only if its part is visible on the screen. Draws all the nodes inside it.

Parameters:
g - Graphics object for image drawing.
limitX1 - lower limit for X-coordinate
limitY1 - lower limit for Y-coordinate
limitX2 - upper limit for X-coordinate
limitY2 - upper limit for Y-coordinate

repositionNodes

public void repositionNodes()
Gets new positions and assigns then to all nodes inside the cluster. If the node is newly added then only sets its color otherwise maintains its color.



For comments and suggestions please send e-mail to The NaradaBrokering Project