Changeset 33776 in osm


Ignore:
Timestamp:
2017-11-05T19:16:18+01:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 12636

Location:
applications/editors/josm/plugins/gpsblam
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/gpsblam/build.xml

    r33257 r33776  
    55    <property name="commit.message" value="Commit message"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="11713"/>
     7    <property name="plugin.main.version" value="12636"/>
    88
    99    <!--
  • applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamInputData.java

    r32329 r33776  
    1414import org.openstreetmap.josm.data.gpx.GpxTrackSegment;
    1515import org.openstreetmap.josm.data.gpx.WayPoint;
     16import org.openstreetmap.josm.data.projection.Projection;
     17import org.openstreetmap.josm.gui.MainApplication;
    1618import org.openstreetmap.josm.gui.layer.GpxLayer;
    1719import org.openstreetmap.josm.gui.layer.Layer;
     
    2729    // within given radius of line between given points
    2830    GPSBlamInputData(Point p1, Point p2, int radius) {
    29         Collection<Layer> layers = Main.getLayerManager().getLayers();
     31        Collection<Layer> layers = MainApplication.getLayerManager().getLayers();
     32        Projection projection = Main.getProjection();
    3033        for (Layer l : layers) {
    3134            if (l.isVisible() && l instanceof GpxLayer) {
     
    3336                    for (GpxTrackSegment segment: track.getSegments()) {
    3437                        for (WayPoint wayPoint : segment.getWayPoints()) {
    35 
    3638                            if (p2.equals(p1)) {
    3739                                // circular selection
    3840                                CachedLatLon cll = new CachedLatLon(wayPoint.getCoor());
    39                                 Point p = Main.map.mapView.getPoint(cll.getEastNorth());
     41                                Point p = MainApplication.getMap().mapView.getPoint(cll.getEastNorth(projection));
    4042                                if (p.distance(p1) < radius) {
    4143                                    this.add(cll, wayPoint);
     
    5153
    5254                                CachedLatLon cll = new CachedLatLon(wayPoint.getCoor());
    53                                 Point p = Main.map.mapView.getPoint(cll.getEastNorth());
     55                                Point p = MainApplication.getMap().mapView.getPoint(cll.getEastNorth(projection));
    5456                                double pX = p.x-p1.x, pY=p.y-p1.y; // vector from point clicked to waypoint
    5557                                double pPar = pX*dirX + pY*dirY; // parallel component
  • applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamMarker.java

    r30761 r33776  
    2525    /** construct a blammarker by analysis of selected GPS points */
    2626    GPSBlamMarker(GPSBlamInputData inputData) {
     27        Projection projection = Main.getProjection();
    2728        // get mean east, north
    2829        double meanEast=0.0, meanNorth=0.0;
    2930        for (CachedLatLon cll : inputData) {
    30             EastNorth en = cll.getEastNorth();
     31            EastNorth en = cll.getEastNorth(projection);
    3132            meanEast += en.east();
    3233            meanNorth += en.north();
     
    4041        double deast, dnorth;
    4142        for (CachedLatLon cll : inputData) {
    42             EastNorth en = cll.getEastNorth();
     43            EastNorth en = cll.getEastNorth(projection);
    4344            deast = en.east()-meanEast;
    4445            dnorth = en.north()-meanNorth;
     
    8788
    8889    void paint(Graphics2D g, MapView mv) {
     90        Projection projection = Main.getProjection();
    8991        g.setColor(Color.GREEN);
    9092        g.setPaintMode();
    9193        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    9294        g.setStroke(new BasicStroke(2.0f));
    93         Point hair1Point1 = mv.getPoint(hair1Coord1.getEastNorth());
    94         Point hair1Point2 = mv.getPoint(hair1Coord2.getEastNorth());
    95         Point hair2Point1 = mv.getPoint(hair2Coord1.getEastNorth());
    96         Point hair2Point2 = mv.getPoint(hair2Coord2.getEastNorth());
     95        Point hair1Point1 = mv.getPoint(hair1Coord1.getEastNorth(projection));
     96        Point hair1Point2 = mv.getPoint(hair1Coord2.getEastNorth(projection));
     97        Point hair2Point1 = mv.getPoint(hair2Coord1.getEastNorth(projection));
     98        Point hair2Point2 = mv.getPoint(hair2Coord2.getEastNorth(projection));
    9799        g.drawLine(hair1Point1.x, hair1Point1.y, hair1Point2.x, hair1Point2.y);
    98100        g.drawLine(hair2Point1.x, hair2Point1.y, hair2Point2.x, hair2Point2.y);
    99101
    100         Point2D meanPoint = mv.getPoint2D(mean.getEastNorth());
    101         Point2D ellipsePoint1 = mv.getPoint2D(ellipseCoord1.getEastNorth());
    102         Point2D ellipsePoint2 = mv.getPoint2D(ellipseCoord2.getEastNorth());
    103         Point2D ellipsePoint3 = mv.getPoint2D(ellipseCoord3.getEastNorth());
     102        Point2D meanPoint = mv.getPoint2D(mean.getEastNorth(projection));
     103        Point2D ellipsePoint1 = mv.getPoint2D(ellipseCoord1.getEastNorth(projection));
     104        Point2D ellipsePoint2 = mv.getPoint2D(ellipseCoord2.getEastNorth(projection));
     105        Point2D ellipsePoint3 = mv.getPoint2D(ellipseCoord3.getEastNorth(projection));
    104106        double majorAxis = ellipsePoint2.distance(ellipsePoint1);
    105107        double minorAxis = ellipsePoint3.distance(ellipsePoint1);
  • applications/editors/josm/plugins/gpsblam/src/org/openstreetmap/josm/plugins/gpsblam/GPSBlamMode.java

    r33258 r33776  
    2222import java.awt.geom.Path2D;
    2323
    24 import org.openstreetmap.josm.Main;
    2524import org.openstreetmap.josm.actions.mapmode.MapMode;
     25import org.openstreetmap.josm.gui.MainApplication;
     26import org.openstreetmap.josm.gui.MapView;
    2627import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
    2728import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
    2829import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
    2930import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     31import org.openstreetmap.josm.tools.Logging;
    3032
    3133class GPSBlamMode extends MapMode implements LayerChangeListener, MouseWheelListener, AWTEventListener {
     
    4547    public void enterMode() {
    4648        super.enterMode();
    47         Main.map.mapView.addMouseListener(this);
    48         Main.map.mapView.addMouseMotionListener(this);
    49         Main.map.mapView.addMouseWheelListener(this);
     49        MapView mapView = MainApplication.getMap().mapView;
     50        mapView.addMouseListener(this);
     51        mapView.addMouseMotionListener(this);
     52        mapView.addMouseWheelListener(this);
    5053        try {
    5154            Toolkit.getDefaultToolkit().addAWTEventListener(this, AWTEvent.KEY_EVENT_MASK);
    5255        } catch (SecurityException ex) {
    53             Main.error(ex);
     56            Logging.error(ex);
    5457        }
    5558
     
    7275        super.exitMode();
    7376        getLayerManager().removeLayerChangeListener(this);
    74         Main.map.mapView.removeMouseListener(this);
    75         Main.map.mapView.removeMouseMotionListener(this);
    76         Main.map.mapView.removeMouseWheelListener(this);
     77        MainApplication.getMap().mapView.removeMouseListener(this);
     78        MainApplication.getMap().mapView.removeMouseMotionListener(this);
     79        MainApplication.getMap().mapView.removeMouseWheelListener(this);
    7780        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
    7881    }
     
    8386            pointPressed = new Point(e.getPoint());
    8487            // gain exclusive use of mouse wheel for now
    85             mapViewWheelListeners = Main.map.mapView.getMouseWheelListeners();
     88            mapViewWheelListeners = MainApplication.getMap().mapView.getMouseWheelListeners();
    8689            for (MouseWheelListener l : mapViewWheelListeners) {
    8790                if (l != this)
    88                     Main.map.mapView.removeMouseWheelListener(l);
     91                    MainApplication.getMap().mapView.removeMouseWheelListener(l);
    8992            }
    9093            paintBox(pointPressed, radius);
     
    108111        for (MouseWheelListener l : mapViewWheelListeners) {
    109112            if (l != this)
    110                 Main.map.mapView.addMouseWheelListener(l);
     113                MainApplication.getMap().mapView.addMouseWheelListener(l);
    111114        }
    112115
     
    120123            }
    121124            currentBlamLayer.addBlamMarker(new GPSBlamMarker(inputData));
    122             Main.map.mapView.repaint();
     125            MainApplication.getMap().mapView.repaint();
    123126        }
    124127
     
    144147
    145148    private void xorDrawBox(Point p1, Point p2, int radius){
    146         if (Main.map != null) {
    147             Graphics2D g = (Graphics2D) Main.map.mapView.getGraphics();
     149        if (MainApplication.getMap() != null) {
     150            Graphics2D g = (Graphics2D) MainApplication.getMap().mapView.getGraphics();
    148151            g.setXORMode(Color.BLACK);
    149152            g.setColor(Color.WHITE);
     
    177180                } catch (InternalError e) {
    178181                    // Robustness against Java bug https://bugs.openjdk.java.net/browse/JDK-8041647
    179                     Main.error(e);
    180                     Main.error("Java bug JDK-8041647 occured. To avoid this bug, please consult https://bugs.openjdk.java.net/browse/JDK-8041647."
     182                    Logging.error(e);
     183                    Logging.error("Java bug JDK-8041647 occured. To avoid this bug, please consult https://bugs.openjdk.java.net/browse/JDK-8041647."
    181184                            +" If the bug is fixed, please update your Java Runtime Environment.");
    182185                }
     
    186189
    187190    private void paintBox(Point p2, int newRadius) {
    188         if (Main.map != null) {
     191        if (MainApplication.getMap() != null) {
    189192            if (oldP2 != null) {
    190193                xorDrawBox(pointPressed, oldP2, radius); // clear old box
     
    209212        if (e.getRemovedLayer() instanceof GPSBlamLayer) {
    210213            currentBlamLayer = null;
    211             if (Main.map.mapMode instanceof GPSBlamMode)
    212                 Main.map.selectSelectTool(false);
     214            if (MainApplication.getMap().mapMode instanceof GPSBlamMode)
     215                MainApplication.getMap().selectSelectTool(false);
    213216        }
    214217    }
Note: See TracChangeset for help on using the changeset viewer.