Title: Final Projects Demo
1Mobile Computing
Final Projects Demo Maps Navigator
Rong,Yongjun(rong_at_cs.ttu.edu)
2Outline
- Introduction
- Architecture
- Challenges
- Demo
3Introduction
Map Websites www.MapQuest.com
map.yahoo.com map.msn.com Can we use
these map websites if we only has a mobile
device? Help you to find your drive
direction Help you locate yourself
4Architecture
Mapquest
Map Website ClipServer
Internet
GCF
http/html
MsnMap
XML
YahooMap
Session(cookie) Image adapting HTML parsing WS
client
Get Map Get Direction Save and restore
5GUI Design
Submit
Save
GetMap
GetDirection
Submit
Save
Save
Display Text
Restore
ShowMap
6Challenges
Analyze the http packages to make sure whats
the information (URL and cookie) is necessary to
get a map or directions.
7Challenges
HTML file parsing. . Using
HTMLEditorKit.ParserCallback and Regular
expression to parse and extract the needed
information.
public void handleText(char data, int pos)
if(txt.startsWith("document.cookie"))
String tmps txt.split("") else
if(tmp.matches("1-90-9"))
s.append("---"tmp) numreturn
else if(txt.matches("\\pASCIIbecomes\\pASCII
")) s.append(txt) return
8Challenges
Image Adapting
private RenderedImage scaleImage(RenderedImage
rImg,int x, int y) BufferedImage img new
BufferedImage(x, y, BufferedImage.TYPE_INT_RGB) G
raphics2D g2d (Graphics2D) img.getGraphics() g2
d.setRenderingHint(RenderingHints.KEY_RENDERING,Re
nderingHints.VALUE_RENDER_QUALITY) RenderingHints
.VALUE_ALPHA_INTERPOLATION_QUALITY )
g2d.drawImage((Image)rImg,0,0,x,y,null)
return img
9Challenges
Cookie maintaining private String
getCookie(HttpURLConnection httpURL) int
i0 String keyValuenullStringBuffer
cookieBuffer new StringBuffer()
do i String key httpURL.getHeaderFieldKey(i
) keyValuehttpURL.getHeaderField(i) Syste
m.out.println(key""keyValue)
if((key!null) key.equalsIgnoreCase("Set-Cookie
")) cookieBuffer.append(keyValue.substring(0,1
keyValue.lastIndexOf(""))) while(keyValue!nu
ll) if(cookieBuffer.length()!0)
System.out.println("cookieBuffer"cookieBuffe
r.toString()) return cookieBuffer.substr
ing(0,cookieBuffer.lastIndexOf(""))
return this.cookie
10Demos
11QA Thanks