Remove access to underlying containers inside Graph and Node.
This commit is contained in:
@@ -602,8 +602,8 @@ public class MainWindow extends JFrame {
|
||||
// name that are right-to-left (e.g. arabic names).
|
||||
info += " - " + graph.getMapName() + "\u200e";
|
||||
}
|
||||
info += ", " + graph.getNodes().size() + " nodes, "
|
||||
+ graph.getGraphInformation().getArcCount() + " arcs.";
|
||||
info += ", " + graph.size() + " nodes, " + graph.getGraphInformation().getArcCount()
|
||||
+ " arcs.";
|
||||
graphInfoPanel.setText(info);
|
||||
|
||||
drawGraph();
|
||||
|
@@ -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.getNodes()) {
|
||||
for (Node node: graph) {
|
||||
double dlon = point.getLongitude() - node.getPoint().getLongitude();
|
||||
double dlat = point.getLatitude() - node.getPoint().getLatitude();
|
||||
double dis = dlon * dlon + dlat * dlat; // No need to square
|
||||
@@ -308,7 +308,7 @@ public class NodesInputPanel extends JPanel
|
||||
*/
|
||||
protected Node getNodeForInput(JTextField textfield) {
|
||||
try {
|
||||
Node node = graph.getNodes().get(Integer.valueOf(textfield.getText().trim()));
|
||||
Node node = graph.get(Integer.valueOf(textfield.getText().trim()));
|
||||
return node;
|
||||
}
|
||||
catch (IllegalArgumentException | IndexOutOfBoundsException ex) {
|
||||
|
@@ -614,7 +614,7 @@ public class BasicDrawing extends JPanel implements Drawing {
|
||||
|
||||
@Override
|
||||
public void drawGraph(Graph graph, GraphPalette palette) {
|
||||
int repaintModulo = Math.max(1, graph.getNodes().size() / 100);
|
||||
int repaintModulo = Math.max(1, graph.size() / 100);
|
||||
|
||||
// Initialize the buffered image
|
||||
|
||||
@@ -625,8 +625,8 @@ public class BasicDrawing extends JPanel implements Drawing {
|
||||
this.removeMouseMotionListener(zoomAndPanListener);
|
||||
this.removeMouseWheelListener(zoomAndPanListener);
|
||||
|
||||
for (Node node: graph.getNodes()) {
|
||||
for (Arc arc: node.getSuccessors()) {
|
||||
for (Node node: graph) {
|
||||
for (Arc arc: node) {
|
||||
// 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()
|
||||
|
Reference in New Issue
Block a user