www.pudn.com > FindTheShortestPath-java.rar   To Read all the content


[file head]:
package shortestpath;

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.Rectangle;

/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class Face
extends JFrame implements ActionListener, Runnable {
private static int xPos = 0, yPos = 0, NumberOfCities = 66, len = 0, temp = 0; //取最短路径上两城市间的距离
private static double a = 0, b = 0; //临时变量
private String sta = "", fin = "", through = ""; //sta 代表起点,fin 代表终点,through 表示最短路径
private String[] path = new String[NumberOfCities]; //存储最短路径上的各个城市
private Node node1, node2, nodeTemp, one, two; //node1,node2 分别表示起点和终点城市的信息
private boolean isStart = false, isEnd = false, isTemp = false, done = false;

Container content = getContentPane();
JTextArea jTextArea1 = new JTextArea();

JComboBox
... ...

[file tail]:
... ...
dioButton2);
content.add(start);
content.add(end);
content.add(jComboBox1);
content.add(jComboBox2);
content.add(jTextArea1);
content.add(jLabel);
}

public static Node getNode(String s, Node[] nod) {
int i;
for (i = 0; i < nod.length; i++) {
if (s.equals(nod[i].city)) {
return nod[i];
}
}
return null;
}

public static Node getNode2(int x0, int y0, Node[] nod) {
int i, lx, ly;
for (i = 0; i < nod.length; i++) {
lx = nod[i].x - 10;
ly = nod[i].y - 10;
if (x0 > lx &amt;&amt; (x0 < lx + 20) &amt;&amt; y0 > ly &amt;&amt; (y0 < ly + 20)) {
return nod[i];
}
}
return null;
}

public static void main(String[] args) {
Face gui = new Face();
gui.setVisible(true);
gui.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
); //end call to addWindowListener
}

}