Ignore:
Timestamp:
2014-04-22T01:06:55+02:00 (6 years ago)
Author:
Don-vip
Message:

cleanup/refactor of NavigatableComponent

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

Legend:

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

    r6643 r6992  
    1919
    2020import org.openstreetmap.josm.Main;
     21import org.openstreetmap.josm.data.ViewportData;
    2122import org.openstreetmap.josm.gui.HelpAwareOptionPane;
    22 import org.openstreetmap.josm.gui.NavigatableComponent.ViewportData;
    2323import org.openstreetmap.josm.gui.PleaseWaitRunnable;
    2424import org.openstreetmap.josm.gui.layer.Layer;
  • trunk/src/org/openstreetmap/josm/actions/mapmode/ParallelWayAction.java

    r6792 r6992  
    2525import org.openstreetmap.josm.Main;
    2626import org.openstreetmap.josm.data.Bounds;
     27import org.openstreetmap.josm.data.SystemOfMeasurement;
    2728import org.openstreetmap.josm.data.Preferences.PreferenceChangeEvent;
    2829import org.openstreetmap.josm.data.Preferences.PreferenceChangedListener;
     
    3637import org.openstreetmap.josm.gui.MapView;
    3738import org.openstreetmap.josm.gui.NavigatableComponent;
    38 import org.openstreetmap.josm.gui.NavigatableComponent.SystemOfMeasurement;
    3939import org.openstreetmap.josm.gui.layer.Layer;
    4040import org.openstreetmap.josm.gui.layer.MapViewPaintable;
     
    429429            double snapDistance;
    430430            SystemOfMeasurement som = NavigatableComponent.getSystemOfMeasurement();
    431             if (som.equals(NavigatableComponent.CHINESE_SOM)) {
    432                 snapDistance = snapDistanceChinese * NavigatableComponent.CHINESE_SOM.aValue;
    433             } else if (som.equals(NavigatableComponent.IMPERIAL_SOM)) {
    434                 snapDistance = snapDistanceImperial * NavigatableComponent.IMPERIAL_SOM.aValue;
    435             } else if (som.equals(NavigatableComponent.NAUTICAL_MILE_SOM)) {
    436                 snapDistance = snapDistanceNautical * NavigatableComponent.NAUTICAL_MILE_SOM.aValue;
     431            if (som.equals(SystemOfMeasurement.CHINESE)) {
     432                snapDistance = snapDistanceChinese * SystemOfMeasurement.CHINESE.aValue;
     433            } else if (som.equals(SystemOfMeasurement.IMPERIAL)) {
     434                snapDistance = snapDistanceImperial * SystemOfMeasurement.IMPERIAL.aValue;
     435            } else if (som.equals(SystemOfMeasurement.NAUTICAL_MILE)) {
     436                snapDistance = snapDistanceNautical * SystemOfMeasurement.NAUTICAL_MILE.aValue;
    437437            } else {
    438438                snapDistance = snapDistanceMetric; // Metric system by default
  • trunk/src/org/openstreetmap/josm/actions/mapmode/SelectAction.java

    r6957 r6992  
    4848import org.openstreetmap.josm.gui.MapFrame;
    4949import org.openstreetmap.josm.gui.MapView;
    50 import org.openstreetmap.josm.gui.NavigatableComponent;
    5150import org.openstreetmap.josm.gui.SelectionManager;
    5251import org.openstreetmap.josm.gui.SelectionManager.SelectionEnded;
     
    248247     */
    249248    private boolean giveUserFeedback(MouseEvent e, int modifiers) {
    250         Collection<OsmPrimitive> c = MapView.asColl(
     249        Collection<OsmPrimitive> c = asColl(
    251250                mv.getNearestNodeOrWay(e.getPoint(), OsmPrimitive.isSelectablePredicate, true));
    252251
     
    431430            //  if nothing was selected, select primitive under cursor for scaling or rotating
    432431            if (getCurrentDataSet().getSelected().isEmpty()) {
    433                 getCurrentDataSet().setSelected(MapView.asColl(nearestPrimitive));
     432                getCurrentDataSet().setSelected(asColl(nearestPrimitive));
    434433            }
    435434
     
    446445            }
    447446            OsmPrimitive toSelect = cycleManager.cycleSetup(nearestPrimitive, e.getPoint());
    448             selectPrims(NavigatableComponent.asColl(toSelect), false, false);
     447            selectPrims(asColl(toSelect), false, false);
    449448            useLastMoveCommandIfPossible();
    450449            // Schedule a timer to update status line "initialMoveDelay+1" ms in the future
     
    522521                needsRepaint = true;
    523522            }
    524             mv.setNewCursor(getCursor(MapView.asColl(p)), this);
     523            mv.setNewCursor(getCursor(asColl(p)), this);
    525524            // also update the stored mouse event, so we can display the correct cursor
    526525            // when dragging a node onto another one and then press CTRL to merge
     
    953952                if (!(alt || multipleMatchesParameter)) {
    954953                    // no real cycling, just one element in cycle list
    955                     cycleList = MapView.asColl(osm);
     954                    cycleList = asColl(osm);
    956955
    957956                    if (waitForMouseUpParameter) {
     
    10601059            }
    10611060            // return one-element collection with one element to be selected (or added  to selection)
    1062             return MapView.asColl(nxt);
     1061            return asColl(nxt);
    10631062        }
    10641063    }
     
    11621161        }
    11631162    }
     1163
     1164    /**
     1165     * @return o as collection of o's type.
     1166     */
     1167    protected static <T> Collection<T> asColl(T o) {
     1168        if (o == null)
     1169            return Collections.emptySet();
     1170        return Collections.singleton(o);
     1171    }
    11641172}
Note: See TracChangeset for help on using the changeset viewer.