Compare commits
No commits in common. "4b59b88688ffd6d01f6c5d081e4fc726a35406ed" and "0be3b82e7b170dea61a52611c9c5f8165df80c33" have entirely different histories.
4b59b88688
...
0be3b82e7b
41
.idea/workspace.xml
generated
41
.idea/workspace.xml
generated
@ -7,17 +7,12 @@
|
||||
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="Weighting gefixt">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurApplication.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurHybridWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurHybridWindow.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurLegendArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLegendArea.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurLogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurMethodButtons.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurMethodButtons.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurTextArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurTextArea.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurAlgorithm.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurAlgorithm.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurApplication.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurApplication.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurDrawArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurDrawArea.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurParameterArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurParameterArea.class" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -49,17 +44,17 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent">{
|
||||
"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"
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"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"
|
||||
}
|
||||
}</component>
|
||||
}]]></component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Git\ProjektGraph" />
|
||||
@ -192,6 +187,20 @@
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Weighting gefixt" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/OurApplication/OurAlgorithm.java</url>
|
||||
<line>46</line>
|
||||
<option name="timeStamp" value="6" />
|
||||
</line-breakpoint>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/OurApplication/OurParameterArea.java</url>
|
||||
<line>142</line>
|
||||
<option name="timeStamp" value="7" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<watches-manager>
|
||||
<configuration name="Application">
|
||||
<watch expression="newGraph.screenGraph" />
|
||||
|
@ -3,81 +3,86 @@ 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 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.
|
||||
*
|
||||
* 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.
|
||||
* @see Algorithm
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurAlgorithm extends Algorithm {
|
||||
|
||||
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||
private OurMethodButtons methodButtons;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Initializes an instance of OurAlgorithm.
|
||||
*/
|
||||
public OurAlgorithm() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
* Creates a sum up algorithm.
|
||||
* @param parameterArea the sum up parameter area the algorithm gets its parameters from
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
public LogElementList<OurLogElement> run() {
|
||||
|
||||
this.setCurrentGraph(((OurParameterArea) this.getParameterArea()).getSelectedGraph());
|
||||
|
||||
|
||||
|
||||
MarkedVertex<VertexMarking> start = null;
|
||||
for (MarkedVertex<VertexMarking> i : this.currentGraph.getAllVertexes()) {
|
||||
for (MarkedVertex<VertexMarking> i: this.currentGraph.getAllVertexes()) {
|
||||
if (Objects.equals(i.getName(), "Start")) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
|
||||
MarkedVertex<VertexMarking> end = null;
|
||||
for (MarkedVertex<VertexMarking> i : this.currentGraph.getAllVertexes()) {
|
||||
for (MarkedVertex<VertexMarking> i: this.currentGraph.getAllVertexes()) {
|
||||
if (Objects.equals(i.getName(), "Ende")) {
|
||||
end = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.methodButtons.getSelectedMethod()) {
|
||||
|
||||
/*Random random = new Random();
|
||||
|
||||
MarkedVertex<VertexMarking> start = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size()));
|
||||
MarkedVertex<VertexMarking> end = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size()));
|
||||
System.out.println(start.getName() + " to " + end.getName());*/
|
||||
|
||||
|
||||
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<VertexMarking, EdgeMarking> graph) {
|
||||
this.currentGraph = graph;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2,68 +2,69 @@ 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;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* 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<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurApplication {
|
||||
|
||||
/**
|
||||
* Default constructor for OurApplication.
|
||||
* Initializes the application components and starts the graphical interface.
|
||||
* Standard constructor.
|
||||
*/
|
||||
public OurApplication() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Main method to launch the OurApplication.
|
||||
* Initializes necessary components, creates a graphical window, and starts the application.
|
||||
*
|
||||
* @param args command-line arguments (not used)
|
||||
* 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){
|
||||
public static void main(String[]args){
|
||||
|
||||
// Create a directed graph instance
|
||||
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
||||
System.out.println(myGraph.toString());
|
||||
|
||||
// Initialize logging elements
|
||||
LogElementList<OurLogElement> logList = new LogElementList<>();
|
||||
|
||||
// Create UI components
|
||||
|
||||
LogElementList<OurLogElement> logList = new LogElementList<>();
|
||||
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<OurDrawArea, OurTextArea, OurParameterArea, OurAlgorithm, OurLogElement, OurLegendArea, OurMethodButtons> applet = new OurHybridWindow<>(drawArea, textArea, parameterArea, algorithm, logList, legendArea, methodButtons);
|
||||
|
||||
// Create a HybridWindow instance combining all UI components
|
||||
OurHybridWindow<OurDrawArea, OurTextArea, OurParameterArea, OurAlgorithm, OurLogElement, OurLegendArea, OurMethodButtons> 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -4,58 +4,154 @@ 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.
|
||||
* It extends DrawArea to visualize a graph based on logging elements.
|
||||
*
|
||||
* @see DrawArea
|
||||
* @see logging.Algorithm
|
||||
@author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurDrawArea extends DrawArea {
|
||||
public class OurDrawArea extends DrawArea{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Initializes an empty draw area.
|
||||
*/
|
||||
public OurDrawArea() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<OurLogElement> logList, String drawAreaName) {
|
||||
super(logList, drawAreaName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws visualization elements on the draw area.
|
||||
* @param g the graphics context used for drawing
|
||||
* 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.
|
||||
*/
|
||||
public OurDrawArea(LogElementList<OurLogElement> logList, String drawAreaName){
|
||||
super(logList, drawAreaName);
|
||||
|
||||
/*
|
||||
this.addMouseListener(new MouseListener() {
|
||||
|
||||
MarkedVertex<VertexMarking> 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<VertexMarking, EdgeMarking> graph) {
|
||||
this.currentGraph = graph;
|
||||
}
|
||||
|
||||
public graph.Graph<VertexMarking, EdgeMarking> 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<VertexMarking> n) {
|
||||
this.currentGraph.removeVertex(n);
|
||||
this.currentGraph.createLoglistElement();
|
||||
this.drawStep();
|
||||
}
|
||||
|
||||
// TODO Edge
|
||||
private void addEdge(MarkedVertex<VertexMarking> start, MarkedVertex<VertexMarking> end) {
|
||||
this.currentGraph.addEdge(new MarkedEdge<>("", start, end, new EdgeWeightMarking(1)));
|
||||
this.currentGraph.createLoglistElement();
|
||||
this.drawStep();
|
||||
}
|
||||
|
||||
|
||||
private MarkedVertex<graph.VertexMarking> check(java.awt.Point point) {
|
||||
for (MarkedVertex<graph.VertexMarking> 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.
|
||||
*/
|
||||
public void draw(Graphics g) {
|
||||
// Get the current log element from the log list
|
||||
|
||||
OurLogElement logElement = (OurLogElement) logList.get();
|
||||
|
||||
// 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);
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,18 +17,13 @@ import java.awt.event.ItemListener;
|
||||
|
||||
/**
|
||||
* This class provides an example for using visualization.HybridWindow.
|
||||
* It extends HybridWindow to integrate graphical components with algorithmic operations.
|
||||
*
|
||||
* @param <DRAW> Type of the draw area used in the hybrid window.
|
||||
* @param <TEXT> Type of the text area used in the hybrid window.
|
||||
* @param <PARAM> Type of the parameter area used in the hybrid window.
|
||||
* @param <ALGORITHM> Type of the algorithm used in the hybrid window.
|
||||
* @param <LOG> Type of logging elements used in the hybrid window.
|
||||
* @param <LEGEND> Type of legend area used in the hybrid window.
|
||||
* @param <METHODBUTTONS> Type of method buttons used in the hybrid window.
|
||||
*
|
||||
* Overwriting the constructor is necessary to run as an applet.
|
||||
* For running as an application overwriting the constructor is not necessary
|
||||
* @see HybridWindow
|
||||
* @see OurApplication
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurHybridWindow<DRAW extends DrawArea,
|
||||
TEXT extends TextArea,
|
||||
@ -36,7 +31,7 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
ALGORITHM extends Algorithm,
|
||||
LOG extends LogElement,
|
||||
LEGEND extends LegendArea,
|
||||
METHODBUTTONS extends ParameterArea> extends HybridWindow {
|
||||
METHODBUTTONS extends ParameterArea> extends HybridWindow{
|
||||
|
||||
protected METHODBUTTONS methodButtons;
|
||||
protected StartListener startListener;
|
||||
@ -63,78 +58,69 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
|
||||
/**
|
||||
* Overwritten standard constructor.
|
||||
* Creates a HybridWindow with specified draw area, text area, parameter area,
|
||||
* algorithm, log list, legend area, and method buttons.
|
||||
*
|
||||
* @param drawArea the draw area used in the hybrid window
|
||||
* @param textArea the text area used in the hybrid window
|
||||
* @param parameterArea the parameter area used in the hybrid window
|
||||
* @param algorithm the algorithm used in the hybrid window
|
||||
* @param logList the log element list used in the hybrid window
|
||||
* @param legendArea the legend area used in the hybrid window
|
||||
* @param methodButtons the method buttons used in the hybrid window
|
||||
* Creates a TestUpHybridWindow with
|
||||
* TestParameterArea,SumUpLegendArea, TestDrawArea, TestTextArea,
|
||||
* TestAlgorithm and a LogElementList of TestLogElements.
|
||||
*/
|
||||
public OurHybridWindow(DRAW drawArea, TEXT textArea, PARAM parameterArea, ALGORITHM algorithm,
|
||||
LogElementList<LOG> logList, LEGEND legendArea, METHODBUTTONS methodButtons) {
|
||||
public OurHybridWindow() {
|
||||
super();
|
||||
}
|
||||
public OurHybridWindow(DRAW drawArea, TEXT textArea, PARAM parameterArea, ALGORITHM algorithm, LogElementList<LOG>logList, LEGEND legendArea, METHODBUTTONS methodButtons) {
|
||||
super(drawArea, textArea, parameterArea, algorithm, logList, legendArea);
|
||||
this.methodButtons = methodButtons;
|
||||
}
|
||||
public void init(){
|
||||
startButton=new JButton("start");
|
||||
stopButton=new JButton("stop");
|
||||
nextButton=new JButton("next");
|
||||
prevButton=new JButton("prev");
|
||||
lastButton=new JButton("last");
|
||||
firstButton=new JButton("first");
|
||||
autoButton=new JToggleButton("automatc");
|
||||
autoSlider=new JSlider(1,100,1);
|
||||
autoForwardButton=new JRadioButton("forward");
|
||||
autoBackwardButton=new JRadioButton("backward");
|
||||
pauseButton=new JButton("pause");
|
||||
|
||||
/**
|
||||
* Initializes the hybrid window by setting up UI components and event listeners.
|
||||
*/
|
||||
public void init() {
|
||||
startButton = new JButton("start");
|
||||
stopButton = new JButton("stop");
|
||||
nextButton = new JButton("next");
|
||||
prevButton = new JButton("prev");
|
||||
lastButton = new JButton("last");
|
||||
firstButton = new JButton("first");
|
||||
autoButton = new JToggleButton("automatic");
|
||||
autoSlider = new JSlider(1, 100, 1);
|
||||
autoForwardButton = new JRadioButton("forward");
|
||||
autoBackwardButton = new JRadioButton("backward");
|
||||
pauseButton = new JButton("pause");
|
||||
|
||||
ButtonGroup autoDirection = new ButtonGroup();
|
||||
ButtonGroup autoDirection=new ButtonGroup();
|
||||
autoDirection.add(autoForwardButton);
|
||||
autoDirection.add(autoBackwardButton);
|
||||
autoForwardButton.setSelected(true);
|
||||
|
||||
JPanel panelStartStopControls = new JPanel();
|
||||
panelStartStopControls.setLayout(new GridLayout(4, 1, 5, 5));
|
||||
JPanel panelStartStopControls=new JPanel();
|
||||
panelStartStopControls.setLayout(new GridLayout(4,1,5,5));
|
||||
panelStartStopControls.add(startButton);
|
||||
panelStartStopControls.add(stopButton);
|
||||
panelStartStopControls.add(pauseButton);
|
||||
panelStartStopControls.add(methodButtons);
|
||||
panelStartStopControls.setBorder(BorderFactory.createTitledBorder("Start / Stop"));
|
||||
|
||||
JPanel panelStepwiseExecutionControls = new JPanel();
|
||||
panelStepwiseExecutionControls.setLayout(new GridLayout(4, 1, 5, 5));
|
||||
JPanel panelStepwiseExecutionControls=new JPanel();
|
||||
panelStepwiseExecutionControls.setLayout(new GridLayout(4,1,5,5));
|
||||
panelStepwiseExecutionControls.add(firstButton);
|
||||
panelStepwiseExecutionControls.add(nextButton);
|
||||
panelStepwiseExecutionControls.add(prevButton);
|
||||
panelStepwiseExecutionControls.add(lastButton);
|
||||
panelStepwiseExecutionControls.setBorder(BorderFactory.createTitledBorder("Stepwise execution"));
|
||||
|
||||
JPanel panelAutomaticExecutionControls = new JPanel();
|
||||
panelAutomaticExecutionControls.setLayout(new GridLayout(5, 1, 5, 5));
|
||||
JPanel panelAutomaticExecutionControls=new JPanel();
|
||||
panelAutomaticExecutionControls.setLayout(new GridLayout(5,1,5,5));
|
||||
panelAutomaticExecutionControls.add(autoButton);
|
||||
panelAutomaticExecutionControls.add(autoSlider);
|
||||
panelAutomaticExecutionControls.add(autoForwardButton);
|
||||
panelAutomaticExecutionControls.add(autoBackwardButton);
|
||||
panelAutomaticExecutionControls.setBorder(BorderFactory.createTitledBorder("Automatic execution"));
|
||||
|
||||
JPanel buttonLine = new JPanel();
|
||||
buttonLine.setLayout(new GridLayout(3, 1, 5, 5));
|
||||
buttonLine.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
JPanel buttonLine=new JPanel();
|
||||
buttonLine.setLayout(new GridLayout(3,1,5,5));
|
||||
buttonLine.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
buttonLine.add(panelStartStopControls);
|
||||
buttonLine.add(panelStepwiseExecutionControls);
|
||||
buttonLine.add(panelAutomaticExecutionControls);
|
||||
|
||||
JLabel headline = new JLabel(algorithm.getTitle());
|
||||
headline.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||
headline.setFont(new Font("SansSerif", Font.PLAIN, 20));
|
||||
JLabel headline=new JLabel(algorithm.getTitle());
|
||||
headline.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
||||
headline.setFont(new Font("SansSerif",Font.PLAIN,20));
|
||||
|
||||
JScrollPane parameterAreaScrollPane = parameterArea.getScrollPane();
|
||||
JScrollPane legendAreaScrollPane = legendArea.getScrollPane();
|
||||
@ -142,33 +128,33 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
parameterAreaScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
legendAreaScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
|
||||
JSplitPane hybridWindowSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, parameterAreaScrollPane, legendAreaScrollPane);
|
||||
JSplitPane hybridWindowSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,parameterAreaScrollPane, legendAreaScrollPane);
|
||||
hybridWindowSplitPane.setOneTouchExpandable(true);
|
||||
hybridWindowSplitPane.setResizeWeight(0.465);
|
||||
tabbedPane.insertTab(drawArea.getDrawAreaName(), null, drawArea.getScrollPane(), drawArea.getDrawAreaName(), 0);
|
||||
tabbedPane.insertTab(drawArea.getDrawAreaName(),null, drawArea.getScrollPane(),drawArea.getDrawAreaName(),0);
|
||||
tabbedPane.setSelectedIndex(0);
|
||||
|
||||
setLayout(new BorderLayout(10, 10));
|
||||
setLayout(new BorderLayout(10,10));
|
||||
|
||||
add(headline, BorderLayout.NORTH);
|
||||
add(hybridWindowSplitPane, BorderLayout.WEST);
|
||||
add(tabbedPane, BorderLayout.CENTER);
|
||||
add(textArea.getScrollPane(), BorderLayout.SOUTH);
|
||||
add(buttonLine, BorderLayout.EAST);
|
||||
add(headline,BorderLayout.NORTH);
|
||||
add(hybridWindowSplitPane,BorderLayout.WEST);
|
||||
add(tabbedPane,BorderLayout.CENTER);
|
||||
add(textArea.getScrollPane(),BorderLayout.SOUTH);
|
||||
add(buttonLine,BorderLayout.EAST);
|
||||
|
||||
setState(PARAMETERSTATE);
|
||||
|
||||
startListener = new StartListener();
|
||||
stopListener = new StopListener();
|
||||
prevListener = new PrevListener();
|
||||
nextListener = new NextListener();
|
||||
firstListener = new FirstListener();
|
||||
lastListener = new LastListener();
|
||||
autoButtonListener = new AutoButtonListener();
|
||||
autoSliderListener = new AutoSliderListener();
|
||||
autoForwardListener = new AutoForwardListener();
|
||||
autoBackwardListener = new AutoBackwardListener();
|
||||
pauseButtonListener = new PauseButtonListener();
|
||||
startListener= new StartListener();
|
||||
stopListener=new StopListener();
|
||||
prevListener=new PrevListener();
|
||||
nextListener=new NextListener();
|
||||
firstListener=new FirstListener();
|
||||
lastListener=new LastListener();
|
||||
autoButtonListener=new AutoButtonListener();
|
||||
autoSliderListener=new AutoSliderListener();
|
||||
autoForwardListener=new AutoForwardListener();
|
||||
autoBackwardListener=new AutoBackwardListener();
|
||||
pauseButtonListener=new PauseButtonListener();
|
||||
|
||||
startButton.addActionListener(startListener);
|
||||
stopButton.addActionListener(stopListener);
|
||||
@ -182,33 +168,27 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
autoBackwardButton.addItemListener(autoBackwardListener);
|
||||
pauseButton.addActionListener(pauseButtonListener);
|
||||
|
||||
autoTimer = new Timer(1, nextListener);
|
||||
autoTimer=new Timer(1,nextListener);
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for starting the algorithm.
|
||||
*/
|
||||
class StartListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
Component[] bComponents = methodButtons.getComponents();
|
||||
class StartListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
Component[]bComponents=methodButtons.getComponents();
|
||||
setState(RUNSTATE);
|
||||
for (Component c : bComponents) {
|
||||
for(Component c:bComponents){
|
||||
c.setEnabled(false);
|
||||
}
|
||||
logList = algorithm.run();
|
||||
logList=algorithm.run();
|
||||
drawArea.setLogList(logList);
|
||||
textArea.setLogList(logList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for stopping the algorithm.
|
||||
*/
|
||||
class StopListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
Component[] bComponents = methodButtons.getComponents();
|
||||
class StopListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
Component[]bComponents=methodButtons.getComponents();
|
||||
setState(PARAMETERSTATE);
|
||||
for (Component c : bComponents) {
|
||||
for(Component c:bComponents){
|
||||
c.setEnabled(true);
|
||||
}
|
||||
logList.clear();
|
||||
@ -217,20 +197,19 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for moving to the previous step.
|
||||
*/
|
||||
class PrevListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (logList.isInitialized()) {
|
||||
if (logList.get() == logList.firstElement()) {
|
||||
class PrevListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(logList.isInitialized()){
|
||||
if(logList.get()==logList.firstElement()){
|
||||
autoButton.setSelected(false);
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
logList.prev();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
logList.prev();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
@ -238,20 +217,19 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for moving to the next step.
|
||||
*/
|
||||
class NextListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (logList.isInitialized()) {
|
||||
if (logList.get() == logList.lastElement()) {
|
||||
class NextListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(logList.isInitialized()){
|
||||
if(logList.get()==logList.lastElement()){
|
||||
autoButton.setSelected(false);
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
logList.next();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else{
|
||||
logList.next();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
@ -259,89 +237,68 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for moving to the first step.
|
||||
*/
|
||||
class FirstListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
class FirstListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
logList.first();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for moving to the last step.
|
||||
*/
|
||||
class LastListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
class LastListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
logList.last();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemListener implementation for handling auto button state changes.
|
||||
*/
|
||||
class AutoButtonListener implements ItemListener {
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
public void itemStateChanged(ItemEvent event){
|
||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
||||
setState(AUTOSTATE);
|
||||
autoTimer.setDelay(10000 / ((int) Math.pow(autoSlider.getValue(), 2)));
|
||||
autoTimer.setDelay(10000/((int)Math.pow(autoSlider.getValue(),2)));
|
||||
autoTimer.start();
|
||||
} else {
|
||||
}else{
|
||||
setState(RUNSTATE);
|
||||
autoTimer.stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ChangeListener implementation for handling auto slider changes.
|
||||
*/
|
||||
class AutoSliderListener implements ChangeListener {
|
||||
public void stateChanged(ChangeEvent event) {
|
||||
if (autoTimer.isRunning()) {
|
||||
public void stateChanged(ChangeEvent event){
|
||||
if(autoTimer.isRunning()){
|
||||
autoTimer.stop();
|
||||
autoTimer.setInitialDelay(10000 / ((int) Math.pow(autoSlider.getValue(), 2)));
|
||||
autoTimer.setDelay(10000 / ((int) Math.pow(autoSlider.getValue(), 2)));
|
||||
autoTimer.setInitialDelay(10000/((int)Math.pow(autoSlider.getValue(),2)));
|
||||
autoTimer.setDelay(10000/((int)Math.pow(autoSlider.getValue(),2)));
|
||||
autoTimer.start();
|
||||
autoTimer.setInitialDelay(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemListener implementation for handling auto forward button state changes.
|
||||
*/
|
||||
class AutoForwardListener implements ItemListener {
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
class AutoForwardListener implements ItemListener{
|
||||
public void itemStateChanged(ItemEvent event){
|
||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
||||
autoTimer.removeActionListener(prevListener);
|
||||
autoTimer.addActionListener(nextListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ItemListener implementation for handling auto backward button state changes.
|
||||
*/
|
||||
class AutoBackwardListener implements ItemListener {
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
class AutoBackwardListener implements ItemListener{
|
||||
public void itemStateChanged(ItemEvent event){
|
||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
||||
autoTimer.removeActionListener(nextListener);
|
||||
autoTimer.addActionListener(prevListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ActionListener implementation for handling pause button clicks.
|
||||
*/
|
||||
class PauseButtonListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (autoButton.isSelected()) {
|
||||
class PauseButtonListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(autoButton.isSelected()){
|
||||
setState(RUNSTATE);
|
||||
autoTimer.stop();
|
||||
autoButton.setSelected(false);
|
||||
|
@ -8,6 +8,9 @@ import java.awt.*;
|
||||
/**
|
||||
* This class represents a visualization.LegendArea implementation and has been created for demonstration purposes only.
|
||||
* Method initialize(Graphics) is overridden and now implements logic for drawing parameters on the legend area.
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurLegendArea extends LegendArea{
|
||||
|
||||
@ -33,16 +36,8 @@ public class OurLegendArea extends LegendArea{
|
||||
// Erstellt einen neuen TitledBorder für den Legendenbereich
|
||||
setBorder(BorderFactory.createTitledBorder("LegendArea"));
|
||||
|
||||
// Zeichnet den schwarzen Knoten (Unbesuchter Knoten)
|
||||
int y = 30; // Startposition für das Zeichnen der Legenden-Elemente
|
||||
g.setColor(Color.BLACK);
|
||||
g.fillOval(10, y, 20, 20); // Zeichnet einen kleinen Kreis (Knoten) mit der Farbe des Elements
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawOval(10, y, 20, 20); // Zeichnet den Rand des Kreises
|
||||
g.drawString("Unbesuchter Knoten", 40, y + 15); // Zeichnet die Beschreibung neben dem Kreis
|
||||
|
||||
// Zeichnet den roten Knoten (Start/End Knoten)
|
||||
y += 40; // Startposition für das Zeichnen der Legenden-Elemente
|
||||
int y = 30; // Startposition für das Zeichnen der Legenden-Elemente
|
||||
g.setColor(Color.RED);
|
||||
g.fillOval(10, y, 20, 20); // Zeichnet einen kleinen Kreis (Knoten) mit der Farbe des Elements
|
||||
g.setColor(Color.BLACK);
|
||||
@ -73,5 +68,10 @@ public class OurLegendArea extends LegendArea{
|
||||
g.drawOval(10, y, 20, 20); // Zeichnet den Rand des Kreises
|
||||
g.drawString("Fertiger Weg", 40, y + 15); // Zeichnet die Beschreibung neben dem Kreis
|
||||
|
||||
// Zeichnet die schwarze Linie (Kanten Markierung)
|
||||
y += 40; // Nach unten verschieben für das nächste Element
|
||||
g.setColor(Color.BLACK);
|
||||
g.drawLine(10, y + 10, 30, y + 10); // Zeichnet eine horizontale Linie
|
||||
g.drawString("Kanten Markierung", 40, y + 15); // Zeichnet die Beschreibung neben der Linie
|
||||
}
|
||||
}
|
@ -8,14 +8,17 @@ import visualizationElements.Edge;
|
||||
import visualizationElements.Vertex;
|
||||
|
||||
/**
|
||||
* This class extends logging.LogElement to provide additional functionality
|
||||
* for logging various elements related to graph visualization.
|
||||
*
|
||||
* This class provides an example for using logging.LogElement.
|
||||
* The super class has been extended by member value and corresponding get method.
|
||||
* The standard constructor has been overwritten and a new one has been introduced.
|
||||
* @see LogElement
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurLogElement extends LogElement {
|
||||
public class OurLogElement extends LogElement{
|
||||
|
||||
/** The sum up value associated with this log element. */
|
||||
/** The log elements sum up value. */
|
||||
protected long value;
|
||||
protected Vertex vertex;
|
||||
protected Edge edge;
|
||||
@ -23,7 +26,7 @@ public class OurLogElement extends LogElement {
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Initializes the log element with default values.
|
||||
* Calls the constructor of super class and sets value 0.
|
||||
*/
|
||||
public OurLogElement() {
|
||||
super();
|
||||
@ -32,46 +35,28 @@ public class OurLogElement extends LogElement {
|
||||
|
||||
/**
|
||||
* Extended constructor.
|
||||
* Initializes the log element with specified step number, description, sum up value, and vertex.
|
||||
*
|
||||
* @param step the step number of the log element
|
||||
* @param description the description of the log element
|
||||
* @param value the sum up value associated with the log element
|
||||
* @param vertex the vertex associated with the log element
|
||||
* Sets specified step number, description and sum up value.
|
||||
* @param step the log element's step number
|
||||
* @param description the log element's step description
|
||||
* @param value the log element's sum up value
|
||||
*/
|
||||
public OurLogElement(int step, String description, long value, Vertex vertex) {
|
||||
public OurLogElement(int step, String description, long value, Vertex vertex){
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.vertex = vertex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extended constructor.
|
||||
* Initializes the log element with specified step number, description, sum up value, and edge.
|
||||
*
|
||||
* @param step the step number of the log element
|
||||
* @param description the description of the log element
|
||||
* @param value the sum up value associated with the log element
|
||||
* @param edge the edge associated with the log element
|
||||
*/
|
||||
public OurLogElement(int step, String description, long value, Edge edge) {
|
||||
|
||||
public OurLogElement(int step, String description, long value, Edge edge){
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.edge = edge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extended constructor.
|
||||
* Initializes the log element with specified step number, description, sum up value, and graph.
|
||||
*
|
||||
* @param step the step number of the log element
|
||||
* @param description the description of the log element
|
||||
* @param value the sum up value associated with the log element
|
||||
* @param ourGraph the graph associated with the log element
|
||||
*/
|
||||
public OurLogElement(int step, String description, long value, visualizationElements.Graph ourGraph) {
|
||||
|
||||
public OurLogElement(int step, String description, long value, visualizationElements.Graph ourGraph ){
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
@ -79,37 +64,24 @@ public class OurLogElement extends LogElement {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the sum up value associated with this log element.
|
||||
*
|
||||
* @return the sum up value of the log element
|
||||
* Returns the log element's sum up value.
|
||||
* @return the log element's sum up value
|
||||
*/
|
||||
public long getValue() {
|
||||
public long getValue(){
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the edge associated with this log element.
|
||||
*
|
||||
* @return the edge associated with the log element
|
||||
*/
|
||||
|
||||
public Edge getEdge() {
|
||||
return this.edge;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the vertex associated with this log element.
|
||||
*
|
||||
* @return the vertex associated with the log element
|
||||
*/
|
||||
|
||||
public Vertex getVertex() {
|
||||
return this.vertex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the graph associated with this log element.
|
||||
*
|
||||
* @return the graph associated with the log element
|
||||
*/
|
||||
|
||||
public visualizationElements.Graph getGraph() {
|
||||
return this.ourGraph;
|
||||
}
|
||||
|
@ -8,12 +8,13 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* This class extends visualisation.ParameterArea to provide a panel for selecting
|
||||
* algorithmic methods such as Djikstra or A-Star.
|
||||
*
|
||||
* This class provides an example for using visualization.ParameterArea.
|
||||
* @see ParameterArea
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurMethodButtons extends ParameterArea {
|
||||
public class OurMethodButtons extends ParameterArea{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ -21,31 +22,32 @@ public class OurMethodButtons extends ParameterArea {
|
||||
protected JRadioButton button2;
|
||||
private boolean isDjikstra;
|
||||
|
||||
|
||||
/** TextField containing maximum sum up value. */
|
||||
protected JTextField maxValue;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Initializes the method buttons panel with default settings.
|
||||
* Creates SumUpMethodArea with an empty JTextField.
|
||||
*/
|
||||
public OurMethodButtons() {
|
||||
super();
|
||||
|
||||
isDjikstra = true; // Default to Djikstra
|
||||
isDjikstra = true; // Standardmäßig Djikstra
|
||||
|
||||
// Set layout manager to arrange buttons vertically
|
||||
setLayout(new GridLayout(1, 2, 5, 5)); // 1 row, 2 columns, 5 pixels gap
|
||||
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
|
||||
setLayout(new GridLayout(1, 2, 5, 5)); // 1 Zeile, 2 Spalten, 5 Pixel Abstand
|
||||
|
||||
// Create radio buttons
|
||||
// Buttons erstellen
|
||||
button1 = new JRadioButton("Djikstra", true);
|
||||
button2 = new JRadioButton("A-Stern");
|
||||
|
||||
// Create a button group and add buttons to ensure mutual exclusion
|
||||
// ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(button1);
|
||||
group.add(button2);
|
||||
|
||||
// Add action listeners to handle button selections
|
||||
// ActionListener hinzufügen
|
||||
button1.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -60,16 +62,11 @@ public class OurMethodButtons extends ParameterArea {
|
||||
}
|
||||
});
|
||||
|
||||
// Add buttons to the panel
|
||||
// Buttons zum Panel hinzufügen
|
||||
this.add(button1);
|
||||
this.add(button2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the selected algorithmic method.
|
||||
*
|
||||
* @return true if Djikstra is selected, false if A-Star is selected
|
||||
*/
|
||||
public boolean getSelectedMethod() {
|
||||
return isDjikstra;
|
||||
}
|
||||
|
@ -5,38 +5,37 @@ import visualisation.ParameterArea;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* This class extends visualisation.ParameterArea and provides an example for using it.
|
||||
* It includes functionality for managing a graph selection and creation based on user input.
|
||||
*
|
||||
* This class provides an example for using visualization.ParameterArea.
|
||||
* @see ParameterArea
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurParameterArea extends ParameterArea {
|
||||
public class OurParameterArea extends ParameterArea{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
// Custom graph instance
|
||||
private DirectedGraph<VertexMarking, EdgeMarking> customGraph;
|
||||
|
||||
// Radio buttons for selecting examples or custom graph
|
||||
private JRadioButton button1;
|
||||
private JRadioButton button2;
|
||||
private JRadioButton button3;
|
||||
private JRadioButton button4;
|
||||
private JRadioButton button5;
|
||||
|
||||
// Button to add a custom graph
|
||||
private JButton buttonAddGraph;
|
||||
|
||||
// Text fields for inputting vertex and edge data
|
||||
private JTextField textField1;
|
||||
private JTextField textField2;
|
||||
|
||||
// Selected example identifier
|
||||
|
||||
private int selectedExample;
|
||||
|
||||
|
||||
/** TextField containing maximum sum up value. */
|
||||
protected JTextField maxValue;
|
||||
|
||||
@ -46,31 +45,30 @@ public class OurParameterArea extends ParameterArea {
|
||||
*/
|
||||
public OurParameterArea() {
|
||||
super();
|
||||
selectedExample = 1; // Default to example 1
|
||||
selectedExample = 1; // Standardmäßig Beispiel 1
|
||||
this.customGraph = new DirectedGraph<>();
|
||||
|
||||
setBorder(BorderFactory.createTitledBorder("ParameterArea"));
|
||||
|
||||
// Set layout manager to arrange buttons vertically
|
||||
setLayout(new GridLayout(4, 1, 5, 5)); // 4 rows, 1 column, 5 pixel gap
|
||||
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
|
||||
setLayout(new GridLayout(4, 1, 5, 5)); // 4 Zeilen, 1 Spalte, 5 Pixel Abstand
|
||||
|
||||
// Create radio buttons
|
||||
// Buttons erstellen
|
||||
button1 = new JRadioButton("Beispiel 1", true);
|
||||
button2 = new JRadioButton("Beispiel 2");
|
||||
button3 = new JRadioButton("Beispiel 3");
|
||||
button4 = new JRadioButton("Beispiel 4");
|
||||
button5 = new JRadioButton("Eigener Graph");
|
||||
|
||||
// Button to add a graph
|
||||
buttonAddGraph = new JButton("Graph einfügen");
|
||||
|
||||
// Input text fields
|
||||
// Eingabefelder
|
||||
textField1 = new JTextField("A-100-100;Ende-200-200;Start-100-200;D-200-100");
|
||||
textField2 = new JTextField("A-Ende-15;Start-D-10;D-A-3;A-Ende-15;Start-D-10;D-A-3");
|
||||
textField1.setPreferredSize(new Dimension(button5.getWidth(), button5.getHeight()));
|
||||
textField2.setPreferredSize(new Dimension(button5.getWidth(), button5.getHeight()));
|
||||
|
||||
// Button group to ensure mutual exclusion of radio buttons
|
||||
|
||||
// ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(button1);
|
||||
group.add(button2);
|
||||
@ -78,36 +76,39 @@ public class OurParameterArea extends ParameterArea {
|
||||
group.add(button4);
|
||||
group.add(button5);
|
||||
|
||||
// Add action listeners to radio buttons
|
||||
// ActionListener hinzufügen
|
||||
button1.addActionListener(e -> selectedExample = 1);
|
||||
|
||||
button2.addActionListener(e -> selectedExample = 2);
|
||||
|
||||
button3.addActionListener(e -> selectedExample = 3);
|
||||
|
||||
button4.addActionListener(e -> selectedExample = 4);
|
||||
|
||||
button5.addActionListener(e -> selectedExample = 5);
|
||||
|
||||
// Add action listener to add graph button
|
||||
|
||||
buttonAddGraph.addActionListener(e -> {
|
||||
|
||||
String input1 = textField1.getText();
|
||||
String input2 = textField2.getText();
|
||||
this.customGraph = createGraph(input1, input2);
|
||||
|
||||
});
|
||||
|
||||
// Add components to panel
|
||||
// Buttons zum Panel hinzufügen
|
||||
add(button1);
|
||||
add(button2);
|
||||
add(button3);
|
||||
add(button4);
|
||||
add(button5);
|
||||
|
||||
add(buttonAddGraph);
|
||||
add(textField1);
|
||||
add(textField2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the selected graph based on the user's choice.
|
||||
*
|
||||
* @return The selected graph as a DirectedGraph instance.
|
||||
*/
|
||||
|
||||
public DirectedGraph<VertexMarking, EdgeMarking> getSelectedGraph() {
|
||||
ExampleGraphs temp = new ExampleGraphs();
|
||||
switch (selectedExample) {
|
||||
@ -125,26 +126,21 @@ public class OurParameterArea extends ParameterArea {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a directed graph based on input vertex and edge data.
|
||||
*
|
||||
* @param vertices String representation of vertices in the format "Name-X-Y;..."
|
||||
* @param edges String representation of edges in the format "Source-Target-Weight;..."
|
||||
* @return DirectedGraph<VertexMarking, EdgeMarking> created from the input data.
|
||||
*/
|
||||
|
||||
// Vertex Beispiel-Eingabe: A-100-100;Ende-200-200;Start-100-200;D-200-100
|
||||
// Edge Beispiel-Eingabe: A-B-15;C-D-10;D-A-3
|
||||
public DirectedGraph<VertexMarking, EdgeMarking> createGraph(String vertices, String edges) {
|
||||
DirectedGraph<VertexMarking, EdgeMarking> newGraph = new DirectedGraph<>();
|
||||
|
||||
|
||||
String[] allVertices = vertices.split(";");
|
||||
String[] allEdges = edges.split(";");
|
||||
|
||||
// Create vertices
|
||||
for (String i: allVertices) {
|
||||
String[] current = i.split("-");
|
||||
newGraph.addVertex(new MarkedVertex<>(Integer.parseInt(current[1]), Integer.parseInt(current[2]), current[0], null, Color.BLACK));
|
||||
}
|
||||
|
||||
// Create edges
|
||||
MarkedVertex<VertexMarking> start = null;
|
||||
MarkedVertex<VertexMarking> end = null;
|
||||
for (String i: allEdges) {
|
||||
@ -162,4 +158,5 @@ public class OurParameterArea extends ParameterArea {
|
||||
|
||||
return newGraph;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,40 +5,39 @@ import logging.LogElementList;
|
||||
import visualisation.TextArea;
|
||||
|
||||
/**
|
||||
* This class extends visualisation.TextArea and provides an example of its usage.
|
||||
* It overrides constructors and the print() method.
|
||||
*
|
||||
* This class provides an example for using visualization.TextArea.
|
||||
* Constructors and print() method have been overwritten.
|
||||
* @see TextArea
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurTextArea extends TextArea {
|
||||
public class OurTextArea extends TextArea{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* Default constructor for creating an instance of OurTextArea.
|
||||
* Initializes with default settings.
|
||||
* Standard constructor.
|
||||
*/
|
||||
public OurTextArea() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Extended constructor for creating an instance of OurTextArea.
|
||||
* Sets the initial LogElementList of OurLogElement as the log list.
|
||||
*
|
||||
* @param logList the LogElementList containing OurLogElement objects for the text area's log.
|
||||
* Extended constructor.
|
||||
* Sets LogElementList of TestLogElements as log list.
|
||||
* @param logList the text area's log element list.
|
||||
*/
|
||||
public OurTextArea(LogElementList<OurLogElement> logList) {
|
||||
public OurTextArea(LogElementList<OurLogElement>logList){
|
||||
super(logList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs the description of a log element to the text area.
|
||||
*
|
||||
* @return true if the operation is successful, false otherwise.
|
||||
* Textual output of a log element.
|
||||
* No output.
|
||||
*/
|
||||
public boolean print() {
|
||||
LogElement logElement = (LogElement) logList.get();
|
||||
public boolean print(){
|
||||
LogElement logElement=(LogElement)logList.get();
|
||||
setText(logElement.getDescription());
|
||||
return true;
|
||||
}
|
||||
|
17
out/production/ProjektGraph/.idea/workspace.xml
generated
17
out/production/ProjektGraph/.idea/workspace.xml
generated
@ -7,6 +7,7 @@
|
||||
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="Weighting gefixt">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -180,20 +181,4 @@
|
||||
<MESSAGE value="Weighting gefixt" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Weighting gefixt" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/OurApplication/OurParameterArea.java</url>
|
||||
<line>142</line>
|
||||
<option name="timeStamp" value="7" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
<watches-manager>
|
||||
<configuration name="Application">
|
||||
<watch expression="newGraph.screenGraph" />
|
||||
</configuration>
|
||||
</watches-manager>
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user