Changeset 26168 in osm for applications/editors/josm/plugins
- Timestamp:
- 2011-06-23T17:50:32+02:00 (14 years ago)
- Location:
- applications/editors/josm/plugins/public_transport/src/public_transport
- Files:
-
- 1 added
- 27 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSAddCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 57 59 (String)gtfsStopTM.getValueAt(j, 1)); 58 60 gtfsStopTM.nodes.set(j, node); 59 gtfsStopTM.setValueAt( "added", j, 2);61 gtfsStopTM.setValueAt(tr("added"), j, 2); 60 62 } 61 63 return true; … … 85 87 @Override public JLabel getDescription() 86 88 { 87 return new JLabel( "public_transport.GTFSStops.Enable");89 return new JLabel(tr("Public Transport: Enable GTFSStops")); 88 90 } 89 91 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSCatchCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 108 110 @Override public JLabel getDescription() 109 111 { 110 return new JLabel( "public_transport.GTFSStops.Catch");112 return new JLabel(tr("Public Transport: Catch GTFS stops")); 111 113 } 112 114 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSDeleteCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 59 61 continue; 60 62 gtfsStopTM.nodes.set(j, null); 61 gtfsStopTM.setValueAt( "skipped", j, 2);63 gtfsStopTM.setValueAt(tr("skipped"), j, 2); 62 64 Main.main.getCurrentDataSet().removePrimitive(node); 63 65 node.setDeleted(true); … … 89 91 @Override public JLabel getDescription() 90 92 { 91 return new JLabel( "public_transport.GTFS.Disable");93 return new JLabel(tr("Public Transport: Disable GTFS")); 92 94 } 93 95 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSImporterAction.java
r26147 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 115 114 if (curDir.equals("")) 116 115 { 117 curDir = ".";116 curDir = "."; 118 117 } 119 118 JFileChooser fc = new JFileChooser(new File(curDir)); 120 fc.setDialogTitle( "Select GTFS file (stops.txt)");119 fc.setDialogTitle(tr("Select GTFS file (stops.txt)")); 121 120 fc.setMultiSelectionEnabled(false); 122 121 123 122 int answer = fc.showOpenDialog(Main.parent); 124 123 if (answer != JFileChooser.APPROVE_OPTION) 125 return;124 return; 126 125 127 126 if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir)) 128 Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());127 Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath()); 129 128 130 129 importData(fc.getSelectedFile()); … … 216 215 if (Main.main.getCurrentDataSet() == null) 217 216 { 218 JOptionPane.showMessageDialog(null, "There exists no dataset." 219 + " Try to download data from the server or open an OSM file.", 220 "No data found", JOptionPane.ERROR_MESSAGE); 221 222 System.out.println("Public Transport: StopInserter: No data found"); 217 JOptionPane.showMessageDialog(null, tr("There exists no dataset." 218 + " Try to download data from the server or open an OSM file."), 219 tr("No data found"), JOptionPane.ERROR_MESSAGE); 223 220 224 221 return; … … 226 223 else 227 224 { 228 Iterator< Node > iter =225 Iterator< Node > iter = 229 226 Main.main.getCurrentDataSet().getNodes().iterator(); 230 while (iter.hasNext())231 {232 Node node = iter.next();233 if ("bus_stop".equals(node.get("highway")))234 existingStops.add(node);235 }227 while (iter.hasNext()) 228 { 229 Node node = iter.next(); 230 if ("bus_stop".equals(node.get("highway"))) 231 existingStops.add(node); 232 } 236 233 } 237 234 238 235 Iterator< String > iter = data.iterator(); 239 236 if (iter.hasNext()) 240 gtfsStopTM = new GTFSStopTableModel(this, iter.next());237 gtfsStopTM = new GTFSStopTableModel(this, iter.next()); 241 238 else 242 239 { 243 JOptionPane.showMessageDialog 244 (null, "The GTFS file was empty.", "No data found", 245 JOptionPane.ERROR_MESSAGE); 246 247 System.out.println("Public Transport: GTFSImporter: No data found"); 240 JOptionPane.showMessageDialog 241 (null, tr("The GTFS file was empty."), tr("No data found"), 242 JOptionPane.ERROR_MESSAGE); 248 243 249 244 return; … … 252 247 while (iter.hasNext()) 253 248 { 254 String s = iter.next();255 gtfsStopTM.addRow(s, existingStops);249 String s = iter.next(); 250 gtfsStopTM.addRow(s, existingStops); 256 251 } 257 252 dialog.setGTFSStopTableModel(gtfsStopTM); … … 260 255 { 261 256 JOptionPane.showMessageDialog 262 (null, "The GTFS file was empty.", "No data found",257 (null, tr("The GTFS file was empty."), tr("No data found"), 263 258 JOptionPane.ERROR_MESSAGE); 264 265 System.out.println("Public Transport: GTFSImporter: No data found");266 259 } 267 260 } … … 298 291 if (Main.main.getCurrentDataSet() == null) 299 292 { 300 JOptionPane.showMessageDialog(null, "There exists no dataset." 301 + " Try to download data from the server or open an OSM file.", 302 "No data found", JOptionPane.ERROR_MESSAGE); 303 304 System.out.println("Public Transport: StopInserter: No data found"); 293 JOptionPane.showMessageDialog(null, tr("There exists no dataset." 294 + " Try to download data from the server or open an OSM file."), 295 tr("No data found"), JOptionPane.ERROR_MESSAGE); 305 296 306 297 return null; … … 319 310 { 320 311 for (int i = 0; i < selectedLines.length; ++i) 321 consideredLines.add(selectedLines[i]);312 consideredLines.add(selectedLines[i]); 322 313 } 323 314 else 324 315 { 325 316 for (int i = 0; i < table.getRowCount(); ++i) 326 consideredLines.add(new Integer(i));317 consideredLines.add(new Integer(i)); 327 318 } 328 319 return consideredLines; … … 340 331 { 341 332 if ((nodes.elementAt(i) != null) && 342 343 table.addRowSelectionInterval(i, i);333 (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i)))) 334 table.addRowSelectionInterval(i, i); 344 335 } 345 336 } … … 355 346 int j = consideredLines.elementAt(i); 356 347 if (nodes.elementAt(j) != null) 357 nodes.elementAt(j).visit(box);348 nodes.elementAt(j).visit(box); 358 349 } 359 350 if (box.getBounds() == null) … … 374 365 int j = consideredLines.elementAt(i); 375 366 if (nodes.elementAt(j) != null) 376 Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));367 Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j)); 377 368 } 378 369 } -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSImporterDialog.java
r23192 r26168 74 74 private JTable stoplistTable = null; 75 75 private JTable gtfsStopTable = null; 76 private final String[] stoptypes = new String[]{marktr("bus"), marktr("tram"), marktr("light_rail"), marktr("subway"), marktr("rail")}; 76 77 77 78 public GTFSImporterDialog(GTFSImporterAction controller) 78 79 { 79 80 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 80 jDialog = new JDialog(frame, "Create Stops from GTFS", false);81 jDialog = new JDialog(frame, tr("Create Stops from GTFS"), false); 81 82 tabbedPane = new JTabbedPane(); 82 83 JPanel tabSettings = new JPanel(); 83 tabbedPane.addTab( marktr("Settings"), tabSettings);84 tabbedPane.addTab(tr("Settings"), tabSettings); 84 85 JPanel tabWaypoints = new JPanel(); 85 tabbedPane.addTab( marktr("GTFS-Stops"), tabWaypoints);86 tabbedPane.addTab(tr("GTFS-Stops"), tabWaypoints); 86 87 tabbedPane.setEnabledAt(0, false); 87 88 tabbedPane.setEnabledAt(1, true); … … 94 95 contentPane.setLayout(gridbag); 95 96 96 JLabel label = new JLabel( "Type of stops to add");97 JLabel label = new JLabel(tr("Type of stops to add")); 97 98 98 99 layoutCons.gridx = 0; … … 107 108 cbStoptype = new JComboBox(); 108 109 cbStoptype.setEditable(false); 109 cbStoptype.addItem("bus"); 110 cbStoptype.addItem("tram"); 111 cbStoptype.addItem("light_rail"); 112 cbStoptype.addItem("subway"); 113 cbStoptype.addItem("rail"); 110 for(String type : stoptypes) 111 cbStoptype.addItem(new TransText(type)); 114 112 cbStoptype.setActionCommand("gtfsImporter.settingsStoptype"); 115 113 cbStoptype.addActionListener(controller); … … 124 122 contentPane.add(cbStoptype); 125 123 126 label = new JLabel( "Time on your GPS device");124 label = new JLabel(tr("Time on your GPS device")); 127 125 128 126 layoutCons.gridx = 0; … … 148 146 contentPane.add(tfGPSTimeStart); 149 147 150 label = new JLabel("HH:MM:SS.sss"); 148 /* I18n: Don't change the time format, you only may translate the letters */ 149 label = new JLabel(tr("HH:MM:SS.sss")); 151 150 152 151 layoutCons.gridx = 1; … … 159 158 contentPane.add(label); 160 159 161 label = new JLabel( "Time on your stopwatch");160 label = new JLabel(tr("Time on your stopwatch")); 162 161 163 162 layoutCons.gridx = 0; … … 183 182 contentPane.add(tfStopwatchStart); 184 183 185 label = new JLabel("HH:MM:SS.sss"); 184 /* I18n: Don't change the time format, you only may translate the letters */ 185 label = new JLabel(tr("HH:MM:SS.sss")); 186 186 187 187 layoutCons.gridx = 1; … … 194 194 contentPane.add(label); 195 195 196 label = new JLabel( "Time window");196 label = new JLabel(tr("Time window")); 197 197 198 198 layoutCons.gridx = 0; … … 218 218 contentPane.add(tfTimeWindow); 219 219 220 label = new JLabel( "seconds");220 label = new JLabel(tr("seconds")); 221 221 222 222 layoutCons.gridx = 1; … … 229 229 contentPane.add(label); 230 230 231 label = new JLabel( "Move Threshold");231 label = new JLabel(tr("Move Threshold")); 232 232 233 233 layoutCons.gridx = 0; … … 253 253 contentPane.add(tfThreshold); 254 254 255 label = new JLabel( "meters");255 label = new JLabel(tr("meters")); 256 256 257 257 layoutCons.gridx = 1; … … 264 264 contentPane.add(label); 265 265 266 JButton bSuggestStops = new JButton( "Suggest Stops");266 JButton bSuggestStops = new JButton(tr("Suggest Stops")); 267 267 bSuggestStops.setActionCommand("gtfsImporter.settingsSuggestStops"); 268 268 bSuggestStops.addActionListener(controller); … … 319 319 contentPane.add(tableSP); 320 320 321 JButton bFind = new JButton( "Find");321 JButton bFind = new JButton(tr("Find")); 322 322 bFind.setActionCommand("gtfsImporter.gtfsStopsFind"); 323 323 bFind.addActionListener(controller); … … 332 332 contentPane.add(bFind); 333 333 334 JButton bShow = new JButton( "Show");334 JButton bShow = new JButton(tr("Show")); 335 335 bShow.setActionCommand("gtfsImporter.gtfsStopsShow"); 336 336 bShow.addActionListener(controller); … … 345 345 contentPane.add(bShow); 346 346 347 JButton bMark = new JButton( "Mark");347 JButton bMark = new JButton(tr("Mark")); 348 348 bMark.setActionCommand("gtfsImporter.gtfsStopsMark"); 349 349 bMark.addActionListener(controller); … … 359 359 contentPane.add(bMark); 360 360 361 JButton bCatch = new JButton( "Catch");361 JButton bCatch = new JButton(tr("Catch")); 362 362 bCatch.setActionCommand("gtfsImporter.gtfsStopsCatch"); 363 363 bCatch.addActionListener(controller); … … 373 373 contentPane.add(bCatch); 374 374 375 JButton bJoin = new JButton( "Join");375 JButton bJoin = new JButton(tr("Join")); 376 376 bJoin.setActionCommand("gtfsImporter.gtfsStopsJoin"); 377 377 bJoin.addActionListener(controller); … … 387 387 contentPane.add(bJoin); 388 388 389 JButton bAdd = new JButton( "Enable");389 JButton bAdd = new JButton(tr("Enable")); 390 390 bAdd.setActionCommand("gtfsImporter.gtfsStopsAdd"); 391 391 bAdd.addActionListener(controller); … … 401 401 contentPane.add(bAdd); 402 402 403 JButton bDelete = new JButton( "Disable");403 JButton bDelete = new JButton(tr("Disable")); 404 404 bDelete.setActionCommand("gtfsImporter.gtfsStopsDelete"); 405 405 bDelete.addActionListener(controller); … … 440 440 public String getStoptype() 441 441 { 442 return ( String)cbStoptype.getSelectedItem();442 return ((TransText)cbStoptype.getSelectedItem()).text; 443 443 } 444 444 … … 452 452 { 453 453 JOptionPane.showMessageDialog 454 (null, "Can't parse a time from this string.", "Invalid value",454 (null, tr("Can't parse a time from this string."), tr("Invalid value"), 455 455 JOptionPane.ERROR_MESSAGE); 456 456 return false; … … 477 477 { 478 478 JOptionPane.showMessageDialog 479 (null, "Can't parse a time from this string.", "Invalid value",479 (null, tr("Can't parse a time from this string."), tr("Invalid value"), 480 480 JOptionPane.ERROR_MESSAGE); 481 481 return false; -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSJoinCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 66 68 gtfsStopTM.nodes.set(j, dest); 67 69 type = (String)gtfsStopTM.getValueAt(j, 2); 68 gtfsStopTM.setValueAt( "moved", j, 2);70 gtfsStopTM.setValueAt(tr("moved"), j, 2); 69 71 70 72 return true; … … 106 108 @Override public JLabel getDescription() 107 109 { 108 return new JLabel( "public_transport.GTFSStops.Join");110 return new JLabel(tr("Public Transport: Join GTFS stops")); 109 111 } 110 112 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/GTFSStopTableModel.java
r25701 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 70 69 71 70 this.controller = controller; 72 addColumn( "Id");73 addColumn( "Name");74 addColumn( "State");71 addColumn(tr("Id")); 72 addColumn(tr("Name")); 73 addColumn(tr("State")); 75 74 addTableModelListener(this); 76 75 } … … 138 137 public void insertRow(int insPos, String s, Vector< Node > existingStops) 139 138 { 140 String[] buf = { "", "", "pending"};139 String[] buf = { "", "", tr("pending") }; 141 140 int pos = tokenize(s, 0); 142 141 int oldPos = 0; … … 176 175 while (iter.hasNext()) 177 176 { 178 if (iter.next().bounds.contains(coor))179 {180 inside = true;181 break;182 }177 if (iter.next().bounds.contains(coor)) 178 { 179 inside = true; 180 break; 181 } 183 182 } 184 183 if (!inside) 185 buf[2] = "outside";184 buf[2] = tr("outside"); 186 185 } 187 186 … … 193 192 if (coor.greatCircleDistance(node.getCoor()) < 1000) 194 193 { 195 nearBusStop = true;196 break;194 nearBusStop = true; 195 break; 197 196 } 198 197 } … … 200 199 if (insPos == -1) 201 200 { 202 if ((nearBusStop) || !( "pending".equals(buf[2])))203 nodes.addElement(null);201 if ((nearBusStop) || !(tr("pending").equals(buf[2]))) 202 nodes.addElement(null); 204 203 else 205 204 { 206 Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);207 nodes.addElement(node);208 buf[2] = "added";205 Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]); 206 nodes.addElement(node); 207 buf[2] = tr("added"); 209 208 } 210 209 coors.addElement(coor); … … 213 212 else 214 213 { 215 if ((nearBusStop) || !( "pending".equals(buf[2])))216 nodes.insertElementAt(null, insPos);214 if ((nearBusStop) || !(tr("pending").equals(buf[2]))) 215 nodes.insertElementAt(null, insPos); 217 216 else 218 217 { 219 Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);220 nodes.insertElementAt(node, insPos);221 buf[2] = "added";218 Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]); 219 nodes.insertElementAt(node, insPos); 220 buf[2] = tr("added"); 222 221 } 223 222 coors.insertElementAt(coor, insPos); -
applications/editors/josm/plugins/public_transport/src/public_transport/ItineraryTableModel.java
r23192 r26168 1 1 package public_transport; 2 2 3 // import static org.openstreetmap.josm.tools.I18n.marktr; 4 // import static org.openstreetmap.josm.tools.I18n.tr; 5 // 6 // import java.awt.BorderLayout; 7 // import java.awt.Container; 8 // import java.awt.Dimension; 9 // import java.awt.Frame; 10 // import java.awt.GridBagConstraints; 11 // import java.awt.GridBagLayout; 12 // import java.awt.event.ActionEvent; 13 // import java.util.Collection; 14 // import java.util.Collections; 15 // import java.util.Iterator; 16 // import java.util.LinkedList; 17 // import java.util.List; 18 // import java.util.ListIterator; 19 // import java.util.Map; 20 // import java.util.TreeMap; 21 // import java.util.TreeSet; 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 22 5 import java.util.Vector; 23 // 24 // import javax.swing.DefaultCellEditor; 25 // import javax.swing.DefaultListModel; 26 // import javax.swing.JButton; 27 // import javax.swing.JCheckBox; 28 // import javax.swing.JComboBox; 29 // import javax.swing.JDialog; 30 // import javax.swing.JLabel; 31 // import javax.swing.JList; 32 // import javax.swing.JOptionPane; 33 // import javax.swing.JPanel; 34 // import javax.swing.JScrollPane; 35 // import javax.swing.JTabbedPane; 36 // import javax.swing.JTable; 37 // import javax.swing.JTextField; 38 // import javax.swing.ListSelectionModel; 39 // import javax.swing.event.ListSelectionEvent; 40 // import javax.swing.event.ListSelectionListener; 6 41 7 import javax.swing.event.TableModelEvent; 42 8 import javax.swing.event.TableModelListener; 43 9 import javax.swing.table.DefaultTableModel; 44 // import javax.swing.table.TableCellEditor; 45 // 46 // import org.openstreetmap.josm.Main; 47 // import org.openstreetmap.josm.actions.JosmAction; 48 // import org.openstreetmap.josm.actions.mapmode.DeleteAction; 49 // import org.openstreetmap.josm.data.osm.DataSet; 10 50 11 import org.openstreetmap.josm.data.osm.Node; 51 // import org.openstreetmap.josm.data.osm.OsmPrimitive;52 // import org.openstreetmap.josm.data.osm.Relation;53 // import org.openstreetmap.josm.data.osm.RelationMember;54 12 import org.openstreetmap.josm.data.osm.Way; 55 // import org.openstreetmap.josm.data.osm.visitor.BoundingXYVisitor;56 // import org.openstreetmap.josm.gui.ExtendedDialog;57 // import org.openstreetmap.josm.tools.GBC;58 // import org.openstreetmap.josm.tools.Shortcut;59 // import org.openstreetmap.josm.tools.UrlLabel;60 13 61 14 public class ItineraryTableModel extends DefaultTableModel … … 104 57 String curName = way.get("name"); 105 58 if (way.isIncomplete()) 106 buf[0] = "[incomplete]";59 buf[0] = tr("[incomplete]"); 107 60 else if (way.getNodesCount() < 1) 108 buf[0] = "[empty way]";61 buf[0] = tr("[empty way]"); 109 62 else if (curName != null) 110 63 buf[0] = curName; 111 64 else 112 buf[0] = "[ID] " + (new Long(way.getId())).toString();65 buf[0] = tr("[ID] {0}", (new Long(way.getId())).toString()); 113 66 buf[1] = role; 114 67 if (insPos == -1) … … 139 92 if (ways.elementAt(i) == null) 140 93 { 141 ++i;142 if (i >= getRowCount())143 break;94 ++i; 95 if (i >= getRowCount()) 96 break; 144 97 } 145 98 while ((ways.elementAt(i) == null) && 146 ((i == 0) || (ways.elementAt(i-1) == null)))99 ((i == 0) || (ways.elementAt(i-1) == null))) 147 100 { 148 ways.removeElementAt(i);149 removeRow(i);150 if (i >= getRowCount())151 break;101 ways.removeElementAt(i); 102 removeRow(i); 103 if (i >= getRowCount()) 104 break; 152 105 } 153 106 if (i >= getRowCount()) 154 break;107 break; 155 108 156 109 boolean gapRequired = gapNecessary … … 158 111 if ((i > 0) && (!gapRequired) && (ways.elementAt(i-1) == null)) 159 112 { 160 ways.removeElementAt(i-1);161 removeRow(i-1);162 --i;113 ways.removeElementAt(i-1); 114 removeRow(i-1); 115 --i; 163 116 } 164 117 else if ((i > 0) && gapRequired && (ways.elementAt(i-1) != null)) 165 118 { 166 String[] buf = { "", "" };167 buf[0] = "[gap]";168 insertRow(i, buf);169 ++i;119 String[] buf = { "", "" }; 120 buf[0] = tr("[gap]"); 121 insertRow(i, buf); 122 ++i; 170 123 } 171 124 lastNode = getLastNode(ways.elementAt(i), (String)(getValueAt(i, 1))); … … 185 138 { 186 139 if (inEvent) 187 return;140 return; 188 141 cleanupGaps(); 189 142 RoutePatternAction.rebuildWays(); … … 198 151 { 199 152 if ("backward".equals(role)) 200 return way.getNode(0);153 return way.getNode(0); 201 154 else 202 return way.getNode(way.getNodesCount() - 1);155 return way.getNode(way.getNodesCount() - 1); 203 156 } 204 157 } … … 210 163 Node firstNode = null; 211 164 if ("backward".equals(role)) 212 firstNode = way.getNode(way.getNodesCount() - 1);165 firstNode = way.getNode(way.getNodesCount() - 1); 213 166 else 214 firstNode = way.getNode(0);167 firstNode = way.getNode(0); 215 168 if ((lastNode != null) && (!lastNode.equals(firstNode))) 216 return true;169 return true; 217 170 } 218 171 return false; -
applications/editors/josm/plugins/public_transport/src/public_transport/PublicTransportPlugin.java
r23192 r26168 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.marktr; 4 import static org.openstreetmap.josm.tools.I18n.tr;5 4 6 5 import java.awt.event.KeyEvent; -
applications/editors/josm/plugins/public_transport/src/public_transport/RoutePatternAction.java
r26147 r26168 85 85 if (route.get("route") != null) 86 86 { 87 if (rr.route.get("route") == null) 88 return -1; 89 int result = route.get("route").compareTo(rr.route.get("route")); 90 if (result != 0) 87 if (rr.route.get("route") == null) 88 return -1; 89 int result = route.get("route").compareTo(rr.route.get("route")); 90 if (result != 0) 91 return result; 92 } 93 else if (rr.route.get("route") != null) 94 return 1; 95 if (route.get("ref") != null) 96 { 97 if (rr.route.get("ref") == null) 98 return -1; 99 int result = route.get("ref").compareTo(rr.route.get("ref")); 100 if (result != 0) 91 101 return result; 92 102 } 93 else if (rr.route.get("route") != null)94 return 1;95 if (route.get("ref") != null)96 {97 if (rr.route.get("ref") == null)98 return -1;99 int result = route.get("ref").compareTo(rr.route.get("ref"));100 if (result != 0)101 return result;102 }103 103 else if (rr.route.get("ref") != null) 104 return 1;104 return 1; 105 105 if (route.get("to") != null) 106 106 { 107 if (rr.route.get("to") == null)108 return -1;109 int result = route.get("to").compareTo(rr.route.get("to"));110 if (result != 0)111 return result;107 if (rr.route.get("to") == null) 108 return -1; 109 int result = route.get("to").compareTo(rr.route.get("to")); 110 if (result != 0) 111 return result; 112 112 } 113 113 else if (rr.route.get("to") != null) 114 return 1;114 return 1; 115 115 if (route.get("direction") != null) 116 116 { 117 if (rr.route.get("direction") == null)118 return -1;119 int result = route.get("direction").compareTo(rr.route.get("direction"));120 if (result != 0)121 return result;117 if (rr.route.get("direction") == null) 118 return -1; 119 int result = route.get("direction").compareTo(rr.route.get("direction")); 120 if (result != 0) 121 return result; 122 122 } 123 123 else if (rr.route.get("direction") != null) 124 return 1;124 return 1; 125 125 if (route.getId() < rr.route.getId()) 126 return -1;126 return -1; 127 127 else if (route.getId() > rr.route.getId()) 128 return 1;128 return 1; 129 129 return 0; 130 130 } … … 134 134 if ((route.get("ref") != null) && (route.get("ref") != "")) 135 135 { 136 if ((route.get("to") != null) && (route.get("to") != ""))137 {138 buf += " " + route.get("ref") + ": " + route.get("to");139 }140 else if ((route.get("direction") != null) && (route.get("direction") != ""))141 {142 buf += " " + route.get("ref") + ": " + route.get("direction");143 }144 else145 {146 buf += " " + route.get("ref");147 }148 } 149 buf += " [ID " + Long.toString(route.getId()) + "]";136 if ((route.get("to") != null) && (route.get("to") != "")) 137 { 138 buf += " " + route.get("ref") + ": " + route.get("to"); 139 } 140 else if ((route.get("direction") != null) && (route.get("direction") != "")) 141 { 142 buf += " " + route.get("ref") + ": " + route.get("direction"); 143 } 144 else 145 { 146 buf += " " + route.get("ref"); 147 } 148 } 149 buf += tr(" [ID] {0}", Long.toString(route.getId())); 150 150 151 151 return buf; … … 164 164 public boolean isCellEditable(int row, int column) { 165 165 if ((column == 0) && (hasFixedKeys)) 166 return false;166 return false; 167 167 return true; 168 168 } … … 173 173 for (int i = 0; i < getRowCount(); ++i) 174 174 { 175 String value = rel.get((String)getValueAt(i, 0));176 if (value == null)177 value = "";178 setValueAt(value, i, 1);175 String value = rel.get((String)getValueAt(i, 0)); 176 if (value == null) 177 value = ""; 178 setValueAt(value, i, 1); 179 179 } 180 180 } … … 188 188 while (iter.hasNext()) 189 189 { 190 Map.Entry< String, String > entry = iter.next();191 if (!blacklist.contains(entry.getKey()))192 {193 Vector< String > newRow = new Vector< String >();194 newRow.add(entry.getKey());195 newRow.add(entry.getValue());196 addRow(newRow);197 }190 Map.Entry< String, String > entry = iter.next(); 191 if (!blacklist.contains(entry.getKey())) 192 { 193 Vector< String > newRow = new Vector< String >(); 194 newRow.add(entry.getKey()); 195 newRow.add(entry.getValue()); 196 addRow(newRow); 197 } 198 198 } 199 199 200 200 for (int i = 0; i < getRowCount(); ++i) 201 201 { 202 String value = rel.get((String)getValueAt(i, 0));203 if (value == null)204 value = "";205 setValueAt(value, i, 1);202 String value = rel.get((String)getValueAt(i, 0)); 203 if (value == null) 204 value = ""; 205 setValueAt(value, i, 1); 206 206 } 207 207 } … … 211 211 if (e.getType() == TableModelEvent.UPDATE) 212 212 { 213 relation.setModified(true);214 215 String key = (String)getValueAt(e.getFirstRow(), 0);216 if (key == null)217 return;218 if ((blacklist == null) || (!blacklist.contains(key)))219 {220 relation.setModified(true);221 if ("".equals(getValueAt(e.getFirstRow(), 1)))222 relation.remove(key);223 else224 relation.put(key, (String)getValueAt(e.getFirstRow(), 1));225 }226 else227 {228 if (e.getColumn() == 0)229 setValueAt("", e.getFirstRow(), 0);230 }213 relation.setModified(true); 214 215 String key = (String)getValueAt(e.getFirstRow(), 0); 216 if (key == null) 217 return; 218 if ((blacklist == null) || (!blacklist.contains(key))) 219 { 220 relation.setModified(true); 221 if ("".equals(getValueAt(e.getFirstRow(), 1))) 222 relation.remove(key); 223 else 224 relation.put(key, (String)getValueAt(e.getFirstRow(), 1)); 225 } 226 else 227 { 228 if (e.getColumn() == 0) 229 setValueAt("", e.getFirstRow(), 0); 230 } 231 231 } 232 232 } … … 245 245 TableCellEditor editor = null; 246 246 if (column == 0) 247 editor = col1.get(new Integer(row));247 editor = col1.get(new Integer(row)); 248 248 else 249 editor = col2.get(new Integer(row));249 editor = col2.get(new Integer(row)); 250 250 if (editor == null) 251 return new DefaultCellEditor(new JTextField());251 return new DefaultCellEditor(new JTextField()); 252 252 else 253 return editor;253 return editor; 254 254 } 255 255 256 256 public void setCellEditor(int row, int column, TableCellEditor editor) { 257 257 if (column == 0) 258 col1.put(new Integer(row), editor);258 col1.put(new Integer(row), editor); 259 259 else 260 col2.put(new Integer(row), editor);260 col2.put(new Integer(row), editor); 261 261 } 262 262 }; … … 293 293 else 294 294 { 295 buf[0] = "[ID] " + (new Long(node.getId())).toString();295 buf[0] = tr("[ID] {0}", (new Long(node.getId())).toString()); 296 296 } 297 297 String curRef = node.get("ref"); … … 325 325 if (e.getType() == TableModelEvent.UPDATE) 326 326 { 327 rebuildNodes();327 rebuildNodes(); 328 328 } 329 329 } … … 427 427 if (jDialog == null) 428 428 { 429 jDialog = new JDialog(frame, "Route Patterns", false);429 jDialog = new JDialog(frame, tr("Route Patterns"), false); 430 430 tabbedPane = new JTabbedPane(); 431 431 JPanel tabOverview = new JPanel(); 432 tabbedPane.addTab( marktr("Overview"), tabOverview);432 tabbedPane.addTab(tr("Overview"), tabOverview); 433 433 JPanel tabTags = new JPanel(); 434 tabbedPane.addTab( marktr("Tags"), tabTags);434 tabbedPane.addTab(tr("Tags"), tabTags); 435 435 JPanel tabItinerary = new JPanel(); 436 tabbedPane.addTab( marktr("Itinerary"), tabItinerary);436 tabbedPane.addTab(tr("Itinerary"), tabItinerary); 437 437 JPanel tabStoplist = new JPanel(); 438 tabbedPane.addTab( marktr("Stops"), tabStoplist);438 tabbedPane.addTab(tr("Stops"), tabStoplist); 439 439 JPanel tabMeta = new JPanel(); 440 tabbedPane.addTab( marktr("Meta"), tabMeta);440 tabbedPane.addTab(tr("Meta"), tabMeta); 441 441 tabbedPane.setEnabledAt(0, true); 442 442 tabbedPane.setEnabledAt(1, false); … … 452 452 contentPane.setLayout(gridbag); 453 453 454 JLabel headline = new JLabel( "Existing route patterns:");454 JLabel headline = new JLabel(tr("Existing route patterns:")); 455 455 456 456 layoutCons.gridx = 0; … … 480 480 contentPane.add(rpListSP); 481 481 482 JButton bRefresh = new JButton( "Refresh");482 JButton bRefresh = new JButton(tr("Refresh")); 483 483 bRefresh.setActionCommand("routePattern.refresh"); 484 484 bRefresh.addActionListener(this); … … 494 494 contentPane.add(bRefresh); 495 495 496 JButton bNew = new JButton( "New");496 JButton bNew = new JButton(tr("New")); 497 497 bNew.setActionCommand("routePattern.overviewNew"); 498 498 bNew.addActionListener(this); … … 508 508 contentPane.add(bNew); 509 509 510 JButton bDelete = new JButton( "Delete");510 JButton bDelete = new JButton(tr("Delete")); 511 511 bDelete.setActionCommand("routePattern.overviewDelete"); 512 512 bDelete.addActionListener(this); … … 522 522 contentPane.add(bDelete); 523 523 524 JButton bDuplicate = new JButton( "Duplicate");524 JButton bDuplicate = new JButton(tr("Duplicate")); 525 525 bDuplicate.setActionCommand("routePattern.overviewDuplicate"); 526 526 bDuplicate.addActionListener(this); … … 536 536 contentPane.add(bDuplicate); 537 537 538 JButton bReflect = new JButton( "Reflect");538 JButton bReflect = new JButton(tr("Reflect")); 539 539 bReflect.setActionCommand("routePattern.overviewReflect"); 540 540 bReflect.addActionListener(this); … … 556 556 contentPane.setLayout(gridbag); 557 557 558 /*JLabel*/ headline = new JLabel( "Required tags:");558 /*JLabel*/ headline = new JLabel(tr("Required tags:")); 559 559 560 560 layoutCons.gridx = 0; … … 568 568 requiredTagsTable = new CustomCellEditorTable(); 569 569 requiredTagsData = new TagTableModel(true); 570 requiredTagsData.addColumn( "Key");571 requiredTagsData.addColumn( "Value");570 requiredTagsData.addColumn(tr("Key")); 571 requiredTagsData.addColumn(tr("Value")); 572 572 tagBlacklist = new TreeSet< String >(); 573 573 Vector< String > rowContent = new Vector< String >(); 574 /* TODO: keys and values should also be translated using TransText class */ 574 575 rowContent.add("type"); 575 576 tagBlacklist.add("type"); … … 622 623 contentPane.add(tableSP); 623 624 624 headline = new JLabel( "Common tags:");625 headline = new JLabel(tr("Common tags:")); 625 626 626 627 layoutCons.gridx = 0; … … 634 635 commonTagsTable = new CustomCellEditorTable(); 635 636 commonTagsData = new TagTableModel(true); 636 commonTagsData.addColumn( "Key");637 commonTagsData.addColumn( "Value");637 commonTagsData.addColumn(tr("Key")); 638 commonTagsData.addColumn(tr("Value")); 638 639 rowContent = new Vector< String >(); 639 640 rowContent.add(0, "direction"); … … 676 677 contentPane.add(tableSP); 677 678 678 headline = new JLabel( "Additional tags:");679 headline = new JLabel(tr("Additional tags:")); 679 680 680 681 layoutCons.gridx = 0; … … 688 689 otherTagsTable = new CustomCellEditorTable(); 689 690 otherTagsData = new TagTableModel(false); 690 otherTagsData.addColumn( "Key");691 otherTagsData.addColumn( "Value");691 otherTagsData.addColumn(tr("Key")); 692 otherTagsData.addColumn(tr("Value")); 692 693 otherTagsTable.setModel(otherTagsData); 693 694 /*JScrollPane*/ tableSP = new JScrollPane(otherTagsTable); … … 705 706 contentPane.add(tableSP); 706 707 707 JButton bAddTag = new JButton( "Add a new Tag");708 JButton bAddTag = new JButton(tr("Add a new Tag")); 708 709 bAddTag.setActionCommand("routePattern.tagAddTag"); 709 710 bAddTag.addActionListener(this); … … 726 727 itineraryTable = new JTable(); 727 728 itineraryData = new ItineraryTableModel(); 728 itineraryData.addColumn( "Name/Id");729 itineraryData.addColumn( "Role");729 itineraryData.addColumn(tr("Name/Id")); 730 itineraryData.addColumn(tr("Role")); 730 731 itineraryTable.setModel(itineraryData); 731 732 /*JScrollPane*/ tableSP = new JScrollPane(itineraryTable); … … 747 748 contentPane.add(tableSP); 748 749 749 JButton bFind = new JButton( "Find");750 JButton bFind = new JButton(tr("Find")); 750 751 bFind.setActionCommand("routePattern.itineraryFind"); 751 752 bFind.addActionListener(this); … … 760 761 contentPane.add(bFind); 761 762 762 JButton bShow = new JButton( "Show");763 JButton bShow = new JButton(tr("Show")); 763 764 bShow.setActionCommand("routePattern.itineraryShow"); 764 765 bShow.addActionListener(this); … … 773 774 contentPane.add(bShow); 774 775 775 JButton bMark = new JButton( "Mark");776 JButton bMark = new JButton(tr("Mark")); 776 777 bMark.setActionCommand("routePattern.itineraryMark"); 777 778 bMark.addActionListener(this); … … 787 788 contentPane.add(bMark); 788 789 789 JButton bAdd = new JButton( "Add");790 JButton bAdd = new JButton(tr("Add")); 790 791 bAdd.setActionCommand("routePattern.itineraryAdd"); 791 792 bAdd.addActionListener(this); … … 801 802 contentPane.add(bAdd); 802 803 803 /*JButton*/ bDelete = new JButton( "Delete");804 /*JButton*/ bDelete = new JButton(tr("Delete")); 804 805 bDelete.setActionCommand("routePattern.itineraryDelete"); 805 806 bDelete.addActionListener(this); … … 814 815 contentPane.add(bDelete); 815 816 816 JButton bSort = new JButton( "Sort");817 JButton bSort = new JButton(tr("Sort")); 817 818 bSort.setActionCommand("routePattern.itinerarySort"); 818 819 bSort.addActionListener(this); … … 827 828 contentPane.add(bSort); 828 829 829 /*JButton*/ bReflect = new JButton( "Reflect");830 /*JButton*/ bReflect = new JButton(tr("Reflect")); 830 831 bReflect.setActionCommand("routePattern.itineraryReflect"); 831 832 bReflect.addActionListener(this); … … 848 849 stoplistTable = new JTable(); 849 850 stoplistData = new StoplistTableModel(); 850 stoplistData.addColumn( "Name/Id");851 stoplistData.addColumn( "Ref");852 stoplistData.addColumn( "Role");851 stoplistData.addColumn(tr("Name/Id")); 852 stoplistData.addColumn(tr("Ref")); 853 stoplistData.addColumn(tr("Role")); 853 854 stoplistTable.setModel(stoplistData); 854 855 /*JScrollPane*/ tableSP = new JScrollPane(stoplistTable); … … 870 871 contentPane.add(tableSP); 871 872 872 /*JButton*/ bFind = new JButton( "Find");873 /*JButton*/ bFind = new JButton(tr("Find")); 873 874 bFind.setActionCommand("routePattern.stoplistFind"); 874 875 bFind.addActionListener(this); … … 883 884 contentPane.add(bFind); 884 885 885 /*JButton*/ bShow = new JButton( "Show");886 /*JButton*/ bShow = new JButton(tr("Show")); 886 887 bShow.setActionCommand("routePattern.stoplistShow"); 887 888 bShow.addActionListener(this); … … 896 897 contentPane.add(bShow); 897 898 898 /*JButton*/ bMark = new JButton( "Mark");899 /*JButton*/ bMark = new JButton(tr("Mark")); 899 900 bMark.setActionCommand("routePattern.stoplistMark"); 900 901 bMark.addActionListener(this); … … 910 911 contentPane.add(bMark); 911 912 912 /*JButton*/ bAdd = new JButton( "Add");913 /*JButton*/ bAdd = new JButton(tr("Add")); 913 914 bAdd.setActionCommand("routePattern.stoplistAdd"); 914 915 bAdd.addActionListener(this); … … 924 925 contentPane.add(bAdd); 925 926 926 /*JButton*/ bDelete = new JButton( "Delete");927 /*JButton*/ bDelete = new JButton(tr("Delete")); 927 928 bDelete.setActionCommand("routePattern.stoplistDelete"); 928 929 bDelete.addActionListener(this); … … 937 938 contentPane.add(bDelete); 938 939 939 /*JButton*/ bSort = new JButton( "Sort");940 /*JButton*/ bSort = new JButton(tr("Sort")); 940 941 bSort.setActionCommand("routePattern.stoplistSort"); 941 942 bSort.addActionListener(this); … … 950 951 contentPane.add(bSort); 951 952 952 /*JButton*/ bReflect = new JButton( "Reflect");953 /*JButton*/ bReflect = new JButton(tr("Reflect")); 953 954 bReflect.setActionCommand("routePattern.stoplistReflect"); 954 955 bReflect.addActionListener(this); … … 969 970 contentPane.setLayout(gridbag); 970 971 971 JLabel rightleft = new JLabel( "Stops are possible on the");972 JLabel rightleft = new JLabel(tr("Stops are possible on the")); 972 973 973 974 layoutCons.gridx = 0; … … 980 981 contentPane.add(rightleft); 981 982 982 cbRight = new JCheckBox( "right hand side", true);983 cbRight = new JCheckBox(tr("right hand side"), true); 983 984 984 985 layoutCons.gridx = 0; … … 991 992 contentPane.add(cbRight); 992 993 993 cbLeft = new JCheckBox( "left hand side", false);994 cbLeft = new JCheckBox(tr("left hand side"), false); 994 995 995 996 layoutCons.gridx = 0; … … 1002 1003 contentPane.add(cbLeft); 1003 1004 1004 JLabel maxdist = new JLabel( "Maximum distance from route");1005 JLabel maxdist = new JLabel(tr("Maximum distance from route")); 1005 1006 1006 1007 layoutCons.gridx = 0; … … 1024 1025 contentPane.add(tfSuggestStopsLimit); 1025 1026 1026 JLabel meters = new JLabel( "meters");1027 JLabel meters = new JLabel(tr("meters")); 1027 1028 1028 1029 layoutCons.gridx = 1; … … 1035 1036 contentPane.add(meters); 1036 1037 1037 JButton bSuggestStops = new JButton( "Suggest Stops");1038 JButton bSuggestStops = new JButton(tr("Suggest Stops")); 1038 1039 bSuggestStops.setActionCommand("routePattern.metaSuggestStops"); 1039 1040 bSuggestStops.addActionListener(this); … … 1099 1100 for (int i = 0; i < currentRoute.getMembersCount(); ++i) 1100 1101 { 1101 RelationMember item = currentRoute.getMember(i);1102 1103 if (item.isWay())1104 {1105 String role = item.getRole();1106 if ("backward".equals(role))1107 role = "forward";1108 else if ("forward".equals(role))1109 role = "backward";1110 else1111 role = "backward";1112 1113 itemsToReflect.add(new RelationMember(role, item.getWay()));1114 }1115 else if (item.isNode())1116 itemsToReflect.add(item);1117 else1118 otherItems.add(item);1102 RelationMember item = currentRoute.getMember(i); 1103 1104 if (item.isWay()) 1105 { 1106 String role = item.getRole(); 1107 if ("backward".equals(role)) 1108 role = "forward"; 1109 else if ("forward".equals(role)) 1110 role = "backward"; 1111 else 1112 role = "backward"; 1113 1114 itemsToReflect.add(new RelationMember(role, item.getWay())); 1115 } 1116 else if (item.isNode()) 1117 itemsToReflect.add(item); 1118 else 1119 otherItems.add(item); 1119 1120 } 1120 1121 1121 1122 currentRoute.setMembers(null); 1122 1123 for (int i = itemsToReflect.size()-1; i >= 0; --i) 1123 currentRoute.addMember(itemsToReflect.elementAt(i));1124 currentRoute.addMember(itemsToReflect.elementAt(i)); 1124 1125 for (int i = 0; i < otherItems.size(); ++i) 1125 currentRoute.addMember(otherItems.elementAt(i));1126 currentRoute.addMember(otherItems.elementAt(i)); 1126 1127 1127 1128 refreshData(); … … 1129 1130 for (int i = 0; i < relsListModel.size(); ++i) 1130 1131 { 1131 if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)1132 relsList.setSelectedIndex(i);1132 if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route) 1133 relsList.setSelectedIndex(i); 1133 1134 } 1134 1135 } … … 1155 1156 { 1156 1157 if (mainDataSet == null) 1157 return;1158 return; 1158 1159 1159 1160 itineraryTable.clearSelection(); … … 1161 1162 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1162 1163 { 1163 if ((itineraryData.ways.elementAt(i) != null) &&1164 (mainDataSet.isSelected(itineraryData.ways.elementAt(i))))1165 itineraryTable.addRowSelectionInterval(i, i);1164 if ((itineraryData.ways.elementAt(i) != null) && 1165 (mainDataSet.isSelected(itineraryData.ways.elementAt(i)))) 1166 itineraryTable.addRowSelectionInterval(i, i); 1166 1167 } 1167 1168 } … … 1171 1172 if (itineraryTable.getSelectedRowCount() > 0) 1172 1173 { 1173 for (int i = 0; i < itineraryData.getRowCount(); ++i)1174 {1175 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))1176 {1177 itineraryData.ways.elementAt(i).visit(box);1178 }1179 }1174 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1175 { 1176 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null)) 1177 { 1178 itineraryData.ways.elementAt(i).visit(box); 1179 } 1180 } 1180 1181 } 1181 1182 else 1182 1183 { 1183 for (int i = 0; i < itineraryData.getRowCount(); ++i)1184 {1185 if (itineraryData.ways.elementAt(i) != null)1186 {1187 itineraryData.ways.elementAt(i).visit(box);1188 }1189 }1184 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1185 { 1186 if (itineraryData.ways.elementAt(i) != null) 1187 { 1188 itineraryData.ways.elementAt(i).visit(box); 1189 } 1190 } 1190 1191 } 1191 1192 if (box.getBounds() == null) 1192 return;1193 return; 1193 1194 box.enlargeBoundingBox(); 1194 1195 Main.map.mapView.recalculateCenterScale(box); … … 1201 1202 if (itineraryTable.getSelectedRowCount() > 0) 1202 1203 { 1203 for (int i = 0; i < itineraryData.getRowCount(); ++i)1204 {1205 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))1206 {1207 mainDataSet.addSelected(itineraryData.ways.elementAt(i));1208 1209 RelationMember markedWay = new RelationMember1210 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));1211 markedWays.addElement(markedWay);1212 }1213 }1204 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1205 { 1206 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null)) 1207 { 1208 mainDataSet.addSelected(itineraryData.ways.elementAt(i)); 1209 1210 RelationMember markedWay = new RelationMember 1211 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i)); 1212 markedWays.addElement(markedWay); 1213 } 1214 } 1214 1215 } 1215 1216 else 1216 1217 { 1217 for (int i = 0; i < itineraryData.getRowCount(); ++i)1218 {1219 if (itineraryData.ways.elementAt(i) != null)1220 {1221 mainDataSet.addSelected(itineraryData.ways.elementAt(i));1222 1223 RelationMember markedWay = new RelationMember1224 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));1225 markedWays.addElement(markedWay);1226 }1227 }1218 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1219 { 1220 if (itineraryData.ways.elementAt(i) != null) 1221 { 1222 mainDataSet.addSelected(itineraryData.ways.elementAt(i)); 1223 1224 RelationMember markedWay = new RelationMember 1225 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i)); 1226 markedWays.addElement(markedWay); 1227 } 1228 } 1228 1229 } 1229 1230 } … … 1234 1235 TreeSet<Way> addedWays = new TreeSet<Way>(); 1235 1236 if (mainDataSet == null) 1236 return;1237 return; 1237 1238 1238 1239 while (relIter.hasNext()) 1239 1240 { 1240 RelationMember curMember = relIter.next();1241 if ((curMember.isWay()) && (mainDataSet.isSelected(curMember.getWay())))1242 {1243 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());1244 if (insPos >= 0)1245 ++insPos;1246 1247 addedWays.add(curMember.getWay());1248 }1241 RelationMember curMember = relIter.next(); 1242 if ((curMember.isWay()) && (mainDataSet.isSelected(curMember.getWay()))) 1243 { 1244 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 1245 if (insPos >= 0) 1246 ++insPos; 1247 1248 addedWays.add(curMember.getWay()); 1249 } 1249 1250 } 1250 1251 … … 1254 1255 while (wayIter.hasNext()) 1255 1256 { 1256 Way curMember = wayIter.next();1257 if (!(addedWays.contains(curMember)))1258 {1259 itineraryData.insertRow(insPos, curMember, "");1260 if (insPos >= 0)1261 ++insPos;1262 }1257 Way curMember = wayIter.next(); 1258 if (!(addedWays.contains(curMember))) 1259 { 1260 itineraryData.insertRow(insPos, curMember, ""); 1261 if (insPos >= 0) 1262 ++insPos; 1263 } 1263 1264 } 1264 1265 1265 1266 if ((insPos > 0) && (insPos < itineraryData.getRowCount())) 1266 1267 { 1267 while ((insPos < itineraryData.getRowCount())1268 && (itineraryData.ways.elementAt(insPos) == null))1269 ++insPos;1270 itineraryTable.removeRowSelectionInterval(0, itineraryData.getRowCount()-1);1271 if (insPos < itineraryData.getRowCount())1272 itineraryTable.addRowSelectionInterval(insPos, insPos);1268 while ((insPos < itineraryData.getRowCount()) 1269 && (itineraryData.ways.elementAt(insPos) == null)) 1270 ++insPos; 1271 itineraryTable.removeRowSelectionInterval(0, itineraryData.getRowCount()-1); 1272 if (insPos < itineraryData.getRowCount()) 1273 itineraryTable.addRowSelectionInterval(insPos, insPos); 1273 1274 } 1274 1275 … … 1280 1281 for (int i = itineraryData.getRowCount()-1; i >=0; --i) 1281 1282 { 1282 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))1283 {1284 itineraryData.ways.removeElementAt(i);1285 itineraryData.removeRow(i);1286 }1283 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null)) 1284 { 1285 itineraryData.ways.removeElementAt(i); 1286 itineraryData.removeRow(i); 1287 } 1287 1288 } 1288 1289 … … 1303 1304 if (itineraryTable.getSelectedRowCount() > 0) 1304 1305 { 1305 for (int i = itineraryData.getRowCount()-1; i >=0; --i)1306 {1307 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))1308 {1309 if (!(usedWays.contains(itineraryData.ways.elementAt(i))))1310 {1311 addWayToSortingData1312 (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);1313 usedWays.add(itineraryData.ways.elementAt(i));1314 }1315 1316 itineraryData.ways.removeElementAt(i);1317 itineraryData.removeRow(i);1318 }1319 }1306 for (int i = itineraryData.getRowCount()-1; i >=0; --i) 1307 { 1308 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null)) 1309 { 1310 if (!(usedWays.contains(itineraryData.ways.elementAt(i)))) 1311 { 1312 addWayToSortingData 1313 (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops); 1314 usedWays.add(itineraryData.ways.elementAt(i)); 1315 } 1316 1317 itineraryData.ways.removeElementAt(i); 1318 itineraryData.removeRow(i); 1319 } 1320 } 1320 1321 } 1321 1322 else 1322 1323 { 1323 for (int i = itineraryData.getRowCount()-1; i >=0; --i)1324 {1325 if (itineraryData.ways.elementAt(i) != null)1326 {1327 if (!(usedWays.contains(itineraryData.ways.elementAt(i))))1328 {1329 addWayToSortingData1330 (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);1331 usedWays.add(itineraryData.ways.elementAt(i));1332 }1333 }1334 }1335 1336 itineraryData.clear();1324 for (int i = itineraryData.getRowCount()-1; i >=0; --i) 1325 { 1326 if (itineraryData.ways.elementAt(i) != null) 1327 { 1328 if (!(usedWays.contains(itineraryData.ways.elementAt(i)))) 1329 { 1330 addWayToSortingData 1331 (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops); 1332 usedWays.add(itineraryData.ways.elementAt(i)); 1333 } 1334 } 1335 } 1336 1337 itineraryData.clear(); 1337 1338 } 1338 1339 … … 1341 1342 while (entryIter.hasNext()) 1342 1343 { 1343 Iterator<RelationMember> relIter = entryIter.next().getValue().iterator();1344 while (relIter.hasNext())1345 {1346 RelationMember curMember = relIter.next();1347 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());1348 if (insPos >= 0)1349 ++insPos;1350 }1344 Iterator<RelationMember> relIter = entryIter.next().getValue().iterator(); 1345 while (relIter.hasNext()) 1346 { 1347 RelationMember curMember = relIter.next(); 1348 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 1349 if (insPos >= 0) 1350 ++insPos; 1351 } 1351 1352 } 1352 1353 … … 1354 1355 while (listIter.hasNext()) 1355 1356 { 1356 Iterator<RelationMember> relIter = listIter.next().iterator();1357 while (relIter.hasNext())1358 {1359 RelationMember curMember = relIter.next();1360 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());1361 if (insPos >= 0)1362 ++insPos;1363 }1357 Iterator<RelationMember> relIter = listIter.next().iterator(); 1358 while (relIter.hasNext()) 1359 { 1360 RelationMember curMember = relIter.next(); 1361 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 1362 if (insPos >= 0) 1363 ++insPos; 1364 } 1364 1365 } 1365 1366 … … 1374 1375 if (itineraryTable.getSelectedRowCount() > 0) 1375 1376 { 1376 for (int i = itineraryData.getRowCount()-1; i >=0; --i)1377 {1378 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))1379 {1380 String role = (String)(itineraryData.getValueAt(i, 1));1381 if ("backward".equals(role))1382 role = "forward";1383 else if ("forward".equals(role))1384 role = "backward";1385 else1386 role = "backward";1387 RelationMember markedWay = new RelationMember1388 (role, itineraryData.ways.elementAt(i));1389 itemsToReflect.addElement(markedWay);1390 1391 itineraryData.ways.removeElementAt(i);1392 itineraryData.removeRow(i);1393 }1394 }1377 for (int i = itineraryData.getRowCount()-1; i >=0; --i) 1378 { 1379 if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null)) 1380 { 1381 String role = (String)(itineraryData.getValueAt(i, 1)); 1382 if ("backward".equals(role)) 1383 role = "forward"; 1384 else if ("forward".equals(role)) 1385 role = "backward"; 1386 else 1387 role = "backward"; 1388 RelationMember markedWay = new RelationMember 1389 (role, itineraryData.ways.elementAt(i)); 1390 itemsToReflect.addElement(markedWay); 1391 1392 itineraryData.ways.removeElementAt(i); 1393 itineraryData.removeRow(i); 1394 } 1395 } 1395 1396 } 1396 1397 else 1397 1398 { 1398 for (int i = itineraryData.getRowCount()-1; i >=0; --i)1399 {1400 if (itineraryData.ways.elementAt(i) != null)1401 {1402 String role = (String)(itineraryData.getValueAt(i, 1));1403 if ("backward".equals(role))1404 role = "forward";1405 else if ("forward".equals(role))1406 role = "backward";1407 else1408 role = "backward";1409 RelationMember markedWay = new RelationMember1410 (role, itineraryData.ways.elementAt(i));1411 itemsToReflect.addElement(markedWay);1412 }1413 }1414 1415 itineraryData.clear();1399 for (int i = itineraryData.getRowCount()-1; i >=0; --i) 1400 { 1401 if (itineraryData.ways.elementAt(i) != null) 1402 { 1403 String role = (String)(itineraryData.getValueAt(i, 1)); 1404 if ("backward".equals(role)) 1405 role = "forward"; 1406 else if ("forward".equals(role)) 1407 role = "backward"; 1408 else 1409 role = "backward"; 1410 RelationMember markedWay = new RelationMember 1411 (role, itineraryData.ways.elementAt(i)); 1412 itemsToReflect.addElement(markedWay); 1413 } 1414 } 1415 1416 itineraryData.clear(); 1416 1417 } 1417 1418 … … 1420 1421 while (relIter.hasNext()) 1421 1422 { 1422 RelationMember curMember = relIter.next(); 1423 if (curMember.isWay()) 1424 { 1425 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 1423 RelationMember curMember = relIter.next(); 1424 if (curMember.isWay()) 1425 { 1426 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 1427 if (insPos >= 0) 1428 ++insPos; 1429 } 1430 } 1426 1431 if (insPos >= 0) 1427 ++insPos; 1428 } 1429 } 1430 if (insPos >= 0) 1431 itineraryTable.addRowSelectionInterval(startPos, insPos-1); 1432 itineraryTable.addRowSelectionInterval(startPos, insPos-1); 1432 1433 1433 1434 itineraryData.cleanupGaps(); … … 1437 1438 { 1438 1439 if (mainDataSet == null) 1439 return;1440 return; 1440 1441 1441 1442 stoplistTable.clearSelection(); … … 1443 1444 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1444 1445 { 1445 if ((stoplistData.nodes.elementAt(i) != null) &&1446 (mainDataSet.isSelected(stoplistData.nodes.elementAt(i))))1447 stoplistTable.addRowSelectionInterval(i, i);1446 if ((stoplistData.nodes.elementAt(i) != null) && 1447 (mainDataSet.isSelected(stoplistData.nodes.elementAt(i)))) 1448 stoplistTable.addRowSelectionInterval(i, i); 1448 1449 } 1449 1450 } … … 1453 1454 if (stoplistTable.getSelectedRowCount() > 0) 1454 1455 { 1455 for (int i = 0; i < stoplistData.getRowCount(); ++i)1456 {1457 if (stoplistTable.isRowSelected(i))1458 {1459 stoplistData.nodes.elementAt(i).visit(box);1460 }1461 }1456 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1457 { 1458 if (stoplistTable.isRowSelected(i)) 1459 { 1460 stoplistData.nodes.elementAt(i).visit(box); 1461 } 1462 } 1462 1463 } 1463 1464 else 1464 1465 { 1465 for (int i = 0; i < stoplistData.getRowCount(); ++i)1466 {1467 stoplistData.nodes.elementAt(i).visit(box);1468 }1466 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1467 { 1468 stoplistData.nodes.elementAt(i).visit(box); 1469 } 1469 1470 } 1470 1471 if (box.getBounds() == null) 1471 return;1472 return; 1472 1473 box.enlargeBoundingBox(); 1473 1474 Main.map.mapView.recalculateCenterScale(box); … … 1480 1481 if (stoplistTable.getSelectedRowCount() > 0) 1481 1482 { 1482 for (int i = 0; i < stoplistData.getRowCount(); ++i)1483 {1484 if (stoplistTable.isRowSelected(i))1485 {1486 mainDataSet.addSelected(stoplistData.nodes.elementAt(i));1487 1488 RelationMember markedNode = new RelationMember1489 ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));1490 markedNodes.addElement(markedNode);1491 }1492 }1483 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1484 { 1485 if (stoplistTable.isRowSelected(i)) 1486 { 1487 mainDataSet.addSelected(stoplistData.nodes.elementAt(i)); 1488 1489 RelationMember markedNode = new RelationMember 1490 ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i)); 1491 markedNodes.addElement(markedNode); 1492 } 1493 } 1493 1494 } 1494 1495 else 1495 1496 { 1496 for (int i = 0; i < stoplistData.getRowCount(); ++i)1497 {1498 mainDataSet.addSelected(stoplistData.nodes.elementAt(i));1499 1500 RelationMember markedNode = new RelationMember1501 ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));1502 markedNodes.addElement(markedNode);1503 }1497 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1498 { 1499 mainDataSet.addSelected(stoplistData.nodes.elementAt(i)); 1500 1501 RelationMember markedNode = new RelationMember 1502 ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i)); 1503 markedNodes.addElement(markedNode); 1504 } 1504 1505 } 1505 1506 } … … 1510 1511 TreeSet<Node> addedNodes = new TreeSet<Node>(); 1511 1512 if (mainDataSet == null) 1512 return;1513 return; 1513 1514 1514 1515 while (relIter.hasNext()) 1515 1516 { 1516 RelationMember curMember = relIter.next();1517 if ((curMember.isNode()) && (mainDataSet.isSelected(curMember.getNode())))1518 {1519 stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());1520 if (insPos >= 0)1521 ++insPos;1522 1523 addedNodes.add(curMember.getNode());1524 }1517 RelationMember curMember = relIter.next(); 1518 if ((curMember.isNode()) && (mainDataSet.isSelected(curMember.getNode()))) 1519 { 1520 stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole()); 1521 if (insPos >= 0) 1522 ++insPos; 1523 1524 addedNodes.add(curMember.getNode()); 1525 } 1525 1526 } 1526 1527 … … 1530 1531 while (nodeIter.hasNext()) 1531 1532 { 1532 Node curMember = nodeIter.next();1533 if (!(addedNodes.contains(curMember)))1534 {1535 stoplistData.insertRow(insPos, curMember, "");1536 if (insPos >= 0)1537 ++insPos;1538 }1533 Node curMember = nodeIter.next(); 1534 if (!(addedNodes.contains(curMember))) 1535 { 1536 stoplistData.insertRow(insPos, curMember, ""); 1537 if (insPos >= 0) 1538 ++insPos; 1539 } 1539 1540 } 1540 1541 1541 1542 if ((insPos > 0) && (insPos < stoplistData.getRowCount())) 1542 1543 { 1543 while ((insPos < stoplistData.getRowCount())1544 && (stoplistData.nodes.elementAt(insPos) == null))1545 ++insPos;1546 stoplistTable.removeRowSelectionInterval(0, stoplistData.getRowCount()-1);1547 if (insPos < stoplistData.getRowCount())1548 stoplistTable.addRowSelectionInterval(insPos, insPos);1544 while ((insPos < stoplistData.getRowCount()) 1545 && (stoplistData.nodes.elementAt(insPos) == null)) 1546 ++insPos; 1547 stoplistTable.removeRowSelectionInterval(0, stoplistData.getRowCount()-1); 1548 if (insPos < stoplistData.getRowCount()) 1549 stoplistTable.addRowSelectionInterval(insPos, insPos); 1549 1550 } 1550 1551 … … 1555 1556 for (int i = stoplistData.getRowCount()-1; i >=0; --i) 1556 1557 { 1557 if (stoplistTable.isRowSelected(i))1558 {1559 stoplistData.nodes.removeElementAt(i);1560 stoplistData.removeRow(i);1561 }1558 if (stoplistTable.isRowSelected(i)) 1559 { 1560 stoplistData.nodes.removeElementAt(i); 1561 stoplistData.removeRow(i); 1562 } 1562 1563 } 1563 1564 … … 1571 1572 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1572 1573 { 1573 if (itineraryData.ways.elementAt(i) != null) 1574 { 1575 Way way = itineraryData.ways.elementAt(i); 1576 if (!(way.isIncomplete())) 1577 { 1578 if ("backward".equals((String)(itineraryData.getValueAt(i, 1)))) 1579 { 1580 for (int j = way.getNodesCount()-2; j >= 0; --j) 1574 if (itineraryData.ways.elementAt(i) != null) 1575 { 1576 Way way = itineraryData.ways.elementAt(i); 1577 if (!(way.isIncomplete())) 1581 1578 { 1582 SegmentMetric sm = new SegmentMetric 1583 (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(), 1584 way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon()); 1585 segmentMetrics.add(sm); 1579 if ("backward".equals((String)(itineraryData.getValueAt(i, 1)))) 1580 { 1581 for (int j = way.getNodesCount()-2; j >= 0; --j) 1582 { 1583 SegmentMetric sm = new SegmentMetric 1584 (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(), 1585 way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon()); 1586 segmentMetrics.add(sm); 1587 } 1588 } 1589 else 1590 { 1591 for (int j = 0; j < way.getNodesCount()-1; ++j) 1592 { 1593 SegmentMetric sm = new SegmentMetric 1594 (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(), 1595 way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon()); 1596 segmentMetrics.add(sm); 1597 } 1598 } 1586 1599 } 1587 1600 } 1588 1601 else 1589 1602 { 1590 for (int j = 0; j < way.getNodesCount()-1; ++j) 1591 { 1592 SegmentMetric sm = new SegmentMetric 1593 (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(), 1594 way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon()); 1595 segmentMetrics.add(sm); 1596 } 1597 } 1598 } 1599 } 1600 else 1601 { 1602 segmentMetrics.add(null); 1603 } 1603 segmentMetrics.add(null); 1604 } 1604 1605 } 1605 1606 … … 1610 1611 // Determine for each member its position on the itinerary: position means here the 1611 1612 // point on the itinerary that has minimal distance to the coor 1612 for (int i = stoplistData.getRowCount()-1; i >= 0; --i) 1613 { 1614 if (stoplistTable.isRowSelected(i)) 1615 { 1616 StopReference sr = detectMinDistance 1617 (stoplistData.nodes.elementAt(i), segmentMetrics, 1618 cbRight.isSelected(), cbLeft.isSelected()); 1619 if (sr != null) 1620 { 1621 if (sr.distance < 1622 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ) 1613 for (int i = stoplistData.getRowCount()-1; i >= 0; --i) 1614 { 1615 if (stoplistTable.isRowSelected(i)) 1623 1616 { 1624 sr.role = (String)stoplistData.getValueAt(i, 1); 1625 srm.addElement(sr); 1617 StopReference sr = detectMinDistance 1618 (stoplistData.nodes.elementAt(i), segmentMetrics, 1619 cbRight.isSelected(), cbLeft.isSelected()); 1620 if (sr != null) 1621 { 1622 if (sr.distance < 1623 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ) 1624 { 1625 sr.role = (String)stoplistData.getValueAt(i, 1); 1626 srm.addElement(sr); 1627 } 1628 else 1629 { 1630 sr.role = (String)stoplistData.getValueAt(i, 1); 1631 sr.index = segmentMetrics.size()*2; 1632 sr.pos = 0; 1633 srm.addElement(sr); 1634 } 1635 1636 stoplistData.nodes.removeElementAt(i); 1637 stoplistData.removeRow(i); 1638 } 1639 1626 1640 } 1627 else 1641 } 1642 } 1643 else 1644 { 1645 // Determine for each member its position on the itinerary: position means here the 1646 // point on the itinerary that has minimal distance to the coor 1647 for (int i = stoplistData.getRowCount()-1; i >= 0; --i) 1648 { 1649 StopReference sr = detectMinDistance 1650 (stoplistData.nodes.elementAt(i), segmentMetrics, 1651 cbRight.isSelected(), cbLeft.isSelected()); 1652 if (sr != null) 1628 1653 { 1629 sr.role = (String)stoplistData.getValueAt(i, 1); 1630 sr.index = segmentMetrics.size()*2; 1631 sr.pos = 0; 1632 srm.addElement(sr); 1654 if (sr.distance < 1655 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ) 1656 { 1657 sr.role = (String)stoplistData.getValueAt(i, 1); 1658 srm.addElement(sr); 1659 } 1660 else 1661 { 1662 sr.role = (String)stoplistData.getValueAt(i, 1); 1663 sr.index = segmentMetrics.size()*2; 1664 sr.pos = 0; 1665 srm.addElement(sr); 1666 } 1633 1667 } 1634 1635 stoplistData.nodes.removeElementAt(i); 1636 stoplistData.removeRow(i); 1637 } 1638 1639 } 1640 } 1641 } 1642 else 1643 { 1644 // Determine for each member its position on the itinerary: position means here the 1645 // point on the itinerary that has minimal distance to the coor 1646 for (int i = stoplistData.getRowCount()-1; i >= 0; --i) 1647 { 1648 StopReference sr = detectMinDistance 1649 (stoplistData.nodes.elementAt(i), segmentMetrics, 1650 cbRight.isSelected(), cbLeft.isSelected()); 1651 if (sr != null) 1652 { 1653 if (sr.distance < 1654 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ) 1655 { 1656 sr.role = (String)stoplistData.getValueAt(i, 1); 1657 srm.addElement(sr); 1658 } 1659 else 1660 { 1661 sr.role = (String)stoplistData.getValueAt(i, 1); 1662 sr.index = segmentMetrics.size()*2; 1663 sr.pos = 0; 1664 srm.addElement(sr); 1665 } 1666 } 1667 } 1668 1669 stoplistData.clear(); 1668 } 1669 1670 stoplistData.clear(); 1670 1671 } 1671 1672 … … 1674 1675 for (int i = 0; i < srm.size(); ++i) 1675 1676 { 1676 stoplistData.insertRow(insPos, srm.elementAt(i).node, srm.elementAt(i).role);1677 if (insPos >= 0)1678 ++insPos;1677 stoplistData.insertRow(insPos, srm.elementAt(i).node, srm.elementAt(i).role); 1678 if (insPos >= 0) 1679 ++insPos; 1679 1680 } 1680 1681 … … 1688 1689 if (stoplistTable.getSelectedRowCount() > 0) 1689 1690 { 1690 for (int i = stoplistData.getRowCount()-1; i >=0; --i)1691 {1692 if (stoplistTable.isRowSelected(i))1693 {1694 String role = (String)(stoplistData.getValueAt(i, 1));1695 RelationMember markedNode = new RelationMember1696 (role, stoplistData.nodes.elementAt(i));1697 itemsToReflect.addElement(markedNode);1698 1699 stoplistData.nodes.removeElementAt(i);1700 stoplistData.removeRow(i);1701 }1702 }1691 for (int i = stoplistData.getRowCount()-1; i >=0; --i) 1692 { 1693 if (stoplistTable.isRowSelected(i)) 1694 { 1695 String role = (String)(stoplistData.getValueAt(i, 1)); 1696 RelationMember markedNode = new RelationMember 1697 (role, stoplistData.nodes.elementAt(i)); 1698 itemsToReflect.addElement(markedNode); 1699 1700 stoplistData.nodes.removeElementAt(i); 1701 stoplistData.removeRow(i); 1702 } 1703 } 1703 1704 } 1704 1705 else 1705 1706 { 1706 for (int i = stoplistData.getRowCount()-1; i >=0; --i)1707 {1708 String role = (String)(stoplistData.getValueAt(i, 1));1709 RelationMember markedNode = new RelationMember1710 (role, stoplistData.nodes.elementAt(i));1711 itemsToReflect.addElement(markedNode);1712 }1713 1714 stoplistData.clear();1707 for (int i = stoplistData.getRowCount()-1; i >=0; --i) 1708 { 1709 String role = (String)(stoplistData.getValueAt(i, 1)); 1710 RelationMember markedNode = new RelationMember 1711 (role, stoplistData.nodes.elementAt(i)); 1712 itemsToReflect.addElement(markedNode); 1713 } 1714 1715 stoplistData.clear(); 1715 1716 } 1716 1717 … … 1719 1720 while (relIter.hasNext()) 1720 1721 { 1721 RelationMember curMember = relIter.next(); 1722 if (curMember.isNode()) 1723 { 1724 stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole()); 1722 RelationMember curMember = relIter.next(); 1723 if (curMember.isNode()) 1724 { 1725 stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole()); 1726 if (insPos >= 0) 1727 ++insPos; 1728 } 1729 } 1725 1730 if (insPos >= 0) 1726 ++insPos; 1727 } 1728 } 1729 if (insPos >= 0) 1730 stoplistTable.addRowSelectionInterval(startPos, insPos-1); 1731 stoplistTable.addRowSelectionInterval(startPos, insPos-1); 1731 1732 1732 1733 rebuildNodes(); … … 1739 1740 for (int i = 0; i < itineraryData.getRowCount(); ++i) 1740 1741 { 1741 if (itineraryData.ways.elementAt(i) != null) 1742 { 1743 Way way = itineraryData.ways.elementAt(i); 1744 if (!(way.isIncomplete())) 1745 { 1746 if ("backward".equals((String)(itineraryData.getValueAt(i, 1)))) 1747 { 1748 for (int j = way.getNodesCount()-2; j >= 0; --j) 1742 if (itineraryData.ways.elementAt(i) != null) 1743 { 1744 Way way = itineraryData.ways.elementAt(i); 1745 if (!(way.isIncomplete())) 1749 1746 { 1750 SegmentMetric sm = new SegmentMetric 1751 (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(), 1752 way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon()); 1753 segmentMetrics.add(sm); 1747 if ("backward".equals((String)(itineraryData.getValueAt(i, 1)))) 1748 { 1749 for (int j = way.getNodesCount()-2; j >= 0; --j) 1750 { 1751 SegmentMetric sm = new SegmentMetric 1752 (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(), 1753 way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon()); 1754 segmentMetrics.add(sm); 1755 } 1756 } 1757 else 1758 { 1759 for (int j = 0; j < way.getNodesCount()-1; ++j) 1760 { 1761 SegmentMetric sm = new SegmentMetric 1762 (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(), 1763 way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon()); 1764 segmentMetrics.add(sm); 1765 } 1766 } 1754 1767 } 1755 1768 } 1756 1769 else 1757 1770 { 1758 for (int j = 0; j < way.getNodesCount()-1; ++j) 1759 { 1760 SegmentMetric sm = new SegmentMetric 1761 (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(), 1762 way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon()); 1763 segmentMetrics.add(sm); 1764 } 1765 } 1766 } 1767 } 1768 else 1769 { 1770 segmentMetrics.add(null); 1771 } 1771 segmentMetrics.add(null); 1772 } 1772 1773 } 1773 1774 … … 1778 1779 if (mainDataSet != null) 1779 1780 { 1780 String stopKey = "";1781 String stopValue = "";1782 if ("bus".equals(currentRoute.get("route")))1783 {1784 stopKey = "highway";1785 stopValue = "bus_stop";1786 }1787 else if ("trolleybus".equals(currentRoute.get("route")))1788 {1789 stopKey = "highway";1790 stopValue = "bus_stop";1791 }1792 else if ("tram".equals(currentRoute.get("route")))1793 {1794 stopKey = "railway";1795 stopValue = "tram_stop";1796 }1797 else if ("light_rail".equals(currentRoute.get("route")))1798 {1799 stopKey = "railway";1800 stopValue = "station";1801 }1802 else if ("subway".equals(currentRoute.get("route")))1803 {1804 stopKey = "railway";1805 stopValue = "station";1806 }1807 else if ("rail".equals(currentRoute.get("route")))1808 {1809 stopKey = "railway";1810 stopValue = "station";1811 }1812 1813 Collection< Node > nodeCollection = mainDataSet.getNodes();1814 Iterator< Node > nodeIter = nodeCollection.iterator();1815 while (nodeIter.hasNext())1816 {1817 Node currentNode = nodeIter.next();1818 if (!currentNode.isUsable())1819 continue;1820 if (stopValue.equals(currentNode.get(stopKey)))1821 {1822 StopReference sr = detectMinDistance1823 (currentNode, segmentMetrics,1824 cbRight.isSelected(), cbLeft.isSelected());1825 if ((sr != null) && (sr.distance <1826 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ))1827 srm.addElement(sr);1828 }1829 }1781 String stopKey = ""; 1782 String stopValue = ""; 1783 if ("bus".equals(currentRoute.get("route"))) 1784 { 1785 stopKey = "highway"; 1786 stopValue = "bus_stop"; 1787 } 1788 else if ("trolleybus".equals(currentRoute.get("route"))) 1789 { 1790 stopKey = "highway"; 1791 stopValue = "bus_stop"; 1792 } 1793 else if ("tram".equals(currentRoute.get("route"))) 1794 { 1795 stopKey = "railway"; 1796 stopValue = "tram_stop"; 1797 } 1798 else if ("light_rail".equals(currentRoute.get("route"))) 1799 { 1800 stopKey = "railway"; 1801 stopValue = "station"; 1802 } 1803 else if ("subway".equals(currentRoute.get("route"))) 1804 { 1805 stopKey = "railway"; 1806 stopValue = "station"; 1807 } 1808 else if ("rail".equals(currentRoute.get("route"))) 1809 { 1810 stopKey = "railway"; 1811 stopValue = "station"; 1812 } 1813 1814 Collection< Node > nodeCollection = mainDataSet.getNodes(); 1815 Iterator< Node > nodeIter = nodeCollection.iterator(); 1816 while (nodeIter.hasNext()) 1817 { 1818 Node currentNode = nodeIter.next(); 1819 if (!currentNode.isUsable()) 1820 continue; 1821 if (stopValue.equals(currentNode.get(stopKey))) 1822 { 1823 StopReference sr = detectMinDistance 1824 (currentNode, segmentMetrics, 1825 cbRight.isSelected(), cbLeft.isSelected()); 1826 if ((sr != null) && (sr.distance < 1827 Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 )) 1828 srm.addElement(sr); 1829 } 1830 } 1830 1831 } 1831 1832 else 1832 1833 { 1833 JOptionPane.showMessageDialog(null, "There exists no dataset." 1834 + " Try to download data from the server or open an OSM file.", 1835 "No data found", JOptionPane.ERROR_MESSAGE); 1836 1837 System.out.println("Public Transport: RoutePattern: No data found"); 1838 } 1839 1840 for (int i = 0; i < stoplistData.getRowCount(); ++i) 1841 { 1842 } 1834 JOptionPane.showMessageDialog(null, tr("There exists no dataset." 1835 + " Try to download data from the server or open an OSM file."), 1836 tr("No data found"), JOptionPane.ERROR_MESSAGE); 1837 } 1838 1839 /*for (int i = 0; i < stoplistData.getRowCount(); ++i) 1840 { 1841 }*/ 1843 1842 1844 1843 Collections.sort(srm); … … 1847 1846 for (int i = 0; i < srm.size(); ++i) 1848 1847 { 1849 stoplistData.addRow(srm.elementAt(i).node, srm.elementAt(i).role);1848 stoplistData.addRow(srm.elementAt(i).node, srm.elementAt(i).role); 1850 1849 } 1851 1850 … … 1875 1874 while (relIter.hasNext()) 1876 1875 { 1877 Relation currentRel = relIter.next();1878 if (!currentRel.isDeleted())1879 {1880 String routeVal = currentRel.get("route");1881 if ("bus".equals(routeVal))1882 relRefs.add(new RouteReference(currentRel));1883 else if ("trolleybus".equals(routeVal))1884 relRefs.add(new RouteReference(currentRel));1885 else if ("tram".equals(routeVal))1886 relRefs.add(new RouteReference(currentRel));1887 else if ("light_rail".equals(routeVal))1888 relRefs.add(new RouteReference(currentRel));1889 else if ("subway".equals(routeVal))1890 relRefs.add(new RouteReference(currentRel));1891 else if ("rail".equals(routeVal))1892 relRefs.add(new RouteReference(currentRel));1893 }1876 Relation currentRel = relIter.next(); 1877 if (!currentRel.isDeleted()) 1878 { 1879 String routeVal = currentRel.get("route"); 1880 if ("bus".equals(routeVal)) 1881 relRefs.add(new RouteReference(currentRel)); 1882 else if ("trolleybus".equals(routeVal)) 1883 relRefs.add(new RouteReference(currentRel)); 1884 else if ("tram".equals(routeVal)) 1885 relRefs.add(new RouteReference(currentRel)); 1886 else if ("light_rail".equals(routeVal)) 1887 relRefs.add(new RouteReference(currentRel)); 1888 else if ("subway".equals(routeVal)) 1889 relRefs.add(new RouteReference(currentRel)); 1890 else if ("rail".equals(routeVal)) 1891 relRefs.add(new RouteReference(currentRel)); 1892 } 1894 1893 } 1895 1894 … … 1898 1897 Iterator< RouteReference > iter = relRefs.iterator(); 1899 1898 while (iter.hasNext()) 1900 relsListModel.addElement(iter.next());1899 relsListModel.addElement(iter.next()); 1901 1900 } 1902 1901 else 1903 1902 { 1904 JOptionPane.showMessageDialog(null, "There exists no dataset." 1905 + " Try to download data from the server or open an OSM file.", 1906 "No data found", JOptionPane.ERROR_MESSAGE); 1907 1908 System.out.println("Public Transport: No data found"); 1903 JOptionPane.showMessageDialog(null, tr("There exists no dataset." 1904 + " Try to download data from the server or open an OSM file."), 1905 tr("No data found"), JOptionPane.ERROR_MESSAGE); 1909 1906 } 1910 1907 } … … 1924 1921 if (itineraryData.ways.elementAt(i) != null) 1925 1922 { 1926 RelationMember member = new RelationMember1923 RelationMember member = new RelationMember 1927 1924 ((String)(itineraryData.getValueAt(i, 1)), 1928 1925 itineraryData.ways.elementAt(i)); 1929 members.add(member);1926 members.add(member); 1930 1927 } 1931 1928 } … … 1940 1937 if (currentRoute.getMember(i).isNode()) 1941 1938 { 1942 currentRoute.removeMember(i);1939 currentRoute.removeMember(i); 1943 1940 } 1944 1941 } … … 1970 1967 Node lastListNode = null; 1971 1968 if ("backward".equals(list.getLast().getRole())) 1972 lastListNode = list.getLast().getWay().getNode(0);1969 lastListNode = list.getLast().getWay().getNode(0); 1973 1970 else 1974 lastListNode = list.getLast().getWay().getNode1971 lastListNode = list.getLast().getWay().getNode 1975 1972 (list.getLast().getWay().getNodesCount() - 1); 1976 1973 if (lastNode.equals(lastListNode)) 1977 1974 { 1978 backNodes.remove(lastListNode);1979 loops.add(list);1975 backNodes.remove(lastListNode); 1976 loops.add(list); 1980 1977 } 1981 1978 else if (frontNodes.get(lastNode) != null) 1982 1979 { 1983 backNodes.remove(lastListNode); 1984 LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode); 1985 Iterator<RelationMember> memberIter = list.iterator(); 1986 while (memberIter.hasNext()) 1987 { 1988 RelationMember member = memberIter.next(); 1989 if ("backward".equals(member.getRole())) 1990 listToAppend.addFirst(new RelationMember("forward", member.getWay())); 1980 backNodes.remove(lastListNode); 1981 LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode); 1982 Iterator<RelationMember> memberIter = list.iterator(); 1983 while (memberIter.hasNext()) 1984 { 1985 RelationMember member = memberIter.next(); 1986 if ("backward".equals(member.getRole())) 1987 listToAppend.addFirst(new RelationMember("forward", member.getWay())); 1988 else 1989 listToAppend.addFirst(new RelationMember("backward", member.getWay())); 1990 } 1991 frontNodes.remove(lastNode); 1992 frontNodes.put(lastListNode, listToAppend); 1993 } 1994 else if (backNodes.get(lastNode) != null) 1995 { 1996 backNodes.remove(lastListNode); 1997 LinkedList<RelationMember> listToAppend = backNodes.get(lastNode); 1998 Iterator<RelationMember> memberIter = list.iterator(); 1999 while (memberIter.hasNext()) 2000 { 2001 RelationMember member = memberIter.next(); 2002 listToAppend.addLast(member); 2003 } 2004 backNodes.remove(lastNode); 2005 backNodes.put(lastListNode, listToAppend); 2006 } 1991 2007 else 1992 listToAppend.addFirst(new RelationMember("backward", member.getWay())); 1993 } 1994 frontNodes.remove(lastNode); 1995 frontNodes.put(lastListNode, listToAppend); 1996 } 1997 else if (backNodes.get(lastNode) != null) 1998 { 1999 backNodes.remove(lastListNode); 2000 LinkedList<RelationMember> listToAppend = backNodes.get(lastNode); 2001 Iterator<RelationMember> memberIter = list.iterator(); 2002 while (memberIter.hasNext()) 2003 { 2004 RelationMember member = memberIter.next(); 2005 listToAppend.addLast(member); 2006 } 2007 backNodes.remove(lastNode); 2008 backNodes.put(lastListNode, listToAppend); 2009 } 2010 else 2011 frontNodes.put(lastNode, list); 2008 frontNodes.put(lastNode, list); 2012 2009 } 2013 2010 else if (backNodes.get(firstNode) != null) … … 2019 2016 Node firstListNode = null; 2020 2017 if ("backward".equals(list.getFirst().getRole())) 2021 firstListNode = list.getFirst().getWay().getNode2018 firstListNode = list.getFirst().getWay().getNode 2022 2019 (list.getFirst().getWay().getNodesCount() - 1); 2023 2020 else 2024 firstListNode = list.getFirst().getWay().getNode(0);2021 firstListNode = list.getFirst().getWay().getNode(0); 2025 2022 if (lastNode.equals(firstListNode)) 2026 2023 { 2027 frontNodes.remove(firstListNode);2028 loops.add(list);2024 frontNodes.remove(firstListNode); 2025 loops.add(list); 2029 2026 } 2030 2027 else if (frontNodes.get(lastNode) != null) 2031 2028 { 2032 frontNodes.remove(firstListNode);2033 LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);2034 ListIterator<RelationMember> memberIter = list.listIterator(list.size());2035 while (memberIter.hasPrevious())2036 {2037 RelationMember member = memberIter.previous();2038 listToAppend.addFirst(member);2039 }2040 frontNodes.remove(lastNode);2041 frontNodes.put(firstListNode, listToAppend);2029 frontNodes.remove(firstListNode); 2030 LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode); 2031 ListIterator<RelationMember> memberIter = list.listIterator(list.size()); 2032 while (memberIter.hasPrevious()) 2033 { 2034 RelationMember member = memberIter.previous(); 2035 listToAppend.addFirst(member); 2036 } 2037 frontNodes.remove(lastNode); 2038 frontNodes.put(firstListNode, listToAppend); 2042 2039 } 2043 2040 else if (backNodes.get(lastNode) != null) 2044 2041 { 2045 frontNodes.remove(firstListNode); 2046 LinkedList<RelationMember> listToAppend = backNodes.get(lastNode); 2047 ListIterator<RelationMember> memberIter = list.listIterator(list.size()); 2048 while (memberIter.hasPrevious()) 2049 { 2050 RelationMember member = memberIter.previous(); 2051 if ("backward".equals(member.getRole())) 2052 listToAppend.addLast(new RelationMember("forward", member.getWay())); 2042 frontNodes.remove(firstListNode); 2043 LinkedList<RelationMember> listToAppend = backNodes.get(lastNode); 2044 ListIterator<RelationMember> memberIter = list.listIterator(list.size()); 2045 while (memberIter.hasPrevious()) 2046 { 2047 RelationMember member = memberIter.previous(); 2048 if ("backward".equals(member.getRole())) 2049 listToAppend.addLast(new RelationMember("forward", member.getWay())); 2050 else 2051 listToAppend.addLast(new RelationMember("backward", member.getWay())); 2052 } 2053 backNodes.remove(lastNode); 2054 backNodes.put(firstListNode, listToAppend); 2055 } 2053 2056 else 2054 listToAppend.addLast(new RelationMember("backward", member.getWay())); 2055 } 2056 backNodes.remove(lastNode); 2057 backNodes.put(firstListNode, listToAppend); 2058 } 2059 else 2060 backNodes.put(lastNode, list); 2057 backNodes.put(lastNode, list); 2061 2058 } 2062 2059 else if (frontNodes.get(lastNode) != null) … … 2127 2124 if (curMember.isWay()) 2128 2125 { 2129 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());2130 if (insPos >= 0)2131 ++insPos;2126 itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole()); 2127 if (insPos >= 0) 2128 ++insPos; 2132 2129 } 2133 2130 } … … 2169 2166 if (sm == null) 2170 2167 { 2171 angleLat = 100.0;2172 angleLon = 200.0;2173 2174 continue;2168 angleLat = 100.0; 2169 angleLon = 200.0; 2170 2171 continue; 2175 2172 } 2176 2173 … … 2179 2176 if (curPosition < 0) 2180 2177 { 2181 if (angleLat <= 90.0)2182 {2183 double lastSegAngle = Math.atan2(angleLat - sm.aLat, angleLon - sm.aLon);2184 double segAngle = Math.atan2(sm.d1, -sm.o1);2185 double vertexAngle = Math.atan2(lat - sm.aLat, lon - sm.aLon);2186 2187 boolean vertexOnSeg = (vertexAngle == segAngle) ||2188 (vertexAngle == lastSegAngle);2189 boolean vertexOnTheLeft = (!vertexOnSeg) &&2190 (((lastSegAngle > vertexAngle) && (vertexAngle > segAngle))2191 || ((vertexAngle > segAngle) && (segAngle > lastSegAngle))2192 || ((segAngle > lastSegAngle) && (lastSegAngle > vertexAngle)));2193 2194 double currentDistance = Math.sqrt((lat - sm.aLat)*(lat - sm.aLat)2195 + (lon - sm.aLon)*(lon - sm.aLon)2196 *Math.cos(sm.aLat * Math.PI/180.0)*Math.cos(sm.aLat * Math.PI/180.0));2197 curPosition = vertexAngle - segAngle;2198 if (vertexOnTheLeft)2199 curPosition = -curPosition;2200 if (curPosition < 0)2201 curPosition += 2*Math.PI;2202 if ((Math.abs(currentDistance) < distance)2203 && (((!vertexOnTheLeft) && (rhsPossible))2204 || ((vertexOnTheLeft) && (lhsPossible))2205 || (vertexOnSeg)))2206 {2207 distance = Math.abs(currentDistance);2208 minIndex = curIndex-1;2209 position = curPosition;2210 }2211 }2212 angleLat = 100.0;2213 angleLon = 200.0;2178 if (angleLat <= 90.0) 2179 { 2180 double lastSegAngle = Math.atan2(angleLat - sm.aLat, angleLon - sm.aLon); 2181 double segAngle = Math.atan2(sm.d1, -sm.o1); 2182 double vertexAngle = Math.atan2(lat - sm.aLat, lon - sm.aLon); 2183 2184 boolean vertexOnSeg = (vertexAngle == segAngle) || 2185 (vertexAngle == lastSegAngle); 2186 boolean vertexOnTheLeft = (!vertexOnSeg) && 2187 (((lastSegAngle > vertexAngle) && (vertexAngle > segAngle)) 2188 || ((vertexAngle > segAngle) && (segAngle > lastSegAngle)) 2189 || ((segAngle > lastSegAngle) && (lastSegAngle > vertexAngle))); 2190 2191 double currentDistance = Math.sqrt((lat - sm.aLat)*(lat - sm.aLat) 2192 + (lon - sm.aLon)*(lon - sm.aLon) 2193 *Math.cos(sm.aLat * Math.PI/180.0)*Math.cos(sm.aLat * Math.PI/180.0)); 2194 curPosition = vertexAngle - segAngle; 2195 if (vertexOnTheLeft) 2196 curPosition = -curPosition; 2197 if (curPosition < 0) 2198 curPosition += 2*Math.PI; 2199 if ((Math.abs(currentDistance) < distance) 2200 && (((!vertexOnTheLeft) && (rhsPossible)) 2201 || ((vertexOnTheLeft) && (lhsPossible)) 2202 || (vertexOnSeg))) 2203 { 2204 distance = Math.abs(currentDistance); 2205 minIndex = curIndex-1; 2206 position = curPosition; 2207 } 2208 } 2209 angleLat = 100.0; 2210 angleLon = 200.0; 2214 2211 } 2215 2212 else if (curPosition > sm.length) 2216 2213 { 2217 angleLat = sm.aLat;2218 angleLon = sm.aLon;2214 angleLat = sm.aLat; 2215 angleLon = sm.aLon; 2219 2216 } 2220 2217 else 2221 2218 { 2222 double currentDistance = (lat - sm.aLat)*sm.o1 + (lon - sm.aLon)*sm.o2;2223 if ((Math.abs(currentDistance) < distance)2224 && (((currentDistance >= 0) && (rhsPossible))2225 || ((currentDistance <= 0) && (lhsPossible))))2226 {2227 distance = Math.abs(currentDistance);2228 minIndex = curIndex;2229 position = curPosition;2230 }2231 2232 angleLat = 100.0;2233 angleLon = 200.0;2219 double currentDistance = (lat - sm.aLat)*sm.o1 + (lon - sm.aLon)*sm.o2; 2220 if ((Math.abs(currentDistance) < distance) 2221 && (((currentDistance >= 0) && (rhsPossible)) 2222 || ((currentDistance <= 0) && (lhsPossible)))) 2223 { 2224 distance = Math.abs(currentDistance); 2225 minIndex = curIndex; 2226 position = curPosition; 2227 } 2228 2229 angleLat = 100.0; 2230 angleLon = 200.0; 2234 2231 } 2235 2232 } -
applications/editors/josm/plugins/public_transport/src/public_transport/SettingsStoptypeCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 47 49 if ((Node)waypointTM.nodes.elementAt(i) != null) 48 50 { 49 Node node = (Node)waypointTM.nodes.elementAt(i);50 oldStrings.add(new HighwayRailway(node));51 StopImporterAction.setTagsWrtType(node, type);51 Node node = (Node)waypointTM.nodes.elementAt(i); 52 oldStrings.add(new HighwayRailway(node)); 53 StopImporterAction.setTagsWrtType(node, type); 52 54 } 53 55 } … … 57 59 for (int i = 0; i < track.stoplistTM.getRowCount(); ++i) 58 60 { 59 if (track.stoplistTM.nodeAt(i) != null)60 {61 Node node = track.stoplistTM.nodeAt(i);62 oldStrings.add(new HighwayRailway(node));63 StopImporterAction.setTagsWrtType(node, type);64 }61 if (track.stoplistTM.nodeAt(i) != null) 62 { 63 Node node = track.stoplistTM.nodeAt(i); 64 oldStrings.add(new HighwayRailway(node)); 65 StopImporterAction.setTagsWrtType(node, type); 66 } 65 67 } 66 68 } … … 86 88 @Override public JLabel getDescription() 87 89 { 88 return new JLabel( "public_transport.Settings.ChangeStoptype");90 return new JLabel(tr("Public Transport: Change stop type")); 89 91 } 90 92 -
applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java
r26147 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 117 116 } 118 117 JFileChooser fc = new JFileChooser(new File(curDir)); 119 fc.setDialogTitle( "Select GPX file");118 fc.setDialogTitle(tr("Select GPX file")); 120 119 fc.setMultiSelectionEnabled(false); 121 120 … … 265 264 { 266 265 JOptionPane.showMessageDialog 267 (null, "The GPX file contained no tracks or waypoints.", "No data found",266 (null, tr("The GPX file contained no tracks or waypoints."), tr("No data found"), 268 267 JOptionPane.ERROR_MESSAGE); 269 270 System.out.println("Public Transport: StopImporter: No data found");271 268 } 272 269 } … … 307 304 if (Main.main.getCurrentDataSet() == null) 308 305 { 309 JOptionPane.showMessageDialog(null, "There exists no dataset." 310 + " Try to download data from the server or open an OSM file.", 311 "No data found", JOptionPane.ERROR_MESSAGE); 312 313 System.out.println("Public Transport: StopInserter: No data found"); 306 JOptionPane.showMessageDialog(null, tr("There exists no dataset." 307 + " Try to download data from the server or open an OSM file."), 308 tr("No data found"), JOptionPane.ERROR_MESSAGE); 314 309 315 310 return null; … … 345 340 { 346 341 for (int i = 0; i < selectedLines.length; ++i) 347 consideredLines.add(selectedLines[i]);342 consideredLines.add(selectedLines[i]); 348 343 } 349 344 else 350 345 { 351 346 for (int i = 0; i < table.getRowCount(); ++i) 352 consideredLines.add(new Integer(i));347 consideredLines.add(new Integer(i)); 353 348 } 354 349 return consideredLines; … … 366 361 { 367 362 if ((nodes.elementAt(i) != null) && 368 369 table.addRowSelectionInterval(i, i);363 (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i)))) 364 table.addRowSelectionInterval(i, i); 370 365 } 371 366 } … … 381 376 int j = consideredLines.elementAt(i); 382 377 if (nodes.elementAt(j) != null) 383 nodes.elementAt(j).visit(box);378 nodes.elementAt(j).visit(box); 384 379 } 385 380 if (box.getBounds() == null) … … 400 395 int j = consideredLines.elementAt(i); 401 396 if (nodes.elementAt(j) != null) 402 Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));397 Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j)); 403 398 } 404 399 } … … 464 459 public void actionPerformed(ActionEvent e) 465 460 { 466 JTable table = dialog.getStoplistTable();467 int row = table.getEditingRow();468 if (row < 0)469 return;470 table.clearSelection();471 table.addRowSelectionInterval(row, row);472 Main.main.undoRedo.add473 (new TrackStoplistDeleteCommand(StopImporterAction.this));461 JTable table = dialog.getStoplistTable(); 462 int row = table.getEditingRow(); 463 if (row < 0) 464 return; 465 table.clearSelection(); 466 table.addRowSelectionInterval(row, row); 467 Main.main.undoRedo.add 468 (new TrackStoplistDeleteCommand(StopImporterAction.this)); 474 469 } 475 470 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterDialog.java
r23192 r26168 75 75 private JTable waypointTable = null; 76 76 77 private final String[] stoptypes = new String[]{marktr("bus"), marktr("tram"), marktr("light_rail"), marktr("subway"), marktr("rail")}; 78 77 79 public StopImporterDialog(StopImporterAction controller) 78 80 { 79 81 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 80 jDialog = new JDialog(frame, "Create Stops from GPX", false);82 jDialog = new JDialog(frame, tr("Create Stops from GPX"), false); 81 83 tabbedPane = new JTabbedPane(); 82 84 JPanel tabTracks = new JPanel(); 83 tabbedPane.addTab( marktr("Tracks"), tabTracks);85 tabbedPane.addTab(tr("Tracks"), tabTracks); 84 86 JPanel tabSettings = new JPanel(); 85 tabbedPane.addTab( marktr("Settings"), tabSettings);87 tabbedPane.addTab(tr("Settings"), tabSettings); 86 88 JPanel tabStops = new JPanel(); 87 tabbedPane.addTab( marktr("Stops"), tabStops);89 tabbedPane.addTab(tr("Stops"), tabStops); 88 90 JPanel tabWaypoints = new JPanel(); 89 tabbedPane.addTab( marktr("Waypoints"), tabWaypoints);91 tabbedPane.addTab(tr("Waypoints"), tabWaypoints); 90 92 tabbedPane.setEnabledAt(0, true); 91 93 tabbedPane.setEnabledAt(1, true); … … 100 102 contentPane.setLayout(gridbag); 101 103 102 JLabel label = new JLabel( "Tracks in this GPX file:");104 JLabel label = new JLabel(tr("Tracks in this GPX file:")); 103 105 104 106 layoutCons.gridx = 0; … … 134 136 contentPane.setLayout(gridbag); 135 137 136 label = new JLabel( "Type of stops to add");138 label = new JLabel(tr("Type of stops to add")); 137 139 138 140 layoutCons.gridx = 0; … … 147 149 cbStoptype = new JComboBox(); 148 150 cbStoptype.setEditable(false); 149 cbStoptype.addItem("bus"); 150 cbStoptype.addItem("tram"); 151 cbStoptype.addItem("light_rail"); 152 cbStoptype.addItem("subway"); 153 cbStoptype.addItem("rail"); 151 for(String type : stoptypes) 152 cbStoptype.addItem(new TransText(type)); 154 153 cbStoptype.setActionCommand("stopImporter.settingsStoptype"); 155 154 cbStoptype.addActionListener(controller); … … 164 163 contentPane.add(cbStoptype); 165 164 166 label = new JLabel( "Time on your GPS device");165 label = new JLabel(tr("Time on your GPS device")); 167 166 168 167 layoutCons.gridx = 0; … … 188 187 contentPane.add(tfGPSTimeStart); 189 188 190 label = new JLabel( "HH:MM:SS.sss");189 label = new JLabel(tr("HH:MM:SS.sss")); 191 190 192 191 layoutCons.gridx = 1; … … 199 198 contentPane.add(label); 200 199 201 label = new JLabel( "Time on your stopwatch");200 label = new JLabel(tr("Time on your stopwatch")); 202 201 203 202 layoutCons.gridx = 0; … … 223 222 contentPane.add(tfStopwatchStart); 224 223 225 label = new JLabel( "HH:MM:SS.sss");224 label = new JLabel(tr("HH:MM:SS.sss")); 226 225 227 226 layoutCons.gridx = 1; … … 234 233 contentPane.add(label); 235 234 236 label = new JLabel( "Time window");235 label = new JLabel(tr("Time window")); 237 236 238 237 layoutCons.gridx = 0; … … 258 257 contentPane.add(tfTimeWindow); 259 258 260 label = new JLabel( "seconds");259 label = new JLabel(tr("seconds")); 261 260 262 261 layoutCons.gridx = 1; … … 269 268 contentPane.add(label); 270 269 271 label = new JLabel( "Move Threshold");270 label = new JLabel(tr("Move Threshold")); 272 271 273 272 layoutCons.gridx = 0; … … 293 292 contentPane.add(tfThreshold); 294 293 295 label = new JLabel( "meters");294 label = new JLabel(tr("meters")); 296 295 297 296 layoutCons.gridx = 1; … … 304 303 contentPane.add(label); 305 304 306 JButton bSuggestStops = new JButton( "Suggest Stops");305 JButton bSuggestStops = new JButton(tr("Suggest Stops")); 307 306 bSuggestStops.setActionCommand("stopImporter.settingsSuggestStops"); 308 307 bSuggestStops.addActionListener(controller); … … 359 358 contentPane.add(tableSP); 360 359 361 JButton bFind = new JButton( "Find");360 JButton bFind = new JButton(tr("Find")); 362 361 bFind.setActionCommand("stopImporter.stoplistFind"); 363 362 bFind.addActionListener(controller); … … 372 371 contentPane.add(bFind); 373 372 374 JButton bShow = new JButton( "Show");373 JButton bShow = new JButton(tr("Show")); 375 374 bShow.setActionCommand("stopImporter.stoplistShow"); 376 375 bShow.addActionListener(controller); … … 385 384 contentPane.add(bShow); 386 385 387 JButton bMark = new JButton( "Mark");386 JButton bMark = new JButton(tr("Mark")); 388 387 bMark.setActionCommand("stopImporter.stoplistMark"); 389 388 bMark.addActionListener(controller); … … 399 398 contentPane.add(bMark); 400 399 401 JButton bDetach = new JButton( "Detach");400 JButton bDetach = new JButton(tr("Detach")); 402 401 bDetach.setActionCommand("stopImporter.stoplistDetach"); 403 402 bDetach.addActionListener(controller); … … 413 412 contentPane.add(bDetach); 414 413 415 JButton bAdd = new JButton( "Add");414 JButton bAdd = new JButton(tr("Add")); 416 415 bAdd.setActionCommand("stopImporter.stoplistAdd"); 417 416 bAdd.addActionListener(controller); … … 427 426 contentPane.add(bAdd); 428 427 429 JButton bDelete = new JButton( "Delete");428 JButton bDelete = new JButton(tr("Delete")); 430 429 bDelete.setActionCommand("stopImporter.stoplistDelete"); 431 430 bDelete.addActionListener(controller); … … 440 439 contentPane.add(bDelete); 441 440 442 JButton bSort = new JButton( "Sort");441 JButton bSort = new JButton(tr("Sort")); 443 442 bSort.setActionCommand("stopImporter.stoplistSort"); 444 443 bSort.addActionListener(controller); … … 496 495 contentPane.add(tableSP); 497 496 498 bFind = new JButton( "Find");497 bFind = new JButton(tr("Find")); 499 498 bFind.setActionCommand("stopImporter.waypointsFind"); 500 499 bFind.addActionListener(controller); … … 509 508 contentPane.add(bFind); 510 509 511 bShow = new JButton( "Show");510 bShow = new JButton(tr("Show")); 512 511 bShow.setActionCommand("stopImporter.waypointsShow"); 513 512 bShow.addActionListener(controller); … … 522 521 contentPane.add(bShow); 523 522 524 bMark = new JButton( "Mark");523 bMark = new JButton(tr("Mark")); 525 524 bMark.setActionCommand("stopImporter.waypointsMark"); 526 525 bMark.addActionListener(controller); … … 536 535 contentPane.add(bMark); 537 536 538 bDetach = new JButton( "Detach");537 bDetach = new JButton(tr("Detach")); 539 538 bDetach.setActionCommand("stopImporter.waypointsDetach"); 540 539 bDetach.addActionListener(controller); … … 550 549 contentPane.add(bDetach); 551 550 552 bAdd = new JButton( "Enable");551 bAdd = new JButton(tr("Enable")); 553 552 bAdd.setActionCommand("stopImporter.waypointsAdd"); 554 553 bAdd.addActionListener(controller); … … 564 563 contentPane.add(bAdd); 565 564 566 bDelete = new JButton( "Disable");565 bDelete = new JButton(tr("Disable")); 567 566 bDelete.setActionCommand("stopImporter.waypointsDelete"); 568 567 bDelete.addActionListener(controller); … … 603 602 public String getStoptype() 604 603 { 605 return ( String)cbStoptype.getSelectedItem();604 return ((TransText)cbStoptype.getSelectedItem()).text; 606 605 } 607 606 … … 615 614 { 616 615 JOptionPane.showMessageDialog 617 (null, "Can't parse a time from this string.", "Invalid value",616 (null, tr("Can't parse a time from this string."), tr("Invalid value"), 618 617 JOptionPane.ERROR_MESSAGE); 619 618 return false; … … 640 639 { 641 640 JOptionPane.showMessageDialog 642 (null, "Can't parse a time from this string.", "Invalid value",641 (null, tr("Can't parse a time from this string."), tr("Invalid value"), 643 642 JOptionPane.ERROR_MESSAGE); 644 643 return false; … … 675 674 stoplistTable.setModel(model); 676 675 JComboBox comboBox = new JComboBox(); 677 comboBox.addItem( "");678 comboBox.addItem( "yes");679 comboBox.addItem( "no");680 comboBox.addItem( "implicit");676 comboBox.addItem(new TransText(null)); 677 comboBox.addItem(new TransText(marktr("yes"))); 678 comboBox.addItem(new TransText(marktr("no"))); 679 comboBox.addItem(new TransText(marktr("implicit"))); 681 680 stoplistTable.getColumnModel().getColumn(2) 682 681 .setCellEditor(new DefaultCellEditor(comboBox)); … … 696 695 waypointTable.setModel(model); 697 696 JComboBox comboBox = new JComboBox(); 698 comboBox.addItem( "");699 comboBox.addItem( "yes");700 comboBox.addItem( "no");701 comboBox.addItem( "implicit");697 comboBox.addItem(new TransText(null)); 698 comboBox.addItem(new TransText(marktr("yes"))); 699 comboBox.addItem(new TransText(marktr("no"))); 700 comboBox.addItem(new TransText(marktr("implicit"))); 702 701 waypointTable.getColumnModel().getColumn(2) 703 702 .setCellEditor(new DefaultCellEditor(comboBox)); … … 736 735 int selectedPos = tracksList.getAnchorSelectionIndex(); 737 736 if (tracksList.isSelectedIndex(selectedPos)) 738 root.tracksSelectionChanged(selectedPos);737 root.tracksSelectionChanged(selectedPos); 739 738 else 740 root.tracksSelectionChanged(-1);739 root.tracksSelectionChanged(-1); 741 740 } 742 741 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackReference.java
r23192 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 57 56 { 58 57 JOptionPane.showMessageDialog 59 (null, "The GPX file doesn't contain valid trackpoints. "60 + "Please use a GPX file that has trackpoints." , "GPX File Trouble",58 (null, tr("The GPX file doesn't contain valid trackpoints. " 59 + "Please use a GPX file that has trackpoints."), tr("GPX File Trouble"), 61 60 JOptionPane.ERROR_MESSAGE); 62 61 … … 93 92 String buf = (String)track.getAttributes().get("name"); 94 93 if (buf == null) 95 return "unnamed";94 return tr("unnamed"); 96 95 return buf; 97 96 } … … 111 110 (stoplistTM.timeAt(e.getFirstRow()), e.getFirstRow(), 0); 112 111 JOptionPane.showMessageDialog 113 (null, "Can't parse a time from this string.", "Invalid value",112 (null, tr("Can't parse a time from this string."), tr("Invalid value"), 114 113 JOptionPane.ERROR_MESSAGE); 115 114 return; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistAddCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 43 45 @Override public JLabel getDescription() 44 46 { 45 return new JLabel( "public_transport.TrackStoplist.Add");47 return new JLabel(tr("Public Transport: Add track stop")); 46 48 } 47 49 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDeleteCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 14 16 private class NodeTimeName 15 17 { 16 NodeTimeName(Node node, String time, String name, Stringshelter)18 NodeTimeName(Node node, String time, String name, TransText shelter) 17 19 { 18 20 this.node = node; … … 25 27 public String time; 26 28 public String name; 27 public Stringshelter;29 public TransText shelter; 28 30 }; 29 31 … … 44 46 for (int i = 0; i < selectedLines.length; ++i) 45 47 { 46 workingLines.add(selectedLines[i]);48 workingLines.add(selectedLines[i]); 47 49 } 48 50 } … … 50 52 { 51 53 for (int i = 0; i < stoplistTM.getRowCount(); ++i) 52 workingLines.add(new Integer(i));54 workingLines.add(new Integer(i)); 53 55 } 54 56 } … … 64 66 (node, (String)stoplistTM.getValueAt(j, 0), 65 67 (String)stoplistTM.getValueAt(j, 1), 66 ( String)stoplistTM.getValueAt(j, 2)));68 (TransText)stoplistTM.getValueAt(j, 2))); 67 69 stoplistTM.removeRow(j); 68 70 if (node == null) 69 continue;71 continue; 70 72 Main.main.getCurrentDataSet().removePrimitive(node); 71 73 node.setDeleted(true); … … 82 84 stoplistTM.insertRow(j, ntn.node, ntn.time, ntn.name, ntn.shelter); 83 85 if (ntn.node == null) 84 continue;86 continue; 85 87 ntn.node.setDeleted(false); 86 88 Main.main.getCurrentDataSet().addPrimitive(ntn.node); … … 96 98 @Override public JLabel getDescription() 97 99 { 98 return new JLabel( "public_transport.TrackStoplist.Delete");100 return new JLabel(tr("Public Transport: Delete track stop")); 99 101 } 100 102 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDetachCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 28 30 { 29 31 for (int i = 0; i < selectedLines.length; ++i) 30 consideredLines.add(selectedLines[i]);32 consideredLines.add(selectedLines[i]); 31 33 } 32 34 else 33 35 { 34 36 for (int i = 0; i < stoplistTM.getRowCount(); ++i) 35 consideredLines.add(new Integer(i));37 consideredLines.add(new Integer(i)); 36 38 } 37 39 … … 40 42 { 41 43 if (stoplistTM.nodeAt(consideredLines.elementAt(i)) != null) 42 workingLines.add(consideredLines.elementAt(i));44 workingLines.add(consideredLines.elementAt(i)); 43 45 } 44 46 } … … 75 77 @Override public JLabel getDescription() 76 78 { 77 return new JLabel( "public_transport.TrackStoplist.Detach");79 return new JLabel(tr("Public Transport: Detach track stop list")); 78 80 } 79 81 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistNameCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 20 22 private String time = null; 21 23 private String oldShelter = null; 22 private Stringshelter = null;24 private TransText shelter = null; 23 25 private LatLon oldLatLon = null; 24 26 … … 38 40 this.time = (String)trackref.stoplistTM.getValueAt(workingLine, 0); 39 41 this.name = (String)trackref.stoplistTM.getValueAt(workingLine, 1); 40 this.shelter = ( String)trackref.stoplistTM.getValueAt(workingLine, 2);41 if ("".equals(this.shelter ))42 this.shelter = (TransText)trackref.stoplistTM.getValueAt(workingLine, 2); 43 if ("".equals(this.shelter.text)) 42 44 this.shelter = null; 43 45 } … … 49 51 { 50 52 node.put("name", name); 51 node.put("shelter", shelter );53 node.put("shelter", shelter.text); 52 54 double dTime = StopImporterDialog.parseTime(time); 53 55 node.setCoor(trackref.computeCoor(dTime)); … … 62 64 else 63 65 trackref.stoplistTM.setValueAt(name, workingLine, 1); 64 if (shelter == null) 65 trackref.stoplistTM.setValueAt("", workingLine, 2); 66 else 67 trackref.stoplistTM.setValueAt(shelter, workingLine, 2); 66 trackref.stoplistTM.setValueAt(shelter, workingLine, 2); 68 67 trackref.inEvent = false; 69 68 return true; … … 88 87 else 89 88 trackref.stoplistTM.setValueAt(oldName, workingLine, 1); 90 if (oldShelter == null) 91 trackref.stoplistTM.setValueAt("", workingLine, 2); 92 else 93 trackref.stoplistTM.setValueAt(oldShelter, workingLine, 2); 89 trackref.stoplistTM.setValueAt(new TransText(oldShelter), workingLine, 2); 94 90 trackref.inEvent = false; 95 91 } … … 103 99 @Override public JLabel getDescription() 104 100 { 105 return new JLabel( "public_transport.TrackStoplist.Edit");101 return new JLabel(tr("Public Transport: Edit track stop list")); 106 102 } 107 103 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistRelocateCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 88 90 @Override public JLabel getDescription() 89 91 { 90 return new JLabel( "public_transport.TrackStoplist.RelocateNodes");92 return new JLabel(tr("Public Transport: Relocate nodes in track stoplist")); 91 93 } 92 94 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistSortCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 35 37 { 36 38 for (int i = 0; i < selectedLines.length; ++i) 37 workingLines.add(selectedLines[i]);39 workingLines.add(selectedLines[i]); 38 40 } 39 41 else 40 42 { 41 43 for (int i = 0; i < stoplistTM.getRowCount(); ++i) 42 workingLines.add(new Integer(i));44 workingLines.add(new Integer(i)); 43 45 } 44 46 } … … 59 61 (stoplistTM.nodeAt(j), (String)stoplistTM.getValueAt(j, 0), 60 62 (String)stoplistTM.getValueAt(j, 1), 61 ( String)stoplistTM.getValueAt(j, 2),63 (TransText)stoplistTM.getValueAt(j, 2), 62 64 StopImporterDialog.parseTime(stopwatchStart))); 63 65 stoplistTM.removeRow(j); … … 73 75 stoplistTM.insertRow(insPos, nse.node, nse.time, nse.name, nse.shelter); 74 76 if (insPos >= 0) 75 ++insPos;77 ++insPos; 76 78 } 77 79 return true; … … 93 95 @Override public JLabel getDescription() 94 96 { 95 return new JLabel( "public_transport.TrackStoplist.Sort");97 return new JLabel(tr("Public Transport: sort track stop list")); 96 98 } 97 99 … … 101 103 public String time = null; 102 104 public String name = null; 103 public Stringshelter = null;105 public TransText shelter = null; 104 106 public double startTime = 0; 105 107 106 108 public NodeSortEntry 107 (Node node, String time, String name, Stringshelter, double startTime)109 (Node node, String time, String name, TransText shelter, double startTime) 108 110 { 109 111 this.node = node; … … 117 119 double time = StopImporterDialog.parseTime(this.time); 118 120 if (time - startTime > 12*60*60) 119 time -= 24*60*60;121 time -= 24*60*60; 120 122 121 123 double nseTime = StopImporterDialog.parseTime(nse.time); 122 124 if (nseTime - startTime > 12*60*60) 123 nseTime -= 24*60*60;125 nseTime -= 24*60*60; 124 126 125 127 if (time < nseTime) 126 return -1;128 return -1; 127 129 else if (time > nseTime) 128 return 1;130 return 1; 129 131 else 130 return 0;132 return 0; 131 133 } 132 134 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistTableModel.java
r23192 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 20 19 { 21 20 columns = new Vector< String >(); 22 columns.add( "Time");23 columns.add( "Name");24 columns.add( "Shelter");21 columns.add(tr("Time")); 22 columns.add(tr("Name")); 23 columns.add(tr("Shelter")); 25 24 } 26 25 nodes = new Vector< Node >(); … … 49 48 public void insertRow(int insPos, String time) 50 49 { 51 insertRow(insPos, null, time, "", "");50 insertRow(insPos, null, time, "", new TransText(null)); 52 51 } 53 52 … … 100 99 101 100 public void insertRow 102 (int insPos, Node node, String time, String name, Stringshelter)101 (int insPos, Node node, String time, String name, TransText shelter) 103 102 { 104 String[] buf = { "", "", "" }; 105 buf[0] = time; 106 buf[1] = name; 103 Object[] buf = { time, name, shelter }; 107 104 if (insPos == -1) 108 105 { -
applications/editors/josm/plugins/public_transport/src/public_transport/TrackSuggestStopsCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import java.util.Collection; … … 58 60 Node node = stoplistTM.nodeAt(i); 59 61 if (node == null) 60 continue;62 continue; 61 63 Main.main.getCurrentDataSet().removePrimitive(node); 62 64 node.setDeleted(true); … … 70 72 Iterator< WayPoint > witer = siter.next().getWayPoints().iterator(); 71 73 while (witer.hasNext()) 72 wayPoints.add(witer.next());74 wayPoints.add(witer.next()); 73 75 } 74 76 Vector< Double > wayPointsDist = new Vector< Double >(wayPoints.size()); … … 80 82 { 81 83 if (wayPoints.elementAt(i).getString("time") != null) 82 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)83 .getString("time").substring(11,19));84 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 85 .getString("time").substring(11,19)); 84 86 if (time < dGpsStartTime) 85 time += 24*60*60;87 time += 24*60*60; 86 88 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY)); 87 89 ++i; … … 93 95 while ((j > 0) && (time - timeWindow/2 < time2)) 94 96 { 95 --j;96 if (wayPoints.elementAt(j).getString("time") != null)97 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j)98 .getString("time").substring(11,19));99 if (time2 < dGpsStartTime)100 time2 += 24*60*60;97 --j; 98 if (wayPoints.elementAt(j).getString("time") != null) 99 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(j) 100 .getString("time").substring(11,19)); 101 if (time2 < dGpsStartTime) 102 time2 += 24*60*60; 101 103 } 102 104 int k = i + 1; … … 104 106 while ((k < wayPoints.size()) && (time + timeWindow/2 > time2)) 105 107 { 106 if (wayPoints.elementAt(k).getString("time") != null)107 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k)108 .getString("time").substring(11,19));109 if (time2 < dGpsStartTime)110 time2 += 24*60*60;111 ++k;108 if (wayPoints.elementAt(k).getString("time") != null) 109 time2 = StopImporterDialog.parseTime(wayPoints.elementAt(k) 110 .getString("time").substring(11,19)); 111 if (time2 < dGpsStartTime) 112 time2 += 24*60*60; 113 ++k; 112 114 } 113 115 114 116 if (j < k) 115 117 { 116 double dist = 0;117 LatLon latLonI = wayPoints.elementAt(i).getCoor();118 for (int l = j; l < k; ++l)119 {120 double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor());121 if (distL > dist)122 dist = distL;123 }124 wayPointsDist.add(Double.valueOf(dist));118 double dist = 0; 119 LatLon latLonI = wayPoints.elementAt(i).getCoor(); 120 for (int l = j; l < k; ++l) 121 { 122 double distL = latLonI.greatCircleDistance(wayPoints.elementAt(l).getCoor()); 123 if (distL > dist) 124 dist = distL; 125 } 126 wayPointsDist.add(Double.valueOf(dist)); 125 127 } 126 128 else 127 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));129 wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY)); 128 130 129 131 if (wayPoints.elementAt(i).getString("time") != null) 130 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)131 .getString("time").substring(11,19));132 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 133 .getString("time").substring(11,19)); 132 134 if (time < dGpsStartTime) 133 time += 24*60*60;135 time += 24*60*60; 134 136 ++i; 135 137 } … … 139 141 { 140 142 if (wayPointsDist.elementAt(i).doubleValue() >= threshold) 141 continue;143 continue; 142 144 if ((wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i-1)) != -1) 143 145 || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i+1)) != -1)) 144 continue;146 continue; 145 147 146 148 LatLon latLon = wayPoints.elementAt(i).getCoor(); 147 149 if ((lastStopCoor != null) && (lastStopCoor.greatCircleDistance(latLon) < threshold)) 148 continue;150 continue; 149 151 150 152 if (wayPoints.elementAt(i).getString("time") != null) 151 153 { 152 time = StopImporterDialog.parseTime(wayPoints.elementAt(i)153 .getString("time").substring(11,19));154 double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime);155 if (gpsSyncTime < dGpsStartTime - 12*60*60)156 gpsSyncTime += 24*60*60;157 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);158 time -= timeDelta;159 Node node = StopImporterAction.createNode(latLon, type, "");160 stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), "", "");154 time = StopImporterDialog.parseTime(wayPoints.elementAt(i) 155 .getString("time").substring(11,19)); 156 double gpsSyncTime = StopImporterDialog.parseTime(this.gpsSyncTime); 157 if (gpsSyncTime < dGpsStartTime - 12*60*60) 158 gpsSyncTime += 24*60*60; 159 double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart); 160 time -= timeDelta; 161 Node node = StopImporterAction.createNode(latLon, type, ""); 162 stoplistTM.insertRow(-1, node, StopImporterAction.timeOf(time), "", new TransText(null)); 161 163 } 162 164 … … 175 177 Node node = stoplistTM.nodeAt(i); 176 178 if (node == null) 177 continue;179 continue; 178 180 Main.main.getCurrentDataSet().removePrimitive(node); 179 181 node.setDeleted(true); … … 188 190 Node node = stoplistTM.nodeAt(i); 189 191 if (node == null) 190 continue;192 continue; 191 193 node.setDeleted(false); 192 194 Main.main.getCurrentDataSet().addPrimitive(node); … … 202 204 @Override public JLabel getDescription() 203 205 { 204 return new JLabel( "public_transport.TrackStoplist.SuggestStops");206 return new JLabel(tr("Public Transport: Suggest stops")); 205 207 } 206 208 … … 223 225 double time = StopImporterDialog.parseTime(this.time); 224 226 if (time - startTime > 12*60*60) 225 time -= 24*60*60;227 time -= 24*60*60; 226 228 227 229 double nseTime = StopImporterDialog.parseTime(nse.time); 228 230 if (nseTime - startTime > 12*60*60) 229 nseTime -= 24*60*60;231 nseTime -= 24*60*60; 230 232 231 233 if (time < nseTime) 232 return -1;234 return -1; 233 235 else if (time > nseTime) 234 return 1;236 return 1; 235 237 else 236 return 0;238 return 0; 237 239 } 238 240 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/WaypointTableModel.java
r23192 r26168 1 1 package public_transport; 2 2 3 import static org.openstreetmap.josm.tools.I18n.marktr;4 3 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 … … 25 24 { 26 25 this.controller = controller; 27 addColumn( "Time");28 addColumn( "Stopname");29 addColumn( "Shelter");26 addColumn(tr("Time")); 27 addColumn(tr("Stopname")); 28 addColumn(tr("Shelter")); 30 29 addTableModelListener(this); 31 30 } … … 55 54 public void insertRow(int insPos, WayPoint wp) 56 55 { 57 String[] buf = { "", "", "" }; 58 buf[0] = wp.getString("time"); 59 if (buf[0] == null) 60 buf[0] = ""; 61 buf[1] = wp.getString("name"); 62 if (buf[1] == null) 63 buf[1] = ""; 56 String time = wp.getString("time"); 57 if (time == null) 58 time = ""; 59 String name = wp.getString("name"); 60 if (name == null) 61 name = ""; 64 62 65 Node node = controller.createNode(wp.getCoor(), buf[1]);63 Node node = controller.createNode(wp.getCoor(), name); 66 64 65 Object[] buf = { time, name, new TransText(null) }; 67 66 if (insPos == -1) 68 67 { … … 90 89 { 91 90 if (inEvent) 92 return;91 return; 93 92 Main.main.undoRedo.add(new WaypointsNameCommand 94 93 (this, e.getFirstRow(), (String)getValueAt(e.getFirstRow(), 1), 95 ( String)getValueAt(e.getFirstRow(), 2)));94 (TransText)getValueAt(e.getFirstRow(), 2))); 96 95 } 97 96 } -
applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsDetachCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 75 77 @Override public JLabel getDescription() 76 78 { 77 return new JLabel( "public_transport.Waypoints.Detach");79 return new JLabel(tr("Public Transport: Detach waypoints")); 78 80 } 79 81 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsDisableCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 83 85 @Override public JLabel getDescription() 84 86 { 85 return new JLabel( "public_transport.Waypoints.Disable");87 return new JLabel(tr("Public Transport: Disable waypoints")); 86 88 } 87 89 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsEnableCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 28 30 { 29 31 for (int i = 0; i < selectedLines.length; ++i) 30 consideredLines.add(selectedLines[i]);32 consideredLines.add(selectedLines[i]); 31 33 } 32 34 else 33 35 { 34 36 for (int i = 0; i < waypointTM.getRowCount(); ++i) 35 consideredLines.add(new Integer(i));37 consideredLines.add(new Integer(i)); 36 38 } 37 39 … … 40 42 { 41 43 if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) == null) 42 workingLines.add(consideredLines.elementAt(i));44 workingLines.add(consideredLines.elementAt(i)); 43 45 } 44 46 } … … 51 53 Node node = StopImporterAction.createNode 52 54 (waypointTM.coors.elementAt(j), type, (String)waypointTM.getValueAt(j, 1)); 53 if ("".equals((String)waypointTM.getValueAt(j, 2))) 54 node.put("shelter", null); 55 else 56 node.put("shelter", (String)waypointTM.getValueAt(j, 2)); 55 TransText shelter = (TransText)waypointTM.getValueAt(j, 2); 56 node.put("shelter", shelter.text); 57 57 waypointTM.nodes.set(j, node); 58 58 } … … 68 68 waypointTM.nodes.set(j, null); 69 69 if (node == null) 70 continue;70 continue; 71 71 Main.main.getCurrentDataSet().removePrimitive(node); 72 72 node.setDeleted(true); … … 82 82 @Override public JLabel getDescription() 83 83 { 84 return new JLabel( "public_transport.Waypoints.Enable");84 return new JLabel(tr("Public Transport: Enable waypoints")); 85 85 } 86 86 }; -
applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsNameCommand.java
r23192 r26168 1 1 package public_transport; 2 3 import static org.openstreetmap.josm.tools.I18n.tr; 2 4 3 5 import org.openstreetmap.josm.Main; … … 17 19 private String name = null; 18 20 private String oldShelter = null; 19 private String shelter = null;21 private TransText shelter; 20 22 21 23 public WaypointsNameCommand 22 (WaypointTableModel waypointTM, int workingLine, String name, Stringshelter)24 (WaypointTableModel waypointTM, int workingLine, String name, TransText shelter) 23 25 { 24 26 this.waypointTM = waypointTM; … … 31 33 this.name = name; 32 34 this.shelter = shelter; 33 if ("".equals(shelter))34 this.shelter = null;35 35 } 36 36 … … 40 40 { 41 41 waypointTM.nodes.elementAt(workingLine).put("name", name); 42 waypointTM.nodes.elementAt(workingLine).put("shelter", shelter );42 waypointTM.nodes.elementAt(workingLine).put("shelter", shelter.text); 43 43 } 44 44 waypointTM.inEvent = true; … … 47 47 else 48 48 waypointTM.setValueAt(name, workingLine, 1); 49 if (shelter == null) 50 waypointTM.setValueAt("", workingLine, 2); 51 else 52 waypointTM.setValueAt(shelter, workingLine, 2); 49 waypointTM.setValueAt(shelter, workingLine, 2); 53 50 waypointTM.inEvent = false; 54 51 return true; … … 67 64 else 68 65 waypointTM.setValueAt(oldName, workingLine, 1); 69 if (oldShelter == null) 70 waypointTM.setValueAt("", workingLine, 2); 71 else 72 waypointTM.setValueAt(oldShelter, workingLine, 2); 66 waypointTM.setValueAt(new TransText(oldShelter), workingLine, 2); 73 67 waypointTM.inEvent = false; 74 68 } … … 82 76 @Override public JLabel getDescription() 83 77 { 84 return new JLabel( "public_transport.Waypoints.EditName");78 return new JLabel(tr("Public Transport: Edit waypoint name")); 85 79 } 86 80 };
Note:
See TracChangeset
for help on using the changeset viewer.