Ignore:
Timestamp:
2016-06-29T23:55:18+02:00 (8 years ago)
Author:
donvip
Message:

remove calls to deprecated methods

Location:
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustMapMode.java

    r32329 r32451  
    1616import org.openstreetmap.josm.gui.IconToggleButton;
    1717import org.openstreetmap.josm.gui.MapFrame;
    18 import org.openstreetmap.josm.gui.MapView;
    19 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    2018import 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;
    2125import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    2226import org.openstreetmap.josm.tools.Shortcut;
     
    2933 * handles it.
    3034 */
    31 public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener {
     35public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener, ActiveLayerChangeListener {
    3236
    3337    /** True if this map mode waits for mouse events. */
     
    3539    /** True if the map mode button is selected and active. */
    3640    private boolean modeSelected = false;
    37     private MouseAdapter mouseAdapter = null;
    38     private MouseMotionAdapter mouseMotionAdapter = null;
    39     private IconToggleButton mmButton = null;
    40     private PhotoAdjustWorker worker = null;
     41    private MouseAdapter mouseAdapter;
     42    private MouseMotionAdapter mouseMotionAdapter;
     43    private IconToggleButton mmButton;
     44    private PhotoAdjustWorker worker;
    4145
    4246    public PhotoAdjustMapMode(MapFrame mapFrame, PhotoAdjustWorker worker) {
     
    5155        initAdapters();
    5256        this.worker = worker;
    53         MapView.addLayerChangeListener(this);
     57        Main.getLayerManager().addLayerChangeListener(this);
     58        Main.getLayerManager().addActiveLayerChangeListener(this);
    5459    }
    5560
     
    131136        modeSelected = true;
    132137        // Activate the mode only if the current layer is not a
    133         // GeoImageLayer.  GeoImageLayer's are handled by the plug-in
    134         // directly.
     138        // GeoImageLayer.  GeoImageLayer's are handled by the plug-in directly.
    135139        if (! (Main.getLayerManager().getActiveLayer() instanceof GeoImageLayer)) {
    136140            activateMode();
     
    141145    public void exitMode() {
    142146        super.exitMode();
    143         MapView.removeLayerChangeListener(this);
     147        Main.getLayerManager().removeActiveLayerChangeListener(this);
     148        Main.getLayerManager().removeLayerChangeListener(this);
    144149        deactivateMode();
    145150        modeSelected = false;
    146151    }
    147152
    148     // LayerChangeListener: activeLayerChange/layerAdded/layerRemoved
    149     @Override
    150     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
    151         // The main part of the plugin takes care of all operations if
    152         // a GeoImageLayer is active.
    153         if (newLayer instanceof GeoImageLayer) {
     153    @Override
     154    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     155        // The main part of the plugin takes care of all operations if a GeoImageLayer is active.
     156        if (Main.getLayerManager().getActiveLayer() instanceof GeoImageLayer) {
    154157            deactivateMode();
    155         }
    156         else {
     158        } else {
    157159            activateMode();
    158160        }
     
    160162
    161163    @Override
    162     public void layerAdded(Layer newLayer) {
     164    public void layerAdded(LayerAddEvent e) {
    163165        if (modeActive) updateStatusLine();
    164166        updateButtonState();
     
    166168
    167169    @Override
    168     public void layerRemoved(Layer oldLayer) {
     170    public void layerRemoving(LayerRemoveEvent e) {
    169171        if (modeActive) updateStatusLine();
    170172        updateButtonState();
    171173    }
    172     // End LayerChangeListener
     174
     175    @Override
     176    public void layerOrderChanged(LayerOrderChangeEvent e) {
     177    }
    173178
    174179    /**
     
    228233    public void destroy() {
    229234        super.destroy();
    230         MapView.removeLayerChangeListener(this);
     235        Main.getLayerManager().removeLayerChangeListener(this);
     236        Main.getLayerManager().removeActiveLayerChangeListener(this);
    231237    }
    232238}
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustPlugin.java

    r31961 r32451  
    88
    99import org.openstreetmap.josm.Main;
     10import org.openstreetmap.josm.gui.MapFrame;
     11import org.openstreetmap.josm.gui.layer.Layer;
     12import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     13import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
     14import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    1015import org.openstreetmap.josm.plugins.Plugin;
    1116import org.openstreetmap.josm.plugins.PluginInformation;
    12 import org.openstreetmap.josm.gui.MapFrame;
    13 import org.openstreetmap.josm.gui.MapView;
    14 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;
    15 import org.openstreetmap.josm.gui.layer.Layer;
    16 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer;
    1717
    1818/**
     
    2121 * coordinates (untagged photos) on the map.
    2222 */
    23 public class PhotoAdjustPlugin extends Plugin implements LayerChangeListener {
     23public class PhotoAdjustPlugin extends Plugin implements ActiveLayerChangeListener {
    2424 
    2525    private GeoImageLayer imageLayer = null;
     
    7777    public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) {
    7878        if (oldFrame == null && newFrame != null) {
    79             MapView.addLayerChangeListener(this, true);
     79            Main.getLayerManager().addAndFireActiveLayerChangeListener(this);
    8080            PhotoAdjustMapMode adjustMode = new PhotoAdjustMapMode(newFrame, worker);
    8181            adjustMode.installMapMode(newFrame);
    82         }
    83         else {
    84             MapView.removeLayerChangeListener(this);
     82        } else {
     83            Main.getLayerManager().removeActiveLayerChangeListener(this);
    8584        }
    8685    }
    8786
    88     // LayerChangeListener: activeLayerChange/layerAdded/layerRemoved
    8987    @Override
    90     public void activeLayerChange(Layer oldLayer, Layer newLayer) {
     88    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    9189        worker.reset();
     90        Layer oldLayer = e.getPreviousActiveLayer();
     91        Layer newLayer = Main.getLayerManager().getActiveLayer();
    9292        if ( oldLayer instanceof GeoImageLayer
    9393             && newLayer instanceof GeoImageLayer) {
     
    107107        }
    108108    }
    109 
    110     @Override
    111     public void layerAdded(Layer newLayer) {}
    112 
    113     @Override
    114     public void layerRemoved(Layer oldLayer) {}
    115109}
  • applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/UntaggedGeoImageLayerAction.java

    r30737 r32451  
    5353                }
    5454            }
    55             Main.main.addLayer(new GeoImageLayer(untagged, layer.getGpxLayer(),
     55            Main.getLayerManager().addLayer(new GeoImageLayer(untagged, layer.getGpxLayer(),
    5656                                                 tr("Untagged Images"),
    5757                                                 layer.isUseThumbs()));
Note: See TracChangeset for help on using the changeset viewer.