|
@@ -5,6 +5,7 @@ import java.awt.Dimension;
|
5
|
5
|
import java.io.BufferedInputStream;
|
6
|
6
|
import java.io.DataInputStream;
|
7
|
7
|
import java.io.FileInputStream;
|
|
8
|
+import java.io.IOException;
|
8
|
9
|
|
9
|
10
|
import javax.swing.JFrame;
|
10
|
11
|
import javax.swing.SwingUtilities;
|
|
@@ -14,6 +15,7 @@ import org.insa.graphs.gui.drawing.components.BasicDrawing;
|
14
|
15
|
import org.insa.graphs.model.Graph;
|
15
|
16
|
import org.insa.graphs.model.Path;
|
16
|
17
|
import org.insa.graphs.model.io.BinaryGraphReader;
|
|
18
|
+import org.insa.graphs.model.io.BinaryPathReader;
|
17
|
19
|
import org.insa.graphs.model.io.GraphReader;
|
18
|
20
|
import org.insa.graphs.model.io.PathReader;
|
19
|
21
|
|
|
@@ -46,28 +48,43 @@ public class Launch {
|
46
|
48
|
public static void main(String[] args) throws Exception {
|
47
|
49
|
|
48
|
50
|
// Visit these directory to see the list of available files on Commetud.
|
49
|
|
- final String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
|
50
|
|
- final String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path";
|
|
51
|
+ final String mapName = "Maps/insa.mapgr";
|
|
52
|
+ final String pathName = "Paths/path_fr31insa_rangueil_r2.path";
|
51
|
53
|
|
52
|
54
|
// Create a graph reader.
|
53
|
55
|
final GraphReader reader = new BinaryGraphReader(
|
54
|
56
|
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
|
55
|
57
|
|
56
|
58
|
// TODO: Read the graph.
|
57
|
|
- final Graph graph = null;
|
|
59
|
+ final Graph graph;
|
|
60
|
+ try {
|
|
61
|
+ graph = reader.read();
|
|
62
|
+ } catch (IOException e) {
|
|
63
|
+ System.err.println(e);
|
|
64
|
+ return;
|
|
65
|
+ }
|
58
|
66
|
|
59
|
67
|
// Create the drawing:
|
60
|
|
- final Drawing drawing = createDrawing();
|
|
68
|
+ final Drawing drawing;
|
|
69
|
+ try {
|
|
70
|
+ drawing = createDrawing();
|
|
71
|
+ } catch (Exception e) {
|
|
72
|
+ System.err.println(e);
|
|
73
|
+ return;
|
|
74
|
+ }
|
61
|
75
|
|
62
|
76
|
// TODO: Draw the graph on the drawing.
|
|
77
|
+ drawing.drawGraph(graph);
|
63
|
78
|
|
64
|
79
|
// TODO: Create a PathReader.
|
65
|
|
- final PathReader pathReader = null;
|
|
80
|
+ final PathReader pathReader = new BinaryPathReader(
|
|
81
|
+ new DataInputStream(new BufferedInputStream(new FileInputStream(pathName))));
|
66
|
82
|
|
67
|
83
|
// TODO: Read the path.
|
68
|
|
- final Path path = null;
|
|
84
|
+ final Path path = pathReader.readPath(graph);
|
69
|
85
|
|
70
|
86
|
// TODO: Draw the path.
|
|
87
|
+ drawing.drawPath(path);
|
71
|
88
|
}
|
72
|
89
|
|
73
|
90
|
}
|