Create a basic Launch class.

This commit is contained in:
Mikael Capelle 2018-03-13 17:48:54 +01:00
parent 73f1c6bd78
commit 44ae861fb8
2 changed files with 78 additions and 3 deletions

View File

@ -0,0 +1,69 @@
package org.insa.base;
import java.awt.Dimension;
import java.io.BufferedInputStream;
import java.io.DataInputStream;
import java.io.FileInputStream;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import org.insa.graph.Graph;
import org.insa.graph.Path;
import org.insa.graph.io.BinaryGraphReader;
import org.insa.graph.io.GraphReader;
import org.insa.graph.io.PathReader;
import org.insa.graphics.drawing.Drawing;
import org.insa.graphics.drawing.components.BasicDrawing;
public class Launch {
/**
* Create a new Drawing inside a JFrame an return it.
*
* @return The created drawing.
*/
public static Drawing createDrawing() throws Exception {
BasicDrawing basicDrawing = new BasicDrawing();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
JFrame frame = new JFrame("BE Graphes - Launch");
frame.setContentPane(basicDrawing);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(new Dimension(800, 600));
}
});
return basicDrawing;
}
public static void main(String[] args) throws Exception {
// Visit these directory to see the list of available files on Commetud.
String mapName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/Maps/insa.mapgr";
String pathName = "/home/commetud/3eme Annee MIC/Graphes-et-Algorithmes/path/path_fr31insa_rangueil_r2.path";
// Create a graph reader.
GraphReader reader = new BinaryGraphReader(
new DataInputStream(new BufferedInputStream(new FileInputStream(mapName))));
// TODO: Read the graph.
Graph graph = null;
// Create the drawing:
Drawing drawing = createDrawing();
// TODO: Draw the graph on the drawing.
// TODO: Create a PathReader.
PathReader pathReader = null;
// TODO: Read the path.
Path path = null;
// TODO: Draw the path.
}
}

View File

@ -37,6 +37,7 @@ import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.Timer;
import javax.swing.UIManager;
import javax.swing.border.CompoundBorder;
@ -848,9 +849,14 @@ public class MainWindow extends JFrame {
catch (Exception e) {
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
MainWindow w = new MainWindow();
w.setExtendedState(JFrame.MAXIMIZED_BOTH);
w.setVisible(true);
}
});
}
}