⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 locationanalyzer.java

📁 无线通信的主要编程软件,是无线通信工作人员的必备工具,关天相关教程我会在后续传上.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    {	NodeInfo nodeInfo = (NodeInfo)proprietaryNodeInfo.get(nodeNumber);	if(nodeInfo !=null)	    {		return nodeInfo.GetY();	    }	else	    {		return -1;	    }    }    public NodeInfo GetNodeInfo(Integer nodeNumber){return (NodeInfo)proprietaryNodeInfo.get(nodeNumber);}    public EdgeInfo GetEdgeInfo(Integer sourceNumber, Integer destinationNumber){return (EdgeInfo)proprietaryEdgeInfo.get(sourceNumber,destinationNumber);}    public Enumeration GetNodeInfo(){return proprietaryNodeInfo.elements();}    public Enumeration GetEdgeInfo(){return proprietaryEdgeInfo.elements();}    public class NodeInfo    {	protected double x;	protected double y;	protected Integer nodeNumber;	protected boolean fixed;//determines if the node can move around automatically or not	protected boolean displayCoords;//determines if the XY Coords should be drawn	public NodeInfo(Integer pNodeNumber)	{	    nodeNumber = pNodeNumber;	    try{		FileInputStream f = new FileInputStream("temp/" + nodeNumber + ".data");				ObjectInputStream o = new ObjectInputStream(f);		x = ((Double)(o.readObject())).doubleValue();		y = ((Double)(o.readObject())).doubleValue();		f.close();		fixed = true;	    }catch (Exception e){		x = Math.random();		y = Math.random();		fixed = false;	    }	    displayCoords = true;	}	public Integer GetNodeNumber(){return nodeNumber;}	public double GetX(){return x;}	public double GetY(){return y;}	public boolean GetFixed(){return fixed;}	public boolean GetDisplayCoords(){return displayCoords;}	public void SetX(double pX){x=pX;}	public void SetY(double pY){y=pY;}	public void SetFixed(boolean pFixed){fixed = pFixed;}	public void SetDisplayCoords(boolean pDisplayCoords){displayCoords= pDisplayCoords;}	public void RecordLocation(){	    try{		FileOutputStream f = new FileOutputStream("temp/" + nodeNumber + ".data");					ObjectOutputStream o = new ObjectOutputStream(f);		o.writeObject(new Double(x));		o.writeObject(new Double(y));		o.flush();		f.close();	    }catch (Exception e){		e.printStackTrace();	    }	}    }    public class EdgeInfo    {	protected double distance;	protected Integer sourceNodeNumber;	protected Integer destinationNodeNumber;	protected boolean displayLength;//determines if the length should be drawn	protected boolean is_routing_path;	protected double link_quality;	EdgeInfo(Integer pSource, Integer pDestination)	{	    sourceNodeNumber = pSource;	    destinationNodeNumber = pDestination; 	    distance = .5;	    is_routing_path = true;	    displayLength = false;	    link_quality = -1.0;	}	public Integer GetSourceNodeNumber(){return sourceNodeNumber;}	public Integer GetDestinationNodeNumber(){return destinationNodeNumber;}	public double GetDistance(){return distance;}	public void SetDistance(double pDistance){distance = pDistance;}	public boolean GetDisplayLength(){return displayLength;}	public void SetDisplayLength(boolean pDisplayLength){displayLength = pDisplayLength;}	public boolean GetRoutingPath(){	    if(destinationNodeNumber.equals(ObjectMaintainer.getParent(sourceNodeNumber))) return true;	    else if(sourceNodeNumber.equals(ObjectMaintainer.getParent(destinationNodeNumber))) return true;	    return false;	}     	public void SetLinkQuality(int quality) {	    if (quality == 255) link_quality = -1.0;	    else {		link_quality = (quality * 1.0) / 100.0;	    }	}	public Color GetEdgeColor() {	    return Util.gradientColor(link_quality);	}    }    public class ProprietaryNodeInfoPanel extends net.tinyos.surge.Dialog.ActivePanel    {	NodeInfo nodeInfo;	public ProprietaryNodeInfoPanel(NodeInfo pNodeInfo)	{	    tabTitle = "Location";	    nodeInfo = pNodeInfo;	    //{{INIT_CONTROLS	    setLayout(null);	    Insets ins = getInsets();	    setSize(247,168);	    JLabel3.setText("X Coordinate");	    add(JLabel3);	    JLabel3.setBounds(36,48,84,24);	    JLabel4.setText("Y Coordinate");	    add(JLabel4);	    JLabel4.setBounds(36,72,75,24);	    JTextField1.setNextFocusableComponent(JTextField2);	    JTextField1.setToolTipText("The scale of the coordinate system is determined by the user, and scaled automatically by the system to fit to the screen");	    JTextField1.setText("1.5");	    add(JTextField1);	    JTextField1.setBounds(120,48,87,18);	    JTextField2.setToolTipText("The scale of the coordinate system is determined by the user, and scaled automatically by the system to fit to the screen");	    JTextField2.setText("3.2");	    add(JTextField2);	    JTextField2.setBounds(120,72,87,18);	    JCheckBox1.setToolTipText("Check this is you don\'t want the node to move around");	    JCheckBox1.setText("Fixed x/y Coordinates");	    add(JCheckBox1);	    JCheckBox1.setBounds(36,96,168,24);	    JCheckBox2.setToolTipText("Check this is you want the coordinates to be displayed on the screen");	    JCheckBox2.setText("Display x/y Coordinates");	    add(JCheckBox2);	    JCheckBox2.setBounds(36,120,168,24);	    //}}	    //{{REGISTER_LISTENERS	    //}}	}	//{{DECLARE_CONTROLS	javax.swing.JLabel JLabel3 = new javax.swing.JLabel();	javax.swing.JLabel JLabel4 = new javax.swing.JLabel();	javax.swing.JTextField JTextField1 = new javax.swing.JTextField();	javax.swing.JTextField JTextField2 = new javax.swing.JTextField();	javax.swing.JCheckBox JCheckBox1 = new javax.swing.JCheckBox();	javax.swing.JCheckBox JCheckBox2 = new javax.swing.JCheckBox();	//}}	public void ApplyChanges()	{	    nodeInfo.SetX(Double.valueOf(JTextField1.getText()).doubleValue());	    nodeInfo.SetY(Double.valueOf(JTextField2.getText()).doubleValue());	    nodeInfo.SetFixed(JCheckBox1.isSelected());	    nodeInfo.SetDisplayCoords(JCheckBox2.isSelected());	}	public void InitializeDisplayValues()	{	    JTextField1.setText(String.valueOf(nodeInfo.GetX()));	    JTextField2.setText(String.valueOf(nodeInfo.GetY()));	    JCheckBox1.setSelected(nodeInfo.GetFixed());	    JCheckBox2.setSelected(nodeInfo.GetDisplayCoords());	}    }    public class ProprietaryEdgeInfoPanel extends net.tinyos.surge.Dialog.ActivePanel    {	EdgeInfo edgeInfo;	public ProprietaryEdgeInfoPanel(EdgeInfo pEdgeInfo)	{	    tabTitle = "Location";	    edgeInfo = pEdgeInfo;	    //{{INIT_CONTROLS	    setLayout(null);	    Insets ins = getInsets();	    setSize(247,168);	    JLabel3.setText("Distance");	    add(JLabel3);	    JLabel3.setBounds(36,48,84,24);	    JTextField1.setToolTipText("The scale of the coordinate system is determined by the user, and scaled automatically by the system to fit to the screen");	    JTextField1.setText("1.5");	    add(JTextField1);	    JTextField1.setBounds(120,48,87,18);	    JCheckBox1.setToolTipText("Check this is you want the length of the edge to be displayed");	    JCheckBox1.setText("Display Length");	    add(JCheckBox1);	    JCheckBox1.setBounds(36,66,168,24);	    //}}	    //{{REGISTER_LISTENERS	    //}}	}	//{{DECLARE_CONTROLS	javax.swing.JLabel JLabel3 = new javax.swing.JLabel();	javax.swing.JTextField JTextField1 = new javax.swing.JTextField();	javax.swing.JCheckBox JCheckBox1 = new javax.swing.JCheckBox();	//}}	public void ApplyChanges()	{	    edgeInfo.SetDistance(Double.parseDouble(JTextField1.getText()));	    edgeInfo.SetDisplayLength(JCheckBox1.isSelected());	}	public void InitializeDisplayValues()	{	    JTextField1.setText(String.valueOf(edgeInfo.GetDistance()));	    JCheckBox1.setSelected(edgeInfo.GetDisplayLength());	}    }    void drawLine(Graphics g,		  int x1, int y1,		  int x2, int y2,		  int lineWidth) {	if (lineWidth == 1)	    g.drawLine(x1, y1, x2, y2);	else {	    double angle;	    double halfWidth = ((double)lineWidth)/2.0;	    double deltaX = (double)(x2 - x1);	    double deltaY = (double)(y2 - y1);	    if (x1 == x2)		angle=Math.PI;	    else		angle=Math.atan(deltaY/deltaX)+Math.PI/2;	    int xOffset = (int)(halfWidth*Math.cos(angle));	    int yOffset = (int)(halfWidth*Math.sin(angle));	    int[] xCorners = { x1-xOffset, x2-xOffset+1,			       x2+xOffset+1, x1+xOffset };	    int[] yCorners = { y1-yOffset, y2-yOffset,			       y2+yOffset+1, y1+yOffset+1 };	    g.fillPolygon(xCorners, yCorners, 4);	}    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -