/* * navigate.java * * Created on July 14, 2007, 2:18 AM * * To change this template, choose Tools | Template Manager * and open the template in the editor. */ package nav; import javax.microedition.location.*; import gui.geoc; import java.lang.Thread; /** * * @author manut */ public class navigate { private geoc gui; private LocationProvider pos; private int provState; private Location actLoc; private Landmark dest; private processLoc pLoc; private processState pState; /** Creates a new instance of navigate */ public navigate(geoc _gui) throws LocationException { pos = LocationProvider.getInstance(null); if (pos == null) throw new LocationException(); gui = _gui; pLoc = new processLoc(gui); pState = new processState(gui); } /** sets destination */ public void setDestination ( String north, String east ) throws IllegalArgumentException { double latitude, longitude; float altitude, hAcc, vAcc; latitude = Coordinates.convert(north); longitude = Coordinates.convert(east); altitude = Float.NaN; hAcc = 0; vAcc = 0; QualifiedCoordinates coord; coord = new QualifiedCoordinates( latitude, longitude, altitude, hAcc, vAcc ); if(dest == null){ AddressInfo info = new AddressInfo(); dest = new Landmark("destination", "stageX", coord, info); } else dest.setQualifiedCoordinates(coord); locListener locList = new locListener(this); int interval = -1; gui.get_stringItemDestNorth().setText(north); gui.get_stringItemDestEast().setText(east); pos.setLocationListener(locList, interval, 0, 0); } public void setNewLoc(Location loc){ actLoc = loc; pLoc.set(loc, dest); pLoc.run(); } public void setNewState(int state){ provState = state; pState.set(state); pState.run(); } }