Changeset 33794 in osm for applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions
- Timestamp:
- 2017-11-06T23:17:11+01:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
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.");
Note:
See TracChangeset
for help on using the changeset viewer.