diff --git a/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java b/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java index 1eb1154494..ee4fc81b98 100644 --- a/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java +++ b/DataExtractionOSM/src/net/osmand/router/RouteResultPreparation.java @@ -286,7 +286,7 @@ public class RouteResultPreparation { } result.get(prevSegment).setDescription(turn + String.format(" and go %.2f meters", dist)); if(result.get(prevSegment).getTurnType().isSkipToSpeak()) { - result.get(prevSegment).setDescription(result.get(prevSegment).getDescription() +" (*)"); + result.get(prevSegment).setDescription("-*"+result.get(prevSegment).getDescription()); } } prevSegment = i; diff --git a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java index 9c8b3eb3d0..334a13b823 100644 --- a/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java +++ b/DataExtractionOSM/src/net/osmand/swing/MapRouterLayer.java @@ -526,35 +526,6 @@ public class MapRouterLayer implements MapPanelLayer { if (!w.getNodes().isEmpty()) { res.add(w); } - - /*DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dom = factory.newDocumentBuilder(); - Document doc = dom.parse(new InputSource(new StringReader(content.toString()))); - NodeList list = doc.getElementsByTagName("coordinates"); - for(int i=0; i ways = new DataTileManager(); - for (Way w : ((Street) o).getWayNodes()) { - LatLon l = w.getLatLon(); - ways.registerObject(l.getLatitude(), l.getLongitude(), w); - } - mapPanel.setPoints(ways); - mapPanel.requestFocus(); - } - mapPanel.setLatLon(location.getLatitude(), location.getLongitude()); - mapPanel.requestFocus(); - } - if (o instanceof TransportRoute) { - DataTileManager ways = new DataTileManager(); - for (Way w : ((TransportRoute) o).getWays()) { - LatLon l = w.getLatLon(); - ways.registerObject(l.getLatitude(), l.getLongitude(), w); - } - for (TransportStop w : ((TransportRoute) o).getBackwardStops()) { - LatLon l = w.getLocation(); - ways.registerObject(l.getLatitude(), l.getLongitude(), new Node(l.getLatitude(), l.getLongitude(), w - .getId())); - } - for (TransportStop w : ((TransportRoute) o).getForwardStops()) { - LatLon l = w.getLocation(); - ways.registerObject(l.getLatitude(), l.getLongitude(), new Node(l.getLatitude(), l.getLongitude(), w - .getId())); - } - mapPanel.setPoints(ways); - mapPanel.requestFocus(); - } - - } else if (o instanceof Entity) { - Entity c = (Entity) o; - LatLon latLon = c.getLatLon(); - if (latLon != null) { - mapPanel.setLatLon(latLon.getLatitude(), latLon.getLongitude()); - mapPanel.requestFocus(); - } - } - } - } - - } - }); - - treeModelListener = new TreeModelListener() { - public void treeNodesChanged(TreeModelEvent e) { - Object node = e.getTreePath().getLastPathComponent(); - if (e.getChildren() != null && e.getChildren().length > 0) { - node = e.getChildren()[0]; - } - if (node instanceof DataExtractionTreeNode) { - DataExtractionTreeNode n = ((DataExtractionTreeNode) node); - if (n.getModelObject() instanceof MapObject) { - MapObject r = (MapObject) n.getModelObject(); - String newName = n.getUserObject().toString(); - if (!r.getName().equals(newName)) { - r.setName(n.getUserObject().toString()); - } - if (r instanceof Street && !((Street) r).isRegisteredInCity()) { - DefaultMutableTreeNode parent = ((DefaultMutableTreeNode) n.getParent()); - parent.remove(n); - ((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent); - } - } - } - } - - public void treeNodesInserted(TreeModelEvent e) { - } - - public void treeNodesRemoved(TreeModelEvent e) { - } - - public void treeStructureChanged(TreeModelEvent e) { - } - }; - treePlaces.getModel().addTreeModelListener(treeModelListener); - return treePlaces; - } - - public void fillPopupMenuWithActions(JPopupMenu menu) { - Action delete = new AbstractAction("Delete") { - private static final long serialVersionUID = 7476603434847164396L; - - public void actionPerformed(ActionEvent e) { - TreePath[] p = treePlaces.getSelectionPaths(); - if(p != null && - JOptionPane.OK_OPTION == - JOptionPane.showConfirmDialog(frame, "Are you sure about deleting " +p.length + " resources ? ")){ - for(TreePath path : treePlaces.getSelectionPaths()){ - Object node = path.getLastPathComponent(); - if (node instanceof DataExtractionTreeNode) { - DataExtractionTreeNode n = ((DataExtractionTreeNode) node); - if(n.getParent() instanceof DataExtractionTreeNode){ - DataExtractionTreeNode parent = ((DataExtractionTreeNode) n.getParent()); - boolean remove = false; - if (n.getModelObject() instanceof Street) { - ((City)parent.getModelObject()).unregisterStreet(((Street)n.getModelObject()).getName()); - remove = true; - } else if (n.getModelObject() instanceof Building) { - ((Street)parent.getModelObject()).getBuildings().remove(n.getModelObject()); - remove = true; - } else if (n.getModelObject() instanceof City) { - Region r = (Region) ((DataExtractionTreeNode)parent.getParent()).getModelObject(); - r.unregisterCity((City) n.getModelObject()); - remove = true; - } else if (n.getModelObject() instanceof Amenity) { - Region r = (Region) ((DataExtractionTreeNode)parent.getParent().getParent()).getModelObject(); - Amenity am = (Amenity) n.getModelObject(); - r.getAmenityManager().unregisterObject(am.getLocation().getLatitude(), am.getLocation().getLongitude(), am); - remove = true; - } - if(remove){ - parent.remove(n); - ((DefaultTreeModel) treePlaces.getModel()).nodeStructureChanged(parent); - } - } - } - } - - } - } - }; - menu.add(delete); - Action rename= new AbstractAction("Rename") { - private static final long serialVersionUID = -8257594433235073767L; - - public void actionPerformed(ActionEvent e) { - TreePath path = treePlaces.getSelectionPath(); - if(path != null){ - treePlaces.startEditingAtPath(path); - } - } - }; - menu.add(rename); - } - - - public void setRegion(Region region, String name){ - if (this.region == region) { - return; - } - this.region = region; - DefaultMutableTreeNode root = new DataExtractionTreeNode(name, region); - if (region != null) { - amenitiesTree = new DataExtractionTreeNode("Amenities", region); - amenitiesTree.add(new DataExtractionTreeNode("First 15", region)); - for (AmenityType type : AmenityType.values()) { - amenitiesTree.add(new DataExtractionTreeNode(Algoritms.capitalizeFirstLetterAndLowercase(type.toString()), type)); - } - root.add(amenitiesTree); - - DataExtractionTreeNode transport = new DataExtractionTreeNode("Transport", region); - root.add(transport); - for(String s : region.getTransportRoutes().keySet()){ - DataExtractionTreeNode trRoute = new DataExtractionTreeNode(s, s); - transport.add(trRoute); - List list = region.getTransportRoutes().get(s); - for(TransportRoute r : list){ - DataExtractionTreeNode route = new DataExtractionTreeNode(r.getRef(), r); - trRoute.add(route); - } - - } - - for (CityType t : CityType.values()) { - DefaultMutableTreeNode cityTree = new DataExtractionTreeNode(Algoritms.capitalizeFirstLetterAndLowercase(t.toString()), t); - root.add(cityTree); - for (City ct : region.getCitiesByType(t)) { - DefaultMutableTreeNode cityNodeTree = new DataExtractionTreeNode(ct.getName(), ct); - cityTree.add(cityNodeTree); - - for (Street str : ct.getStreets()) { - DefaultMutableTreeNode strTree = new DataExtractionTreeNode(str.getName(), str); - cityNodeTree.add(strTree); - for (Building b : str.getBuildings()) { - DefaultMutableTreeNode building = new DataExtractionTreeNode(b.getName(), b); - strTree.add(building); - } - } - } - } - } - - if (searchList != null) { - updateListCities(region, searchTextField.getText(), searchList); - } - mapPanel.repaint(); - DefaultTreeModel newModel = new DefaultTreeModel(root, false); - newModel.addTreeModelListener(treeModelListener); - treePlaces.setModel(newModel); - - updateButtonsBar(); - locationChanged(mapPanel.getLatitude(), mapPanel.getLongitude(), this); - } - - public static class DataExtractionTreeNode extends DefaultMutableTreeNode { - private static final long serialVersionUID = 1L; - private final Object modelObject; - - public DataExtractionTreeNode(String name, Object modelObject){ - super(name); - this.modelObject = modelObject; - } - - public Object getModelObject(){ - return modelObject; - } - - } - - private void recalculateAmenities(final double newLatitude, final double newLongitude) { - if (amenitiesTree != null) { - Region reg = (Region) amenitiesTree.getModelObject(); - List closestAmenities = reg.getAmenityManager().getClosestObjects(newLatitude, newLongitude, 0, 5); - MapUtils.sortListOfMapObject(closestAmenities, newLatitude, newLongitude); - - - Map> filter = new HashMap>(); - for (Amenity n : closestAmenities) { - AmenityType type = n.getType(); - if (!filter.containsKey(type)) { - filter.put(type, new ArrayList()); - } - filter.get(type).add(n); - } - - - for (int i = 1; i < amenitiesTree.getChildCount(); i++) { - AmenityType type = (AmenityType) ((DataExtractionTreeNode) amenitiesTree.getChildAt(i)).getModelObject(); - ((DefaultMutableTreeNode) amenitiesTree.getChildAt(i)).removeAllChildren(); - if (filter.get(type) != null) { - for (Amenity n : filter.get(type)) { - int dist = (int) (MapUtils.getDistance(n.getLocation(), newLatitude, newLongitude)); - String str = n.getStringWithoutType(false) + " [" + dist + " m ]"; - DataExtractionTreeNode node = new DataExtractionTreeNode(str, n); - ((DefaultMutableTreeNode) amenitiesTree.getChildAt(i)).add(node); - } - } - ((DefaultTreeModel)treePlaces.getModel()).nodeStructureChanged(amenitiesTree.getChildAt(i)); - } - ((DefaultMutableTreeNode) amenitiesTree.getChildAt(0)).removeAllChildren(); - - for (int i = 0; i < 15 && i < closestAmenities.size(); i++) { - Amenity n = closestAmenities.get(i); - int dist = (int) (MapUtils.getDistance(n.getLocation(), newLatitude, newLongitude)); - String str = n.getSimpleFormat(false) + " [" + dist + " m ]"; - ((DefaultMutableTreeNode) amenitiesTree.getChildAt(0)).add(new DataExtractionTreeNode(str, n)); - ((DefaultTreeModel)treePlaces.getModel()).nodeStructureChanged(amenitiesTree.getChildAt(0)); - } - } - } - - public void updateListCities(Region r, String text, JList jList) { - Collection city; - if (r == null) { - city = Collections.emptyList(); - } else { - city = r.getSuggestedCities(text, 100); - } - City[] names = new City[city.size()]; - int i = 0; - for (City c : city) { - names[i++] = c; - } - jList.setListData(names); - } - - public static class RegionCellEditor extends DefaultTreeCellEditor { - - public RegionCellEditor(JTree tree, DefaultTreeCellRenderer renderer) { - super(tree, renderer); - } - - public RegionCellEditor(JTree tree, DefaultTreeCellRenderer renderer, TreeCellEditor editor) { - super(tree, renderer, editor); - } - - public boolean isCellEditable(EventObject event) { - boolean returnValue = super.isCellEditable(event); - if (returnValue) { - Object node = tree.getLastSelectedPathComponent(); - if (node instanceof DataExtractionTreeNode) { - DataExtractionTreeNode treeNode = (DataExtractionTreeNode) node; - if (treeNode.getModelObject() instanceof Region || treeNode.getModelObject() instanceof MapObject) { - return true; - } - } - } - return returnValue; - } - - } - private class PopupTrigger extends MouseAdapter { - - private final JPopupMenu popupMenu; - - public PopupTrigger(JPopupMenu popupMenu) { - this.popupMenu = popupMenu; - } - public void mouseReleased(MouseEvent e) - { - if (e.isPopupTrigger()) - { - int x = e.getX(); - int y = e.getY(); - TreePath path = treePlaces.getPathForLocation(x, y); - if (path != null) { - if(!treePlaces.getSelectionModel().isPathSelected(path)){ - treePlaces.setSelectionPath(path); - } - popupMenu.show(treePlaces, x, y); - } - } - } - } -*/ - } \ No newline at end of file