summaryrefslogtreecommitdiff
path: root/trunk/build/preprocessed/nav/navigate.java
blob: eeaffce0644fd9e3f06b41ad9cf8d76e5fe96f64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*
 * 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();
    }

}