Implemented from scratch part

This commit is contained in:
Arnaud Vergnet 2020-03-25 17:11:34 +01:00
parent 558a665ec0
commit 1ea28ab806
2 changed files with 38 additions and 6 deletions

View file

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

View file

@ -5,6 +5,7 @@ import java.awt.Dimension;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.DataInputStream; import java.io.DataInputStream;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
@ -14,6 +15,7 @@ import org.insa.graphs.gui.drawing.components.BasicDrawing;
import org.insa.graphs.model.Graph; import org.insa.graphs.model.Graph;
import org.insa.graphs.model.Path; import org.insa.graphs.model.Path;
import org.insa.graphs.model.io.BinaryGraphReader; import org.insa.graphs.model.io.BinaryGraphReader;
import org.insa.graphs.model.io.BinaryPathReader;
import org.insa.graphs.model.io.GraphReader; import org.insa.graphs.model.io.GraphReader;
import org.insa.graphs.model.io.PathReader; import org.insa.graphs.model.io.PathReader;
@ -46,28 +48,43 @@ public class Launch {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// Visit these directory to see the list of available files on Commetud. // Visit these directory to see the list of available files on Commetud.
final String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr"; final String mapName = "Maps/insa.mapgr";
final String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path"; final String pathName = "Paths/path_fr31insa_rangueil_r2.path";
// Create a graph reader. // Create a graph reader.
final GraphReader reader = new BinaryGraphReader( final GraphReader reader = new BinaryGraphReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName)))); new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
// TODO: Read the graph. // TODO: Read the graph.
final Graph graph = null; final Graph graph;
try {
graph = reader.read();
} catch (IOException e) {
System.err.println(e);
return;
}
// Create the drawing: // Create the drawing:
final Drawing drawing = createDrawing(); final Drawing drawing;
try {
drawing = createDrawing();
} catch (Exception e) {
System.err.println(e);
return;
}
// TODO: Draw the graph on the drawing. // TODO: Draw the graph on the drawing.
drawing.drawGraph(graph);
// TODO: Create a PathReader. // TODO: Create a PathReader.
final PathReader pathReader = null; final PathReader pathReader = new BinaryPathReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(pathName))));
// TODO: Read the path. // TODO: Read the path.
final Path path = null; final Path path = pathReader.readPath(graph);
// TODO: Draw the path. // TODO: Draw the path.
drawing.drawPath(path);
} }
} }