Changeset 10972 in josm for trunk/src


Ignore:
Timestamp:
2016-09-07T01:23:17+02:00 (3 years ago)
Author:
Don-vip
Message:

remove deprecated stuff - gsoc-core

Location:
trunk/src/org/openstreetmap/josm
Files:
11 edited

Legend:

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

    r10962 r10972  
    6969import org.openstreetmap.josm.data.projection.ProjectionChangeListener;
    7070import org.openstreetmap.josm.data.validation.OsmValidator;
    71 import org.openstreetmap.josm.gui.GettingStarted;
    7271import org.openstreetmap.josm.gui.MainFrame;
    7372import org.openstreetmap.josm.gui.MainMenu;
     
    8180import org.openstreetmap.josm.gui.layer.Layer;
    8281import org.openstreetmap.josm.gui.layer.MainLayerManager;
    83 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    8482import org.openstreetmap.josm.gui.layer.OsmDataLayer.CommandQueueListener;
    8583import org.openstreetmap.josm.gui.preferences.ToolbarPreferences;
     
    9088import org.openstreetmap.josm.gui.progress.ProgressMonitorExecutor;
    9189import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    92 import org.openstreetmap.josm.gui.util.GuiHelper;
    9390import org.openstreetmap.josm.gui.util.RedirectInputMap;
    9491import org.openstreetmap.josm.io.FileWatcher;
     
    208205    public static final FileWatcher fileWatcher = new FileWatcher();
    209206
    210     /**
    211      * The MOTD Layer.
    212      * @deprecated Do not access this. It will be removed soon. You should not need to access the GettingStarted panel.
    213      */
    214     @Deprecated
    215     public final GettingStarted gettingStarted = mainPanel.getGettingStarted();
    216 
    217207    protected static final Map<String, Throwable> NETWORK_ERRORS = new HashMap<>();
    218208
     
    467457     */
    468458    public static volatile PlatformHook platform;
    469 
    470     /**
    471      * Set or clear (if passed <code>null</code>) the map.
    472      * <p>
    473      * To be removed any time
    474      * @param map The map to set {@link Main#map} to. Can be null.
    475      * @deprecated This is done automatically by {@link MainPanel}
    476      */
    477     @Deprecated
    478     public final void setMapFrame(final MapFrame map) {
    479         Main.warn("setMapFrame call was ignored.");
    480     }
    481 
    482     /**
    483      * Remove the specified layer from the map. If it is the last layer,
    484      * remove the map as well.
    485      * <p>
    486      * To be removed end of 2016
    487      * @param layer The layer to remove
    488      * @deprecated You can remove the layer using {@link #getLayerManager()}
    489      */
    490     @Deprecated
    491     public final synchronized void removeLayer(final Layer layer) {
    492         if (map != null) {
    493             getLayerManager().removeLayer(layer);
    494         }
    495     }
    496459
    497460    private static volatile InitStatusListener initListener;
     
    627590     *
    628591     * If no map exists, create one.
    629      * <p>
    630      * To be removed end of 2016
    631      *
    632      * @param layer the layer
    633      *
    634      * @see #addLayer(Layer, ProjectionBounds)
    635      * @see #addLayer(Layer, ViewportData)
    636      * @deprecated You can add the layer to the layer manager: {@link #getLayerManager()}
    637      */
    638     @Deprecated
    639     public final void addLayer(final Layer layer) {
    640         addLayer(layer, (ViewportData) null);
    641     }
    642 
    643     /**
    644      * Add a new layer to the map.
    645      *
    646      * If no map exists, create one.
    647592     *
    648593     * @param layer the layer
     
    668613            Main.map.mapView.scheduleZoomTo(viewport);
    669614        }
    670     }
    671 
    672     /**
    673      * Creates the map frame. Call only in EDT Thread.
    674      * <p>
    675      * To be removed any time
    676      * @param firstLayer The first layer that was added.
    677      * @param viewportData The initial viewport. Can be <code>null</code> to be automatically computed.
    678      * @deprecated Not supported. MainPanel does this automatically.
    679      */
    680     @Deprecated
    681     public synchronized void createMapFrame(Layer firstLayer, ViewportData viewportData) {
    682         GuiHelper.assertCallFromEdt();
    683         Main.error("createMapFrame() not supported any more.");
    684     }
    685 
    686     /**
    687      * Replies <code>true</code> if there is an edit layer
    688      * <p>
    689      * To be removed end of 2016
    690      *
    691      * @return <code>true</code> if there is an edit layer
    692      * @deprecated You can get the edit layer using the layer manager and then check if it is not null: {@link #getLayerManager()}
    693      */
    694     @Deprecated
    695     public boolean hasEditLayer() {
    696         if (getEditLayer() == null) return false;
    697         return true;
    698     }
    699 
    700     /**
    701      * Replies the current edit layer
    702      * <p>
    703      * To be removed end of 2016
    704      *
    705      * @return the current edit layer. <code>null</code>, if no current edit layer exists
    706      * @deprecated You can get the edit layer using the layer manager: {@link #getLayerManager()}
    707      */
    708     @Deprecated
    709     public OsmDataLayer getEditLayer() {
    710         return getLayerManager().getEditLayer();
    711     }
    712 
    713     /**
    714      * Replies the current data set.
    715      * <p>
    716      * To be removed end of 2016
    717      *
    718      * @return the current data set. <code>null</code>, if no current data set exists
    719      * @deprecated You can get the data set using the layer manager: {@link #getLayerManager()}
    720      */
    721     @Deprecated
    722     public DataSet getCurrentDataSet() {
    723         return getLayerManager().getEditDataSet();
    724615    }
    725616
     
    741632            return ds.getSelected();
    742633        }
    743     }
    744 
    745     /**
    746      * Returns the currently active  layer
    747      * <p>
    748      * To be removed end of 2016
    749      *
    750      * @return the currently active layer. <code>null</code>, if currently no active layer exists
    751      * @deprecated You can get the layer using the layer manager: {@link #getLayerManager()}
    752      */
    753     @Deprecated
    754     public Layer getActiveLayer() {
    755         return getLayerManager().getActiveLayer();
    756634    }
    757635
  • trunk/src/org/openstreetmap/josm/actions/JosmAction.java

    r10601 r10972  
    2323import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    2424import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    25 import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2625import org.openstreetmap.josm.gui.progress.PleaseWaitProgressMonitor;
    2726import org.openstreetmap.josm.tools.Destroyable;
     
    3837 * a layer change event or a selection change event it invokes {@link #updateEnabledState()}.
    3938 * Subclasses can override {@link #updateEnabledState()} in order to update the {@link #isEnabled()}-state
    40  * of a JosmAction depending on the {@link #getCurrentDataSet()} and the current layers
    41  * (see also {@link #getEditLayer()}).
     39 * of a JosmAction depending on the {@link #getLayerManager()} state.
    4240 *
    4341 * destroy() from interface Destroyable is called e.g. for MapModes, when the last layer has
     
    270268    }
    271269
    272     /**
    273      * Replies the current edit layer
    274      *
    275      * @return the current edit layer. null, if no edit layer exists
    276      * @deprecated Use {@link #getLayerManager()}.getEditLayer() instead. To be removed in end of 2016.
    277      */
    278     @Deprecated
    279     public static OsmDataLayer getEditLayer() {
    280         return Main.getLayerManager().getEditLayer();
    281     }
    282 
    283     /**
    284      * Replies the current dataset.
    285      *
    286      * @return the current dataset. null, if no current dataset exists
    287      * @deprecated Use {@link #getLayerManager()}.getEditDataSet() instead. To be removed in end of 2016.
    288      */
    289     @Deprecated
    290     public static DataSet getCurrentDataSet() {
    291         return Main.getLayerManager().getEditDataSet();
    292     }
    293 
    294270    protected static void waitFuture(final Future<?> future, final PleaseWaitProgressMonitor monitor) {
    295271        Main.worker.submit(() -> {
  • trunk/src/org/openstreetmap/josm/data/osm/DataSet.java

    r10891 r10972  
    9494 * @author imi
    9595 */
    96 public final class DataSet implements Data, Cloneable, ProjectionChangeListener {
     96public final class DataSet implements Data, ProjectionChangeListener {
    9797
    9898    /**
     
    919919            fireSelectionChanged();
    920920        }
    921     }
    922 
    923     /**
    924      * Return a copy of this dataset
    925      * @deprecated Use the copy constructor instead. Remove in July 2016
    926      */
    927     @Deprecated
    928     @Override
    929     public DataSet clone() {
    930         return new DataSet(this);
    931921    }
    932922
  • trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java

    r10896 r10972  
    1919import java.util.Objects;
    2020import java.util.Set;
    21 import java.util.function.Predicate;
    2221
    2322import org.openstreetmap.josm.Main;
     
    196195        return ret;
    197196    }
    198 
    199     /**
    200      * A predicate that filters primitives that are usable.
    201      * @see OsmPrimitive#isUsable()
    202      * @deprecated Use {@code OsmPrimitive::isUsable} instead
    203      */
    204     @Deprecated
    205     public static final Predicate<OsmPrimitive> isUsablePredicate = OsmPrimitive::isUsable;
    206 
    207     /**
    208      * A predicate filtering primitives that are selectable.
    209      * @deprecated Use {@code OsmPrimitive::isSelectable} instead
    210      */
    211     @Deprecated
    212     public static final Predicate<OsmPrimitive> isSelectablePredicate = OsmPrimitive::isSelectable;
    213 
    214     /**
    215      * A predicate filtering primitives that are not deleted.
    216      * @deprecated Use {@code p -> !p.isDeleted()} instead
    217      */
    218     @Deprecated
    219     public static final Predicate<OsmPrimitive> nonDeletedPredicate = p -> !p.isDeleted();
    220 
    221     /**
    222      * A predicate filtering primitives that are not deleted and not incomplete.
    223      * @deprecated use lambda instead
    224      */
    225     @Deprecated
    226     public static final Predicate<OsmPrimitive> nonDeletedCompletePredicate =
    227             primitive -> !primitive.isDeleted() && !primitive.isIncomplete();
    228 
    229     /**
    230      * A predicate filtering primitives that are not deleted and not incomplete and that are not a relation.
    231      * @deprecated use lambda instead
    232      */
    233     @Deprecated
    234     public static final Predicate<OsmPrimitive> nonDeletedPhysicalPredicate =
    235             primitive -> !primitive.isDeleted() && !primitive.isIncomplete() && !(primitive instanceof Relation);
    236 
    237     /**
    238      * A predicate filtering primitives that are modified
    239      * @deprecated Use {@code OsmPrimitive::isModified} instead
    240      */
    241     @Deprecated
    242     public static final Predicate<OsmPrimitive> modifiedPredicate = OsmPrimitive::isModified;
    243 
    244     /**
    245      * A predicate filtering nodes.
    246      * @deprecated Use {@code Node.class::isInstance} instead
    247      */
    248     @Deprecated
    249     public static final Predicate<OsmPrimitive> nodePredicate = Node.class::isInstance;
    250 
    251     /**
    252      * A predicate filtering ways.
    253      * @deprecated Use {@code Way.class::isInstance} instead
    254      */
    255     @Deprecated
    256     public static final Predicate<OsmPrimitive> wayPredicate = Way.class::isInstance;
    257 
    258     /**
    259      * A predicate filtering relations.
    260      * @deprecated Use {@code Relation.class::isInstance} instead
    261      */
    262     @Deprecated
    263     public static final Predicate<OsmPrimitive> relationPredicate = Relation.class::isInstance;
    264 
    265     /**
    266      * A predicate filtering multipolygon relations.
    267      * @deprecated Use {@code OsmPrimitive::isMultipolygon} instead
    268      */
    269     @Deprecated
    270     public static final Predicate<OsmPrimitive> multipolygonPredicate = OsmPrimitive::isMultipolygon;
    271 
    272     /**
    273      * This matches all ways that have a direction
    274      *
    275      * @see #FLAG_HAS_DIRECTIONS
    276      * @deprecated use {@code directionKeys::match}
    277      */
    278     @Deprecated
    279     public static final Predicate<Tag> directionalKeyPredicate = directionKeys::match;
    280197
    281198    /**
  • trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java

    r10736 r10972  
    324324
    325325    /**
    326      * Replies true if this tag collection contains at least one tag with key <code>key</code>.
    327      *
    328      * @param key the key to look up
    329      * @return true if this tag collection contains at least one tag with key <code>key</code>; false, otherwise
    330      * @deprecated Use {@link #hasTagsFor(String)} instead.
    331      */
    332     @Deprecated
    333     public boolean containsKey(String key) {
    334         return generateStreamForKey(key).findAny().isPresent();
    335     }
    336 
    337     /**
    338326     * Replies true if this tag collection contains all tags in <code>tags</code>. Replies
    339327     * false, if tags is null.
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r10965 r10972  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui;
    3 
    4 import static org.openstreetmap.josm.tools.I18n.tr;
    53
    64import java.awt.AlphaComposite;
     
    2321import java.util.ArrayList;
    2422import java.util.Arrays;
    25 import java.util.Collection;
    2623import java.util.Collections;
    2724import java.util.HashMap;
     
    5956import org.openstreetmap.josm.gui.layer.LayerManager;
    6057import org.openstreetmap.josm.gui.layer.LayerManager.LayerAddEvent;
     58import org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener;
    6159import org.openstreetmap.josm.gui.layer.LayerManager.LayerOrderChangeEvent;
    6260import org.openstreetmap.josm.gui.layer.LayerManager.LayerRemoveEvent;
    6361import org.openstreetmap.josm.gui.layer.MainLayerManager;
    6462import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
    65 import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener;
    6663import org.openstreetmap.josm.gui.layer.MapViewGraphics;
    6764import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    9390implements PropertyChangeListener, PreferenceChangedListener,
    9491LayerManager.LayerChangeListener, MainLayerManager.ActiveLayerChangeListener {
    95     /**
    96      * Interface to notify listeners of a layer change.
    97      * <p>
    98      * To be removed: end of 2016.
    99      * @deprecated Use {@link org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener} instead.
    100      * @author imi
    101      */
    102     @Deprecated
    103     public interface LayerChangeListener {
    104 
    105         /**
    106          * Notifies this listener that the active layer has changed.
    107          * @param oldLayer The previous active layer
    108          * @param newLayer The new activer layer
    109          */
    110         void activeLayerChange(Layer oldLayer, Layer newLayer);
    111 
    112         /**
    113          * Notifies this listener that a layer has been added.
    114          * @param newLayer The new added layer
    115          */
    116         void layerAdded(Layer newLayer);
    117 
    118         /**
    119          * Notifies this listener that a layer has been removed.
    120          * @param oldLayer The old removed layer
    121          */
    122         void layerRemoved(Layer oldLayer);
    123     }
    124 
    125     /**
    126      * An interface that needs to be implemented in order to listen for changes to the active edit layer.
    127      * <p>
    128      * To be removed: end of 2016.
    129      * @deprecated Use {@link ActiveLayerChangeListener} instead.
    130      */
    131     @Deprecated
    132     @FunctionalInterface
    133     public interface EditLayerChangeListener {
    134 
    135         /**
    136          * Called after the active edit layer was changed.
    137          * @param oldLayer The old edit layer
    138          * @param newLayer The current (new) edit layer
    139          */
    140         void editLayerChanged(OsmDataLayer oldLayer, OsmDataLayer newLayer);
    141     }
    14292
    14393    /**
     
    211161
    212162    /**
    213      * This class is an adapter for the old layer change interface.
    214      * @author Michael Zangl
    215      * @since 10271
    216      * @deprecated New implementations should use {@link org.openstreetmap.josm.gui.layer.LayerManager.LayerChangeListener}
    217      */
    218     @Deprecated
    219     protected static class LayerChangeAdapter implements ActiveLayerChangeListener, LayerManager.LayerChangeListener {
    220 
    221         private final LayerChangeListener wrapped;
    222         private boolean receiveOneInitialFire;
    223 
    224         public LayerChangeAdapter(LayerChangeListener wrapped) {
    225             this.wrapped = wrapped;
    226         }
    227 
    228         public LayerChangeAdapter(LayerChangeListener wrapped, boolean initialFire) {
    229             this(wrapped);
    230             this.receiveOneInitialFire = initialFire;
    231         }
    232 
    233         @Override
    234         public void layerAdded(LayerAddEvent e) {
    235             wrapped.layerAdded(e.getAddedLayer());
    236         }
    237 
    238         @Override
    239         public void layerRemoving(LayerRemoveEvent e) {
    240             wrapped.layerRemoved(e.getRemovedLayer());
    241         }
    242 
    243         @Override
    244         public void layerOrderChanged(LayerOrderChangeEvent e) {
    245             // not in old API
    246         }
    247 
    248         @Override
    249         public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    250             Layer oldActive = receiveOneInitialFire ? null : e.getPreviousActiveLayer();
    251             Layer newActive = e.getSource().getActiveLayer();
    252             if (oldActive != newActive) {
    253                 wrapped.activeLayerChange(oldActive, newActive);
    254             }
    255             receiveOneInitialFire = false;
    256         }
    257 
    258         @Override
    259         public int hashCode() {
    260             final int prime = 31;
    261             int result = 1;
    262             result = prime * result + ((wrapped == null) ? 0 : wrapped.hashCode());
    263             return result;
    264         }
    265 
    266         @Override
    267         public boolean equals(Object obj) {
    268             if (this == obj)
    269                 return true;
    270             if (obj == null)
    271                 return false;
    272             if (getClass() != obj.getClass())
    273                 return false;
    274             LayerChangeAdapter other = (LayerChangeAdapter) obj;
    275             if (wrapped == null) {
    276                 if (other.wrapped != null)
    277                     return false;
    278             } else if (!wrapped.equals(other.wrapped))
    279                 return false;
    280             return true;
    281         }
    282 
    283         @Override
    284         public String toString() {
    285             return "LayerChangeAdapter [wrapped=" + wrapped + ']';
    286         }
    287     }
    288 
    289     /**
    290      * This class is an adapter for the old layer change interface.
    291      * @author Michael Zangl
    292      * @since 10271
    293      * @deprecated New implementations should use {@link org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeListener}
    294      */
    295     @Deprecated
    296     protected static class EditLayerChangeAdapter implements ActiveLayerChangeListener {
    297 
    298         private final EditLayerChangeListener wrapped;
    299 
    300         public EditLayerChangeAdapter(EditLayerChangeListener wrapped) {
    301             this.wrapped = wrapped;
    302         }
    303 
    304         @Override
    305         public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
    306             OsmDataLayer oldLayer = e.getPreviousEditLayer();
    307             OsmDataLayer newLayer = e.getSource().getEditLayer();
    308             if (oldLayer != newLayer) {
    309                 wrapped.editLayerChanged(oldLayer, newLayer);
    310             }
    311         }
    312 
    313         @Override
    314         public int hashCode() {
    315             final int prime = 31;
    316             int result = 1;
    317             result = prime * result + ((wrapped == null) ? 0 : wrapped.hashCode());
    318             return result;
    319         }
    320 
    321         @Override
    322         public boolean equals(Object obj) {
    323             if (this == obj)
    324                 return true;
    325             if (obj == null)
    326                 return false;
    327             if (getClass() != obj.getClass())
    328                 return false;
    329             EditLayerChangeAdapter other = (EditLayerChangeAdapter) obj;
    330             if (wrapped == null) {
    331                 if (other.wrapped != null)
    332                     return false;
    333             } else if (!wrapped.equals(other.wrapped))
    334                 return false;
    335             return true;
    336         }
    337 
    338         @Override
    339         public String toString() {
    340             return "EditLayerChangeAdapter [wrapped=" + wrapped + ']';
    341         }
    342     }
    343 
    344     /**
    345163     * A layer painter that issues a warning when being called.
    346164     * @author Michael Zangl
     
    368186        }
    369187    }
    370 
    371     /**
    372      * Removes a layer change listener
    373      * <p>
    374      * To be removed: end of 2016.
    375      *
    376      * @param listener the listener. Ignored if null or not registered.
    377      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    378      */
    379     @Deprecated
    380     public static void removeLayerChangeListener(LayerChangeListener listener) {
    381         LayerChangeAdapter adapter = new LayerChangeAdapter(listener);
    382         try {
    383             Main.getLayerManager().removeLayerChangeListener(adapter);
    384         } catch (IllegalArgumentException e) {
    385             // Ignored in old implementation
    386             Main.debug(e);
    387         }
    388         try {
    389             Main.getLayerManager().removeActiveLayerChangeListener(adapter);
    390         } catch (IllegalArgumentException e) {
    391             // Ignored in old implementation
    392             Main.debug(e);
    393         }
    394     }
    395 
    396     /**
    397      * Removes an edit layer change listener
    398      * <p>
    399      * To be removed: end of 2016.
    400      *
    401      * @param listener the listener. Ignored if null or not registered.
    402      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    403      */
    404     @Deprecated
    405     public static void removeEditLayerChangeListener(EditLayerChangeListener listener) {
    406         try {
    407             Main.getLayerManager().removeActiveLayerChangeListener(new EditLayerChangeAdapter(listener));
    408         } catch (IllegalArgumentException e) {
    409             // Ignored in old implementation
    410             Main.debug(e);
    411         }
    412     }
    413 
    414     /**
    415      * Adds a layer change listener
    416      * <p>
    417      * To be removed: end of 2016.
    418      *
    419      * @param listener the listener. Ignored if null or already registered.
    420      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    421      */
    422     @Deprecated
    423     public static void addLayerChangeListener(LayerChangeListener listener) {
    424         if (fireDeprecatedListenerOnAdd) {
    425             Main.warn("Plugin seems to be adding listener during mapFrameInitialized(): " + BugReport.getCallingMethod(2)
    426             + ". Layer listeners should be set on plugin load.");
    427         }
    428         addLayerChangeListener(listener, fireDeprecatedListenerOnAdd);
    429     }
    430 
    431     /**
    432      * Adds a layer change listener
    433      * <p>
    434      * To be removed: end of 2016.
    435      *
    436      * @param listener the listener. Ignored if null or already registered.
    437      * @param initialFire fire an active-layer-changed-event right after adding
    438      * the listener in case there is a layer present (should be)
    439      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    440      */
    441     @Deprecated
    442     public static void addLayerChangeListener(LayerChangeListener listener, boolean initialFire) {
    443         if (listener != null) {
    444             boolean doInitialFire = initialFire && (Main.isDisplayingMapView() || fireDeprecatedListenerOnAdd);
    445 
    446             LayerChangeAdapter adapter = new LayerChangeAdapter(listener, doInitialFire);
    447             Main.getLayerManager().addLayerChangeListener(adapter, doInitialFire);
    448             if (doInitialFire) {
    449                 Main.getLayerManager().addAndFireActiveLayerChangeListener(adapter);
    450             } else {
    451                 Main.getLayerManager().addActiveLayerChangeListener(adapter);
    452             }
    453             adapter.receiveOneInitialFire = false;
    454         }
    455     }
    456 
    457     /**
    458      * Adds an edit layer change listener
    459      * <p>
    460      * To be removed: end of 2016.
    461      *
    462      * @param listener the listener. Ignored if null or already registered.
    463      * @param initialFire fire an edit-layer-changed-event right after adding
    464      * the listener in case there is an edit layer present
    465      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    466      */
    467     @Deprecated
    468     public static void addEditLayerChangeListener(EditLayerChangeListener listener, boolean initialFire) {
    469         if (listener != null) {
    470             boolean doFire = initialFire && Main.isDisplayingMapView() && Main.getLayerManager().getEditLayer() != null;
    471             if (doFire) {
    472                 Main.getLayerManager().addAndFireActiveLayerChangeListener(new EditLayerChangeAdapter(listener));
    473             } else {
    474                 Main.getLayerManager().addActiveLayerChangeListener(new EditLayerChangeAdapter(listener));
    475             }
    476         }
    477     }
    478 
    479     /**
    480      * Adds an edit layer change listener
    481      * <p>
    482      * To be removed: end of 2016.
    483      *
    484      * @param listener the listener. Ignored if null or already registered.
    485      * @deprecated You should register the listener on {@link Main#getLayerManager()} instead.
    486      */
    487     @Deprecated
    488     public static void addEditLayerChangeListener(EditLayerChangeListener listener) {
    489         addEditLayerChangeListener(listener, false);
    490     }
    491 
    492188
    493189    /**
     
    630326        oldSize = getSize();
    631327        oldLoc = getLocationOnScreen();
    632     }
    633 
    634     /**
    635      * Add a layer to the current MapView.
    636      * <p>
    637      * To be removed: end of 2016.
    638      * @param layer The layer to add
    639      * @deprecated Use {@link Main#getLayerManager()}.addLayer() instead.
    640      */
    641     @Deprecated
    642     public void addLayer(Layer layer) {
    643         layerManager.addLayer(layer);
    644328    }
    645329
     
    675359
    676360    /**
    677      * Returns current data set. To be removed: end of 2016.
    678      * @deprecated Use {@link #getLayerManager()}.getEditDataSet() instead.
    679      */
    680     @Override
    681     @Deprecated
    682     protected DataSet getCurrentDataSet() {
    683         return layerManager.getEditDataSet();
    684     }
    685 
    686     /**
    687361     * Replies true if the active data layer (edit layer) is drawable.
    688362     *
     
    701375        OsmDataLayer e = layerManager.getEditLayer();
    702376        return e != null && e.isVisible();
    703     }
    704 
    705     /**
    706      * Determines the next active data layer according to the following rules:
    707      * <ul>
    708      *   <li>if there is at least one {@link OsmDataLayer} the first one
    709      *     becomes active</li>
    710      *   <li>otherwise, the top most layer of any type becomes active</li>
    711      * </ul>
    712      * To be removed: end of 2016.
    713      * @param layersList lit of layers
    714      *
    715      * @return the next active data layer
    716      * @deprecated now handled by {@link MainLayerManager}
    717      */
    718     @Deprecated
    719     protected Layer determineNextActiveLayer(List<Layer> layersList) {
    720         // First look for data layer
    721         for (Layer layer:layersList) {
    722             if (layer instanceof OsmDataLayer)
    723                 return layer;
    724         }
    725 
    726         // Then any layer
    727         if (!layersList.isEmpty())
    728             return layersList.get(0);
    729 
    730         // and then give up
    731         return null;
    732     }
    733 
    734     /**
    735      * Remove the layer from the mapview. If the layer was in the list before,
    736      * an LayerChange event is fired.
    737      * <p>
    738      * To be removed: end of 2016.
    739      * @param layer The layer to remove
    740      * @deprecated Use {@link Main#getLayerManager()}.removeLayer() instead.
    741      */
    742     @Deprecated
    743     public void removeLayer(Layer layer) {
    744         layerManager.removeLayer(layer);
    745377    }
    746378
     
    797429        AudioPlayer.reset();
    798430        repaint();
    799     }
    800 
    801     /**
    802      * Gets the index of the layer in the layer list.
    803      * <p>
    804      * To be removed: end of 2016.
    805      * @param layer The layer to search for.
    806      * @return The index in the list.
    807      * @throws IllegalArgumentException if that layer does not belong to this view.
    808      * @deprecated Access the layer list using {@link Main#getLayerManager()} instead.
    809      */
    810     @Deprecated
    811     public int getLayerPos(Layer layer) {
    812         int curLayerPos = layerManager.getLayers().indexOf(layer);
    813         if (curLayerPos == -1)
    814             throw new IllegalArgumentException(tr("Layer not in list."));
    815         return curLayerPos;
    816     }
    817 
    818     /**
    819      * Creates a list of the visible layers in Z-Order, the layer with the lowest Z-Order
    820      * first, layer with the highest Z-Order last.
    821      * <p>
    822      * The active data layer is pulled above all adjacent data layers.
    823      * <p>
    824      * To be removed: end of 2016.
    825      *
    826      * @return a list of the visible in Z-Order, the layer with the lowest Z-Order
    827      * first, layer with the highest Z-Order last.
    828      * @deprecated Access the layer list using {@link Main#getLayerManager()} instead.
    829      */
    830     @Deprecated
    831     public List<Layer> getVisibleLayersInZOrder() {
    832         return layerManager.getVisibleLayersInZOrder();
    833431    }
    834432
     
    1049647    }
    1050648
    1051     /**
    1052      * Returns all layers. To be removed: end of 2016.
    1053      *
    1054      * @return An unmodifiable collection of all layers
    1055      * @deprecated Use {@link LayerManager#getLayers()} instead.
    1056      */
    1057     @Deprecated
    1058     public Collection<Layer> getAllLayers() {
    1059         return layerManager.getLayers();
    1060     }
    1061 
    1062     /**
    1063      * Returns all layers as list. To be removed: end of 2016.
    1064      *
    1065      * @return An unmodifiable ordered list of all layers
    1066      * @deprecated Use {@link LayerManager#getLayers()} instead.
    1067      */
    1068     @Deprecated
    1069     public List<Layer> getAllLayersAsList() {
    1070         return layerManager.getLayers();
    1071     }
    1072 
    1073     /**
    1074      * Replies an unmodifiable list of layers of a certain type. To be removed: end of 2016.
    1075      *
    1076      * Example:
    1077      * <pre>
    1078      *     List&lt;WMSLayer&gt; wmsLayers = getLayersOfType(WMSLayer.class);
    1079      * </pre>
    1080      *
    1081      * @param <T> layer type
    1082      *
    1083      * @param ofType The layer type.
    1084      * @return an unmodifiable list of layers of a certain type.
    1085      * @deprecated Use {@link LayerManager#getLayersOfType(Class)} instead.
    1086      */
    1087     @Deprecated
    1088     public <T extends Layer> List<T> getLayersOfType(Class<T> ofType) {
    1089         return layerManager.getLayersOfType(ofType);
    1090     }
    1091 
    1092     /**
    1093      * Replies the number of layers managed by this map view. To be removed: end of 2016.
    1094      * <p>
    1095      *
    1096      * @return the number of layers managed by this map view
    1097      * @deprecated Use {@link Main#getLayerManager()}.getLayers().size() instead.
    1098      */
    1099     @Deprecated
    1100     public int getNumLayers() {
    1101         return getAllLayers().size();
    1102     }
    1103 
    1104     /**
    1105      * Replies true if there is at least one layer in this map view
    1106      * <p>
    1107      *
    1108      * @return true if there is at least one layer in this map view
    1109      * @deprecated Use !{@link Main#getLayerManager()}.getLayers().isEmpty() instead.
    1110      */
    1111     @Deprecated
    1112     public boolean hasLayers() {
    1113         return getNumLayers() > 0;
    1114     }
    1115 
    1116     /**
    1117      * Sets the active layer to <code>layer</code>. If <code>layer</code> is an instance
    1118      * of {@link OsmDataLayer} also sets editLayer to <code>layer</code>.
    1119      * <p>
    1120      *
    1121      * @param layer the layer to be activate; must be one of the layers in the list of layers
    1122      * @throws IllegalArgumentException if layer is not in the list of layers
    1123      * @deprecated Use !{@link Main#getLayerManager()}.setActiveLayer() instead.
    1124      */
    1125     @Deprecated
    1126     public void setActiveLayer(Layer layer) {
    1127         layerManager.setActiveLayer(layer);
    1128     }
    1129 
    1130     /**
    1131      * Replies the currently active layer
    1132      * <p>
    1133      *
    1134      * @return the currently active layer (may be null)
    1135      * @deprecated Use !{@link Main#getLayerManager()}.getActiveLayer() instead.
    1136      */
    1137     @Deprecated
    1138     public Layer getActiveLayer() {
    1139         return layerManager.getActiveLayer();
    1140     }
    1141 
    1142649    @Override
    1143650    public void activeOrEditLayerChanged(ActiveLayerChangeEvent e) {
     
    1164671
    1165672    /**
    1166      * Replies the current edit layer, if any
    1167      * <p>
    1168      *
    1169      * @return the current edit layer. May be null.
    1170      * @deprecated Use !{@link Main#getLayerManager()}.getEditLayer() instead. To be made private: end of 2016.
    1171      */
    1172     @Deprecated
    1173     public OsmDataLayer getEditLayer() {
    1174         return layerManager.getEditLayer();
    1175     }
    1176 
    1177     /**
    1178      * replies true if the list of layers managed by this map view contain layer
    1179      * <p>
    1180      *
    1181      * @param layer the layer
    1182      * @return true if the list of layers managed by this map view contain layer
    1183      * @deprecated Use !{@link Main#getLayerManager()}.containsLayer() instead.
    1184      */
    1185     @Deprecated
    1186     public boolean hasLayer(Layer layer) {
    1187         return layerManager.containsLayer(layer);
    1188     }
    1189 
    1190     /**
    1191673     * Adds a new temporary layer.
    1192674     * <p>
     
    1241723                invalidatedListener.invalidate(l);
    1242724            }
    1243         }
    1244     }
    1245 
    1246     /**
    1247      * Sets the title of the JOSM main window, adding a star if there are dirty layers.
    1248      * @see Main#parent
    1249      * @deprecated Replaced by {@link MainFrame#refreshTitle()}. The {@link MainFrame} should handle this by itself.
    1250      */
    1251     @Deprecated
    1252     protected void refreshTitle() {
    1253         if (Main.parent != null) {
    1254             ((MainFrame) Main.parent).refreshTitle();
    1255725        }
    1256726    }
  • trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java

    r10965 r10972  
    304304    }
    305305
    306     /**
    307      * Returns current data set. To be removed: end of 2016.
    308      * @return current data set
    309      * @deprecated Use {@link Main#getLayerManager()}.getEditDataSet() instead.
    310      */
    311     @Deprecated
    312     protected DataSet getCurrentDataSet() {
    313         return Main.getLayerManager().getEditDataSet();
    314     }
    315 
    316306    protected void updateLocationState() {
    317307        if (isVisibleOnScreen()) {
  • trunk/src/org/openstreetmap/josm/gui/layer/Layer.java

    r10959 r10972  
    182182
    183183    /**
    184      * Return a Color for this layer. Return null when no color specified.
    185      * @param ignoreCustom Custom color should return null, as no default color
    186      *      is used. When this is true, then even for custom coloring the base
    187      *      color is returned - mainly for layer internal use.
    188      * @return layer color
    189      * @deprecated Use the new {@link #getColorProperty()}. To be removed end of 2016.
    190      */
    191     @Deprecated
    192     public Color getColor(boolean ignoreCustom) {
    193         return null;
    194     }
    195 
    196     /**
    197184     * Gets the color property to use for this layer.
    198185     * @return The color property.
     
    619606
    620607    /**
    621      * @return bytes that the tile will use. Needed for resource management
    622      * @deprecated Not used any more.
    623      */
    624     @Deprecated
    625     protected long estimateMemoryUsage() {
    626         return 0;
    627     }
    628 
    629     /**
    630608     * Gets the strategy that specifies where this layer should be inserted in a layer list.
    631609     * @return That strategy.
  • trunk/src/org/openstreetmap/josm/gui/layer/MainLayerManager.java

    r10653 r10972  
    149149    private final List<ActiveLayerChangeListener> activeLayerChangeListeners = new CopyOnWriteArrayList<>();
    150150    private final List<LayerAvailabilityListener> layerAvailabilityListeners = new CopyOnWriteArrayList<>();
    151 
    152     /**
    153      * Adds a active/edit layer change listener
    154      *
    155      * @param listener the listener.
    156      * @param initialFire use {@link #addAndFireActiveLayerChangeListener(ActiveLayerChangeListener)} instead.
    157      * @deprecated Do not use the second parameter. To be removed in a few weeks.
    158      */
    159     @Deprecated
    160     public synchronized void addActiveLayerChangeListener(ActiveLayerChangeListener listener, boolean initialFire) {
    161         if (initialFire) {
    162             addAndFireActiveLayerChangeListener(listener);
    163         } else {
    164             addActiveLayerChangeListener(listener);
    165         }
    166     }
    167151
    168152    /**
  • trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java

    r10959 r10972  
    280280     *
    281281     * @param listener the listener. Ignored if null or already registered.
    282      * @since 5519
    283      * @deprecated Method name contains a typo, use {@link #removeLayerStateChangeListener(LayerStateChangeListener)}.
    284      */
    285     @Deprecated
    286     public void removeLayerPropertyChangeListener(LayerStateChangeListener listener) {
    287         removeLayerStateChangeListener(listener);
    288     }
    289 
    290     /**
    291      * Removes a layer state change listener
    292      *
    293      * @param listener the listener. Ignored if null or already registered.
    294282     * @since 10340
    295283     */
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r10931 r10972  
    88import java.awt.Color;
    99import java.awt.Font;
    10 import java.awt.datatransfer.Clipboard;
    11 import java.awt.datatransfer.Transferable;
    1210import java.awt.font.FontRenderContext;
    1311import java.awt.font.GlyphVector;
     
    5452import java.util.regex.Matcher;
    5553import java.util.regex.Pattern;
    56 import java.util.stream.Stream;
    5754import java.util.zip.GZIPInputStream;
    5855import java.util.zip.ZipEntry;
     
    6966import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
    7067import org.openstreetmap.josm.Main;
    71 import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    7268import org.w3c.dom.Document;
    7369import org.xml.sax.InputSource;
     
    9995    private Utils() {
    10096        // Hide default constructor for utils classes
    101     }
    102 
    103     /**
    104      * Tests whether {@code predicate} applies to at least one element from {@code collection}.
    105      * <p>
    106      * @param <T> type of items
    107      * @param collection the collection
    108      * @param predicate the predicate
    109      * @return {@code true} if {@code predicate} applies to at least one element from {@code collection}
    110      * @deprecated use {@link Stream#anyMatch(Predicate)} instead.
    111      */
    112     @Deprecated
    113     public static <T> boolean exists(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    114         for (T item : collection) {
    115             if (predicate.test(item)) {
    116                 return true;
    117             }
    118         }
    119         return false;
    120     }
    121 
    122     /**
    123      * Tests whether {@code predicate} applies to all elements from {@code collection}.
    124      * <p>
    125      * @param <T> type of items
    126      * @param collection the collection
    127      * @param predicate the predicate
    128      * @return {@code true} if {@code predicate} applies to all elements from {@code collection}
    129      * @deprecated use {@link Stream#allMatch(Predicate)} instead.
    130      */
    131     @Deprecated
    132     public static <T> boolean forAll(Iterable<? extends T> collection, Predicate<? super T> predicate) {
    133         return !exists(collection, predicate.negate());
    13497    }
    13598
     
    580543        }
    581544        return true;
    582     }
    583 
    584     /**
    585      * Copies the string {@code s} to system clipboard.
    586      * @param s string to be copied to clipboard.
    587      * @return true if succeeded, false otherwise.
    588      * @deprecated Use {@link ClipboardUtils#copyString(String)}. To be removed end of 2016.
    589      */
    590     @Deprecated
    591     public static boolean copyToClipboard(String s) {
    592         return ClipboardUtils.copyString(s);
    593     }
    594 
    595     /**
    596      * Extracts clipboard content as {@code Transferable} object.
    597      * @param clipboard clipboard from which contents are retrieved
    598      * @return clipboard contents if available, {@code null} otherwise.
    599      * @since 8429
    600      * @deprecated Use {@link ClipboardUtils#getClipboardContent(Clipboard)} instead. To be removed end of 2016.
    601      */
    602     @Deprecated
    603     public static Transferable getTransferableContent(Clipboard clipboard) {
    604         return ClipboardUtils.getClipboardContent(clipboard);
    605     }
    606 
    607     /**
    608      * Extracts clipboard content as string.
    609      * @return string clipboard contents if available, {@code null} otherwise.
    610      * @deprecated Use {@link ClipboardUtils#getClipboardStringContent()}. To be removed end of 2016
    611      */
    612     @Deprecated
    613     public static String getClipboardContent() {
    614         return ClipboardUtils.getClipboardStringContent();
    615545    }
    616546
Note: See TracChangeset for help on using the changeset viewer.