Add getNodes() and getSuccessors() methods and remove iterable from Graph and Node.

This commit is contained in:
Mikaël Capelle
2019-03-18 20:05:49 +01:00
parent 71a0085d59
commit d8470055f1
8 changed files with 91 additions and 83 deletions

View File

@@ -65,7 +65,7 @@ public class NodesInputPanel extends JPanel
public Node findClosestNode(Point point) {
Node minNode = null;
double minDis = Double.POSITIVE_INFINITY;
for (Node node: graph) {
for (Node node: graph.getNodes()) {
double dlon = point.getLongitude() - node.getPoint().getLongitude();
double dlat = point.getLatitude() - node.getPoint().getLatitude();
double dis = dlon * dlon + dlat * dlat; // No need to square

View File

@@ -679,8 +679,8 @@ public class BasicDrawing extends JPanel implements Drawing {
this.removeMouseMotionListener(zoomAndPanListener);
this.removeMouseWheelListener(zoomAndPanListener);
for (Node node: graph) {
for (Arc arc: node) {
for (Node node: graph.getNodes()) {
for (Arc arc: node.getSuccessors()) {
// Draw arcs only if there are one-way arcs or if origin is lower than
// destination, avoid drawing two-ways arc twice.
if (arc.getRoadInformation().isOneWay()