Ignore:
Timestamp:
2010-09-15T18:59:53+02:00 (14 years ago)
Author:
stoecker
Message:

remove tabs

Location:
applications/editors/josm/plugins/public_transport/src/public_transport
Files:
27 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSAddCommand.java

    r22148 r23192  
    1616  private GTFSStopTableModel gtfsStopTM = null;
    1717  private String type = null;
    18  
     18
    1919  public GTFSAddCommand(GTFSImporterAction controller)
    2020  {
     
    2323    workingLines = new Vector< Integer >();
    2424    typesForUndo = new Vector< String >();
    25    
     25
    2626    // use either selected lines or all lines if no line is selected
    2727    int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
     
    3030    {
    3131      for (int i = 0; i < selectedLines.length; ++i)
    32         consideredLines.add(selectedLines[i]);
     32    consideredLines.add(selectedLines[i]);
    3333    }
    3434    else
    3535    {
    3636      for (int i = 0; i < gtfsStopTM.getRowCount(); ++i)
    37         consideredLines.add(new Integer(i));
     37    consideredLines.add(new Integer(i));
    3838    }
    39    
     39
    4040    // keep only lines where a node can be added
    4141    for (int i = 0; i < consideredLines.size(); ++i)
    4242    {
    4343      if (gtfsStopTM.nodes.elementAt(consideredLines.elementAt(i)) == null)
    44         workingLines.add(consideredLines.elementAt(i));
     44    workingLines.add(consideredLines.elementAt(i));
    4545    }
    4646  }
    47  
     47
    4848  public boolean executeCommand()
    4949  {
     
    6161    return true;
    6262  }
    63  
     63
    6464  public void undoCommand()
    6565  {
     
    7171      gtfsStopTM.setValueAt(typesForUndo.elementAt(i), j, 2);
    7272      if (node == null)
    73         continue;
     73    continue;
    7474      Main.main.getCurrentDataSet().removePrimitive(node);
    7575      node.setDeleted(true);
    7676    }
    7777  }
    78  
     78
    7979  public void fillModifiedData
    8080    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    8282  {
    8383  }
    84  
     84
    8585  @Override public JLabel getDescription()
    8686  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSCatchCommand.java

    r22148 r23192  
    1818  private GTFSStopTableModel gtfsStopTM = null;
    1919  private String type = null;
    20  
     20
    2121  public GTFSCatchCommand(GTFSImporterAction controller)
    2222  {
    2323    gtfsStopTM = controller.getGTFSStopTableModel();
    2424    workingLines = new Vector< Integer >();
    25    
     25
    2626    // use either selected lines or all lines if no line is selected
    2727    int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
     
    3030    workingLines.add(selectedLines[0]);
    3131  }
    32  
     32
    3333  public boolean executeCommand()
    3434  {
     
    4343      Node n = iter.next();
    4444      if ((n != null) && (n.equals(gtfsStopTM.nodes.elementAt(j))))
    45         continue;
     45    continue;
    4646      if (dest != null)
    47         return false;
     47    return false;
    4848      dest = n;
    4949    }
     
    5151      return false;
    5252    undoMapNode = new Node(dest);
    53    
     53
    5454    Node node = gtfsStopTM.nodes.elementAt(j);
    5555    undoTableNode = node;
     
    5959      node.setDeleted(true);
    6060    }
    61    
     61
    6262    dest.setCoor(gtfsStopTM.coors.elementAt(j));
    6363    dest.put("highway", "bus_stop");
     
    6969    type = (String)gtfsStopTM.getValueAt(j, 2);
    7070    gtfsStopTM.setValueAt("fed", j, 2);
    71    
     71
    7272    return true;
    7373  }
    74  
     74
    7575  public void undoCommand()
    7676  {
     
    7878      return;
    7979    int j = workingLines.elementAt(0);
    80    
     80
    8181    Node node = gtfsStopTM.nodes.elementAt(j);
    8282    if (node != null)
     
    8585      node.setDeleted(true);
    8686    }
    87    
     87
    8888    if (undoMapNode != null)
    8989    {
     
    9999    gtfsStopTM.setValueAt(type, j, 2);
    100100  }
    101  
     101
    102102  public void fillModifiedData
    103103    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    105105  {
    106106  }
    107  
     107
    108108  @Override public JLabel getDescription()
    109109  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSDeleteCommand.java

    r22148 r23192  
    1616  private Vector< String > typesForUndo = null;
    1717  private GTFSStopTableModel gtfsStopTM = null;
    18  
     18
    1919  public GTFSDeleteCommand(GTFSImporterAction controller)
    2020  {
     
    2323    nodesForUndo = new Vector< Node >();
    2424    typesForUndo = new Vector< String >();
    25    
     25
    2626    // use either selected lines or all lines if no line is selected
    2727    int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
     
    3030    {
    3131      for (int i = 0; i < selectedLines.length; ++i)
    32         consideredLines.add(selectedLines[i]);
     32    consideredLines.add(selectedLines[i]);
    3333    }
    3434    else
    3535    {
    3636      for (int i = 0; i < gtfsStopTM.getRowCount(); ++i)
    37         consideredLines.add(new Integer(i));
     37    consideredLines.add(new Integer(i));
    3838    }
    39    
     39
    4040    // keep only lines where a node can be added
    4141    for (int i = 0; i < consideredLines.size(); ++i)
    4242    {
    4343      if (gtfsStopTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
    44         workingLines.add(consideredLines.elementAt(i));
     44    workingLines.add(consideredLines.elementAt(i));
    4545    }
    4646  }
    47  
     47
    4848  public boolean executeCommand()
    4949  {
     
    5757      typesForUndo.add((String)gtfsStopTM.getValueAt(j, 2));
    5858      if (node == null)
    59         continue;
     59    continue;
    6060      gtfsStopTM.nodes.set(j, null);
    6161      gtfsStopTM.setValueAt("skipped", j, 2);
     
    6565    return true;
    6666  }
    67  
     67
    6868  public void undoCommand()
    6969  {
     
    7575      gtfsStopTM.setValueAt(typesForUndo.elementAt(i), j, 2);
    7676      if (node == null)
    77         continue;
     77    continue;
    7878      node.setDeleted(false);
    7979      Main.main.getCurrentDataSet().addPrimitive(node);
    8080    }
    8181  }
    82  
     82
    8383  public void fillModifiedData
    8484    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    8686  {
    8787  }
    88  
     88
    8989  @Override public JLabel getDescription()
    9090  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSImporterAction.java

    r23094 r23192  
    6363
    6464public class GTFSImporterAction extends JosmAction
    65 { 
     65{
    6666  private static GTFSImporterDialog dialog = null;
    6767  private static DefaultListModel tracksListModel = null;
     
    7070  private static GTFSStopTableModel gtfsStopTM = null;
    7171  public boolean inEvent = false;
    72  
     72
    7373  public GTFSImporterAction()
    7474  {
    7575    super(tr("Create Stops from GTFS ..."), null,
    76           tr("Create Stops from a GTFS file"), null, true);
     76      tr("Create Stops from a GTFS file"), null, true);
    7777  }
    7878
     
    8181    return gtfsStopTM;
    8282  }
    83  
     83
    8484  public GTFSImporterDialog getDialog()
    8585  {
     
    9393    return tracksListModel;
    9494  }
    95  
     95
    9696  public TrackReference getCurrentTrack()
    9797  {
     
    102102  {
    103103    DataSet mainDataSet = Main.main.getCurrentDataSet();
    104    
     104
    105105    if (dialog == null)
    106106      dialog = new GTFSImporterDialog(this);
    107    
     107
    108108    dialog.setVisible(true);
    109109
     
    113113      if (curDir.equals(""))
    114114      {
    115         curDir = ".";
     115    curDir = ".";
    116116      }
    117117      JFileChooser fc = new JFileChooser(new File(curDir));
    118       fc.setDialogTitle("Select GTFS file (stops.txt)"); 
     118      fc.setDialogTitle("Select GTFS file (stops.txt)");
    119119      fc.setMultiSelectionEnabled(false);
    120      
     120
    121121      int answer = fc.showOpenDialog(Main.parent);
    122122      if (answer != JFileChooser.APPROVE_OPTION)
    123         return;
    124      
     123    return;
     124
    125125      if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
    126         Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
    127      
     126    Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
     127
    128128      importData(fc.getSelectedFile());
    129      
     129
    130130      refreshData();
    131131    }
     
    133133    {
    134134      if ((!inEvent) && (dialog.gpsTimeStartValid()) && (currentTrack != null))
    135         Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
     135    Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
    136136    }
    137137    else if ("stopImporter.settingsStopwatchStart".equals(event.getActionCommand()))
    138138    {
    139139      if ((!inEvent) && (dialog.stopwatchStartValid()) && (currentTrack != null))
    140         Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
     140    Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
    141141    }
    142142    else if ("stopImporter.settingsTimeWindow".equals(event.getActionCommand()))
    143143    {
    144144      if (currentTrack != null)
    145         currentTrack.timeWindow = dialog.getTimeWindow();
     145    currentTrack.timeWindow = dialog.getTimeWindow();
    146146    }
    147147    else if ("stopImporter.settingsThreshold".equals(event.getActionCommand()))
    148148    {
    149149      if (currentTrack != null)
    150         currentTrack.threshold = dialog.getThreshold();
     150    currentTrack.threshold = dialog.getThreshold();
    151151    }
    152152    else if ("stopImporter.settingsSuggestStops".equals(event.getActionCommand()))
     
    181181  private void importData(final File file)
    182182  {
    183     try 
     183    try
    184184    {
    185185      FileReader is = new FileReader(file);
    186186      final BufferedReader r = new BufferedReader(is);
    187      
     187
    188188      if (data == null)
    189         data = new Vector< String >();
     189    data = new Vector< String >();
    190190      else
    191         data.clear();
    192      
     191    data.clear();
     192
    193193      while (r.ready())
    194         data.add(r.readLine());
    195     }
    196     catch (FileNotFoundException e) 
     194    data.add(r.readLine());
     195    }
     196    catch (FileNotFoundException e)
    197197    {
    198198      e.printStackTrace();
     
    211211    {
    212212      Vector< Node > existingStops = new Vector< Node >();
    213      
     213
    214214      if (Main.main.getCurrentDataSet() == null)
    215215      {
    216216        JOptionPane.showMessageDialog(null, "There exists no dataset."
    217             + " Try to download data from the server or open an OSM file.",
     217        + " Try to download data from the server or open an OSM file.",
    218218     "No data found", JOptionPane.ERROR_MESSAGE);
    219      
     219
    220220        System.out.println("Public Transport: StopInserter: No data found");
    221221
     
    224224      else
    225225      {
    226         Iterator< Node > iter =
    227             Main.main.getCurrentDataSet().getNodes().iterator();
    228         while (iter.hasNext())
    229         {
    230           Node node = iter.next();
    231           if ("bus_stop".equals(node.get("highway")))
    232             existingStops.add(node);
    233         }
    234       }
    235      
     226    Iterator< Node > iter =
     227        Main.main.getCurrentDataSet().getNodes().iterator();
     228    while (iter.hasNext())
     229    {
     230      Node node = iter.next();
     231      if ("bus_stop".equals(node.get("highway")))
     232        existingStops.add(node);
     233    }
     234      }
     235
    236236      Iterator< String > iter = data.iterator();
    237237      if (iter.hasNext())
    238         gtfsStopTM = new GTFSStopTableModel(this, iter.next());
     238    gtfsStopTM = new GTFSStopTableModel(this, iter.next());
    239239      else
    240240      {
    241         JOptionPane.showMessageDialog
    242         (null, "The GTFS file was empty.", "No data found",
    243         JOptionPane.ERROR_MESSAGE);
    244          
     241    JOptionPane.showMessageDialog
     242    (null, "The GTFS file was empty.", "No data found",
     243    JOptionPane.ERROR_MESSAGE);
     244
    245245        System.out.println("Public Transport: GTFSImporter: No data found");
    246246
    247247        return;
    248248      }
    249      
     249
    250250      while (iter.hasNext())
    251251      {
    252         String s = iter.next();
    253         gtfsStopTM.addRow(s, existingStops);
     252    String s = iter.next();
     253    gtfsStopTM.addRow(s, existingStops);
    254254      }
    255255      dialog.setGTFSStopTableModel(gtfsStopTM);
     
    260260      (null, "The GTFS file was empty.", "No data found",
    261261       JOptionPane.ERROR_MESSAGE);
    262      
     262
    263263      System.out.println("Public Transport: GTFSImporter: No data found");
    264264    }
    265265  }
    266  
     266
    267267//   public void tracksSelectionChanged(int selectedPos)
    268268//   {
     
    271271//       currentTrack = ((TrackReference)tracksListModel.elementAt(selectedPos));
    272272//       dialog.setTrackValid(true);
    273 //       
     273//
    274274//       //Prepare Settings
    275275//       dialog.setSettings
    276 //        (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
    277 //         currentTrack.timeWindow, currentTrack.threshold);
    278 //       
     276//    (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
     277//     currentTrack.timeWindow, currentTrack.threshold);
     278//
    279279//       //Prepare Stoplist
    280280//       dialog.setStoplistTableModel
     
    297297    {
    298298      JOptionPane.showMessageDialog(null, "There exists no dataset."
    299           + " Try to download data from the server or open an OSM file.",
     299      + " Try to download data from the server or open an OSM file.",
    300300   "No data found", JOptionPane.ERROR_MESSAGE);
    301      
     301
    302302      System.out.println("Public Transport: StopInserter: No data found");
    303            
     303
    304304      return null;
    305305    }
     
    317317    {
    318318      for (int i = 0; i < selectedLines.length; ++i)
    319         consideredLines.add(selectedLines[i]);
     319    consideredLines.add(selectedLines[i]);
    320320    }
    321321    else
    322322    {
    323323      for (int i = 0; i < table.getRowCount(); ++i)
    324         consideredLines.add(new Integer(i));
     324    consideredLines.add(new Integer(i));
    325325    }
    326326    return consideredLines;
     
    332332    if (Main.main.getCurrentDataSet() == null)
    333333      return;
    334      
     334
    335335    table.clearSelection();
    336      
     336
    337337    for (int i = 0; i < table.getRowCount(); ++i)
    338338    {
    339339      if ((nodes.elementAt(i) != null) &&
    340            (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i))))
    341         table.addRowSelectionInterval(i, i);
    342     }
    343   }
    344  
     340       (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i))))
     341    table.addRowSelectionInterval(i, i);
     342    }
     343  }
     344
    345345  /* shows the nodes that correspond to the marked lines in the table.
    346346     If no lines are marked in the table, show all nodes from the vector */
     
    353353      int j = consideredLines.elementAt(i);
    354354      if (nodes.elementAt(j) != null)
    355         nodes.elementAt(j).visit(box);
     355    nodes.elementAt(j).visit(box);
    356356    }
    357357    if (box.getBounds() == null)
     
    360360    Main.map.mapView.recalculateCenterScale(box);
    361361  }
    362  
     362
    363363  /* marks the nodes that correspond to the marked lines in the table.
    364364  If no lines are marked in the table, mark all nodes from the vector */
     
    372372      int j = consideredLines.elementAt(i);
    373373      if (nodes.elementAt(j) != null)
    374         Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));
    375     }
    376   }
    377  
     374    Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));
     375    }
     376  }
     377
    378378  public static String timeOf(double t)
    379379  {
    380380    t -= Math.floor(t/24/60/60)*24*60*60;
    381    
     381
    382382    int hour = (int)Math.floor(t/60/60);
    383383    t -=  Math.floor(t/60/60)*60*60;
     
    385385    t -=  Math.floor(t/60)*60;
    386386    double second = t;
    387    
     387
    388388    Format format = new DecimalFormat("00");
    389389    Format formatS = new DecimalFormat("00.###");
    390390    return (format.format(hour) + ":" + format.format(minute) + ":"
    391         + formatS.format(second));
    392   }
    393  
     391    + formatS.format(second));
     392  }
     393
    394394  public Action getFocusAddAction()
    395395  {
    396396    return new FocusAddAction();
    397397  }
    398  
     398
    399399  private class FocusAddAction extends AbstractAction
    400400  {
     
    405405    }
    406406  };
    407  
     407
    408408/*  public Action getFocusWaypointShelterAction(String shelter)
    409409  {
     
    417417      public void actionPerformed(ActionEvent e)
    418418      {
    419         JTable table = dialog.getWaypointsTable();
    420         int row = table.getEditingRow();
    421         if (row < 0)
    422           return;
    423         table.clearSelection();
    424         table.addRowSelectionInterval(row, row);
    425 /*      Main.main.undoRedo.add
    426             (new WaypointsDisableCommand(GTFSImporterAction.this));*
     419    JTable table = dialog.getWaypointsTable();
     420    int row = table.getEditingRow();
     421    if (row < 0)
     422      return;
     423    table.clearSelection();
     424    table.addRowSelectionInterval(row, row);
     425/*  Main.main.undoRedo.add
     426        (new WaypointsDisableCommand(GTFSImporterAction.this));*
    427427      }
    428428    };
     
    433433    return new FocusTrackStoplistNameAction();
    434434  }
    435  
     435
    436436  public Action getFocusTrackStoplistShelterAction(String shelter)
    437437  {
     
    445445      public void actionPerformed(ActionEvent e)
    446446      {
    447         JTable table = dialog.getStoplistTable();
    448         int row = table.getEditingRow();
    449         if (row < 0)
    450           return;
    451         table.clearSelection();
    452         table.addRowSelectionInterval(row, row);
    453 /*      Main.main.undoRedo.add
    454             (new TrackStoplistDeleteCommand(GTFSImporterAction.this));*
     447    JTable table = dialog.getStoplistTable();
     448    int row = table.getEditingRow();
     449    if (row < 0)
     450      return;
     451    table.clearSelection();
     452    table.addRowSelectionInterval(row, row);
     453/*  Main.main.undoRedo.add
     454        (new TrackStoplistDeleteCommand(GTFSImporterAction.this));*
    455455      }
    456456    };
     
    466466      int row = table.getEditingRow();
    467467      if (row < 0)
    468         row = 0;
     468    row = 0;
    469469      waypointTM.inEvent = true;
    470470      if (table.getCellEditor() != null)
    471471      {
    472         if (!table.getCellEditor().stopCellEditing())
    473           table.getCellEditor().cancelCellEditing();
     472    if (!table.getCellEditor().stopCellEditing())
     473      table.getCellEditor().cancelCellEditing();
    474474      }
    475475      table.editCellAt(row, 1);
    476476      table.getCellEditor().getTableCellEditorComponent
    477           (table, "", true, row, 1);
     477      (table, "", true, row, 1);
    478478      waypointTM.inEvent = false;
    479479    }
    480480  };
    481  
     481
    482482  private class FocusWaypointShelterAction extends AbstractAction
    483483  {
    484484    private String defaultShelter = null;
    485    
     485
    486486    public FocusWaypointShelterAction(String defaultShelter)
    487487    {
    488488      this.defaultShelter = defaultShelter;
    489489    }
    490    
     490
    491491    public void actionPerformed(ActionEvent e)
    492492    {
     
    496496      int row = table.getEditingRow();
    497497      if (row < 0)
    498         row = 0;
     498    row = 0;
    499499      waypointTM.inEvent = true;
    500500      if (table.getCellEditor() != null)
    501501      {
    502         if (!table.getCellEditor().stopCellEditing())
    503           table.getCellEditor().cancelCellEditing();
     502    if (!table.getCellEditor().stopCellEditing())
     503      table.getCellEditor().cancelCellEditing();
    504504      }
    505505      table.editCellAt(row, 2);
     
    509509    }
    510510  };
    511  
     511
    512512  private class FocusTrackStoplistNameAction extends AbstractAction
    513513  {
     
    519519      int row = table.getEditingRow();
    520520      if (row < 0)
    521         row = 0;
     521    row = 0;
    522522      currentTrack.inEvent = true;
    523523      if (table.getCellEditor() != null)
    524524      {
    525         if (!table.getCellEditor().stopCellEditing())
    526           table.getCellEditor().cancelCellEditing();
     525    if (!table.getCellEditor().stopCellEditing())
     526      table.getCellEditor().cancelCellEditing();
    527527      }
    528528      table.editCellAt(row, 1);
     
    532532    }
    533533  };
    534  
     534
    535535  private class FocusTrackStoplistShelterAction extends AbstractAction
    536536  {
    537537    private String defaultShelter = null;
    538    
     538
    539539    public FocusTrackStoplistShelterAction(String defaultShelter)
    540540    {
    541541      this.defaultShelter = defaultShelter;
    542542    }
    543    
     543
    544544    public void actionPerformed(ActionEvent e)
    545545    {
     
    549549      int row = table.getEditingRow();
    550550      if (row < 0)
    551         row = 0;
     551    row = 0;
    552552      currentTrack.inEvent = true;
    553553      if (table.getCellEditor() != null)
    554554      {
    555         if (!table.getCellEditor().stopCellEditing())
    556           table.getCellEditor().cancelCellEditing();
     555    if (!table.getCellEditor().stopCellEditing())
     556      table.getCellEditor().cancelCellEditing();
    557557      }
    558558      table.editCellAt(row, 2);
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSImporterDialog.java

    r22148 r23192  
    6363
    6464public class GTFSImporterDialog
    65 { 
     65{
    6666  private JDialog jDialog = null;
    6767  private JTabbedPane tabbedPane = null;
     
    7474  private JTable stoplistTable = null;
    7575  private JTable gtfsStopTable = null;
    76  
     76
    7777  public GTFSImporterDialog(GTFSImporterAction controller)
    7878  {
     
    8787    tabbedPane.setEnabledAt(1, true);
    8888    jDialog.add(tabbedPane);
    89      
     89
    9090    //Settings Tab
    9191    JPanel contentPane = tabSettings;
     
    9393    GridBagConstraints layoutCons = new GridBagConstraints();
    9494    contentPane.setLayout(gridbag);
    95      
     95
    9696    JLabel label = new JLabel("Type of stops to add");
    97      
     97
    9898    layoutCons.gridx = 0;
    9999    layoutCons.gridy = 0;
     
    104104    gridbag.setConstraints(label, layoutCons);
    105105    contentPane.add(label);
    106    
     106
    107107    cbStoptype = new JComboBox();
    108108    cbStoptype.setEditable(false);
     
    114114    cbStoptype.setActionCommand("gtfsImporter.settingsStoptype");
    115115    cbStoptype.addActionListener(controller);
    116    
     116
    117117    layoutCons.gridx = 0;
    118118    layoutCons.gridy = 1;
     
    123123    gridbag.setConstraints(cbStoptype, layoutCons);
    124124    contentPane.add(cbStoptype);
    125      
     125
    126126    label = new JLabel("Time on your GPS device");
    127      
     127
    128128    layoutCons.gridx = 0;
    129129    layoutCons.gridy = 2;
     
    134134    gridbag.setConstraints(label, layoutCons);
    135135    contentPane.add(label);
    136      
     136
    137137    tfGPSTimeStart = new JTextField("00:00:00", 15);
    138138    tfGPSTimeStart.setActionCommand("gtfsImporter.settingsGPSTimeStart");
    139139    tfGPSTimeStart.addActionListener(controller);
    140      
     140
    141141    layoutCons.gridx = 0;
    142142    layoutCons.gridy = 3;
     
    147147    gridbag.setConstraints(tfGPSTimeStart, layoutCons);
    148148    contentPane.add(tfGPSTimeStart);
    149      
     149
    150150    label = new JLabel("HH:MM:SS.sss");
    151      
     151
    152152    layoutCons.gridx = 1;
    153153    layoutCons.gridy = 3;
     
    158158    gridbag.setConstraints(label, layoutCons);
    159159    contentPane.add(label);
    160            
     160
    161161    label = new JLabel("Time on your stopwatch");
    162      
     162
    163163    layoutCons.gridx = 0;
    164164    layoutCons.gridy = 4;
     
    169169    gridbag.setConstraints(label, layoutCons);
    170170    contentPane.add(label);
    171      
     171
    172172    tfStopwatchStart = new JTextField("00:00:00", 15);
    173173    tfStopwatchStart.setActionCommand("gtfsImporter.settingsStopwatchStart");
    174174    tfStopwatchStart.addActionListener(controller);
    175      
     175
    176176    layoutCons.gridx = 0;
    177177    layoutCons.gridy = 5;
     
    182182    gridbag.setConstraints(tfStopwatchStart, layoutCons);
    183183    contentPane.add(tfStopwatchStart);
    184      
     184
    185185    label = new JLabel("HH:MM:SS.sss");
    186      
     186
    187187    layoutCons.gridx = 1;
    188188    layoutCons.gridy = 5;
     
    193193    gridbag.setConstraints(label, layoutCons);
    194194    contentPane.add(label);
    195      
     195
    196196    label = new JLabel("Time window");
    197      
     197
    198198    layoutCons.gridx = 0;
    199199    layoutCons.gridy = 6;
     
    204204    gridbag.setConstraints(label, layoutCons);
    205205    contentPane.add(label);
    206      
     206
    207207    tfTimeWindow = new JTextField("15", 4);
    208208    tfTimeWindow.setActionCommand("gtfsImporter.settingsTimeWindow");
    209209    tfTimeWindow.addActionListener(controller);
    210      
     210
    211211    layoutCons.gridx = 0;
    212212    layoutCons.gridy = 7;
     
    217217    gridbag.setConstraints(tfTimeWindow, layoutCons);
    218218    contentPane.add(tfTimeWindow);
    219      
     219
    220220    label = new JLabel("seconds");
    221      
     221
    222222    layoutCons.gridx = 1;
    223223    layoutCons.gridy = 7;
     
    228228    gridbag.setConstraints(label, layoutCons);
    229229    contentPane.add(label);
    230      
     230
    231231    label = new JLabel("Move Threshold");
    232      
     232
    233233    layoutCons.gridx = 0;
    234234    layoutCons.gridy = 8;
     
    239239    gridbag.setConstraints(label, layoutCons);
    240240    contentPane.add(label);
    241      
     241
    242242    tfThreshold = new JTextField("20", 4);
    243243    tfThreshold.setActionCommand("gtfsImporter.settingsThreshold");
    244244    tfThreshold.addActionListener(controller);
    245      
     245
    246246    layoutCons.gridx = 0;
    247247    layoutCons.gridy = 9;
     
    252252    gridbag.setConstraints(tfThreshold, layoutCons);
    253253    contentPane.add(tfThreshold);
    254      
     254
    255255    label = new JLabel("meters");
    256      
     256
    257257    layoutCons.gridx = 1;
    258258    layoutCons.gridy = 9;
     
    263263    gridbag.setConstraints(label, layoutCons);
    264264    contentPane.add(label);
    265      
     265
    266266    JButton bSuggestStops = new JButton("Suggest Stops");
    267267    bSuggestStops.setActionCommand("gtfsImporter.settingsSuggestStops");
    268268    bSuggestStops.addActionListener(controller);
    269      
     269
    270270    layoutCons.gridx = 0;
    271271    layoutCons.gridy = 10;
     
    276276    gridbag.setConstraints(bSuggestStops, layoutCons);
    277277    contentPane.add(bSuggestStops);
    278      
     278
    279279    //Waypoints Tab
    280280    contentPane = tabWaypoints;
     
    285285        (KeyStroke.getKeyStroke("alt N"), "gtfsImporter.gtfsStopsFocusAdd");
    286286    contentPane.getActionMap().put
    287         ("gtfsImporter.gtfsStopsFocusAdd", controller.getFocusAddAction());
     287    ("gtfsImporter.gtfsStopsFocusAdd", controller.getFocusAddAction());
    288288/*    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    289289        (KeyStroke.getKeyStroke("alt S"), "gtfsImporter.focusShelterYes");
    290290    contentPane.getActionMap().put
    291         ("gtfsImporter.focusShelterYes",
    292         controller.getFocusWaypointShelterAction("yes"));
     291    ("gtfsImporter.focusShelterYes",
     292    controller.getFocusWaypointShelterAction("yes"));
    293293    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    294294        (KeyStroke.getKeyStroke("alt T"), "gtfsImporter.focusShelterNo");
    295295    contentPane.getActionMap().put
    296         ("gtfsImporter.focusShelterNo",
    297         controller.getFocusWaypointShelterAction("no"));
     296    ("gtfsImporter.focusShelterNo",
     297    controller.getFocusWaypointShelterAction("no"));
    298298    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    299299        (KeyStroke.getKeyStroke("alt U"), "gtfsImporter.focusShelterImplicit");
    300300    contentPane.getActionMap().put
    301         ("gtfsImporter.focusShelterImplicit",
    302         controller.getFocusWaypointShelterAction("implicit"));
     301    ("gtfsImporter.focusShelterImplicit",
     302    controller.getFocusWaypointShelterAction("implicit"));
    303303    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    304304        (KeyStroke.getKeyStroke("alt D"), "gtfsImporter.gtfsStopsDelete");
    305305    contentPane.getActionMap().put
    306         ("gtfsImporter.gtfsStopsDelete",
    307         controller.getFocusWaypointDeleteAction());*/
    308      
     306    ("gtfsImporter.gtfsStopsDelete",
     307    controller.getFocusWaypointDeleteAction());*/
     308
    309309    gtfsStopTable = new JTable();
    310310    JScrollPane tableSP = new JScrollPane(gtfsStopTable);
    311    
     311
    312312    layoutCons.gridx = 0;
    313313    layoutCons.gridy = 0;
     
    318318    gridbag.setConstraints(tableSP, layoutCons);
    319319    contentPane.add(tableSP);
    320      
     320
    321321    JButton bFind = new JButton("Find");
    322322    bFind.setActionCommand("gtfsImporter.gtfsStopsFind");
    323323    bFind.addActionListener(controller);
    324      
     324
    325325    layoutCons.gridx = 0;
    326326    layoutCons.gridy = 1;
     
    331331    gridbag.setConstraints(bFind, layoutCons);
    332332    contentPane.add(bFind);
    333      
     333
    334334    JButton bShow = new JButton("Show");
    335335    bShow.setActionCommand("gtfsImporter.gtfsStopsShow");
    336336    bShow.addActionListener(controller);
    337      
     337
    338338    layoutCons.gridx = 0;
    339339    layoutCons.gridy = 2;
     
    344344    gridbag.setConstraints(bShow, layoutCons);
    345345    contentPane.add(bShow);
    346      
     346
    347347    JButton bMark = new JButton("Mark");
    348348    bMark.setActionCommand("gtfsImporter.gtfsStopsMark");
    349349    bMark.addActionListener(controller);
    350      
     350
    351351    layoutCons.gridx = 1;
    352352    layoutCons.gridy = 1;
     
    358358    gridbag.setConstraints(bMark, layoutCons);
    359359    contentPane.add(bMark);
    360      
     360
    361361    JButton bCatch = new JButton("Catch");
    362362    bCatch.setActionCommand("gtfsImporter.gtfsStopsCatch");
    363363    bCatch.addActionListener(controller);
    364      
     364
    365365    layoutCons.gridx = 2;
    366366    layoutCons.gridy = 1;
     
    372372    gridbag.setConstraints(bCatch, layoutCons);
    373373    contentPane.add(bCatch);
    374      
     374
    375375    JButton bJoin = new JButton("Join");
    376376    bJoin.setActionCommand("gtfsImporter.gtfsStopsJoin");
    377377    bJoin.addActionListener(controller);
    378      
     378
    379379    layoutCons.gridx = 2;
    380380    layoutCons.gridy = 2;
     
    386386    gridbag.setConstraints(bJoin, layoutCons);
    387387    contentPane.add(bJoin);
    388      
     388
    389389    JButton bAdd = new JButton("Enable");
    390390    bAdd.setActionCommand("gtfsImporter.gtfsStopsAdd");
    391391    bAdd.addActionListener(controller);
    392      
     392
    393393    layoutCons.gridx = 3;
    394394    layoutCons.gridy = 1;
     
    400400    gridbag.setConstraints(bAdd, layoutCons);
    401401    contentPane.add(bAdd);
    402      
     402
    403403    JButton bDelete = new JButton("Disable");
    404404    bDelete.setActionCommand("gtfsImporter.gtfsStopsDelete");
    405405    bDelete.addActionListener(controller);
    406      
     406
    407407    layoutCons.gridx = 3;
    408408    layoutCons.gridy = 2;
     
    413413    gridbag.setConstraints(bDelete, layoutCons);
    414414    contentPane.add(bDelete);
    415      
     415
    416416    jDialog.pack();
    417417    jDialog.setLocationRelativeTo(frame);
    418418  }
    419  
     419
    420420  public void setTrackValid(boolean valid)
    421421  {
    422422    tabbedPane.setEnabledAt(2, valid);
    423423  }
    424  
     424
    425425  public void setVisible(boolean visible)
    426426  {
    427427    jDialog.setVisible(visible);
    428428  }
    429  
     429
    430430  public void setSettings
    431431      (String gpsSyncTime, String stopwatchStart,
     
    437437    tfThreshold.setText(Double.toString(threshold));
    438438  }
    439  
     439
    440440  public String getStoptype()
    441441  {
    442442    return (String)cbStoptype.getSelectedItem();
    443443  }
    444  
     444
    445445  public boolean gpsTimeStartValid()
    446446  {
     
    452452    {
    453453      JOptionPane.showMessageDialog
    454           (null, "Can't parse a time from this string.", "Invalid value",
    455            JOptionPane.ERROR_MESSAGE);
     454      (null, "Can't parse a time from this string.", "Invalid value",
     455       JOptionPane.ERROR_MESSAGE);
    456456      return false;
    457457    }
    458458  }
    459  
     459
    460460  public String getGpsTimeStart()
    461461  {
    462462    return tfGPSTimeStart.getText();
    463463  }
    464  
     464
    465465  public void setGpsTimeStart(String s)
    466466  {
    467467    tfGPSTimeStart.setText(s);
    468468  }
    469  
     469
    470470  public boolean stopwatchStartValid()
    471471  {
     
    477477    {
    478478      JOptionPane.showMessageDialog
    479           (null, "Can't parse a time from this string.", "Invalid value",
    480            JOptionPane.ERROR_MESSAGE);
     479      (null, "Can't parse a time from this string.", "Invalid value",
     480       JOptionPane.ERROR_MESSAGE);
    481481      return false;
    482482    }
    483483  }
    484  
     484
    485485  public String getStopwatchStart()
    486486  {
    487487    return tfStopwatchStart.getText();
    488488  }
    489  
     489
    490490  public void setStopwatchStart(String s)
    491491  {
    492492    tfStopwatchStart.setText(s);
    493493  }
    494  
     494
    495495  public double getTimeWindow()
    496496  {
    497497    return Double.parseDouble(tfTimeWindow.getText());
    498498  }
    499  
     499
    500500  public double getThreshold()
    501501  {
    502502    return Double.parseDouble(tfThreshold.getText());
    503503  }
    504  
     504
    505505  public JTable getGTFSStopTable()
    506506  {
    507507    return gtfsStopTable;
    508508  }
    509  
     509
    510510  public void setGTFSStopTableModel(GTFSStopTableModel model)
    511511  {
     
    516516    gtfsStopTable.getColumnModel().getColumn(2).setPreferredWidth((int)(width * 0.1));
    517517  }
    518  
     518
    519519  public static double parseTime(String s)
    520520  {
    521521    double result = 0;
    522522    if ((s.charAt(2) != ':') || (s.charAt(2) != ':')
    523         || (s.length() < 8))
     523    || (s.length() < 8))
    524524      return -1;
    525525    int hour = Integer.parseInt(s.substring(0, 2));
     
    527527    double second = Double.parseDouble(s.substring(6, s.length()));
    528528    if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59)
    529         || (second < 0) || (second >= 60.0))
     529    || (second < 0) || (second >= 60.0))
    530530      return -1;
    531531    return (second + minute*60 + hour*60*60);
    532532  }
    533  
     533
    534534/*  private class TracksLSL implements ListSelectionListener
    535535  {
    536536    GTFSImporterAction root = null;
    537    
     537
    538538    public TracksLSL(GTFSImporterAction sia)
    539539    {
    540540      root = sia;
    541541    }
    542    
     542
    543543    public void valueChanged(ListSelectionEvent e)
    544544    {
    545545      int selectedPos = tracksList.getAnchorSelectionIndex();
    546546      if (tracksList.isSelectedIndex(selectedPos))
    547         root.tracksSelectionChanged(selectedPos);
     547    root.tracksSelectionChanged(selectedPos);
    548548      else
    549         root.tracksSelectionChanged(-1);
     549    root.tracksSelectionChanged(-1);
    550550    }
    551551  };*/
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSJoinCommand.java

    r22148 r23192  
    1818  private GTFSStopTableModel gtfsStopTM = null;
    1919  private String type = null;
    20  
     20
    2121  public GTFSJoinCommand(GTFSImporterAction controller)
    2222  {
    2323    gtfsStopTM = controller.getGTFSStopTableModel();
    2424    workingLines = new Vector< Integer >();
    25    
     25
    2626    // use either selected lines or all lines if no line is selected
    2727    int[] selectedLines = controller.getDialog().getGTFSStopTable().getSelectedRows();
     
    3030    workingLines.add(selectedLines[0]);
    3131  }
    32  
     32
    3333  public boolean executeCommand()
    3434  {
     
    4343      Node n = iter.next();
    4444      if ((n != null) && (n.equals(gtfsStopTM.nodes.elementAt(j))))
    45         continue;
     45    continue;
    4646      if (dest != null)
    47         return false;
     47    return false;
    4848      dest = n;
    4949    }
     
    5151      return false;
    5252    undoMapNode = new Node(dest);
    53    
     53
    5454    Node node = gtfsStopTM.nodes.elementAt(j);
    5555    undoTableNode = node;
     
    5959      node.setDeleted(true);
    6060    }
    61    
     61
    6262    dest.put("highway", "bus_stop");
    6363    dest.put("stop_id", (String)gtfsStopTM.getValueAt(j, 0));
     
    6767    type = (String)gtfsStopTM.getValueAt(j, 2);
    6868    gtfsStopTM.setValueAt("moved", j, 2);
    69    
     69
    7070    return true;
    7171  }
    72  
     72
    7373  public void undoCommand()
    7474  {
     
    7676      return;
    7777    int j = workingLines.elementAt(0);
    78    
     78
    7979    Node node = gtfsStopTM.nodes.elementAt(j);
    8080    if (node != null)
     
    8383      node.setDeleted(true);
    8484    }
    85    
     85
    8686    if (undoMapNode != null)
    8787    {
     
    9797    gtfsStopTM.setValueAt(type, j, 2);
    9898  }
    99  
     99
    100100  public void fillModifiedData
    101101    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    103103  {
    104104  }
    105  
     105
    106106  @Override public JLabel getDescription()
    107107  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/GTFSStopTableModel.java

    r23095 r23192  
    2727  private int lonCol = -1;
    2828  private char separator = ',';
    29  
     29
    3030  public GTFSStopTableModel(GTFSImporterAction controller,
    31                             String columnConfig)
     31                String columnConfig)
    3232  {
    3333    int pos = columnConfig.indexOf(separator);
     
    4848      String title = columnConfig.substring(oldPos, pos);
    4949      if ("stop_id".equals(title))
    50         idCol = i;
     50    idCol = i;
    5151      else if ("stop_name".equals(title))
    52         nameCol = i;
     52    nameCol = i;
    5353      else if ("stop_lat".equals(title))
    54         latCol = i;
     54    latCol = i;
    5555      else if ("stop_lon".equals(title))
    56         lonCol = i;
     56    lonCol = i;
    5757      ++i;
    5858      oldPos = pos + 1;
     
    6868    else if ("stop_lon".equals(title))
    6969      lonCol = i;
    70    
     70
    7171    this.controller = controller;
    7272    addColumn("Id");
     
    7575    addTableModelListener(this);
    7676  }
    77    
     77
    7878  public boolean isCellEditable(int row, int column)
    7979  {
    8080    return false;
    8181  }
    82    
     82
    8383  public void addRow(Object[] obj)
    8484  {
    8585    throw new UnsupportedOperationException();
    8686  }
    87    
     87
    8888  public void insertRow(int insPos, Object[] obj)
    8989  {
    9090    throw new UnsupportedOperationException();
    9191  }
    92    
     92
    9393  public void addRow(String s)
    9494  {
    9595    insertRow(-1, s, new Vector< Node >());
    9696  }
    97  
     97
    9898  public void addRow(String s, Vector< Node > existingStops)
    9999  {
     
    135135    return s;
    136136  }
    137  
     137
    138138  public void insertRow(int insPos, String s, Vector< Node > existingStops)
    139139  {
     
    147147    {
    148148      if (i == idCol)
    149         buf[0] = stripQuot(s.substring(oldPos, pos));
     149    buf[0] = stripQuot(s.substring(oldPos, pos));
    150150      else if (i == nameCol)
    151         buf[1] = stripQuot(s.substring(oldPos, pos));
     151    buf[1] = stripQuot(s.substring(oldPos, pos));
    152152      else if (i == latCol)
    153         lat = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
     153    lat = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
    154154      else if (i == lonCol)
    155         lon = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
     155    lon = Double.parseDouble(stripQuot(s.substring(oldPos, pos)));
    156156      ++i;
    157157      oldPos = pos + 1;
     
    166166    else if (i == lonCol)
    167167      lon = Double.parseDouble(stripQuot(s.substring(oldPos)));
    168    
     168
    169169    LatLon coor = new LatLon(lat, lon);
    170    
     170
    171171    if (Main.main.getCurrentDataSet() != null)
    172172    {
     
    176176      while (iter.hasNext())
    177177      {
    178         if (iter.next().bounds.contains(coor))
    179         {
    180           inside = true;
    181           break;
    182         }
     178    if (iter.next().bounds.contains(coor))
     179    {
     180      inside = true;
     181      break;
     182    }
    183183      }
    184184      if (!inside)
    185         buf[2] = "outside";
    186     }
    187    
     185    buf[2] = "outside";
     186    }
     187
    188188    boolean nearBusStop = false;
    189189    Iterator< Node > iter = existingStops.iterator();
     
    193193      if (coor.greatCircleDistance(node.getCoor()) < 1000)
    194194      {
    195         nearBusStop = true;
    196         break;
    197       }
    198     }
    199    
     195    nearBusStop = true;
     196    break;
     197      }
     198    }
     199
    200200    if (insPos == -1)
    201201    {
    202202      if ((nearBusStop) || !("pending".equals(buf[2])))
    203         nodes.addElement(null);
     203    nodes.addElement(null);
    204204      else
    205205      {
    206         Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
    207         nodes.addElement(node);
    208         buf[2] = "added";
     206    Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
     207    nodes.addElement(node);
     208    buf[2] = "added";
    209209      }
    210210      coors.addElement(coor);
     
    214214    {
    215215      if ((nearBusStop) || !("pending".equals(buf[2])))
    216         nodes.insertElementAt(null, insPos);
     216    nodes.insertElementAt(null, insPos);
    217217      else
    218218      {
    219         Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
    220         nodes.insertElementAt(node, insPos);
    221         buf[2] = "added";
     219    Node node = GTFSImporterAction.createNode(coor, buf[0], buf[1]);
     220    nodes.insertElementAt(node, insPos);
     221    buf[2] = "added";
    222222      }
    223223      coors.insertElementAt(coor, insPos);
     
    225225    }
    226226  }
    227    
     227
    228228  public void clear()
    229229  {
     
    231231    super.setRowCount(0);
    232232  }
    233  
     233
    234234  public void tableChanged(TableModelEvent e)
    235235  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/ItineraryTableModel.java

    r20895 r23192  
    33// import static org.openstreetmap.josm.tools.I18n.marktr;
    44// import static org.openstreetmap.josm.tools.I18n.tr;
    5 // 
     5//
    66// import java.awt.BorderLayout;
    77// import java.awt.Container;
     
    2121// import java.util.TreeSet;
    2222import java.util.Vector;
    23 // 
     23//
    2424// import javax.swing.DefaultCellEditor;
    2525// import javax.swing.DefaultListModel;
     
    4343import javax.swing.table.DefaultTableModel;
    4444// import javax.swing.table.TableCellEditor;
    45 // 
     45//
    4646// import org.openstreetmap.josm.Main;
    4747// import org.openstreetmap.josm.actions.JosmAction;
     
    6464  public Vector<Way> ways = new Vector<Way>();
    6565  public boolean inEvent = false;
    66  
     66
    6767  public boolean isCellEditable(int row, int column)
    6868  {
     
    7373    return true;
    7474  }
    75  
     75
    7676  public void addRow(Object[] obj)
    7777  {
     
    7979    super.addRow(obj);
    8080  }
    81  
     81
    8282  public void insertRow(int insPos, Object[] obj)
    8383  {
     
    9393    }
    9494  }
    95  
     95
    9696  public void addRow(Way way, String role)
    9797  {
    9898    insertRow(-1, way, role);
    9999  }
    100  
     100
    101101  public void insertRow(int insPos, Way way, String role)
    102102  {
     
    123123    }
    124124  }
    125  
     125
    126126  public void clear()
    127127  {
     
    129129    super.setRowCount(0);
    130130  }
    131  
     131
    132132  public void cleanupGaps()
    133133  {
    134134    inEvent = true;
    135135    Node lastNode = null;
    136    
     136
    137137    for (int i = 0; i < getRowCount(); ++i)
    138138    {
    139139      if (ways.elementAt(i) == null)
    140140      {
    141         ++i;
    142         if (i >= getRowCount())
    143           break;
     141    ++i;
     142    if (i >= getRowCount())
     143      break;
    144144      }
    145145      while ((ways.elementAt(i) == null) &&
    146         ((i == 0) || (ways.elementAt(i-1) == null)))
    147       {
    148         ways.removeElementAt(i);
    149         removeRow(i);
    150         if (i >= getRowCount())
    151           break;
     146    ((i == 0) || (ways.elementAt(i-1) == null)))
     147      {
     148    ways.removeElementAt(i);
     149    removeRow(i);
     150    if (i >= getRowCount())
     151      break;
    152152      }
    153153      if (i >= getRowCount())
    154         break;
    155      
     154    break;
     155
    156156      boolean gapRequired = gapNecessary
    157157      (ways.elementAt(i), (String)(getValueAt(i, 1)), lastNode);
    158158      if ((i > 0) && (!gapRequired) && (ways.elementAt(i-1) == null))
    159159      {
    160         ways.removeElementAt(i-1);
    161         removeRow(i-1);
    162         --i;
     160    ways.removeElementAt(i-1);
     161    removeRow(i-1);
     162    --i;
    163163      }
    164164      else if ((i > 0) && gapRequired && (ways.elementAt(i-1) != null))
    165165      {
    166         String[] buf = { "", "" };
    167         buf[0] = "[gap]";
    168         insertRow(i, buf);
    169         ++i;
     166    String[] buf = { "", "" };
     167    buf[0] = "[gap]";
     168    insertRow(i, buf);
     169    ++i;
    170170      }
    171171      lastNode = getLastNode(ways.elementAt(i), (String)(getValueAt(i, 1)));
     
    179179    inEvent = false;
    180180  }
    181  
     181
    182182  public void tableChanged(TableModelEvent e)
    183183  {
     
    185185    {
    186186      if (inEvent)
    187         return;
     187    return;
    188188      cleanupGaps();
    189189      RoutePatternAction.rebuildWays();
    190190    }
    191191  }
    192  
     192
    193193  private Node getLastNode(Way way, String role)
    194194  {
     
    200200      return way.getNode(0);
    201201      else
    202         return way.getNode(way.getNodesCount() - 1);
    203     }
    204   }
    205  
     202    return way.getNode(way.getNodesCount() - 1);
     203    }
     204  }
     205
    206206  private boolean gapNecessary(Way way, String role, Node lastNode)
    207207  {
     
    212212      firstNode = way.getNode(way.getNodesCount() - 1);
    213213      else
    214         firstNode = way.getNode(0);
     214    firstNode = way.getNode(0);
    215215      if ((lastNode != null) && (!lastNode.equals(firstNode)))
    216         return true;
     216    return true;
    217217    }
    218218    return false;
  • applications/editors/josm/plugins/public_transport/src/public_transport/PublicTransportPlugin.java

    r22148 r23192  
    2323
    2424public class PublicTransportPlugin extends Plugin {
    25    
     25
    2626  static JMenu jMenu;
    2727
  • applications/editors/josm/plugins/public_transport/src/public_transport/RoutePatternAction.java

    r21867 r23192  
    6060
    6161public class RoutePatternAction extends JosmAction {
    62  
     62
    6363  private class RoutesLSL implements ListSelectionListener {
    6464    RoutePatternAction root = null;
    65    
     65
    6666    public RoutesLSL(RoutePatternAction rpa) {
    6767      root = rpa;
    6868    }
    69    
     69
    7070    public void valueChanged(ListSelectionEvent e) {
    7171      root.routesSelectionChanged();
    7272    }
    7373  };
    74  
     74
    7575  private class RouteReference implements Comparable< RouteReference > {
    7676    Relation route;
    77    
     77
    7878    public RouteReference(Relation route) {
    7979      this.route = route;
    8080    }
    81    
     81
    8282    public int compareTo(RouteReference rr) {
    8383      if (route.get("route") != null)
    8484      {
    85         if (rr.route.get("route") == null)
    86           return -1;
    87         int result = route.get("route").compareTo(rr.route.get("route"));
    88         if (result != 0)
    89           return result;
     85    if (rr.route.get("route") == null)
     86      return -1;
     87    int result = route.get("route").compareTo(rr.route.get("route"));
     88    if (result != 0)
     89      return result;
    9090      }
    9191      else if (rr.route.get("route") != null)
    92         return 1;
     92    return 1;
    9393      if (route.get("ref") != null)
    9494      {
    95         if (rr.route.get("ref") == null)
    96           return -1;
    97         int result = route.get("ref").compareTo(rr.route.get("ref"));
    98         if (result != 0)
    99           return result;
     95    if (rr.route.get("ref") == null)
     96      return -1;
     97    int result = route.get("ref").compareTo(rr.route.get("ref"));
     98    if (result != 0)
     99      return result;
    100100      }
    101101      else if (rr.route.get("ref") != null)
    102         return 1;
     102    return 1;
    103103      if (route.get("to") != null)
    104104      {
    105         if (rr.route.get("to") == null)
    106           return -1;
    107         int result = route.get("to").compareTo(rr.route.get("to"));
    108         if (result != 0)
    109           return result;
     105    if (rr.route.get("to") == null)
     106      return -1;
     107    int result = route.get("to").compareTo(rr.route.get("to"));
     108    if (result != 0)
     109      return result;
    110110      }
    111111      else if (rr.route.get("to") != null)
    112         return 1;
     112    return 1;
    113113      if (route.get("direction") != null)
    114114      {
    115         if (rr.route.get("direction") == null)
    116           return -1;
    117         int result = route.get("direction").compareTo(rr.route.get("direction"));
    118         if (result != 0)
    119           return result;
     115    if (rr.route.get("direction") == null)
     116      return -1;
     117    int result = route.get("direction").compareTo(rr.route.get("direction"));
     118    if (result != 0)
     119      return result;
    120120      }
    121121      else if (rr.route.get("direction") != null)
    122         return 1;
     122    return 1;
    123123      if (route.getId() < rr.route.getId())
    124         return -1;
     124    return -1;
    125125      else if (route.getId() > rr.route.getId())
    126         return 1;
     126    return 1;
    127127      return 0;
    128128    }
    129    
     129
    130130    public String toString() {
    131131      String buf = route.get("route");
    132132      if ((route.get("ref") != null) && (route.get("ref") != ""))
    133133      {
    134         if ((route.get("to") != null) && (route.get("to") != ""))
    135         {
    136           buf += " " + route.get("ref") + ": " + route.get("to");
    137         }
    138         else if ((route.get("direction") != null) && (route.get("direction") != ""))
    139         {
    140           buf += " " + route.get("ref") + ": " + route.get("direction");
    141         }
    142         else
    143         {
    144           buf += " " + route.get("ref");
    145         }
     134    if ((route.get("to") != null) && (route.get("to") != ""))
     135    {
     136      buf += " " + route.get("ref") + ": " + route.get("to");
     137    }
     138    else if ((route.get("direction") != null) && (route.get("direction") != ""))
     139    {
     140      buf += " " + route.get("ref") + ": " + route.get("direction");
     141    }
     142    else
     143    {
     144      buf += " " + route.get("ref");
     145    }
    146146      }
    147147      buf += " [ID " + Long.toString(route.getId()) + "]";
    148      
     148
    149149      return buf;
    150150    }
    151151  };
    152  
     152
    153153  private class TagTableModel extends DefaultTableModel implements TableModelListener {
    154154    Relation relation = null;
    155155    TreeSet< String > blacklist = null;
    156156    boolean hasFixedKeys = true;
    157    
     157
    158158    public TagTableModel(boolean hasFixedKeys) {
    159159      this.hasFixedKeys = hasFixedKeys;
     
    162162    public boolean isCellEditable(int row, int column) {
    163163      if ((column == 0) && (hasFixedKeys))
    164         return false;
     164    return false;
    165165      return true;
    166166    }
    167    
     167
    168168    public void readRelation(Relation rel) {
    169169      relation = rel;
    170      
     170
    171171      for (int i = 0; i < getRowCount(); ++i)
    172172      {
    173         String value = rel.get((String)getValueAt(i, 0));
    174         if (value == null)
    175           value = "";
    176         setValueAt(value, i, 1);
    177       }
    178     }
    179    
     173    String value = rel.get((String)getValueAt(i, 0));
     174    if (value == null)
     175      value = "";
     176    setValueAt(value, i, 1);
     177      }
     178    }
     179
    180180    public void readRelation(Relation rel, TreeSet< String > blacklist) {
    181181      relation = rel;
    182182      this.blacklist = blacklist;
    183      
     183
    184184      setRowCount(0);
    185185      Iterator< Map.Entry< String, String > > iter = rel.getKeys().entrySet().iterator();
    186186      while (iter.hasNext())
    187187      {
    188         Map.Entry< String, String > entry = iter.next();
    189         if (!blacklist.contains(entry.getKey()))
    190         {
    191           Vector< String > newRow = new Vector< String >();
    192           newRow.add(entry.getKey());
    193           newRow.add(entry.getValue());
    194           addRow(newRow);
    195         }
    196       }
    197      
     188    Map.Entry< String, String > entry = iter.next();
     189    if (!blacklist.contains(entry.getKey()))
     190    {
     191      Vector< String > newRow = new Vector< String >();
     192      newRow.add(entry.getKey());
     193      newRow.add(entry.getValue());
     194      addRow(newRow);
     195    }
     196      }
     197
    198198      for (int i = 0; i < getRowCount(); ++i)
    199199      {
    200         String value = rel.get((String)getValueAt(i, 0));
    201         if (value == null)
    202           value = "";
    203         setValueAt(value, i, 1);
    204       }
    205     }
    206  
     200    String value = rel.get((String)getValueAt(i, 0));
     201    if (value == null)
     202      value = "";
     203    setValueAt(value, i, 1);
     204      }
     205    }
     206
    207207    public void tableChanged(TableModelEvent e)
    208208    {
    209209      if (e.getType() == TableModelEvent.UPDATE)
    210210      {
    211         relation.setModified(true);
    212        
    213         String key = (String)getValueAt(e.getFirstRow(), 0);
    214         if (key == null)
    215           return;
    216         if ((blacklist == null) || (!blacklist.contains(key)))
    217         {
    218           relation.setModified(true);
    219           if ("".equals(getValueAt(e.getFirstRow(), 1)))
    220             relation.remove(key);
    221           else
    222             relation.put(key, (String)getValueAt(e.getFirstRow(), 1));
    223         }
    224         else
    225         {
    226           if (e.getColumn() == 0)
    227             setValueAt("", e.getFirstRow(), 0);
    228         }
     211    relation.setModified(true);
     212
     213    String key = (String)getValueAt(e.getFirstRow(), 0);
     214    if (key == null)
     215      return;
     216    if ((blacklist == null) || (!blacklist.contains(key)))
     217    {
     218      relation.setModified(true);
     219      if ("".equals(getValueAt(e.getFirstRow(), 1)))
     220        relation.remove(key);
     221      else
     222        relation.put(key, (String)getValueAt(e.getFirstRow(), 1));
     223    }
     224    else
     225    {
     226      if (e.getColumn() == 0)
     227        setValueAt("", e.getFirstRow(), 0);
     228    }
    229229      }
    230230    }
    231231  };
    232  
     232
    233233  private class CustomCellEditorTable extends JTable {
    234234    TreeMap< Integer, TableCellEditor > col1 = null;
    235235    TreeMap< Integer, TableCellEditor > col2 = null;
    236    
     236
    237237    public CustomCellEditorTable() {
    238238      col1 = new TreeMap< Integer, TableCellEditor >();
    239239      col2 = new TreeMap< Integer, TableCellEditor >();
    240240    }
    241    
     241
    242242    public TableCellEditor getCellEditor(int row, int column) {
    243243      TableCellEditor editor = null;
    244244      if (column == 0)
    245         editor = col1.get(new Integer(row));
     245    editor = col1.get(new Integer(row));
    246246      else
    247         editor = col2.get(new Integer(row));
     247    editor = col2.get(new Integer(row));
    248248      if (editor == null)
    249         return new DefaultCellEditor(new JTextField());
     249    return new DefaultCellEditor(new JTextField());
    250250      else
    251         return editor;
    252     }
    253    
     251    return editor;
     252    }
     253
    254254    public void setCellEditor(int row, int column, TableCellEditor editor) {
    255255      if (column == 0)
    256         col1.put(new Integer(row), editor);
     256    col1.put(new Integer(row), editor);
    257257      else
    258         col2.put(new Integer(row), editor);
     258    col2.put(new Integer(row), editor);
    259259    }
    260260  };
    261  
     261
    262262  private class StoplistTableModel extends DefaultTableModel {
    263263    public Vector<Node> nodes = new Vector<Node>();
    264    
     264
    265265    public boolean isCellEditable(int row, int column) {
    266266      if (column != 1)
    267         return false;
     267    return false;
    268268      return true;
    269269    }
    270  
     270
    271271    public void addRow(Object[] obj) {
    272272      throw new UnsupportedOperationException();
    273273    }
    274    
     274
    275275    public void insertRow(int insPos, Object[] obj) {
    276276      throw new UnsupportedOperationException();
    277277    }
    278    
     278
    279279    public void addRow(Node node, String role) {
    280280      insertRow(-1, node, role);
    281281    }
    282    
     282
    283283    public void insertRow(int insPos, Node node, String role) {
    284284      String[] buf = { "", "" };
     
    286286      if (curName != null)
    287287      {
    288         buf[0] = curName;
     288    buf[0] = curName;
    289289      }
    290290      else
    291291      {
    292         buf[0] = "[ID] " + (new Long(node.getId())).toString();
     292    buf[0] = "[ID] " + (new Long(node.getId())).toString();
    293293      }
    294294      buf[1] = role;
    295295      if (insPos == -1)
    296296      {
    297         nodes.addElement(node);
    298         super.addRow(buf);
     297    nodes.addElement(node);
     298    super.addRow(buf);
    299299      }
    300300      else
    301301      {
    302         nodes.insertElementAt(node, insPos);
    303         super.insertRow(insPos, buf);
    304       }
    305     }
    306    
     302    nodes.insertElementAt(node, insPos);
     303    super.insertRow(insPos, buf);
     304      }
     305    }
     306
    307307    public void clear()
    308308    {
     
    311311    }
    312312  };
    313  
     313
    314314  private class StoplistTableModelListener implements TableModelListener {
    315315    public void tableChanged(TableModelEvent e)
     
    317317      if (e.getType() == TableModelEvent.UPDATE)
    318318      {
    319         rebuildNodes();
     319    rebuildNodes();
    320320      }
    321321    }
    322322  };
    323  
     323
    324324  private class SegmentMetric {
    325325    public double aLat, aLon;
    326326    public double length;
    327327    public double d1, d2, o1, o2;
    328    
     328
    329329    public SegmentMetric(double fromLat, double fromLon, double toLat, double toLon) {
    330330      aLat = fromLat;
    331331      aLon = fromLon;
    332      
     332
    333333      //Compute length and direction
    334334      //length is in units of latitude degrees
     
    336336      d2 = (toLon - fromLon) * Math.cos(fromLat * Math.PI/180.0);
    337337      length = Math.sqrt(d1*d1 + d2*d2);
    338    
     338
    339339      //Normalise direction
    340340      d1 = d1 / length;
    341341      d2 = d2 / length;
    342    
     342
    343343      //Compute orthogonal direction (right hand size is positive)
    344344      o1 = - d2;
    345345      o2 = d1;
    346    
     346
    347347      //Prepare lon direction to reduce the number of necessary multiplications
    348348      d2 = d2 * Math.cos(fromLat * Math.PI/180.0);
     
    350350    }
    351351  };
    352  
     352
    353353  private class StopReference implements Comparable< StopReference > {
    354354    public int index = 0;
     
    358358    public String role = "";
    359359    public Node node;
    360    
     360
    361361    public StopReference(int inIndex, double inPos, double inDistance,
    362                         String inName, String inRole, Node inNode) {
     362            String inName, String inRole, Node inNode) {
    363363      index = inIndex;
    364364      pos = inPos;
     
    368368      node = inNode;
    369369    }
    370    
     370
    371371    public int compareTo(StopReference sr) {
    372372      if (this.index < sr.index)
    373         return -1;
     373    return -1;
    374374      if (this.index > sr.index)
    375         return 1;
     375    return 1;
    376376      if (this.pos < sr.pos)
    377         return -1;
     377    return -1;
    378378      if (this.pos > sr.pos)
    379         return 1;
     379    return 1;
    380380      return 0;
    381381    }
    382382  };
    383  
     383
    384384  private static JDialog jDialog = null;
    385385  private static JTabbedPane tabbedPane = null;
     
    403403  private static Vector< RelationMember > markedWays = new Vector< RelationMember >();
    404404  private static Vector< RelationMember > markedNodes = new Vector< RelationMember >();
    405  
     405
    406406  private static Relation copy = null;
    407  
     407
    408408  public RoutePatternAction() {
    409409    super(tr("Route patterns ..."), null,
    410           tr("Edit Route patterns for public transport"), null, true);
     410      tr("Edit Route patterns for public transport"), null, true);
    411411  }
    412412
     
    414414    Frame frame = JOptionPane.getFrameForComponent(Main.parent);
    415415    DataSet mainDataSet = Main.main.getCurrentDataSet();
    416    
     416
    417417    if (jDialog == null)
    418418    {
     
    435435      tabbedPane.setEnabledAt(4, false);
    436436      jDialog.add(tabbedPane);
    437      
     437
    438438      //Overview Tab
    439439      Container contentPane = tabOverview;
     
    441441      GridBagConstraints layoutCons = new GridBagConstraints();
    442442      contentPane.setLayout(gridbag);
    443      
     443
    444444      JLabel headline = new JLabel("Existing route patterns:");
    445        
     445
    446446      layoutCons.gridx = 0;
    447447      layoutCons.gridy = 0;
     
    452452      gridbag.setConstraints(headline, layoutCons);
    453453      contentPane.add(headline);
    454        
     454
    455455      relsListModel = new DefaultListModel();
    456456      relsList = new JList(relsListModel);
     
    460460      relsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    461461      relsList.addListSelectionListener(new RoutesLSL(this));
    462      
     462
    463463      layoutCons.gridx = 0;
    464464      layoutCons.gridy = 1;
     
    469469      gridbag.setConstraints(rpListSP, layoutCons);
    470470      contentPane.add(rpListSP);
    471        
     471
    472472      JButton bRefresh = new JButton("Refresh");
    473473      bRefresh.setActionCommand("routePattern.refresh");
    474474      bRefresh.addActionListener(this);
    475        
     475
    476476      layoutCons.gridx = 0;
    477477      layoutCons.gridy = 2;
     
    483483      gridbag.setConstraints(bRefresh, layoutCons);
    484484      contentPane.add(bRefresh);
    485        
     485
    486486      JButton bNew = new JButton("New");
    487487      bNew.setActionCommand("routePattern.overviewNew");
    488488      bNew.addActionListener(this);
    489        
     489
    490490      layoutCons.gridx = 1;
    491491      layoutCons.gridy = 2;
     
    497497      gridbag.setConstraints(bNew, layoutCons);
    498498      contentPane.add(bNew);
    499        
     499
    500500      JButton bDelete = new JButton("Delete");
    501501      bDelete.setActionCommand("routePattern.overviewDelete");
    502502      bDelete.addActionListener(this);
    503        
     503
    504504      layoutCons.gridx = 1;
    505505      layoutCons.gridy = 3;
     
    511511      gridbag.setConstraints(bDelete, layoutCons);
    512512      contentPane.add(bDelete);
    513      
     513
    514514      JButton bDuplicate = new JButton("Duplicate");
    515515      bDuplicate.setActionCommand("routePattern.overviewDuplicate");
    516516      bDuplicate.addActionListener(this);
    517        
     517
    518518      layoutCons.gridx = 2;
    519519      layoutCons.gridy = 2;
     
    525525      gridbag.setConstraints(bDuplicate, layoutCons);
    526526      contentPane.add(bDuplicate);
    527        
     527
    528528      JButton bReflect = new JButton("Reflect");
    529529      bReflect.setActionCommand("routePattern.overviewReflect");
    530530      bReflect.addActionListener(this);
    531        
     531
    532532      layoutCons.gridx = 2;
    533533      layoutCons.gridy = 3;
     
    539539      gridbag.setConstraints(bReflect, layoutCons);
    540540      contentPane.add(bReflect);
    541      
     541
    542542      //Tags Tab
    543543      /*Container*/ contentPane = tabTags;
     
    545545      /*GridBagConstraints*/ layoutCons = new GridBagConstraints();
    546546      contentPane.setLayout(gridbag);
    547      
     547
    548548      /*JLabel*/ headline = new JLabel("Required tags:");
    549        
     549
    550550      layoutCons.gridx = 0;
    551551      layoutCons.gridy = 0;
     
    555555      gridbag.setConstraints(headline, layoutCons);
    556556      contentPane.add(headline);
    557        
     557
    558558      requiredTagsTable = new CustomCellEditorTable();
    559559      requiredTagsData = new TagTableModel(true);
     
    600600      JScrollPane tableSP = new JScrollPane(requiredTagsTable);
    601601      requiredTagsData.addTableModelListener(requiredTagsData);
    602      
     602
    603603      layoutCons.gridx = 0;
    604604      layoutCons.gridy = 1;
     
    611611      tableSP.setPreferredSize(preferredSize);
    612612      contentPane.add(tableSP);
    613        
     613
    614614      headline = new JLabel("Common tags:");
    615        
     615
    616616      layoutCons.gridx = 0;
    617617      layoutCons.gridy = 2;
     
    621621      gridbag.setConstraints(headline, layoutCons);
    622622      contentPane.add(headline);
    623      
     623
    624624      commonTagsTable = new CustomCellEditorTable();
    625625      commonTagsData = new TagTableModel(true);
     
    654654      /*JScrollPane*/ tableSP = new JScrollPane(commonTagsTable);
    655655      commonTagsData.addTableModelListener(commonTagsData);
    656      
     656
    657657      layoutCons.gridx = 0;
    658658      layoutCons.gridy = 3;
     
    665665      tableSP.setPreferredSize(preferredSize);
    666666      contentPane.add(tableSP);
    667        
     667
    668668      headline = new JLabel("Additional tags:");
    669        
     669
    670670      layoutCons.gridx = 0;
    671671      layoutCons.gridy = 4;
     
    675675      gridbag.setConstraints(headline, layoutCons);
    676676      contentPane.add(headline);
    677        
     677
    678678      otherTagsTable = new CustomCellEditorTable();
    679679      otherTagsData = new TagTableModel(false);
     
    683683      /*JScrollPane*/ tableSP = new JScrollPane(otherTagsTable);
    684684      otherTagsData.addTableModelListener(otherTagsData);
    685      
     685
    686686      layoutCons.gridx = 0;
    687687      layoutCons.gridy = 5;
     
    694694      tableSP.setPreferredSize(preferredSize);
    695695      contentPane.add(tableSP);
    696      
     696
    697697      JButton bAddTag = new JButton("Add a new Tag");
    698698      bAddTag.setActionCommand("routePattern.tagAddTag");
    699699      bAddTag.addActionListener(this);
    700      
     700
    701701      layoutCons.gridx = 0;
    702702      layoutCons.gridy = 6;
     
    707707      gridbag.setConstraints(bAddTag, layoutCons);
    708708      contentPane.add(bAddTag);
    709        
     709
    710710      //Itinerary Tab
    711711      contentPane = tabItinerary;
     
    713713      layoutCons = new GridBagConstraints();
    714714      contentPane.setLayout(gridbag);
    715      
     715
    716716      itineraryTable = new JTable();
    717717      itineraryData = new ItineraryTableModel();
     
    725725      comboBox.addItem("backward");
    726726      itineraryTable.getColumnModel().getColumn(1)
    727           .setCellEditor(new DefaultCellEditor(comboBox));
     727      .setCellEditor(new DefaultCellEditor(comboBox));
    728728      itineraryData.addTableModelListener(itineraryData);
    729      
     729
    730730      layoutCons.gridx = 0;
    731731      layoutCons.gridy = 0;
     
    736736      gridbag.setConstraints(tableSP, layoutCons);
    737737      contentPane.add(tableSP);
    738        
     738
    739739      JButton bFind = new JButton("Find");
    740740      bFind.setActionCommand("routePattern.itineraryFind");
    741741      bFind.addActionListener(this);
    742        
     742
    743743      layoutCons.gridx = 0;
    744744      layoutCons.gridy = 1;
     
    749749      gridbag.setConstraints(bFind, layoutCons);
    750750      contentPane.add(bFind);
    751      
     751
    752752      JButton bShow = new JButton("Show");
    753753      bShow.setActionCommand("routePattern.itineraryShow");
    754754      bShow.addActionListener(this);
    755        
     755
    756756      layoutCons.gridx = 0;
    757757      layoutCons.gridy = 2;
     
    762762      gridbag.setConstraints(bShow, layoutCons);
    763763      contentPane.add(bShow);
    764        
     764
    765765      JButton bMark = new JButton("Mark");
    766766      bMark.setActionCommand("routePattern.itineraryMark");
    767767      bMark.addActionListener(this);
    768        
     768
    769769      layoutCons.gridx = 1;
    770770      layoutCons.gridy = 1;
     
    776776      gridbag.setConstraints(bMark, layoutCons);
    777777      contentPane.add(bMark);
    778        
     778
    779779      JButton bAdd = new JButton("Add");
    780780      bAdd.setActionCommand("routePattern.itineraryAdd");
    781781      bAdd.addActionListener(this);
    782        
     782
    783783      layoutCons.gridx = 2;
    784784      layoutCons.gridy = 1;
     
    790790      gridbag.setConstraints(bAdd, layoutCons);
    791791      contentPane.add(bAdd);
    792        
     792
    793793      /*JButton*/ bDelete = new JButton("Delete");
    794794      bDelete.setActionCommand("routePattern.itineraryDelete");
    795795      bDelete.addActionListener(this);
    796        
     796
    797797      layoutCons.gridx = 2;
    798798      layoutCons.gridy = 2;
     
    803803      gridbag.setConstraints(bDelete, layoutCons);
    804804      contentPane.add(bDelete);
    805        
     805
    806806      JButton bSort = new JButton("Sort");
    807807      bSort.setActionCommand("routePattern.itinerarySort");
    808808      bSort.addActionListener(this);
    809        
     809
    810810      layoutCons.gridx = 3;
    811811      layoutCons.gridy = 1;
     
    816816      gridbag.setConstraints(bSort, layoutCons);
    817817      contentPane.add(bSort);
    818        
     818
    819819      /*JButton*/ bReflect = new JButton("Reflect");
    820820      bReflect.setActionCommand("routePattern.itineraryReflect");
    821821      bReflect.addActionListener(this);
    822      
     822
    823823      layoutCons.gridx = 3;
    824824      layoutCons.gridy = 2;
     
    829829      gridbag.setConstraints(bReflect, layoutCons);
    830830      contentPane.add(bReflect);
    831      
     831
    832832      //Stoplist Tab
    833833      contentPane = tabStoplist;
     
    835835      layoutCons = new GridBagConstraints();
    836836      contentPane.setLayout(gridbag);
    837      
     837
    838838      stoplistTable = new JTable();
    839839      stoplistData = new StoplistTableModel();
     
    847847      comboBox.addItem("backward_stop");
    848848      stoplistTable.getColumnModel().getColumn(1)
    849           .setCellEditor(new DefaultCellEditor(comboBox));
     849      .setCellEditor(new DefaultCellEditor(comboBox));
    850850      stoplistData.addTableModelListener(new StoplistTableModelListener());
    851      
     851
    852852      layoutCons.gridx = 0;
    853853      layoutCons.gridy = 0;
     
    858858      gridbag.setConstraints(tableSP, layoutCons);
    859859      contentPane.add(tableSP);
    860        
     860
    861861      /*JButton*/ bFind = new JButton("Find");
    862862      bFind.setActionCommand("routePattern.stoplistFind");
    863863      bFind.addActionListener(this);
    864        
     864
    865865      layoutCons.gridx = 0;
    866866      layoutCons.gridy = 1;
     
    871871      gridbag.setConstraints(bFind, layoutCons);
    872872      contentPane.add(bFind);
    873        
     873
    874874      /*JButton*/ bShow = new JButton("Show");
    875875      bShow.setActionCommand("routePattern.stoplistShow");
    876876      bShow.addActionListener(this);
    877        
     877
    878878      layoutCons.gridx = 0;
    879879      layoutCons.gridy = 2;
     
    884884      gridbag.setConstraints(bShow, layoutCons);
    885885      contentPane.add(bShow);
    886        
     886
    887887      /*JButton*/ bMark = new JButton("Mark");
    888888      bMark.setActionCommand("routePattern.stoplistMark");
    889889      bMark.addActionListener(this);
    890        
     890
    891891      layoutCons.gridx = 1;
    892892      layoutCons.gridy = 1;
     
    898898      gridbag.setConstraints(bMark, layoutCons);
    899899      contentPane.add(bMark);
    900        
     900
    901901      /*JButton*/ bAdd = new JButton("Add");
    902902      bAdd.setActionCommand("routePattern.stoplistAdd");
    903903      bAdd.addActionListener(this);
    904        
     904
    905905      layoutCons.gridx = 2;
    906906      layoutCons.gridy = 1;
     
    912912      gridbag.setConstraints(bAdd, layoutCons);
    913913      contentPane.add(bAdd);
    914        
     914
    915915      /*JButton*/ bDelete = new JButton("Delete");
    916916      bDelete.setActionCommand("routePattern.stoplistDelete");
    917917      bDelete.addActionListener(this);
    918        
     918
    919919      layoutCons.gridx = 2;
    920920      layoutCons.gridy = 2;
     
    925925      gridbag.setConstraints(bDelete, layoutCons);
    926926      contentPane.add(bDelete);
    927        
     927
    928928      /*JButton*/ bSort = new JButton("Sort");
    929929      bSort.setActionCommand("routePattern.stoplistSort");
    930930      bSort.addActionListener(this);
    931        
     931
    932932      layoutCons.gridx = 3;
    933933      layoutCons.gridy = 1;
     
    938938      gridbag.setConstraints(bSort, layoutCons);
    939939      contentPane.add(bSort);
    940        
     940
    941941      /*JButton*/ bReflect = new JButton("Reflect");
    942942      bReflect.setActionCommand("routePattern.stoplistReflect");
    943943      bReflect.addActionListener(this);
    944      
     944
    945945      layoutCons.gridx = 3;
    946946      layoutCons.gridy = 2;
     
    951951      gridbag.setConstraints(bReflect, layoutCons);
    952952      contentPane.add(bReflect);
    953      
     953
    954954      //Meta Tab
    955955      contentPane = tabMeta;
     
    957957      layoutCons = new GridBagConstraints();
    958958      contentPane.setLayout(gridbag);
    959      
     959
    960960      JLabel rightleft = new JLabel("Stops are possible on the");
    961      
     961
    962962      layoutCons.gridx = 0;
    963963      layoutCons.gridy = 1;
     
    968968      gridbag.setConstraints(rightleft, layoutCons);
    969969      contentPane.add(rightleft);
    970        
     970
    971971      cbRight = new JCheckBox("right hand side", true);
    972      
     972
    973973      layoutCons.gridx = 0;
    974974      layoutCons.gridy = 2;
     
    979979      gridbag.setConstraints(cbRight, layoutCons);
    980980      contentPane.add(cbRight);
    981        
     981
    982982      cbLeft = new JCheckBox("left hand side", false);
    983      
     983
    984984      layoutCons.gridx = 0;
    985985      layoutCons.gridy = 3;
     
    990990      gridbag.setConstraints(cbLeft, layoutCons);
    991991      contentPane.add(cbLeft);
    992      
     992
    993993      JLabel maxdist = new JLabel("Maximum distance from route");
    994      
     994
    995995      layoutCons.gridx = 0;
    996996      layoutCons.gridy = 4;
     
    10011001      gridbag.setConstraints(maxdist, layoutCons);
    10021002      contentPane.add(maxdist);
    1003      
     1003
    10041004      tfSuggestStopsLimit = new JTextField("20", 4);
    1005      
     1005
    10061006      layoutCons.gridx = 0;
    10071007      layoutCons.gridy = 5;
     
    10121012      gridbag.setConstraints(tfSuggestStopsLimit, layoutCons);
    10131013      contentPane.add(tfSuggestStopsLimit);
    1014      
     1014
    10151015      JLabel meters = new JLabel("meters");
    1016      
     1016
    10171017      layoutCons.gridx = 1;
    10181018      layoutCons.gridy = 5;
     
    10231023      gridbag.setConstraints(meters, layoutCons);
    10241024      contentPane.add(meters);
    1025      
     1025
    10261026      JButton bSuggestStops = new JButton("Suggest Stops");
    10271027      bSuggestStops.setActionCommand("routePattern.metaSuggestStops");
    10281028      bSuggestStops.addActionListener(this);
    1029        
     1029
    10301030      layoutCons.gridx = 0;
    10311031      layoutCons.gridy = 6;
     
    10361036      gridbag.setConstraints(bSuggestStops, layoutCons);
    10371037      contentPane.add(bSuggestStops);
    1038        
     1038
    10391039      jDialog.pack();
    10401040    }
    1041      
     1041
    10421042    if ("routePattern.refresh".equals(event.getActionCommand()))
    10431043    {
     
    10501050      currentRoute.put("route", "bus");
    10511051      mainDataSet.addPrimitive(currentRoute);
    1052      
     1052
    10531053      refreshData();
    1054      
     1054
    10551055      for (int i = 0; i < relsListModel.size(); ++i)
    10561056      {
    1057         if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
    1058           relsList.setSelectedIndex(i);
     1057    if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
     1058      relsList.setSelectedIndex(i);
    10591059      }
    10601060    }
     
    10651065      currentRoute.put("route", "bus");
    10661066      mainDataSet.addPrimitive(currentRoute);
    1067      
     1067
    10681068      refreshData();
    1069        
     1069
    10701070      for (int i = 0; i < relsListModel.size(); ++i)
    10711071      {
    1072         if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
    1073           relsList.setSelectedIndex(i);
     1072    if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
     1073      relsList.setSelectedIndex(i);
    10741074      }
    10751075    }
     
    10811081      currentRoute.put("from", tag_to);
    10821082      currentRoute.put("to", tag_from);
    1083      
     1083
    10841084      Vector< RelationMember > itemsToReflect = new Vector< RelationMember >();
    10851085      Vector< RelationMember > otherItems = new Vector< RelationMember >();
    10861086      int insPos = itineraryTable.getSelectedRow();
    1087      
     1087
    10881088      for (int i = 0; i < currentRoute.getMembersCount(); ++i)
    10891089      {
    1090         RelationMember item = currentRoute.getMember(i);
    1091        
    1092         if (item.isWay())
    1093         {
    1094           String role = item.getRole();
    1095           if ("backward".equals(role))
    1096             role = "forward";
    1097           else if ("forward".equals(role))
    1098             role = "backward";
    1099           else
    1100             role = "backward";
    1101          
    1102           itemsToReflect.add(new RelationMember(role, item.getWay()));
    1103         }
    1104         else if (item.isNode())
    1105           itemsToReflect.add(item);
    1106         else
    1107           otherItems.add(item);
    1108       }
    1109        
     1090    RelationMember item = currentRoute.getMember(i);
     1091
     1092    if (item.isWay())
     1093    {
     1094      String role = item.getRole();
     1095      if ("backward".equals(role))
     1096        role = "forward";
     1097      else if ("forward".equals(role))
     1098        role = "backward";
     1099      else
     1100        role = "backward";
     1101
     1102      itemsToReflect.add(new RelationMember(role, item.getWay()));
     1103    }
     1104    else if (item.isNode())
     1105      itemsToReflect.add(item);
     1106    else
     1107      otherItems.add(item);
     1108      }
     1109
    11101110      currentRoute.setMembers(null);
    11111111      for (int i = itemsToReflect.size()-1; i >= 0; --i)
    1112         currentRoute.addMember(itemsToReflect.elementAt(i));
     1112    currentRoute.addMember(itemsToReflect.elementAt(i));
    11131113      for (int i = 0; i < otherItems.size(); ++i)
    1114         currentRoute.addMember(otherItems.elementAt(i));
    1115      
     1114    currentRoute.addMember(otherItems.elementAt(i));
     1115
    11161116      refreshData();
    1117      
     1117
    11181118      for (int i = 0; i < relsListModel.size(); ++i)
    11191119      {
    1120         if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
    1121           relsList.setSelectedIndex(i);
     1120    if (currentRoute == ((RouteReference)relsListModel.elementAt(i)).route)
     1121      relsList.setSelectedIndex(i);
    11221122      }
    11231123    }
     
    11251125    {
    11261126      DeleteAction.deleteRelation(Main.main.getEditLayer(), currentRoute);
    1127      
     1127
    11281128      currentRoute = null;
    11291129      tabbedPane.setEnabledAt(1, false);
     
    11311131      tabbedPane.setEnabledAt(3, false);
    11321132      tabbedPane.setEnabledAt(4, false);
    1133      
     1133
    11341134      refreshData();
    11351135    }
     
    11441144    {
    11451145      if (mainDataSet == null)
    1146         return;
    1147      
     1146    return;
     1147
    11481148      itineraryTable.clearSelection();
    1149      
     1149
    11501150      for (int i = 0; i < itineraryData.getRowCount(); ++i)
    11511151      {
    1152         if ((itineraryData.ways.elementAt(i) != null) &&
    1153             (mainDataSet.isSelected(itineraryData.ways.elementAt(i))))
    1154             itineraryTable.addRowSelectionInterval(i, i);
     1152    if ((itineraryData.ways.elementAt(i) != null) &&
     1153        (mainDataSet.isSelected(itineraryData.ways.elementAt(i))))
     1154        itineraryTable.addRowSelectionInterval(i, i);
    11551155      }
    11561156    }
     
    11601160      if (itineraryTable.getSelectedRowCount() > 0)
    11611161      {
    1162         for (int i = 0; i < itineraryData.getRowCount(); ++i)
    1163         {
    1164           if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
    1165           {
    1166             itineraryData.ways.elementAt(i).visit(box);
    1167           }
    1168         }
     1162    for (int i = 0; i < itineraryData.getRowCount(); ++i)
     1163    {
     1164      if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
     1165      {
     1166        itineraryData.ways.elementAt(i).visit(box);
     1167      }
     1168    }
    11691169      }
    11701170      else
    11711171      {
    1172         for (int i = 0; i < itineraryData.getRowCount(); ++i)
    1173         {
    1174           if (itineraryData.ways.elementAt(i) != null)
    1175           {
    1176             itineraryData.ways.elementAt(i).visit(box);
    1177           }
    1178         }
     1172    for (int i = 0; i < itineraryData.getRowCount(); ++i)
     1173    {
     1174      if (itineraryData.ways.elementAt(i) != null)
     1175      {
     1176        itineraryData.ways.elementAt(i).visit(box);
     1177      }
     1178    }
    11791179      }
    11801180      if (box.getBounds() == null)
    1181         return;
     1181    return;
    11821182      box.enlargeBoundingBox();
    11831183      Main.map.mapView.recalculateCenterScale(box);
     
    11901190      if (itineraryTable.getSelectedRowCount() > 0)
    11911191      {
    1192         for (int i = 0; i < itineraryData.getRowCount(); ++i)
    1193         {
    1194           if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
    1195           {
    1196             mainDataSet.addSelected(itineraryData.ways.elementAt(i));
    1197            
    1198             RelationMember markedWay = new RelationMember
    1199                 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));
    1200             markedWays.addElement(markedWay);
    1201           }
    1202         }
     1192    for (int i = 0; i < itineraryData.getRowCount(); ++i)
     1193    {
     1194      if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
     1195      {
     1196        mainDataSet.addSelected(itineraryData.ways.elementAt(i));
     1197
     1198        RelationMember markedWay = new RelationMember
     1199        ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));
     1200        markedWays.addElement(markedWay);
     1201      }
     1202    }
    12031203      }
    12041204      else
    12051205      {
    1206         for (int i = 0; i < itineraryData.getRowCount(); ++i)
    1207         {
    1208           if (itineraryData.ways.elementAt(i) != null)
    1209           {
    1210             mainDataSet.addSelected(itineraryData.ways.elementAt(i));
    1211            
    1212             RelationMember markedWay = new RelationMember
    1213                 ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));
    1214             markedWays.addElement(markedWay);
    1215           }
    1216         }
     1206    for (int i = 0; i < itineraryData.getRowCount(); ++i)
     1207    {
     1208      if (itineraryData.ways.elementAt(i) != null)
     1209      {
     1210        mainDataSet.addSelected(itineraryData.ways.elementAt(i));
     1211
     1212        RelationMember markedWay = new RelationMember
     1213        ((String)(itineraryData.getValueAt(i, 1)), itineraryData.ways.elementAt(i));
     1214        markedWays.addElement(markedWay);
     1215      }
     1216    }
    12171217      }
    12181218    }
     
    12231223      TreeSet<Way> addedWays = new TreeSet<Way>();
    12241224      if (mainDataSet == null)
    1225         return;
    1226      
     1225    return;
     1226
    12271227      while (relIter.hasNext())
    12281228      {
    1229         RelationMember curMember = relIter.next();
    1230         if ((curMember.isWay()) && (mainDataSet.isSelected(curMember.getWay())))
    1231         {
    1232           itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    1233           if (insPos >= 0)
    1234             ++insPos;
    1235          
    1236           addedWays.add(curMember.getWay());
    1237         }
    1238       }
    1239      
     1229    RelationMember curMember = relIter.next();
     1230    if ((curMember.isWay()) && (mainDataSet.isSelected(curMember.getWay())))
     1231    {
     1232      itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
     1233      if (insPos >= 0)
     1234        ++insPos;
     1235
     1236      addedWays.add(curMember.getWay());
     1237    }
     1238      }
     1239
    12401240      Collection<Way> selectedWays = mainDataSet.getSelectedWays();
    12411241      Iterator<Way> wayIter = selectedWays.iterator();
    1242      
     1242
    12431243      while (wayIter.hasNext())
    12441244      {
    1245         Way curMember = wayIter.next();
    1246         if (!(addedWays.contains(curMember)))
    1247         {
    1248           itineraryData.insertRow(insPos, curMember, "");
    1249           if (insPos >= 0)
    1250             ++insPos;
    1251         }
    1252       }
    1253      
     1245    Way curMember = wayIter.next();
     1246    if (!(addedWays.contains(curMember)))
     1247    {
     1248      itineraryData.insertRow(insPos, curMember, "");
     1249      if (insPos >= 0)
     1250        ++insPos;
     1251    }
     1252      }
     1253
    12541254      if ((insPos > 0) && (insPos < itineraryData.getRowCount()))
    12551255      {
    1256         while ((insPos < itineraryData.getRowCount())
    1257                        && (itineraryData.ways.elementAt(insPos) == null))
    1258           ++insPos;
    1259         itineraryTable.removeRowSelectionInterval(0, itineraryData.getRowCount()-1);
    1260         if (insPos < itineraryData.getRowCount())
    1261           itineraryTable.addRowSelectionInterval(insPos, insPos);
     1256    while ((insPos < itineraryData.getRowCount())
     1257               && (itineraryData.ways.elementAt(insPos) == null))
     1258      ++insPos;
     1259    itineraryTable.removeRowSelectionInterval(0, itineraryData.getRowCount()-1);
     1260    if (insPos < itineraryData.getRowCount())
     1261      itineraryTable.addRowSelectionInterval(insPos, insPos);
    12621262      }
    12631263
     
    12691269      for (int i = itineraryData.getRowCount()-1; i >=0; --i)
    12701270      {
    1271         if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
    1272         {
    1273           itineraryData.ways.removeElementAt(i);
    1274           itineraryData.removeRow(i);
    1275         }
    1276       }
    1277    
     1271    if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
     1272    {
     1273      itineraryData.ways.removeElementAt(i);
     1274      itineraryData.removeRow(i);
     1275    }
     1276      }
     1277
    12781278      itineraryData.cleanupGaps();
    12791279      rebuildWays();
     
    12831283      TreeSet<Way> usedWays = new TreeSet<Way>();
    12841284      TreeMap<Node, LinkedList<RelationMember> > frontNodes =
    1285           new TreeMap<Node, LinkedList<RelationMember> >();
     1285      new TreeMap<Node, LinkedList<RelationMember> >();
    12861286      TreeMap<Node, LinkedList<RelationMember> > backNodes =
    1287           new TreeMap<Node, LinkedList<RelationMember> >();
     1287      new TreeMap<Node, LinkedList<RelationMember> >();
    12881288      Vector< LinkedList<RelationMember> > loops =
    1289           new Vector< LinkedList<RelationMember> >();
     1289      new Vector< LinkedList<RelationMember> >();
    12901290      int insPos = itineraryTable.getSelectedRow();
    1291      
     1291
    12921292      if (itineraryTable.getSelectedRowCount() > 0)
    12931293      {
    1294         for (int i = itineraryData.getRowCount()-1; i >=0; --i)
    1295         {
    1296           if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
    1297           {
    1298             if (!(usedWays.contains(itineraryData.ways.elementAt(i))))
    1299             {
    1300               addWayToSortingData
    1301                   (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);
    1302               usedWays.add(itineraryData.ways.elementAt(i));
    1303             }
    1304            
    1305             itineraryData.ways.removeElementAt(i);
    1306             itineraryData.removeRow(i);
    1307           }
    1308         }
     1294    for (int i = itineraryData.getRowCount()-1; i >=0; --i)
     1295    {
     1296      if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
     1297      {
     1298        if (!(usedWays.contains(itineraryData.ways.elementAt(i))))
     1299        {
     1300          addWayToSortingData
     1301          (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);
     1302          usedWays.add(itineraryData.ways.elementAt(i));
     1303        }
     1304
     1305        itineraryData.ways.removeElementAt(i);
     1306        itineraryData.removeRow(i);
     1307      }
     1308    }
    13091309      }
    13101310      else
    13111311      {
    1312         for (int i = itineraryData.getRowCount()-1; i >=0; --i)
    1313         {
    1314           if (itineraryData.ways.elementAt(i) != null)
    1315           {
    1316             if (!(usedWays.contains(itineraryData.ways.elementAt(i))))
    1317             {
    1318               addWayToSortingData
    1319                   (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);
    1320               usedWays.add(itineraryData.ways.elementAt(i));
    1321             }
    1322           }
    1323         }
    1324        
    1325         itineraryData.clear();
     1312    for (int i = itineraryData.getRowCount()-1; i >=0; --i)
     1313    {
     1314      if (itineraryData.ways.elementAt(i) != null)
     1315      {
     1316        if (!(usedWays.contains(itineraryData.ways.elementAt(i))))
     1317        {
     1318          addWayToSortingData
     1319          (itineraryData.ways.elementAt(i), frontNodes, backNodes, loops);
     1320          usedWays.add(itineraryData.ways.elementAt(i));
     1321        }
     1322      }
     1323    }
     1324
     1325    itineraryData.clear();
    13261326      }
    13271327
    13281328      Iterator< Map.Entry< Node, LinkedList<RelationMember> > > entryIter
    1329           = frontNodes.entrySet().iterator();
     1329      = frontNodes.entrySet().iterator();
    13301330      while (entryIter.hasNext())
    13311331      {
    1332         Iterator<RelationMember> relIter = entryIter.next().getValue().iterator();
    1333         while (relIter.hasNext())
    1334         {
    1335           RelationMember curMember = relIter.next();
    1336           itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    1337           if (insPos >= 0)
    1338             ++insPos;
    1339         }
    1340       }
    1341      
     1332    Iterator<RelationMember> relIter = entryIter.next().getValue().iterator();
     1333    while (relIter.hasNext())
     1334    {
     1335      RelationMember curMember = relIter.next();
     1336      itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
     1337      if (insPos >= 0)
     1338        ++insPos;
     1339    }
     1340      }
     1341
    13421342      Iterator< LinkedList<RelationMember> > listIter = loops.iterator();
    13431343      while (listIter.hasNext())
    13441344      {
    1345         Iterator<RelationMember> relIter = listIter.next().iterator();
    1346         while (relIter.hasNext())
    1347         {
    1348           RelationMember curMember = relIter.next();
    1349           itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    1350           if (insPos >= 0)
    1351             ++insPos;
    1352         }
    1353       }
    1354      
     1345    Iterator<RelationMember> relIter = listIter.next().iterator();
     1346    while (relIter.hasNext())
     1347    {
     1348      RelationMember curMember = relIter.next();
     1349      itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
     1350      if (insPos >= 0)
     1351        ++insPos;
     1352    }
     1353      }
     1354
    13551355      itineraryData.cleanupGaps();
    13561356      rebuildWays();
     
    13601360      Vector<RelationMember> itemsToReflect = new Vector<RelationMember>();
    13611361      int insPos = itineraryTable.getSelectedRow();
    1362      
     1362
    13631363      if (itineraryTable.getSelectedRowCount() > 0)
    13641364      {
    1365         for (int i = itineraryData.getRowCount()-1; i >=0; --i)
    1366         {
    1367           if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
    1368           {
    1369             String role = (String)(itineraryData.getValueAt(i, 1));
    1370             if ("backward".equals(role))
    1371               role = "forward";
    1372             else if ("forward".equals(role))
    1373               role = "backward";
    1374             else
    1375               role = "backward";
    1376             RelationMember markedWay = new RelationMember
    1377                 (role, itineraryData.ways.elementAt(i));
    1378             itemsToReflect.addElement(markedWay);
    1379            
    1380             itineraryData.ways.removeElementAt(i);
    1381             itineraryData.removeRow(i);
    1382           }
    1383         }
     1365    for (int i = itineraryData.getRowCount()-1; i >=0; --i)
     1366    {
     1367      if ((itineraryTable.isRowSelected(i)) && (itineraryData.ways.elementAt(i) != null))
     1368      {
     1369        String role = (String)(itineraryData.getValueAt(i, 1));
     1370        if ("backward".equals(role))
     1371          role = "forward";
     1372        else if ("forward".equals(role))
     1373          role = "backward";
     1374        else
     1375          role = "backward";
     1376        RelationMember markedWay = new RelationMember
     1377        (role, itineraryData.ways.elementAt(i));
     1378        itemsToReflect.addElement(markedWay);
     1379
     1380        itineraryData.ways.removeElementAt(i);
     1381        itineraryData.removeRow(i);
     1382      }
     1383    }
    13841384      }
    13851385      else
    13861386      {
    1387         for (int i = itineraryData.getRowCount()-1; i >=0; --i)
    1388         {
    1389           if (itineraryData.ways.elementAt(i) != null)
    1390           {
    1391             String role = (String)(itineraryData.getValueAt(i, 1));
    1392             if ("backward".equals(role))
    1393               role = "forward";
    1394             else if ("forward".equals(role))
    1395               role = "backward";
    1396             else
    1397               role = "backward";
    1398             RelationMember markedWay = new RelationMember
    1399                 (role, itineraryData.ways.elementAt(i));
    1400             itemsToReflect.addElement(markedWay);
    1401           }
    1402         }
    1403        
    1404         itineraryData.clear();
     1387    for (int i = itineraryData.getRowCount()-1; i >=0; --i)
     1388    {
     1389      if (itineraryData.ways.elementAt(i) != null)
     1390      {
     1391        String role = (String)(itineraryData.getValueAt(i, 1));
     1392        if ("backward".equals(role))
     1393          role = "forward";
     1394        else if ("forward".equals(role))
     1395          role = "backward";
     1396        else
     1397          role = "backward";
     1398        RelationMember markedWay = new RelationMember
     1399        (role, itineraryData.ways.elementAt(i));
     1400        itemsToReflect.addElement(markedWay);
     1401      }
     1402    }
     1403
     1404    itineraryData.clear();
    14051405      }
    14061406
     
    14091409      while (relIter.hasNext())
    14101410      {
    1411         RelationMember curMember = relIter.next();
    1412         if (curMember.isWay())
    1413         {
    1414           itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    1415           if (insPos >= 0)
    1416             ++insPos;
    1417         }
    1418       }
     1411    RelationMember curMember = relIter.next();
     1412    if (curMember.isWay())
     1413    {
     1414      itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    14191415      if (insPos >= 0)
    1420         itineraryTable.addRowSelectionInterval(startPos, insPos-1);
    1421      
     1416        ++insPos;
     1417    }
     1418      }
     1419      if (insPos >= 0)
     1420    itineraryTable.addRowSelectionInterval(startPos, insPos-1);
     1421
    14221422      itineraryData.cleanupGaps();
    14231423      rebuildWays();
     
    14261426    {
    14271427      if (mainDataSet == null)
    1428         return;
    1429      
     1428    return;
     1429
    14301430      stoplistTable.clearSelection();
    1431      
     1431
    14321432      for (int i = 0; i < stoplistData.getRowCount(); ++i)
    14331433      {
    1434         if ((stoplistData.nodes.elementAt(i) != null) &&
    1435               (mainDataSet.isSelected(stoplistData.nodes.elementAt(i))))
    1436           stoplistTable.addRowSelectionInterval(i, i);
     1434    if ((stoplistData.nodes.elementAt(i) != null) &&
     1435          (mainDataSet.isSelected(stoplistData.nodes.elementAt(i))))
     1436      stoplistTable.addRowSelectionInterval(i, i);
    14371437      }
    14381438    }
     
    14421442      if (stoplistTable.getSelectedRowCount() > 0)
    14431443      {
    1444         for (int i = 0; i < stoplistData.getRowCount(); ++i)
    1445         {
    1446           if (stoplistTable.isRowSelected(i))
    1447           {
    1448             stoplistData.nodes.elementAt(i).visit(box);
    1449           }
    1450         }
     1444    for (int i = 0; i < stoplistData.getRowCount(); ++i)
     1445    {
     1446      if (stoplistTable.isRowSelected(i))
     1447      {
     1448        stoplistData.nodes.elementAt(i).visit(box);
     1449      }
     1450    }
    14511451      }
    14521452      else
    14531453      {
    1454         for (int i = 0; i < stoplistData.getRowCount(); ++i)
    1455         {
    1456           stoplistData.nodes.elementAt(i).visit(box);
    1457         }
     1454    for (int i = 0; i < stoplistData.getRowCount(); ++i)
     1455    {
     1456      stoplistData.nodes.elementAt(i).visit(box);
     1457    }
    14581458      }
    14591459      if (box.getBounds() == null)
    1460         return;
     1460    return;
    14611461      box.enlargeBoundingBox();
    14621462      Main.map.mapView.recalculateCenterScale(box);
     
    14691469      if (stoplistTable.getSelectedRowCount() > 0)
    14701470      {
    1471         for (int i = 0; i < stoplistData.getRowCount(); ++i)
    1472         {
    1473           if (stoplistTable.isRowSelected(i))
    1474           {
    1475             mainDataSet.addSelected(stoplistData.nodes.elementAt(i));
    1476            
    1477             RelationMember markedNode = new RelationMember
    1478                 ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));
    1479             markedNodes.addElement(markedNode);
    1480           }
    1481         }
     1471    for (int i = 0; i < stoplistData.getRowCount(); ++i)
     1472    {
     1473      if (stoplistTable.isRowSelected(i))
     1474      {
     1475        mainDataSet.addSelected(stoplistData.nodes.elementAt(i));
     1476
     1477        RelationMember markedNode = new RelationMember
     1478        ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));
     1479        markedNodes.addElement(markedNode);
     1480      }
     1481    }
    14821482      }
    14831483      else
    14841484      {
    1485         for (int i = 0; i < stoplistData.getRowCount(); ++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         }
     1485    for (int i = 0; i < stoplistData.getRowCount(); ++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    }
    14931493      }
    14941494    }
     
    14991499      TreeSet<Node> addedNodes = new TreeSet<Node>();
    15001500      if (mainDataSet == null)
    1501         return;
    1502      
     1501    return;
     1502
    15031503      while (relIter.hasNext())
    15041504      {
    1505         RelationMember curMember = relIter.next();
    1506         if ((curMember.isNode()) && (mainDataSet.isSelected(curMember.getNode())))
    1507         {
    1508           stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
    1509           if (insPos >= 0)
    1510             ++insPos;
    1511          
    1512           addedNodes.add(curMember.getNode());
    1513         }
    1514       }
    1515      
     1505    RelationMember curMember = relIter.next();
     1506    if ((curMember.isNode()) && (mainDataSet.isSelected(curMember.getNode())))
     1507    {
     1508      stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
     1509      if (insPos >= 0)
     1510        ++insPos;
     1511
     1512      addedNodes.add(curMember.getNode());
     1513    }
     1514      }
     1515
    15161516      Collection<Node> selectedNodes = mainDataSet.getSelectedNodes();
    15171517      Iterator<Node> nodeIter = selectedNodes.iterator();
    1518      
     1518
    15191519      while (nodeIter.hasNext())
    15201520      {
    1521         Node curMember = nodeIter.next();
    1522         if (!(addedNodes.contains(curMember)))
    1523         {
    1524           stoplistData.insertRow(insPos, curMember, "");
    1525           if (insPos >= 0)
    1526             ++insPos;
    1527         }
    1528       }
    1529      
     1521    Node curMember = nodeIter.next();
     1522    if (!(addedNodes.contains(curMember)))
     1523    {
     1524      stoplistData.insertRow(insPos, curMember, "");
     1525      if (insPos >= 0)
     1526        ++insPos;
     1527    }
     1528      }
     1529
    15301530      if ((insPos > 0) && (insPos < stoplistData.getRowCount()))
    15311531      {
    1532         while ((insPos < stoplistData.getRowCount())
    1533                        && (stoplistData.nodes.elementAt(insPos) == null))
    1534           ++insPos;
    1535         stoplistTable.removeRowSelectionInterval(0, stoplistData.getRowCount()-1);
    1536         if (insPos < stoplistData.getRowCount())
    1537           stoplistTable.addRowSelectionInterval(insPos, insPos);
     1532    while ((insPos < stoplistData.getRowCount())
     1533               && (stoplistData.nodes.elementAt(insPos) == null))
     1534      ++insPos;
     1535    stoplistTable.removeRowSelectionInterval(0, stoplistData.getRowCount()-1);
     1536    if (insPos < stoplistData.getRowCount())
     1537      stoplistTable.addRowSelectionInterval(insPos, insPos);
    15381538      }
    15391539
     
    15441544      for (int i = stoplistData.getRowCount()-1; i >=0; --i)
    15451545      {
    1546         if (stoplistTable.isRowSelected(i))
    1547         {
    1548           stoplistData.nodes.removeElementAt(i);
    1549           stoplistData.removeRow(i);
    1550         }
    1551       }
    1552    
     1546    if (stoplistTable.isRowSelected(i))
     1547    {
     1548      stoplistData.nodes.removeElementAt(i);
     1549      stoplistData.removeRow(i);
     1550    }
     1551      }
     1552
    15531553      rebuildNodes();
    15541554    }
     
    15601560      for (int i = 0; i < itineraryData.getRowCount(); ++i)
    15611561      {
    1562         if (itineraryData.ways.elementAt(i) != null)
    1563         {
    1564           Way way = itineraryData.ways.elementAt(i);
    1565           if (!(way.isIncomplete()))
    1566           {
    1567             if ("backward".equals((String)(itineraryData.getValueAt(i, 1))))
    1568             {
    1569               for (int j = way.getNodesCount()-2; j >= 0; --j)
    1570               {
    1571                 SegmentMetric sm = new SegmentMetric
    1572                     (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(),
    1573                      way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon());
    1574                 segmentMetrics.add(sm);
    1575               }
    1576             }
    1577             else
    1578             {
    1579               for (int j = 0; j < way.getNodesCount()-1; ++j)
    1580               {
    1581                 SegmentMetric sm = new SegmentMetric
    1582                     (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
    1583                      way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon());
    1584                 segmentMetrics.add(sm);
    1585               }
    1586             }
    1587           }
    1588         }
    1589         else
    1590         {
    1591           segmentMetrics.add(null);
    1592         }
    1593       }
    1594      
     1562    if (itineraryData.ways.elementAt(i) != null)
     1563    {
     1564      Way way = itineraryData.ways.elementAt(i);
     1565      if (!(way.isIncomplete()))
     1566      {
     1567        if ("backward".equals((String)(itineraryData.getValueAt(i, 1))))
     1568        {
     1569          for (int j = way.getNodesCount()-2; j >= 0; --j)
     1570          {
     1571        SegmentMetric sm = new SegmentMetric
     1572            (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(),
     1573             way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon());
     1574        segmentMetrics.add(sm);
     1575          }
     1576        }
     1577        else
     1578        {
     1579          for (int j = 0; j < way.getNodesCount()-1; ++j)
     1580          {
     1581        SegmentMetric sm = new SegmentMetric
     1582            (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
     1583             way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon());
     1584        segmentMetrics.add(sm);
     1585          }
     1586        }
     1587      }
     1588    }
     1589    else
     1590    {
     1591      segmentMetrics.add(null);
     1592    }
     1593      }
     1594
    15951595      Vector< StopReference > srm = new Vector< StopReference >();
    15961596      int insPos = stoplistTable.getSelectedRow();
     
    15991599        // Determine for each member its position on the itinerary: position means here the
    16001600        // point on the itinerary that has minimal distance to the coor
    1601         for (int i = stoplistData.getRowCount()-1; i >= 0; --i)
    1602         {
    1603           if (stoplistTable.isRowSelected(i))
    1604           {
    1605             StopReference sr = detectMinDistance
    1606                 (stoplistData.nodes.elementAt(i), segmentMetrics,
    1607                 cbRight.isSelected(), cbLeft.isSelected());
    1608             if (sr != null)
    1609             {
    1610               if (sr.distance <
    1611                         Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 )
    1612               {
    1613                 sr.role = (String)stoplistData.getValueAt(i, 1);
    1614                 srm.addElement(sr);
    1615               }
    1616               else
    1617               {
    1618                 sr.role = (String)stoplistData.getValueAt(i, 1);
    1619                 sr.index = segmentMetrics.size()*2;
    1620                 sr.pos = 0;
    1621                 srm.addElement(sr);
    1622               }
    1623              
    1624               stoplistData.nodes.removeElementAt(i);
    1625               stoplistData.removeRow(i);
    1626             }
    1627          
    1628           }
    1629         }
     1601    for (int i = stoplistData.getRowCount()-1; i >= 0; --i)
     1602    {
     1603      if (stoplistTable.isRowSelected(i))
     1604      {
     1605        StopReference sr = detectMinDistance
     1606        (stoplistData.nodes.elementAt(i), segmentMetrics,
     1607        cbRight.isSelected(), cbLeft.isSelected());
     1608        if (sr != null)
     1609        {
     1610          if (sr.distance <
     1611            Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 )
     1612          {
     1613        sr.role = (String)stoplistData.getValueAt(i, 1);
     1614        srm.addElement(sr);
     1615          }
     1616          else
     1617          {
     1618        sr.role = (String)stoplistData.getValueAt(i, 1);
     1619        sr.index = segmentMetrics.size()*2;
     1620        sr.pos = 0;
     1621        srm.addElement(sr);
     1622          }
     1623
     1624          stoplistData.nodes.removeElementAt(i);
     1625          stoplistData.removeRow(i);
     1626        }
     1627
     1628      }
     1629    }
    16301630      }
    16311631      else
    16321632      {
    1633         // Determine for each member its position on the itinerary: position means here the
     1633    // Determine for each member its position on the itinerary: position means here the
    16341634        // point on the itinerary that has minimal distance to the coor
    1635         for (int i = stoplistData.getRowCount()-1; i >= 0; --i)
    1636         {
    1637           StopReference sr = detectMinDistance
    1638               (stoplistData.nodes.elementAt(i), segmentMetrics,
    1639                cbRight.isSelected(), cbLeft.isSelected());
    1640           if (sr != null)
    1641           {
    1642             if (sr.distance <
    1643                        Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 )
    1644             {
    1645               sr.role = (String)stoplistData.getValueAt(i, 1);
    1646               srm.addElement(sr);
    1647             }
    1648             else
    1649             {
    1650               sr.role = (String)stoplistData.getValueAt(i, 1);
    1651               sr.index = segmentMetrics.size()*2;
    1652               sr.pos = 0;
    1653               srm.addElement(sr);
    1654             }
    1655           }
    1656         }
    1657      
    1658         stoplistData.clear();
     1635    for (int i = stoplistData.getRowCount()-1; i >= 0; --i)
     1636    {
     1637      StopReference sr = detectMinDistance
     1638          (stoplistData.nodes.elementAt(i), segmentMetrics,
     1639           cbRight.isSelected(), cbLeft.isSelected());
     1640      if (sr != null)
     1641      {
     1642        if (sr.distance <
     1643               Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 )
     1644        {
     1645          sr.role = (String)stoplistData.getValueAt(i, 1);
     1646          srm.addElement(sr);
     1647        }
     1648        else
     1649        {
     1650          sr.role = (String)stoplistData.getValueAt(i, 1);
     1651          sr.index = segmentMetrics.size()*2;
     1652          sr.pos = 0;
     1653          srm.addElement(sr);
     1654        }
     1655      }
     1656    }
     1657
     1658    stoplistData.clear();
    16591659      }
    16601660
    16611661      Collections.sort(srm);
    1662      
     1662
    16631663      for (int i = 0; i < srm.size(); ++i)
    16641664      {
    1665         stoplistData.insertRow(insPos, srm.elementAt(i).node, srm.elementAt(i).role);
    1666         if (insPos >= 0)
    1667           ++insPos;
    1668       }
    1669      
     1665    stoplistData.insertRow(insPos, srm.elementAt(i).node, srm.elementAt(i).role);
     1666    if (insPos >= 0)
     1667      ++insPos;
     1668      }
     1669
    16701670      rebuildNodes();
    16711671    }
     
    16741674      Vector<RelationMember> itemsToReflect = new Vector<RelationMember>();
    16751675      int insPos = stoplistTable.getSelectedRow();
    1676      
     1676
    16771677      if (stoplistTable.getSelectedRowCount() > 0)
    16781678      {
    1679         for (int i = stoplistData.getRowCount()-1; i >=0; --i)
    1680         {
    1681           if (stoplistTable.isRowSelected(i))
    1682           {
    1683             String role = (String)(stoplistData.getValueAt(i, 1));
    1684             RelationMember markedNode = new RelationMember
    1685                 (role, stoplistData.nodes.elementAt(i));
    1686             itemsToReflect.addElement(markedNode);
    1687            
    1688             stoplistData.nodes.removeElementAt(i);
    1689             stoplistData.removeRow(i);
    1690           }
    1691         }
     1679    for (int i = stoplistData.getRowCount()-1; i >=0; --i)
     1680    {
     1681      if (stoplistTable.isRowSelected(i))
     1682      {
     1683        String role = (String)(stoplistData.getValueAt(i, 1));
     1684        RelationMember markedNode = new RelationMember
     1685        (role, stoplistData.nodes.elementAt(i));
     1686        itemsToReflect.addElement(markedNode);
     1687
     1688        stoplistData.nodes.removeElementAt(i);
     1689        stoplistData.removeRow(i);
     1690      }
     1691    }
    16921692      }
    16931693      else
    16941694      {
    1695         for (int i = stoplistData.getRowCount()-1; i >=0; --i)
    1696         {
    1697           String role = (String)(stoplistData.getValueAt(i, 1));
    1698           RelationMember markedNode = new RelationMember
    1699               (role, stoplistData.nodes.elementAt(i));
    1700           itemsToReflect.addElement(markedNode);
    1701         }
    1702        
    1703         stoplistData.clear();
     1695    for (int i = stoplistData.getRowCount()-1; i >=0; --i)
     1696    {
     1697      String role = (String)(stoplistData.getValueAt(i, 1));
     1698      RelationMember markedNode = new RelationMember
     1699          (role, stoplistData.nodes.elementAt(i));
     1700      itemsToReflect.addElement(markedNode);
     1701    }
     1702
     1703    stoplistData.clear();
    17041704      }
    17051705
     
    17081708      while (relIter.hasNext())
    17091709      {
    1710         RelationMember curMember = relIter.next();
    1711         if (curMember.isNode())
    1712         {
    1713           stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
    1714           if (insPos >= 0)
    1715             ++insPos;
    1716         }
    1717       }
     1710    RelationMember curMember = relIter.next();
     1711    if (curMember.isNode())
     1712    {
     1713      stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
    17181714      if (insPos >= 0)
    1719         stoplistTable.addRowSelectionInterval(startPos, insPos-1);
    1720      
     1715        ++insPos;
     1716    }
     1717      }
     1718      if (insPos >= 0)
     1719    stoplistTable.addRowSelectionInterval(startPos, insPos-1);
     1720
    17211721      rebuildNodes();
    17221722    }
     
    17281728      for (int i = 0; i < itineraryData.getRowCount(); ++i)
    17291729      {
    1730         if (itineraryData.ways.elementAt(i) != null)
    1731         {
    1732           Way way = itineraryData.ways.elementAt(i);
    1733           if (!(way.isIncomplete()))
    1734           {
    1735             if ("backward".equals((String)(itineraryData.getValueAt(i, 1))))
    1736             {
    1737               for (int j = way.getNodesCount()-2; j >= 0; --j)
    1738               {
    1739                 SegmentMetric sm = new SegmentMetric
    1740                     (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(),
    1741                      way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon());
    1742                 segmentMetrics.add(sm);
    1743               }
    1744             }
    1745             else
    1746             {
    1747               for (int j = 0; j < way.getNodesCount()-1; ++j)
    1748               {
    1749                 SegmentMetric sm = new SegmentMetric
    1750                     (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
    1751                      way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon());
    1752                 segmentMetrics.add(sm);
    1753               }
    1754             }
    1755           }
    1756         }
    1757         else
    1758         {
    1759           segmentMetrics.add(null);
    1760         }
    1761       }
    1762      
     1730    if (itineraryData.ways.elementAt(i) != null)
     1731    {
     1732      Way way = itineraryData.ways.elementAt(i);
     1733      if (!(way.isIncomplete()))
     1734      {
     1735        if ("backward".equals((String)(itineraryData.getValueAt(i, 1))))
     1736        {
     1737          for (int j = way.getNodesCount()-2; j >= 0; --j)
     1738          {
     1739        SegmentMetric sm = new SegmentMetric
     1740            (way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon(),
     1741             way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon());
     1742        segmentMetrics.add(sm);
     1743          }
     1744        }
     1745        else
     1746        {
     1747          for (int j = 0; j < way.getNodesCount()-1; ++j)
     1748          {
     1749        SegmentMetric sm = new SegmentMetric
     1750            (way.getNode(j).getCoor().lat(), way.getNode(j).getCoor().lon(),
     1751             way.getNode(j+1).getCoor().lat(), way.getNode(j+1).getCoor().lon());
     1752        segmentMetrics.add(sm);
     1753          }
     1754        }
     1755      }
     1756    }
     1757    else
     1758    {
     1759      segmentMetrics.add(null);
     1760    }
     1761      }
     1762
    17631763      Vector< StopReference > srm = new Vector< StopReference >();
    17641764      // Determine for each member its position on the itinerary: position means here the
     
    17671767      if (mainDataSet != null)
    17681768      {
    1769         String stopKey = "";
    1770         String stopValue = "";
    1771         if ("bus".equals(currentRoute.get("route")))
    1772         {
    1773           stopKey = "highway";
    1774           stopValue = "bus_stop";
    1775         }
    1776         else if ("trolleybus".equals(currentRoute.get("route")))
    1777         {
    1778           stopKey = "highway";
    1779           stopValue = "bus_stop";
    1780         }
    1781         else if ("tram".equals(currentRoute.get("route")))
    1782         {
    1783           stopKey = "railway";
    1784           stopValue = "tram_stop";
    1785         }
    1786         else if ("light_rail".equals(currentRoute.get("route")))
    1787         {
    1788           stopKey = "railway";
    1789           stopValue = "station";
    1790         }
    1791         else if ("subway".equals(currentRoute.get("route")))
    1792         {
    1793           stopKey = "railway";
    1794           stopValue = "station";
    1795         }
    1796         else if ("rail".equals(currentRoute.get("route")))
    1797         {
    1798           stopKey = "railway";
    1799           stopValue = "station";
    1800         }
    1801 
    1802         Collection< Node > nodeCollection = mainDataSet.getNodes();
    1803         Iterator< Node > nodeIter = nodeCollection.iterator();
    1804         while (nodeIter.hasNext())
    1805         {
    1806           Node currentNode = nodeIter.next();
    1807           if (!currentNode.isUsable())
    1808             continue;
    1809           if (stopValue.equals(currentNode.get(stopKey)))
    1810           {
    1811             StopReference sr = detectMinDistance
    1812                 (currentNode, segmentMetrics,
    1813                 cbRight.isSelected(), cbLeft.isSelected());
    1814             if ((sr != null) && (sr.distance < 
    1815                         Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ))
    1816               srm.addElement(sr);
    1817           }
    1818         }
     1769    String stopKey = "";
     1770    String stopValue = "";
     1771    if ("bus".equals(currentRoute.get("route")))
     1772    {
     1773      stopKey = "highway";
     1774      stopValue = "bus_stop";
     1775    }
     1776    else if ("trolleybus".equals(currentRoute.get("route")))
     1777    {
     1778      stopKey = "highway";
     1779      stopValue = "bus_stop";
     1780    }
     1781    else if ("tram".equals(currentRoute.get("route")))
     1782    {
     1783      stopKey = "railway";
     1784      stopValue = "tram_stop";
     1785    }
     1786    else if ("light_rail".equals(currentRoute.get("route")))
     1787    {
     1788      stopKey = "railway";
     1789      stopValue = "station";
     1790    }
     1791    else if ("subway".equals(currentRoute.get("route")))
     1792    {
     1793      stopKey = "railway";
     1794      stopValue = "station";
     1795    }
     1796    else if ("rail".equals(currentRoute.get("route")))
     1797    {
     1798      stopKey = "railway";
     1799      stopValue = "station";
     1800    }
     1801
     1802    Collection< Node > nodeCollection = mainDataSet.getNodes();
     1803    Iterator< Node > nodeIter = nodeCollection.iterator();
     1804    while (nodeIter.hasNext())
     1805    {
     1806      Node currentNode = nodeIter.next();
     1807      if (!currentNode.isUsable())
     1808        continue;
     1809      if (stopValue.equals(currentNode.get(stopKey)))
     1810      {
     1811        StopReference sr = detectMinDistance
     1812        (currentNode, segmentMetrics,
     1813        cbRight.isSelected(), cbLeft.isSelected());
     1814        if ((sr != null) && (sr.distance <
     1815            Double.parseDouble(tfSuggestStopsLimit.getText()) * 9.0 / 1000000.0 ))
     1816          srm.addElement(sr);
     1817      }
     1818    }
    18191819      }
    18201820      else
    18211821      {
    1822         JOptionPane.showMessageDialog(null, "There exists no dataset."
    1823             + " Try to download data from the server or open an OSM file.",
     1822    JOptionPane.showMessageDialog(null, "There exists no dataset."
     1823        + " Try to download data from the server or open an OSM file.",
    18241824     "No data found", JOptionPane.ERROR_MESSAGE);
    1825      
    1826         System.out.println("Public Transport: RoutePattern: No data found");
    1827       }
    1828      
     1825
     1826    System.out.println("Public Transport: RoutePattern: No data found");
     1827      }
     1828
    18291829      for (int i = 0; i < stoplistData.getRowCount(); ++i)
    18301830      {
     
    18321832
    18331833      Collections.sort(srm);
    1834      
     1834
    18351835      stoplistData.clear();
    18361836      for (int i = 0; i < srm.size(); ++i)
    18371837      {
    1838         stoplistData.addRow(srm.elementAt(i).node, srm.elementAt(i).role);
    1839       }
    1840      
     1838    stoplistData.addRow(srm.elementAt(i).node, srm.elementAt(i).role);
     1839      }
     1840
    18411841      rebuildNodes();
    18421842    }
     
    18441844    {
    18451845      refreshData();
    1846      
     1846
    18471847      jDialog.setLocationRelativeTo(frame);
    18481848      jDialog.setVisible(true);
    18491849    }
    18501850  }
    1851  
     1851
    18521852  private void refreshData() {
    18531853    Relation copy = currentRoute;
    18541854    relsListModel.clear();
    18551855    currentRoute = copy;
    1856        
     1856
    18571857    DataSet mainDataSet = Main.main.getCurrentDataSet();
    18581858    if (mainDataSet != null)
     
    18611861      Collection< Relation > relCollection = mainDataSet.getRelations();
    18621862      Iterator< Relation > relIter = relCollection.iterator();
    1863      
     1863
    18641864      while (relIter.hasNext())
    18651865      {
    1866         Relation currentRel = relIter.next();
    1867         if (!currentRel.isDeleted())
    1868         {
    1869           String routeVal = currentRel.get("route");
    1870           if ("bus".equals(routeVal))
    1871             relRefs.add(new RouteReference(currentRel));
    1872           else if ("trolleybus".equals(routeVal))
    1873             relRefs.add(new RouteReference(currentRel));
    1874           else if ("tram".equals(routeVal))
    1875             relRefs.add(new RouteReference(currentRel));
    1876           else if ("light_rail".equals(routeVal))
    1877             relRefs.add(new RouteReference(currentRel));
    1878           else if ("subway".equals(routeVal))
    1879             relRefs.add(new RouteReference(currentRel));
    1880           else if ("rail".equals(routeVal))
    1881             relRefs.add(new RouteReference(currentRel));
    1882         }
    1883       }
    1884      
     1866    Relation currentRel = relIter.next();
     1867    if (!currentRel.isDeleted())
     1868    {
     1869      String routeVal = currentRel.get("route");
     1870      if ("bus".equals(routeVal))
     1871        relRefs.add(new RouteReference(currentRel));
     1872      else if ("trolleybus".equals(routeVal))
     1873        relRefs.add(new RouteReference(currentRel));
     1874      else if ("tram".equals(routeVal))
     1875        relRefs.add(new RouteReference(currentRel));
     1876      else if ("light_rail".equals(routeVal))
     1877        relRefs.add(new RouteReference(currentRel));
     1878      else if ("subway".equals(routeVal))
     1879        relRefs.add(new RouteReference(currentRel));
     1880      else if ("rail".equals(routeVal))
     1881        relRefs.add(new RouteReference(currentRel));
     1882    }
     1883      }
     1884
    18851885      Collections.sort(relRefs);
    18861886
    18871887      Iterator< RouteReference > iter = relRefs.iterator();
    18881888      while (iter.hasNext())
    1889         relsListModel.addElement(iter.next());
     1889    relsListModel.addElement(iter.next());
    18901890    }
    18911891    else
    18921892    {
    18931893      JOptionPane.showMessageDialog(null, "There exists no dataset."
    1894           + " Try to download data from the server or open an OSM file.",
     1894      + " Try to download data from the server or open an OSM file.",
    18951895   "No data found", JOptionPane.ERROR_MESSAGE);
    1896      
     1896
    18971897      System.out.println("Public Transport: No data found");
    18981898    }
    18991899  }
    1900  
     1900
    19011901  //Rebuild ways in the relation currentRoute
    19021902  public static void rebuildWays() {
     
    19071907    {
    19081908      if (iter.next().isWay())
    1909         iter.remove();
     1909    iter.remove();
    19101910    }
    19111911    for (int i = 0; i < itineraryData.getRowCount(); ++i)
     
    19131913      if (itineraryData.ways.elementAt(i) != null)
    19141914      {
    1915         RelationMember member = new RelationMember
    1916             ((String)(itineraryData.getValueAt(i, 1)),
    1917              itineraryData.ways.elementAt(i));
    1918         members.add(member);
     1915    RelationMember member = new RelationMember
     1916        ((String)(itineraryData.getValueAt(i, 1)),
     1917         itineraryData.ways.elementAt(i));
     1918    members.add(member);
    19191919      }
    19201920    }
    19211921    currentRoute.setMembers(members);
    19221922  }
    1923  
     1923
    19241924  //Rebuild nodes in the relation currentRoute
    19251925  private void rebuildNodes() {
     
    19291929      if (currentRoute.getMember(i).isNode())
    19301930      {
    1931         currentRoute.removeMember(i);
     1931    currentRoute.removeMember(i);
    19321932      }
    19331933    }
     
    19351935    {
    19361936      RelationMember member = new RelationMember
    1937           ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));
     1937      ((String)(stoplistData.getValueAt(i, 1)), stoplistData.nodes.elementAt(i));
    19381938      currentRoute.addMember(member);
    19391939    }
    19401940  }
    1941  
     1941
    19421942  private void addWayToSortingData
    19431943      (Way way, TreeMap<Node, LinkedList<RelationMember> > frontNodes,
     
    19471947    if (way.getNodesCount() < 1)
    19481948      return;
    1949    
     1949
    19501950    Node firstNode = way.getNode(0);
    19511951    Node lastNode = way.getNode(way.getNodesCount() - 1);
    1952    
     1952
    19531953    if (frontNodes.get(firstNode) != null)
    19541954    {
     
    19561956      list.addFirst(new RelationMember("backward", way));
    19571957      frontNodes.remove(firstNode);
    1958      
     1958
    19591959      Node lastListNode = null;
    19601960      if ("backward".equals(list.getLast().getRole()))
    1961         lastListNode = list.getLast().getWay().getNode(0);
     1961    lastListNode = list.getLast().getWay().getNode(0);
    19621962      else
    1963         lastListNode = list.getLast().getWay().getNode
    1964             (list.getLast().getWay().getNodesCount() - 1);
     1963    lastListNode = list.getLast().getWay().getNode
     1964        (list.getLast().getWay().getNodesCount() - 1);
    19651965      if (lastNode.equals(lastListNode))
    19661966      {
    1967         backNodes.remove(lastListNode);
    1968         loops.add(list);
     1967    backNodes.remove(lastListNode);
     1968    loops.add(list);
    19691969      }
    19701970      else if (frontNodes.get(lastNode) != null)
    19711971      {
    1972         backNodes.remove(lastListNode);
    1973         LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
    1974         Iterator<RelationMember> memberIter = list.iterator();
    1975         while (memberIter.hasNext())
    1976         {
    1977           RelationMember member = memberIter.next();
    1978           if ("backward".equals(member.getRole()))
    1979             listToAppend.addFirst(new RelationMember("forward", member.getWay()));
    1980           else
    1981             listToAppend.addFirst(new RelationMember("backward", member.getWay()));
    1982         }
    1983         frontNodes.remove(lastNode);
    1984         frontNodes.put(lastListNode, listToAppend);
     1972    backNodes.remove(lastListNode);
     1973    LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
     1974    Iterator<RelationMember> memberIter = list.iterator();
     1975    while (memberIter.hasNext())
     1976    {
     1977      RelationMember member = memberIter.next();
     1978      if ("backward".equals(member.getRole()))
     1979        listToAppend.addFirst(new RelationMember("forward", member.getWay()));
     1980      else
     1981        listToAppend.addFirst(new RelationMember("backward", member.getWay()));
     1982    }
     1983    frontNodes.remove(lastNode);
     1984    frontNodes.put(lastListNode, listToAppend);
    19851985      }
    19861986      else if (backNodes.get(lastNode) != null)
    19871987      {
    1988         backNodes.remove(lastListNode);
    1989         LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
    1990         Iterator<RelationMember> memberIter = list.iterator();
    1991         while (memberIter.hasNext())
    1992         {
    1993           RelationMember member = memberIter.next();
    1994           listToAppend.addLast(member);
    1995         }
    1996         backNodes.remove(lastNode);
    1997         backNodes.put(lastListNode, listToAppend);
     1988    backNodes.remove(lastListNode);
     1989    LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
     1990    Iterator<RelationMember> memberIter = list.iterator();
     1991    while (memberIter.hasNext())
     1992    {
     1993      RelationMember member = memberIter.next();
     1994      listToAppend.addLast(member);
     1995    }
     1996    backNodes.remove(lastNode);
     1997    backNodes.put(lastListNode, listToAppend);
    19981998      }
    19991999      else
    2000         frontNodes.put(lastNode, list);
     2000    frontNodes.put(lastNode, list);
    20012001    }
    20022002    else if (backNodes.get(firstNode) != null)
     
    20052005      list.addLast(new RelationMember("forward", way));
    20062006      backNodes.remove(firstNode);
    2007      
     2007
    20082008      Node firstListNode = null;
    20092009      if ("backward".equals(list.getFirst().getRole()))
    2010         firstListNode = list.getFirst().getWay().getNode
    2011             (list.getFirst().getWay().getNodesCount() - 1);
     2010    firstListNode = list.getFirst().getWay().getNode
     2011        (list.getFirst().getWay().getNodesCount() - 1);
    20122012      else
    2013         firstListNode = list.getFirst().getWay().getNode(0);
     2013    firstListNode = list.getFirst().getWay().getNode(0);
    20142014      if (lastNode.equals(firstListNode))
    20152015      {
    2016         frontNodes.remove(firstListNode);
    2017         loops.add(list);
     2016    frontNodes.remove(firstListNode);
     2017    loops.add(list);
    20182018      }
    20192019      else if (frontNodes.get(lastNode) != null)
    20202020      {
    2021         frontNodes.remove(firstListNode);
    2022         LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
    2023         ListIterator<RelationMember> memberIter = list.listIterator(list.size());
    2024         while (memberIter.hasPrevious())
    2025         {
    2026           RelationMember member = memberIter.previous();
    2027           listToAppend.addFirst(member);
    2028         }
    2029         frontNodes.remove(lastNode);
    2030         frontNodes.put(firstListNode, listToAppend);
     2021    frontNodes.remove(firstListNode);
     2022    LinkedList<RelationMember> listToAppend = frontNodes.get(lastNode);
     2023    ListIterator<RelationMember> memberIter = list.listIterator(list.size());
     2024    while (memberIter.hasPrevious())
     2025    {
     2026      RelationMember member = memberIter.previous();
     2027      listToAppend.addFirst(member);
     2028    }
     2029    frontNodes.remove(lastNode);
     2030    frontNodes.put(firstListNode, listToAppend);
    20312031      }
    20322032      else if (backNodes.get(lastNode) != null)
    20332033      {
    2034         frontNodes.remove(firstListNode);
    2035         LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
    2036         ListIterator<RelationMember> memberIter = list.listIterator(list.size());
    2037         while (memberIter.hasPrevious())
    2038         {
    2039           RelationMember member = memberIter.previous();
    2040           if ("backward".equals(member.getRole()))
    2041             listToAppend.addLast(new RelationMember("forward", member.getWay()));
    2042           else
    2043             listToAppend.addLast(new RelationMember("backward", member.getWay()));
    2044         }
    2045         backNodes.remove(lastNode);
    2046         backNodes.put(firstListNode, listToAppend);
    2047       }
     2034    frontNodes.remove(firstListNode);
     2035    LinkedList<RelationMember> listToAppend = backNodes.get(lastNode);
     2036    ListIterator<RelationMember> memberIter = list.listIterator(list.size());
     2037    while (memberIter.hasPrevious())
     2038    {
     2039      RelationMember member = memberIter.previous();
     2040      if ("backward".equals(member.getRole()))
     2041        listToAppend.addLast(new RelationMember("forward", member.getWay()));
    20482042      else
    2049         backNodes.put(lastNode, list);
     2043        listToAppend.addLast(new RelationMember("backward", member.getWay()));
     2044    }
     2045    backNodes.remove(lastNode);
     2046    backNodes.put(firstListNode, listToAppend);
     2047      }
     2048      else
     2049    backNodes.put(lastNode, list);
    20502050    }
    20512051    else if (frontNodes.get(lastNode) != null)
     
    20712071    }
    20722072  }
    2073  
     2073
    20742074  private void routesSelectionChanged() {
    20752075    int selectedPos = relsList.getAnchorSelectionIndex();
     
    20812081      tabbedPane.setEnabledAt(3, true);
    20822082      tabbedPane.setEnabledAt(4, true);
    2083      
     2083
    20842084      //Prepare Tags
    20852085      requiredTagsData.readRelation(currentRoute);
    20862086      commonTagsData.readRelation(currentRoute);
    20872087      otherTagsData.readRelation(currentRoute, tagBlacklist);
    2088      
     2088
    20892089      //Prepare Itinerary
    20902090      itineraryData.clear();
     
    20922092      Iterator<RelationMember> relIter = relMembers.iterator();
    20932093      fillItineraryTable(relIter, 0, -1);
    2094    
     2094
    20952095      //Prepare Stoplist
    20962096      stoplistData.clear();
     
    21082108    }
    21092109  }
    2110  
     2110
    21112111  private void fillItineraryTable
    21122112      (Iterator<RelationMember> relIter, long lastNodeId, int insPos) {
     
    21162116      if (curMember.isWay())
    21172117      {
    2118         itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
    2119         if (insPos >= 0)
    2120           ++insPos;
     2118    itineraryData.insertRow(insPos, curMember.getWay(), curMember.getRole());
     2119    if (insPos >= 0)
     2120      ++insPos;
    21212121      }
    21222122    }
    21232123    itineraryData.cleanupGaps();
    21242124  }
    2125  
     2125
    21262126  private void fillStoplistTable
    21272127      (Iterator<RelationMember> relIter, int insPos) {
     
    21312131      if (curMember.isNode())
    21322132      {
    2133         stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
    2134         if (insPos >= 0)
    2135           ++insPos;
     2133    stoplistData.insertRow(insPos, curMember.getNode(), curMember.getRole());
     2134    if (insPos >= 0)
     2135      ++insPos;
    21362136      }
    21372137    }
    21382138  }
    2139  
     2139
    21402140  private StopReference detectMinDistance
    21412141      (Node node, Vector< SegmentMetric > segmentMetrics,
     
    21462146    double lat = node.getCoor().lat();
    21472147    double lon = node.getCoor().lon();
    2148        
     2148
    21492149    int curIndex = -2;
    21502150    double angleLat = 100.0;
     
    21552155      curIndex += 2;
    21562156      SegmentMetric sm = iter.next();
    2157          
     2157
    21582158      if (sm == null)
    21592159      {
    2160         angleLat = 100.0;
    2161         angleLon = 200.0;
    2162            
    2163         continue;
    2164       }
    2165          
     2160    angleLat = 100.0;
     2161    angleLon = 200.0;
     2162
     2163    continue;
     2164      }
     2165
    21662166      double curPosition = (lat - sm.aLat)*sm.d1 + (lon - sm.aLon)*sm.d2;
    2167          
     2167
    21682168      if (curPosition < 0)
    21692169      {
    2170         if (angleLat <= 90.0)
    2171         {
    2172           double lastSegAngle = Math.atan2(angleLat - sm.aLat, angleLon - sm.aLon);
    2173           double segAngle = Math.atan2(sm.d1, -sm.o1);
    2174           double vertexAngle = Math.atan2(lat - sm.aLat, lon - sm.aLon);
    2175 
    2176           boolean vertexOnSeg = (vertexAngle == segAngle) ||
    2177               (vertexAngle == lastSegAngle);
    2178           boolean vertexOnTheLeft = (!vertexOnSeg) &&
    2179               (((lastSegAngle > vertexAngle) && (vertexAngle > segAngle))
    2180               || ((vertexAngle > segAngle) && (segAngle > lastSegAngle))
    2181               || ((segAngle > lastSegAngle) && (lastSegAngle > vertexAngle)));
    2182 
    2183           double currentDistance = Math.sqrt((lat - sm.aLat)*(lat - sm.aLat)
    2184                 + (lon - sm.aLon)*(lon - sm.aLon)
    2185                 *Math.cos(sm.aLat * Math.PI/180.0)*Math.cos(sm.aLat * Math.PI/180.0));
    2186           curPosition = vertexAngle - segAngle;
    2187           if (vertexOnTheLeft)
    2188             curPosition = -curPosition;
    2189           if (curPosition < 0)
    2190             curPosition += 2*Math.PI;
    2191           if ((Math.abs(currentDistance) < distance)
    2192             && (((!vertexOnTheLeft) && (rhsPossible))
    2193                 || ((vertexOnTheLeft) && (lhsPossible))
    2194                || (vertexOnSeg)))
    2195           {
    2196             distance = Math.abs(currentDistance);
    2197             minIndex = curIndex-1;
    2198             position = curPosition;
    2199           }
    2200         }
    2201         angleLat = 100.0;
    2202         angleLon = 200.0;
     2170    if (angleLat <= 90.0)
     2171    {
     2172      double lastSegAngle = Math.atan2(angleLat - sm.aLat, angleLon - sm.aLon);
     2173      double segAngle = Math.atan2(sm.d1, -sm.o1);
     2174      double vertexAngle = Math.atan2(lat - sm.aLat, lon - sm.aLon);
     2175
     2176      boolean vertexOnSeg = (vertexAngle == segAngle) ||
     2177          (vertexAngle == lastSegAngle);
     2178      boolean vertexOnTheLeft = (!vertexOnSeg) &&
     2179          (((lastSegAngle > vertexAngle) && (vertexAngle > segAngle))
     2180          || ((vertexAngle > segAngle) && (segAngle > lastSegAngle))
     2181          || ((segAngle > lastSegAngle) && (lastSegAngle > vertexAngle)));
     2182
     2183      double currentDistance = Math.sqrt((lat - sm.aLat)*(lat - sm.aLat)
     2184        + (lon - sm.aLon)*(lon - sm.aLon)
     2185        *Math.cos(sm.aLat * Math.PI/180.0)*Math.cos(sm.aLat * Math.PI/180.0));
     2186      curPosition = vertexAngle - segAngle;
     2187      if (vertexOnTheLeft)
     2188        curPosition = -curPosition;
     2189      if (curPosition < 0)
     2190        curPosition += 2*Math.PI;
     2191      if ((Math.abs(currentDistance) < distance)
     2192        && (((!vertexOnTheLeft) && (rhsPossible))
     2193        || ((vertexOnTheLeft) && (lhsPossible))
     2194           || (vertexOnSeg)))
     2195      {
     2196        distance = Math.abs(currentDistance);
     2197        minIndex = curIndex-1;
     2198        position = curPosition;
     2199      }
     2200    }
     2201    angleLat = 100.0;
     2202    angleLon = 200.0;
    22032203      }
    22042204      else if (curPosition > sm.length)
    22052205      {
    2206         angleLat = sm.aLat;
    2207         angleLon = sm.aLon;
     2206    angleLat = sm.aLat;
     2207    angleLon = sm.aLon;
    22082208      }
    22092209      else
    22102210      {
    2211         double currentDistance = (lat - sm.aLat)*sm.o1 + (lon - sm.aLon)*sm.o2;
    2212         if ((Math.abs(currentDistance) < distance)
    2213                     && (((currentDistance >= 0) && (rhsPossible))
    2214                     || ((currentDistance <= 0) && (lhsPossible))))
    2215         {
    2216           distance = Math.abs(currentDistance);
    2217           minIndex = curIndex;
    2218           position = curPosition;
    2219         }
    2220            
    2221         angleLat = 100.0;
    2222         angleLon = 200.0;
    2223       }
    2224     }
    2225        
     2211    double currentDistance = (lat - sm.aLat)*sm.o1 + (lon - sm.aLon)*sm.o2;
     2212    if ((Math.abs(currentDistance) < distance)
     2213            && (((currentDistance >= 0) && (rhsPossible))
     2214            || ((currentDistance <= 0) && (lhsPossible))))
     2215    {
     2216      distance = Math.abs(currentDistance);
     2217      minIndex = curIndex;
     2218      position = curPosition;
     2219    }
     2220
     2221    angleLat = 100.0;
     2222    angleLon = 200.0;
     2223      }
     2224    }
     2225
    22262226    if (minIndex == -1)
    22272227      return new StopReference(segmentMetrics.size()*2, 0, 180.0, node.get("name"),
    2228                                "", node);
    2229          
     2228                   "", node);
     2229
    22302230    return new StopReference(minIndex, position, distance, node.get("name"),
    2231                              "", node);
     2231                 "", node);
    22322232  }
    22332233}
  • applications/editors/josm/plugins/public_transport/src/public_transport/SettingsStoptypeCommand.java

    r22048 r23192  
    2121      railway = node.get("railway");
    2222    }
    23    
     23
    2424    public Node node;
    2525    public String highway;
    2626    public String railway;
    2727  };
    28  
     28
    2929  private Vector< HighwayRailway > oldStrings = null;
    3030  private WaypointTableModel waypointTM = null;
    3131  private DefaultListModel tracksListModel = null;
    3232  private String type = null;
    33  
     33
    3434  public SettingsStoptypeCommand(StopImporterAction controller)
    3535  {
     
    3939    oldStrings = new Vector< HighwayRailway >();
    4040  }
    41  
     41
    4242  public boolean executeCommand()
    4343  {
     
    4747      if ((Node)waypointTM.nodes.elementAt(i) != null)
    4848      {
    49         Node node = (Node)waypointTM.nodes.elementAt(i);
    50         oldStrings.add(new HighwayRailway(node));
    51         StopImporterAction.setTagsWrtType(node, type);
     49    Node node = (Node)waypointTM.nodes.elementAt(i);
     50    oldStrings.add(new HighwayRailway(node));
     51    StopImporterAction.setTagsWrtType(node, type);
    5252      }
    5353    }
     
    5757      for (int i = 0; i < track.stoplistTM.getRowCount(); ++i)
    5858      {
    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         }
     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    }
    6565      }
    6666    }
    6767    return true;
    6868  }
    69  
     69
    7070  public void undoCommand()
    7171  {
     
    7777    }
    7878  }
    79  
     79
    8080  public void fillModifiedData
    8181    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    8383  {
    8484  }
    85  
     85
    8686  @Override public JLabel getDescription()
    8787  {
    8888    return new JLabel("public_transport.Settings.ChangeStoptype");
    8989  }
    90  
     90
    9191};
  • applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java

    r20867 r23192  
    6262
    6363public class StopImporterAction extends JosmAction
    64 { 
     64{
    6565  private static StopImporterDialog dialog = null;
    6666  private static DefaultListModel tracksListModel = null;
     
    6969  private static WaypointTableModel waypointTM = null;
    7070  public boolean inEvent = false;
    71  
     71
    7272  public StopImporterAction()
    7373  {
    7474    super(tr("Create Stops from GPX ..."), null,
    75           tr("Create Stops from a GPX file"), null, true);
     75      tr("Create Stops from a GPX file"), null, true);
    7676  }
    7777
     
    8080    return waypointTM;
    8181  }
    82  
     82
    8383  public StopImporterDialog getDialog()
    8484  {
     
    9292    return tracksListModel;
    9393  }
    94  
     94
    9595  public TrackReference getCurrentTrack()
    9696  {
     
    101101  {
    102102    DataSet mainDataSet = Main.main.getCurrentDataSet();
    103    
     103
    104104    if (dialog == null)
    105105      dialog = new StopImporterDialog(this);
    106    
     106
    107107    dialog.setVisible(true);
    108108
     
    112112      if (curDir.equals(""))
    113113      {
    114         curDir = ".";
     114    curDir = ".";
    115115      }
    116116      JFileChooser fc = new JFileChooser(new File(curDir));
    117       fc.setDialogTitle("Select GPX file"); 
     117      fc.setDialogTitle("Select GPX file");
    118118      fc.setMultiSelectionEnabled(false);
    119      
     119
    120120      int answer = fc.showOpenDialog(Main.parent);
    121121      if (answer != JFileChooser.APPROVE_OPTION)
    122         return;
    123      
     122    return;
     123
    124124      if (!fc.getCurrentDirectory().getAbsolutePath().equals(curDir))
    125         Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
    126      
     125    Main.pref.put("lastDirectory", fc.getCurrentDirectory().getAbsolutePath());
     126
    127127      importData(fc.getSelectedFile());
    128      
     128
    129129      refreshData();
    130130    }
     
    132132    {
    133133      if ((!inEvent) && (dialog.gpsTimeStartValid()) && (currentTrack != null))
    134         Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
     134    Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
    135135    }
    136136    else if ("stopImporter.settingsStopwatchStart".equals(event.getActionCommand()))
    137137    {
    138138      if ((!inEvent) && (dialog.stopwatchStartValid()) && (currentTrack != null))
    139         Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
     139    Main.main.undoRedo.add(new TrackStoplistRelocateCommand(this));
    140140    }
    141141    else if ("stopImporter.settingsTimeWindow".equals(event.getActionCommand()))
    142142    {
    143143      if (currentTrack != null)
    144         currentTrack.timeWindow = dialog.getTimeWindow();
     144    currentTrack.timeWindow = dialog.getTimeWindow();
    145145    }
    146146    else if ("stopImporter.settingsThreshold".equals(event.getActionCommand()))
    147147    {
    148148      if (currentTrack != null)
    149         currentTrack.threshold = dialog.getThreshold();
     149    currentTrack.threshold = dialog.getThreshold();
    150150    }
    151151    else if ("stopImporter.settingsSuggestStops".equals(event.getActionCommand()))
     
    189189  private void importData(final File file)
    190190  {
    191     try 
     191    try
    192192    {
    193193      InputStream is;
    194194      if (file.getName().endsWith(".gpx.gz"))
    195         is = new GZIPInputStream(new FileInputStream(file));
     195    is = new GZIPInputStream(new FileInputStream(file));
    196196      else
    197         is = new FileInputStream(file);
     197    is = new FileInputStream(file);
    198198      // Workaround for SAX BOM bug
    199199      // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206835
    200200      if (!((is.read() == 0xef) && (is.read() == 0xbb) && (is.read() == 0xbf)))
    201201      {
    202         is.close();
    203         if (file.getName().endsWith(".gpx.gz"))
    204           is = new GZIPInputStream(new FileInputStream(file));
    205         else
    206           is = new FileInputStream(file);
     202    is.close();
     203    if (file.getName().endsWith(".gpx.gz"))
     204      is = new GZIPInputStream(new FileInputStream(file));
     205    else
     206      is = new FileInputStream(file);
    207207      }
    208208      final GpxReader r = new GpxReader(is);
    209209      final boolean parsedProperly = r.parse(true);
    210210      data = r.data;
    211      
     211
    212212      if (!parsedProperly)
    213213      {
    214         JOptionPane.showMessageDialog(null, tr("Error occured while parsing gpx file {0}. Only part of the file will be available", file.getName()));
    215       }
    216     }
    217     catch (FileNotFoundException e) 
     214    JOptionPane.showMessageDialog(null, tr("Error occured while parsing gpx file {0}. Only part of the file will be available", file.getName()));
     215      }
     216    }
     217    catch (FileNotFoundException e)
    218218    {
    219219      e.printStackTrace();
     
    241241      while (trackIter.hasNext())
    242242      {
    243         GpxTrack track = trackIter.next();
    244         trackRefs.add(new TrackReference(track, this));
    245       }
    246      
     243    GpxTrack track = trackIter.next();
     244    trackRefs.add(new TrackReference(track, this));
     245      }
     246
    247247      Collections.sort(trackRefs);
    248248
    249249      Iterator< TrackReference > iter = trackRefs.iterator();
    250250      while (iter.hasNext())
    251         tracksListModel.addElement(iter.next());
    252      
     251    tracksListModel.addElement(iter.next());
     252
    253253      waypointTM = new WaypointTableModel(this);
    254254      Iterator< WayPoint > waypointIter = data.waypoints.iterator();
    255255      while (waypointIter.hasNext())
    256256      {
    257         WayPoint waypoint = waypointIter.next();
    258         waypointTM.addRow(waypoint);
     257    WayPoint waypoint = waypointIter.next();
     258    waypointTM.addRow(waypoint);
    259259      }
    260260      dialog.setWaypointsTableModel(waypointTM);
     
    265265      (null, "The GPX file contained no tracks or waypoints.", "No data found",
    266266       JOptionPane.ERROR_MESSAGE);
    267      
     267
    268268      System.out.println("Public Transport: StopImporter: No data found");
    269269    }
    270270  }
    271  
     271
    272272  public void tracksSelectionChanged(int selectedPos)
    273273  {
     
    276276      currentTrack = ((TrackReference)tracksListModel.elementAt(selectedPos));
    277277      dialog.setTrackValid(true);
    278      
     278
    279279      //Prepare Settings
    280280      dialog.setSettings
    281           (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
    282            currentTrack.timeWindow, currentTrack.threshold);
    283      
     281      (currentTrack.gpsSyncTime, currentTrack.stopwatchStart,
     282       currentTrack.timeWindow, currentTrack.threshold);
     283
    284284      //Prepare Stoplist
    285285      dialog.setStoplistTableModel
     
    297297    return createNode(latLon, dialog.getStoptype(), name);
    298298  }
    299    
     299
    300300  public static Node createNode(LatLon latLon, String type, String name)
    301301  {
     
    306306    {
    307307      JOptionPane.showMessageDialog(null, "There exists no dataset."
    308           + " Try to download data from the server or open an OSM file.",
     308      + " Try to download data from the server or open an OSM file.",
    309309   "No data found", JOptionPane.ERROR_MESSAGE);
    310      
     310
    311311      System.out.println("Public Transport: StopInserter: No data found");
    312            
     312
    313313      return null;
    314314    }
     
    333333      node.put("railway", "station");
    334334  }
    335  
     335
    336336  /* returns a collection of all selected lines or
    337337     a collection of all lines otherwise */
     
    343343    {
    344344      for (int i = 0; i < selectedLines.length; ++i)
    345         consideredLines.add(selectedLines[i]);
     345    consideredLines.add(selectedLines[i]);
    346346    }
    347347    else
    348348    {
    349349      for (int i = 0; i < table.getRowCount(); ++i)
    350         consideredLines.add(new Integer(i));
     350    consideredLines.add(new Integer(i));
    351351    }
    352352    return consideredLines;
     
    358358    if (Main.main.getCurrentDataSet() == null)
    359359      return;
    360      
     360
    361361    table.clearSelection();
    362      
     362
    363363    for (int i = 0; i < table.getRowCount(); ++i)
    364364    {
    365365      if ((nodes.elementAt(i) != null) &&
    366            (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i))))
    367         table.addRowSelectionInterval(i, i);
    368     }
    369   }
    370  
     366       (Main.main.getCurrentDataSet().isSelected(nodes.elementAt(i))))
     367    table.addRowSelectionInterval(i, i);
     368    }
     369  }
     370
    371371  /* shows the nodes that correspond to the marked lines in the table.
    372372     If no lines are marked in the table, show all nodes from the vector */
     
    379379      int j = consideredLines.elementAt(i);
    380380      if (nodes.elementAt(j) != null)
    381         nodes.elementAt(j).visit(box);
     381    nodes.elementAt(j).visit(box);
    382382    }
    383383    if (box.getBounds() == null)
     
    386386    Main.map.mapView.recalculateCenterScale(box);
    387387  }
    388  
     388
    389389  /* marks the nodes that correspond to the marked lines in the table.
    390390  If no lines are marked in the table, mark all nodes from the vector */
     
    398398      int j = consideredLines.elementAt(i);
    399399      if (nodes.elementAt(j) != null)
    400         Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));
    401     }
    402   }
    403  
     400    Main.main.getCurrentDataSet().addSelected(nodes.elementAt(j));
     401    }
     402  }
     403
    404404  public static String timeOf(double t)
    405405  {
    406406    t -= Math.floor(t/24/60/60)*24*60*60;
    407    
     407
    408408    int hour = (int)Math.floor(t/60/60);
    409409    t -=  Math.floor(t/60/60)*60*60;
     
    411411    t -=  Math.floor(t/60)*60;
    412412    double second = t;
    413    
     413
    414414    Format format = new DecimalFormat("00");
    415415    Format formatS = new DecimalFormat("00.###");
    416416    return (format.format(hour) + ":" + format.format(minute) + ":"
    417         + formatS.format(second));
    418   }
    419  
     417    + formatS.format(second));
     418  }
     419
    420420  public Action getFocusWaypointNameAction()
    421421  {
    422422    return new FocusWaypointNameAction();
    423423  }
    424  
     424
    425425  public Action getFocusWaypointShelterAction(String shelter)
    426426  {
     
    434434      public void actionPerformed(ActionEvent e)
    435435      {
    436         JTable table = dialog.getWaypointsTable();
    437         int row = table.getEditingRow();
    438         if (row < 0)
    439           return;
    440         table.clearSelection();
    441         table.addRowSelectionInterval(row, row);
    442         Main.main.undoRedo.add
    443             (new WaypointsDisableCommand(StopImporterAction.this));
     436    JTable table = dialog.getWaypointsTable();
     437    int row = table.getEditingRow();
     438    if (row < 0)
     439      return;
     440    table.clearSelection();
     441    table.addRowSelectionInterval(row, row);
     442    Main.main.undoRedo.add
     443        (new WaypointsDisableCommand(StopImporterAction.this));
    444444      }
    445445    };
     
    450450    return new FocusTrackStoplistNameAction();
    451451  }
    452  
     452
    453453  public Action getFocusTrackStoplistShelterAction(String shelter)
    454454  {
     
    462462      public void actionPerformed(ActionEvent e)
    463463      {
    464         JTable table = dialog.getStoplistTable();
    465         int row = table.getEditingRow();
    466         if (row < 0)
    467           return;
    468         table.clearSelection();
    469         table.addRowSelectionInterval(row, row);
    470         Main.main.undoRedo.add
    471             (new TrackStoplistDeleteCommand(StopImporterAction.this));
     464    JTable table = dialog.getStoplistTable();
     465    int row = table.getEditingRow();
     466    if (row < 0)
     467      return;
     468    table.clearSelection();
     469    table.addRowSelectionInterval(row, row);
     470    Main.main.undoRedo.add
     471        (new TrackStoplistDeleteCommand(StopImporterAction.this));
    472472      }
    473473    };
     
    483483      int row = table.getEditingRow();
    484484      if (row < 0)
    485         row = 0;
     485    row = 0;
    486486      waypointTM.inEvent = true;
    487487      if (table.getCellEditor() != null)
    488488      {
    489         if (!table.getCellEditor().stopCellEditing())
    490           table.getCellEditor().cancelCellEditing();
     489    if (!table.getCellEditor().stopCellEditing())
     490      table.getCellEditor().cancelCellEditing();
    491491      }
    492492      table.editCellAt(row, 1);
    493493      table.getCellEditor().getTableCellEditorComponent
    494           (table, "", true, row, 1);
     494      (table, "", true, row, 1);
    495495      waypointTM.inEvent = false;
    496496    }
    497497  };
    498  
     498
    499499  private class FocusWaypointShelterAction extends AbstractAction
    500500  {
    501501    private String defaultShelter = null;
    502    
     502
    503503    public FocusWaypointShelterAction(String defaultShelter)
    504504    {
    505505      this.defaultShelter = defaultShelter;
    506506    }
    507    
     507
    508508    public void actionPerformed(ActionEvent e)
    509509    {
     
    513513      int row = table.getEditingRow();
    514514      if (row < 0)
    515         row = 0;
     515    row = 0;
    516516      waypointTM.inEvent = true;
    517517      if (table.getCellEditor() != null)
    518518      {
    519         if (!table.getCellEditor().stopCellEditing())
    520           table.getCellEditor().cancelCellEditing();
     519    if (!table.getCellEditor().stopCellEditing())
     520      table.getCellEditor().cancelCellEditing();
    521521      }
    522522      table.editCellAt(row, 2);
     
    526526    }
    527527  };
    528  
     528
    529529  private class FocusTrackStoplistNameAction extends AbstractAction
    530530  {
     
    536536      int row = table.getEditingRow();
    537537      if (row < 0)
    538         row = 0;
     538    row = 0;
    539539      currentTrack.inEvent = true;
    540540      if (table.getCellEditor() != null)
    541541      {
    542         if (!table.getCellEditor().stopCellEditing())
    543           table.getCellEditor().cancelCellEditing();
     542    if (!table.getCellEditor().stopCellEditing())
     543      table.getCellEditor().cancelCellEditing();
    544544      }
    545545      table.editCellAt(row, 1);
     
    549549    }
    550550  };
    551  
     551
    552552  private class FocusTrackStoplistShelterAction extends AbstractAction
    553553  {
    554554    private String defaultShelter = null;
    555    
     555
    556556    public FocusTrackStoplistShelterAction(String defaultShelter)
    557557    {
    558558      this.defaultShelter = defaultShelter;
    559559    }
    560    
     560
    561561    public void actionPerformed(ActionEvent e)
    562562    {
     
    566566      int row = table.getEditingRow();
    567567      if (row < 0)
    568         row = 0;
     568    row = 0;
    569569      currentTrack.inEvent = true;
    570570      if (table.getCellEditor() != null)
    571571      {
    572         if (!table.getCellEditor().stopCellEditing())
    573           table.getCellEditor().cancelCellEditing();
     572    if (!table.getCellEditor().stopCellEditing())
     573      table.getCellEditor().cancelCellEditing();
    574574      }
    575575      table.editCellAt(row, 2);
  • applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterDialog.java

    r20867 r23192  
    6363
    6464public class StopImporterDialog
    65 { 
     65{
    6666  private JDialog jDialog = null;
    6767  private JTabbedPane tabbedPane = null;
     
    7474  private JTable stoplistTable = null;
    7575  private JTable waypointTable = null;
    76  
     76
    7777  public StopImporterDialog(StopImporterAction controller)
    7878  {
     
    9393    tabbedPane.setEnabledAt(3, true);
    9494    jDialog.add(tabbedPane);
    95      
     95
    9696    //Tracks Tab
    9797    JPanel contentPane = tabTracks;
     
    9999    GridBagConstraints layoutCons = new GridBagConstraints();
    100100    contentPane.setLayout(gridbag);
    101      
     101
    102102    JLabel label = new JLabel("Tracks in this GPX file:");
    103      
     103
    104104    layoutCons.gridx = 0;
    105105    layoutCons.gridy = 0;
     
    110110    gridbag.setConstraints(label, layoutCons);
    111111    contentPane.add(label);
    112      
     112
    113113    DefaultListModel tracksListModel = controller.getTracksListModel();
    114114    tracksList = new JList(tracksListModel);
     
    118118    tracksList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    119119    tracksList.addListSelectionListener(new TracksLSL(controller));
    120      
     120
    121121    layoutCons.gridx = 0;
    122122    layoutCons.gridy = 1;
     
    124124    layoutCons.weightx = 1.0;
    125125    layoutCons.weighty = 1.0;
    126     layoutCons.fill = GridBagConstraints.BOTH;     
     126    layoutCons.fill = GridBagConstraints.BOTH;
    127127    gridbag.setConstraints(rpListSP, layoutCons);
    128128    contentPane.add(rpListSP);
    129      
     129
    130130    //Settings Tab
    131131    contentPane = tabSettings;
     
    133133    layoutCons = new GridBagConstraints();
    134134    contentPane.setLayout(gridbag);
    135      
     135
    136136    label = new JLabel("Type of stops to add");
    137      
     137
    138138    layoutCons.gridx = 0;
    139139    layoutCons.gridy = 0;
     
    144144    gridbag.setConstraints(label, layoutCons);
    145145    contentPane.add(label);
    146    
     146
    147147    cbStoptype = new JComboBox();
    148148    cbStoptype.setEditable(false);
     
    154154    cbStoptype.setActionCommand("stopImporter.settingsStoptype");
    155155    cbStoptype.addActionListener(controller);
    156    
     156
    157157    layoutCons.gridx = 0;
    158158    layoutCons.gridy = 1;
     
    163163    gridbag.setConstraints(cbStoptype, layoutCons);
    164164    contentPane.add(cbStoptype);
    165      
     165
    166166    label = new JLabel("Time on your GPS device");
    167      
     167
    168168    layoutCons.gridx = 0;
    169169    layoutCons.gridy = 2;
     
    174174    gridbag.setConstraints(label, layoutCons);
    175175    contentPane.add(label);
    176      
     176
    177177    tfGPSTimeStart = new JTextField("00:00:00", 15);
    178178    tfGPSTimeStart.setActionCommand("stopImporter.settingsGPSTimeStart");
    179179    tfGPSTimeStart.addActionListener(controller);
    180      
     180
    181181    layoutCons.gridx = 0;
    182182    layoutCons.gridy = 3;
     
    187187    gridbag.setConstraints(tfGPSTimeStart, layoutCons);
    188188    contentPane.add(tfGPSTimeStart);
    189      
     189
    190190    label = new JLabel("HH:MM:SS.sss");
    191      
     191
    192192    layoutCons.gridx = 1;
    193193    layoutCons.gridy = 3;
     
    198198    gridbag.setConstraints(label, layoutCons);
    199199    contentPane.add(label);
    200            
     200
    201201    label = new JLabel("Time on your stopwatch");
    202      
     202
    203203    layoutCons.gridx = 0;
    204204    layoutCons.gridy = 4;
     
    209209    gridbag.setConstraints(label, layoutCons);
    210210    contentPane.add(label);
    211      
     211
    212212    tfStopwatchStart = new JTextField("00:00:00", 15);
    213213    tfStopwatchStart.setActionCommand("stopImporter.settingsStopwatchStart");
    214214    tfStopwatchStart.addActionListener(controller);
    215      
     215
    216216    layoutCons.gridx = 0;
    217217    layoutCons.gridy = 5;
     
    222222    gridbag.setConstraints(tfStopwatchStart, layoutCons);
    223223    contentPane.add(tfStopwatchStart);
    224      
     224
    225225    label = new JLabel("HH:MM:SS.sss");
    226      
     226
    227227    layoutCons.gridx = 1;
    228228    layoutCons.gridy = 5;
     
    233233    gridbag.setConstraints(label, layoutCons);
    234234    contentPane.add(label);
    235      
     235
    236236    label = new JLabel("Time window");
    237      
     237
    238238    layoutCons.gridx = 0;
    239239    layoutCons.gridy = 6;
     
    244244    gridbag.setConstraints(label, layoutCons);
    245245    contentPane.add(label);
    246      
     246
    247247    tfTimeWindow = new JTextField("15", 4);
    248248    tfTimeWindow.setActionCommand("stopImporter.settingsTimeWindow");
    249249    tfTimeWindow.addActionListener(controller);
    250      
     250
    251251    layoutCons.gridx = 0;
    252252    layoutCons.gridy = 7;
     
    257257    gridbag.setConstraints(tfTimeWindow, layoutCons);
    258258    contentPane.add(tfTimeWindow);
    259      
     259
    260260    label = new JLabel("seconds");
    261      
     261
    262262    layoutCons.gridx = 1;
    263263    layoutCons.gridy = 7;
     
    268268    gridbag.setConstraints(label, layoutCons);
    269269    contentPane.add(label);
    270      
     270
    271271    label = new JLabel("Move Threshold");
    272      
     272
    273273    layoutCons.gridx = 0;
    274274    layoutCons.gridy = 8;
     
    279279    gridbag.setConstraints(label, layoutCons);
    280280    contentPane.add(label);
    281      
     281
    282282    tfThreshold = new JTextField("20", 4);
    283283    tfThreshold.setActionCommand("stopImporter.settingsThreshold");
    284284    tfThreshold.addActionListener(controller);
    285      
     285
    286286    layoutCons.gridx = 0;
    287287    layoutCons.gridy = 9;
     
    292292    gridbag.setConstraints(tfThreshold, layoutCons);
    293293    contentPane.add(tfThreshold);
    294      
     294
    295295    label = new JLabel("meters");
    296      
     296
    297297    layoutCons.gridx = 1;
    298298    layoutCons.gridy = 9;
     
    303303    gridbag.setConstraints(label, layoutCons);
    304304    contentPane.add(label);
    305      
     305
    306306    JButton bSuggestStops = new JButton("Suggest Stops");
    307307    bSuggestStops.setActionCommand("stopImporter.settingsSuggestStops");
    308308    bSuggestStops.addActionListener(controller);
    309      
     309
    310310    layoutCons.gridx = 0;
    311311    layoutCons.gridy = 10;
     
    316316    gridbag.setConstraints(bSuggestStops, layoutCons);
    317317    contentPane.add(bSuggestStops);
    318      
     318
    319319    //Stops Tab
    320320    contentPane = tabStops;
     
    325325        (KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
    326326    contentPane.getActionMap().put
    327         ("stopImporter.focusName", controller.getFocusTrackStoplistNameAction());
     327    ("stopImporter.focusName", controller.getFocusTrackStoplistNameAction());
    328328    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    329329        (KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
    330330    contentPane.getActionMap().put
    331         ("stopImporter.focusShelterYes",
    332         controller.getFocusTrackStoplistShelterAction("yes"));
     331    ("stopImporter.focusShelterYes",
     332    controller.getFocusTrackStoplistShelterAction("yes"));
    333333    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    334334        (KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
    335335    contentPane.getActionMap().put
    336         ("stopImporter.focusShelterNo",
    337         controller.getFocusTrackStoplistShelterAction("no"));
     336    ("stopImporter.focusShelterNo",
     337    controller.getFocusTrackStoplistShelterAction("no"));
    338338    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    339339        (KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
    340340    contentPane.getActionMap().put
    341         ("stopImporter.focusShelterImplicit",
    342         controller.getFocusTrackStoplistShelterAction("implicit"));
     341    ("stopImporter.focusShelterImplicit",
     342    controller.getFocusTrackStoplistShelterAction("implicit"));
    343343    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    344344        (KeyStroke.getKeyStroke("alt D"), "stopImporter.stoplistDelete");
    345345    contentPane.getActionMap().put
    346         ("stopImporter.stoplistDelete",
    347         controller.getFocusStoplistDeleteAction());
    348      
     346    ("stopImporter.stoplistDelete",
     347    controller.getFocusStoplistDeleteAction());
     348
    349349    stoplistTable = new JTable();
    350350    JScrollPane tableSP = new JScrollPane(stoplistTable);
    351    
     351
    352352    layoutCons.gridx = 0;
    353353    layoutCons.gridy = 0;
     
    358358    gridbag.setConstraints(tableSP, layoutCons);
    359359    contentPane.add(tableSP);
    360      
     360
    361361    JButton bFind = new JButton("Find");
    362362    bFind.setActionCommand("stopImporter.stoplistFind");
    363363    bFind.addActionListener(controller);
    364      
     364
    365365    layoutCons.gridx = 0;
    366366    layoutCons.gridy = 1;
     
    371371    gridbag.setConstraints(bFind, layoutCons);
    372372    contentPane.add(bFind);
    373      
     373
    374374    JButton bShow = new JButton("Show");
    375375    bShow.setActionCommand("stopImporter.stoplistShow");
    376376    bShow.addActionListener(controller);
    377      
     377
    378378    layoutCons.gridx = 0;
    379379    layoutCons.gridy = 2;
     
    384384    gridbag.setConstraints(bShow, layoutCons);
    385385    contentPane.add(bShow);
    386      
     386
    387387    JButton bMark = new JButton("Mark");
    388388    bMark.setActionCommand("stopImporter.stoplistMark");
    389389    bMark.addActionListener(controller);
    390      
     390
    391391    layoutCons.gridx = 1;
    392392    layoutCons.gridy = 1;
     
    398398    gridbag.setConstraints(bMark, layoutCons);
    399399    contentPane.add(bMark);
    400      
     400
    401401    JButton bDetach = new JButton("Detach");
    402402    bDetach.setActionCommand("stopImporter.stoplistDetach");
    403403    bDetach.addActionListener(controller);
    404      
     404
    405405    layoutCons.gridx = 1;
    406406    layoutCons.gridy = 2;
     
    412412    gridbag.setConstraints(bDetach, layoutCons);
    413413    contentPane.add(bDetach);
    414      
     414
    415415    JButton bAdd = new JButton("Add");
    416416    bAdd.setActionCommand("stopImporter.stoplistAdd");
    417417    bAdd.addActionListener(controller);
    418      
     418
    419419    layoutCons.gridx = 2;
    420420    layoutCons.gridy = 1;
     
    426426    gridbag.setConstraints(bAdd, layoutCons);
    427427    contentPane.add(bAdd);
    428      
     428
    429429    JButton bDelete = new JButton("Delete");
    430430    bDelete.setActionCommand("stopImporter.stoplistDelete");
    431431    bDelete.addActionListener(controller);
    432      
     432
    433433    layoutCons.gridx = 2;
    434434    layoutCons.gridy = 2;
     
    439439    gridbag.setConstraints(bDelete, layoutCons);
    440440    contentPane.add(bDelete);
    441      
     441
    442442    JButton bSort = new JButton("Sort");
    443443    bSort.setActionCommand("stopImporter.stoplistSort");
    444444    bSort.addActionListener(controller);
    445      
     445
    446446    layoutCons.gridx = 3;
    447447    layoutCons.gridy = 1;
     
    453453    gridbag.setConstraints(bSort, layoutCons);
    454454    contentPane.add(bSort);
    455      
     455
    456456    //Waypoints Tab
    457457    contentPane = tabWaypoints;
     
    462462        (KeyStroke.getKeyStroke("alt N"), "stopImporter.focusName");
    463463    contentPane.getActionMap().put
    464         ("stopImporter.focusName", controller.getFocusWaypointNameAction());
     464    ("stopImporter.focusName", controller.getFocusWaypointNameAction());
    465465    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    466466        (KeyStroke.getKeyStroke("alt S"), "stopImporter.focusShelterYes");
    467467    contentPane.getActionMap().put
    468         ("stopImporter.focusShelterYes",
    469         controller.getFocusWaypointShelterAction("yes"));
     468    ("stopImporter.focusShelterYes",
     469    controller.getFocusWaypointShelterAction("yes"));
    470470    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    471471        (KeyStroke.getKeyStroke("alt T"), "stopImporter.focusShelterNo");
    472472    contentPane.getActionMap().put
    473         ("stopImporter.focusShelterNo",
    474         controller.getFocusWaypointShelterAction("no"));
     473    ("stopImporter.focusShelterNo",
     474    controller.getFocusWaypointShelterAction("no"));
    475475    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    476476        (KeyStroke.getKeyStroke("alt U"), "stopImporter.focusShelterImplicit");
    477477    contentPane.getActionMap().put
    478         ("stopImporter.focusShelterImplicit",
    479         controller.getFocusWaypointShelterAction("implicit"));
     478    ("stopImporter.focusShelterImplicit",
     479    controller.getFocusWaypointShelterAction("implicit"));
    480480    contentPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put
    481481        (KeyStroke.getKeyStroke("alt D"), "stopImporter.waypointsDelete");
    482482    contentPane.getActionMap().put
    483         ("stopImporter.waypointsDelete",
    484         controller.getFocusWaypointDeleteAction());
    485      
     483    ("stopImporter.waypointsDelete",
     484    controller.getFocusWaypointDeleteAction());
     485
    486486    waypointTable = new JTable();
    487487    tableSP = new JScrollPane(waypointTable);
    488    
     488
    489489    layoutCons.gridx = 0;
    490490    layoutCons.gridy = 0;
     
    495495    gridbag.setConstraints(tableSP, layoutCons);
    496496    contentPane.add(tableSP);
    497      
     497
    498498    bFind = new JButton("Find");
    499499    bFind.setActionCommand("stopImporter.waypointsFind");
    500500    bFind.addActionListener(controller);
    501      
     501
    502502    layoutCons.gridx = 0;
    503503    layoutCons.gridy = 1;
     
    508508    gridbag.setConstraints(bFind, layoutCons);
    509509    contentPane.add(bFind);
    510      
     510
    511511    bShow = new JButton("Show");
    512512    bShow.setActionCommand("stopImporter.waypointsShow");
    513513    bShow.addActionListener(controller);
    514      
     514
    515515    layoutCons.gridx = 0;
    516516    layoutCons.gridy = 2;
     
    521521    gridbag.setConstraints(bShow, layoutCons);
    522522    contentPane.add(bShow);
    523      
     523
    524524    bMark = new JButton("Mark");
    525525    bMark.setActionCommand("stopImporter.waypointsMark");
    526526    bMark.addActionListener(controller);
    527      
     527
    528528    layoutCons.gridx = 1;
    529529    layoutCons.gridy = 1;
     
    535535    gridbag.setConstraints(bMark, layoutCons);
    536536    contentPane.add(bMark);
    537      
     537
    538538    bDetach = new JButton("Detach");
    539539    bDetach.setActionCommand("stopImporter.waypointsDetach");
    540540    bDetach.addActionListener(controller);
    541      
     541
    542542    layoutCons.gridx = 1;
    543543    layoutCons.gridy = 2;
     
    549549    gridbag.setConstraints(bDetach, layoutCons);
    550550    contentPane.add(bDetach);
    551      
     551
    552552    bAdd = new JButton("Enable");
    553553    bAdd.setActionCommand("stopImporter.waypointsAdd");
    554554    bAdd.addActionListener(controller);
    555      
     555
    556556    layoutCons.gridx = 2;
    557557    layoutCons.gridy = 1;
     
    563563    gridbag.setConstraints(bAdd, layoutCons);
    564564    contentPane.add(bAdd);
    565      
     565
    566566    bDelete = new JButton("Disable");
    567567    bDelete.setActionCommand("stopImporter.waypointsDelete");
    568568    bDelete.addActionListener(controller);
    569      
     569
    570570    layoutCons.gridx = 2;
    571571    layoutCons.gridy = 2;
     
    576576    gridbag.setConstraints(bDelete, layoutCons);
    577577    contentPane.add(bDelete);
    578      
     578
    579579    jDialog.pack();
    580580    jDialog.setLocationRelativeTo(frame);
    581581  }
    582  
     582
    583583  public void setTrackValid(boolean valid)
    584584  {
    585585    tabbedPane.setEnabledAt(2, valid);
    586586  }
    587  
     587
    588588  public void setVisible(boolean visible)
    589589  {
    590590    jDialog.setVisible(visible);
    591591  }
    592  
     592
    593593  public void setSettings
    594594      (String gpsSyncTime, String stopwatchStart,
     
    600600    tfThreshold.setText(Double.toString(threshold));
    601601  }
    602  
     602
    603603  public String getStoptype()
    604604  {
    605605    return (String)cbStoptype.getSelectedItem();
    606606  }
    607  
     607
    608608  public boolean gpsTimeStartValid()
    609609  {
     
    615615    {
    616616      JOptionPane.showMessageDialog
    617           (null, "Can't parse a time from this string.", "Invalid value",
    618            JOptionPane.ERROR_MESSAGE);
     617      (null, "Can't parse a time from this string.", "Invalid value",
     618       JOptionPane.ERROR_MESSAGE);
    619619      return false;
    620620    }
    621621  }
    622  
     622
    623623  public String getGpsTimeStart()
    624624  {
    625625    return tfGPSTimeStart.getText();
    626626  }
    627  
     627
    628628  public void setGpsTimeStart(String s)
    629629  {
    630630    tfGPSTimeStart.setText(s);
    631631  }
    632  
     632
    633633  public boolean stopwatchStartValid()
    634634  {
     
    640640    {
    641641      JOptionPane.showMessageDialog
    642           (null, "Can't parse a time from this string.", "Invalid value",
    643            JOptionPane.ERROR_MESSAGE);
     642      (null, "Can't parse a time from this string.", "Invalid value",
     643       JOptionPane.ERROR_MESSAGE);
    644644      return false;
    645645    }
    646646  }
    647  
     647
    648648  public String getStopwatchStart()
    649649  {
    650650    return tfStopwatchStart.getText();
    651651  }
    652  
     652
    653653  public void setStopwatchStart(String s)
    654654  {
    655655    tfStopwatchStart.setText(s);
    656656  }
    657  
     657
    658658  public double getTimeWindow()
    659659  {
    660660    return Double.parseDouble(tfTimeWindow.getText());
    661661  }
    662  
     662
    663663  public double getThreshold()
    664664  {
    665665    return Double.parseDouble(tfThreshold.getText());
    666666  }
    667  
     667
    668668  public JTable getStoplistTable()
    669669  {
    670670    return stoplistTable;
    671671  }
    672  
     672
    673673  public void setStoplistTableModel(TrackStoplistTableModel model)
    674674  {
     
    680680    comboBox.addItem("implicit");
    681681    stoplistTable.getColumnModel().getColumn(2)
    682         .setCellEditor(new DefaultCellEditor(comboBox));
     682    .setCellEditor(new DefaultCellEditor(comboBox));
    683683    int width = stoplistTable.getPreferredSize().width;
    684684    stoplistTable.getColumnModel().getColumn(0).setPreferredWidth((int)(width * 0.4));
     
    686686    stoplistTable.getColumnModel().getColumn(2).setPreferredWidth((int)(width * 0.1));
    687687  }
    688  
     688
    689689  public JTable getWaypointsTable()
    690690  {
    691691    return waypointTable;
    692692  }
    693  
     693
    694694  public void setWaypointsTableModel(WaypointTableModel model)
    695695  {
     
    701701    comboBox.addItem("implicit");
    702702    waypointTable.getColumnModel().getColumn(2)
    703         .setCellEditor(new DefaultCellEditor(comboBox));
     703    .setCellEditor(new DefaultCellEditor(comboBox));
    704704    int width = waypointTable.getPreferredSize().width;
    705705    waypointTable.getColumnModel().getColumn(0).setPreferredWidth((int)(width * 0.4));
     
    707707    waypointTable.getColumnModel().getColumn(2).setPreferredWidth((int)(width * 0.1));
    708708  }
    709  
     709
    710710  public static double parseTime(String s)
    711711  {
    712712    double result = 0;
    713713    if ((s.charAt(2) != ':') || (s.charAt(2) != ':')
    714         || (s.length() < 8))
     714    || (s.length() < 8))
    715715      return -1;
    716716    int hour = Integer.parseInt(s.substring(0, 2));
     
    718718    double second = Double.parseDouble(s.substring(6, s.length()));
    719719    if ((hour < 0) || (hour > 23) || (minute < 0) || (minute > 59)
    720         || (second < 0) || (second >= 60.0))
     720    || (second < 0) || (second >= 60.0))
    721721      return -1;
    722722    return (second + minute*60 + hour*60*60);
    723723  }
    724  
     724
    725725  private class TracksLSL implements ListSelectionListener
    726726  {
    727727    StopImporterAction root = null;
    728    
     728
    729729    public TracksLSL(StopImporterAction sia)
    730730    {
    731731      root = sia;
    732732    }
    733    
     733
    734734    public void valueChanged(ListSelectionEvent e)
    735735    {
    736736      int selectedPos = tracksList.getAnchorSelectionIndex();
    737737      if (tracksList.isSelectedIndex(selectedPos))
    738         root.tracksSelectionChanged(selectedPos);
     738    root.tracksSelectionChanged(selectedPos);
    739739      else
    740         root.tracksSelectionChanged(-1);
     740    root.tracksSelectionChanged(-1);
    741741    }
    742742  };
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackReference.java

    r20839 r23192  
    3232  private StopImporterAction controller = null;
    3333  public boolean inEvent = false;
    34    
     34
    3535  public TrackReference(GpxTrack track, StopImporterAction controller)
    3636  {
     
    4646      while ((siter.hasNext()) && (this.gpsSyncTime == null))
    4747      {
    48         Iterator< WayPoint > witer = siter.next().getWayPoints().iterator();
    49         if (witer.hasNext())
    50         {
    51           this.gpsStartTime = witer.next().getString("time");
    52           if (this.gpsStartTime != null)
    53             this.gpsSyncTime = this.gpsStartTime.substring(11, 19);
    54         }
     48    Iterator< WayPoint > witer = siter.next().getWayPoints().iterator();
     49    if (witer.hasNext())
     50    {
     51      this.gpsStartTime = witer.next().getString("time");
     52      if (this.gpsStartTime != null)
     53        this.gpsSyncTime = this.gpsStartTime.substring(11, 19);
     54    }
    5555      }
    5656      if (this.gpsSyncTime == null)
    5757      {
    58         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    JOptionPane.showMessageDialog
     59        (null, "The GPX file doesn't contain valid trackpoints. "
     60        + "Please use a GPX file that has trackpoints.", "GPX File Trouble",
    6161     JOptionPane.ERROR_MESSAGE);
    62          
    63         this.gpsStartTime = "1970-01-01T00:00:00Z";
    64         this.gpsSyncTime = this.stopwatchStart;
     62
     63    this.gpsStartTime = "1970-01-01T00:00:00Z";
     64    this.gpsSyncTime = this.stopwatchStart;
    6565      }
    6666    }
     
    7070    this.threshold = 20;
    7171  }
    72  
     72
    7373  public GpxTrack getGpxTrack()
    7474  {
    7575    return track;
    7676  }
    77    
     77
    7878  public int compareTo(TrackReference tr)
    7979  {
     
    8383    {
    8484      if (tr_name == null)
    85         return -1;
     85    return -1;
    8686      return name.compareTo(tr_name);
    8787    }
    8888    return 1;
    8989  }
    90    
     90
    9191  public String toString()
    9292  {
     
    9696    return buf;
    9797  }
    98    
     98
    9999  public void tableChanged(TableModelEvent e)
    100100  {
     
    102102    {
    103103      if (inEvent)
    104         return;
    105      
     104    return;
     105
    106106      double time = StopImporterDialog.parseTime
    107             ((String)stoplistTM.getValueAt(e.getFirstRow(), 0));
     107        ((String)stoplistTM.getValueAt(e.getFirstRow(), 0));
    108108      if (time < 0)
    109109      {
    110         stoplistTM.setValueAt
    111             (stoplistTM.timeAt(e.getFirstRow()), e.getFirstRow(), 0);
    112         JOptionPane.showMessageDialog
    113             (null, "Can't parse a time from this string.", "Invalid value",
    114              JOptionPane.ERROR_MESSAGE);
    115         return;
     110    stoplistTM.setValueAt
     111        (stoplistTM.timeAt(e.getFirstRow()), e.getFirstRow(), 0);
     112    JOptionPane.showMessageDialog
     113        (null, "Can't parse a time from this string.", "Invalid value",
     114         JOptionPane.ERROR_MESSAGE);
     115    return;
    116116      }
    117117
     
    119119              (this, e.getFirstRow()));
    120120      stoplistTM.setTimeAt
    121           (e.getFirstRow(), (String)stoplistTM.getValueAt(e.getFirstRow(), 0));
     121      (e.getFirstRow(), (String)stoplistTM.getValueAt(e.getFirstRow(), 0));
    122122    }
    123123  }
    124    
     124
    125125  public LatLon computeCoor(double time)
    126126  {
     
    131131    double timeDelta = gpsSyncTime - StopImporterDialog.parseTime(stopwatchStart);
    132132    time += timeDelta;
    133        
     133
    134134    WayPoint wayPoint = null;
    135135    WayPoint lastWayPoint = null;
     
    142142      while (witer.hasNext())
    143143      {
    144         wayPoint = witer.next();
    145         String startTime = wayPoint.getString("time");
    146         wayPointTime = StopImporterDialog.parseTime(startTime.substring(11, 19));
    147         if (startTime.substring(11, 19).compareTo(gpsStartTime.substring(11, 19)) == -1)
    148           wayPointTime += 24*60*60;
    149         if (wayPointTime >= time)
    150           break;
    151         lastWayPoint = wayPoint;
    152         lastWayPointTime = wayPointTime;
     144    wayPoint = witer.next();
     145    String startTime = wayPoint.getString("time");
     146    wayPointTime = StopImporterDialog.parseTime(startTime.substring(11, 19));
     147    if (startTime.substring(11, 19).compareTo(gpsStartTime.substring(11, 19)) == -1)
     148      wayPointTime += 24*60*60;
     149    if (wayPointTime >= time)
     150      break;
     151    lastWayPoint = wayPoint;
     152    lastWayPointTime = wayPointTime;
    153153      }
    154154      if (wayPointTime >= time)
    155         break;
     155    break;
    156156    }
    157        
     157
    158158    double lat = 0;
    159159    if ((wayPointTime == lastWayPointTime) || (lastWayPoint == null))
     
    161161    else
    162162      lat = wayPoint.getCoor().lat()
    163           *(time - lastWayPointTime)/(wayPointTime - lastWayPointTime)
    164           + lastWayPoint.getCoor().lat()
    165           *(wayPointTime - time)/(wayPointTime - lastWayPointTime);
     163      *(time - lastWayPointTime)/(wayPointTime - lastWayPointTime)
     164      + lastWayPoint.getCoor().lat()
     165      *(wayPointTime - time)/(wayPointTime - lastWayPointTime);
    166166    double lon = 0;
    167167    if ((wayPointTime == lastWayPointTime) || (lastWayPoint == null))
     
    169169    else
    170170      lon = wayPoint.getCoor().lon()
    171           *(time - lastWayPointTime)/(wayPointTime - lastWayPointTime)
    172           + lastWayPoint.getCoor().lon()
    173           *(wayPointTime - time)/(wayPointTime - lastWayPointTime);
    174      
     171      *(time - lastWayPointTime)/(wayPointTime - lastWayPointTime)
     172      + lastWayPoint.getCoor().lon()
     173      *(wayPointTime - time)/(wayPointTime - lastWayPointTime);
     174
    175175    return new LatLon(lat, lon);
    176176  }
    177    
     177
    178178  public void relocateNodes()
    179179  {
     
    182182      Node node = stoplistTM.nodeAt(i);
    183183      if (node == null)
    184         continue;
    185        
     184    continue;
     185
    186186      double time = StopImporterDialog.parseTime
    187             ((String)stoplistTM.getValueAt(i, 0));
     187        ((String)stoplistTM.getValueAt(i, 0));
    188188      LatLon latLon = computeCoor(time);
    189189
     
    193193      if (cmd != null)
    194194      {
    195         Main.main.undoRedo.add(cmd);
     195    Main.main.undoRedo.add(cmd);
    196196      }
    197197    }
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistAddCommand.java

    r22048 r23192  
    1414  private int workingLine;
    1515  private TrackStoplistTableModel stoplistTM = null;
    16  
     16
    1717  public TrackStoplistAddCommand(StopImporterAction controller)
    1818  {
     
    2020    workingLine = controller.getDialog().getStoplistTable().getSelectedRow();
    2121  }
    22  
     22
    2323  public boolean executeCommand()
    2424  {
     
    2626    return true;
    2727  }
    28  
     28
    2929  public void undoCommand()
    3030  {
     
    3434    stoplistTM.removeRow(workingLine);
    3535  }
    36  
     36
    3737  public void fillModifiedData
    3838    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    4040  {
    4141  }
    42  
     42
    4343  @Override public JLabel getDescription()
    4444  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDeleteCommand.java

    r22048 r23192  
    2121      this.shelter = shelter;
    2222    }
    23    
     23
    2424    public Node node;
    2525    public String time;
     
    2727    public String shelter;
    2828  };
    29  
     29
    3030  private Vector< Integer > workingLines = null;
    3131  private Vector< NodeTimeName > nodesForUndo = null;
    3232  private TrackStoplistTableModel stoplistTM = null;
    33  
     33
    3434  public TrackStoplistDeleteCommand(StopImporterAction controller)
    3535  {
     
    3737    workingLines = new Vector< Integer >();
    3838    nodesForUndo = new Vector< NodeTimeName >();
    39    
     39
    4040    // use selected lines or all lines if no line is selected
    4141    int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
     
    4444      for (int i = 0; i < selectedLines.length; ++i)
    4545      {
    46         workingLines.add(selectedLines[i]);
     46    workingLines.add(selectedLines[i]);
    4747      }
    4848    }
     
    5050    {
    5151      for (int i = 0; i < stoplistTM.getRowCount(); ++i)
    52         workingLines.add(new Integer(i));
     52    workingLines.add(new Integer(i));
    5353    }
    5454  }
    55  
     55
    5656  public boolean executeCommand()
    5757  {
     
    6262      Node node = stoplistTM.nodeAt(j);
    6363      nodesForUndo.add(new NodeTimeName
    64           (node, (String)stoplistTM.getValueAt(j, 0),
    65            (String)stoplistTM.getValueAt(j, 1),
    66            (String)stoplistTM.getValueAt(j, 2)));
     64      (node, (String)stoplistTM.getValueAt(j, 0),
     65       (String)stoplistTM.getValueAt(j, 1),
     66       (String)stoplistTM.getValueAt(j, 2)));
    6767      stoplistTM.removeRow(j);
    6868      if (node == null)
    69         continue;
     69    continue;
    7070      Main.main.getCurrentDataSet().removePrimitive(node);
    7171      node.setDeleted(true);
     
    7373    return true;
    7474  }
    75  
     75
    7676  public void undoCommand()
    7777  {
     
    8282      stoplistTM.insertRow(j, ntn.node, ntn.time, ntn.name, ntn.shelter);
    8383      if (ntn.node == null)
    84         continue;
     84    continue;
    8585      ntn.node.setDeleted(false);
    8686      Main.main.getCurrentDataSet().addPrimitive(ntn.node);
    8787    }
    8888  }
    89  
     89
    9090  public void fillModifiedData
    9191    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    9393  {
    9494  }
    95  
     95
    9696  @Override public JLabel getDescription()
    9797  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistDetachCommand.java

    r22048 r23192  
    1515  private Vector< Node > nodesForUndo = null;
    1616  private TrackStoplistTableModel stoplistTM = null;
    17  
     17
    1818  public TrackStoplistDetachCommand(StopImporterAction controller)
    1919  {
     
    2121    workingLines = new Vector< Integer >();
    2222    nodesForUndo = new Vector< Node >();
    23    
     23
    2424    // use either selected lines or all lines if no line is selected
    2525    int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
     
    2828    {
    2929      for (int i = 0; i < selectedLines.length; ++i)
    30         consideredLines.add(selectedLines[i]);
     30    consideredLines.add(selectedLines[i]);
    3131    }
    3232    else
    3333    {
    3434      for (int i = 0; i < stoplistTM.getRowCount(); ++i)
    35         consideredLines.add(new Integer(i));
     35    consideredLines.add(new Integer(i));
    3636    }
    37    
     37
    3838    // keep only lines where a node can be added
    3939    for (int i = 0; i < consideredLines.size(); ++i)
    4040    {
    4141      if (stoplistTM.nodeAt(consideredLines.elementAt(i)) != null)
    42         workingLines.add(consideredLines.elementAt(i));
     42    workingLines.add(consideredLines.elementAt(i));
    4343    }
    4444  }
    45  
     45
    4646  public boolean executeCommand()
    4747  {
     
    5656    return true;
    5757  }
    58  
     58
    5959  public void undoCommand()
    6060  {
     
    6666    }
    6767  }
    68  
     68
    6969  public void fillModifiedData
    7070    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    7272  {
    7373  }
    74  
     74
    7575  @Override public JLabel getDescription()
    7676  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistNameCommand.java

    r22048 r23192  
    2222  private String shelter = null;
    2323  private LatLon oldLatLon = null;
    24  
     24
    2525  @SuppressWarnings("unchecked")
    2626  public TrackStoplistNameCommand(TrackReference trackref, int workingLine)
     
    4242      this.shelter = null;
    4343  }
    44  
     44
    4545  public boolean executeCommand()
    4646  {
     
    6969    return true;
    7070  }
    71  
     71
    7272  public void undoCommand()
    7373  {
     
    9494    trackref.inEvent = false;
    9595  }
    96  
     96
    9797  public void fillModifiedData
    9898    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    100100  {
    101101  }
    102  
     102
    103103  @Override public JLabel getDescription()
    104104  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistRelocateCommand.java

    r22048 r23192  
    2121  private String gpsSyncTime = null;
    2222  private String stopwatchStart = null;
    23  
     23
    2424  public TrackStoplistRelocateCommand(StopImporterAction controller)
    2525  {
     
    3131    this.oldStopwatchStart = currentTrack.stopwatchStart;
    3232  }
    33  
     33
    3434  public boolean executeCommand()
    3535  {
     
    4040      Node node = currentTrack.stoplistTM.nodeAt(i);
    4141      if (node == null)
    42         continue;
    43        
     42    continue;
     43
    4444      double time = StopImporterDialog.parseTime
    45             ((String)currentTrack.stoplistTM.getValueAt(i, 0));
     45        ((String)currentTrack.stoplistTM.getValueAt(i, 0));
    4646      node.setCoor(currentTrack.computeCoor(time));
    4747    }
     
    5353      controller.inEvent = false;
    5454    }
    55    
     55
    5656    return true;
    5757  }
    58  
     58
    5959  public void undoCommand()
    6060  {
     
    6565      Node node = currentTrack.stoplistTM.nodeAt(i);
    6666      if (node == null)
    67         continue;
    68        
     67    continue;
     68
    6969      double time = StopImporterDialog.parseTime
    70             ((String)currentTrack.stoplistTM.getValueAt(i, 0));
     70        ((String)currentTrack.stoplistTM.getValueAt(i, 0));
    7171      node.setCoor(currentTrack.computeCoor(time));
    7272    }
     
    7979    }
    8080  }
    81  
     81
    8282  public void fillModifiedData
    8383    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    8585  {
    8686  }
    87  
     87
    8888  @Override public JLabel getDescription()
    8989  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistSortCommand.java

    r22048 r23192  
    2222  private int insPos;
    2323  private String stopwatchStart;
    24  
     24
    2525  public TrackStoplistSortCommand(StopImporterAction controller)
    2626  {
     
    2929    insPos = controller.getDialog().getStoplistTable().getSelectedRow();
    3030    stopwatchStart = controller.getCurrentTrack().stopwatchStart;
    31    
     31
    3232    // use either selected lines or all lines if no line is selected
    3333    int[] selectedLines = controller.getDialog().getStoplistTable().getSelectedRows();
     
    3535    {
    3636      for (int i = 0; i < selectedLines.length; ++i)
    37         workingLines.add(selectedLines[i]);
     37    workingLines.add(selectedLines[i]);
    3838    }
    3939    else
    4040    {
    4141      for (int i = 0; i < stoplistTM.getRowCount(); ++i)
    42         workingLines.add(new Integer(i));
     42    workingLines.add(new Integer(i));
    4343    }
    4444  }
    45  
     45
    4646  @SuppressWarnings("unchecked")
    4747  public boolean executeCommand()
    4848  {
    4949    tableDataModel = (Vector< Vector< Object > >)stoplistTM.getDataVector()
    50         .clone();
     50    .clone();
    5151    nodes = (Vector< Node >)stoplistTM.getNodes().clone();
    5252    times = (Vector< String >)stoplistTM.getTimes().clone();
    53    
     53
    5454    Vector< NodeSortEntry > nodesToSort = new Vector< NodeSortEntry >();
    5555    for (int i = workingLines.size()-1; i >= 0; --i)
     
    5757      int j = workingLines.elementAt(i).intValue();
    5858      nodesToSort.add(new NodeSortEntry
    59           (stoplistTM.nodeAt(j), (String)stoplistTM.getValueAt(j, 0),
    60             (String)stoplistTM.getValueAt(j, 1),
    61             (String)stoplistTM.getValueAt(j, 2),
    62              StopImporterDialog.parseTime(stopwatchStart)));
     59      (stoplistTM.nodeAt(j), (String)stoplistTM.getValueAt(j, 0),
     60        (String)stoplistTM.getValueAt(j, 1),
     61        (String)stoplistTM.getValueAt(j, 2),
     62         StopImporterDialog.parseTime(stopwatchStart)));
    6363      stoplistTM.removeRow(j);
    6464    }
    65    
     65
    6666    Collections.sort(nodesToSort);
    67    
     67
    6868    int insPos = this.insPos;
    6969    Iterator< NodeSortEntry > iter = nodesToSort.iterator();
     
    7373      stoplistTM.insertRow(insPos, nse.node, nse.time, nse.name, nse.shelter);
    7474      if (insPos >= 0)
    75         ++insPos;
     75    ++insPos;
    7676    }
    7777    return true;
    7878  }
    79  
     79
    8080  public void undoCommand()
    8181  {
     
    8484    stoplistTM.setTimes(times);
    8585  }
    86  
     86
    8787  public void fillModifiedData
    8888    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    9090  {
    9191  }
    92  
     92
    9393  @Override public JLabel getDescription()
    9494  {
    9595    return new JLabel("public_transport.TrackStoplist.Sort");
    9696  }
    97  
     97
    9898  private class NodeSortEntry implements Comparable< NodeSortEntry >
    9999  {
     
    103103    public String shelter = null;
    104104    public double startTime = 0;
    105    
     105
    106106    public NodeSortEntry
    107107        (Node node, String time, String name, String shelter, double startTime)
     
    112112      this.shelter = shelter;
    113113    }
    114    
     114
    115115    public int compareTo(NodeSortEntry nse)
    116116    {
    117117      double time = StopImporterDialog.parseTime(this.time);
    118118      if (time - startTime > 12*60*60)
    119         time -= 24*60*60;
    120      
     119    time -= 24*60*60;
     120
    121121      double nseTime = StopImporterDialog.parseTime(nse.time);
    122122      if (nseTime - startTime > 12*60*60)
    123         nseTime -= 24*60*60;
    124      
     123    nseTime -= 24*60*60;
     124
    125125      if (time < nseTime)
    126         return -1;
     126    return -1;
    127127      else if (time > nseTime)
    128         return 1;
     128    return 1;
    129129      else
    130         return 0;
     130    return 0;
    131131    }
    132132  };
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistTableModel.java

    r20839 r23192  
    1414  private Vector< String > times = null;
    1515  private static Vector< String > columns = null;
    16    
     16
    1717  public TrackStoplistTableModel(TrackReference tr)
    1818  {
     
    2626    nodes = new Vector< Node >();
    2727    times = new Vector< String >();
    28      
     28
    2929    setColumnIdentifiers(columns);
    3030    addTableModelListener(tr);
    3131  }
    32    
     32
    3333  public boolean isCellEditable(int row, int column) {
    3434    return true;
    3535  }
    36    
     36
    3737  public void addRow(Object[] obj) {
    3838    throw new UnsupportedOperationException();
    3939  }
    40    
     40
    4141  public void insertRow(int insPos, Object[] obj) {
    4242    throw new UnsupportedOperationException();
    4343  }
    44    
     44
    4545  public void addRow(String time) {
    4646    insertRow(-1, time);
    4747  }
    48    
     48
    4949  public void insertRow(int insPos, String time)
    5050  {
     
    118118    }
    119119  }
    120    
     120
    121121  public void clear()
    122122  {
     
    125125    super.setRowCount(0);
    126126  }
    127    
     127
    128128  public void setDataVector(Vector< Vector< Object > > dataVector)
    129129  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackSuggestStopsCommand.java

    r22048 r23192  
    2929  private Vector< Node > nodes = null;
    3030  private Vector< String > times = null;
    31  
     31
    3232  public TrackSuggestStopsCommand(StopImporterAction controller)
    3333  {
     
    4343    segments = controller.getCurrentTrack().getGpxTrack().getSegments();
    4444  }
    45  
     45
    4646  @SuppressWarnings("unchecked")
    4747  public boolean executeCommand()
     
    5050      return false;
    5151    tableDataModel = (Vector< Vector< Object > >)stoplistTM.getDataVector()
    52         .clone();
     52    .clone();
    5353    nodes = (Vector< Node >)stoplistTM.getNodes().clone();
    5454    times = (Vector< String >)stoplistTM.getTimes().clone();
    55    
     55
    5656    for (int i = 0; i < stoplistTM.getNodes().size(); ++i)
    5757    {
    5858      Node node = stoplistTM.nodeAt(i);
    5959      if (node == null)
    60         continue;
     60    continue;
    6161      Main.main.getCurrentDataSet().removePrimitive(node);
    6262      node.setDeleted(true);
     
    7070      Iterator< WayPoint > witer = siter.next().getWayPoints().iterator();
    7171      while (witer.hasNext())
    72         wayPoints.add(witer.next());
     72    wayPoints.add(witer.next());
    7373    }
    7474    Vector< Double > wayPointsDist = new Vector< Double >(wayPoints.size());
    75      
     75
    7676    int i = 0;
    7777    double time = -48*60*60;
     
    8080    {
    8181      if (wayPoints.elementAt(i).getString("time") != null)
    82         time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
    83             .getString("time").substring(11,19));
     82    time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
     83        .getString("time").substring(11,19));
    8484      if (time < dGpsStartTime)
    85         time += 24*60*60;
     85    time += 24*60*60;
    8686      wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));
    8787      ++i;
     
    9393      while ((j > 0) && (time - timeWindow/2 < time2))
    9494      {
    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;
     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;
    101101      }
    102102      int k = i + 1;
     
    104104      while ((k < wayPoints.size()) && (time + timeWindow/2 > time2))
    105105      {
    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;
    112       }
    113        
     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;
     112      }
     113
    114114      if (j < k)
    115115      {
    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));
     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));
    125125      }
    126126      else
    127         wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));
    128        
     127    wayPointsDist.add(Double.valueOf(Double.POSITIVE_INFINITY));
     128
    129129      if (wayPoints.elementAt(i).getString("time") != null)
    130         time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
    131             .getString("time").substring(11,19));
     130    time = StopImporterDialog.parseTime(wayPoints.elementAt(i)
     131        .getString("time").substring(11,19));
    132132      if (time < dGpsStartTime)
    133         time += 24*60*60;
     133    time += 24*60*60;
    134134      ++i;
    135135    }
    136      
     136
    137137    LatLon lastStopCoor = null;
    138138    for (i = 1; i < wayPoints.size()-1; ++i)
    139139    {
    140140      if (wayPointsDist.elementAt(i).doubleValue() >= threshold)
    141         continue;
     141    continue;
    142142      if ((wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i-1)) != -1)
    143            || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i+1)) != -1))
    144         continue;
    145        
     143       || (wayPointsDist.elementAt(i).compareTo(wayPointsDist.elementAt(i+1)) != -1))
     144    continue;
     145
    146146      LatLon latLon = wayPoints.elementAt(i).getCoor();
    147147      if ((lastStopCoor != null) &&  (lastStopCoor.greatCircleDistance(latLon) < threshold))
    148         continue;
    149        
     148    continue;
     149
    150150      if (wayPoints.elementAt(i).getString("time") != null)
    151151      {
    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), "", "");
    161       }
    162        
     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), "", "");
     161      }
     162
    163163      lastStopCoor = latLon;
    164164    }
    165    
     165
    166166    return true;
    167167  }
    168  
     168
    169169  public void undoCommand()
    170170  {
     
    175175      Node node = stoplistTM.nodeAt(i);
    176176      if (node == null)
    177         continue;
     177    continue;
    178178      Main.main.getCurrentDataSet().removePrimitive(node);
    179179      node.setDeleted(true);
    180180    }
    181    
     181
    182182    stoplistTM.setDataVector(tableDataModel);
    183183    stoplistTM.setNodes(nodes);
    184184    stoplistTM.setTimes(times);
    185    
     185
    186186    for (int i = 0; i < stoplistTM.getNodes().size(); ++i)
    187187    {
    188188      Node node = stoplistTM.nodeAt(i);
    189189      if (node == null)
    190         continue;
     190    continue;
    191191      node.setDeleted(false);
    192192      Main.main.getCurrentDataSet().addPrimitive(node);
    193193    }
    194194  }
    195  
     195
    196196  public void fillModifiedData
    197197    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    199199  {
    200200  }
    201  
     201
    202202  @Override public JLabel getDescription()
    203203  {
    204204    return new JLabel("public_transport.TrackStoplist.SuggestStops");
    205205  }
    206  
     206
    207207  private class NodeSortEntry implements Comparable< NodeSortEntry >
    208208  {
     
    211211    public String name = null;
    212212    public double startTime = 0;
    213    
     213
    214214    public NodeSortEntry(Node node, String time, String name, double startTime)
    215215    {
     
    218218      this.name = name;
    219219    }
    220    
     220
    221221    public int compareTo(NodeSortEntry nse)
    222222    {
    223223      double time = StopImporterDialog.parseTime(this.time);
    224224      if (time - startTime > 12*60*60)
    225         time -= 24*60*60;
    226      
     225    time -= 24*60*60;
     226
    227227      double nseTime = StopImporterDialog.parseTime(nse.time);
    228228      if (nseTime - startTime > 12*60*60)
    229         nseTime -= 24*60*60;
    230      
     229    nseTime -= 24*60*60;
     230
    231231      if (time < nseTime)
    232         return -1;
     232    return -1;
    233233      else if (time > nseTime)
    234         return 1;
     234    return 1;
    235235      else
    236         return 0;
     236    return 0;
    237237    }
    238238  };
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointTableModel.java

    r20835 r23192  
    2121  public Vector< Node > nodes = new Vector< Node >();
    2222  public Vector< LatLon > coors = new Vector< LatLon >();
    23    
     23
    2424  public WaypointTableModel(StopImporterAction controller)
    2525  {
     
    3030    addTableModelListener(this);
    3131  }
    32    
     32
    3333  public boolean isCellEditable(int row, int column)
    3434  {
     
    3737    return false;
    3838  }
    39    
     39
    4040  public void addRow(Object[] obj)
    4141  {
    4242    throw new UnsupportedOperationException();
    4343  }
    44    
     44
    4545  public void insertRow(int insPos, Object[] obj)
    4646  {
    4747    throw new UnsupportedOperationException();
    4848  }
    49    
     49
    5050  public void addRow(WayPoint wp)
    5151  {
    5252    insertRow(-1, wp);
    5353  }
    54    
     54
    5555  public void insertRow(int insPos, WayPoint wp)
    5656  {
     
    6464
    6565    Node node = controller.createNode(wp.getCoor(), buf[1]);
    66    
     66
    6767    if (insPos == -1)
    6868    {
     
    7878    }
    7979  }
    80    
     80
    8181  public void clear()
    8282  {
     
    8484    super.setRowCount(0);
    8585  }
    86  
     86
    8787  public void tableChanged(TableModelEvent e)
    8888  {
     
    9090    {
    9191      if (inEvent)
    92         return;
     92    return;
    9393      Main.main.undoRedo.add(new WaypointsNameCommand
    94           (this, e.getFirstRow(), (String)getValueAt(e.getFirstRow(), 1),
    95            (String)getValueAt(e.getFirstRow(), 2)));
     94      (this, e.getFirstRow(), (String)getValueAt(e.getFirstRow(), 1),
     95       (String)getValueAt(e.getFirstRow(), 2)));
    9696    }
    9797  }
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsDetachCommand.java

    r22048 r23192  
    1515  private Vector< Node > nodesForUndo = null;
    1616  private WaypointTableModel waypointTM = null;
    17  
     17
    1818  public WaypointsDetachCommand(StopImporterAction controller)
    1919  {
     
    2121    workingLines = new Vector< Integer >();
    2222    nodesForUndo = new Vector< Node >();
    23    
     23
    2424    // use either selected lines or all lines if no line is selected
    2525    int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
     
    2828    {
    2929      for (int i = 0; i < selectedLines.length; ++i)
    30         consideredLines.add(selectedLines[i]);
     30    consideredLines.add(selectedLines[i]);
    3131    }
    3232    else
    3333    {
    3434      for (int i = 0; i < waypointTM.getRowCount(); ++i)
    35         consideredLines.add(new Integer(i));
     35    consideredLines.add(new Integer(i));
    3636    }
    37    
     37
    3838    // keep only lines where a node can be added
    3939    for (int i = 0; i < consideredLines.size(); ++i)
    4040    {
    4141      if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
    42         workingLines.add(consideredLines.elementAt(i));
     42    workingLines.add(consideredLines.elementAt(i));
    4343    }
    4444  }
    45  
     45
    4646  public boolean executeCommand()
    4747  {
     
    5656    return true;
    5757  }
    58  
     58
    5959  public void undoCommand()
    6060  {
     
    6666    }
    6767  }
    68  
     68
    6969  public void fillModifiedData
    7070    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    7272  {
    7373  }
    74  
     74
    7575  @Override public JLabel getDescription()
    7676  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsDisableCommand.java

    r22048 r23192  
    1515  private Vector< Node > nodesForUndo = null;
    1616  private WaypointTableModel waypointTM = null;
    17  
     17
    1818  public WaypointsDisableCommand(StopImporterAction controller)
    1919  {
     
    2121    workingLines = new Vector< Integer >();
    2222    nodesForUndo = new Vector< Node >();
    23    
     23
    2424    // use either selected lines or all lines if no line is selected
    2525    int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
     
    2828    {
    2929      for (int i = 0; i < selectedLines.length; ++i)
    30         consideredLines.add(selectedLines[i]);
     30    consideredLines.add(selectedLines[i]);
    3131    }
    3232    else
    3333    {
    3434      for (int i = 0; i < waypointTM.getRowCount(); ++i)
    35         consideredLines.add(new Integer(i));
     35    consideredLines.add(new Integer(i));
    3636    }
    37    
     37
    3838    // keep only lines where a node can be added
    3939    for (int i = 0; i < consideredLines.size(); ++i)
    4040    {
    4141      if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) != null)
    42         workingLines.add(consideredLines.elementAt(i));
     42    workingLines.add(consideredLines.elementAt(i));
    4343    }
    4444  }
    45  
     45
    4646  public boolean executeCommand()
    4747  {
     
    5353      nodesForUndo.add(node);
    5454      if (node == null)
    55         continue;
     55    continue;
    5656      waypointTM.nodes.set(j, null);
    5757      Main.main.getCurrentDataSet().removePrimitive(node);
     
    6060    return true;
    6161  }
    62  
     62
    6363  public void undoCommand()
    6464  {
     
    6969      waypointTM.nodes.set(j, node);
    7070      if (node == null)
    71         continue;
     71    continue;
    7272      node.setDeleted(false);
    7373      Main.main.getCurrentDataSet().addPrimitive(node);
    7474    }
    7575  }
    76  
     76
    7777  public void fillModifiedData
    7878    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    8080  {
    8181  }
    82  
     82
    8383  @Override public JLabel getDescription()
    8484  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsEnableCommand.java

    r22048 r23192  
    1515  private WaypointTableModel waypointTM = null;
    1616  private String type = null;
    17  
     17
    1818  public WaypointsEnableCommand(StopImporterAction controller)
    1919  {
     
    2121    type = controller.getDialog().getStoptype();
    2222    workingLines = new Vector< Integer >();
    23    
     23
    2424    // use either selected lines or all lines if no line is selected
    2525    int[] selectedLines = controller.getDialog().getWaypointsTable().getSelectedRows();
     
    2828    {
    2929      for (int i = 0; i < selectedLines.length; ++i)
    30         consideredLines.add(selectedLines[i]);
     30    consideredLines.add(selectedLines[i]);
    3131    }
    3232    else
    3333    {
    3434      for (int i = 0; i < waypointTM.getRowCount(); ++i)
    35         consideredLines.add(new Integer(i));
     35    consideredLines.add(new Integer(i));
    3636    }
    37    
     37
    3838    // keep only lines where a node can be added
    3939    for (int i = 0; i < consideredLines.size(); ++i)
    4040    {
    4141      if (waypointTM.nodes.elementAt(consideredLines.elementAt(i)) == null)
    42         workingLines.add(consideredLines.elementAt(i));
     42    workingLines.add(consideredLines.elementAt(i));
    4343    }
    4444  }
    45  
     45
    4646  public boolean executeCommand()
    4747  {
     
    5252        (waypointTM.coors.elementAt(j), type, (String)waypointTM.getValueAt(j, 1));
    5353      if ("".equals((String)waypointTM.getValueAt(j, 2)))
    54         node.put("shelter", null);
     54    node.put("shelter", null);
    5555      else
    56         node.put("shelter", (String)waypointTM.getValueAt(j, 2));
     56    node.put("shelter", (String)waypointTM.getValueAt(j, 2));
    5757      waypointTM.nodes.set(j, node);
    5858    }
    5959    return true;
    6060  }
    61  
     61
    6262  public void undoCommand()
    6363  {
     
    6868      waypointTM.nodes.set(j, null);
    6969      if (node == null)
    70         continue;
     70    continue;
    7171      Main.main.getCurrentDataSet().removePrimitive(node);
    7272      node.setDeleted(true);
    7373    }
    7474  }
    75  
     75
    7676  public void fillModifiedData
    7777    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    7979  {
    8080  }
    81  
     81
    8282  @Override public JLabel getDescription()
    8383  {
  • applications/editors/josm/plugins/public_transport/src/public_transport/WaypointsNameCommand.java

    r22048 r23192  
    1818  private String oldShelter = null;
    1919  private String shelter = null;
    20  
     20
    2121  public WaypointsNameCommand
    2222      (WaypointTableModel waypointTM, int workingLine, String name, String shelter)
     
    3434      this.shelter = null;
    3535  }
    36  
     36
    3737  public boolean executeCommand()
    3838  {
     
    5454    return true;
    5555  }
    56  
     56
    5757  public void undoCommand()
    5858  {
     
    7373    waypointTM.inEvent = false;
    7474  }
    75  
     75
    7676  public void fillModifiedData
    7777    (Collection< OsmPrimitive > modified, Collection< OsmPrimitive > deleted,
     
    7979  {
    8080  }
    81  
     81
    8282  @Override public JLabel getDescription()
    8383  {
Note: See TracChangeset for help on using the changeset viewer.