Changeset 33794 in osm
- Timestamp:
- 2017-11-06T23:17:11+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/routing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/routing/build.xml
r32680 r33794 5 5 <property name="commit.message" value="added one-way support in roundabouts"/> 6 6 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 7 <property name="plugin.main.version" value="1 0580"/>7 <property name="plugin.main.version" value="12840"/> 8 8 9 9 <!-- -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
r32768 r33794 13 13 import org.jgrapht.alg.DijkstraShortestPath; 14 14 import org.jgrapht.graph.DirectedWeightedMultigraph; 15 import org.openstreetmap.josm.Main;16 15 import org.openstreetmap.josm.data.coor.LatLon; 17 16 import org.openstreetmap.josm.data.osm.DataSet; 18 17 import org.openstreetmap.josm.data.osm.Node; 19 18 import org.openstreetmap.josm.data.osm.Way; 19 import org.openstreetmap.josm.gui.MainApplication; 20 20 21 21 import com.innovant.josm.jrt.osm.OsmEdge; … … 318 318 Graph<Node, OsmEdge> g; 319 319 double totalWeight = 0; 320 RoutingLayer layer = (RoutingLayer) Main .getLayerManager().getActiveLayer();320 RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer(); 321 321 RoutingModel routingModel = layer.getRoutingModel(); 322 322 -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java
r32768 r33794 26 26 import org.openstreetmap.josm.data.osm.Way; 27 27 import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor; 28 import org.openstreetmap.josm.gui.MainApplication; 28 29 import org.openstreetmap.josm.gui.MapView; 29 30 import org.openstreetmap.josm.gui.NavigatableComponent; … … 102 103 103 104 this.routingModel.routingGraph.createGraph(); /* construct the graph right after we we create the layer */ 104 Main.map.repaint(); /* update MapView */105 invalidate(); /* update MapView */ 105 106 } 106 107 … … 135 136 if (n.isDeleted() || n.isIncomplete()) continue; 136 137 137 Point P = Main .map.mapView.getPoint(n);138 Point P = MainApplication.getMap().mapView.getPoint(n); 138 139 double dist = p.distance(P); 139 140 if (dist < snapDistance) { -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java
r32768 r33794 9 9 import org.apache.log4j.Logger; 10 10 import org.apache.log4j.xml.DOMConfigurator; 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 13 12 import org.openstreetmap.josm.data.osm.event.DataSetListenerAdapter; … … 15 14 import org.openstreetmap.josm.data.osm.event.DatasetEventManager.FireMode; 16 15 import org.openstreetmap.josm.gui.IconToggleButton; 16 import org.openstreetmap.josm.gui.MainApplication; 17 17 import org.openstreetmap.josm.gui.MapFrame; 18 18 import org.openstreetmap.josm.gui.layer.Layer; … … 25 25 import org.openstreetmap.josm.plugins.Plugin; 26 26 import org.openstreetmap.josm.plugins.PluginInformation; 27 import org.openstreetmap.josm.tools.Logging; 27 28 28 29 import com.innovant.josm.plugin.routing.actions.AddRouteNodeAction; … … 128 129 menu = new RoutingMenu(); 129 130 // Register this class as LayerChangeListener 130 Main .getLayerManager().addLayerChangeListener(this);131 MainApplication.getLayerManager().addLayerChangeListener(this); 131 132 DatasetEventManager.getInstance().addDatasetListener(datasetAdapter, FireMode.IN_EDT_CONSOLIDATED); 132 133 logger.debug("Finished loading plugin"); … … 150 151 151 152 public void addLayer() { 152 OsmDataLayer osmLayer = Main .getLayerManager().getEditLayer();153 OsmDataLayer osmLayer = MainApplication.getLayerManager().getEditLayer(); 153 154 if (osmLayer != null) { 154 155 RoutingLayer layer = new RoutingLayer(tr("Routing") + " [" + osmLayer.getName() + "]", osmLayer); 155 156 layers.add(layer); 156 Main .getLayerManager().addLayer(layer);157 MainApplication.getLayerManager().addLayer(layer); 157 158 } 158 159 } … … 162 163 if (newFrame != null) { 163 164 // 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(); 167 168 // Create plugin buttons and add them to the toolbar 168 169 addRouteNodeButton = new IconToggleButton(addRouteNodeAction); … … 216 217 menu.enableRestOfItems(); 217 218 // 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); 219 220 logger.debug("Added routing layer."); 220 221 } … … 241 242 try { 242 243 // Remove layer 243 Main .getLayerManager().removeLayer(layersArray[i]);244 MainApplication.getLayerManager().removeLayer(layersArray[i]); 244 245 } catch (IllegalArgumentException e) { 245 Main.error(e);246 Logging.error(e); 246 247 } 247 248 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
r32768 r33794 7 7 8 8 import org.apache.log4j.Logger; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.actions.mapmode.MapMode; 11 10 import org.openstreetmap.josm.data.osm.Node; 12 import org.openstreetmap.josm.gui.Ma pFrame;11 import org.openstreetmap.josm.gui.MainApplication; 13 12 import org.openstreetmap.josm.gui.layer.Layer; 14 13 import org.openstreetmap.josm.tools.ImageProvider; … … 35 34 * @param mapFrame map frame 36 35 */ 37 public AddRouteNodeAction( MapFrame mapFrame) {36 public AddRouteNodeAction() { 38 37 // TODO Use constructor with shortcut 39 38 super(tr("Routing"), "add", 40 39 tr("Click to add destination."), 41 mapFrame,ImageProvider.getCursor("crosshair", null));40 ImageProvider.getCursor("crosshair", null)); 42 41 } 43 42 44 43 @Override public void enterMode() { 45 44 super.enterMode(); 46 Main .map.mapView.addMouseListener(this);45 MainApplication.getMap().mapView.addMouseListener(this); 47 46 } 48 47 49 48 @Override public void exitMode() { 50 49 super.exitMode(); 51 Main .map.mapView.removeMouseListener(this);50 MainApplication.getMap().mapView.removeMouseListener(this); 52 51 } 53 52 … … 57 56 // Search for nearest highway node 58 57 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(); 61 60 node = layer.getNearestHighwayNode(e.getPoint()); 62 61 if (node == null) { … … 69 68 } 70 69 } 71 Main .map.repaint();70 MainApplication.getMap().repaint(); 72 71 } 73 72 -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
r32768 r33794 9 9 10 10 import org.apache.log4j.Logger; 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.actions.mapmode.MapMode; 13 12 import org.openstreetmap.josm.data.osm.Node; 14 import org.openstreetmap.josm.gui.Ma pFrame;13 import org.openstreetmap.josm.gui.MainApplication; 15 14 import org.openstreetmap.josm.gui.layer.Layer; 16 15 import org.openstreetmap.josm.tools.ImageProvider; … … 49 48 * @param mapFrame map frame 50 49 */ 51 public MoveRouteNodeAction( MapFrame mapFrame) {50 public MoveRouteNodeAction() { 52 51 // TODO Use constructor with shortcut 53 52 super(tr("Routing"), "move", 54 53 tr("Click and drag to move destination"), 55 mapFrame,ImageProvider.getCursor("normal", "move"));54 ImageProvider.getCursor("normal", "move")); 56 55 } 57 56 58 57 @Override public void enterMode() { 59 58 super.enterMode(); 60 Main .map.mapView.addMouseListener(this);59 MainApplication.getMap().mapView.addMouseListener(this); 61 60 } 62 61 63 62 @Override public void exitMode() { 64 63 super.exitMode(); 65 Main .map.mapView.removeMouseListener(this);64 MainApplication.getMap().mapView.removeMouseListener(this); 66 65 } 67 66 … … 69 68 // If left button is pressed 70 69 if (e.getButton() == MouseEvent.BUTTON1) { 71 if (Main .getLayerManager().getActiveLayer() instanceof RoutingLayer) {70 if (MainApplication.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 72 71 requestFocusInMapView(); 73 RoutingLayer layer = (RoutingLayer) Main .getLayerManager().getActiveLayer();72 RoutingLayer layer = (RoutingLayer) MainApplication.getLayerManager().getActiveLayer(); 74 73 RoutingModel routingModel = layer.getRoutingModel(); 75 74 // Search for the nearest node in the list … … 79 78 for (int i = 0; i < nl.size(); i++) { 80 79 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()); 82 81 if (d < dmax) { 83 82 dmax = d; … … 102 101 103 102 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(); 106 105 RoutingModel routingModel = layer.getRoutingModel(); 107 106 RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog(); … … 118 117 routingModel.insertNode(index, node); 119 118 routingDialog.insertNode(index, node); 120 Main .map.repaint();119 MainApplication.getMap().repaint(); 121 120 } 122 121 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
r32768 r33794 8 8 9 9 import org.apache.log4j.Logger; 10 import org.openstreetmap.josm.Main;11 10 import org.openstreetmap.josm.actions.mapmode.MapMode; 12 11 import org.openstreetmap.josm.data.osm.Node; 13 import org.openstreetmap.josm.gui.Ma pFrame;12 import org.openstreetmap.josm.gui.MainApplication; 14 13 import org.openstreetmap.josm.gui.layer.Layer; 15 14 import org.openstreetmap.josm.tools.ImageProvider; … … 38 37 static Logger logger = Logger.getLogger(RoutingLayer.class); 39 38 40 public RemoveRouteNodeAction( MapFrame mapFrame) {39 public RemoveRouteNodeAction() { 41 40 // TODO Use constructor with shortcut 42 41 super(tr("Routing"), "remove", 43 42 tr("Click to remove destination"), 44 mapFrame,ImageProvider.getCursor("normal", "delete"));43 ImageProvider.getCursor("normal", "delete")); 45 44 } 46 45 47 46 @Override public void enterMode() { 48 47 super.enterMode(); 49 Main .map.mapView.addMouseListener(this);48 MainApplication.getMap().mapView.addMouseListener(this); 50 49 } 51 50 52 51 @Override public void exitMode() { 53 52 super.exitMode(); 54 Main .map.mapView.removeMouseListener(this);53 MainApplication.getMap().mapView.removeMouseListener(this); 55 54 } 56 55 … … 58 57 // If left button is clicked 59 58 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(); 62 61 RoutingModel routingModel = layer.getRoutingModel(); 63 62 // Search for the nearest node in the list … … 67 66 for (int i = 0; i < nl.size(); i++) { 68 67 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()); 70 69 if (d < dmax) { 71 70 dmax = d; … … 79 78 routingModel.removeNode(index); 80 79 RoutingPlugin.getInstance().getRoutingDialog().removeNode(index); 81 Main .map.repaint();80 MainApplication.getMap().repaint(); 82 81 } else { 83 82 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 11 11 import javax.swing.JScrollPane; 12 12 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.osm.Node; 14 import org.openstreetmap.josm.gui.MainApplication; 15 15 import org.openstreetmap.josm.gui.dialogs.ToggleDialog; 16 16 import org.openstreetmap.josm.tools.Shortcut; … … 101 101 public void refresh() { 102 102 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(); 105 105 RoutingModel routingModel = routingLayer.getRoutingModel(); 106 106 for (Node n : routingModel.getSelectedNodes()) { -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
r32768 r33794 17 17 import javax.swing.JRadioButtonMenuItem; 18 18 19 import org.openstreetmap.josm. Main;19 import org.openstreetmap.josm.gui.MainApplication; 20 20 import org.openstreetmap.josm.gui.MainMenu; 21 21 … … 47 47 */ 48 48 public RoutingMenu() { 49 MainMenu mm = Main .main.menu;49 MainMenu mm = MainApplication.getMenu(); 50 50 menu = mm.addMenu("Routing", tr("Routing"), KeyEvent.VK_O, mm.getDefaultMenuPos(), ht("/Plugin/Routing")); 51 51 … … 69 69 @Override 70 70 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(); 73 73 RoutingModel routingModel = layer.getRoutingModel(); 74 74 if (e.getStateChange() == ItemEvent.SELECTED) { … … 82 82 //FIXME: do not change node but recalculate routing. 83 83 routingModel.setNodesChanged(); 84 Main .map.repaint();84 MainApplication.getMap().repaint(); 85 85 } 86 86 } … … 99 99 @Override 100 100 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(); 103 103 RoutingModel routingModel = layer.getRoutingModel(); 104 104 if (e.getStateChange() == ItemEvent.SELECTED) … … 108 108 routingModel.setNodesChanged(); 109 109 routingModel.setOnewayChanged(); 110 Main .map.repaint();110 MainApplication.getMap().repaint(); 111 111 } 112 112 } … … 120 120 @Override 121 121 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(); 124 124 RoutingModel routingModel = layer.getRoutingModel(); 125 125 routingModel.reverseNodes(); 126 Main .map.repaint();126 MainApplication.getMap().repaint(); 127 127 } 128 128 } … … 134 134 @Override 135 135 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(); 138 138 RoutingModel routingModel = layer.getRoutingModel(); 139 139 // Reset routing nodes and paths 140 140 routingModel.reset(); 141 141 RoutingPlugin.getInstance().getRoutingDialog().clearNodes(); 142 Main .map.repaint();142 MainApplication.getMap().repaint(); 143 143 } 144 144 } … … 150 150 @Override 151 151 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(); 155 154 RoutingModel routingModel = layer.getRoutingModel(); 156 155 routingModel.routingGraph.resetGraph(); 157 156 routingModel.routingGraph.createGraph(); 158 157 } 159 160 158 } 161 159 }); 162 160 menu.add(regraphMI); 163 164 161 165 162 // Initially disabled -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java
r32768 r33794 193 193 logger.debug("Loading Default Preferences."); 194 194 for (OsmWayTypes owt : OsmWayTypes.values()) { 195 Main.pref.putInt eger("routing.profile.default.speed."195 Main.pref.putInt("routing.profile.default.speed." 196 196 + owt.getTag(), owt.getSpeed()); 197 197 }
Note:
See TracChangeset
for help on using the changeset viewer.