Changeset 33788 in osm for applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogLayer.java
- Timestamp:
- 2017-11-05T20:04:04+01:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogLayer.java
r32638 r33788 37 37 import org.openstreetmap.josm.data.gpx.WayPoint; 38 38 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 39 import org.openstreetmap.josm.gui.MainApplication; 39 40 import org.openstreetmap.josm.gui.MapView; 40 41 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; … … 44 45 import org.openstreetmap.josm.gui.layer.Layer; 45 46 import org.openstreetmap.josm.tools.ImageProvider; 47 import org.openstreetmap.josm.tools.Logging; 46 48 47 49 /** … … 65 67 66 68 public void setupListeners() { 67 Main .map.mapView.addMouseListener(mouseListener);68 Main .map.mapView.addMouseMotionListener(mouseListener);69 } 70 71 @Override 72 public void destroy() { 73 Main .map.mapView.removeMouseListener(mouseListener);74 Main .map.mapView.removeMouseMotionListener(mouseListener);69 MainApplication.getMap().mapView.addMouseListener(mouseListener); 70 MainApplication.getMap().mapView.addMouseMotionListener(mouseListener); 71 } 72 73 @Override 74 public synchronized void destroy() { 75 MainApplication.getMap().mapView.removeMouseListener(mouseListener); 76 MainApplication.getMap().mapView.removeMouseMotionListener(mouseListener); 75 77 super.destroy(); 76 78 } … … 123 125 timeDate = fmt.parse(time); 124 126 } catch (ParseException e) { 125 Main.warn(e);127 Logging.warn(e); 126 128 } 127 129 if (message == null || message.length() == 0 || timeDate == null) … … 132 134 try { 133 135 pos = new LatLon(Double.parseDouble(lat), Double.parseDouble(lon)); 134 direction = newInteger(dir);136 direction = Integer.valueOf(dir); 135 137 } catch (NumberFormatException e) { 136 Main.trace(e);138 Logging.trace(e); 137 139 } 138 140 } 139 NanoLogEntry entry = new NanoLogEntry(timeDate, message, pos, direction); 140 result.add(entry); 141 result.add(new NanoLogEntry(timeDate, message, pos, direction)); 141 142 } 142 143 } … … 221 222 else if (selectedEntry >= log.size()) 222 223 selectedEntry = log.size() - 1; 223 Main.map.repaint();224 invalidate(); 224 225 } 225 226 … … 231 232 else if (selectedEntry >= log.size()) 232 233 selectedEntry = log.size() - 1; 233 Main.map.repaint();234 invalidate(); 234 235 } 235 236 … … 237 238 int newSelected = i >= 0 && i < log.size() ? i : -1; 238 239 if (newSelected != selectedEntry) { 239 // System.out.println("selected: " + log.get(newSelected).getMessage());240 240 selectedEntry = newSelected; 241 241 fireMarkerSelected(); 242 Main.map.mapView.repaint();242 invalidate(); 243 243 } 244 244 } … … 261 261 262 262 public int nearestEntry(MouseEvent e) { 263 LatLon ll = Main .map.mapView.getLatLon(e.getX(), e.getY());263 LatLon ll = MainApplication.getMap().mapView.getLatLon(e.getX(), e.getY()); 264 264 int radius = 8; 265 265 if (ll != null) { 266 LatLon lld = Main .map.mapView.getLatLon(e.getX() + radius, e.getY() + radius);266 LatLon lld = MainApplication.getMap().mapView.getLatLon(e.getX() + radius, e.getY() + radius); 267 267 double distance = Math.max(lld.lat() - ll.lat(), lld.lon() - ll.lon()); 268 268 boolean selectedIsSelected = false; … … 303 303 public void mousePressed(MouseEvent e) { 304 304 int nearest = nearestEntry(e); 305 if (nearest > 0 && Main.getLayerManager().getActiveLayer() == NanoLogLayer.this) { 305 if (nearest > 0 && MainApplication.getLayerManager().getActiveLayer() == NanoLogLayer.this) { 306 306 dragging = nearest; 307 307 doDrag(e); … … 319 319 if (gpx == null) 320 320 return; 321 EastNorth eastNorth = Main .map.mapView.getEastNorth(x, y);322 double tolerance = eastNorth.distance(Main .map.mapView.getEastNorth(x + 300, y));321 EastNorth eastNorth = MainApplication.getMap().mapView.getEastNorth(x, y); 322 double tolerance = eastNorth.distance(MainApplication.getMap().mapView.getEastNorth(x + 300, y)); 323 323 WayPoint wp = gpx.data.nearestPointOnTrack(eastNorth, tolerance); 324 324 if (wp == null) … … 329 329 Correlator.revertPos(log); 330 330 Correlator.correlate(log, gpx.data, log.get(entry).getTime().getTime() - newTime); 331 Main .map.mapView.repaint();331 MainApplication.getMap().mapView.repaint(); 332 332 } 333 333 … … 353 353 Correlator.correlate(log, layer.data, offset); 354 354 fireMarkersChanged(); 355 Main .map.mapView.repaint();355 MainApplication.getMap().mapView.repaint(); 356 356 } 357 357 // 3. Show non-modal (?) window with a slider and a text input … … 360 360 } 361 361 362 private class SaveLayer extends JosmAction { 362 private static class SaveLayer extends JosmAction { 363 363 364 364 SaveLayer() {
Note:
See TracChangeset
for help on using the changeset viewer.
