Changeset 30358 in osm


Ignore:
Timestamp:
2014-03-24T22:26:05+01:00 (11 years ago)
Author:
donvip
Message:

[josm_public_transport] code cleanup

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

Legend:

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

    r28318 r30358  
    9393                if (knownDistance == null || distance < knownDistance.doubleValue())
    9494                {
    95                     openList.put(edge.getEnd(), distance);
     95            openList.put(edge.getEnd(), distance);
    9696                    pathTail.put(edge.getEnd(), edge);
    9797                }
  • applications/editors/josm/plugins/public_transport/src/public_transport/StopImporterAction.java

    r29859 r30358  
    171171        is = new FileInputStream(file);
    172172      // Workaround for SAX BOM bug
    173       // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6206835
     173      // https://bugs.openjdk.java.net/browse/JDK-6206835
    174174      if (!((is.read() == 0xef) && (is.read() == 0xbb) && (is.read() == 0xbf)))
    175175      {
  • applications/editors/josm/plugins/public_transport/src/public_transport/TrackStoplistNameCommand.java

    r29861 r30358  
    1111
    1212public class TrackStoplistNameCommand extends Command {
    13         private int workingLine = 0;
    14         private TrackReference trackref = null;
    15         private String oldName = null;
    16         private String name = null;
    17         private String oldTime = null;
    18         private String time = null;
    19         private String oldShelter = null;
    20         private TransText shelter = null;
    21         private LatLon oldLatLon = null;
     13    private int workingLine = 0;
     14    private TrackReference trackref = null;
     15    private String oldName = null;
     16    private String name = null;
     17    private String oldTime = null;
     18    private String time = null;
     19    private String oldShelter = null;
     20    private TransText shelter = null;
     21    private LatLon oldLatLon = null;
    2222
    23         public TrackStoplistNameCommand(TrackReference trackref, int workingLine) {
    24                 this.trackref = trackref;
    25                 this.workingLine = workingLine;
    26                 Node node = trackref.stoplistTM.nodeAt(workingLine);
    27                 if (node != null) {
    28                         oldName = node.get("name");
    29                         oldTime = trackref.stoplistTM.timeAt(workingLine);
    30                         oldShelter = node.get("shelter");
    31                         oldLatLon = node.getCoor();
    32                 }
    33                 this.time = (String) trackref.stoplistTM.getValueAt(workingLine, 0);
    34                 this.name = (String) trackref.stoplistTM.getValueAt(workingLine, 1);
    35                 this.shelter = (TransText) trackref.stoplistTM.getValueAt(workingLine, 2);
    36                 if ("".equals(this.shelter.text))
    37                         this.shelter = null;
    38         }
     23    public TrackStoplistNameCommand(TrackReference trackref, int workingLine) {
     24        this.trackref = trackref;
     25        this.workingLine = workingLine;
     26        Node node = trackref.stoplistTM.nodeAt(workingLine);
     27        if (node != null) {
     28            oldName = node.get("name");
     29            oldTime = trackref.stoplistTM.timeAt(workingLine);
     30            oldShelter = node.get("shelter");
     31            oldLatLon = node.getCoor();
     32        }
     33        this.time = (String) trackref.stoplistTM.getValueAt(workingLine, 0);
     34        this.name = (String) trackref.stoplistTM.getValueAt(workingLine, 1);
     35        this.shelter = (TransText) trackref.stoplistTM.getValueAt(workingLine, 2);
     36        if ("".equals(this.shelter.text))
     37            this.shelter = null;
     38    }
    3939
    40         public boolean executeCommand() {
    41                 Node node = trackref.stoplistTM.nodeAt(workingLine);
    42                 if (node != null) {
    43                         node.put("name", name);
    44                         node.put("shelter", shelter.text);
    45                         double dTime = StopImporterDialog.parseTime(time);
    46                         node.setCoor(trackref.computeCoor(dTime));
    47                 }
    48                 trackref.inEvent = true;
    49                 if (time == null)
    50                         trackref.stoplistTM.setValueAt("", workingLine, 0);
    51                 else
    52                         trackref.stoplistTM.setValueAt(time, workingLine, 0);
    53                 if (name == null)
    54                         trackref.stoplistTM.setValueAt("", workingLine, 1);
    55                 else
    56                         trackref.stoplistTM.setValueAt(name, workingLine, 1);
    57                 trackref.stoplistTM.setValueAt(shelter, workingLine, 2);
    58                 trackref.inEvent = false;
    59                 return true;
    60         }
     40    public boolean executeCommand() {
     41        Node node = trackref.stoplistTM.nodeAt(workingLine);
     42        if (node != null) {
     43            node.put("name", name);
     44            node.put("shelter", shelter.text);
     45            double dTime = StopImporterDialog.parseTime(time);
     46            node.setCoor(trackref.computeCoor(dTime));
     47        }
     48        trackref.inEvent = true;
     49        if (time == null)
     50            trackref.stoplistTM.setValueAt("", workingLine, 0);
     51        else
     52            trackref.stoplistTM.setValueAt(time, workingLine, 0);
     53        if (name == null)
     54            trackref.stoplistTM.setValueAt("", workingLine, 1);
     55        else
     56            trackref.stoplistTM.setValueAt(name, workingLine, 1);
     57        trackref.stoplistTM.setValueAt(shelter, workingLine, 2);
     58        trackref.inEvent = false;
     59        return true;
     60    }
    6161
    62         public void undoCommand() {
    63                 Node node = trackref.stoplistTM.nodeAt(workingLine);
    64                 if (node != null) {
    65                         node.put("name", oldName);
    66                         node.put("shelter", oldShelter);
    67                         node.setCoor(oldLatLon);
    68                 }
    69                 trackref.inEvent = true;
    70                 if (oldTime == null)
    71                         trackref.stoplistTM.setValueAt("", workingLine, 0);
    72                 else
    73                         trackref.stoplistTM.setValueAt(oldTime, workingLine, 0);
    74                 if (oldName == null)
    75                         trackref.stoplistTM.setValueAt("", workingLine, 1);
    76                 else
    77                         trackref.stoplistTM.setValueAt(oldName, workingLine, 1);
    78                 trackref.stoplistTM.setValueAt(new TransText(oldShelter), workingLine, 2);
    79                 trackref.inEvent = false;
    80         }
     62    public void undoCommand() {
     63        Node node = trackref.stoplistTM.nodeAt(workingLine);
     64        if (node != null) {
     65            node.put("name", oldName);
     66            node.put("shelter", oldShelter);
     67            node.setCoor(oldLatLon);
     68        }
     69        trackref.inEvent = true;
     70        if (oldTime == null)
     71            trackref.stoplistTM.setValueAt("", workingLine, 0);
     72        else
     73            trackref.stoplistTM.setValueAt(oldTime, workingLine, 0);
     74        if (oldName == null)
     75            trackref.stoplistTM.setValueAt("", workingLine, 1);
     76        else
     77            trackref.stoplistTM.setValueAt(oldName, workingLine, 1);
     78        trackref.stoplistTM.setValueAt(new TransText(oldShelter), workingLine, 2);
     79        trackref.inEvent = false;
     80    }
    8181
    82         public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
    83                         Collection<OsmPrimitive> added) {
    84         }
     82    public void fillModifiedData(Collection<OsmPrimitive> modified, Collection<OsmPrimitive> deleted,
     83            Collection<OsmPrimitive> added) {
     84    }
    8585
    86         @Override
    87         public String getDescriptionText() {
    88                 return tr("Public Transport: Edit track stop list");
    89         }
     86    @Override
     87    public String getDescriptionText() {
     88        return tr("Public Transport: Edit track stop list");
     89    }
    9090};
Note: See TracChangeset for help on using the changeset viewer.