Ignore:
Timestamp:
2009-08-09T13:32:56+02:00 (15 years ago)
Author:
stoecker
Message:

minor cleanup, removed config file

Location:
applications/editors/josm/plugins/livegps/src/livegps
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java

    r14057 r16933  
    1616
    1717import org.openstreetmap.josm.data.coor.LatLon;
     18import org.openstreetmap.josm.Main;
    1819
    1920public class LiveGpsAcquirer implements Runnable {
     
    2122    BufferedReader gpsdReader;
    2223    boolean connected = false;
    23     String gpsdHost = "localhost";
    24     int gpsdPort = 2947;
    25     String configFile = "liveGPS.conf";
     24    String gpsdHost = Main.pref.get("livegps.gpsd.host","localhost");
     25    int gpsdPort = Main.pref.getInteger("livegps.gpsd.port", 2947);
    2626    boolean shutdownFlag = false;
    2727    private List<PropertyChangeListener> propertyChangeListener = new ArrayList<PropertyChangeListener>();
    2828    private PropertyChangeEvent lastStatusEvent;
    2929    private PropertyChangeEvent lastDataEvent;
    30 
    31     public LiveGpsAcquirer(String pluginDir) {
    32 
    33         Properties liveGPSconfig = new Properties();
    34 
    35         FileInputStream fis = null;
    36 
    37         try {
    38             fis = new FileInputStream(pluginDir + configFile);
    39         } catch (FileNotFoundException e) {
    40             System.err.println("No liveGPS.conf found, using defaults");
    41         }
    42 
    43         if(fis != null)
    44         {
    45             try {
    46                 liveGPSconfig.load(fis);
    47                 this.gpsdHost = liveGPSconfig.getProperty("host");
    48                 this.gpsdPort = Integer.parseInt(liveGPSconfig.getProperty("port"));
    49 
    50             } catch (IOException e) {
    51                 System.err.println("Error while loading liveGPS.conf, using defaults");
    52             }
    53 
    54             if(this.gpsdHost == null || this.gpsdPort == 0)
    55             {
    56                 System.err.println("Error in liveGPS.conf, using defaults");
    57                 this.gpsdHost = "localhost";
    58                 this.gpsdPort = 2947;
    59             }
    60         }
    61 
    62     }
    6330
    6431    /**
     
    230197        }
    231198
    232     fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected"));
     199        fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected"));
    233200        if (gpsdSocket != null) {
    234       try {
    235         gpsdSocket.close();
    236         gpsdSocket = null;
    237             System.out.println("LiveGps: Disconnected from gpsd");
    238       }
    239       catch (Exception e) {
    240         System.out.println("LiveGps: Unable to close socket; reconnection may not be possible");
    241       };
    242       }
    243   }
     201            try {
     202              gpsdSocket.close();
     203              gpsdSocket = null;
     204                  System.out.println("LiveGps: Disconnected from gpsd");
     205            }
     206            catch (Exception e) {
     207              System.out.println("LiveGps: Unable to close socket; reconnection may not be possible");
     208            }
     209        }
     210    }
    244211
    245212    public void shutdown()
  • applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java

    r14057 r16933  
    33 */
    44package livegps;
     5
     6import static org.openstreetmap.josm.tools.I18n.tr;
    57
    68import java.awt.Point;
     
    109111        return getClass().getSimpleName() + "[fix=" + fix + ", lat=" + latLon.lat()
    110112        + ", long=" + latLon.lon() + ", speed=" + speed + ", course=" + course + "]";
    111 
    112113    }
    113114
     
    127128                    builder.append(tmp);
    128129                } else {
    129                     builder.append("no name");
     130                    builder.append(tr("no name"));
    130131                }
    131132                tmp = way.get("ref");
     
    163164    public Way getWay() {
    164165        if(way == null) {
    165             EastNorth eastnorth = Main.proj.latlon2eastNorth(getLatLon());
    166             Point xy = Main.map.mapView.getPoint(eastnorth);
     166            Point xy = Main.map.mapView.getPoint(getLatLon());
    167167            way = Main.map.mapView.getNearestWay(xy);
    168168        }
    169169        return way;
    170 
    171170    }
    172171
     
    206205        return true;
    207206    }
    208 
    209 
    210 
    211207}
  • applications/editors/josm/plugins/livegps/src/livegps/LiveGpsDialog.java

    r14057 r16933  
    8484                    wayLabel.setText(wayString);
    8585                } else {
    86                     wayLabel.setText("unknown");
     86                    wayLabel.setText(tr("unknown"));
    8787                }
    8888
  • applications/editors/josm/plugins/livegps/src/livegps/LiveGpsPlugin.java

    r14120 r16933  
    131131        {
    132132            if (acquirer == null) {
    133                 acquirer = new LiveGpsAcquirer(getPluginDir());
     133                acquirer = new LiveGpsAcquirer();
    134134                if (lgpslayer == null) {
    135135                    lgpslayer = new LiveGpsLayer(data);
Note: See TracChangeset for help on using the changeset viewer.