Changeset 12778 in osm for applications/editors/josm/plugins/navigator/src/at
- Timestamp:
- 2009-01-01T18:28:53+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/JosmEdgeFactory.java
r3686 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 13 13 public class JosmEdgeFactory implements EdgeFactory<Node, WayEdge> { 14 14 15 15 16 16 17 17 /* (non-Javadoc) -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/NavigatorAction.java
r3749 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 28 28 super(tr("Navigate")); 29 29 this.navigatorPlugin = navigatorPlugin; 30 30 31 31 } 32 32 -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/NavigatorLayer.java
r3891 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 29 29 /** 30 30 * @author cdaller 31 * 31 * 32 32 */ 33 33 public class NavigatorLayer extends Layer { … … 43 43 /** 44 44 * Constructor 45 * 45 * 46 46 * @param name 47 47 * the name of the layer. … … 53 53 /* 54 54 * (non-Javadoc) 55 * 55 * 56 56 * @see org.openstreetmap.josm.gui.layer.Layer#getIcon() 57 57 */ … … 64 64 /* 65 65 * (non-Javadoc) 66 * 66 * 67 67 * @see org.openstreetmap.josm.gui.layer.Layer#getInfoComponent() 68 68 */ … … 74 74 /* 75 75 * (non-Javadoc) 76 * 76 * 77 77 * @see org.openstreetmap.josm.gui.layer.Layer#getMenuEntries() 78 78 */ … … 85 85 /* 86 86 * (non-Javadoc) 87 * 87 * 88 88 * @see org.openstreetmap.josm.gui.layer.Layer#getToolTipText() 89 89 */ … … 95 95 /* 96 96 * (non-Javadoc) 97 * 97 * 98 98 * @see org.openstreetmap.josm.gui.layer.Layer#isMergable(org.openstreetmap.josm.gui.layer.Layer) 99 99 */ … … 105 105 /* 106 106 * (non-Javadoc) 107 * 107 * 108 108 * @see org.openstreetmap.josm.gui.layer.Layer#mergeFrom(org.openstreetmap.josm.gui.layer.Layer) 109 109 */ … … 115 115 /* 116 116 * (non-Javadoc) 117 * 117 * 118 118 * @see org.openstreetmap.josm.gui.layer.Layer#paint(java.awt.Graphics, 119 119 * org.openstreetmap.josm.gui.MapView) … … 125 125 return; 126 126 } 127 127 128 128 if(startIcon == null) { 129 129 startIcon = ImageProvider.get("navigation", "startflag"); … … 135 135 Point screen = mv.getPoint(node.eastNorth); 136 136 startIcon.paintIcon(mv, g, screen.x, screen.y - startIcon.getIconHeight()); 137 137 138 138 // middle icons: 139 139 for(int index = 1; index < nodes.size() - 1; ++index) { … … 148 148 endIcon.paintIcon(mv, g, screen.x, screen.y - endIcon.getIconHeight()); 149 149 } 150 150 151 151 String colorString = Main.pref.get(KEY_ROUTE_COLOR); 152 152 if(colorString.length() == 0) { … … 170 170 } 171 171 } 172 172 173 173 /** 174 174 * Draw a line with the given color. … … 183 183 } else { 184 184 from = mv.getPoint(edge.getSegment().to.eastNorth); 185 to = mv.getPoint(edge.getSegment().from.eastNorth); 186 } 187 185 to = mv.getPoint(edge.getSegment().from.eastNorth); 186 } 187 188 188 Rectangle screen = g.getClipBounds(); 189 189 Line2D line = new Line2D.Double(from.x, from.y, to.x, to.y); … … 206 206 /* 207 207 * (non-Javadoc) 208 * 208 * 209 209 * @see org.openstreetmap.josm.gui.layer.Layer#visitBoundingBox(org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor) 210 210 */ … … 225 225 226 226 /** 227 * 227 * 228 228 */ 229 229 public void navigate() { … … 235 235 Main.pref.put(KEY_ROUTE_SELECT, selectString); 236 236 } 237 237 238 238 if(Boolean.parseBoolean(selectString)) { 239 239 List<Segment> path = navigatorNodeModel.getSegmentPath(); … … 244 244 } 245 245 } 246 Main.map.repaint(); 246 Main.map.repaint(); 247 247 } 248 248 -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/NavigatorModeAction.java
r12707 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 24 24 private NavigatorLayer navigatorLayer; 25 25 private boolean layerAdded; 26 26 27 27 public NavigatorModeAction(MapFrame mapFrame, NavigatorModel navigatorModel, NavigatorLayer navigationLayer) { 28 28 super(tr("Navigator"), "navigation", tr("Set start/end for routing. Middle mouse button to reset."), KeyEvent.VK_F, mapFrame, ImageProvider.getCursor("crosshair", "selection")); … … 30 30 this.navigatorLayer = navigationLayer; 31 31 } 32 32 33 33 @Override public void enterMode() { 34 34 super.enterMode(); … … 50 50 if (e.getButton() == MouseEvent.BUTTON2) { 51 51 navigatorModel.reset(); 52 } else if (e.getButton() == MouseEvent.BUTTON1) { 52 } else if (e.getButton() == MouseEvent.BUTTON1) { 53 53 Node node = Main.map.mapView.getNearestNode(e.getPoint()); 54 54 System.out.println("selected node " + node); -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/NavigatorModel.java
r3865 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 36 36 highwayWeight = new HashMap<String, Double>(); 37 37 } 38 38 39 39 /** 40 40 * Set the weight for the given highway type. The higher the weight is, … … 46 46 highwayWeight.put(type, weigth); 47 47 } 48 48 49 49 /** 50 50 * @return the selectedNodes … … 67 67 } 68 68 69 70 /** 71 * 69 70 /** 71 * 72 72 */ 73 73 public void calculateShortesPath() { … … 92 92 fullWeight += routing.getPathLength(); 93 93 } 94 94 95 95 edgePath = new ArrayList<SegmentEdge>(); 96 96 edgePath.addAll(fullPath); 97 97 98 98 System.out.println("shortest path found: " + fullPath + "\nweight: " + fullWeight); 99 99 System.out.println(getPathDescription()); … … 104 104 // System.out.println("all added: " + weight2); 105 105 } 106 106 107 107 public String getPathDescription() { 108 108 List<PathDescription> pathDescriptions = getPathDescriptions(); 109 109 110 110 // create text representation from description: 111 111 StringBuilder builder = new StringBuilder(); … … 137 137 Way oldWay = null; 138 138 Way way = null; 139 139 140 140 SegmentEdge edge; 141 141 for(int segIndex = 0; segIndex < edgePath.size(); ++segIndex) { … … 150 150 description = new PathDescription(oldWay, length); // add finished way 151 151 pathDescriptions.add(description); 152 length = 0; 152 length = 0; 153 153 } 154 154 if(segIndex == edgePath.size() - 1) { 155 155 description = new PathDescription(way, length); 156 pathDescriptions.add(description); 156 pathDescriptions.add(description); 157 157 } 158 158 oldWay = way; 159 159 } 160 161 160 161 162 162 // for(SegmentEdge edge : edgePath) { 163 163 // way = edge.getWay(); … … 216 216 return this.edgePath; 217 217 } 218 218 219 219 /** 220 220 * Resets all data (nodes, edges, segments). -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/NavigatorPlugin.java
r3865 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 21 21 /** 22 22 * Plugin that allows navigation in josm 23 * 23 * 24 24 * @author cdaller 25 * 25 * 26 26 */ 27 27 public class NavigatorPlugin extends Plugin { … … 31 31 32 32 /** 33 * 33 * 34 34 */ 35 35 public NavigatorPlugin() { … … 40 40 navigatorLayer = new NavigatorLayer(tr("Navigation")); 41 41 navigatorLayer.setNavigatorNodeModel(navigatorModel); 42 42 43 43 JMenuBar menu = Main.main.menu; 44 44 JMenu navigatorMenu = new JMenu(tr("Navigation")); … … 55 55 menu.add(navigatorMenu); 56 56 } 57 57 58 58 /** 59 59 * Reads the weight values for the different highway types from the preferences. … … 70 70 } 71 71 } 72 72 73 73 /** 74 * Checks if there are any highway weights set in the preferences. If not, default 74 * Checks if there are any highway weights set in the preferences. If not, default 75 75 * values are used. 76 76 */ … … 86 86 setDefaultWeight("footway", 0.0); 87 87 } 88 88 89 89 private void setDefaultWeight(String type, double value) { 90 90 if(!Main.pref.hasKey(KEY_HIGHWAY_WEIGHT_PREFIX + type)) { … … 92 92 } 93 93 } 94 94 95 95 /* (non-Javadoc) 96 96 * @see org.openstreetmap.josm.plugins.Plugin#mapFrameInitialized(org.openstreetmap.josm.gui.MapFrame, org.openstreetmap.josm.gui.MapFrame) … … 99 99 public void mapFrameInitialized(MapFrame oldFrame, MapFrame newFrame) { 100 100 if(newFrame != null) { 101 IconToggleButton button = new IconToggleButton(new NavigatorModeAction(newFrame, navigatorModel, navigatorLayer)); 101 IconToggleButton button = new IconToggleButton(new NavigatorModeAction(newFrame, navigatorModel, navigatorLayer)); 102 102 newFrame.toolBarActions.add(button); 103 103 newFrame.toolGroup.add(button); -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/OsmGraphCreator.java
r3892 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 23 23 /** 24 24 * @author cdaller 25 * 25 * 26 26 */ 27 27 public class OsmGraphCreator { … … 38 38 highwayWeight = new HashMap<String, Double>(); 39 39 } 40 40 41 41 /** 42 42 * Set the weight for the given highway type. The higher the weight is, … … 58 58 // iterate all ways and segments for all nodes: 59 59 for(Way way : Main.ds.ways) { 60 if(way != null && !way.deleted) { 60 if(way != null && !way.deleted) { 61 61 for(Segment segment : way.segments) { 62 62 if(segment != null && !segment.deleted && segment.from != null && segment.to != null) { … … 67 67 graph.addEdge(segment.from, segment.to, edge); 68 68 weight = getWeight(way, segment); 69 System.out.println("edge for segment " + segment.id + "(from node "+ segment.from.id + " to node " 69 System.out.println("edge for segment " + segment.id + "(from node "+ segment.from.id + " to node " 70 70 + segment.to.id + ") has weight: " + weight); 71 71 graph.setEdgeWeight(edge, weight); … … 74 74 edge.setWay(way); 75 75 graph.addEdge(segment.to, segment.from, edge); 76 graph.setEdgeWeight(edge, weight); 77 System.out.println("inverse segment " + segment.id + "(from node "+ segment.to.id + " to node " 76 graph.setEdgeWeight(edge, weight); 77 System.out.println("inverse segment " + segment.id + "(from node "+ segment.to.id + " to node " 78 78 + segment.from.id + ") has weight: " + weight); 79 79 } … … 105 105 } 106 106 // deg to m (at equator :-): 107 double distance = Math.sqrt(segment.from.coor.distance(segment.to.coor)) * 111000; 107 double distance = Math.sqrt(segment.from.coor.distance(segment.to.coor)) * 111000; 108 108 if(weight == 0.0) { 109 109 weight = 1E-20; … … 191 191 /** 192 192 * Returns the other segment for the given node (works only for non crossing nodes). 193 * 193 * 194 194 * @param node 195 195 * @param segment -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/PathDescription.java
r3833 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/SegmentEdge.java
r3834 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 10 10 /** 11 11 * @author cdaller 12 * 12 * 13 13 */ 14 14 public class SegmentEdge extends DefaultWeightedEdge { -
applications/editors/josm/plugins/navigator/src/at/dallermassl/josm/plugin/navigator/WayEdge.java
r3686 r12778 1 1 /** 2 * 2 * 3 3 */ 4 4 package at.dallermassl.josm.plugin.navigator; … … 18 18 private Node endNode; 19 19 private List<Segment> segments; 20 20 21 21 public WayEdge() { 22 22 23 23 } 24 24 25 25 public WayEdge(int length) { 26 26 this.length = length; … … 82 82 this.endNode = endNode; 83 83 } 84 85 84 85 86 86 87 87 }
Note:
See TracChangeset
for help on using the changeset viewer.