diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 367300f..176cedc 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -7,12 +7,17 @@
+
+
+
+
+
+
-
@@ -44,17 +49,17 @@
- {
+ "keyToString": {
+ "Application.Display.executor": "Run",
+ "Application.OurApplication.executor": "Run",
+ "Application.OurLegendArea.executor": "Run",
+ "RunOnceActivity.ShowReadmeOnStart": "true",
+ "git-widget-placeholder": "main",
+ "kotlin-language-version-configured": "true",
+ "last_opened_file_path": "C:/Git/ProjektGraphMain"
}
-}]]>
+}
@@ -187,20 +192,6 @@
-
-
-
- file://$PROJECT_DIR$/OurApplication/OurAlgorithm.java
- 46
-
-
-
- file://$PROJECT_DIR$/OurApplication/OurParameterArea.java
- 142
-
-
-
-
diff --git a/OurApplication/OurAlgorithm.java b/OurApplication/OurAlgorithm.java
index 019a579..f63beb5 100644
--- a/OurApplication/OurAlgorithm.java
+++ b/OurApplication/OurAlgorithm.java
@@ -3,86 +3,81 @@ package OurApplication;
import graph.*;
import logging.Algorithm;
import logging.LogElementList;
-import visualizationElements.Vertex;
-import java.awt.*;
import java.util.Objects;
-import java.util.Random;
-import java.util.Vector;
+
/**
- * This class provides an example for using logging.Algorithm.
- * It sums up integer number starting with 0 up to the maximum value specified in the parameter area.
+ * This class provides an example of using logging.Algorithm.
+ * It implements a summation algorithm that computes the sum of integers starting from 0 up to a specified maximum value from the parameter area.
+ *
* @see Algorithm
- * @author MSch�fer
- * DHBW Stuttgart/Campus Horb AI2008
- *
*/
public class OurAlgorithm extends Algorithm {
private graph.Graph currentGraph;
private OurMethodButtons methodButtons;
+ /**
+ * Standard constructor.
+ * Initializes an instance of OurAlgorithm.
+ */
public OurAlgorithm() {
super();
}
+
/**
- * Creates a sum up algorithm.
- * @param parameterArea the sum up parameter area the algorithm gets its parameters from
+ * Constructs a summation algorithm with parameters from the parameter area.
+ *
+ * @param parameterArea the parameter area providing the selected graph for the algorithm
+ * @param methodButtons the method buttons determining the algorithm type (Dijkstra or A-Star)
*/
- public OurAlgorithm(OurParameterArea parameterArea, OurMethodButtons methodButtons){
- super(parameterArea,"Thema II: Kürzeste Wege");
+ public OurAlgorithm(OurParameterArea parameterArea, OurMethodButtons methodButtons) {
+ super(parameterArea, "Thema II: Kürzeste Wege");
this.methodButtons = methodButtons;
}
-
+
/**
- * Overwritten from super class.
- * Runs the algorithm..
- * Returns the LogElementList produced by the algorithm processing.
- * Adds integer number starting with 0 up to the maximum value.
- * @return a LogElementList containing the algorithm processing single steps
+ * Overridden method from the superclass.
+ * Executes the summation algorithm.
+ * Computes the shortest path in the current graph based on the selected method (Dijkstra or A-Star).
+ *
+ * @return a LogElementList containing the single steps of the algorithm processing
*/
public LogElementList run() {
this.setCurrentGraph(((OurParameterArea) this.getParameterArea()).getSelectedGraph());
-
-
MarkedVertex start = null;
- for (MarkedVertex i: this.currentGraph.getAllVertexes()) {
- if (Objects.equals(i.getName(), "Start")) {
- start = i;
- }
- }
+ for (MarkedVertex i : this.currentGraph.getAllVertexes()) {
+ if (Objects.equals(i.getName(), "Start")) {
+ start = i;
+ }
+ }
MarkedVertex end = null;
- for (MarkedVertex i: this.currentGraph.getAllVertexes()) {
- if (Objects.equals(i.getName(), "Ende")) {
- end = i;
- }
- }
+ for (MarkedVertex i : this.currentGraph.getAllVertexes()) {
+ if (Objects.equals(i.getName(), "Ende")) {
+ end = i;
+ }
+ }
-
- /*Random random = new Random();
-
- MarkedVertex start = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size()));
- MarkedVertex end = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size()));
- System.out.println(start.getName() + " to " + end.getName());*/
-
-
- if(this.methodButtons.getSelectedMethod()){
+ if (this.methodButtons.getSelectedMethod()) {
this.currentGraph.getShortestPathDijkstra(start, end);
- }else{
+ } else {
this.currentGraph.getShortestPathAStar(start, end);
}
return this.currentGraph.getLogList();
}
-
+ /**
+ * Sets the current graph for the algorithm.
+ *
+ * @param graph the graph to be set as the current graph
+ */
public void setCurrentGraph(graph.Graph graph) {
this.currentGraph = graph;
}
}
-
diff --git a/OurApplication/OurApplication.java b/OurApplication/OurApplication.java
index b38ea21..e89517e 100644
--- a/OurApplication/OurApplication.java
+++ b/OurApplication/OurApplication.java
@@ -2,69 +2,68 @@ package OurApplication;
import graph.*;
import logging.LogElementList;
-import visualisation.HybridWindow;
-import visualizationElements.Vertex;
import javax.swing.*;
-import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
-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�fer
- * DHBW Stuttgart/Campus Horb AI2008
- *
+ * Entry point for the OurApplication, demonstrating logging and visualization integration.
+ * This application sets up a graphical interface using Swing components to visualize graphs
+ * and log algorithmic operations.
+ *
+ * @see OurAlgorithm Provides the algorithmic logic for processing graphs.
+ * @see OurDrawArea Displays and interacts with the graph visualization.
+ * @see OurHybridWindow Combines visual components and algorithmic operations.
+ * @see OurLogElement Represents individual logging elements.
+ * @see OurParameterArea Manages parameters for graph operations.
+ * @see OurTextArea Displays log messages and algorithm progress.
+ * @see OurLegendArea Provides legend information for the graphical interface.
+ * @see JPanel Swing panel used in the graphical interface.
*/
public class OurApplication {
/**
- * Standard constructor.
+ * Default constructor for OurApplication.
+ * Initializes the application components and starts the graphical interface.
*/
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){
+ /**
+ * Main method to launch the OurApplication.
+ * Initializes necessary components, creates a graphical window, and starts the application.
+ *
+ * @param args command-line arguments (not used)
+ */
+ public static void main(String[] args){
+
+ // Create a directed graph instance
DirectedGraph myGraph = new DirectedGraph<>();
System.out.println(myGraph.toString());
-
-
+ // Initialize logging elements
LogElementList logList = new LogElementList<>();
+
+ // Create UI components
OurParameterArea parameterArea = new OurParameterArea();
OurMethodButtons methodButtons = new OurMethodButtons();
- OurDrawArea drawArea = new OurDrawArea(logList,"GraphVisualization");
+ OurDrawArea drawArea = new OurDrawArea(logList, "GraphVisualization");
OurTextArea textArea = new OurTextArea(logList);
OurAlgorithm algorithm = new OurAlgorithm(parameterArea, methodButtons);
OurLegendArea legendArea = new OurLegendArea();
- OurHybridWindow applet = new OurHybridWindow<>(drawArea, textArea, parameterArea, algorithm, logList, legendArea, methodButtons);
+ // Create a HybridWindow instance combining all UI components
+ OurHybridWindow applet =
+ new OurHybridWindow<>(drawArea, textArea, parameterArea, algorithm, logList, legendArea, methodButtons);
+
+ // Create and configure the main JFrame
JFrame frame = new JFrame("Visualise");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(applet);
frame.pack();
applet.init();
applet.start();
- frame.setSize(1350,800);
+ frame.setSize(1350, 800);
frame.setVisible(true);
-
}
}
diff --git a/OurApplication/OurDrawArea.java b/OurApplication/OurDrawArea.java
index 9a8b4c1..126d46b 100644
--- a/OurApplication/OurDrawArea.java
+++ b/OurApplication/OurDrawArea.java
@@ -4,154 +4,58 @@ import graph.*;
import logging.LogElementList;
import visualisation.DrawArea;
import visualizationElements.Edge;
-import visualizationElements.Vertex;
-import javax.swing.*;
import java.awt.*;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseListener;
/**
- * This class provides an example for using visualization.DrawArea.
- * @see logging.Algorithm
- @author MSch�fer
- * DHBW Stuttgart/Campus Horb AI2008
- *
+ * This class provides an example for using visualization.DrawArea.
+ * It extends DrawArea to visualize a graph based on logging elements.
+ *
+ * @see DrawArea
*/
-public class OurDrawArea extends DrawArea{
+public class OurDrawArea extends DrawArea {
private static final long serialVersionUID = 1L;
private graph.Graph currentGraph;
-
/**
* Standard constructor.
+ * Initializes an empty draw area.
*/
public OurDrawArea() {
super();
}
-
/**
- * Creates a test draw area and sets the specified log list.
- * @param logList the draw area's log list test log elements.
- * @param drawAreaName The display name over the draw area.
+ * Extended constructor.
+ * Creates a draw area with a specified log list and display name.
+ *
+ * @param logList the draw area's log element list
+ * @param drawAreaName the display name over the draw area
*/
- public OurDrawArea(LogElementList logList, String drawAreaName){
+ public OurDrawArea(LogElementList logList, String drawAreaName) {
super(logList, drawAreaName);
-
- /*
- this.addMouseListener(new MouseListener() {
-
- MarkedVertex temp = null;
-
- @Override
- public void mouseClicked(MouseEvent e) {
- // Linksklick = Einfügen
- if (SwingUtilities.isLeftMouseButton(e)) {
- System.out.println("Left Mouse Clicked at (" + e.getX() + ", " + e.getY() + ")" + e.getPoint());
- if (check(e.getPoint()) == null) {
- addVertex(e.getPoint());
- }
-
- // Rechtsklick = Löschen
- } else if (SwingUtilities.isRightMouseButton(e)) {
- System.out.println("Right Mouse Clicked at (" + e.getX() + ", " + e.getY() + ")");
- if (check(e.getPoint()) != null) {
- removeVertex(check(e.getPoint()));
- }
- }
- }
-
-
- @Override
- public void mousePressed(MouseEvent e) {
- if (check(e.getPoint()) != null) {
- temp = check(e.getPoint());
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent e) {
- if (check(e.getPoint()) != null) {
- addEdge(temp, check(e.getPoint()));
- }
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- }
- });
-
- */
}
-/*
- public void setCurrentGraph(graph.Graph graph) {
- this.currentGraph = graph;
- }
-
- public graph.Graph getCurrentGraph() {
- return this.currentGraph;
- }
-
-
- // TODO Vertex
- private void addVertex(java.awt.Point point) {
- this.currentGraph.addVertex(new MarkedVertex<>(point.x, point.y, "name", new VertexWeightMarking(1), Color.BLACK));
- this.currentGraph.createLoglistElement();
- this.drawStep();
- }
-
- private void removeVertex(MarkedVertex n) {
- this.currentGraph.removeVertex(n);
- this.currentGraph.createLoglistElement();
- this.drawStep();
- }
-
- // TODO Edge
- private void addEdge(MarkedVertex start, MarkedVertex end) {
- this.currentGraph.addEdge(new MarkedEdge<>("", start, end, new EdgeWeightMarking(1)));
- this.currentGraph.createLoglistElement();
- this.drawStep();
- }
-
-
- private MarkedVertex check(java.awt.Point point) {
- for (MarkedVertex i: this.currentGraph.getAllVertexes()) {
- if (isWithinRadius(point.x, point.y, i.getCords()[0], i.getCords()[1], 20)) {
- return i;
- }
- }
- return null;
- }
-
-
- private static boolean isWithinRadius(int clickX, int clickY, int centerX, int centerY, int radius) {
- int deltaX = clickX - centerX;
- int deltaY = clickY - centerY;
- double distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
- return distance <= radius;
- }
-*/
-
/**
- * Draws a visualization element.
+ * Draws visualization elements on the draw area.
+ * @param g the graphics context used for drawing
*/
public void draw(Graphics g) {
-
+ // Get the current log element from the log list
OurLogElement logElement = (OurLogElement) logList.get();
- logElement.getGraph().draw(g);
- for(Edge screenEdge : ((OurLogElement) logList.get()).getGraph().getEdges()){
- g.drawString(screenEdge.getMarking(), (screenEdge.getSource().getXpos() + screenEdge.getDestination().getXpos())/2, (screenEdge.getSource().getYpos() + screenEdge.getDestination().getYpos())/2);
- }
+ // Draw the graph associated with the log element
+ logElement.getGraph().draw(g);
+
+ // Draw markings on edges
+ for (Edge screenEdge : logElement.getGraph().getEdges()) {
+ g.drawString(screenEdge.getMarking(),
+ (screenEdge.getSource().getXpos() + screenEdge.getDestination().getXpos()) / 2,
+ (screenEdge.getSource().getYpos() + screenEdge.getDestination().getYpos()) / 2);
+ }
}
}
diff --git a/OurApplication/OurHybridWindow.java b/OurApplication/OurHybridWindow.java
index 2e76b6d..5279161 100644
--- a/OurApplication/OurHybridWindow.java
+++ b/OurApplication/OurHybridWindow.java
@@ -16,14 +16,19 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
- * This class provides an example for using visualization.HybridWindow.
- * Overwriting the constructor is necessary to run as an applet.
- * For running as an application overwriting the constructor is not necessary
+ * This class provides an example for using visualization.HybridWindow.
+ * It extends HybridWindow to integrate graphical components with algorithmic operations.
+ *
+ * @param Type of the draw area used in the hybrid window.
+ * @param Type of the text area used in the hybrid window.
+ * @param Type of the parameter area used in the hybrid window.
+ * @param Type of the algorithm used in the hybrid window.
+ * @param Type of logging elements used in the hybrid window.
+ * @param