Changeset 33794 in osm


Ignore:
Timestamp:
2017-11-06T23:17:11+01:00 (7 years ago)
Author:
donvip
Message:

update to JOSM 12840

Location:
applications/editors/josm/plugins/routing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/routing/build.xml

    r32680 r33794  
    55    <property name="commit.message" value="added one-way support in roundabouts"/>
    66    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    7     <property name="plugin.main.version" value="10580"/>
     7    <property name="plugin.main.version" value="12840"/>
    88
    99    <!--
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java

    r32768 r33794  
    1313import org.jgrapht.alg.DijkstraShortestPath;
    1414import org.jgrapht.graph.DirectedWeightedMultigraph;
    15 import org.openstreetmap.josm.Main;
    1615import org.openstreetmap.josm.data.coor.LatLon;
    1716import org.openstreetmap.josm.data.osm.DataSet;
    1817import org.openstreetmap.josm.data.osm.Node;
    1918import org.openstreetmap.josm.data.osm.Way;
     19import org.openstreetmap.josm.gui.MainApplication;
    2020
    2121import com.innovant.josm.jrt.osm.OsmEdge;
     
    318318        Graph<Node, OsmEdge> g;
    319319        double totalWeight = 0;
    320         RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     320        RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    321321        RoutingModel routingModel = layer.getRoutingModel();
    322322
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java

    r32768 r33794  
    2626import org.openstreetmap.josm.data.osm.Way;
    2727import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;
     28import org.openstreetmap.josm.gui.MainApplication;
    2829import org.openstreetmap.josm.gui.MapView;
    2930import org.openstreetmap.josm.gui.NavigatableComponent;
     
    102103
    103104        this.routingModel.routingGraph.createGraph();    /* construct the graph right after we we create the layer */
    104         Main.map.repaint();                            /* update MapView */
     105        invalidate();                            /* update MapView */
    105106    }
    106107
     
    135136                if (n.isDeleted() || n.isIncomplete()) continue;
    136137
    137                 Point P = Main.map.mapView.getPoint(n);
     138                Point P = MainApplication.getMap().mapView.getPoint(n);
    138139                double dist = p.distance(P);
    139140                if (dist < snapDistance) {
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java

    r32768 r33794  
    99import org.apache.log4j.Logger;
    1010import org.apache.log4j.xml.DOMConfigurator;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent;
    1312import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter;
     
    1514import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode;
    1615import org.openstreetmap.josm.gui.IconToggleButton;
     16import org.openstreetmap.josm.gui.MainApplication;
    1717import org.openstreetmap.josm.gui.MapFrame;
    1818import org.openstreetmap.josm.gui.layer.Layer;
     
    2525import org.openstreetmap.josm.plugins.Plugin;
    2626import org.openstreetmap.josm.plugins.PluginInformation;
     27import org.openstreetmap.josm.tools.Logging;
    2728
    2829import com.innovant.josm.plugin.routing.actions.AddRouteNodeAction;
     
    128129        menu = new RoutingMenu();
    129130        // Register this class as LayerChangeListener
    130         Main.getLayerManager().addLayerChangeListener(this);
     131        MainApplication.getLayerManager().addLayerChangeListener(this);
    131132        DatasetEventManager.getInstance().addDatasetListener(datasetAdapter, FireMode.IN_EDT_CONSOLIDATED);
    132133        logger.debug("Finished loading plugin");
     
    150151
    151152    public void addLayer() {
    152         OsmDataLayer osmLayer = Main.getLayerManager().getEditLayer();
     153        OsmDataLayer osmLayer = MainApplication.getLayerManager().getEditLayer();
    153154        if (osmLayer != null) {
    154155            RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer);
    155156            layers.add(layer);
    156             Main.getLayerManager().addLayer(layer);
     157            MainApplication.getLayerManager().addLayer(layer);
    157158        }
    158159    }
     
    162163        if (newFrame != null) {
    163164            // Create plugin map modes
    164             addRouteNodeAction = new AddRouteNodeAction(newFrame);
    165             removeRouteNodeAction = new RemoveRouteNodeAction(newFrame);
    166             moveRouteNodeAction = new MoveRouteNodeAction(newFrame);
     165            addRouteNodeAction = new AddRouteNodeAction();
     166            removeRouteNodeAction = new RemoveRouteNodeAction();
     167            moveRouteNodeAction = new MoveRouteNodeAction();
    167168            // Create plugin buttons and add them to the toolbar
    168169            addRouteNodeButton = new IconToggleButton(addRouteNodeAction);
     
    216217            menu.enableRestOfItems();
    217218            // Set layer on top and select layer, also refresh toggleDialog to reflect selection
    218             Main.map.mapView.moveLayer(newLayer, 0);
     219            MainApplication.getMap().mapView.moveLayer(newLayer, 0);
    219220            logger.debug("Added routing layer.");
    220221        }
     
    241242                    try {
    242243                        // Remove layer
    243                         Main.getLayerManager().removeLayer(layersArray[i]);
     244                        MainApplication.getLayerManager().removeLayer(layersArray[i]);
    244245                    } catch (IllegalArgumentException e) {
    245                         Main.error(e);
     246                        Logging.error(e);
    246247                    }
    247248                }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java

    r32768 r33794  
    77
    88import org.apache.log4j.Logger;
    9 import org.openstreetmap.josm.Main;
    109import org.openstreetmap.josm.actions.mapmode.MapMode;
    1110import org.openstreetmap.josm.data.osm.Node;
    12 import org.openstreetmap.josm.gui.MapFrame;
     11import org.openstreetmap.josm.gui.MainApplication;
    1312import org.openstreetmap.josm.gui.layer.Layer;
    1413import org.openstreetmap.josm.tools.ImageProvider;
     
    3534     * @param mapFrame map frame
    3635     */
    37     public AddRouteNodeAction(MapFrame mapFrame) {
     36    public AddRouteNodeAction() {
    3837        // TODO Use constructor with shortcut
    3938        super(tr("Routing"), "add",
    4039                tr("Click to add destination."),
    41                 mapFrame, ImageProvider.getCursor("crosshair", null));
     40                ImageProvider.getCursor("crosshair", null));
    4241    }
    4342
    4443    @Override public void enterMode() {
    4544        super.enterMode();
    46         Main.map.mapView.addMouseListener(this);
     45        MainApplication.getMap().mapView.addMouseListener(this);
    4746    }
    4847
    4948    @Override public void exitMode() {
    5049        super.exitMode();
    51         Main.map.mapView.removeMouseListener(this);
     50        MainApplication.getMap().mapView.removeMouseListener(this);
    5251    }
    5352
     
    5756            // Search for nearest highway node
    5857            Node node = null;
    59             if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    60                 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     58            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     59                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    6160                node = layer.getNearestHighwayNode(e.getPoint());
    6261                if (node == null) {
     
    6968            }
    7069        }
    71         Main.map.repaint();
     70        MainApplication.getMap().repaint();
    7271    }
    7372
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java

    r32768 r33794  
    99
    1010import org.apache.log4j.Logger;
    11 import org.openstreetmap.josm.Main;
    1211import org.openstreetmap.josm.actions.mapmode.MapMode;
    1312import org.openstreetmap.josm.data.osm.Node;
    14 import org.openstreetmap.josm.gui.MapFrame;
     13import org.openstreetmap.josm.gui.MainApplication;
    1514import org.openstreetmap.josm.gui.layer.Layer;
    1615import org.openstreetmap.josm.tools.ImageProvider;
     
    4948     * @param mapFrame map frame
    5049     */
    51     public MoveRouteNodeAction(MapFrame mapFrame) {
     50    public MoveRouteNodeAction() {
    5251        // TODO Use constructor with shortcut
    5352        super(tr("Routing"), "move",
    5453                tr("Click and drag to move destination"),
    55                 mapFrame, ImageProvider.getCursor("normal", "move"));
     54                ImageProvider.getCursor("normal", "move"));
    5655    }
    5756
    5857    @Override public void enterMode() {
    5958        super.enterMode();
    60         Main.map.mapView.addMouseListener(this);
     59        MainApplication.getMap().mapView.addMouseListener(this);
    6160    }
    6261
    6362    @Override public void exitMode() {
    6463        super.exitMode();
    65         Main.map.mapView.removeMouseListener(this);
     64        MainApplication.getMap().mapView.removeMouseListener(this);
    6665    }
    6766
     
    6968        // If left button is pressed
    7069        if (e.getButton() == MouseEvent.BUTTON1) {
    71             if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     70            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    7271                requestFocusInMapView();
    73                 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     72                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    7473                RoutingModel routingModel = layer.getRoutingModel();
    7574                // Search for the nearest node in the list
     
    7978                for (int i = 0; i < nl.size(); i++) {
    8079                    Node node = nl.get(i);
    81                     double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint());
     80                    double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
    8281                    if (d < dmax) {
    8382                        dmax = d;
     
    102101
    103102    private void searchAndReplaceNode(Point point) {
    104         if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    105             RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     103        if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     104            RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    106105            RoutingModel routingModel = layer.getRoutingModel();
    107106            RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog();
     
    118117            routingModel.insertNode(index, node);
    119118            routingDialog.insertNode(index, node);
    120             Main.map.repaint();
     119            MainApplication.getMap().repaint();
    121120        }
    122121    }
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java

    r32768 r33794  
    88
    99import org.apache.log4j.Logger;
    10 import org.openstreetmap.josm.Main;
    1110import org.openstreetmap.josm.actions.mapmode.MapMode;
    1211import org.openstreetmap.josm.data.osm.Node;
    13 import org.openstreetmap.josm.gui.MapFrame;
     12import org.openstreetmap.josm.gui.MainApplication;
    1413import org.openstreetmap.josm.gui.layer.Layer;
    1514import org.openstreetmap.josm.tools.ImageProvider;
     
    3837    static Logger logger = Logger.getLogger(RoutingLayer.class);
    3938
    40     public RemoveRouteNodeAction(MapFrame mapFrame) {
     39    public RemoveRouteNodeAction() {
    4140        // TODO Use constructor with shortcut
    4241        super(tr("Routing"), "remove",
    4342                tr("Click to remove destination"),
    44                 mapFrame, ImageProvider.getCursor("normal", "delete"));
     43                ImageProvider.getCursor("normal", "delete"));
    4544    }
    4645
    4746    @Override public void enterMode() {
    4847        super.enterMode();
    49         Main.map.mapView.addMouseListener(this);
     48        MainApplication.getMap().mapView.addMouseListener(this);
    5049    }
    5150
    5251    @Override public void exitMode() {
    5352        super.exitMode();
    54         Main.map.mapView.removeMouseListener(this);
     53        MainApplication.getMap().mapView.removeMouseListener(this);
    5554    }
    5655
     
    5857        // If left button is clicked
    5958        if (e.getButton() == MouseEvent.BUTTON1) {
    60             if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    61                 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     59            if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     60                RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    6261                RoutingModel routingModel = layer.getRoutingModel();
    6362                // Search for the nearest node in the list
     
    6766                for (int i = 0; i < nl.size(); i++) {
    6867                    Node node = nl.get(i);
    69                     double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint());
     68                    double d = MainApplication.getMap().mapView.getPoint(node).distanceSq(e.getPoint());
    7069                    if (d < dmax) {
    7170                        dmax = d;
     
    7978                    routingModel.removeNode(index);
    8079                    RoutingPlugin.getInstance().getRoutingDialog().removeNode(index);
    81                     Main.map.repaint();
     80                    MainApplication.getMap().repaint();
    8281                } else {
    8382                    logger.debug("Can't find a node to remove.");
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java

    r32768 r33794  
    1111import javax.swing.JScrollPane;
    1212
    13 import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.data.osm.Node;
     14import org.openstreetmap.josm.gui.MainApplication;
    1515import org.openstreetmap.josm.gui.dialogs.ToggleDialog;
    1616import org.openstreetmap.josm.tools.Shortcut;
     
    101101    public void refresh() {
    102102        clearNodes();
    103         if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    104             RoutingLayer routingLayer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     103        if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     104            RoutingLayer routingLayer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    105105            RoutingModel routingModel = routingLayer.getRoutingModel();
    106106            for (Node n : routingModel.getSelectedNodes()) {
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java

    r32768 r33794  
    1717import javax.swing.JRadioButtonMenuItem;
    1818
    19 import org.openstreetmap.josm.Main;
     19import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.gui.MainMenu;
    2121
     
    4747     */
    4848    public RoutingMenu() {
    49         MainMenu mm = Main.main.menu;
     49        MainMenu mm = MainApplication.getMenu();
    5050        menu = mm.addMenu("Routing", tr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing"));
    5151
     
    6969            @Override
    7070            public void itemStateChanged(ItemEvent e) {
    71                 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    72                     RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     71                if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     72                    RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    7373                    RoutingModel routingModel = layer.getRoutingModel();
    7474                    if (e.getStateChange() == ItemEvent.SELECTED) {
     
    8282                    //FIXME: do not change node but recalculate routing.
    8383                    routingModel.setNodesChanged();
    84                     Main.map.repaint();
     84                    MainApplication.getMap().repaint();
    8585                }
    8686            }
     
    9999            @Override
    100100            public void itemStateChanged(ItemEvent e) {
    101                 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    102                     RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     101                if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     102                    RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    103103                    RoutingModel routingModel = layer.getRoutingModel();
    104104                    if (e.getStateChange() == ItemEvent.SELECTED)
     
    108108                    routingModel.setNodesChanged();
    109109                    routingModel.setOnewayChanged();
    110                     Main.map.repaint();
     110                    MainApplication.getMap().repaint();
    111111                }
    112112            }
     
    120120            @Override
    121121            public void actionPerformed(ActionEvent e) {
    122                 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    123                     RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     122                if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     123                    RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    124124                    RoutingModel routingModel = layer.getRoutingModel();
    125125                    routingModel.reverseNodes();
    126                     Main.map.repaint();
     126                    MainApplication.getMap().repaint();
    127127                }
    128128            }
     
    134134            @Override
    135135            public void actionPerformed(ActionEvent e) {
    136                 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    137                     RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     136                if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     137                    RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    138138                    RoutingModel routingModel = layer.getRoutingModel();
    139139                    // Reset routing nodes and paths
    140140                    routingModel.reset();
    141141                    RoutingPlugin.getInstance().getRoutingDialog().clearNodes();
    142                     Main.map.repaint();
     142                    MainApplication.getMap().repaint();
    143143                }
    144144            }
     
    150150            @Override
    151151            public void actionPerformed(ActionEvent e) {
    152 
    153                 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
    154                     RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();
     152                if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) {
     153                    RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer();
    155154                    RoutingModel routingModel = layer.getRoutingModel();
    156155                    routingModel.routingGraph.resetGraph();
    157156                    routingModel.routingGraph.createGraph();
    158157                }
    159 
    160158            }
    161159        });
    162160        menu.add(regraphMI);
    163 
    164161
    165162        // Initially disabled
  • applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java

    r32768 r33794  
    193193            logger.debug("Loading Default Preferences.");
    194194            for (OsmWayTypes owt : OsmWayTypes.values()) {
    195                 Main.pref.putInteger("routing.profile.default.speed."
     195                Main.pref.putInt("routing.profile.default.speed."
    196196                        + owt.getTag(), owt.getSpeed());
    197197            }
Note: See TracChangeset for help on using the changeset viewer.