JavaDoc OurAlgorithm fertig
This commit is contained in:
parent
0be3b82e7b
commit
60a354b508
41
.idea/workspace.xml
generated
41
.idea/workspace.xml
generated
@ -7,12 +7,17 @@
|
||||
<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" />
|
||||
@ -44,17 +49,17 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<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 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>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Git\ProjektGraph" />
|
||||
@ -187,20 +192,6 @@
|
||||
<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,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<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();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<OurLogElement> run() {
|
||||
|
||||
this.setCurrentGraph(((OurParameterArea) this.getParameterArea()).getSelectedGraph());
|
||||
|
||||
|
||||
|
||||
MarkedVertex<VertexMarking> start = null;
|
||||
for (MarkedVertex<VertexMarking> i: this.currentGraph.getAllVertexes()) {
|
||||
if (Objects.equals(i.getName(), "Start")) {
|
||||
start = i;
|
||||
}
|
||||
}
|
||||
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()) {
|
||||
if (Objects.equals(i.getName(), "Ende")) {
|
||||
end = i;
|
||||
}
|
||||
}
|
||||
for (MarkedVertex<VertexMarking> i : this.currentGraph.getAllVertexes()) {
|
||||
if (Objects.equals(i.getName(), "Ende")) {
|
||||
end = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*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()){
|
||||
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,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<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
* 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<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
||||
System.out.println(myGraph.toString());
|
||||
|
||||
|
||||
|
||||
// Initialize logging elements
|
||||
LogElementList<OurLogElement> 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<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,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<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
* 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<VertexMarking, EdgeMarking> 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<OurLogElement> logList, String drawAreaName){
|
||||
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.
|
||||
* 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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 <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.
|
||||
*
|
||||
* @see HybridWindow
|
||||
* @see OurApplication
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurHybridWindow<DRAW extends DrawArea,
|
||||
TEXT extends TextArea,
|
||||
@ -31,7 +36,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;
|
||||
@ -58,69 +63,78 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
|
||||
/**
|
||||
* Overwritten standard constructor.
|
||||
* Creates a TestUpHybridWindow with
|
||||
* TestParameterArea,SumUpLegendArea, TestDrawArea, TestTextArea,
|
||||
* TestAlgorithm and a LogElementList of TestLogElements.
|
||||
* 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
|
||||
*/
|
||||
public OurHybridWindow() {
|
||||
super();
|
||||
}
|
||||
public OurHybridWindow(DRAW drawArea, TEXT textArea, PARAM parameterArea, ALGORITHM algorithm, LogElementList<LOG>logList, LEGEND legendArea, METHODBUTTONS methodButtons) {
|
||||
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");
|
||||
|
||||
ButtonGroup autoDirection=new ButtonGroup();
|
||||
/**
|
||||
* 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();
|
||||
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();
|
||||
@ -128,33 +142,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);
|
||||
@ -168,27 +182,33 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
autoBackwardButton.addItemListener(autoBackwardListener);
|
||||
pauseButton.addActionListener(pauseButtonListener);
|
||||
|
||||
autoTimer=new Timer(1,nextListener);
|
||||
autoTimer = new Timer(1, nextListener);
|
||||
}
|
||||
|
||||
class StartListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
Component[]bComponents=methodButtons.getComponents();
|
||||
/**
|
||||
* ActionListener implementation for starting the algorithm.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
class StopListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
Component[]bComponents=methodButtons.getComponents();
|
||||
/**
|
||||
* ActionListener implementation for stopping the algorithm.
|
||||
*/
|
||||
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();
|
||||
@ -197,19 +217,20 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
class PrevListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(logList.isInitialized()){
|
||||
if(logList.get()==logList.firstElement()){
|
||||
/**
|
||||
* 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()) {
|
||||
autoButton.setSelected(false);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logList.prev();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logList.prev();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
@ -217,19 +238,20 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
class NextListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(logList.isInitialized()){
|
||||
if(logList.get()==logList.lastElement()){
|
||||
/**
|
||||
* 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()) {
|
||||
autoButton.setSelected(false);
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logList.next();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
logList.next();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
@ -237,68 +259,89 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
||||
}
|
||||
}
|
||||
|
||||
class FirstListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
/**
|
||||
* ActionListener implementation for moving to the first step.
|
||||
*/
|
||||
class FirstListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
logList.first();
|
||||
drawArea.drawStep();
|
||||
textArea.printStep();
|
||||
}
|
||||
}
|
||||
|
||||
class LastListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
/**
|
||||
* ActionListener implementation for moving to the last step.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AutoForwardListener implements ItemListener{
|
||||
public void itemStateChanged(ItemEvent event){
|
||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
||||
/**
|
||||
* ItemListener implementation for handling auto forward button state changes.
|
||||
*/
|
||||
class AutoForwardListener implements ItemListener {
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
autoTimer.removeActionListener(prevListener);
|
||||
autoTimer.addActionListener(nextListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class AutoBackwardListener implements ItemListener{
|
||||
public void itemStateChanged(ItemEvent event){
|
||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
||||
/**
|
||||
* ItemListener implementation for handling auto backward button state changes.
|
||||
*/
|
||||
class AutoBackwardListener implements ItemListener {
|
||||
public void itemStateChanged(ItemEvent event) {
|
||||
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||
autoTimer.removeActionListener(nextListener);
|
||||
autoTimer.addActionListener(prevListener);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class PauseButtonListener implements ActionListener{
|
||||
public void actionPerformed(ActionEvent event){
|
||||
if(autoButton.isSelected()){
|
||||
/**
|
||||
* ActionListener implementation for handling pause button clicks.
|
||||
*/
|
||||
class PauseButtonListener implements ActionListener {
|
||||
public void actionPerformed(ActionEvent event) {
|
||||
if (autoButton.isSelected()) {
|
||||
setState(RUNSTATE);
|
||||
autoTimer.stop();
|
||||
autoButton.setSelected(false);
|
||||
|
@ -8,9 +8,6 @@ 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{
|
||||
|
||||
@ -21,7 +18,7 @@ public class OurLegendArea extends LegendArea{
|
||||
*/
|
||||
public OurLegendArea(){
|
||||
super();
|
||||
|
||||
|
||||
//set the legend area's preferred size manually for best visualization
|
||||
setPreferredSize(new Dimension(150, 170));
|
||||
}
|
||||
@ -36,8 +33,16 @@ public class OurLegendArea extends LegendArea{
|
||||
// Erstellt einen neuen TitledBorder für den Legendenbereich
|
||||
setBorder(BorderFactory.createTitledBorder("LegendArea"));
|
||||
|
||||
// Zeichnet den roten Knoten (Start/End Knoten)
|
||||
// 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
|
||||
g.setColor(Color.RED);
|
||||
g.fillOval(10, y, 20, 20); // Zeichnet einen kleinen Kreis (Knoten) mit der Farbe des Elements
|
||||
g.setColor(Color.BLACK);
|
||||
@ -68,10 +73,5 @@ 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,80 +8,108 @@ import visualizationElements.Edge;
|
||||
import visualizationElements.Vertex;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* This class extends logging.LogElement to provide additional functionality
|
||||
* for logging various elements related to graph visualization.
|
||||
*
|
||||
* @see LogElement
|
||||
* @author MSch<EFBFBD>fer
|
||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||
* <br>
|
||||
*/
|
||||
public class OurLogElement extends LogElement{
|
||||
|
||||
/** The log elements sum up value. */
|
||||
public class OurLogElement extends LogElement {
|
||||
|
||||
/** The sum up value associated with this log element. */
|
||||
protected long value;
|
||||
protected Vertex vertex;
|
||||
protected Edge edge;
|
||||
protected visualizationElements.Graph ourGraph;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Calls the constructor of super class and sets value 0.
|
||||
* Standard constructor.
|
||||
* Initializes the log element with default values.
|
||||
*/
|
||||
public OurLogElement() {
|
||||
super();
|
||||
this.value = 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extended constructor.
|
||||
* 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
|
||||
* 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
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
public OurLogElement(int step, String description, long value, Edge edge){
|
||||
/**
|
||||
* 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) {
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.edge = edge;
|
||||
}
|
||||
|
||||
|
||||
public OurLogElement(int step, String description, long value, visualizationElements.Graph ourGraph ){
|
||||
/**
|
||||
* 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) {
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.ourGraph = ourGraph;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the log element's sum up value.
|
||||
* @return the log element's sum up value
|
||||
* Retrieves the sum up value associated with this log element.
|
||||
*
|
||||
* @return the sum up value of the log element
|
||||
*/
|
||||
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,13 +8,12 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
/**
|
||||
* This class provides an example for using visualization.ParameterArea.
|
||||
* This class extends visualisation.ParameterArea to provide a panel for selecting
|
||||
* algorithmic methods such as Djikstra or A-Star.
|
||||
*
|
||||
* @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;
|
||||
|
||||
@ -22,32 +21,31 @@ public class OurMethodButtons extends ParameterArea{
|
||||
protected JRadioButton button2;
|
||||
private boolean isDjikstra;
|
||||
|
||||
|
||||
/** TextField containing maximum sum up value. */
|
||||
/** TextField containing maximum sum up value. */
|
||||
protected JTextField maxValue;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
* Creates SumUpMethodArea with an empty JTextField.
|
||||
* Initializes the method buttons panel with default settings.
|
||||
*/
|
||||
public OurMethodButtons() {
|
||||
super();
|
||||
|
||||
isDjikstra = true; // Standardmäßig Djikstra
|
||||
isDjikstra = true; // Default to Djikstra
|
||||
|
||||
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
|
||||
setLayout(new GridLayout(1, 2, 5, 5)); // 1 Zeile, 2 Spalten, 5 Pixel Abstand
|
||||
// Set layout manager to arrange buttons vertically
|
||||
setLayout(new GridLayout(1, 2, 5, 5)); // 1 row, 2 columns, 5 pixels gap
|
||||
|
||||
// Buttons erstellen
|
||||
// Create radio buttons
|
||||
button1 = new JRadioButton("Djikstra", true);
|
||||
button2 = new JRadioButton("A-Stern");
|
||||
|
||||
// ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten
|
||||
// Create a button group and add buttons to ensure mutual exclusion
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(button1);
|
||||
group.add(button2);
|
||||
|
||||
// ActionListener hinzufügen
|
||||
// Add action listeners to handle button selections
|
||||
button1.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -62,11 +60,16 @@ public class OurMethodButtons extends ParameterArea{
|
||||
}
|
||||
});
|
||||
|
||||
// Buttons zum Panel hinzufügen
|
||||
// Add buttons to the panel
|
||||
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,39 @@ 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 provides an example for using visualization.ParameterArea.
|
||||
* 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.
|
||||
*
|
||||
* @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. */
|
||||
/** TextField containing maximum sum up value. */
|
||||
protected JTextField maxValue;
|
||||
|
||||
/**
|
||||
@ -45,30 +46,31 @@ public class OurParameterArea extends ParameterArea{
|
||||
*/
|
||||
public OurParameterArea() {
|
||||
super();
|
||||
selectedExample = 1; // Standardmäßig Beispiel 1
|
||||
selectedExample = 1; // Default to example 1
|
||||
this.customGraph = new DirectedGraph<>();
|
||||