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

📄 finder.java

📁 一个专门为手机写的程序
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		text.addCommand(exit);
		text.setCommandListener(this);
		
		getNextRoute(true);
		owner.display.setCurrent(text);
	}
	
	public void commandAction(Command c,Displayable d)
	{
		if(c==exit)
		{
			System.gc();
			owner.setCurrent();
		}else if(c==next)
		{
			getNextRoute(true);
		}else{
			getNextRoute(false);			
		}
	}
	
	public void getNextRoute(boolean isNext)
	{
		int j=text.size();
		for(int i=0; i<j; i++)
			text.delete(0);
		if(owner.query.getLineNum()==0)
		{
			text.append("未设置好起止站点,或没有得到符合条件的路线!也可能是所限制的转车数量太少");
			return;
		}
		if(isNext)
		{
			currentRoute++;
			if(currentRoute>=owner.query.getLineNum())
			{ 
				currentRoute=-1;
				owner.display.setCurrent(new Alert("提示", "已是最后一条路线\n将显示第1条路线", null, AlertType.WARNING));
				getNextRoute(true);
				return;
			}
		}else
		{
			currentRoute--;
			if(currentRoute<0)
			{ 
				currentRoute=owner.query.getLineNum();
				owner.display.setCurrent(new Alert("提示", "已是第一条路线\n将显示最后一条路线", null, AlertType.WARNING));
				getNextRoute(false);
				return;
			}
		}
		//某条路线的长度
		int num=owner.query.getGoodLine(currentRoute).getBusNum();
		String no="路线:"+(new Integer(currentRoute+1).toString())+" 乘车数:"; 
		text.append(no);
		text.append(new Integer(num).toString());
		text.append("\n\n");
		text.append(owner.query.getStopName(owner.query.getStartStop())+"\n");
		for(int i=0; i<num; ++i)
		{
			text.append("  乘 "+owner.query.getBusName(owner.query.getGoodLine(currentRoute).buses[i])+"\n");
			text.append(owner.query.getStopName(owner.query.getGoodLine(currentRoute).stops[i])+"\n");
		}
	}
//@@@@@@@@@@@@@	
	private javax.microedition.lcdui.Form text=null;
	private Finder owner;		
	private Command exit;
	private Command last;
	private Command next;
	
	private int currentRoute=-1;
}

/*查看一个站点上的bus*/
class StopQuery implements CommandListener
{
	public StopQuery(Finder own, int num)
	{
		owner=own;
		if(num<0 || num>=owner.query.getStopNum()) return;
		String stop=owner.query.getStopName(num);
		text=new Form(stop);
		//text=new Form("站点查询");
		//text.append(stop);
		
		text.addCommand(exit);
		text.setCommandListener(this);
		addBus(num);
		
		owner.display.setCurrent(text);
	}
	
	public void commandAction(Command c,Displayable d)
	{
		if(c==exit)
		{
			System.gc();
			owner.setCurrent();
		}
	}
	
	public void addBus(int number)
	{
		if(number<0 || number>=owner.query.getStopNum()) return;
		if(text.size()>0) text.delete(0);
		//某条路线的长度
		int num=owner.query.m_stopList.getBusNumOnStop(number);
		//System.out.println(num);
		int busID;
		for(int i=0; i<num; ++i)
		{
			busID=owner.query.m_stopList.getBusIDOnStop(number, i);
			if(buses==null)
			{
				buses=owner.query.getBusName(busID).trim()+"  ";
			}else
				buses+=owner.query.getBusName(busID).trim()+"  ";
		}
		text.append(buses);
		buses=null;
	}
//@@@@@@@@@@@@@	
	private javax.microedition.lcdui.Form text=null;
	Finder owner;		
	private Command exit=new Command("退出", Command.EXIT, 0);
	private String buses=null;
}


/*//查询bus上的车站
class BusQuery implements CommandListener
{
	public BusQuery(Finder own)
	{
		owner=own;
		inputBox=new TextBox("输入车次号", null, owner.query.getBusNameLen(),TextField.NUMERIC);
		form=new Form("车次查询");
		list=new List("车次选择", List.IMPLICIT);
		//用于form
		exit=new Command("退出", Command.OK, 0);
		input=new Command("输入车次", Command.BACK,0);
		form.addCommand(exit);
		form.addCommand(input);
		form.setCommandListener(this);
		//用于inputbox
		ok=new Command("查询", Command.OK, 0);
		cancel=new Command("取消", Command.CANCEL,0);
		inputBox.addCommand(ok);
		inputBox.addCommand(cancel);
		
		
		list.addCommand(ok);
		list.addCommand(cancel);
		

		owner.display.setCurrent(form);
	}
	
	public void commandAction(Command c,Displayable d)
	{
		if(c==exit)
		{
			System.gc();
			owner.setCurrent();
		}else if(c==input)
		{
			inputBox.setCommandListener(this);
			owner.display.setCurrent(inputBox);
		}else if(c==ok && d==inputBox)
		{
			String busInput=inputBox.getString().trim();
			owner.display.setCurrent(list);
			list.setCommandListener(this);
			addBus(busInput);
		}else if((c==ok || c==List.SELECT_COMMAND) && d==list )
		{
			bus=list.getString(list.getSelectedIndex());
			owner.display.setCurrent(form);
			addStop();
		}else if(c==cancel)
		{
			owner.display.setCurrent(form);
		}
	}

	//向list中加入车次名
	private void addBus(String busInput)
	{
		int num=list.size();
		for(int i=0; i<num; ++i) list.delete(0);
		if(busInput.length()<=0) return;
		
		owner.query.searchBusName(busInput, list);
		if(list.size()<=0)
		{	
			if(form.size()>0) form.delete(0);
			form.append("未找到你输入的车次!");
			form.setCommandListener(this);
			owner.display.setCurrent(form);
		}
	}
	
	//根据选择的bus,来加入相应的站点名
	public void addStop()
	{
		if(form.size()>0) form.delete(0);
		int busID=owner.query.getBusIdFromName(bus);
		//某条路线的长度
		int num=owner.query.m_busList.getStopNumOnBus(busID);
		int stopID;
		for(int i=0; i<num; ++i)
		{
			stopID=owner.query.m_busList.getStopIDOnBus(busID, i);
			if(stops==null)
			{
				stops=owner.query.getStopName(stopID).trim()+"\n";
			}else
				stops+=owner.query.getStopName(stopID).trim()+"\n";
		}
		if(stops!=null)form.append(stops);
		stops=null;
	}
//@@@@@@@@@@@@@	
	private Form form;
	private List list;
	private TextBox inputBox;
	private Finder owner;		
	private Command exit,input, ok, cancel;
	private String stops=null,bus;
}
*/

//加入车站名的线程
class AddStops extends Thread
{
	public AddStops(Finder owner)
	{
		this.owner=owner;
	}
	
	public void run()
	{
		owner.query.readName();
		/*for(int i=0; i<owner.query.getStopNum(); ++i)
		{	
			owner.stops.append(owner.query.getStopName(i).trim(), null);
		}*/
		//owner.query.createStopAndBus();
		owner.literalInput.preRun();
		//owner.setCurrent();
	}
	Finder owner=null;
}

//修改路线深度
class SetDepth implements CommandListener
{
	public SetDepth(Finder own)
	{
		owner=own;
		form=new Form("路线深度设置");
		inputDepth=new TextField("深度",new Integer(owner.query.getDepth()).toString(),1,TextField.NUMERIC);
		form.append(inputDepth);
		form.append(new StringItem("说明:", new String("输入一个1至3的数字。限制路线中所乘的公交车数,也可以加速查找!系统的初值是2。")));
		
		okCmd=new Command("确定",Command.OK,1);
		calcelCmd=new Command("取消", Command.EXIT, 0);
		
		form.addCommand(okCmd);
		form.addCommand(calcelCmd);
		form.setCommandListener(this);
		owner.display.setCurrent(form);
	}

	public void commandAction(Command cmd, Displayable dis)
	{
		if(cmd==okCmd)
		{
			char i=inputDepth.getString().charAt(0);
			if(i<'4' && i>'0') owner.query.setDepth((int)i-'0');
		}
		owner.setCurrent();
	}
//@@ATTRIBUTE
	Form form;
	TextField inputDepth;
	Command okCmd,calcelCmd;
	Finder owner;
}

//about
class About implements CommandListener
{
	public About(Finder own, String title, String content)
	{
		owner=own;
		form=new Form(title);
		form.append(content);
		okCmd=new Command("确定",Command.OK,0);
		
		form.addCommand(okCmd);
		form.setCommandListener(this);

		owner.display.setCurrent(form);
	}

	public void commandAction(Command cmd, Displayable dis)
	{
		if(cmd==okCmd){
			owner.setCurrent();
		}
	}
//@@ATTRIBUTE
	Form form;
	Command okCmd;
	Finder owner;
}

class Strings
{
	static String about="软件:公交路线选择软件\n作者:李蛟\n浙江工业大学计本026班\n邮箱:joke_leee@163.com\n"
			+"本软件是用于查询市公交路线选择的软件。"
			+"本软件在对相应文件进行修改后可用于任何类似各个城市的公交路线等的查询。此软件对以前未发布版本作"
			+"了重大改进(才敢拿出来show^_^)。除了用于商业需经得本人同意外,你可以学习使用"
			+"甚至修改。第一次发布,难免很多的错误和不足,欢迎有兴趣的朋友批评指正,发现问"
			+"题请与本人联系,咱们可以交流交流!";
	static String help="输入站点:输入某个站点的部分名称,搜索站点。进行操作。\n\n"
			+"站点查询:查询经过本站点的公交车。可以用中键'i'代替。\n\n"
			+"车次查询:通过输入车次号码,查找车次,并查找此车次所经过的站点。可以用中键'i'代替。\n\n"
			+"设为起点站:设置当前选择的站点为搜索路线时的出发站点。\n\n"
			+"设为目的站:设置当前选择的站点为搜索路线时的出目的站。\n\n"
			+"最多转车数:设置选择路线最多的转车数量,即转车次数需大于所设置数时,次路线不在考虑之内,这样可以加快搜索速度。\n\n"
			+"开始搜索:在设置了起止站点后,开始搜索。时间可能比较长,请耐心等待。\n\n";
			
	static String input="本输入法是为了此软件而作的,可以移植到其他java手机程序中。由于容量大,刚开始输入时"
			+"会比较慢,请耐心等待。等待过程中不要随便乱按按键!对输入法有什么意见也可以通知我,不甚感激!";
}

⌨️ 快捷键说明

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