Browse Source

Implemented from scratch part

Arnaud Vergnet 4 years ago
parent
commit
1ea28ab806

+ 15
- 0
.idea/runConfigurations/Main_no_UI.xml View File

@@ -0,0 +1,15 @@
1
+<component name="ProjectRunConfigurationManager">
2
+  <configuration default="false" name="Main no UI" type="Application" factoryName="Application">
3
+    <option name="MAIN_CLASS_NAME" value="org.insa.graphs.gui.simple.Launch" />
4
+    <module name="be-graphes-gui" />
5
+    <extension name="coverage">
6
+      <pattern>
7
+        <option name="PATTERN" value="org.insa.graphs.gui.simple.*" />
8
+        <option name="ENABLED" value="true" />
9
+      </pattern>
10
+    </extension>
11
+    <method v="2">
12
+      <option name="Make" enabled="true" />
13
+    </method>
14
+  </configuration>
15
+</component>

+ 23
- 6
be-graphes-gui/src/main/java/org/insa/graphs/gui/simple/Launch.java View File

@@ -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
 }

Loading…
Cancel
Save