Dépôt du be graphe
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Launch.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. package org.insa.graphs.gui.simple;
  2. import java.awt.BorderLayout;
  3. import java.awt.Dimension;
  4. import java.io.BufferedInputStream;
  5. import java.io.DataInputStream;
  6. import java.io.FileInputStream;
  7. import javax.swing.JFrame;
  8. import javax.swing.SwingUtilities;
  9. import org.insa.graphs.gui.drawing.Drawing;
  10. import org.insa.graphs.gui.drawing.components.BasicDrawing;
  11. import org.insa.graphs.model.Graph;
  12. import org.insa.graphs.model.Path;
  13. import org.insa.graphs.model.io.BinaryGraphReader;
  14. import org.insa.graphs.model.io.GraphReader;
  15. import org.insa.graphs.model.io.PathReader;
  16. public class Launch {
  17. //Adrien BARBANSON - 25 mars 2021
  18. /**
  19. * Create a new Drawing inside a JFrame an return it.
  20. *
  21. * @return The created drawing.
  22. *
  23. * @throws Exception if something wrong happens when creating the graph.
  24. */
  25. public static Drawing createDrawing() throws Exception {
  26. BasicDrawing basicDrawing = new BasicDrawing();
  27. SwingUtilities.invokeAndWait(new Runnable() {
  28. @Override
  29. public void run() {
  30. JFrame frame = new JFrame("BE Graphes - Launch");
  31. frame.setLayout(new BorderLayout());
  32. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  33. frame.setVisible(true);
  34. frame.setSize(new Dimension(800, 600));
  35. frame.setContentPane(basicDrawing);
  36. frame.validate();
  37. }
  38. });
  39. return basicDrawing;
  40. }
  41. public static void main(String[] args) throws Exception {
  42. // Visit these directory to see the list of available files on Commetud.
  43. final String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
  44. final String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Paths/path_fr31insa_rangueil_r2.path";
  45. // Create a graph reader.
  46. final GraphReader reader = new BinaryGraphReader(
  47. new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
  48. // TODO: Read the graph.
  49. final Graph graph = null;
  50. // Create the drawing:
  51. final Drawing drawing = createDrawing();
  52. // TODO: Draw the graph on the drawing.
  53. // TODO: Create a PathReader.
  54. final PathReader pathReader = null;
  55. // TODO: Read the path.
  56. final Path path = null;
  57. // TODO: Draw the path.
  58. }
  59. }