use of im.tny.segvault.subway.Transfer in project underlx by underlx.
the class Path method manualExtendEnd.
public void manualExtendEnd(Stop vertex) {
// start by reverting to the path with the end without user-made extensions
int edgesToRemove = 0;
while (manualEntry.get(manualEntry.size() - 1)) {
manualEntry.remove(manualEntry.size() - 1);
times.remove(times.size() - 1);
edgesToRemove++;
}
for (int i = 0; i < edgesToRemove; i++) {
edgeList.remove(edgeList.size() - 1);
}
if (edgeList.size() > 0) {
endVertex = edgeList.get(edgeList.size() - 1).getTarget();
}
// now go from the program-made end
Date time = times.get(times.size() - 1).second;
List<Connection> cs = Route.getShortestPath(graph, endVertex, vertex, new LeastHopsWeighter()).getEdgeList();
int size = cs.size();
for (int i = 0; i < size; i++) {
// the same line)
if (i == size - 1 && cs.get(i) instanceof Transfer) {
this.endVertex = cs.get(i).getSource();
return;
}
times.add(new Pair<Date, Date>(time, time));
manualEntry.add(true);
edgeList.add(cs.get(i));
}
this.endVertex = vertex;
for (OnPathChangedListener l : listeners) {
l.onPathChanged(this);
}
}
Aggregations