📄 track.java
字号:
// Decompiled by DJ v3.7.7.81 Copyright 2004 Atanas Neshkov Date: 2008-6-16 11:21:24
// Home Page : http://members.fortunecity.com/neshkov/dj.html - Check often for new version!
// Decompiler options: packimports(3)
// Source File Name: Track.java
package com.eightmotions.map;
import com.eightmotions.util.*;
import henson.midp.Float;
import java.io.*;
import java.util.*;
import javax.microedition.io.HttpConnection;
import javax.microedition.lcdui.*;
import javax.microedition.rms.*;
import org.kxml2.io.KXmlParser;
// Referenced classes of package com.eightmotions.map:
// OneLocSquare, OneLoc, MapCanvas, TrackNotifier,
// oneGPSPos, TrackListener
public class Track
implements NotifyLoadURL
{
protected Track(Display d, String inUrl, String inInfo, MapCanvas inCanvas)
{
isInit = false;
m_rmsId = -1;
times = null;
alts = null;
courses = null;
speeds = null;
m_locType = m_defaultLocType;
m_name = "Noname";
listPlaces = new Vector();
savedTrack = null;
m_tn = null;
nbWaypoints = 0;
sizeTrack = 0;
loaded = false;
modeTrack = 0;
m_autoDisplay = false;
m_refreshType = 0;
m_display = d;
m_url = inUrl;
if(d != null)
{
d.setCurrent(m_a = new Alert("Loading", inInfo, null, AlertType.INFO));
m_a.setTimeout(-2);
}
String url = inUrl;
if(inCanvas != null)
url = inCanvas.locateURL(m_url);
if(UtilMidp.DEBUG)
System.out.println("url:" + url);
int first = url.lastIndexOf('/');
if(first == -1)
first = 0;
if(first == url.length() - 1)
first = 0;
else
first++;
m_name = url.substring(first);
URLFetcher f = new URLFetcher(url);
f.setListener(this);
f.fetch();
isInit = true;
}
protected Track(Display d, String name)
{
isInit = false;
m_rmsId = -1;
times = null;
alts = null;
courses = null;
speeds = null;
m_locType = m_defaultLocType;
m_name = "Noname";
listPlaces = new Vector();
savedTrack = null;
m_tn = null;
nbWaypoints = 0;
sizeTrack = 0;
loaded = false;
modeTrack = 0;
m_autoDisplay = false;
m_refreshType = 0;
m_display = d;
m_name = name;
}
protected Track(Display d, int inRmsId)
{
isInit = false;
m_rmsId = -1;
times = null;
alts = null;
courses = null;
speeds = null;
m_locType = m_defaultLocType;
m_name = "Noname";
listPlaces = new Vector();
savedTrack = null;
m_tn = null;
nbWaypoints = 0;
sizeTrack = 0;
loaded = false;
modeTrack = 0;
m_autoDisplay = false;
m_refreshType = 0;
m_display = d;
m_rmsId = inRmsId;
loadHeader();
}
protected Track(Display d, Displayable reference, InputStream is, String inInfo)
{
isInit = false;
m_rmsId = -1;
times = null;
alts = null;
courses = null;
speeds = null;
m_locType = m_defaultLocType;
m_name = "Noname";
listPlaces = new Vector();
savedTrack = null;
m_tn = null;
nbWaypoints = 0;
sizeTrack = 0;
loaded = false;
modeTrack = 0;
m_autoDisplay = false;
m_refreshType = 0;
m_display = d;
m_url = "none";
d.setCurrent(m_a = new Alert("Loading", inInfo, null, AlertType.INFO));
m_a.setTimeout(-2);
inputStream(is, null);
isInit = true;
}
public static Track getTrack(Display d, String name)
{
Track t = new Track(d, name);
addTrack(t);
return t;
}
public static Track getTrack(Display d, String inUrl, String inInfo, MapCanvas inMap)
{
Track t = new Track(d, inUrl, inInfo, inMap);
addTrack(t);
return t;
}
public static Track getTrack(Display d, Displayable reference, InputStream is, String inInfo)
{
Track t = new Track(d, reference, is, inInfo);
addTrack(t);
return t;
}
public static void addTrack(Track t)
{
tracks.addElement(t);
if(m_tn_glob != null)
m_tn_glob.onTrackCreated(t);
}
protected long readLong(byte b[], int off, int length)
{
long res;
int next;
for(res = 0L; length-- > 0; res = (res << 8) + (long)next)
{
next = b[off++];
if(next < 0)
next = 256 + next;
}
return res;
}
protected static void writeLong(byte b[], int off, int length, long data)
{
while(length-- > 0)
{
b[off + length] = (byte)(int)(data % 255L);
data >>= 8;
}
}
public void setUrl(String inUrl, MapCanvas inMap)
{
m_url = inUrl;
if(inMap != null)
inUrl = inMap.locateURL(inUrl);
URLFetcher f = new URLFetcher(inUrl);
f.setListener(this);
f.fetch();
}
public void export(OutputStream os, int typeExport)
{
switch(typeExport)
{
case 1: // '\001'
sendGPX(os);
break;
case 0: // '\0'
default:
sendKML(os);
break;
}
}
public static void initTracks()
{
int lid = 0;
try
{
RecordStore rs = RecordStore.openRecordStore("GPSTrack", true);
for(RecordEnumeration re = rs.enumerateRecords(null, null, false); re.hasNextElement();)
{
int rd = re.nextRecordId();
int size = rs.getRecordSize(rd);
String name = "Record " + lid++ + " Size:" + size + " rd:" + rd;
try
{
Track track = new Track(null, rd);
addTrack(track);
}
catch(Exception e)
{
e.printStackTrace();
}
}
rs.closeRecordStore();
}
catch(Exception e)
{
e.printStackTrace();
}
}
protected void loadHeader()
{
try
{
RecordStore rs = RecordStore.openRecordStore("GPSTrack", true);
byte buffer[] = rs.getRecord(m_rmsId);
int size;
for(size = 63; buffer[size] == 0; size--);
try
{
m_name = new String(buffer, 0, size, "UTF-8");
}
catch(Exception e)
{
m_name = new String(buffer, 0, size);
}
m_name = m_name.trim();
modeTrack = (int)readLong(buffer, 64, 1);
sizeTrack = (int)readLong(buffer, 65, 3);
nbWaypoints = (int)readLong(buffer, 68, 4);
timeStamp = readLong(buffer, 72, 8);
if(UtilMidp.DEBUG)
System.out.println("Header:" + sizeTrack + " waypoints:" + nbWaypoints + " time:" + timeStamp);
if(UtilMidp.DEBUG)
System.out.println("Trying to read:" + m_rmsId + " size:" + rs.getRecordSize(m_rmsId));
rs.closeRecordStore();
buffer = null;
}
catch(RecordStoreException e)
{
e.printStackTrace();
}
}
public void clear()
{
nbWaypoints = 0;
listPlaces.removeAllElements();
sizeTrack = 0;
}
public boolean inputStream(InputStream is, HttpConnection cnx)
{
try
{
KXmlParser parser;
parser = new KXmlParser();
parser.setInput(is, null);
return parse(parser);
}catch(Exception e)
{
e.printStackTrace();
return false;
}
}
public boolean parse(KXmlParser parser)
{
return false;
// Vector oldList;
// int num;
// oldList = new Vector();
// for(int i = 0; i < listPlaces.size(); i++)
// oldList.addElement(listPlaces.elementAt(i));
//
// clear();
// num = 0;
// boolean inItem;
// boolean cont;
// boolean inLineString;
// boolean inWpt;
// boolean inIconStyle;
// boolean inLink;
// boolean inIcon;
// int color;
// int type;
// String lon;
// String lat;
// String name;
// String description;
// String iconName;
// String photoName;
// String tel;
// String adr;
// String bbox;
// OneLoc curLoc;
// int segments[];
// int nbSegment;
// int iconX;
// int iconY;
// boolean inBlock;
// boolean doReload;
// String urlIcon;
// Hashtable values;
// String curStyleName;
// Hashtable styles;
// inItem = false;
// cont = true;
// inLineString = false;
// inWpt = false;
// inIconStyle = false;
// inLink = false;
// inIcon = false;
// color = -1;
// type = -1;
// lon = "";
// lat = "";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -