Changeset 32462 in osm for applications/editors/josm


Ignore:
Timestamp:
2016-06-30T03:08:25+02:00 (8 years ago)
Author:
donvip
Message:

remove calls to deprecated methods

Location:
applications/editors/josm/plugins/imagery_offset_db
Files:
1 added
4 edited

Legend:

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

    r32329 r32462  
    55    <property name="commit.message" value="Imagery Offset Database"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10279"/>
     7    <property name="plugin.main.version" value="10353"/>
    88        <property name="plugin.canloadatruntime" value="true"/>
    99
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/ImageryOffsetWatcher.java

    r30737 r32462  
    11package iodb;
    22
    3 import java.util.*;
     3import java.util.ArrayList;
     4import java.util.Collection;
     5import java.util.Iterator;
     6import java.util.LinkedList;
     7import java.util.List;
     8import java.util.Map;
     9import java.util.Timer;
     10import java.util.TimerTask;
     11import java.util.TreeMap;
     12
    413import org.openstreetmap.josm.Main;
    514import org.openstreetmap.josm.data.coor.LatLon;
    615import org.openstreetmap.josm.gui.MapView;
     16import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    717import org.openstreetmap.josm.gui.layer.ImageryLayer;
    818import org.openstreetmap.josm.gui.layer.Layer;
     19import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     20import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
     21import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
     22import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
     23import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     24import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    925import org.openstreetmap.josm.tools.Destroyable;
    1026
     
    1632 * @license WTFPL
    1733 */
    18 public class ImageryOffsetWatcher implements MapView.ZoomChangeListener, MapView.LayerChangeListener, Destroyable {
     34public class ImageryOffsetWatcher implements ZoomChangeListener, LayerChangeListener, ActiveLayerChangeListener, Destroyable {
    1935    private static final double THRESHOLD = 1e-8;
    2036    private static ImageryOffsetWatcher instance;
     
    3248        maxDistance = Main.pref.getDouble("iodb.offset.radius", 15);
    3349        MapView.addZoomChangeListener(this);
    34         MapView.addLayerChangeListener(this);
     50        Main.getLayerManager().addLayerChangeListener(this);
     51        Main.getLayerManager().addActiveLayerChangeListener(this);
    3552        checkOffset(); // we assume there's at the most one imagery layer at this moment
    3653        time = new Timer();
     
    4158     * Unregister all events. This actually gets never called, but it's not a problem.
    4259     */
     60    @Override
    4361    public void destroy() {
    4462        MapView.removeZoomChangeListener(this);
    45         MapView.removeLayerChangeListener(this);
     63        Main.getLayerManager().removeLayerChangeListener(this);
     64        Main.getLayerManager().removeActiveLayerChangeListener(this);
    4665        time.cancel();
    4766    }
     
    165184    }
    166185
     186    @Override
    167187    public void zoomChanged() {
    168188        checkOffset();
    169189    }
    170190
    171     public void activeLayerChange( Layer oldLayer, Layer newLayer ) {
    172         checkOffset();
    173     }
    174 
    175     public void layerAdded( Layer newLayer ) {
    176         if( newLayer instanceof ImageryLayer )
    177             loadLayerOffset((ImageryLayer)newLayer);
    178         checkOffset();
    179     }
    180 
    181     public void layerRemoved( Layer oldLayer ) {
    182         checkOffset();
     191    @Override
     192    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     193        checkOffset();
     194    }
     195
     196    @Override
     197    public void layerAdded(LayerAddEvent e) {
     198        Layer newLayer = e.getAddedLayer();
     199        if (newLayer instanceof ImageryLayer)
     200            loadLayerOffset((ImageryLayer) newLayer);
     201        checkOffset();
     202    }
     203
     204    @Override
     205    public void layerRemoving(LayerRemoveEvent e) {
     206        checkOffset();
     207    }
     208
     209    @Override
     210    public void layerOrderChanged(LayerOrderChangeEvent e) {
    183211    }
    184212
     
    204232
    205233    /**
    206      * Loads the current imagery layer offset from preferences. 
     234     * Loads the current imagery layer offset from preferences.
    207235     */
    208236    private void loadLayerOffset( ImageryLayer layer ) {
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/OffsetDialog.java

    r32046 r32462  
    3838import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    3939import org.openstreetmap.josm.gui.MapView;
     40import org.openstreetmap.josm.gui.NavigatableComponent.ZoomChangeListener;
    4041import org.openstreetmap.josm.gui.layer.ImageryLayer;
    4142import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    5152 * @license WTFPL
    5253 */
    53 public class OffsetDialog extends JDialog implements ActionListener, MapView.ZoomChangeListener, MapViewPaintable {
     54public class OffsetDialog extends JDialog implements ActionListener, ZoomChangeListener, MapViewPaintable {
    5455    protected static final String PREF_CALIBRATION = "iodb.show.calibration";
    5556    protected static final String PREF_DEPRECATED = "iodb.show.deprecated";
     
    276277                JOptionPane.showMessageDialog(Main.parent,
    277278                        tr("The topmost imagery layer has been shifted to presumably match\n"
    278                         + "OSM data in the area. Please check that the offset is still valid\n"
    279                         + "by downloading GPS tracks and comparing them and OSM data to the imagery."),
     279                                + "OSM data in the area. Please check that the offset is still valid\n"
     280                                + "by downloading GPS tracks and comparing them and OSM data to the imagery."),
    280281                        ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
    281282                Main.pref.put("iodb.offset.message", true);
     
    283284        } else if( selectedOffset instanceof CalibrationObject ) {
    284285            CalibrationLayer clayer = new CalibrationLayer((CalibrationObject)selectedOffset);
    285             Main.map.mapView.addLayer(clayer);
     286            Main.getLayerManager().addLayer(clayer);
    286287            clayer.panToCenter();
    287288            if( !Main.pref.getBoolean("iodb.calibration.message", false) ) {
    288289                JOptionPane.showMessageDialog(Main.parent,
    289290                        tr("A layer has been added with a calibration geometry. Hide data layers,\n"
    290                         + "find the corresponding feature on the imagery layer and move it accordingly."),
     291                                + "find the corresponding feature on the imagery layer and move it accordingly."),
    291292                        ImageryOffsetTools.DIALOG_TITLE, JOptionPane.INFORMATION_MESSAGE);
    292293                Main.pref.put("iodb.calibration.message", true);
  • applications/editors/josm/plugins/imagery_offset_db/src/iodb/StoreImageryOffsetAction.java

    r30738 r32462  
    11package iodb;
     2
     3import static org.openstreetmap.josm.tools.I18n.tr;
    24
    35import java.awt.event.ActionEvent;
    46import java.io.UnsupportedEncodingException;
    5 import java.net.*;
    6 import java.util.*;
     7import java.net.URLEncoder;
     8import java.util.Collection;
     9import java.util.HashMap;
     10import java.util.Map;
     11
    712import javax.swing.JOptionPane;
     13
    814import org.openstreetmap.josm.Main;
    915import org.openstreetmap.josm.actions.JosmAction;
    1016import org.openstreetmap.josm.data.coor.LatLon;
    11 import org.openstreetmap.josm.data.osm.*;
     17import org.openstreetmap.josm.data.osm.Node;
     18import org.openstreetmap.josm.data.osm.OsmPrimitive;
     19import org.openstreetmap.josm.data.osm.Way;
    1220import org.openstreetmap.josm.gui.JosmUserIdentityManager;
    1321import org.openstreetmap.josm.gui.layer.ImageryLayer;
    14 import static org.openstreetmap.josm.tools.I18n.tr;
    1522
    1623/**
    1724 * Upload the current imagery offset or an calibration geometry information.
    18  * 
     25 *
    1926 * @author Zverik
    2027 * @license WTFPL
     
    3946     * and we don't have one when a user name is needed.
    4047     */
     48    @Override
    4149    public void actionPerformed(ActionEvent e) {
    4250        if( Main.map == null || Main.map.mapView == null )
     
    5664        if( userName.indexOf('@') > 0 )
    5765            userName = userName.replace('@', ',');
    58            
     66
    5967        // check if an object suitable for calibration is selected
    6068        OsmPrimitive calibration = null;
    61         if( getCurrentDataSet() != null ) {
    62             Collection<OsmPrimitive> selectedObjects = getCurrentDataSet().getSelected();
     69        if (getLayerManager().getEditDataSet() != null) {
     70            Collection<OsmPrimitive> selectedObjects = getLayerManager().getEditDataSet().getSelected();
    6371            if( selectedObjects.size() == 1 ) {
    6472                OsmPrimitive selection = selectedObjects.iterator().next();
Note: See TracChangeset for help on using the changeset viewer.