ProjektGraph/OurApplication/OurApplication.java
2024-07-03 19:41:46 +02:00

88 lines
2.7 KiB
Java
Raw Permalink Blame History

package OurApplication;
import graph.*;
import logging.LogElementList;
import visualisation.HybridWindow;
import javax.swing.*;
import java.awt.*;
import java.util.Random;
/**
* This application provides an example for using logging and visualization packages.
* It uses extended classes from logging and visualization.
* @see OurAlgorithm
* @see OurApplication
* @see OurDrawArea
* @see OurHybridWindow
* @see OurLogElement
* @see OurParameterArea
* @see OurTextArea
* @see OurLegendArea
* @see JPanel
* @author MSch<63>fer
* DHBW Stuttgart/Campus Horb AI2008<br>
* <br>
*/
public class OurApplication {
/**
* Standard constructor.
*/
public OurApplication() {
super();
}
/**
* The applications main method.
* Creates a HybridWindow with TestParameterArea, TestLegendArea ,TestDrawArea, TestTextArea and TestAlgorithm and starts it.
* @param args
*/
public static void main(String[]args){
LogElementList<OurLogElement>logList = new LogElementList<OurLogElement>();
OurParameterArea parameterArea = new OurParameterArea();
OurDrawArea drawArea = new OurDrawArea(logList,"GraphVisualization");
OurTextArea textArea = new OurTextArea(logList);
OurAlgorithm algorithm = new OurAlgorithm(parameterArea);
OurLegendArea legendArea = new OurLegendArea();
HybridWindow<OurDrawArea, OurTextArea, OurParameterArea, OurAlgorithm, OurLogElement, OurLegendArea> applet = new HybridWindow<OurDrawArea, OurTextArea, OurParameterArea, OurAlgorithm, OurLogElement, OurLegendArea>(drawArea, textArea, parameterArea, algorithm, logList, legendArea);
JFrame frame = new JFrame("Visualise");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.pack();
applet.init();
applet.start();
frame.setSize(800,600);
frame.setVisible(true);
Random random = new Random();
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
for (int i = 0; i < 10; i++) {
myGraph.addVertex(new MarkedVertex<>(random.nextInt(1, 10)*40, random.nextInt(1, 10)*40, Integer.toString(i), null, Color.BLACK));
}
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
/*
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
*/
System.out.println(myGraph.toString());
drawArea.setCurrentGraph(myGraph);
algorithm.setCurrentGraph(myGraph);
}
}