Changeset 33045 in osm for applications/editors/josm/plugins/livegps
- Timestamp:
- 2016-10-30T00:14:07+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/livegps
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/src/livegps/AppendableGpxTrackSegment.java
r30737 r33045 1 // License: Public Domain. For details, see LICENSE file. 1 2 package livegps; 2 3 -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsAcquirer.java
r32952 r33045 1 // License: Public Domain. For details, see LICENSE file. 1 2 package livegps; 2 3 … … 132 133 Thread.sleep(1000); 133 134 } catch (InterruptedException ignore) { 134 135 135 136 } 136 137 } … … 161 162 oldGpsData = gpsData; 162 163 } catch (IOException iox) { 163 Main.warn("LiveGps: lost connection to gpsd"); 164 Main.warn(iox, "LiveGps: lost connection to gpsd"); 164 165 fireGpsStatusChangeEvent( 165 166 LiveGpsStatus.GpsStatus.CONNECTION_FAILED, … … 168 169 try { 169 170 Thread.sleep(1000); 170 } catch (InterruptedException ignore) {} 171 } catch (InterruptedException ignore) { 172 Main.trace(ignore); 173 } 171 174 // send warning to layer 172 175 } … … 246 249 247 250 private void disconnect() { 248 assert (gpsdSocket != null);251 assert gpsdSocket != null; 249 252 250 253 connected = false; … … 324 327 speed = Float.parseFloat(status[9]); 325 328 course = Float.parseFloat(status[8]); 326 } catch (NumberFormatException nex) {} 329 } catch (NumberFormatException nex) { 330 Main.debug(nex); 331 } 327 332 return new LiveGpsData(lat, lon, course, speed); 328 333 } -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsData.java
r32952 r33045 1 /** 2 * 3 */ 1 // License: Public Domain. For details, see LICENSE file. 4 2 package livegps; 5 3 … … 151 149 */ 152 150 public String getWayInfo() { 153 if(wayString == null) { 151 if (wayString == null) { 154 152 Way way = getWay(); 155 if(way != null) { 153 if (way != null) { 156 154 StringBuilder builder = new StringBuilder(); 157 155 String tmp = way.get("name"); 158 if(tmp != null) { 156 if (tmp != null) { 159 157 builder.append(tmp); 160 158 } else { … … 162 160 } 163 161 tmp = way.get("ref"); 164 if(tmp != null) { 162 if (tmp != null) { 165 163 builder.append(" (").append(tmp).append(")"); 166 164 } 167 165 tmp = way.get("highway"); 168 if(tmp != null) { 166 if (tmp != null) { 169 167 builder.append(" {").append(tmp).append("}"); 170 168 } 171 169 String type = ""; 172 170 tmp = way.get("tunnel"); 173 if(tmp != null) { 171 if (tmp != null) { 174 172 type = type + "T"; 175 173 } 176 174 tmp = way.get("bridge"); 177 if(tmp != null) { 175 if (tmp != null) { 178 176 type = type + "B"; 179 177 } 180 if(type.length() > 0) { 178 if (type.length() > 0) { 181 179 builder.append(" [").append(type).append("]"); 182 180 } … … 194 192 */ 195 193 public Way getWay() { 196 if(way == null && Main.map != null && Main.map.mapView != null) { 194 if (way == null && Main.map != null && Main.map.mapView != null) { 197 195 Point xy = Main.map.mapView.getPoint(getLatLon()); 198 196 way = Main.map.mapView.getNearestWay(xy, OsmPrimitive::isUsable); -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsDialog.java
r32952 r33045 1 /** 2 * 3 */ 1 // License: Public Domain. For details, see LICENSE file. 4 2 package livegps; 5 3 … … 69 67 return; 70 68 71 if("gpsdata".equals(evt.getPropertyName())) { 69 if ("gpsdata".equals(evt.getPropertyName())) { 72 70 data = (LiveGpsData) evt.getNewValue(); 73 71 … … 75 73 @Override 76 74 public void run() { 77 if(data.isFix()) { 75 if (data.isFix()) { 78 76 panel.setBackground(Color.WHITE); 79 77 latLabel.setText(data.getLatitude() + "deg"); … … 84 82 85 83 String wayString = data.getWayInfo(); 86 if (wayString.length() > 0) {84 if (!wayString.isEmpty()) { 87 85 wayLabel.setText(wayString); 88 86 } else { … … 104 102 public void run() { 105 103 statusLabel.setText(status.getStatusMessage()); 106 if(status.getStatus() != LiveGpsStatus.GpsStatus.CONNECTED) { 104 if (status.getStatus() != LiveGpsStatus.GpsStatus.CONNECTED) { 107 105 panel.setBackground(Color.RED); 108 106 } else { -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsLayer.java
r32952 r33045 1 // License: Public Domain. For details, see LICENSE file. 1 2 package livegps; 2 3 … … 6 7 import java.awt.Graphics2D; 7 8 import java.awt.Point; 9 import java.awt.Rectangle; 8 10 import java.awt.geom.Point2D; 9 import java.awt.Rectangle;10 11 import java.beans.PropertyChangeEvent; 11 12 import java.beans.PropertyChangeListener; … … 115 116 if (lastPoint == null) 116 117 return; 117 118 118 119 Point screen = mv.getPoint(lastPoint.getCoor()); 119 120 120 121 int TriaHeight = Main.pref.getInteger(C_CURSOR_H, 20); 121 122 int TriaWidth = Main.pref.getInteger(C_CURSOR_W, 10); 122 123 int TriaThick = Main.pref.getInteger(C_CURSOR_T, 4); 123 124 124 125 /* 125 126 * Draw a bold triangle. 126 127 * In case of deep zoom draw also a thin DOP oval. 127 128 */ 128 129 129 130 g.setColor(COLOR_POSITION_ESTIMATE.get()); 130 131 int w, h; 131 132 double ppm = 100 / mv.getDist100Pixel(); /* pixels per metre */ 132 133 133 134 w = (int )Math.round(lastData.getEpx() * ppm); 134 135 h = (int )Math.round(lastData.getEpy() * ppm); 135 136 136 137 if (w > TriaWidth || h > TriaWidth) { 137 138 int xo, yo; 138 139 139 140 yo = screen.y - Math.round(h/2); 140 141 xo = screen.x - Math.round(w/2); 141 142 142 143 g.drawOval(xo, yo, w, h); 143 144 } 144 145 145 146 int[] x = new int[4]; 146 147 int[] y = new int[4]; … … 152 153 float csin240 = (float )Math.sin(Math.toRadians(course + 240)); 153 154 float ccos240 = (float )Math.cos(Math.toRadians(course + 240)); 154 155 155 156 g.setColor(COLOR_POSITION.get()); 156 157 157 158 for (int i = 0; i < TriaThick; i++, TriaHeight--, TriaWidth--) { 158 159 159 160 x[0] = screen.x + Math.round(TriaHeight * csin); 160 161 y[0] = screen.y - Math.round(TriaHeight * ccos); … … 165 166 x[3] = screen.x + Math.round(TriaWidth * csin240); 166 167 y[3] = screen.y - Math.round(TriaWidth * ccos240); 167 168 168 169 g.drawPolygon(x, y, 4); 169 170 } -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsPlugin.java
r32470 r33045 1 // License: Public Domain. For details, see LICENSE file. 1 2 package livegps; 2 3 … … 117 118 MainMenu menu = Main.main.menu; 118 119 lgpsmenu = menu.gpsMenu; 119 if (lgpsmenu.getItemCount() >0) {120 if (lgpsmenu.getItemCount() > 0) { 120 121 lgpsmenu.addSeparator(); 121 122 } 122 123 123 124 JosmAction captureAction = new CaptureAction(); 124 125 lgpscapture = new JCheckBoxMenuItem(captureAction); 125 126 lgpsmenu.add(lgpscapture); 126 127 lgpscapture.setAccelerator(captureAction.getShortcut().getKeyStroke()); 127 128 128 129 JosmAction centerAction = new CenterAction(); 129 130 MainMenu.add(lgpsmenu, centerAction); 130 131 131 132 JosmAction autoCenterAction = new AutoCenterAction(); 132 133 lgpsautocenter = new JCheckBoxMenuItem(autoCenterAction); … … 162 163 */ 163 164 public void enableTracking(boolean enable) { 164 165 165 166 if (enable && !enabled) { 166 167 assert (acquirer == null); … … 199 200 } 200 201 201 /** 202 * Add a listener for gps events. 203 * @param listener the listener. 204 */ 205 public void addPropertyChangeListener(PropertyChangeListener listener) { 206 assert (!listenerQueue.contains(listener));207 208 listenerQueue.add(listener); 202 /** 203 * Add a listener for gps events. 204 * @param listener the listener. 205 */ 206 public void addPropertyChangeListener(PropertyChangeListener listener) { 207 assert !listenerQueue.contains(listener); 208 209 listenerQueue.add(listener); 209 210 if (acquirer != null) 210 acquirer.addPropertyChangeListener(listener); 211 } 212 213 /** 214 * Remove a listener for gps events. 215 * @param listener the listener. 216 */ 217 public void removePropertyChangeListener(PropertyChangeListener listener) { 218 assert (listenerQueue.contains(listener));219 220 listenerQueue.remove(listener); 221 if (acquirer != null) 222 acquirer.removePropertyChangeListener(listener); 211 acquirer.addPropertyChangeListener(listener); 212 } 213 214 /** 215 * Remove a listener for gps events. 216 * @param listener the listener. 217 */ 218 public void removePropertyChangeListener(PropertyChangeListener listener) { 219 assert listenerQueue.contains(listener); 220 221 listenerQueue.remove(listener); 222 if (acquirer != null) 223 acquirer.removePropertyChangeListener(listener); 223 224 } 224 225 -
applications/editors/josm/plugins/livegps/src/livegps/LiveGpsStatus.java
r14057 r33045 1 /** 2 * 3 */ 1 // License: Public Domain. For details, see LICENSE file. 4 2 package livegps; 5 3 -
applications/editors/josm/plugins/livegps/src/livegps/SingleSegmentGpxTrack.java
r33009 r33045 1 // License: Public Domain. For details, see LICENSE file. 1 2 package livegps; 2 3
Note:
See TracChangeset
for help on using the changeset viewer.