Changeset 20030 in osm for applications/editors
- Timestamp:
- 2010-02-16T09:36:32+01:00 (15 years ago)
- Location:
- applications/editors/josm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/src/public_transport/RoutePatternAction.java
r20003 r20030 46 46 import org.openstreetmap.josm.Main; 47 47 import org.openstreetmap.josm.actions.JosmAction; 48 import org.openstreetmap.josm.actions.mapmode.DeleteAction; 48 49 import org.openstreetmap.josm.data.osm.DataSet; 49 50 import org.openstreetmap.josm.data.osm.Node; … … 486 487 private static Vector< RelationMember > markedNodes = new Vector< RelationMember >(); 487 488 489 private static Relation copy = null; 490 488 491 public RoutePatternAction() { 489 492 super(tr("Route patterns ..."), null, … … 526 529 layoutCons.gridx = 0; 527 530 layoutCons.gridy = 0; 531 layoutCons.gridwidth = 3; 528 532 layoutCons.weightx = 0.0; 529 533 layoutCons.weighty = 0.0; … … 542 546 layoutCons.gridx = 0; 543 547 layoutCons.gridy = 1; 548 layoutCons.gridwidth = 3; 544 549 layoutCons.weightx = 1.0; 545 550 layoutCons.weighty = 1.0; … … 554 559 layoutCons.gridx = 0; 555 560 layoutCons.gridy = 2; 561 layoutCons.gridwidth = 1; 562 layoutCons.gridheight = 2; 556 563 layoutCons.weightx = 1.0; 557 564 layoutCons.weighty = 0.0; … … 560 567 contentPane.add(bRefresh); 561 568 569 JButton bNew = new JButton("New"); 570 bNew.setActionCommand("routePattern.overviewNew"); 571 bNew.addActionListener(this); 572 573 layoutCons.gridx = 1; 574 layoutCons.gridy = 2; 575 layoutCons.gridwidth = 1; 576 layoutCons.gridheight = 1; 577 layoutCons.weightx = 1.0; 578 layoutCons.weighty = 0.0; 579 layoutCons.fill = GridBagConstraints.BOTH; 580 gridbag.setConstraints(bNew, layoutCons); 581 contentPane.add(bNew); 582 583 JButton bDelete = new JButton("Delete"); 584 bDelete.setActionCommand("routePattern.overviewDelete"); 585 bDelete.addActionListener(this); 586 587 layoutCons.gridx = 1; 588 layoutCons.gridy = 3; 589 layoutCons.gridwidth = 1; 590 layoutCons.gridheight = 1; 591 layoutCons.weightx = 1.0; 592 layoutCons.weighty = 0.0; 593 layoutCons.fill = GridBagConstraints.BOTH; 594 gridbag.setConstraints(bDelete, layoutCons); 595 contentPane.add(bDelete); 596 597 JButton bDuplicate = new JButton("Duplicate"); 598 bDuplicate.setActionCommand("routePattern.overviewDuplicate"); 599 bDuplicate.addActionListener(this); 600 601 layoutCons.gridx = 2; 602 layoutCons.gridy = 2; 603 layoutCons.gridwidth = 1; 604 layoutCons.gridheight = 1; 605 layoutCons.weightx = 1.0; 606 layoutCons.weighty = 0.0; 607 layoutCons.fill = GridBagConstraints.BOTH; 608 gridbag.setConstraints(bDuplicate, layoutCons); 609 contentPane.add(bDuplicate); 610 611 JButton bReflect = new JButton("Reflect"); 612 bReflect.setActionCommand("routePattern.overviewReflect"); 613 bReflect.addActionListener(this); 614 615 layoutCons.gridx = 2; 616 layoutCons.gridy = 3; 617 layoutCons.gridwidth = 1; 618 layoutCons.gridheight = 1; 619 layoutCons.weightx = 1.0; 620 layoutCons.weighty = 0.0; 621 layoutCons.fill = GridBagConstraints.BOTH; 622 gridbag.setConstraints(bReflect, layoutCons); 623 contentPane.add(bReflect); 624 562 625 //Tags Tab 563 626 /*Container*/ contentPane = tabTags; … … 810 873 contentPane.add(bAdd); 811 874 812 JButtonbDelete = new JButton("Delete");875 /*JButton*/ bDelete = new JButton("Delete"); 813 876 bDelete.setActionCommand("routePattern.itineraryDelete"); 814 877 bDelete.addActionListener(this); … … 836 899 contentPane.add(bSort); 837 900 838 JButtonbReflect = new JButton("Reflect");901 /*JButton*/ bReflect = new JButton("Reflect"); 839 902 bReflect.setActionCommand("routePattern.itineraryReflect"); 840 903 bReflect.addActionListener(this); … … 1061 1124 if ("routePattern.refresh".equals(event.getActionCommand())) 1062 1125 { 1126 refreshData(); 1127 } 1128 else if ("routePattern.overviewNew".equals(event.getActionCommand())) 1129 { 1130 currentRoute = new Relation(); 1131 currentRoute.put("type", "route"); 1132 currentRoute.put("route", "bus"); 1133 mainDataSet.addPrimitive(currentRoute); 1134 1135 refreshData(); 1136 1137 for (int i = 0; i < relsListModel.size(); ++i) 1138 { 1139 if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route) 1140 relsList.setSelectedIndex(i); 1141 } 1142 } 1143 else if ("routePattern.overviewDuplicate".equals(event.getActionCommand())) 1144 { 1145 currentRoute = new Relation(currentRoute, true); 1146 currentRoute.put("type", "route"); 1147 currentRoute.put("route", "bus"); 1148 mainDataSet.addPrimitive(currentRoute); 1149 1150 refreshData(); 1151 1152 for (int i = 0; i < relsListModel.size(); ++i) 1153 { 1154 if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route) 1155 relsList.setSelectedIndex(i); 1156 } 1157 } 1158 else if ("routePattern.overviewReflect".equals(event.getActionCommand())) 1159 { 1160 currentRoute.setModified(true); 1161 String tag_from = currentRoute.get("from"); 1162 String tag_to = currentRoute.get("to"); 1163 currentRoute.put("from", tag_to); 1164 currentRoute.put("to", tag_from); 1165 1166 Vector< RelationMember > itemsToReflect = new Vector< RelationMember >(); 1167 Vector< RelationMember > otherItems = new Vector< RelationMember >(); 1168 int insPos = itineraryTable.getSelectedRow(); 1169 1170 for (int i = 0; i < currentRoute.getMembersCount(); ++i) 1171 { 1172 RelationMember item = currentRoute.getMember(i); 1173 1174 if (item.isWay()) 1175 { 1176 String role = item.getRole(); 1177 if ("backward".equals(role)) 1178 role = "forward"; 1179 else if ("forward".equals(role)) 1180 role = "backward"; 1181 else 1182 role = "backward"; 1183 1184 itemsToReflect.add(new RelationMember(role, item.getWay())); 1185 } 1186 else if (item.isNode()) 1187 itemsToReflect.add(item); 1188 else 1189 otherItems.add(item); 1190 } 1191 1192 currentRoute.setMembers(null); 1193 for (int i = itemsToReflect.size()-1; i >= 0; --i) 1194 currentRoute.addMember(itemsToReflect.elementAt(i)); 1195 for (int i = 0; i < otherItems.size(); ++i) 1196 currentRoute.addMember(otherItems.elementAt(i)); 1197 1198 refreshData(); 1199 1200 for (int i = 0; i < relsListModel.size(); ++i) 1201 { 1202 if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route) 1203 relsList.setSelectedIndex(i); 1204 } 1205 } 1206 else if ("routePattern.overviewDelete".equals(event.getActionCommand())) 1207 { 1208 DeleteAction.deleteRelation(Main.main.getEditLayer(), currentRoute); 1209 1210 currentRoute = null; 1211 tabbedPane.setEnabledAt(1, false); 1212 tabbedPane.setEnabledAt(2, false); 1213 tabbedPane.setEnabledAt(3, false); 1214 tabbedPane.setEnabledAt(4, false); 1215 1063 1216 refreshData(); 1064 1217 } … … 1773 1926 1774 1927 private void refreshData() { 1928 Relation copy = currentRoute; 1775 1929 relsListModel.clear(); 1930 currentRoute = copy; 1776 1931 1777 1932 DataSet mainDataSet = Main.main.getCurrentDataSet(); … … 1785 1940 { 1786 1941 Relation currentRel = relIter.next(); 1787 String routeVal = currentRel.get("route"); 1788 if ("bus".equals(routeVal)) 1789 relRefs.add(new RouteReference(currentRel)); 1790 else if ("tram".equals(routeVal)) 1791 relRefs.add(new RouteReference(currentRel)); 1792 else if ("light_rail".equals(routeVal)) 1793 relRefs.add(new RouteReference(currentRel)); 1794 else if ("subway".equals(routeVal)) 1795 relRefs.add(new RouteReference(currentRel)); 1796 else if ("rail".equals(routeVal)) 1797 relRefs.add(new RouteReference(currentRel)); 1942 if (!currentRel.isDeleted()) 1943 { 1944 String routeVal = currentRel.get("route"); 1945 if ("bus".equals(routeVal)) 1946 relRefs.add(new RouteReference(currentRel)); 1947 else if ("tram".equals(routeVal)) 1948 relRefs.add(new RouteReference(currentRel)); 1949 else if ("light_rail".equals(routeVal)) 1950 relRefs.add(new RouteReference(currentRel)); 1951 else if ("subway".equals(routeVal)) 1952 relRefs.add(new RouteReference(currentRel)); 1953 else if ("rail".equals(routeVal)) 1954 relRefs.add(new RouteReference(currentRel)); 1955 } 1798 1956 } 1799 1957 1800 1958 Collections.sort(relRefs); 1801 1959 1802 1960 Iterator< RouteReference > iter = relRefs.iterator(); 1803 1961 while (iter.hasNext())
Note:
See TracChangeset
for help on using the changeset viewer.