// ------------------------------------------------------------------------ // 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); }
public double expected_yield(int count) { if (count > 10) return 0.0; if (nodeNumber.intValue() == 0) return 1.0; Integer parent = MainClass.objectMaintainer.getParent(nodeNumber); if (parent == null) return 0.0; NodeInfo parentni = (NodeInfo) MainClass.sensorAnalyzer.proprietaryNodeInfo.get(parent); if (parentni == null) return 0.0; return link_quality * parentni.expected_yield(count + 1); }
// ------------------------------------------------------------------------ // *****---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()); } } }
public void InitializeDisplayValues() // this function will be called when the panel is first shown { JLabel4.setText(String.valueOf(nodeInfo.GetNodeNumber())); JLabel6.setText(String.valueOf(nodeInfo.GetValue())); }
public void ApplyChanges() // this function will be called when the apply button is hit { nodeInfo.SetNodeNumber(Integer.getInteger(JLabel4.getText())); }