예제 #1
0
  // ------------------------------------------------------------------------
  // SCREEN PAINTER
  // Put some function here to paint whatever you want over the screen before and after
  // all edges and nodes have been painted.
  public void PaintScreenBefore(Graphics g) {

    Dimension d = MainClass.mainFrame.GetGraphDisplayPanel().getSize();
    NodeInfo nodeInfo;
    int x = 0;
    int y = 0;
    int step = 10;

    for (; x < d.width; x += step) {
      for (y = 0; y < d.height; y += step) {
        double val = 0;
        double sum = 0;
        double total = 0;
        double min = 10000000;
        for (Enumeration nodes = proprietaryNodeInfo.elements(); nodes.hasMoreElements(); ) {
          nodeInfo = (NodeInfo) nodes.nextElement();
          double dist = distance(x, y, nodeInfo.centerX, nodeInfo.centerY);
          if (nodeInfo.value != -1 && nodeInfo.nodeNumber.intValue() != 1) { // 121
            if (dist < min) min = dist;
            val += ((double) nodeInfo.value) / dist / dist;
            sum += (1 / dist / dist);
          }
        }
        int reading = (int) (val / sum);
        reading = reading >> 2;
        if (reading > 255) reading = 255;
        g.setColor(new Color(reading, reading, reading));
        g.fillRect(x, y, step, step);
      }
    }
  }
예제 #2
0
 // ------------------------------------------------------------------------
 // NODE PAINTER
 // Put some function here to paint whatever you want over the node.
 // The x1,y1 coordinates are the top left corner within which the node will be drawn
 // The x2,y2 coordinates are the bottom right corner
 // Paint everything on the graphics object
 // this function is called by DisplayManager
 public void PaintNode(Integer pNodeNumber, int x1, int y1, int x2, int y2, Graphics g) {
   NodeInfo nodeInfo = (NodeInfo) proprietaryNodeInfo.get(pNodeNumber);
   if (nodeInfo == null) return;
   int light = nodeInfo.GetValue();
   if (light == -1) return;
   nodeInfo.centerX = (x1 + x2) / 2;
   nodeInfo.centerY = (y1 + y2) / 2;
   // System.out.println(pNodeNumber);
 }
예제 #3
0
  // ------------------------------------------------------------------------
  // *****---Packet Recieved event handler---******//
  // this function will be called by the thread running the packetReciever
  // everytime a new packet is recieved
  // make sure it is synchronized if it modifies any of your data
  public synchronized void PacketReceived(PacketEvent e) {
    // this function defines what you do when a new packet is heard by the system (recall that the
    // parent class (PacketAnalyzer) already registered you to listen for new packets automatically)
    // if this is a long function, you should call it in a seperate thread to allow the
    // PacketReciever thread to continue recieving packets

    Packet packet = e.GetPacket();
    Vector node_list = packet.CreateRoutePathArray();
    for (int i = 0; i < node_list.size() - 1; i++) {
      Integer currentNodeNumber = (Integer) node_list.elementAt(i);
      NodeInfo currentNodeInfo;
      if ((currentNodeInfo = (NodeInfo) proprietaryNodeInfo.get(currentNodeNumber)) != null) {
        currentNodeInfo.SetValue(packet.getValue());
      }
    }
  }
예제 #4
0
 //	public EdgeInfo GetEdgeInfo(Integer sourceNumber, Integer destinationNumber){return
 // (EdgeInfo)proprietaryEdgeInfo.get(sourceNumber,destinationNumber);}
 public Enumeration GetNodeInfo() {
   return proprietaryNodeInfo.elements();
 }
예제 #5
0
 // ------------------------------------------------------------------------
 // INTERFACE TO PROPRIETARY DATA
 // write some functions here that will let other Analyzers find and user your data
 public NodeInfo GetNodeInfo(Integer nodeNumber) {
   return (NodeInfo) proprietaryNodeInfo.get(nodeNumber);
 }
예제 #6
0
 // ------------------------------------------------------------------------
 // GET PROPRIETARY NODE INFO PANEL
 // This function returns the Panel that you define it to retunr
 // which will then automatically appear ina dialog when a node is clicked.
 // this function is called by DisplayManager
 public ActivePanel GetProprietaryNodeInfoPanel(Integer pNodeNumber) {
   NodeInfo nodeInfo = (NodeInfo) proprietaryNodeInfo.get(pNodeNumber);
   if (nodeInfo == null) return null;
   ProprietaryNodeInfoPanel panel = new ProprietaryNodeInfoPanel(nodeInfo);
   return (ActivePanel) panel;
 }
예제 #7
0
 // ------------------------------------------------------------------------
 // *****---Node Deleted---******//
 // this function defines what you do when a new node is deleted
 // It is called by net.tinyos.tinydb.topology.PacketAnalyzer.ObjectMainter
 public synchronized void NodeDeleted(NodeEvent e) {
   Integer deletedNodeNumber =
       e.GetNodeNumber(); // you probably want to delete the info pbject to track the data of
   // this new node
   proprietaryNodeInfo.remove(deletedNodeNumber);
 }
예제 #8
0
 // It is called by net.tinyos.tinydb.topology.PacketAnalyzer.ObjectMainter
 public synchronized void NodeCreated(NodeEvent e) {
   Integer newNodeNumber =
       e.GetNodeNumber(); // you probably want to create a new info pbject to track the data of
   // this new node
   proprietaryNodeInfo.put(newNodeNumber, new NodeInfo(newNodeNumber));
 }