- Timestamp:
- 2010-01-07T19:29:53+01:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/AutoScaleAction.java
r2758 r2759 18 18 import org.openstreetmap.josm.data.osm.OsmPrimitive; 19 19 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 20 import org.openstreetmap.josm.gui.MapView; 20 21 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 21 22 import org.openstreetmap.josm.gui.layer.Layer; … … 226 227 setEnabled(true); 227 228 } 229 } else if ("previous".equals(mode)) { 230 setEnabled(Main.map != null && Main.map.mapView != null && Main.map.mapView.hasZoomUndoEntries()); 231 } else if ("next".equals(mode)) { 232 setEnabled(Main.map != null && Main.map.mapView != null && Main.map.mapView.hasZoomRedoEntries()); 228 233 } else { 229 234 setEnabled( … … 240 245 } 241 246 } 247 248 @Override 249 protected void installAdapters() { 250 super.installAdapters(); 251 // make this action listen to zoom change events 252 // 253 zoomChangeAdapter = new ZoomChangeAdapter(); 254 MapView.addZoomChangeListener(zoomChangeAdapter); 255 initEnabledState(); 256 } 257 258 /** 259 * Adapter for selection change events 260 * 261 */ 262 private class ZoomChangeAdapter implements MapView.ZoomChangeListener { 263 public void zoomChanged() { 264 updateEnabledState(); 265 } 266 } 267 268 private ZoomChangeAdapter zoomChangeAdapter; 242 269 } -
trunk/src/org/openstreetmap/josm/actions/JosmAction.java
r2621 r2759 139 139 } 140 140 141 pr ivatevoid installAdapters() {141 protected void installAdapters() { 142 142 // make this action listen to layer change and selection change events 143 143 // -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2758 r2759 13 13 import java.util.List; 14 14 import java.util.TreeMap; 15 import java.util.concurrent.CopyOnWriteArrayList; 15 16 16 17 import javax.swing.JComponent; … … 38 39 */ 39 40 public class NavigatableComponent extends JComponent implements Helpful { 41 42 /** 43 * Interface to notify listeners of the change of the zoom area. 44 */ 45 public interface ZoomChangeListener { 46 void zoomChanged(); 47 } 48 49 /** 50 * the zoom listeners 51 */ 52 private static final CopyOnWriteArrayList<ZoomChangeListener> zoomChangeListeners = new CopyOnWriteArrayList<ZoomChangeListener>(); 53 54 /** 55 * Removes a zoom change listener 56 * 57 * @param listener the listener. Ignored if null or already absent 58 */ 59 public static void removeZoomChangeListener(NavigatableComponent.ZoomChangeListener listener) { 60 zoomChangeListeners.remove(listener); 61 } 62 63 /** 64 * Adds a zoom change listener 65 * 66 * @param listener the listener. Ignored if null or already registered. 67 */ 68 public static void addZoomChangeListener(NavigatableComponent.ZoomChangeListener listener) { 69 if (listener != null) { 70 zoomChangeListeners.addIfAbsent(listener); 71 } 72 } 73 74 protected static void fireZoomChanged() { 75 for (ZoomChangeListener l : zoomChangeListeners) { 76 l.zoomChanged(); 77 } 78 } 79 40 80 41 81 public static final int snapDistance = Main.pref.getInteger("node.snap-distance", 10); … … 267 307 268 308 repaint(); 309 fireZoomChanged(); 269 310 } 270 311 … … 367 408 zoomNoUndoTo(zoom.getCenterEastNorth(), zoom.getScale()); 368 409 } 410 } 411 412 public boolean hasZoomUndoEntries() { 413 return !zoomUndoBuffer.isEmpty(); 414 } 415 416 public boolean hasZoomRedoEntries() { 417 return !zoomRedoBuffer.isEmpty(); 369 418 } 370 419
Note:
See TracChangeset
for help on using the changeset viewer.