Changeset 32451 in osm for applications/editors
- Timestamp:
- 2016-06-29T23:55:18+02:00 (9 years ago)
- 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 16 16 import org.openstreetmap.josm.gui.IconToggleButton; 17 17 import org.openstreetmap.josm.gui.MapFrame; 18 import org.openstreetmap.josm.gui.MapView;19 import org.openstreetmap.josm.gui.MapView.LayerChangeListener;20 18 import org.openstreetmap.josm.gui.layer.Layer; 19 import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent; 20 import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener; 21 import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent; 22 import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent; 23 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 24 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 21 25 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 22 26 import org.openstreetmap.josm.tools.Shortcut; … … 29 33 * handles it. 30 34 */ 31 public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener {35 public class PhotoAdjustMapMode extends MapMode implements LayerChangeListener, ActiveLayerChangeListener { 32 36 33 37 /** True if this map mode waits for mouse events. */ … … 35 39 /** True if the map mode button is selected and active. */ 36 40 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; 41 45 42 46 public PhotoAdjustMapMode(MapFrame mapFrame, PhotoAdjustWorker worker) { … … 51 55 initAdapters(); 52 56 this.worker = worker; 53 MapView.addLayerChangeListener(this); 57 Main.getLayerManager().addLayerChangeListener(this); 58 Main.getLayerManager().addActiveLayerChangeListener(this); 54 59 } 55 60 … … 131 136 modeSelected = true; 132 137 // 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. 135 139 if (! (Main.getLayerManager().getActiveLayer() instanceof GeoImageLayer)) { 136 140 activateMode(); … … 141 145 public void exitMode() { 142 146 super.exitMode(); 143 MapView.removeLayerChangeListener(this); 147 Main.getLayerManager().removeActiveLayerChangeListener(this); 148 Main.getLayerManager().removeLayerChangeListener(this); 144 149 deactivateMode(); 145 150 modeSelected = false; 146 151 } 147 152 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) { 154 157 deactivateMode(); 155 } 156 else { 158 } else { 157 159 activateMode(); 158 160 } … … 160 162 161 163 @Override 162 public void layerAdded(Layer newLayer) {164 public void layerAdded(LayerAddEvent e) { 163 165 if (modeActive) updateStatusLine(); 164 166 updateButtonState(); … … 166 168 167 169 @Override 168 public void layerRemov ed(Layer oldLayer) {170 public void layerRemoving(LayerRemoveEvent e) { 169 171 if (modeActive) updateStatusLine(); 170 172 updateButtonState(); 171 173 } 172 // End LayerChangeListener 174 175 @Override 176 public void layerOrderChanged(LayerOrderChangeEvent e) { 177 } 173 178 174 179 /** … … 228 233 public void destroy() { 229 234 super.destroy(); 230 MapView.removeLayerChangeListener(this); 235 Main.getLayerManager().removeLayerChangeListener(this); 236 Main.getLayerManager().removeActiveLayerChangeListener(this); 231 237 } 232 238 } -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/PhotoAdjustPlugin.java
r31961 r32451 8 8 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.gui.MapFrame; 11 import org.openstreetmap.josm.gui.layer.Layer; 12 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent; 13 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener; 14 import org.openstreetmap.josm.gui.layer.geoimage.GeoImageLayer; 10 15 import org.openstreetmap.josm.plugins.Plugin; 11 16 import 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;17 17 18 18 /** … … 21 21 * coordinates (untagged photos) on the map. 22 22 */ 23 public class PhotoAdjustPlugin extends Plugin implements LayerChangeListener {23 public class PhotoAdjustPlugin extends Plugin implements ActiveLayerChangeListener { 24 24 25 25 private GeoImageLayer imageLayer = null; … … 77 77 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 78 78 if (oldFrame == null && newFrame != null) { 79 Ma pView.addLayerChangeListener(this, true);79 Main.getLayerManager().addAndFireActiveLayerChangeListener(this); 80 80 PhotoAdjustMapMode adjustMode = new PhotoAdjustMapMode(newFrame, worker); 81 81 adjustMode.installMapMode(newFrame); 82 } 83 else { 84 MapView.removeLayerChangeListener(this); 82 } else { 83 Main.getLayerManager().removeActiveLayerChangeListener(this); 85 84 } 86 85 } 87 86 88 // LayerChangeListener: activeLayerChange/layerAdded/layerRemoved89 87 @Override 90 public void active LayerChange(Layer oldLayer, Layer newLayer) {88 public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) { 91 89 worker.reset(); 90 Layer oldLayer = e.getPreviousActiveLayer(); 91 Layer newLayer = Main.getLayerManager().getActiveLayer(); 92 92 if ( oldLayer instanceof GeoImageLayer 93 93 && newLayer instanceof GeoImageLayer) { … … 107 107 } 108 108 } 109 110 @Override111 public void layerAdded(Layer newLayer) {}112 113 @Override114 public void layerRemoved(Layer oldLayer) {}115 109 } -
applications/editors/josm/plugins/photoadjust/src/org/openstreetmap/josm/plugins/photoadjust/UntaggedGeoImageLayerAction.java
r30737 r32451 53 53 } 54 54 } 55 Main. main.addLayer(new GeoImageLayer(untagged, layer.getGpxLayer(),55 Main.getLayerManager().addLayer(new GeoImageLayer(untagged, layer.getGpxLayer(), 56 56 tr("Untagged Images"), 57 57 layer.isUseThumbs()));
Note:
See TracChangeset
for help on using the changeset viewer.