Changeset 32768 in osm for applications/editors/josm/plugins/routing/src/com/innovant
- Timestamp:
- 2016-08-04T02:50:46+02:00 (8 years ago)
- Location:
- applications/editors/josm/plugins/routing/src/com/innovant/josm
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/EdgeIterator.java
r23189 r32768 1 // License: GPL. For details, see LICENSE file. 1 2 package com.innovant.josm.jrt.core; 2 3 3 4 public interface EdgeIterator { 4 5 5 publicboolean hasNext();6 boolean hasNext(); 6 7 7 publicRoutingEdge next();8 RoutingEdge next(); 8 9 9 10 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingEdge.java
r23189 r32768 1 // License: GPL. For details, see LICENSE file. 1 2 package com.innovant.josm.jrt.core; 2 3 … … 5 6 public interface RoutingEdge { 6 7 7 publicLatLon fromLatLon();8 LatLon fromLatLon(); 8 9 9 publicLatLon toLatLon();10 LatLon toLatLon(); 10 11 11 publicObject fromV();12 Object fromV(); 12 13 13 publicObject toV();14 Object toV(); 14 15 15 publicdouble getLength();16 double getLength(); 16 17 17 publicvoid setLength(double length);18 void setLength(double length); 18 19 19 publicdouble getSpeed();20 double getSpeed(); 20 21 21 publicvoid setSpeed(double speed);22 void setSpeed(double speed); 22 23 23 publicboolean isOneway();24 boolean isOneway(); 24 25 25 publicvoid setOneway(boolean isOneway);26 void setOneway(boolean isOneway); 26 27 27 28 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraph.java
r32348 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.jrt.core; 29 3 … … 68 42 public enum Algorithm { 69 43 ROUTING_ALG_DIJKSTRA, ROUTING_ALG_BELLMANFORD 70 } ;44 } 71 45 72 46 /** 73 47 * Search criteria for the route. 74 48 */ 75 public enum RouteType {FASTEST,SHORTEST}; 49 public enum RouteType { 50 FASTEST, 51 SHORTEST 52 } 76 53 77 54 /** … … 91 68 92 69 private static Collection<String> excludedHighwayValues = Arrays.asList(new String[]{ 93 "bus_stop", "traffic_signals", "street_lamp", "stop", "construction",94 "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned"70 "bus_stop", "traffic_signals", "street_lamp", "stop", "construction", 71 "platform", "give_way", "proposed", "milestone", "speed_camera", "abandoned" 95 72 }); 96 73 97 74 /** 98 75 * Graph state … … 108 85 // private WeightedMultigraph<Node, OsmEdge> graph; 109 86 private Graph<Node, OsmEdge> graph; 110 private RoutingGraphDelegator rgDelegator =null;87 private RoutingGraphDelegator rgDelegator = null; 111 88 112 89 … … 114 91 * Graph getter 115 92 */ 116 public Graph<Node, OsmEdge> getGraph() {93 public Graph<Node, OsmEdge> getGraph() { 117 94 return graph; 118 119 } 120 121 122 private void addEdgeBidirectional( Way way, Node from, Node to){ 123 addEdge(way,from,to); 124 addEdge(way,to,from); 125 } 126 127 private void addEdgeReverseOneway( Way way, Node from, Node to){ 128 addEdge(way,to,from); 129 } 130 131 private void addEdgeNormalOneway( Way way, Node from, Node to){ 132 addEdge(way,from,to); 95 } 96 97 private void addEdgeBidirectional(Way way, Node from, Node to) { 98 addEdge(way, from, to); 99 addEdge(way, to, from); 100 } 101 102 private void addEdgeReverseOneway(Way way, Node from, Node to) { 103 addEdge(way, to, from); 104 } 105 106 private void addEdgeNormalOneway(Way way, Node from, Node to) { 107 addEdge(way, from, to); 133 108 } 134 109 … … 136 111 * Speeds 137 112 */ 138 private Map<String, Double> waySpeeds;113 private Map<String, Double> waySpeeds; 139 114 140 115 /** … … 145 120 this.graph = null; 146 121 this.data = data; 147 routeType =RouteType.SHORTEST;148 routingProfile =new RoutingProfile("default");122 routeType = RouteType.SHORTEST; 123 routingProfile = new RoutingProfile("default"); 149 124 routingProfile.setOnewayUse(true); // Don't ignore oneways by default 150 125 this.setWaySpeeds(routingProfile.getWaySpeeds()); … … 154 129 /** 155 130 * Create OSM graph for routing 156 *157 * @return158 131 */ 159 132 public void createGraph() { … … 161 134 logger.debug("Creating Graph..."); 162 135 graph = new DirectedWeightedMultigraph<>(OsmEdge.class); 163 rgDelegator =new RoutingGraphDelegator(graph);136 rgDelegator = new RoutingGraphDelegator(graph); 164 137 rgDelegator.setRouteType(this.routeType); 165 138 // iterate all ways and segments for all nodes: … … 178 151 /* 179 152 * Assume node is A B C D E. The procedure should be 180 * 153 * 181 154 * case 1 - bidirectional ways: 182 155 * 1) Add vertex A B C D E 183 156 * 2) Link A<->B, B<->C, C<->D, D<->E as Edges 184 * 157 * 185 158 * case 2 - oneway reverse: 186 159 * 1) Add vertex A B C D E 187 160 * 2) Link B->A,C->B,D->C,E->D as Edges. result: A<-B<-C<-D<-E 188 * 161 * 189 162 * case 3 - oneway normal: 190 163 * 1) Add vertex A B C D E 191 164 * 2) Link A->B, B->C, C->D, D->E as Edges. result: A->B->C->D->E 192 * 193 * 165 * 166 * 194 167 */ 195 168 … … 244 217 /** 245 218 * Compute weight and add edge to the graph 246 * @param way 247 * @param from 248 * @param to 249 */ 250 private void addEdge(Way way,Node from, Node to) { 219 */ 220 private void addEdge(Way way, Node from, Node to) { 251 221 LatLon fromLL = from.getCoor(); 252 222 LatLon toLL = from.getCoor(); … … 263 233 setWeight(edge, length); 264 234 logger.debug("edge for way " + way.getId() 265 266 267 ((DirectedWeightedMultigraph<Node, OsmEdge>)graph).setEdgeWeight(edge, weight);235 + "(from node " + from.getId() + " to node " 236 + to.getId() + ") has weight: " + weight); 237 ((DirectedWeightedMultigraph<Node, OsmEdge>) graph).setEdgeWeight(edge, weight); 268 238 } 269 239 … … 275 245 * @param way 276 246 * the way. 277 * @return278 247 */ 279 248 private void setWeight(OsmEdge osmedge, double length) { … … 292 261 * @param way 293 262 * the way. 294 * @return295 263 */ 296 264 private double getWeight(Way way, double length) { … … 302 270 // Same speed for all types of ways 303 271 if (this.waySpeeds.containsKey("residential")) 304 speed =this.waySpeeds.get("residential");272 speed = this.waySpeeds.get("residential"); 305 273 break; 306 274 case FASTEST: 307 275 // Each type of way may have a different speed 308 276 if (this.waySpeeds.containsKey(way.get("highway"))) 309 speed =this.waySpeeds.get(way.get("highway"));277 speed = this.waySpeeds.get(way.get("highway")); 310 278 logger.debug("Speed="+speed); 311 279 break; … … 327 295 //if (!way.isTagged()) <---not needed me thinks 328 296 // return false; 329 297 330 298 String highway = way.get("highway"); 331 299 … … 348 316 public List<OsmEdge> applyAlgorithm(List<Node> nodes, Algorithm algorithm) { 349 317 List<OsmEdge> path = new ArrayList<>(); 350 Graph<Node, OsmEdge> g;318 Graph<Node, OsmEdge> g; 351 319 double totalWeight = 0; 352 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();320 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 353 321 RoutingModel routingModel = layer.getRoutingModel(); 354 322 … … 405 373 * @return the number of vertices. 406 374 */ 407 public int getVertexCount() {408 int value =0;409 if (graph !=null) value=graph.vertexSet().size();375 public int getVertexCount() { 376 int value = 0; 377 if (graph != null) value = graph.vertexSet().size(); 410 378 return value; 411 379 } … … 415 383 * @return the number of edges. 416 384 */ 417 public int getEdgeCount() {418 int value =0;419 if (graph !=null) value=graph.edgeSet().size();385 public int getEdgeCount() { 386 int value = 0; 387 if (graph != null) value = graph.edgeSet().size(); 420 388 return value; 421 389 } … … 445 413 446 414 public void resetGraph() { 447 graph =null;415 graph = null; 448 416 } 449 417 -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingGraphDelegator.java
r23189 r32768 1 /** 2 * 3 */ 1 // License: GPL. For details, see LICENSE file. 4 2 package com.innovant.josm.jrt.core; 5 3 … … 9 7 import org.openstreetmap.josm.data.osm.Node; 10 8 11 import com.innovant.josm.jrt.core.RoutingGraphDelegator;12 9 import com.innovant.josm.jrt.core.RoutingGraph.RouteType; 13 10 import com.innovant.josm.jrt.osm.OsmEdge; … … 33 30 } 34 31 35 36 32 public RouteType getRouteType() { 37 33 return routeType; … … 42 38 } 43 39 44 45 40 /** 46 41 * … … 50 45 @Override 51 46 public double getEdgeWeight(OsmEdge edge) { 52 double weight =Double.MAX_VALUE;47 double weight = Double.MAX_VALUE; 53 48 54 if (routeType ==RouteType.SHORTEST) weight=edge.getLength();55 if (routeType ==RouteType.FASTEST) weight=edge.getLength() / edge.getSpeed();49 if (routeType == RouteType.SHORTEST) weight = edge.getLength(); 50 if (routeType == RouteType.FASTEST) weight = edge.getLength() / edge.getSpeed(); 56 51 // Return the time spent to traverse the way 57 52 return weight; -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/core/RoutingProfile.java
r30737 r32768 1 // License: GPL. For details, see LICENSE file. 1 2 package com.innovant.josm.jrt.core; 2 3 … … 57 58 * A speed of zero means that this type of way cannot be traversed. 58 59 */ 59 private Map<String, Double> waySpeeds;60 private Map<String, Double> waySpeeds; 60 61 61 62 … … 64 65 * Holds permission of use for each type of transport mode, using the mode as key. 65 66 */ 66 private Map<String, Boolean> allowedModes;67 private Map<String, Boolean> allowedModes; 67 68 68 69 /** … … 75 76 logger.debug("Init RoutingProfile with name: "+name); 76 77 this.name = name; 77 waySpeeds =new HashMap<>();78 Map<String, String> prefs=Main.pref.getAllPrefix("routing.profile."+name+".speed");79 for (String key:prefs.keySet()){78 waySpeeds = new HashMap<>(); 79 Map<String, String> prefs = Main.pref.getAllPrefix("routing.profile."+name+".speed"); 80 for (String key:prefs.keySet()) { 80 81 waySpeeds.put((key.split("\\.")[4]), Double.valueOf(prefs.get(key))); 81 82 } 82 for (String key:waySpeeds.keySet()) 83 for (String key:waySpeeds.keySet()) { 83 84 logger.debug(key+ "-- speed: "+waySpeeds.get(key)); 85 } 84 86 logger.debug("End init RoutingProfile with name: "+name); 85 87 } … … 147 149 } 148 150 149 public double getSpeed(String key) {150 if (!waySpeeds.containsKey(key)) return 0.0;151 public double getSpeed(String key) { 152 if (!waySpeeds.containsKey(key)) return 0.0; 151 153 return waySpeeds.get(key); 152 154 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/gtfs/GTFSTransportModes.java
r15707 r32768 1 // License: GPL. For details, see LICENSE file. 1 2 package com.innovant.josm.jrt.gtfs; 2 3 … … 7 8 * Routing Profile keys should be Strings 8 9 */ 9 public class GTFSTransportModes { 10 public final class GTFSTransportModes { 11 12 private GTFSTransportModes() { 13 14 } 10 15 11 16 /** -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmEdge.java
r23189 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 1 // License: GPL. For details, see LICENSE file. 27 2 package com.innovant.josm.jrt.osm; 28 3 … … 37 12 */ 38 13 public class OsmEdge extends DefaultWeightedEdge { 39 /**40 * Serial41 */42 private static final long serialVersionUID = 1L;43 /**44 * Way associated45 */46 private Way way;47 /**48 * Nodes in the edge49 */50 private Node from, to;51 /**52 * Length edge53 */54 private double length;55 /**56 * Speed edge.57 */58 private double speed;14 /** 15 * Serial 16 */ 17 private static final long serialVersionUID = 1L; 18 /** 19 * Way associated 20 */ 21 private Way way; 22 /** 23 * Nodes in the edge 24 */ 25 private Node from, to; 26 /** 27 * Length edge 28 */ 29 private double length; 30 /** 31 * Speed edge. 32 */ 33 private double speed; 59 34 60 61 /** 62 * Constructor 63 * @param way 64 * @param length 65 */ 66 public OsmEdge(Way way, Node from, Node to) { 35 /** 36 * Constructor 37 */ 38 public OsmEdge(Way way, Node from, Node to) { 67 39 super(); 68 40 this.way = way; … … 70 42 this.to = to; 71 43 this.length = from.getCoor().greatCircleDistance(to.getCoor()); 72 44 } 73 45 74 /**75 * @return the way76 */77 public Way getWay() {78 return this.way;79 }46 /** 47 * @return the way 48 */ 49 public Way getWay() { 50 return this.way; 51 } 80 52 81 public EastNorth fromEastNorth() {82 return this.from.getEastNorth();83 }53 public EastNorth fromEastNorth() { 54 return this.from.getEastNorth(); 55 } 84 56 85 public EastNorth toEastNorth() {86 return this.to.getEastNorth();87 }57 public EastNorth toEastNorth() { 58 return this.to.getEastNorth(); 59 } 88 60 89 /**90 * Returns length of segment in meters91 * @return length of segment in meters.92 */93 public double getLength() {94 return length;95 }61 /** 62 * Returns length of segment in meters 63 * @return length of segment in meters. 64 */ 65 public double getLength() { 66 return length; 67 } 96 68 97 public void setLength(double length) { 98 this.length = length; 69 public void setLength(double length) { 70 this.length = length; 71 } 72 73 public double getSpeed() { 74 return speed; 75 } 76 77 public void setSpeed(double speed) { 78 this.speed = speed; 79 } 99 80 } 100 101 public double getSpeed() {102 return speed;103 }104 105 public void setSpeed(double speed) {106 this.speed = speed;107 }108 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/jrt/osm/OsmWayTypes.java
r15707 r32768 1 /* 2 * 3 * Copyright (C) 2008 Innovant 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 18 * 19 * For more information, please contact: 20 * 21 * Innovant 22 * juangui@gmail.com 23 * vidalfree@gmail.com 24 * 25 * http://public.grupoinnovant.com/blog 26 * 27 */ 28 1 // License: GPL. For details, see LICENSE file. 29 2 package com.innovant.josm.jrt.osm; 30 3 … … 34 7 */ 35 8 public enum OsmWayTypes { 36 MOTORWAY ("motorway",120),37 MOTORWAY_LINK ("motorway_link",120),38 TRUNK ("trunk",120),39 TRUNK_LINK ("trunk_link",120),40 PRIMARY ("primary",100),41 PRIMARY_LINK ("primary_link",100),42 SECONDARY ("secondary",90),43 TERTIARY ("tertiary",90),44 UNCLASSIFIED ("unclassified",50),45 ROAD ("road",100),46 RESIDENTIAL ("residential",50),47 LIVING_STREET ("living_street",30),48 SERVICE ("service",30),49 TRACK ("track",50),50 PEDESTRIAN ("pedestrian",30),51 BUS_GUIDEWAY ("bus_guideway",50),52 PATH ("path",40),53 CYCLEWAY ("cycleway",40),54 FOOTWAY ("footway",20),55 BRIDLEWAY ("bridleway",40),56 BYWAY ("byway",50),57 STEPS ("steps",10);9 MOTORWAY("motorway", 120), 10 MOTORWAY_LINK("motorway_link", 120), 11 TRUNK("trunk", 120), 12 TRUNK_LINK("trunk_link", 120), 13 PRIMARY("primary", 100), 14 PRIMARY_LINK("primary_link", 100), 15 SECONDARY("secondary", 90), 16 TERTIARY("tertiary", 90), 17 UNCLASSIFIED("unclassified", 50), 18 ROAD("road", 100), 19 RESIDENTIAL("residential", 50), 20 LIVING_STREET("living_street", 30), 21 SERVICE("service", 30), 22 TRACK("track", 50), 23 PEDESTRIAN("pedestrian", 30), 24 BUS_GUIDEWAY("bus_guideway", 50), 25 PATH("path", 40), 26 CYCLEWAY("cycleway", 40), 27 FOOTWAY("footway", 20), 28 BRIDLEWAY("bridleway", 40), 29 BYWAY("byway", 50), 30 STEPS("steps", 10); 58 31 59 32 /** 60 33 * Default Constructor 61 * @param tag62 34 */ 63 OsmWayTypes(String tag, int speed) {35 OsmWayTypes(String tag, int speed) { 64 36 this.tag = tag; 65 37 this.speed = speed; … … 72 44 private final int speed; 73 45 74 /** 75 * @return 76 */ 77 public String getTag() {return tag;}; 78 public int getSpeed() {return speed;}; 46 public String getTag() { 47 return tag; 48 } 49 50 public int getSpeed() { 51 return speed; 52 } 79 53 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingLayer.java
r32349 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing; 29 3 … … 72 46 73 47 public enum PreferencesKeys { 74 KEY_ACTIVE_ROUTE_COLOR 75 KEY_INACTIVE_ROUTE_COLOR 76 KEY_ROUTE_WIDTH 77 KEY_ROUTE_SELECT 48 KEY_ACTIVE_ROUTE_COLOR(marktr("routing active route")), 49 KEY_INACTIVE_ROUTE_COLOR(marktr("routing inactive route")), 50 KEY_ROUTE_WIDTH("routing.route.width"), 51 KEY_ROUTE_SELECT("routing.route.select"); 78 52 79 53 public final String key; 80 PreferencesKeys (String key) { 81 this.key=key; 82 } 83 84 public String getKey() {return key;}; 54 PreferencesKeys(String key) { 55 this.key = key; 56 } 57 58 public String getKey() { 59 return key; 60 } 85 61 } 86 62 … … 103 79 * Start, Middle and End icons 104 80 */ 105 private Icon startIcon, middleIcon,endIcon;81 private Icon startIcon, middleIcon, endIcon; 106 82 107 83 /** … … 117 93 super(name); 118 94 logger.debug("Creating Routing Layer..."); 119 if (startIcon == null) startIcon = ImageProvider.get("routing", "startflag");120 if (middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag");121 if (endIcon == null) endIcon = ImageProvider.get("routing", "endflag");95 if (startIcon == null) startIcon = ImageProvider.get("routing", "startflag"); 96 if (middleIcon == null) middleIcon = ImageProvider.get("routing", "middleflag"); 97 if (endIcon == null) endIcon = ImageProvider.get("routing", "endflag"); 122 98 this.dataLayer = dataLayer; 123 99 this.routingModel = new RoutingModel(dataLayer.data); 124 100 logger.debug("Routing Layer created."); 125 101 126 102 127 103 this.routingModel.routingGraph.createGraph(); /* construct the graph right after we we create the layer */ … … 155 131 double minDist = 0; 156 132 for (Way w : dataLayer.data.getWays()) { 157 if (w.isDeleted() || w.isIncomplete() || w.get("highway") ==null) continue;133 if (w.isDeleted() || w.isIncomplete() || w.get("highway") == null) continue; 158 134 for (Node n : w.getNodes()) { 159 135 if (n.isDeleted() || n.isIncomplete()) continue; … … 181 157 public Object getInfoComponent() { 182 158 String info = "<html>" 183 184 185 186 187 159 + "<body>" 160 +"Graph Vertex: "+this.routingModel.routingGraph.getVertexCount()+"<br/>" 161 +"Graph Edges: "+this.routingModel.routingGraph.getEdgeCount()+"<br/>" 162 + "</body>" 163 + "</html>"; 188 164 return info; 189 165 } … … 193 169 Collection<Action> components = new ArrayList<>(); 194 170 components.add(LayerListDialog.getInstance().createShowHideLayerAction()); 195 // components.add(new JMenuItem(new LayerListDialog.ShowHideMarkerText(this)));171 // components.add(new JMenuItem(new LayerListDialog.ShowHideMarkerText(this))); 196 172 components.add(LayerListDialog.getInstance().createDeleteLayerAction()); 197 173 components.add(SeparatorLayerAction.INSTANCE); … … 241 217 } 242 218 int width = Integer.parseInt(widthString); 243 244 219 220 245 221 // draw our graph 246 222 if (isActiveLayer) { 247 if (routingModel != null) {248 if (routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) {249 Set<OsmEdge> graphEdges = 223 if (routingModel != null) { 224 if (routingModel.routingGraph != null && routingModel.routingGraph.getGraph() != null) { 225 Set<OsmEdge> graphEdges = routingModel.routingGraph.getGraph().edgeSet(); 250 226 if (!graphEdges.isEmpty()) { 251 227 Color color2 = ColorHelper.html2color("#00ff00"); /* just green for now */ … … 253 229 Point from = mv.getPoint(firstedge.fromEastNorth()); 254 230 g.drawRect(from.x-4, from.y+4, from.x+4, from.y-4); 255 for (OsmEdge edge : graphEdges) {231 for (OsmEdge edge : graphEdges) { 256 232 drawGraph(g, mv, edge, color2, width); 257 233 } 258 234 } 259 260 261 } 262 263 264 if (nodes == null || nodes.size() == 0) return;265 235 } 236 } 237 } 238 239 240 if (nodes == null || nodes.size() == 0) return; 241 266 242 // Paint routing path 267 243 List<OsmEdge> routeEdges = routingModel.getRouteEdges(); 268 if (routeEdges != null) {269 for (OsmEdge edge : routeEdges) {244 if (routeEdges != null) { 245 for (OsmEdge edge : routeEdges) { 270 246 drawEdge(g, mv, edge, color, width, true); 271 247 } … … 279 255 280 256 // paint middle icons 281 for (int index = 1; index < nodes.size() - 1; ++index) {257 for (int index = 1; index < nodes.size() - 1; ++index) { 282 258 node = nodes.get(index); 283 259 screen = mv.getPoint(node); … … 286 262 } 287 263 // paint end icon 288 if (nodes.size() > 1) {264 if (nodes.size() > 1) { 289 265 node = nodes.get(nodes.size() - 1); 290 266 screen = mv.getPoint(node); … … 304 280 public void destroy() { 305 281 routingModel.reset(); 306 // layerAdded = false;282 // layerAdded = false; 307 283 } 308 284 … … 318 294 to = mv.getPoint(edge.toEastNorth()); 319 295 320 Graphics2D g2d = (Graphics2D)g; 321 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias! 322 Stroke oldStroke = g2d.getStroke(); 323 g2d.setStroke(new BasicStroke(width)); // thickness 324 g2d.drawLine(from.x, from.y, to.x, to.y); 325 if (showDirection) { 326 double t = Math.atan2(to.y-from.y, to.x-from.x) + Math.PI; 327 g.drawLine(to.x,to.y, (int)(to.x + 10*Math.cos(t-ARROW_PHI)), (int)(to.y + 10*Math.sin(t-ARROW_PHI))); 328 g.drawLine(to.x,to.y, (int)(to.x + 10*Math.cos(t+ARROW_PHI)), (int)(to.y + 10*Math.sin(t+ARROW_PHI))); 329 } 330 g2d.setStroke(oldStroke); 331 } 296 Graphics2D g2d = (Graphics2D) g; 297 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias! 298 Stroke oldStroke = g2d.getStroke(); 299 g2d.setStroke(new BasicStroke(width)); // thickness 300 g2d.drawLine(from.x, from.y, to.x, to.y); 301 if (showDirection) { 302 double t = Math.atan2(to.y-from.y, to.x-from.x) + Math.PI; 303 g.drawLine(to.x, to.y, (int) (to.x + 10*Math.cos(t-ARROW_PHI)), (int) (to.y + 10*Math.sin(t-ARROW_PHI))); 304 g.drawLine(to.x, to.y, (int) (to.x + 10*Math.cos(t+ARROW_PHI)), (int) (to.y + 10*Math.sin(t+ARROW_PHI))); 305 } 306 g2d.setStroke(oldStroke); 307 } 308 332 309 private void drawGraph(Graphics g, MapView mv, OsmEdge edge, Color col, int width) { 333 310 g.setColor(col); … … 336 313 from = mv.getPoint(edge.fromEastNorth()); 337 314 to = mv.getPoint(edge.toEastNorth()); 338 339 Graphics2D g2d = (Graphics2D)g;340 341 342 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);// Anti-alias!343 344 345 346 347 348 315 316 Graphics2D g2d = (Graphics2D) g; 317 Stroke oldStroke = g2d.getStroke(); 318 g2d.setStroke(new BasicStroke(width)); // thickness 319 g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); // Anti-alias! 320 g2d.drawLine(from.x, from.y, to.x, to.y); 321 g2d.drawRect(to.x- 4, to.y+4, 4, 4); 322 323 g2d.setStroke(oldStroke); 324 } 325 349 326 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingModel.java
r30737 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing; 29 3 … … 56 30 * Graph to calculate route 57 31 */ 58 public RoutingGraph routingGraph =null;32 public RoutingGraph routingGraph = null; 59 33 60 34 /** 61 35 * List of nodes that the route has to traverse 62 36 */ 63 private List<Node> nodes =null;37 private List<Node> nodes = null; 64 38 65 private List<OsmEdge> path =null;39 private List<OsmEdge> path = null; 66 40 67 41 /** 68 42 * Flag to advise about changes in the selected nodes. 69 43 */ 70 private boolean changeNodes =false;44 private boolean changeNodes = false; 71 45 72 46 /** 73 47 * Flag to advise about changes in ways. 74 48 */ 75 private boolean changeOneway =false;49 private boolean changeOneway = false; 76 50 77 51 /** … … 98 72 public void addNode(Node node) { 99 73 nodes.add(node); 100 this.changeNodes =true;74 this.changeNodes = true; 101 75 } 102 76 … … 106 80 */ 107 81 public void removeNode(int index) { 108 if (nodes.size() >index) {82 if (nodes.size() > index) { 109 83 nodes.remove(index); 110 this.changeNodes =true;84 this.changeNodes = true; 111 85 } 112 86 } … … 118 92 */ 119 93 public void insertNode(int index, Node node) { 120 if (nodes.size() >=index) {94 if (nodes.size() >= index) { 121 95 nodes.add(index, node); 122 this.changeNodes =true;96 this.changeNodes = true; 123 97 } 124 98 } … … 130 104 List<Node> aux = new ArrayList<>(); 131 105 for (Node n : nodes) { 132 aux.add(0, n);106 aux.add(0, n); 133 107 } 134 108 nodes = aux; 135 this.changeNodes =true;109 this.changeNodes = true; 136 110 } 137 111 … … 141 115 */ 142 116 public List<OsmEdge> getRouteEdges() { 143 if (this.changeNodes || path==null) 144 { 145 path=this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA); 146 this.changeNodes=false; 147 this.changeOneway=false; 117 if (this.changeNodes || path == null) { 118 path = this.routingGraph.applyAlgorithm(nodes, Algorithm.ROUTING_ALG_DIJKSTRA); 119 this.changeNodes = false; 120 this.changeOneway = false; 148 121 } 149 122 return path; … … 176 149 public void reset() { 177 150 nodes.clear(); 178 this.changeNodes =true;151 this.changeNodes = true; 179 152 } 180 153 -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/RoutingPlugin.java
r32465 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing; 29 3 … … 148 122 } 149 123 logger.debug("Loading routing plugin..."); 150 preferenceSettings =new RoutingPreferenceDialog();124 preferenceSettings = new RoutingPreferenceDialog(); 151 125 // Initialize layers list 152 126 layers = new ArrayList<>(); … … 222 196 routingDialog.refresh(); 223 197 } 224 } else{/* hide Routing toolbar and dialog window */198 } else { /* hide Routing toolbar and dialog window */ 225 199 menu.disableRestOfItems(); 226 200 if (routingDialog != null) { … … 250 224 public void layerRemoving(LayerRemoveEvent evt) { 251 225 Layer oldLayer = evt.getRemovedLayer(); 252 if ((oldLayer instanceof RoutingLayer) & (layers.size() ==1)) {226 if ((oldLayer instanceof RoutingLayer) & (layers.size() == 1)) { 253 227 // Remove button(s) from the tool bar when the last routing layer is removed 254 228 addRouteNodeButton.setVisible(false); … … 263 237 // FIXME: can't remove associated routing layers without triggering exceptions in some cases 264 238 RoutingLayer[] layersArray = layers.toArray(new RoutingLayer[0]); 265 for (int i =0;i<layersArray.length;i++) {239 for (int i = 0; i < layersArray.length; i++) { 266 240 if (layersArray[i].getDataLayer().equals(oldLayer)) { 267 241 try { -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/AddRouteNodeAction.java
r32329 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing.actions; 29 3 … … 59 33 /** 60 34 * Constructor 61 * @param mapFrame 35 * @param mapFrame map frame 62 36 */ 63 37 public AddRouteNodeAction(MapFrame mapFrame) { … … 84 58 Node node = null; 85 59 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 86 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();60 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 87 61 node = layer.getNearestHighwayNode(e.getPoint()); 88 if (node == null) {62 if (node == null) { 89 63 logger.debug("no selected node"); 90 64 return; … … 97 71 Main.map.repaint(); 98 72 } 73 99 74 @Override public boolean layerIsSupported(Layer l) { 100 75 return l instanceof RoutingLayer; -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/MoveRouteNodeAction.java
r32329 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing.actions; 29 3 … … 39 13 import org.openstreetmap.josm.data.osm.Node; 40 14 import org.openstreetmap.josm.gui.MapFrame; 15 import org.openstreetmap.josm.gui.layer.Layer; 41 16 import org.openstreetmap.josm.tools.ImageProvider; 42 43 import org.openstreetmap.josm.gui.layer.Layer;44 17 45 18 import com.innovant.josm.plugin.routing.RoutingLayer; … … 74 47 /** 75 48 * Constructor 76 * @param mapFrame 49 * @param mapFrame map frame 77 50 */ 78 51 public MoveRouteNodeAction(MapFrame mapFrame) { … … 98 71 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 99 72 requestFocusInMapView(); 100 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();73 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 101 74 RoutingModel routingModel = layer.getRoutingModel(); 102 75 // Search for the nearest node in the list … … 104 77 index = -1; 105 78 double dmax = DRAG_SQR_RADIUS; // maximum distance, in pixels 106 for (int i =0;i<nl.size();i++) {79 for (int i = 0; i < nl.size(); i++) { 107 80 Node node = nl.get(i); 108 81 double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint()); … … 112 85 } 113 86 } 114 if (index >=0)87 if (index >= 0) 115 88 logger.debug("Moved from node " + nl.get(index)); 116 89 } … … 120 93 @Override public void mouseReleased(MouseEvent e) { 121 94 // If left button is released and a route node is being dragged 122 if ((e.getButton() == MouseEvent.BUTTON1) && (index >=0)) {95 if ((e.getButton() == MouseEvent.BUTTON1) && (index >= 0)) { 123 96 searchAndReplaceNode(e.getPoint()); 124 97 } … … 130 103 private void searchAndReplaceNode(Point point) { 131 104 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 132 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();105 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 133 106 RoutingModel routingModel = layer.getRoutingModel(); 134 107 RoutingDialog routingDialog = RoutingPlugin.getInstance().getRoutingDialog(); … … 148 121 } 149 122 } 123 150 124 @Override public boolean layerIsSupported(Layer l) { 151 125 return l instanceof RoutingLayer; 152 126 } 153 154 127 } -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/actions/RemoveRouteNodeAction.java
r32329 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing.actions; 29 3 … … 85 59 if (e.getButton() == MouseEvent.BUTTON1) { 86 60 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 87 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();61 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 88 62 RoutingModel routingModel = layer.getRoutingModel(); 89 63 // Search for the nearest node in the list … … 91 65 int index = -1; 92 66 double dmax = REMOVE_SQR_RADIUS; // maximum distance, in pixels 93 for (int i =0;i<nl.size();i++) {67 for (int i = 0; i < nl.size(); i++) { 94 68 Node node = nl.get(i); 95 69 double d = Main.map.mapView.getPoint(node).distanceSq(e.getPoint()); -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingDialog.java
r32329 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing.gui; 29 3 … … 99 73 /** 100 74 * Remove item from the list of nodes 101 * @param index102 75 */ 103 76 public void removeNode(int index) { … … 107 80 /** 108 81 * Add item to the list of nodes 109 * @param obj110 82 */ 111 83 public void addNode(Node n) { … … 115 87 /** 116 88 * Insert item to the list of nodes 117 * @param index118 * @param obj119 89 */ 120 90 public void insertNode(int index, Node n) { … … 132 102 clearNodes(); 133 103 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 134 RoutingLayer routingLayer = (RoutingLayer) Main.getLayerManager().getActiveLayer();104 RoutingLayer routingLayer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 135 105 RoutingModel routingModel = routingLayer.getRoutingModel(); 136 106 for (Node n : routingModel.getSelectedNodes()) { -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingMenu.java
r32329 r32768 1 /* 2 * Copyright (C) 2008 Innovant 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 17 * 18 * For more information, please contact: 19 * 20 * Innovant 21 * juangui@gmail.com 22 * vidalfree@gmail.com 23 * 24 * http://public.grupoinnovant.com/blog 25 * 26 */ 27 1 // License: GPL. For details, see LICENSE file. 28 2 package com.innovant.josm.plugin.routing.gui; 29 3 … … 78 52 startMI = new JMenuItem(tr("Add routing layer")); 79 53 startMI.addActionListener(new ActionListener() { 54 @Override 80 55 public void actionPerformed(ActionEvent e) { 81 56 RoutingPlugin.getInstance().addLayer(); … … 92 67 rshorter.setSelected(true); 93 68 rshorter.addItemListener(new ItemListener() { 69 @Override 94 70 public void itemStateChanged(ItemEvent e) { 95 71 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 96 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();72 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 97 73 RoutingModel routingModel = layer.getRoutingModel(); 98 if (e.getStateChange() ==ItemEvent.SELECTED) {74 if (e.getStateChange() == ItemEvent.SELECTED) { 99 75 routingModel.routingGraph.setTypeRoute(RouteType.SHORTEST); 100 76 } else { … … 121 97 JCheckBoxMenuItem cbmi = new JCheckBoxMenuItem(tr("Ignore oneways")); 122 98 cbmi.addItemListener(new ItemListener() { 99 @Override 123 100 public void itemStateChanged(ItemEvent e) { 124 101 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 125 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();102 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 126 103 RoutingModel routingModel = layer.getRoutingModel(); 127 if (e.getStateChange() ==ItemEvent.SELECTED)104 if (e.getStateChange() == ItemEvent.SELECTED) 128 105 routingModel.routingGraph.getRoutingProfile().setOnewayUse(false); 129 106 else … … 141 118 reverseMI = new JMenuItem(tr("Reverse route")); 142 119 reverseMI.addActionListener(new ActionListener() { 120 @Override 143 121 public void actionPerformed(ActionEvent e) { 144 122 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 145 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();123 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 146 124 RoutingModel routingModel = layer.getRoutingModel(); 147 125 routingModel.reverseNodes(); … … 154 132 clearMI = new JMenuItem(tr("Clear route")); 155 133 clearMI.addActionListener(new ActionListener() { 134 @Override 156 135 public void actionPerformed(ActionEvent e) { 157 136 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 158 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();137 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 159 138 RoutingModel routingModel = layer.getRoutingModel(); 160 139 // Reset routing nodes and paths … … 169 148 regraphMI = new JMenuItem(tr("Reconstruct Graph")); 170 149 regraphMI.addActionListener(new ActionListener() { 150 @Override 171 151 public void actionPerformed(ActionEvent e) { 172 152 173 153 if (Main.getLayerManager().getActiveLayer() instanceof RoutingLayer) { 174 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer();154 RoutingLayer layer = (RoutingLayer) Main.getLayerManager().getActiveLayer(); 175 155 RoutingModel routingModel = layer.getRoutingModel(); 176 156 routingModel.routingGraph.resetGraph(); -
applications/editors/josm/plugins/routing/src/com/innovant/josm/plugin/routing/gui/RoutingPreferenceDialog.java
r30532 r32768 1 /* 2 * 3 * Copyright (C) 2008 Innovant 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. 18 * 19 * For more information, please contact: 20 * 21 * Innovant 22 * juangui@gmail.com 23 * vidalfree@gmail.com 24 * 25 * http://public.grupoinnovant.com/blog 26 * 27 */ 28 1 // License: GPL. For details, see LICENSE file. 29 2 package com.innovant.josm.plugin.routing.gui; 30 3 … … 79 52 } 80 53 54 @Override 81 55 public void addGui(final PreferenceTabbedPane gui) { 82 56 … … 86 60 p.setLayout(new GridBagLayout()); 87 61 88 model = new DefaultTableModel(new String[] { 62 model = new DefaultTableModel(new String[] {tr("Highway type"), 89 63 tr("Speed (Km/h)") }, 0) { 90 64 private static final long serialVersionUID = 4253339034781567453L; … … 107 81 p.add(add, GBC.std().insets(0, 5, 0, 0)); 108 82 add.addActionListener(new ActionListener() { 83 @Override 109 84 public void actionPerformed(ActionEvent e) { 110 85 JPanel p = new JPanel(new GridBagLayout()); 111 86 p.add(new JLabel(tr("Weight")), GBC.std().insets(0, 0, 5, 0)); 112 87 JComboBox<String> key = new JComboBox<>(); 113 for (OsmWayTypes pk : OsmWayTypes.values()) 88 for (OsmWayTypes pk : OsmWayTypes.values()) { 114 89 key.addItem(pk.getTag()); 90 } 115 91 JTextField value = new JTextField(10); 116 92 p.add(key, GBC.eop().insets(5, 0, 0, 0).fill(GBC.HORIZONTAL)); … … 132 108 p.add(delete, GBC.std().insets(0, 5, 0, 0)); 133 109 delete.addActionListener(new ActionListener() { 110 @Override 134 111 public void actionPerformed(ActionEvent e) { 135 112 if (list.getSelectedRow() == -1) … … 138 115 else { 139 116 Integer i; 140 while ((i = list.getSelectedRow()) != -1) 117 while ((i = list.getSelectedRow()) != -1) { 141 118 model.removeRow(i); 119 } 142 120 } 143 121 } … … 147 125 p.add(edit, GBC.std().insets(5, 5, 5, 0)); 148 126 edit.addActionListener(new ActionListener() { 127 @Override 149 128 public void actionPerformed(ActionEvent e) { 150 129 edit(gui, list); … … 158 137 // Opciones.addTab("Preferences", new JPanel()); 159 138 160 list.addMouseListener(new MouseAdapter() {139 list.addMouseListener(new MouseAdapter() { 161 140 @Override public void mouseClicked(MouseEvent e) { 162 141 if (e.getClickCount() == 2) … … 169 148 } 170 149 150 @Override 171 151 public boolean ok() { 172 152 for (int i = 0; i < model.getRowCount(); ++i) { … … 180 160 } 181 161 } 182 for (Entry<String, String> e : orig.entrySet()) 162 for (Entry<String, String> e : orig.entrySet()) { 183 163 Main.pref.put(e.getKey(), null); 164 } 184 165 return false; 185 166 } … … 203 184 // Put these values in the model 204 185 for (String tag : orig.keySet()) { 205 model.addRow(new String[] { tag, orig.get(tag)});186 model.addRow(new String[] {tag, orig.get(tag)}); 206 187 } 207 188 } … … 216 197 } 217 198 orig = Main.pref.getAllPrefix("routing.profile.default.speed"); 218 } 219 else logger.debug("Default preferences already exist."); 199 } else logger.debug("Default preferences already exist."); 220 200 } 221 201 /*
Note:
See TracChangeset
for help on using the changeset viewer.