Changeset 33739 in osm for applications
- Timestamp:
- 2017-10-28T16:44:03+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/livegps
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/build.xml
r33360 r33739 2 2 <project name="livegps" default="dist" basedir="."> 3 3 <property name="commit.message" value="Changed the constructor signature of the plugin main class"/> 4 <property name="plugin.main.version" value="12 289"/>4 <property name="plugin.main.version" value="12987"/> 5 5 6 6 <!-- Configure these properties (replace "..." accordingly). -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
r33419 r33739 22 22 23 23 import org.openstreetmap.josm.Main; 24 import org.openstreetmap.josm.tools.Logging; 24 25 25 26 public class LiveGpsAcquirer implements Runnable { … … 47 48 48 49 gpsdHost = Main.pref.get(C_HOST, DEFAULT_HOST); 49 gpsdPort = Main.pref.getInt eger(C_PORT, DEFAULT_PORT);50 gpsdPort = Main.pref.getInt(C_PORT, DEFAULT_PORT); 50 51 // put the settings back in to the preferences, makes keys appear. 51 52 Main.pref.put(C_HOST, gpsdHost); 52 Main.pref.putInt eger(C_PORT, gpsdPort);53 Main.pref.putInt(C_PORT, gpsdPort); 53 54 } 54 55 … … 133 134 Thread.sleep(1000); 134 135 } catch (InterruptedException ignore) { 135 Main.trace(ignore);136 Logging.trace(ignore); 136 137 } 137 138 } … … 162 163 oldGpsData = gpsData; 163 164 } catch (IOException iox) { 164 Main.warn(iox, "LiveGps: lost connection to gpsd");165 Logging.log(Logging.LEVEL_WARN, "LiveGps: lost connection to gpsd", iox); 165 166 fireGpsStatusChangeEvent( 166 167 LiveGpsStatus.GpsStatus.CONNECTION_FAILED, … … 170 171 Thread.sleep(1000); 171 172 } catch (InterruptedException ignore) { 172 Main.trace(ignore);173 Logging.trace(ignore); 173 174 } 174 175 // send warning to layer … … 176 177 } 177 178 178 Main.info("LiveGps: Disconnected from gpsd");179 Logging.info("LiveGps: Disconnected from gpsd"); 179 180 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, 180 181 tr("Not connected")); … … 190 191 String line, type, release; 191 192 192 Main.info("LiveGps: trying to connect to gpsd at " + gpsdHost + ":" + gpsdPort);193 Logging.info("LiveGps: trying to connect to gpsd at " + gpsdHost + ":" + gpsdPort); 193 194 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTING, tr("Connecting")); 194 195 … … 199 200 break; 200 201 } catch (IOException e) { 201 Main.warn("LiveGps: Could not open connection to gpsd: " + e);202 Logging.warn("LiveGps: Could not open connection to gpsd: " + e); 202 203 gpsdSocket = null; 203 204 } … … 222 223 if (type.equals("VERSION")) { 223 224 release = greeting.getString("release"); 224 Main.info("LiveGps: Connected to gpsd " + release);225 Logging.info("LiveGps: Connected to gpsd " + release); 225 226 } else 226 Main.info("LiveGps: Unexpected JSON in gpsd greeting: " + line);227 Logging.info("LiveGps: Unexpected JSON in gpsd greeting: " + line); 227 228 } catch (JsonException jex) { 228 229 if (line.startsWith("GPSD,")) { 229 230 connected = true; 230 231 JSONProtocol = false; 231 Main.info("LiveGps: Connected to old gpsd protocol version.");232 Logging.info("LiveGps: Connected to old gpsd protocol version."); 232 233 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTED, tr("Connected")); 233 234 } … … 257 258 gpsdSocket = null; 258 259 } catch (Exception e) { 259 Main.warn("LiveGps: Unable to close socket; reconnection may not be possible");260 Logging.warn("LiveGps: Unable to close socket; reconnection may not be possible"); 260 261 } 261 262 } … … 272 273 report = Json.createReader(new StringReader(line)).readObject(); 273 274 } catch (JsonException jex) { 274 Main.warn("LiveGps: line read from gpsd is not a JSON object:" + line);275 Logging.warn("LiveGps: line read from gpsd is not a JSON object:" + line); 275 276 return null; 276 277 } … … 332 333 course = Float.parseFloat(status[8]); 333 334 } catch (NumberFormatException nex) { 334 Main.debug(nex);335 Logging.debug(nex); 335 336 } 336 337 return new LiveGpsData(lat, lon, course, speed); -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
r33078 r33739 6 6 import java.awt.Point; 7 7 8 import org.openstreetmap.josm.Main;9 8 import org.openstreetmap.josm.data.coor.LatLon; 10 9 import org.openstreetmap.josm.data.osm.OsmPrimitive; 11 10 import org.openstreetmap.josm.data.osm.Way; 11 import org.openstreetmap.josm.gui.MainApplication; 12 import org.openstreetmap.josm.gui.MapFrame; 12 13 13 14 /** … … 179 180 */ 180 181 public Way getWay() { 181 if (way == null && Main.map != null && Main.map.mapView != null) { 182 Point xy = Main.map.mapView.getPoint(getLatLon()); 183 way = Main.map.mapView.getNearestWay(xy, OsmPrimitive::isUsable); 182 MapFrame map = MainApplication.getMap(); 183 if (way == null && map != null && map.mapView != null) { 184 Point xy = map.mapView.getPoint(getLatLon()); 185 way = map.mapView.getNearestWay(xy, OsmPrimitive::isUsable); 184 186 } 185 187 return way; -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsDrawHelper.java
r33420 r33739 1 1 // License: Public Domain. For details, see LICENSE file. 2 2 package livegps; 3 4 import static org.openstreetmap.josm.tools.I18n.tr;5 3 6 4 import java.awt.Color; … … 11 9 import org.openstreetmap.josm.data.gpx.WayPoint; 12 10 import org.openstreetmap.josm.data.preferences.CachingProperty; 13 import org.openstreetmap.josm.data.preferences.ColorProperty; 11 import org.openstreetmap.josm.data.preferences.NamedColorProperty; 14 12 import org.openstreetmap.josm.gui.MapView; 15 import org.openstreetmap.josm.gui.layer.GpxLayer;16 13 import org.openstreetmap.josm.gui.layer.MapViewGraphics; 17 14 import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper; … … 24 21 25 22 private static final CachingProperty<Color> COLOR_POSITION = 26 new ColorProperty(C_LIVEGPS_COLOR_POSITION, Color.RED).cached(); 23 new NamedColorProperty(C_LIVEGPS_COLOR_POSITION, Color.RED).cached(); 27 24 private static final CachingProperty<Color> COLOR_POSITION_ESTIMATE = 28 new ColorProperty(C_LIVEGPS_COLOR_POSITION_ESTIMATE, Color.CYAN).cached(); 25 new NamedColorProperty(C_LIVEGPS_COLOR_POSITION_ESTIMATE, Color.CYAN).cached(); 29 26 30 27 private static final String C_CURSOR_H = "livegps.cursor_height"; /* in pixels */ … … 51 48 Point screen = mv.getPoint(lastPoint.getCoor()); 52 49 53 int TriaHeight = Main.pref.getInt eger(C_CURSOR_H, 20);54 int TriaWidth = Main.pref.getInt eger(C_CURSOR_W, 10);55 int TriaThick = Main.pref.getInt eger(C_CURSOR_T, 4);50 int TriaHeight = Main.pref.getInt(C_CURSOR_H, 20); 51 int TriaWidth = Main.pref.getInt(C_CURSOR_W, 10); 52 int TriaThick = Main.pref.getInt(C_CURSOR_T, 4); 56 53 57 54 /* -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java
r33420 r33739 14 14 15 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.data.Bounds;17 16 import org.openstreetmap.josm.data.coor.LatLon; 18 17 import org.openstreetmap.josm.data.gpx.GpxData; 19 18 import org.openstreetmap.josm.data.gpx.GpxTrack; 20 19 import org.openstreetmap.josm.data.gpx.WayPoint; 20 import org.openstreetmap.josm.gui.MainApplication; 21 21 import org.openstreetmap.josm.gui.layer.GpxLayer; 22 22 … … 80 80 public void center() { 81 81 if (lastPoint != null) 82 Main .map.mapView.zoomTo(lastPoint.getCoor());82 MainApplication.getMap().mapView.zoomTo(lastPoint.getCoor()); 83 83 } 84 84 85 85 public void conditionalCenter(LatLon Pos) { 86 Point2D P = Main .map.mapView.getPoint2D(Pos);87 Rectangle rv = Main .map.mapView.getBounds(null);86 Point2D P = MainApplication.getMap().mapView.getPoint2D(Pos); 87 Rectangle rv = MainApplication.getMap().mapView.getBounds(null); 88 88 Date date = new Date(); 89 89 long current = date.getTime(); … … 92 92 93 93 if (!rv.contains(P) || (centerInterval > 0 && current - lastCenter >= centerInterval)) { 94 Main .map.mapView.zoomTo(Pos);94 MainApplication.getMap().mapView.zoomTo(Pos); 95 95 lastCenter = current; 96 96 } … … 111 111 setCurrentPosition(lastData.getLatitude(), lastData.getLongitude()); 112 112 if (allowRedraw()) 113 Main .map.repaint();113 MainApplication.getMap().repaint(); 114 114 } 115 115 } … … 139 139 */ 140 140 private void initIntervals() { 141 if ((refreshInterval = Main.pref.getInt eger(oldC_REFRESH_INTERVAL, 0)) != 0) {141 if ((refreshInterval = Main.pref.getInt(oldC_REFRESH_INTERVAL, 0)) != 0) { 142 142 refreshInterval *= 1000; 143 143 Main.pref.put(oldC_REFRESH_INTERVAL, null); 144 144 } else 145 refreshInterval = Main.pref.getInt eger(C_REFRESH_INTERVAL, DEFAULT_REFRESH_INTERVAL);145 refreshInterval = Main.pref.getInt(C_REFRESH_INTERVAL, DEFAULT_REFRESH_INTERVAL); 146 146 147 centerInterval = Main.pref.getInt eger(C_CENTER_INTERVAL, DEFAULT_CENTER_INTERVAL);148 centerFactor = Main.pref.getInt eger(C_CENTER_FACTOR, DEFAULT_CENTER_FACTOR);147 centerInterval = Main.pref.getInt(C_CENTER_INTERVAL, DEFAULT_CENTER_INTERVAL); 148 centerFactor = Main.pref.getInt(C_CENTER_FACTOR, DEFAULT_CENTER_FACTOR); 149 149 if (centerFactor <= 1 || centerFactor >= 99) 150 150 centerFactor = DEFAULT_CENTER_FACTOR; 151 151 152 Main.pref.putInt eger(C_REFRESH_INTERVAL, refreshInterval);153 Main.pref.putInt eger(C_CENTER_INTERVAL, centerInterval);154 Main.pref.putInt eger(C_CENTER_FACTOR, (int) centerFactor);152 Main.pref.putInt(C_REFRESH_INTERVAL, refreshInterval); 153 Main.pref.putInt(C_CENTER_INTERVAL, centerInterval); 154 Main.pref.putInt(C_CENTER_FACTOR, (int) centerFactor); 155 155 156 156 /* -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsPlugin.java
r33078 r33739 13 13 import javax.swing.JMenu; 14 14 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.actions.JosmAction; 17 16 import org.openstreetmap.josm.data.gpx.GpxData; 17 import org.openstreetmap.josm.gui.MainApplication; 18 18 import org.openstreetmap.josm.gui.MainMenu; 19 19 import org.openstreetmap.josm.gui.MapFrame; … … 110 110 enableTracking(false); 111 111 lgpscapture.setSelected(false); 112 Main.getLayerManager().removeLayerChangeListener(this); 112 MainApplication.getLayerManager().removeLayerChangeListener(this); 113 113 lgpslayer = null; 114 114 } … … 116 116 public LiveGpsPlugin(PluginInformation info) { 117 117 super(info); 118 MainMenu menu = Main .main.menu;118 MainMenu menu = MainApplication.getMenu(); 119 119 lgpsmenu = menu.gpsMenu; 120 120 if (lgpsmenu.getItemCount() > 0) { … … 173 173 if (lgpslayer == null) { 174 174 lgpslayer = new LiveGpsLayer(data); 175 Main.getLayerManager().addLayer(lgpslayer); 176 Main.getLayerManager().addLayerChangeListener(this); 175 MainApplication.getLayerManager().addLayer(lgpslayer); 176 MainApplication.getLayerManager().addLayerChangeListener(this); 177 177 lgpslayer.setAutoCenter(isAutoCenter()); 178 178 }
Note:
See TracChangeset
for help on using the changeset viewer.