Changeset 19977 in osm for applications/editors/josm/plugins/public_transport
- Timestamp:
- 2010-02-12T10:36:44+01:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/src/public_transport/RoutePatternAction.java
r19976 r19977 71 71 }; 72 72 73 private class RouteReference implements Comparable< RouteReference > { 74 Relation route; 75 76 public RouteReference(Relation route) { 77 this.route = route; 78 } 79 80 public int compareTo(RouteReference rr) { 81 if (route.get("route") != null) 82 { 83 int result = route.get("route").compareTo(rr.route.get("route")); 84 if (result != 0) 85 return result; 86 } 87 else if (rr.route.get("route") != null) 88 return 1; 89 if (route.get("ref") != null) 90 { 91 int result = route.get("ref").compareTo(rr.route.get("ref")); 92 if (result != 0) 93 return result; 94 } 95 else if (rr.route.get("ref") != null) 96 return 1; 97 if (route.get("to") != null) 98 { 99 int result = route.get("to").compareTo(rr.route.get("to")); 100 if (result != 0) 101 return result; 102 } 103 else if (rr.route.get("to") != null) 104 return 1; 105 if (route.get("direction") != null) 106 { 107 int result = route.get("direction").compareTo(rr.route.get("direction")); 108 if (result != 0) 109 return result; 110 } 111 else if (rr.route.get("direction") != null) 112 return 1; 113 if (route.getId() < rr.route.getId()) 114 return -1; 115 else if (route.getId() > rr.route.getId()) 116 return 1; 117 return 0; 118 } 119 120 public String toString() { 121 String buf = route.get("route"); 122 if ((route.get("ref") != null) && (route.get("ref") != "")) 123 { 124 if ((route.get("to") != null) && (route.get("to") != "")) 125 { 126 buf += " " + route.get("ref") + ": " + route.get("to"); 127 } 128 else if ((route.get("direction") != null) && (route.get("direction") != "")) 129 { 130 buf += " " + route.get("ref") + ": " + route.get("direction"); 131 } 132 else 133 { 134 buf += " " + route.get("ref"); 135 } 136 } 137 buf += " [ID " + Long.toString(route.getId()) + "]"; 138 139 return buf; 140 } 141 }; 142 73 143 private class TagTableModel extends DefaultTableModel implements TableModelListener { 74 144 Relation relation = null; … … 385 455 private static JDialog jDialog = null; 386 456 private static JTabbedPane tabbedPane = null; 387 private static DefaultListModel dlm= null;457 private static DefaultListModel relsListModel = null; 388 458 private static TagTableModel requiredTagsData = null; 389 459 private static CustomCellEditorTable requiredTagsTable = null; … … 397 467 private static StoplistTableModel stoplistData = null; 398 468 private static JTable stoplistTable = null; 399 private static JList r pJList = null;469 private static JList relsList = null; 400 470 private static JCheckBox cbRight = null; 401 471 private static JCheckBox cbLeft = null; 402 472 private static JTextField tfSuggestStopsLimit = null; 403 private static Vector< Relation > routes = new Vector< Relation >(); 473 /* private static Vector< Relation > routes = new Vector< Relation >();*/ 404 474 private static Relation currentRoute = null; 405 475 private static Vector< RelationMember > markedWays = new Vector< RelationMember >(); … … 452 522 contentPane.add(headline); 453 523 454 dlm= new DefaultListModel();455 r pJList = new JList(dlm);456 JScrollPane rpListSP = new JScrollPane(r pJList);524 relsListModel = new DefaultListModel(); 525 relsList = new JList(relsListModel); 526 JScrollPane rpListSP = new JScrollPane(relsList); 457 527 String[] data = {"1", "2", "3", "4", "5", "6"}; 458 dlm.copyInto(data);459 r pJList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);460 r pJList.addListSelectionListener(new RoutesLSL(this));528 relsListModel.copyInto(data); 529 relsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 530 relsList.addListSelectionListener(new RoutesLSL(this)); 461 531 462 532 layoutCons.gridx = 0; … … 566 636 commonTagsData.addColumn("Value"); 567 637 rowContent = new Vector< String >(); 568 rowContent.add(0, "d escription");569 tagBlacklist.add("d escription");638 rowContent.add(0, "direction"); 639 tagBlacklist.add("direction"); 570 640 rowContent.add(1, ""); 571 641 commonTagsData.addRow(rowContent); … … 1614 1684 1615 1685 private void refreshData() { 1616 dlm.clear();1686 relsListModel.clear(); 1617 1687 1618 1688 DataSet mainDataSet = Main.main.getCurrentDataSet(); 1619 1689 if (mainDataSet != null) 1620 1690 { 1621 routes.clear();1622 Vector<String> rpLines = new Vector<String>();1623 Collection<Relation> relCollection = mainDataSet.getRelations();1624 Iterator<Relation> relIter = relCollection.iterator();1691 Vector< RouteReference > relRefs = new Vector< RouteReference >(); 1692 Collection< Relation > relCollection = mainDataSet.getRelations(); 1693 Iterator< Relation > relIter = relCollection.iterator(); 1694 1625 1695 while (relIter.hasNext()) 1626 1696 { … … 1628 1698 String routeVal = currentRel.get("route"); 1629 1699 if ("bus".equals(routeVal)) 1630 { 1631 routes.addElement(currentRel); 1632 String relDesc = currentRel.get("ref"); 1633 if (relDesc == null) 1634 relDesc = ""; 1635 relDesc = "bus: " + relDesc + " ["+ currentRel.getId() + "]"; 1636 rpLines.addElement(relDesc); 1637 } 1638 } 1639 Iterator<String> rplIter = rpLines.iterator(); 1640 while (rplIter.hasNext()) 1641 { 1642 dlm.addElement(rplIter.next()); 1643 } 1700 relRefs.add(new RouteReference(currentRel)); 1701 else if ("tram".equals(routeVal)) 1702 relRefs.add(new RouteReference(currentRel)); 1703 else if ("light_rail".equals(routeVal)) 1704 relRefs.add(new RouteReference(currentRel)); 1705 else if ("subway".equals(routeVal)) 1706 relRefs.add(new RouteReference(currentRel)); 1707 else if ("rail".equals(routeVal)) 1708 relRefs.add(new RouteReference(currentRel)); 1709 } 1710 1711 Collections.sort(relRefs); 1712 1713 Iterator< RouteReference > iter = relRefs.iterator(); 1714 while (iter.hasNext()) 1715 relsListModel.addElement(iter.next()); 1644 1716 } 1645 1717 else … … 1825 1897 1826 1898 private void routesSelectionChanged() { 1827 int selectedPos = r pJList.getAnchorSelectionIndex();1828 if (r pJList.isSelectedIndex(selectedPos))1829 { 1830 currentRoute = routes.elementAt(selectedPos);1899 int selectedPos = relsList.getAnchorSelectionIndex(); 1900 if (relsList.isSelectedIndex(selectedPos)) 1901 { 1902 currentRoute = ((RouteReference)relsListModel.elementAt(selectedPos)).route; 1831 1903 tabbedPane.setEnabledAt(1, true); 1832 1904 tabbedPane.setEnabledAt(2, true);
Note:
See TracChangeset
for help on using the changeset viewer.