Changeset 12107 in josm


Ignore:
Timestamp:
2017-05-11T00:18:12+02:00 (17 months ago)
Author:
michael2402
Message:

Allow invalidation listeners for all MapViewPaintables.

Location:
trunk/src/org/openstreetmap/josm/gui
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r12103 r12107  
    5252import org.openstreetmap.josm.gui.MapViewState.MapViewRectangle;
    5353import org.openstreetmap.josm.gui.datatransfer.OsmTransferHandler;
    54 import org.openstreetmap.josm.gui.layer.AbstractMapViewPaintable;
    5554import org.openstreetmap.josm.gui.layer.GpxLayer;
    5655import org.openstreetmap.josm.gui.layer.ImageryLayer;
     
    124123         */
    125124        public synchronized void addTo(MapViewPaintable p) {
    126             if (p instanceof AbstractMapViewPaintable) {
    127                 ((AbstractMapViewPaintable) p).addInvalidationListener(this);
    128             }
     125            p.addInvalidationListener(this);
    129126        }
    130127
     
    134131         */
    135132        public synchronized void removeFrom(MapViewPaintable p) {
    136             if (p instanceof AbstractMapViewPaintable) {
    137                 ((AbstractMapViewPaintable) p).removeInvalidationListener(this);
    138             }
     133            p.removeInvalidationListener(this);
    139134            invalidatedLayers.remove(p);
    140135        }
  • trunk/src/org/openstreetmap/josm/gui/layer/AbstractMapViewPaintable.java

    r12014 r12107  
    7070    }
    7171
    72     /**
    73      * Adds a new paintable invalidation listener.
    74      * @param l The listener to add.
    75      */
     72    @Override
    7673    public void addInvalidationListener(PaintableInvalidationListener l) {
    7774        invalidationListeners.add(l);
    7875    }
    7976
    80     /**
    81      * Removes an added paintable invalidation listener.
    82      * @param l The listener to remove.
    83      */
     77    @Override
    8478    public void removeInvalidationListener(PaintableInvalidationListener l) {
    8579        invalidationListeners.remove(l);
  • trunk/src/org/openstreetmap/josm/gui/layer/MapViewPaintable.java

    r11713 r12107  
    142142     */
    143143    void paint(Graphics2D g, MapView mv, Bounds bbox);
     144
     145    /**
     146     * Adds a new paintable invalidation listener.
     147     * @param l The listener to add.
     148     * @since 12107
     149     */
     150    default void addInvalidationListener(PaintableInvalidationListener l) {
     151    }
     152
     153    /**
     154     * Removes an added paintable invalidation listener. May throw an exception if the listener is added twice.
     155     * @param l The listener to remove.
     156     * @since 12107
     157     */
     158    default void removeInvalidationListener(PaintableInvalidationListener l) {
     159    }
     160
    144161}
Note: See TracChangeset for help on using the changeset viewer.