Ignore:
Timestamp:
2017-11-05T20:04:04+01:00 (9 years ago)
Author:
donvip
Message:

update to JOSM 12643

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/NanoLog/src/nanolog/NanoLogLayer.java

    r32638 r33788  
    3737import org.openstreetmap.josm.data.gpx.WayPoint;
    3838import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     39import org.openstreetmap.josm.gui.MainApplication;
    3940import org.openstreetmap.josm.gui.MapView;
    4041import org.openstreetmap.josm.gui.dialogs.LayerListDialog;
     
    4445import org.openstreetmap.josm.gui.layer.Layer;
    4546import org.openstreetmap.josm.tools.ImageProvider;
     47import org.openstreetmap.josm.tools.Logging;
    4648
    4749/**
     
    6567
    6668    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);
    7577        super.destroy();
    7678    }
     
    123125                            timeDate = fmt.parse(time);
    124126                        } catch (ParseException e) {
    125                             Main.warn(e);
     127                            Logging.warn(e);
    126128                        }
    127129                        if (message == null || message.length() == 0 || timeDate == null)
     
    132134                            try {
    133135                                pos = new LatLon(Double.parseDouble(lat), Double.parseDouble(lon));
    134                                 direction = new Integer(dir);
     136                                direction = Integer.valueOf(dir);
    135137                            } catch (NumberFormatException e) {
    136                                 Main.trace(e);
     138                                Logging.trace(e);
    137139                            }
    138140                        }
    139                         NanoLogEntry entry = new NanoLogEntry(timeDate, message, pos, direction);
    140                         result.add(entry);
     141                        result.add(new NanoLogEntry(timeDate, message, pos, direction));
    141142                    }
    142143                }
     
    221222        else if (selectedEntry >= log.size())
    222223            selectedEntry = log.size() - 1;
    223         Main.map.repaint();
     224        invalidate();
    224225    }
    225226
     
    231232        else if (selectedEntry >= log.size())
    232233            selectedEntry = log.size() - 1;
    233         Main.map.repaint();
     234        invalidate();
    234235    }
    235236
     
    237238        int newSelected = i >= 0 && i < log.size() ? i : -1;
    238239        if (newSelected != selectedEntry) {
    239 //            System.out.println("selected: " + log.get(newSelected).getMessage());
    240240            selectedEntry = newSelected;
    241241            fireMarkerSelected();
    242             Main.map.mapView.repaint();
     242            invalidate();
    243243        }
    244244    }
     
    261261
    262262        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());
    264264            int radius = 8;
    265265            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);
    267267                double distance = Math.max(lld.lat() - ll.lat(), lld.lon() - ll.lon());
    268268                boolean selectedIsSelected = false;
     
    303303        public void mousePressed(MouseEvent e) {
    304304            int nearest = nearestEntry(e);
    305             if (nearest > 0 && Main.getLayerManager().getActiveLayer() == NanoLogLayer.this) {
     305            if (nearest > 0 && MainApplication.getLayerManager().getActiveLayer() == NanoLogLayer.this) {
    306306                dragging = nearest;
    307307                doDrag(e);
     
    319319        if (gpx == null)
    320320            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));
    323323        WayPoint wp = gpx.data.nearestPointOnTrack(eastNorth, tolerance);
    324324        if (wp == null)
     
    329329        Correlator.revertPos(log);
    330330        Correlator.correlate(log, gpx.data, log.get(entry).getTime().getTime() - newTime);
    331         Main.map.mapView.repaint();
     331        MainApplication.getMap().mapView.repaint();
    332332    }
    333333
     
    353353                Correlator.correlate(log, layer.data, offset);
    354354                fireMarkersChanged();
    355                 Main.map.mapView.repaint();
     355                MainApplication.getMap().mapView.repaint();
    356356            }
    357357            // 3. Show non-modal (?) window with a slider and a text input
     
    360360    }
    361361
    362     private class SaveLayer extends JosmAction {
     362    private static class SaveLayer extends JosmAction {
    363363
    364364        SaveLayer() {
Note: See TracChangeset for help on using the changeset viewer.