Changeset 33788 in osm for applications/editors/josm/plugins/NanoLog/src
- Timestamp:
- 2017-11-05T20:04:04+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/NanoLog/src/nanolog
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/NanoLog/src/nanolog/Correlator.java
r32638 r33788 16 16 import org.openstreetmap.josm.data.gpx.GpxTrackSegment; 17 17 import org.openstreetmap.josm.data.gpx.WayPoint; 18 import org.openstreetmap.josm.tools.Logging; 18 19 import org.openstreetmap.josm.tools.UncheckedParseException; 19 20 import org.openstreetmap.josm.tools.date.DateUtils; … … 52 53 break outer; 53 54 } catch (Exception e) { 54 Main.warn(e);55 Logging.warn(e); 55 56 } 56 57 } … … 99 100 100 101 } catch (UncheckedParseException e) { 101 Main.error("Error while parsing date \"" + curWpTimeStr + '"');102 Main.error(e);102 Logging.error("Error while parsing date \"" + curWpTimeStr + '"'); 103 Logging.error(e); 103 104 prevWp = null; 104 105 prevWpTime = 0; … … 247 248 prevWpTime = curWpTime; 248 249 } catch (UncheckedParseException e) { 249 Main.error("Error while parsing date \"" + curWpTimeStr + '"');250 Main.error(e);250 Logging.error("Error while parsing date \"" + curWpTimeStr + '"'); 251 Logging.error(e); 251 252 prevWp = null; 252 253 prevWpTime = 0; -
applications/editors/josm/plugins/NanoLog/src/nanolog/GPXChooser.java
r32638 r33788 3 3 import javax.swing.JDialog; 4 4 5 import org.openstreetmap.josm. Main;5 import org.openstreetmap.josm.gui.MainApplication; 6 6 import org.openstreetmap.josm.gui.layer.GpxLayer; 7 7 import org.openstreetmap.josm.gui.layer.Layer; … … 20 20 public static GpxLayer topLayer() { 21 21 // return first found local layer 22 for (Layer layer : Main .getLayerManager().getLayers()) {22 for (Layer layer : MainApplication.getLayerManager().getLayers()) { 23 23 if (layer instanceof GpxLayer && ((GpxLayer) layer).isLocalFile()) 24 24 return (GpxLayer) layer; -
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 = new Integer(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() { -
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPanel.java
r32638 r33788 11 11 import javax.swing.JList; 12 12 13 import org.openstreetmap.josm. Main;13 import org.openstreetmap.josm.gui.MainApplication; 14 14 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 15 15 import org.openstreetmap.josm.gui.layer.Layer; … … 40 40 public void updateMarkers() { 41 41 List<NanoLogEntry> entries = new ArrayList<>(); 42 for (NanoLogLayer l : Main .getLayerManager().getLayersOfType(NanoLogLayer.class)) {42 for (NanoLogLayer l : MainApplication.getLayerManager().getLayersOfType(NanoLogLayer.class)) { 43 43 entries.addAll(l.getEntries()); 44 44 } … … 78 78 } 79 79 80 private class LogListModel extends AbstractListModel<String> {80 private static class LogListModel extends AbstractListModel<String> { 81 81 private List<NanoLogEntry> entries; 82 82 private final SimpleDateFormat TIME_FORMAT = new SimpleDateFormat("HH:mm:ss"); -
applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogPlugin.java
r32638 r33788 12 12 import org.openstreetmap.josm.Main; 13 13 import org.openstreetmap.josm.actions.JosmAction; 14 import org.openstreetmap.josm.gui.MainApplication; 14 15 import org.openstreetmap.josm.gui.MapFrame; 15 16 import org.openstreetmap.josm.plugins.Plugin; … … 24 25 public NanoLogPlugin(PluginInformation info) { 25 26 super(info); 26 Main .main.menu.fileMenu.insert(new OpenNanoLogLayerAction(), 4);27 MainApplication.getMenu().fileMenu.insert(new OpenNanoLogLayerAction(), 4); 27 28 } 28 29 … … 32 33 NanoLogPanel panel = new NanoLogPanel(); 33 34 newFrame.addToggleDialog(panel); 34 Main .getLayerManager().addLayerChangeListener(panel);35 MainApplication.getLayerManager().addLayerChangeListener(panel); 35 36 } 36 37 } 37 38 38 private class OpenNanoLogLayerAction extends JosmAction {39 private static class OpenNanoLogLayerAction extends JosmAction { 39 40 40 41 OpenNanoLogLayerAction() { … … 50 51 if (!entries.isEmpty()) { 51 52 NanoLogLayer layer = new NanoLogLayer(entries); 52 Main .getLayerManager().addLayer(layer);53 MainApplication.getLayerManager().addLayer(layer); 53 54 layer.setupListeners(); 54 55 }
Note:
See TracChangeset
for help on using the changeset viewer.