当前位置:文档之家› 公交线路优化路径的查询数据结构课程设计报告

公交线路优化路径的查询数据结构课程设计报告

课程设计报告


课程: 《数据结构》


题目: 公交线路优化路径的查询


学 院: 计算机与电子信息学院

专 业:

班 级:

学 号:

学生姓名: 空白小龙

指导教师:


二〇一一 年 一 月一、实验目的和要求

1、实验目的:

【问题描述】

对于某城市的公交线路,乘坐公交的顾客希望在这样的线路上实现各种优化路径的查询。设该城市 的公交线路的输入格式为:

线路编号:起始站名(该站坐标);经过的站点1名(该站坐标);经过的站点2名(该站坐标);……;经过的站点n名(该站坐标);终点站名(该站坐标)。该线路的乘坐价钱。车速。该线路平均经过多少时间来一辆。

例如:63:A(32,45);B(76,45);C(76,90);……;N(100,100) 。1元。1/每分钟。5分钟。

假定线路的乘坐价钱与乘坐站数无关,假定不考虑公交线路在路上的交通堵塞。不考虑乘客上下车的时间。

对这样的公交线路,需要在其上进行的优化路径查询包括:任何两个站点之间最便宜的路径;任何两个站点之间最省时间的路径。

2、实验要求:

【设计要求】

① 根据上述公交线路的输入格式,定义并建立合适的图模型。

② 针对上述公交线路,能查询获得任何两个站点之间最便宜的路径,即输入站名S,T后,可以输出从S到T的最便宜的路径,输出格式为:线路x :站名S,…,站名M1;换乘线路x :站名M1,…,站M2;…;换乘线路x:站名MK,…,站名T。共花费x元。

③ 针对上述公交线路,能查询获得任何两个站点之间最省时间的路径(不考虑在中间站等下一辆线路的等待时间),即输入站名S,T后,可以输出从S到T的考虑在中间站等下一辆线路的等待时间的最省时间的路径,输出格式为:线路x:站名S,…,站名M1;换乘线路x:站名M1,…,站名M2;…;换乘线路x:站名MK,…,站名T。共花费x时间。

④ 针对上述公交线路,能查询获得任何两个站点之间最省时间的路径(要考虑在中间站等下一辆线路的等待时间),即输入站名 S,T 后,可以输出从 S 到T 的考虑在中间站等下一辆线路的等待时间的最省时间的路径,输出格式为:线路x:站名 S,…,站名 M1;换乘线路 x:站名M1,…,站名 M2;…;换乘线路x:站名 MK,…,站名T。共花费x 时间。

采用图形化界面显示操作结果,使用的编程工具:

Ecclipse:eclliipse-SDK-3.2-win32eclliipse-SDK-3.2-win32

实现图形化界面要安装的插件:emff-sdo-SDK-2..2..2、GEF--ALL--3..2、VE--runttimee-1.2.3_jeemJDK:jdk1..6..0


二、设计概要:

1、根据实验要求,与及所了解的数据类型相关知

识,定义了如下数据类型:①图模型Graph、点模型VertexType、边模型ArcCell

②存储站点、边及公交路线信息的xml文件模型:point、bian、line

③读xml文件的三个模型:Readpoint、Readbian、Readline

④三个图形化界面模型:Welcome、Bus、About

2、实现功能所定义的各种方法:

Graph:

1)、publicpublic Graph(intint a,intint b,intint c)

构造方法

2)、static void SetBusInfo(Graph G)

对图模型信息的赋值方法SetBusInfo()

3)、static String GetMoney(Graph G,String str1,String str2)

查询获得任何两个站点之间最便宜路径的方法

4)、static String GetPath1(Graph G,String str1,String str2)

查询获得任何两个站点之间最省时间路径(不考虑在中间站等下一辆线路的等待时间)的方法

5)、static String GetPath2(Graph G,String str1,String str2)

查询获得任何两个站点之间最省时间路径(要考虑在中间站等下一辆线路的等待时间)的方法

VertexType:无

ArcCell:无

Point:

1)、public void setBusnumber(String number) //set方法

2)、public void setBusname(String name) //set方法

3)、publicpublic void setX(intint a) //set方法

4)、public void setY(int b) //set方法

5)、public String getBusnumber() //get方法

6)、public String getBusname() //get方法

7)、public int getX() //get方法

8)、publicpublic int getY() //get方法

bian:

1)、public void setX(int a) //set方法

2)、publicpublic void setY(intint b) //set方法

3)、public int getFir() //get方法

4)、public int getSec() //get方法

line:

1)、line() //构造方法

2)、publicpublic Vector getPoints() //get方法

Readpoint:无

Readbian:无

Readline:无

3、实验功能所定义的各种按钮:

Welcome:

1)、privateprivate Button getButton() //进入主界面按钮

2)、private Button getButton1() //退出按钮

Bus:

1)、private Button getButton1()

实现查询获得任何两个站点之间最便宜的路径的功能

2)、private Button getButton2()

实现查询获得任何两个站点之间最省时间的路径(不考虑在中间站等下一辆线路的等待时间)的功能

3)、private Button getButton3()

实现查询获得任何两个站点之间最省时间的路径(要考虑在中间站等下一辆线路的等待时间)的功能

4)、private Button getButton4()

清屏按钮

5)、private Button getButton5()

退出按钮

6)、private Button getButton6()

关于界面

About:

1)、privateprivate Button getButton()

退出按钮

2)、private Button getButton1()

返回主界面按钮


三、程序模块流程图

开始

Welcome欢迎界面


进入主界面 结束


Bus查询界面



选择始末站点


最便宜路径 最省时间路径(1) 最省时间路径(2) 清屏 关于 退出


输出线路结果 输出线路结果 输出线路结果 清除所有显示信息 进入关于界面

结束


返回主界面 退出


四、具体程序设计代码

poiint.java

package pack_BusLine

public class point { //存储站点信息的类

String busnumber; //站点的编号

String busname; //站点的名称

int px; //站点的x坐标

int py; //站点的y坐标

public void setBusnumber(String number) //set方法

{

busnumber=number;

}

public void setBusname(String name) //set方法

{

busname=name;

}

public void setX(int a) //set方法

{

px=a;

}

public void setY(intint b) //set方法

{

py=b;

}

public String getBusnumber() //get方法

{

return busnumber;

}

public String getBusname() //get方法

{

return busname;

}

public int getX() //get方法

{

return px;

}

public int getY() //get方法

{

return py;

}

}

bian..jjava

package pack_BusLine;

public class bian { //存储边信息的类

int fir; //邻边的一个站点

int sec; //邻边的另一个站点

public void setX(int a) //set方法

{

fir=a;

}

public void setY(intint b) //set方法

{

sec=b;

}

public int getFir() //get方法

{

return fir;

}

public int getSec() //get方法

{

return sec;

}

}

lline.java

package pack_BusLine;

import java.util.Vector;

public class line { //存储公交线路信息的类

public Vector points;

line(){ //构造方法

points=newnew Vector();

}

public Vector getPoints(){ //get方法

return this.points;

}

}

Readpoiint.java

package pack_BusLine;

import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

public class Readpoint{ //对存储站点信息point的类

Vector point_Vector;

public Vector readXMLFile(String file) throws Exception

{

DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();

DocumentBuilder builder = dbf.newDocumentBuilder();

Document doc = builder.parse(file); //获取到xml文件

//下面开始读取

Element root = doc.getDocumentElement(); //获取根元素

NodeList points = root.getElementsByTagName("point");

point_Vector = new Vector();

for(intint i=0;i
{

//

一次取得每一个站点元素

Element ss = (Element)points.item(i);

//创建一个站点的实例

point po = new point();

po.setBusnumber(ss.getAttribute("busnumber"));

//取出busnumber

NodeList ns = ss.getElementsByTagName("busname");

//取出busname

Element e = (Element)ns.item(0);

Node t = e.getFirstChild();

po.setBusname(t.getNodeValue());

NodeList xs = ss.getElementsByTagName("px");

//取出px

e = (Element)xs.item(0);

t = e.getFirstChild();

po.setX(Integer.parseInt(t.getNodeValue()));

NodeList ys = ss.getElementsByTagName("py");

//取出py

e = (Element)ys.item(0);

t = e.getFirstChild();

po.setY(Integer.parseInt(t.getNodeValue()));

point_Vector.add(po);

}

return point_Vector;

}

}

Readbiian..jjava

package pack_BusLine;

import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

public class Readbian { //对存储边信息point的类

Vector bian_Vector;

Vector readXMLFile(String file) throws Exception

{

DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();

DocumentBuilder builder = dbf.newDocumentBuilder();

Document doc = builder.parse(file); //获取到xml文件

//下面开始读取

Element root = doc.getDocumentElement(); //获取根元素

NodeList bians = root.getElementsByTagName("bian");

bian_Vector = new Vector();

for(int i=0;i
{

//一次取得每一个邻边元素

Element ss = (Element)bians.item(i);

//创建一个邻边的实例

bian bi = new bian();

NodeList firs = ss.getElementsByTagName("fir"); //取出fir

Element e = (Element)firs.item(0);

Node t = e.getFirstChild();

bi.setX(Integer.parseInt(t.getNodeValue()));

NodeList secs = ss.getElementsByTagName("sec"); //取出sec

e = (Element)secs.item(0);

t = e.getFirstChild();

bi.setY(Integer.parseInt(t.getNodeValue()));

bian_Vector.add(bi);

}

return bian_Vector;

}

}

Readline..jjava

package pack_BusLine;

import java.util.Vector;

import javax.xml.parsers.DocumentBuilder;

import javax.xml.parsers.DocumentBuilderFactory;

import org.w3c.dom.Document;

import org.w3c.dom.Element;

import org.w3c.dom.Node;

import org.w3c.dom.NodeList;

public class Readline { //对存储公交线路信息point的类

Vector line_Vector;

Vector readXMLFile(String file) throws Exception

{

DocumentBuilderFactory dbf =DocumentBuilderFactory.newInstance();

DocumentBuilder builder = dbf.newDocumentBuilder();

Document doc = builder.pars

e(file); //获取到xml文件

//下面开始读取

Element root = doc.getDocumentElement(); //获取根元素

NodeList lines = root.getElementsByTagName("line");

line_Vector = new Vector();

for(int i=0;i
{

//一次取得每一个 元素

line l=newnew line();

Element ss = (Element)lines.item(i);

NodeList points = ss.getElementsByTagName("p"); //取出p

for(int j=0;j
{

//一次取得每一个 元素

Element temp = (Element)points.item(j);

Node n=temp.getFirstChild();

l.points.add(n.getNodeValue());

}

line_Vector.add(l);

}

return line_Vector;

}

}

VertexType..jjava

package pack_BusLine;

public class VertexType { //基类--点

int x,y; //点的x和y的坐标

String busstation; //站点的名称

}

ArcCelll.java

package pack_BusLine;

public class ArcCell { //基类--边

int time; //相邻站点的时间

int money; //相邻站点的费用

}

Graph.java

package pack_BusLine;

import java.util.Iterator;

import java.util.Vector;

public class Graph { //类模型--图

VertexType vex[]=newnew VertexType[200]; //图中的点

ArcCell arcs[][]=new ArcCell[200][200]; //图中的边

int vexnum,arcnum,linenum; //站点数、边数、公交线路数目

public Graph(int a,int b,int c) //构造方法

{

this.vexnum=a;

this.arcnum=b;

this.linenum=c;

}

static void SetBusInfo(Graph G) //对图模型信息的赋值方法SetBusInfo()

{

int i,j;

for(i=0;i
{

G.vex[i]=new VertexType();

}

for(i=0;i
for(j=0;j
{

G.arcs[i][j]=new ArcCell();

}

String string = "D:\\info\\point.xml";

//找到存储站点信息的文件point.xml

Readpoint rp = new Readpoint();

//通过读xml文件的形式对站点信息赋值

i=0;

try {

Vector vec = rp.readXMLFile(string);

Iterator it = vec.iterator();

while(it.hasNext())

{

point p = (point)it.next();

/*下边是站点名和站点坐标*/

G.vex[Integer.parseInt(p.getBusnumber())].busstation=p.getBusname(); //赋值站点名称

G.vex[Integer.parseInt(p.getBusnumber())].x=p.getX();//赋值站点坐标x

G.vex[Integer.parseInt(p.getBusnumber())].y=p.getY();//赋值站点坐标y

}

} catch (NumberFormatException e1) {

e1.printStackTrace();

}catch (Exception e1) {

e1.printStackTrace();

}

}

static String GetMoney(Graph G,String str1,String str2){//查询获得任何两个站点之间最便宜路径的方法

String str3;

String str4="";

int i,j,k;


int num=0;

int bs[][]=newnew int[G.linenum][];

//创建存储公交路线的数组,行数为G.linenum

Vector vect;

try {

String str = "D:\\info\\line.xml";

Readline rl=newnew Readline();

vect = rl.readXMLFile(str);

for(i=0;i
{

line l = (line)vect.get(i);

bs[i]=newnew int[(l.points).size()-2];

//设置bs数组的列数

for(j=0;j<(l.points).size()-2;j++)

{

String s=(String)(((l.points).get(j)));

bs[i][j]=Integer.parseInt(s);

//把公交线路信息存储入bs数组

}

}

} catch (NumberFormatException e2) {

e2.printStackTrace();

} catch (Exception e2) {

e2.printStackTrace();

}

int sta[]=new int [G.vexnum];

int temp;

boolean l3;

int price[]=newnew int[bs.length];

int mon[]=new int[bs.length];

for(i=0;i
{

price[i]=bs[i][bs[i].length-1];

//把每路公交线路的价钱存入price[]数组

mon[i]=-1;

}

for(i=1;i
//冒泡排序把公交线路的价钱按从小到大存入price[]数组 for(j=0;j<(price.length-1);j++)

if(price[j]>price[j+1])

{

temp=price[j];

price[j]=price[j+1];

price[j+1]=temp;

}

for(j=0;j
//按从小到大的公交线路的价钱把公交线路的线路编号存入mon[]数组

for(i=0;i
{

l3=true;true

for(int pri=0;pri
{

if(i==mon[pri])

l3=false;

}

if(l3==true&&price[j]==bs[i][bs[i].length-1])

{

mon[j]=i;

break;

}

}

int len;

/*这里把所有的边假定为10000,含义是站台间不可到达*/

for(i=0;i
for(j=0;j
G.arcs[i][j].money=10000;

/*下边是可直接到达的站台间的距离,由于两个站台间距离是互相的,

所以要对图中对称的边同时赋值。*/

for(len=mon.length-1;len>=0;len--)

{

i=mon[len];

for(j=1;j<(bs[i].length-1);j++)

for(k=j+1;k<(bs[i].length-1);k++)

{

G.arcs[bs[i][j]][bs[i][k]].money=G.arcs[bs[i][k]][bs[i][j]].money=bs[i][bs[i].length-1]; //用价钱对邻边赋值

}

}

int busstation1=-1,busstation2=-1;

if(str1==""&&str2=="")

str4=" 始站名和终站名为空,请重新选择!";

else if(str1=="")

str4=" 始站名为空,请重新选择!";

else if(str2=="")

str4=" 终站名为空,请重新选择!";

else if(str1==str2)

str4=" 请输入不同的始站名和终站名!";else

{

for(i=0;i
{

if(G.vex[i].busstation.equals(str1))

//找到起始站点的站点编号

{

busstation1=i;

break;

}

}

for(i=0;i

)

{

if(G.vex[i].busstation.equals(str2))

//找到终止站点的站点编号

{

busstation2=i;

break;

}

}

//求最便宜的路径的Dijkstra算法

int P[][]=newnew int[G.vexnum][G.vexnum];

int M[]=new int[G.vexnum];

int v,w,t;

int fin[]=newnew int[G.vexnum];

int min;

for(v=0;v
{

fin[v]=0;

M[v]=G.arcs[busstation1][v].money;

for(w=0;w
P[v][w]=0;

if(M[v]<10000)

{

P[v][busstation1]=1;

P[v][v]=1;

}

}

M[busstation1]=0;

fin[busstation1]=1;

for(i=0;i
{

min=10000;

for(w=0;w
if(!(fin[w]==1))

if(M[w]
{

v=w;

min=M[w];

}

fin[v]=1;

for(w=0;w
if(!(fin[w]==1)&&((min+G.arcs[v][w].money)
{

M[w]=min+G.arcs[v][w].money;

for(t=0;t
P[w][t]=P[v][t];

P[w][w]=1;

}

}

int a,b,c,d;

a=busstation2;

if(a!=busstation1)

{

str4+=" 从"+G.vex[busstation1].busstation+busstation1+" 到"+G.vex[busstation2].busstation+busstation2+"的最便宜的路径是\n";

d=busstation1;

sta[0]=d;

for(c=0;c
{

P[a][busstation1]=0;

for(b=0;b
{

if(G.arcs[d][b].money<10000&&(P[a][b]==1))

{

num=num+1;

sta[num]=b; //把求出最便宜路径的站点存入sta[]数组

P[a][b]=0;

d=b;

}

}

}

}

int station[]=newnew int[num+1];

for(i=0;i
station[i]=sta[i];

//去掉sta[]中的没用的0元素,把非0元素赋值给station[]数组

int m,k1=0,first=-1,last=-1;

boolean l1,l2;

while(k1
//在存储公交线路的数组bs中的搜索station[]数组中的站点元素

{

for(len=0;len
{

i=mon[len];

l1=l2=false;false

for(j=1;j<(bs[i].length-1)&&k1<(station.length-1);j++)

{

if(bs[i][j]==station[k1])

//把该路的起始站点固定在first位置

{

first=j;

l1=true;

}

}

for(j=1;j<(bs[i].length-1)&&k1<(station.length-1);j++)

{

if(bs[i][j]==station[k1+1])

//把该路的终止站点固定在last位置

{

last=j;

l2=true;

}

}

if(l1==true&&l2==true)

{

k1=k1+1;

}

if(l1==true&&l2==true)true true

{

if(k1<2)

{

str3=Integer.toString(bs[i][0]); str4+="线路"+str3+": "; //输出线路结果

}

else

{

str3=Integer.toString(bs[i][0]);

str4+="\n换乘线路"+str3+": "; //输出换乘线路结果

}

int newline=0;

if(first


for(m=first;m<=last;m++) //输出该线路上的站点

{

if(m!=last)

{

str3=Integer.toString(bs[i][m]);

str4+=" 站 名"+G.vex[bs[i][m]].busstation+str3+", ";

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else //输出该线路上的最后一个站点

{

str3=Integer.toString(bs[i][m]);

str4+=" 站 名"+G.vex[bs[i][m]].busstation+str3+".";

}

}

else

for(m=first;m>=last;m--) //输出该线路上的站点

{

if(m!=last)

{

str3=Integer.toString(bs[i][m]);

str4+=" 站 名"+G.vex[bs[i][m]].busstation+str3+", ";

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else //输出该线路上的最后一个站点

{

str3=Integer.toString(bs[i][m]);

str4+=" 站 名"+G.vex[bs[i][m]].busstation+str3+".";

}

}

}

}

if(k1==(station.length-1))

break;

}

str4+="\n 共花费"+((double)M[a])/10+"元.";double

//输出共花费的费用

for(i=0;i
sta[i]=0;

num=0;

}

return str4;

}

static String GetPath1(Graph G,String str1,String str2)

//查询获得任何两个站点之间最省时间路径(不考虑在中间站等下一辆线路的等待时间)的方法

{

String str3;

String str4="";

int i,j;

int num=0;

int bs[][]=new int[G.linenum][];

//创建存储公交路线的数组,行数为G.linenum

String str;

try {

str = "D:\\info\\line.xml";

Readline rl=new Readline();

Vector vect = rl.readXMLFile(str);

bs=new int[vect.size()][];

for(i=0;i
{

line l = (line)vect.get(i);

bs[i]=new int[(l.points).size()-2]; //设置bs数组的列数

for(j=0;j<(l.points).size();j++)

{

if(j!=(l.points).size()-3)

{

String s=(String)(((l.points).get(j)));

bs[i][j]=Integer.parseInt(s);

//把公交线路信息存储入bs数组

}

else

{

Strings=(String)(((l.points).get((l.points).size()-2)));

bs[i][j]=Integer.parseInt(s);

//把公交线路信息存储入bs数组

break;

}

}

}

} catch (NumberFormatException e2) {

e2.printStackTrace();

} catch (Exception e2) {

e2.printStackTrace();

}

int sta[]=newnew int [G.vexnum];

boolean l3;

int temp;

int bustime[]=new int[bs.length];

int tim[]=new int[bs.length];

for(i=0;i
{

bustime[i]=bs[i][bs[i].length-1];

//把每路公交线路的车速存入bustime[]数组

tim[i]=-1;

}

for(i=1;i
//冒泡排序把公交线路的车

速按从大到小存入bustime[]数组

for(j=0;j<(bustime.length-1);j++)

if(bustime[j]
{

temp=bustime[j];

bustime[j]=bustime[j+1];

bustime[j+1]=temp;

}

for(j=0;j
//按从大到小大的公交线路的车速把公交线路的线路编号存入tim[]数组for(i=0;i
{

l3=true;true

for(int ti=0;ti
{

if(i==tim[ti])

l3=false;

}

if(l3==true&&bustime[j]==bs[i][bs[i].length-1])

{

tim[j]=i;

break;

}

}

int len;

int speed[][]=new int[G.arcnum][3];

str = "D:\\info\\bian.xml";

Readbian rb= new Readbian();

i=0;

Vector vec;

try {

vec = rb.readXMLFile(str);

Iterator it = vec.iterator();

while(it.hasNext())

//从bian.xml文件中读出公交线路图的相邻有向边的信息

{

bian b= (bian)it.next();

speed[i][0]=b.getFir();

speed[i][1]=b.getSec();

speed[i][2]=0;

i++;

}

} catch (Exception e1) {

e1.printStackTrace();

}

int s;

for(s=0;s
for(len=0;len
//使用按公交线路的车速排序好的公交线路的线路查找相邻有向边的最大速度

{

i=tim[len];

l3=false;

for(j=1;j<(bs[i].length-2);j++)

{

if(bs[i][j]==speed[s][0]&&bs[i][j+1]==speed[s][1])

{

l3=true;

speed[s][2]=bs[i][bs[i].length-1];

//存入speed[][2]

break;

}

}

if(l3==false)false

for(j=(bs[i].length-2);j>1;j--)

{

if(bs[i][j]==speed[s][0]&&bs[i][j-1]==speed[s][1])

{

l3=true;

speed[s][2]=bs[i][bs[i].length-1];

//存入speed[][2]

break;

}

}

if(l3==true)

{

len=-1;

break;

}

}

/*这里把所有的边假定为10000,含义是站台间不可到达*/

for(i=0;i
for(j=0;j
G.arcs[i][j].time=10000;

/*下边是可直接到达的站台间的距离,由于两个站台间距离是互相的,

所以要对图中对称的边同时赋值。*/

for(s=0;s
G.arcs[speed[s][0]][speed[s][1]].time=G.arcs[speed[s][1]][speed[s][0]].time=(int)(Math.sqrt((G.vex[speed[s][0]].x-G.vex[speed[s][1]].x)*(G.vex[speed[s][0]].x-G.vex[speed[s][1]].x)+(G.vex[speed[s][0]].y-G.vex[speed[s][1]].y)*(G.vex[speed[s][0]].y-G.vex[speed[s][1]].y)))/speed[s][2];

int busstation1=-1,busstation2=-1;

if(str1==""&&str2=="")

str4=" 始站名和终站名为空,请重新选择!";

else if(str1=="")

str4=" 始站名为空,请重新选择!";

else if(str2=="")

str4=" 终站名为空,请重新选择!";

else if(str1==str2)

str4=" 请输入不同的始站名和终站名!";

else

{


for(i=0;i
{

if(G.vex[i].busstation.equals(str1))

{

busstation1=i;

break;

}

}

for(i=0;i
{

if(G.vex[i].busstation.equals(str2))

{

busstation2=i;

break;

}

}

//求最省时间路径(不考虑在中间站等下一辆线路的等待时间)的Dijkstra算法

int P[][]=new int[G.vexnum][G.vexnum];

int T[]=newnew int[G.vexnum];

int v,w,t;

int fin[]=new int[G.vexnum];

int min;

for(v=0;v
{

fin[v]=0;

T[v]=G.arcs[busstation1][v].time;

for(w=0;w
P[v][w]=0;

if(T[v]<10000)

{

P[v][busstation1]=1;

P[v][v]=1;

}

}

T[busstation1]=0;

fin[busstation1]=1;

for(i=0;i
{

min=10000;

for(w=0;w
if(!(fin[w]==1))

if(T[w]
{

v=w;

min=T[w];

}

fin[v]=1;

for(w=0;w
if(!(fin[w]==1)&&((min+G.arcs[v][w].time)
{

T[w]=min+G.arcs[v][w].time;

for(t=0;t
P[w][t]=P[v][t];

P[w][w]=1;

}

}

int a,b,c,d;

a=busstation2;

if(a!=busstation1)

{

str4+=" 从"+G.vex[busstation1].busstation+busstation1+" 到"+G.vex[busstation2].busstation+busstation2+"的最省时间路径(不考虑在中间站等下一辆线路的等待时间)是\n";

d=busstation1;

sta[0]=d;

for(c=0;c
{

P[a][busstation1]=0;

for(b=0;b
{

if(G.arcs[d][b].time<10000&&(P[a][b]==1))

{

num=num+1;

sta[num]=b;//把求出最省时间路径(不考虑在中间站等下一辆线路的等待时间)的站点存入sta[]数组

P[a][b]=0;

d=b;

}

}

}

}

int station[]=new int[num+1];

for(i=0;i
station[i]=sta[i];

//去掉sta[]中的没用的0元素,把非0元素赋值给station[]数组

int m,n,w1=0;

int flag=0,k1=0;

boolean l;

for(len=0;len
//在存储公交线路的数组bs中的搜索station[]数组中的站点元素

{

i=tim[len];

l=false;

n=0;

for(j=1;j<(bs[i].length-2)&&k1<(station.length-1);j++)

{

if((bs[i][j]==station[k1])&&(bs[i][j+1]==station[k1+1]))

//正向查找两个相邻站点

{

l=true;true

k1=k1+1;

n=n+1;

}

}

if(l==false)false

for(j=(bs[i].length-2);j>1&&k1<(station.length-1);j--)

{

if((bs[i][j]==station[k1])&&(bs[i][j-1]==station[k1+1])) //反向查找两个相邻站点

{

l=true;true

k1=k1+1;

n=n+1;

}

}

if(l==true)true


{

flag=flag+1;

}

int newline=0;

for(;flag==1&&w1<1;w1++)

{

str3=Integer.toString(bs[i][0]);

str4+="线路"+str3+": "; //输出线路结果

for(m=k1;m<=n+k1;m++)

{

if((m-n)!=(station.length-1))

{

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+", "; //输出该线路上的站点

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else //输出该线路上的最后一个站点和共花费的时间

{

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+"."+"\n 共花费"+T[a]+"分钟.";

}

}

}

newline=0;

if(flag>1)

{

str3=Integer.toString(bs[i][0]);

str4+="\n换乘线路"+str3+": "; //输出换乘线路结果

for(m=k1;m<=n+k1;m++)

{

if((m-n)!=(station.length-1))

{

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+", "; //输出该线路上的站点

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else //输出该线路上的最后一个站点和共花费的时间

{

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+"."+"\n 共花费"+T[a]+"分钟.";

}

}

}

if(k1==(station.length-1))

break;

if(l==true)

{

len=-1;

flag=1;

}

}

for(i=0;i
sta[i]=0;

num=0;

}

return str4;

}

static String GetPath2(Graph G,String str1,String str2) //查询获得任何两个站点之间最省时间路径(要考虑在中间站等下一辆线路的等待时间)的方法

{

String str3;

String str4="";

int i,j;

int num=0;

int bs[][]=new int[G.linenum][];

//创建存储公交路线的数组,行数为G.linenum

Vector vect;

String str;

try {

str = "D:\\info\\line.xml";

Readline rl=newnew Readline();

vect = rl.readXMLFile(str);

bs=newnew int[vect.size()][];

for(i=0;i
{

line l = (line)vect.get(i);

bs[i]=newnew int[(l.points).size()-1]; //设置bs数组的列数

for(j=0;j<(l.points).size();j++)

{

if(j!=(l.points).size()-3)

{

String s=(String)(((l.points).get(j)));

bs[i][j]=Integer.parseInt(s);

//把公交线路信息存储入bs数组

}

else

{

String

s=(String)(((l.points).get((l.points).size()-2)));

bs[i][j]=Integer.parseInt(s);

s=(String)(((l.points).get((l.points).size()-1)));

bs[i][j+1]=Integer.parseInt(s);

//把公交线路信息存储入bs

数组

break;

}

}

}

}catch (NumberFormatException e2) {

e2.printStackTrace();

} catch (Exception e2) {

e2.printStackTrace();

}

int sta[]=new int [G.vexnum];

boolean l3;

int temp;

int bustime[]=new int[bs.length];

int tim[]=new int[bs.length];

for(i=0;i
{

bustime[i]=bs[i][bs[i].length-2];

//把每路公交线路的车速存入bustime[]数组

tim[i]=-1;

}

for(i=1;i
//冒泡排序把公交线路的车速按从大到小存入bustime[]数组

for(j=0;j<(bustime.length-1);j++)

if(bustime[j]
{

temp=bustime[j];

bustime[j]=bustime[j+1];

bustime[j+1]=temp;

}

for(j=0;j
//按从大到小大的公交线路的车速把公交线路的线路编号存入tim[]数组for(i=0;i
{

l3=true;true

for(int ti=0;ti
{

if(i==tim[ti])

l3=false;

}

if(l3==true&&bustime[j]==bs[i][bs[i].length-2])

{

tim[j]=i;

break;

}

}

int len;

int speed[][]=new int[G.arcnum][3];

//从bian.xml文件中读出公交线路图的相邻有向边的信息

str = "D:\\info\\bian.xml";

Readbian rb= new Readbian();

i=0;

Vector vec;

try {

vec = rb.readXMLFile(str);

Iterator it = vec.iterator();

while(it.hasNext())

{

bian b= (bian)it.next();

speed[i][0]=b.getFir();

speed[i][1]=b.getSec();

speed[i][2]=0;

i++;

}

} catch (Exception e1) {

e1.printStackTrace();

}

int s;

for(s=0;s
//使用按公交线路的车速排序好的公交线路的线路查找相邻有向边的最大速度

for(len=0;len
{

i=tim[len];

l3=false;false

for(j=1;j<(bs[i].length-3);j++)

{

if(bs[i][j]==speed[s][0]&&bs[i][j+1]==speed[s][1])

{

l3=true;

speed[s][2]=bs[i][bs[i].length-2];

//存入speed[][2]

break;

}

}

if(l3==false)false

for(j=(bs[i].length-3);j>1;j--)

{

if(bs[i][j]==speed[s][0]&&bs[i][j-1]==speed[s][1])

{

l3=true;

speed[s][2]=bs[i][bs[i].length-2];

//存入speed[][2]

break;

}

}

if(l3==true)

{

len=-1;

break;

}

}

/*这里把所有的边假定为10000,含义是站台间不可到达*/

for(i=0;i
for(j=0;j
G.arcs[i][j].time=10000;

/*下边是可直接到达的站台间的距离,由于两个站台间距离是互相的,

所以要对图中对称的边同时赋值。*/

for(s=0;s
G.arcs[speed[s][0]][speed[s][1]].time=G.arcs[speed[s][1]][speed[s][0]].time=(int)(Math.sqrt((G.vex[speed[s][0

]].x-G.vex[speed[s][1]].x)*(G.vex[speed[s][0]].x-G.vex[speed[s][1]].x)+(G.vex[speed[s][0]].y-G.vex[speed[s][1]].y)*(G.vex[speed[s][0]].y-G.vex[speed[s][1]].y)))/speed[s][2];

int busstation1=-1,busstation2=-1;

if(str1==""&&str2=="")

str4=" 始站名和终站名为空,请重新选择!";

else if(str1=="")

str4=" 始站名为空,请重新选择!";

else if(str2=="")

str4=" 终站名为空,请重新选择!";

else if(str1==str2)

str4=" 请输入不同的始站名和终站名!";

else

{

for(i=0;i
{

if(G.vex[i].busstation.equals(str1))

{

busstation1=i;

break;

}

}

for(i=0;i
{

if(G.vex[i].busstation.equals(str2))

{

busstation2=i;

break;

}

}

//求最省时间路径(要考虑在中间站等下一辆线路的等待时间)的Dijkstra算法

int P[][]=newnew int[G.vexnum][G.vexnum];

int T[]=new int[G.vexnum];

int v,w,t;

int fin[]=newnew int[G.vexnum];

int busflag[]=new int[G.vexnum];

int min;

for(v=0;v
{

fin[v]=0;

busflag[v]=-1;

T[v]=G.arcs[busstation1][v].time;

for(w=0;w
P[v][w]=0;

if(T[v]<10000)

{

P[v][busstation1]=1;

P[v][v]=1;

}

}

T[busstation1]=0;

fin[busstation1]=1;

busflag[busstation1]=-1;

//判断是否要加入在中间站等下一辆线路的等待时间

for(i=0;i
{

boolean myflag;

min=10000;

for(w=0;w
if(!(fin[w]==1))

if(T[w]
{

v=w;

min=T[w];

}

fin[v]=1;

if(busflag[v]==-1)

{

for(len=0;len
{

i=tim[len];

myflag=false;

for(j=1;j<(bs[i].length-3);j++)

{

if(bs[i][j]==busstation1&&bs[i][j+1]==v)

{

myflag=true;

busflag[v]=i; //赋为该公交线路的编号

break;

}

}

if(myflag==false)

for(j=(bs[i].length-3);j>1;j--)

{

if(bs[i][j]==busstation1&&bs[i][j-1]==v)

{

myflag=true;

busflag[v]=i; //赋为该公交线路的编号 break;

}

}

if(myflag==true)

break;

}

}

for(w=0;w
if(!(fin[w]==1)&&((min+G.arcs[v][w].time)
{

myflag=false;

for(j=1;j<(bs[busflag[v]].length-3);j++)

{

if(bs[busflag[v]][j]==v&&bs[busflag[v]][j+1]==w)

{

myflag=true;true

busflag[w]=busflag[v];

//判断公交线路的编号是否为同一值

break;

}

}

if(myflag==false)

for(j=(bs[busflag[v]].length-3);j>1;j--)

{

if(bs[busflag[v]][j]==v&&bs[busflag[v]][j-1]==w)

{

myflag=true;

busflag[w]=busflag[v];

//判断公交线路的编号是否为同一值

break;

}

}

if(myflag==false)false

for(len=0;len
{

i=tim[len];

for(j=1;j<(bs[i].length-3);j++)

{

if(bs[i][j]==v&&bs[i][j+1]==w)

{

myflag=true;

busflag[w]=i;

//赋为该公交线路的编号

break;

}

}

if(myflag==false)false

for(j=(bs[i].length-3);j>1;j--)

{

if(bs[i][j]==v&&bs[i][j-1]==w)

{

myflag=true;true

busflag[w]=i;

//赋为该公交线路的编号

break;

}

}

if(myflag==true)

break;

}

if(busflag[v]==busflag[w])

//判断公交线路的编号是否为同一值

{ //不加入在中间站等下一辆线路的等待时间

T[w]=min+G.arcs[v][w].time;

for(t=0;t
P[w][t]=P[v][t];

P[w][w]=1;

}

else

{ //加入在中间站等下一辆线路的等待时间

T[w]=min+G.arcs[v][w].time+bs[busflag[w]][bs[busflag[w]].length-1];

for(t=0;t
P[w][t]=P[v][t];

P[w][w]=1;

}

}

}

int a,b,c,d;

a=busstation2;

if(a!=busstation1)

{

str4+="从"+G.vex[busstation1].busstation+busstation1+"到"+G.vex[busstation2].busstation+busstation2+"的最省时间路径(考虑在中间站等下一辆线路的等待时间)是\n";

d=busstation1;

sta[0]=d;

for(c=0;c
{

P[a][busstation1]=0;

for(b=0;b
{

if(G.arcs[d][b].time<10000&&(P[a][b]==1))

{

num=num+1;

sta[num]=b; //把求出最省时间路径(不考虑在中间站等下一辆线路的等待时间)的站点存入sta[]数组

P[a][b]=0;

d=b;

}

}

}

}

int station[]=new int[num+1];

for(i=0;i
station[i]=sta[i];

//去掉sta[]中的没用的0元素,把非0元素赋值给station[]数组

int m,n,w1=0;

int flag=0,k1=0;

boolean l;

for(len=0;len
{ //在存储公交线路的数组bs中的搜索station[]数组中的站点元素

i=tim[len];

l=false;

n=0;

for(j=1;j<(bs[i].length-3)&&k1<(station.length-1);j++)

{ //正向查找两个相邻站点

if((bs[i][j]==station[k1])&&(bs[i][j+1]==station[k1+1]))

{

l=true;

k1=k1+1;

n=n+1;

}

}

if(l==false)

for(j=(bs[i].length-3);j>1&&k1<(station.length-1);j--)

{ //反向查找两个相邻站点

if((bs[i][j]==station[k1])&&(bs[i][j-1]==station[k1+1]))

{

l=true;

k1=k1+1;

n=n+1;

}

}

if(l==true)

{

flag=flag+1;

}

int newline=0;

for(;flag==1&&w1<1;w1++)

{

str3=I

nteger.toString(bs[i][0]);

str4+="线路"+str3+": "; //输出线路结果

for(m=k1;m<=n+k1;m++)

{

if((m-n)!=(station.length-1))

{ //输出该线路上的站点

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+", ";

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else

{ //输出该线路上的最后一个站点和共花费的时间

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+"."+"\n 共花费"+T[a]+"分钟.";

}

}

}

newline=0;

if(flag>1)

{

str3=Integer.toString(bs[i][0]);

str4+="\n换乘线路"+str3+": "; //输出换乘线路结果

for(m=k1;m<=n+k1;m++)

{

if((m-n)!=(station.length-1))

{ //输出该线路上的站点

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+", ";

newline++;

if(newline==4)

{

str4+="\n ";

newline=0;

}

}

else

{ //输出该线路上的最后一个站点和共花费的时间

str3=Integer.toString(station[m-n]);

str4+=" 站 名"+G.vex[station[m-n]].busstation+str3+"."+"\n 共花费"+T[a]+"分钟.";

}

}

}

if(k1==(station.length-1))

break;

if(l==true)

{

len=-1;

flag=1;

}

}

for(i=0;i
sta[i]=0;

num=0;

}

return str4;

}

}

Welcome.java

package pack_BusLine;

import java.awt.Dimension;

import java.awt.Frame;

import java.awt.Toolkit;

import https://www.doczj.com/doc/9f13422722.html,bel;

import java.awt.Rectangle;

import java.awt.Button;

import java.awt.Font;

public class Welcome extends Frame { //欢迎界面

private static final long serialVersionUID = 1L;

private Button button = null;

private Button button1 = null;

private Label label = null;

private Label label1 = null;

private Button getButton() { //进入主界面按钮

if (button == null) {

button = new Button();

button.setBounds(new Rectangle(56, 177, 104, 51));

button.setFont(newnew Font("Dialog", Font.BOLD, 18));

button.setLabel("进入主界面");

button.addActionListener(newnew

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

Welcome.this.setVisible(false);

Bus bus=newnew Bus();

bus.setVisible(true);

}

});

}

return button;

}

private Button getButton1() { //退出按钮

if (button1 == null) {

button1 = new Button();

button1.setBounds(newnew Rectangle(209, 177, 104, 51));

button1.setFont(new Font("Dialog", Font.BOLD, 18));

button1.s

etLabel("退出");

button1.addActionListener(newnew

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

System.exit(0);

}

});

}

return button1;

}

public static void main(String[] args) {

Welcome welcome=newnew Welcome();

welcome.setVisible(true);

}

public Welcome() {

super();

initialize();

}

private void initialize() {

Dimension d;

label1 = new Label();

label1.setBounds(newnew Rectangle(26, 113, 330, 50));

label1.setFont(new Font("Dialog", Font.BOLD, 20));

label1.setText("路优化路径查询...");

label = new Label();

label.setBounds(new Rectangle(26, 59, 330, 50));

label.setFont(newnew Font("Dialog", Font.BOLD, 20));

label.setText(" 欢迎您进入鸟巢503----公交线");

d=Toolkit.getDefaultToolkit().getScreenSize();

this.setLayout(null);null

this.setLocation(d.width/3, d.height/5);

this.setSize(380, 250);

this.setTitle("Welcome to鸟巢503");

this.add(getButton(), null);

this.add(getButton1(), null);

this.add(label, null);

this.add(label1, null);

this.addWindowListener(new java.awt.event.WindowAdapter() {

publicvoidwindowClosing(java.awt.event.WindowEvente){

System.exit(0);

}

});

}

}

Bus..jjava

package pack_BusLine;

import java.awt.Dimension;

import java.awt.Frame;

import java.awt.Toolkit;

import javax.swing.Icon;

import javax.swing.ImageIcon;

import javax.swing.JLabel;

import java.awt.Rectangle;

import https://www.doczj.com/doc/9f13422722.html,bel;

import java.awt.Font;

import java.awt.Button;

import java.awt.TextArea;

import javax.swing.JComboBox;

public class Bus extends Frame {

Icon ico=new ImageIcon("D:\\info\\Bus.jpg");

//把要显示的图片路径赋给ico

private static final long serialVersionUID = 1L;

private JLabel jLabel = null;

private Label label = null;

private Label label1 = null;

private Label label2 = null;

private Button button1 = null;

private Button button2 = null;

private Button button3 = null;

private Button button4 = null;

private Button button5 = null;

private Button button6 = null;

private Label label3 = null;

private TextArea textArea = null;

private JComboBox jComboBox1 = null;

private JComboBox jComboBox2 = null;

private Button getButton1() {

//实现查询获得任何两个站点之间最便宜的路径的功能

if (button1 == null) {

button1 = new Button();

button1.setBounds(new Rectangle(140, 545, 98, 38));

button1.setLabel("最便宜路径");

button1.addActionListener(new

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

String s

tr1;

String str2;

String str4;

str1=(String) jComboBox1.getSelectedItem();

//把用户选择的起始站点赋给str1

str2=(String) jComboBox2.getSelectedItem();

//把用户选择的终止站点赋给str2

Graph G=newnew Graph(200,239,16);

//调用构造函数Graph()

Graph.SetBusInfo(G); //调用赋值函数SetBusInfo() str4=Graph.GetMoney(G,str1,str2);

//调用查询获得任何两个站点之间最便宜路径的函数GetMoney()

textArea.setText(str4); //文本框textArea输出结果

}

});

}

return button1;

}

private Button getButton2() { //实现查询获得任何两个站点之间最省时间的路径(不考虑在中间站等下一辆线路的等待时间)的功能

if (button2 == null) {

button2 = new Button();

button2.setBounds(new Rectangle(254, 545, 98, 38));

button2.setLabel("最省时间路径(1)");

button2.addActionListener(newnew

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

String str1;

String str2;

String str4;

str1=(String) jComboBox1.getSelectedItem();

//把用户选择的起始站点赋给str1

str2=(String) jComboBox2.getSelectedItem();

//把用户选择的终止站点赋给str2

Graph G=newnew Graph(200,239,16);

//调用构造函数Graph()

Graph.SetBusInfo(G); //调用赋值函数SetBusInfo()

str4=Graph.GetPath1(G,str1,str2);//调用查询获得任何两个站点之间最省时间路径(不考虑在中间站等下一辆线路的等待时间)的函数GetPath1()

textArea.setText(str4); //文本框textArea输出结果

}

});

}

return button2;

}

private Button getButton3() { //实现查询获得任何两个站点之间最省时间的路径(要考虑在中间站等下一辆线路的等待时间)的功能

if (button3 == null) {

button3 = new Button();

button3.setBounds(new Rectangle(368, 545, 98, 38));

button3.setLabel("最省时间路径(2)");

button3.addActionListener(new

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

String str1;

String str2;

String str4;

str1=(String) jComboBox1.getSelectedItem();

//把用户选择的起始站点赋给str1

str2=(String) jComboBox2.getSelectedItem();

//把用户选择的终止站点赋给str2

Graph G=newnew Graph(200,239,16);

//调用构造函数Graph()

Graph.SetBusInfo(G); //调用赋值函数SetBusInfo()

str4=Graph.GetPath2(G,str1,str2);//调用查询获得任何两个站点之间最省时间路径(要考虑在中间站等下一辆线路的等待时间)的函数GetPath1()

textArea.setText(str4); //文本框textArea输出结果

}

});

}

ret

urn button3;

}

private Button getButton4() { //清屏按钮

if (button4 == null) {

button4 = new Button();

button4.setBounds(newnew Rectangle(508, 545, 98, 38));

button4.setLabel("清屏");

button4.addActionListener(new

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

jComboBox1.setSelectedItem("");

//对jComboBox1赋值为空

jComboBox2.setSelectedItem("");

//对jComboBox2赋值为空

textArea.setText(""); //对textArea赋值为空

}

});

}

return button4;

}

private Button getButton5() { //退出按钮

if (button5 == null) {

button5 = new Button();

button5.setBounds(newnew Rectangle(629, 545, 98, 38));

button5.setLabel("退出");

button5.addActionListener(new

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

System.exit(0); //退出语句

}

});

}

return button5;

}

private Button getButton6() { //关于界面

if (button6 == null) {

button6 = new Button();

button6.setBounds(newnew Rectangle(629, 492, 98, 38));

button6.setLabel("关于");

button6.addActionListener(new

java.awt.event.ActionListener() {

public voidactionPerformed(java.awt.event.ActionEvent e) {

Bus.this.setVisible(false); //关掉当前界面

About about=new About(); //打开关于界面

about.setVisible(true);true

}

});

}

return button6;

}

private TextArea getTextArea() {

if (textArea == null) {

textArea = new TextArea();

textArea.setBounds(new Rectangle(90, 587, 653, 166));

textArea.setFont(newnew Font("Dialog", Font.PLAIN, 13));

}

return textArea;

}

private JComboBox getJComboBox1() {

if (jComboBox1 == null) {

jComboBox1 = new JComboBox();

jComboBox1.setBounds(newnew Rectangle(240, 460, 170, 34));

jComboBox1.setMaximumRowCount(10);

}

return jComboBox1;

}

private JComboBox getJComboBox2() {

if (jComboBox2 == null) {

jComboBox2 = new JComboBox();

jComboBox2.setBounds(new Rectangle(240, 506, 170, 34));

jComboBox2.setMaximumRowCount(10);

}

return jComboBox2;

}

public static void main(String[] args) {

Bus bus=newnew Bus();

bus.setVisible(true);

}

public Bus() {

super();

initialize();

}

private void initialize() {

label3 = new Label();

label3.setBounds(new Rectangle(24, 648, 57, 34));

label3.setAlignment(Label.CENTER);

label3.setText("结果为:");

label2 = new Label();

label2.setBounds(newnew Rectangle(140, 506, 99, 34));

label2.setAlignment(Label.CENTER);

label2.setText("请选择终站点:");

label1

= new Label();

label1.setBounds(new Rectangle(140, 460, 99, 34));

label1.setAlignment(Label.CENTER);

label1.setText("请选择始站点:");

label = new Label();

label.setBounds(new Rectangle(304, 28, 121, 27));

label.setFont(new Font("Dialog", Font.BOLD, 15));

label.setText("南宁公交路线图");

jLabel = new JLabel();

jLabel.setIcon(ico); //显示地图

jLabel.setBounds(new Rectangle(24, 56, 700, 400));

jLabel.setText("");

this.setLayout(null);null

this.setSize(754, 765);

this.setTitle("鸟巢503----南宁公交线路优化路径查询");

this.add(jLabel, null);

this.add(label, null);

this.add(label1, null);

this.add(label2, null);

this.add(getButton1(), null);

this.add(getButton2(), null);

this.add(getButton3(), null);

this.add(getButton4(), null);

this.add(getButton5(), null);

this.add(getButton6(), null);

this.add(label3, null);

this.add(getTextArea(), null);

this.add(getJComboBox1(), null);

this.add(getJComboBox2(), null);

jComboBox1.addItem(""); //jComboBox1选择框jComboBox1.addItem("安湖路口");

jComboBox1.addItem("");

jComboBox1.addItem("北大客运中心");

jComboBox1.addItem("北大路口");

jComboBox1.addItem("北大路中");

jComboBox1.addItem("北湖安居小区");

jComboBox1.addItem("北湖路北");

jComboBox1.addItem("北湖市场");

jComboBox1.addItem("北湖衡阳路口");

jComboBox1.addItem("北湖东二里");

jComboBox1.addItem("北湖路口");

jComboBox1.addItem("北际路口");

jComboBox1.addItem("北大江北路口");

jComboBox1.addItem("北湖东市场");

jComboBox1.addItem("滨湖广场");

jComboBox1.addItem("");

jComboBox1.addItem("朝阳济南路口");

jComboBox1.addItem("朝阳花园");

jComboBox1.addItem("长岗民主路口");

jComboBox1.addItem("长岗市场");

jComboBox1.addItem("长岗三里路口");

jComboBox1.addItem("茶花园望园路口");jComboBox1.addItem("茶花碧湖路口");

jComboBox1.addItem("长湖金湖路口");

jComboBox1.addItem("长湖滨湖路口");

jComboBox1.addItem("长岗路中");

jComboBox1.addItem("");

jComboBox1.addItem("大学清川路口");jComboBox1.addItem("大岭路口");jComboBox1.addItem("动物园");jComboBox1.addItem("电力学校");jComboBox1.addItem("大学路口");jComboBox1.addItem("东博机电城");jComboBox1.addItem("大树脚");jComboBox1.addItem("大会堂");jComboBox1.addItem("东葛路口");jComboBox1.addItem("东葛中路");jComboBox1.addItem("东葛葛村路口");jComboBox1.addItem("东葛东路");jComboBox1.addItem("东葛长湖路口");jComboBox1.addItem("");

jComboBox1.addItem("二塘立交");jComboBox1.addItem("二公里");jComboBox1.addItem("");

jComboBox1.addItem("广西民族大学");jComboBox1.addItem("广西大学西门");jComboBox1.addItem("广西大学");jComboBox1.addItem("广西大学附中");jComboBox1.addItem("

工业学校");jComboBox1.addItem("广西大学东门");jComboBox1.addItem("工人新村");jComboBox1.addItem("广西民族医院");jComboBox1.addItem("广西艺术学院");jComboBox1.addItem("古城路口");jComboBox1.addItem("古城建政路口");jComboBox1.addItem("广西日报社");jComboBox1.addItem("葛村建政路口");jComboBox1.addItem("葛村路口");jComboBox1.addItem("");

jComboBox1.addItem("火炬路");jComboBox1.addItem("衡阳北大路口");jComboBox1.addItem("火炬路一支");jComboBox1.addItem("衡阳地洞路口");jComboBox1.addItem("衡阳路口");jComboBox1.addItem("衡阳友爱路口");jComboBox1.addItem("衡阳路中");jComboBox1.addItem("火车站");jComboBox1.addItem("衡阳园湖路口");jComboBox1.addItem("虎邱");

jComboBox1.addItem("会展中心");jComboBox1.addItem("");

jComboBox1.addItem("经济管理干部学院");jComboBox1.addItem("解放路口");jComboBox1.addItem("江北永宁路口");jComboBox1.addItem("建政东路");jComboBox1.addItem("金花茶公园");jComboBox1.addItem("金湖路口");jComboBox1.addItem("金浦路口");jComboBox1.addItem("");

jComboBox1.addItem("科园路口");jComboBox1.addItem("科园综合市场");jComboBox1.addItem("科园秀厢路口");jComboBox1.addItem("");

jComboBox1.addItem("鲁班路口");jComboBox1.addItem("鲁班大学路口");jComboBox1.addItem("鲁班路北");jComboBox1.addItem("龙腾新阳路口");jComboBox1.addItem("龙腾路");

jComboBox1.addItem("利客隆");

jComboBox1.addItem("鲤湾路口");jComboBox1.addItem("琅东");

jComboBox1.addItem("烈士陵园");jComboBox1.addItem("");

jComboBox1.addItem("明秀新阳路口");jComboBox1.addItem("明秀路中");jComboBox1.addItem("明秀友爱路口");jComboBox1.addItem("明秀北湖路口");jComboBox1.addItem("民生广场");jComboBox1.addItem("民族江北路口");jComboBox1.addItem("民族共和路口");jComboBox1.addItem("民主路口");jComboBox1.addItem("民族广场");jComboBox1.addItem("民主园湖路口");jComboBox1.addItem("明秀市场");jComboBox1.addItem("明秀望州路口");jComboBox1.addItem("麻村");

jComboBox1.addItem("民族茶花");jComboBox1.addItem("茅桥");

jComboBox1.addItem("");

jComboBox1.addItem("农院路中");jComboBox1.addItem("农大路口");jComboBox1.addItem("南铁二衡");jComboBox1.addItem("南环路");jComboBox1.addItem("南湖公园");jComboBox1.addItem("南梧景观路口");jComboBox1.addItem("南梧望州路口");jComboBox1.addItem("");

jComboBox1.addItem("清川桥北");jComboBox1.addItem("青岛啤酒站");jComboBox1.addItem("区妇幼");jComboBox1.addItem("青年活动中心");jComboBox1.addItem("区体育场");jComboBox1.addItem("七星一巷路口");jComboBox1.addItem("区交通科研所");jComboBox1.addItem("青秀路口");jComboBox1.addItem("");

jComboBox1.addItem("肉联厂");jComboBox1.addItem("人民公园");jComboBox1.addItem("人民路口");jComboBox1.addItem("人民北大路口");jComboBox1.addItem("人民永宁路口");jComboBox

相关主题
文本预览
相关文档 最新文档