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">
|
<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$/.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/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/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/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/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/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/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>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -44,17 +49,17 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Application.Display.executor": "Run",
|
"Application.Display.executor": "Run",
|
||||||
"Application.OurApplication.executor": "Run",
|
"Application.OurApplication.executor": "Run",
|
||||||
"Application.OurLegendArea.executor": "Run",
|
"Application.OurLegendArea.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="C:\Git\ProjektGraph" />
|
<recent name="C:\Git\ProjektGraph" />
|
||||||
@ -187,20 +192,6 @@
|
|||||||
<option name="LAST_COMMIT_MESSAGE" value="Weighting gefixt" />
|
<option name="LAST_COMMIT_MESSAGE" value="Weighting gefixt" />
|
||||||
</component>
|
</component>
|
||||||
<component name="XDebuggerManager">
|
<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>
|
<watches-manager>
|
||||||
<configuration name="Application">
|
<configuration name="Application">
|
||||||
<watch expression="newGraph.screenGraph" />
|
<watch expression="newGraph.screenGraph" />
|
||||||
|
@ -3,86 +3,81 @@ package OurApplication;
|
|||||||
import graph.*;
|
import graph.*;
|
||||||
import logging.Algorithm;
|
import logging.Algorithm;
|
||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
import visualizationElements.Vertex;
|
|
||||||
|
|
||||||
import java.awt.*;
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Random;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using logging.Algorithm.
|
* This class provides an example of using logging.Algorithm.
|
||||||
* It sums up integer number starting with 0 up to the maximum value specified in the parameter area.
|
* 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
|
* @see Algorithm
|
||||||
* @author MSch<EFBFBD>fer
|
|
||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
||||||
* <br>
|
|
||||||
*/
|
*/
|
||||||
public class OurAlgorithm extends Algorithm {
|
public class OurAlgorithm extends Algorithm {
|
||||||
|
|
||||||
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||||
private OurMethodButtons methodButtons;
|
private OurMethodButtons methodButtons;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Standard constructor.
|
||||||
|
* Initializes an instance of OurAlgorithm.
|
||||||
|
*/
|
||||||
public OurAlgorithm() {
|
public OurAlgorithm() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a sum up algorithm.
|
* Constructs a summation algorithm with parameters from the parameter area.
|
||||||
* @param parameterArea the sum up parameter area the algorithm gets its parameters from
|
*
|
||||||
|
* @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){
|
public OurAlgorithm(OurParameterArea parameterArea, OurMethodButtons methodButtons) {
|
||||||
super(parameterArea,"Thema II: Kürzeste Wege");
|
super(parameterArea, "Thema II: Kürzeste Wege");
|
||||||
this.methodButtons = methodButtons;
|
this.methodButtons = methodButtons;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwritten from super class.
|
* Overridden method from the superclass.
|
||||||
* Runs the algorithm..
|
* Executes the summation algorithm.
|
||||||
* Returns the LogElementList produced by the algorithm processing.
|
* Computes the shortest path in the current graph based on the selected method (Dijkstra or A-Star).
|
||||||
* Adds integer number starting with 0 up to the maximum value.
|
*
|
||||||
* @return a LogElementList containing the algorithm processing single steps
|
* @return a LogElementList containing the single steps of the algorithm processing
|
||||||
*/
|
*/
|
||||||
public LogElementList<OurLogElement> run() {
|
public LogElementList<OurLogElement> run() {
|
||||||
|
|
||||||
this.setCurrentGraph(((OurParameterArea) this.getParameterArea()).getSelectedGraph());
|
this.setCurrentGraph(((OurParameterArea) this.getParameterArea()).getSelectedGraph());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
MarkedVertex<VertexMarking> start = null;
|
MarkedVertex<VertexMarking> start = null;
|
||||||
for (MarkedVertex<VertexMarking> i: this.currentGraph.getAllVertexes()) {
|
for (MarkedVertex<VertexMarking> i : this.currentGraph.getAllVertexes()) {
|
||||||
if (Objects.equals(i.getName(), "Start")) {
|
if (Objects.equals(i.getName(), "Start")) {
|
||||||
start = i;
|
start = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MarkedVertex<VertexMarking> end = null;
|
MarkedVertex<VertexMarking> end = null;
|
||||||
for (MarkedVertex<VertexMarking> i: this.currentGraph.getAllVertexes()) {
|
for (MarkedVertex<VertexMarking> i : this.currentGraph.getAllVertexes()) {
|
||||||
if (Objects.equals(i.getName(), "Ende")) {
|
if (Objects.equals(i.getName(), "Ende")) {
|
||||||
end = i;
|
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);
|
this.currentGraph.getShortestPathDijkstra(start, end);
|
||||||
}else{
|
} else {
|
||||||
this.currentGraph.getShortestPathAStar(start, end);
|
this.currentGraph.getShortestPathAStar(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.currentGraph.getLogList();
|
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) {
|
public void setCurrentGraph(graph.Graph<VertexMarking, EdgeMarking> graph) {
|
||||||
this.currentGraph = graph;
|
this.currentGraph = graph;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,69 +2,68 @@ package OurApplication;
|
|||||||
|
|
||||||
import graph.*;
|
import graph.*;
|
||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
import visualisation.HybridWindow;
|
|
||||||
import visualizationElements.Vertex;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
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.
|
* Entry point for the OurApplication, demonstrating logging and visualization integration.
|
||||||
* It uses extended classes from logging and visualization.
|
* This application sets up a graphical interface using Swing components to visualize graphs
|
||||||
* @see OurAlgorithm
|
* and log algorithmic operations.
|
||||||
* @see OurApplication
|
*
|
||||||
* @see OurDrawArea
|
* @see OurAlgorithm Provides the algorithmic logic for processing graphs.
|
||||||
* @see OurHybridWindow
|
* @see OurDrawArea Displays and interacts with the graph visualization.
|
||||||
* @see OurLogElement
|
* @see OurHybridWindow Combines visual components and algorithmic operations.
|
||||||
* @see OurParameterArea
|
* @see OurLogElement Represents individual logging elements.
|
||||||
* @see OurTextArea
|
* @see OurParameterArea Manages parameters for graph operations.
|
||||||
* @see OurLegendArea
|
* @see OurTextArea Displays log messages and algorithm progress.
|
||||||
* @see JPanel
|
* @see OurLegendArea Provides legend information for the graphical interface.
|
||||||
* @author MSch<EFBFBD>fer
|
* @see JPanel Swing panel used in the graphical interface.
|
||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
||||||
* <br>
|
|
||||||
*/
|
*/
|
||||||
public class OurApplication {
|
public class OurApplication {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Default constructor for OurApplication.
|
||||||
|
* Initializes the application components and starts the graphical interface.
|
||||||
*/
|
*/
|
||||||
public OurApplication() {
|
public OurApplication() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The applications main method.
|
* Main method to launch the OurApplication.
|
||||||
* Creates a HybridWindow with TestParameterArea, TestLegendArea ,TestDrawArea, TestTextArea and TestAlgorithm and starts it.
|
* Initializes necessary components, creates a graphical window, and starts the application.
|
||||||
* @param args
|
*
|
||||||
|
* @param args command-line arguments (not used)
|
||||||
*/
|
*/
|
||||||
public static void main(String[]args){
|
public static void main(String[] args){
|
||||||
|
|
||||||
|
// Create a directed graph instance
|
||||||
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
||||||
System.out.println(myGraph.toString());
|
System.out.println(myGraph.toString());
|
||||||
|
|
||||||
|
// Initialize logging elements
|
||||||
|
|
||||||
LogElementList<OurLogElement> logList = new LogElementList<>();
|
LogElementList<OurLogElement> logList = new LogElementList<>();
|
||||||
|
|
||||||
|
// Create UI components
|
||||||
OurParameterArea parameterArea = new OurParameterArea();
|
OurParameterArea parameterArea = new OurParameterArea();
|
||||||
OurMethodButtons methodButtons = new OurMethodButtons();
|
OurMethodButtons methodButtons = new OurMethodButtons();
|
||||||
OurDrawArea drawArea = new OurDrawArea(logList,"GraphVisualization");
|
OurDrawArea drawArea = new OurDrawArea(logList, "GraphVisualization");
|
||||||
OurTextArea textArea = new OurTextArea(logList);
|
OurTextArea textArea = new OurTextArea(logList);
|
||||||
OurAlgorithm algorithm = new OurAlgorithm(parameterArea, methodButtons);
|
OurAlgorithm algorithm = new OurAlgorithm(parameterArea, methodButtons);
|
||||||
OurLegendArea legendArea = new OurLegendArea();
|
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");
|
JFrame frame = new JFrame("Visualise");
|
||||||
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
frame.getContentPane().add(applet);
|
frame.getContentPane().add(applet);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
applet.init();
|
applet.init();
|
||||||
applet.start();
|
applet.start();
|
||||||
frame.setSize(1350,800);
|
frame.setSize(1350, 800);
|
||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,154 +4,58 @@ import graph.*;
|
|||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
import visualisation.DrawArea;
|
import visualisation.DrawArea;
|
||||||
import visualizationElements.Edge;
|
import visualizationElements.Edge;
|
||||||
import visualizationElements.Vertex;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.MouseEvent;
|
|
||||||
import java.awt.event.MouseListener;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using visualization.DrawArea.
|
* This class provides an example for using visualization.DrawArea.
|
||||||
* @see logging.Algorithm
|
* It extends DrawArea to visualize a graph based on logging elements.
|
||||||
@author MSch<EFBFBD>fer
|
*
|
||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
* @see DrawArea
|
||||||
* <br>
|
|
||||||
*/
|
*/
|
||||||
public class OurDrawArea extends DrawArea{
|
public class OurDrawArea extends DrawArea {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
|
* Initializes an empty draw area.
|
||||||
*/
|
*/
|
||||||
public OurDrawArea() {
|
public OurDrawArea() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a test draw area and sets the specified log list.
|
* Extended constructor.
|
||||||
* @param logList the draw area's log list test log elements.
|
* Creates a draw area with a specified log list and display name.
|
||||||
* @param drawAreaName The display name over the draw area.
|
*
|
||||||
|
* @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);
|
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) {
|
public void draw(Graphics g) {
|
||||||
|
// Get the current log element from the log list
|
||||||
OurLogElement logElement = (OurLogElement) logList.get();
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,13 +17,18 @@ import java.awt.event.ItemListener;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using visualization.HybridWindow.
|
* This class provides an example for using visualization.HybridWindow.
|
||||||
* Overwriting the constructor is necessary to run as an applet.
|
* It extends HybridWindow to integrate graphical components with algorithmic operations.
|
||||||
* For running as an application overwriting the constructor is not necessary
|
*
|
||||||
|
* @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 HybridWindow
|
||||||
* @see OurApplication
|
* @see OurApplication
|
||||||
* @author MSch<EFBFBD>fer
|
|
||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
||||||
* <br>
|
|
||||||
*/
|
*/
|
||||||
public class OurHybridWindow<DRAW extends DrawArea,
|
public class OurHybridWindow<DRAW extends DrawArea,
|
||||||
TEXT extends TextArea,
|
TEXT extends TextArea,
|
||||||
@ -31,7 +36,7 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
ALGORITHM extends Algorithm,
|
ALGORITHM extends Algorithm,
|
||||||
LOG extends LogElement,
|
LOG extends LogElement,
|
||||||
LEGEND extends LegendArea,
|
LEGEND extends LegendArea,
|
||||||
METHODBUTTONS extends ParameterArea> extends HybridWindow{
|
METHODBUTTONS extends ParameterArea> extends HybridWindow {
|
||||||
|
|
||||||
protected METHODBUTTONS methodButtons;
|
protected METHODBUTTONS methodButtons;
|
||||||
protected StartListener startListener;
|
protected StartListener startListener;
|
||||||
@ -58,69 +63,78 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Overwritten standard constructor.
|
* Overwritten standard constructor.
|
||||||
* Creates a TestUpHybridWindow with
|
* Creates a HybridWindow with specified draw area, text area, parameter area,
|
||||||
* TestParameterArea,SumUpLegendArea, TestDrawArea, TestTextArea,
|
* algorithm, log list, legend area, and method buttons.
|
||||||
* TestAlgorithm and a LogElementList of TestLogElements.
|
*
|
||||||
|
* @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() {
|
public OurHybridWindow(DRAW drawArea, TEXT textArea, PARAM parameterArea, ALGORITHM algorithm,
|
||||||
super();
|
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);
|
super(drawArea, textArea, parameterArea, algorithm, logList, legendArea);
|
||||||
this.methodButtons = methodButtons;
|
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(autoForwardButton);
|
||||||
autoDirection.add(autoBackwardButton);
|
autoDirection.add(autoBackwardButton);
|
||||||
autoForwardButton.setSelected(true);
|
autoForwardButton.setSelected(true);
|
||||||
|
|
||||||
JPanel panelStartStopControls=new JPanel();
|
JPanel panelStartStopControls = new JPanel();
|
||||||
panelStartStopControls.setLayout(new GridLayout(4,1,5,5));
|
panelStartStopControls.setLayout(new GridLayout(4, 1, 5, 5));
|
||||||
panelStartStopControls.add(startButton);
|
panelStartStopControls.add(startButton);
|
||||||
panelStartStopControls.add(stopButton);
|
panelStartStopControls.add(stopButton);
|
||||||
panelStartStopControls.add(pauseButton);
|
panelStartStopControls.add(pauseButton);
|
||||||
panelStartStopControls.add(methodButtons);
|
panelStartStopControls.add(methodButtons);
|
||||||
panelStartStopControls.setBorder(BorderFactory.createTitledBorder("Start / Stop"));
|
panelStartStopControls.setBorder(BorderFactory.createTitledBorder("Start / Stop"));
|
||||||
|
|
||||||
JPanel panelStepwiseExecutionControls=new JPanel();
|
JPanel panelStepwiseExecutionControls = new JPanel();
|
||||||
panelStepwiseExecutionControls.setLayout(new GridLayout(4,1,5,5));
|
panelStepwiseExecutionControls.setLayout(new GridLayout(4, 1, 5, 5));
|
||||||
panelStepwiseExecutionControls.add(firstButton);
|
panelStepwiseExecutionControls.add(firstButton);
|
||||||
panelStepwiseExecutionControls.add(nextButton);
|
panelStepwiseExecutionControls.add(nextButton);
|
||||||
panelStepwiseExecutionControls.add(prevButton);
|
panelStepwiseExecutionControls.add(prevButton);
|
||||||
panelStepwiseExecutionControls.add(lastButton);
|
panelStepwiseExecutionControls.add(lastButton);
|
||||||
panelStepwiseExecutionControls.setBorder(BorderFactory.createTitledBorder("Stepwise execution"));
|
panelStepwiseExecutionControls.setBorder(BorderFactory.createTitledBorder("Stepwise execution"));
|
||||||
|
|
||||||
JPanel panelAutomaticExecutionControls=new JPanel();
|
JPanel panelAutomaticExecutionControls = new JPanel();
|
||||||
panelAutomaticExecutionControls.setLayout(new GridLayout(5,1,5,5));
|
panelAutomaticExecutionControls.setLayout(new GridLayout(5, 1, 5, 5));
|
||||||
panelAutomaticExecutionControls.add(autoButton);
|
panelAutomaticExecutionControls.add(autoButton);
|
||||||
panelAutomaticExecutionControls.add(autoSlider);
|
panelAutomaticExecutionControls.add(autoSlider);
|
||||||
panelAutomaticExecutionControls.add(autoForwardButton);
|
panelAutomaticExecutionControls.add(autoForwardButton);
|
||||||
panelAutomaticExecutionControls.add(autoBackwardButton);
|
panelAutomaticExecutionControls.add(autoBackwardButton);
|
||||||
panelAutomaticExecutionControls.setBorder(BorderFactory.createTitledBorder("Automatic execution"));
|
panelAutomaticExecutionControls.setBorder(BorderFactory.createTitledBorder("Automatic execution"));
|
||||||
|
|
||||||
JPanel buttonLine=new JPanel();
|
JPanel buttonLine = new JPanel();
|
||||||
buttonLine.setLayout(new GridLayout(3,1,5,5));
|
buttonLine.setLayout(new GridLayout(3, 1, 5, 5));
|
||||||
buttonLine.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
buttonLine.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||||
buttonLine.add(panelStartStopControls);
|
buttonLine.add(panelStartStopControls);
|
||||||
buttonLine.add(panelStepwiseExecutionControls);
|
buttonLine.add(panelStepwiseExecutionControls);
|
||||||
buttonLine.add(panelAutomaticExecutionControls);
|
buttonLine.add(panelAutomaticExecutionControls);
|
||||||
|
|
||||||
JLabel headline=new JLabel(algorithm.getTitle());
|
JLabel headline = new JLabel(algorithm.getTitle());
|
||||||
headline.setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
|
headline.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
|
||||||
headline.setFont(new Font("SansSerif",Font.PLAIN,20));
|
headline.setFont(new Font("SansSerif", Font.PLAIN, 20));
|
||||||
|
|
||||||
JScrollPane parameterAreaScrollPane = parameterArea.getScrollPane();
|
JScrollPane parameterAreaScrollPane = parameterArea.getScrollPane();
|
||||||
JScrollPane legendAreaScrollPane = legendArea.getScrollPane();
|
JScrollPane legendAreaScrollPane = legendArea.getScrollPane();
|
||||||
@ -128,33 +142,33 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
parameterAreaScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
parameterAreaScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||||
legendAreaScrollPane.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.setOneTouchExpandable(true);
|
||||||
hybridWindowSplitPane.setResizeWeight(0.465);
|
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);
|
tabbedPane.setSelectedIndex(0);
|
||||||
|
|
||||||
setLayout(new BorderLayout(10,10));
|
setLayout(new BorderLayout(10, 10));
|
||||||
|
|
||||||
add(headline,BorderLayout.NORTH);
|
add(headline, BorderLayout.NORTH);
|
||||||
add(hybridWindowSplitPane,BorderLayout.WEST);
|
add(hybridWindowSplitPane, BorderLayout.WEST);
|
||||||
add(tabbedPane,BorderLayout.CENTER);
|
add(tabbedPane, BorderLayout.CENTER);
|
||||||
add(textArea.getScrollPane(),BorderLayout.SOUTH);
|
add(textArea.getScrollPane(), BorderLayout.SOUTH);
|
||||||
add(buttonLine,BorderLayout.EAST);
|
add(buttonLine, BorderLayout.EAST);
|
||||||
|
|
||||||
setState(PARAMETERSTATE);
|
setState(PARAMETERSTATE);
|
||||||
|
|
||||||
startListener= new StartListener();
|
startListener = new StartListener();
|
||||||
stopListener=new StopListener();
|
stopListener = new StopListener();
|
||||||
prevListener=new PrevListener();
|
prevListener = new PrevListener();
|
||||||
nextListener=new NextListener();
|
nextListener = new NextListener();
|
||||||
firstListener=new FirstListener();
|
firstListener = new FirstListener();
|
||||||
lastListener=new LastListener();
|
lastListener = new LastListener();
|
||||||
autoButtonListener=new AutoButtonListener();
|
autoButtonListener = new AutoButtonListener();
|
||||||
autoSliderListener=new AutoSliderListener();
|
autoSliderListener = new AutoSliderListener();
|
||||||
autoForwardListener=new AutoForwardListener();
|
autoForwardListener = new AutoForwardListener();
|
||||||
autoBackwardListener=new AutoBackwardListener();
|
autoBackwardListener = new AutoBackwardListener();
|
||||||
pauseButtonListener=new PauseButtonListener();
|
pauseButtonListener = new PauseButtonListener();
|
||||||
|
|
||||||
startButton.addActionListener(startListener);
|
startButton.addActionListener(startListener);
|
||||||
stopButton.addActionListener(stopListener);
|
stopButton.addActionListener(stopListener);
|
||||||
@ -168,27 +182,33 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
autoBackwardButton.addItemListener(autoBackwardListener);
|
autoBackwardButton.addItemListener(autoBackwardListener);
|
||||||
pauseButton.addActionListener(pauseButtonListener);
|
pauseButton.addActionListener(pauseButtonListener);
|
||||||
|
|
||||||
autoTimer=new Timer(1,nextListener);
|
autoTimer = new Timer(1, nextListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
class StartListener implements ActionListener{
|
/**
|
||||||
public void actionPerformed(ActionEvent event){
|
* ActionListener implementation for starting the algorithm.
|
||||||
Component[]bComponents=methodButtons.getComponents();
|
*/
|
||||||
|
class StartListener implements ActionListener {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
Component[] bComponents = methodButtons.getComponents();
|
||||||
setState(RUNSTATE);
|
setState(RUNSTATE);
|
||||||
for(Component c:bComponents){
|
for (Component c : bComponents) {
|
||||||
c.setEnabled(false);
|
c.setEnabled(false);
|
||||||
}
|
}
|
||||||
logList=algorithm.run();
|
logList = algorithm.run();
|
||||||
drawArea.setLogList(logList);
|
drawArea.setLogList(logList);
|
||||||
textArea.setLogList(logList);
|
textArea.setLogList(logList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class StopListener implements ActionListener{
|
/**
|
||||||
public void actionPerformed(ActionEvent event){
|
* ActionListener implementation for stopping the algorithm.
|
||||||
Component[]bComponents=methodButtons.getComponents();
|
*/
|
||||||
|
class StopListener implements ActionListener {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
Component[] bComponents = methodButtons.getComponents();
|
||||||
setState(PARAMETERSTATE);
|
setState(PARAMETERSTATE);
|
||||||
for(Component c:bComponents){
|
for (Component c : bComponents) {
|
||||||
c.setEnabled(true);
|
c.setEnabled(true);
|
||||||
}
|
}
|
||||||
logList.clear();
|
logList.clear();
|
||||||
@ -197,19 +217,20 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PrevListener implements ActionListener{
|
/**
|
||||||
public void actionPerformed(ActionEvent event){
|
* ActionListener implementation for moving to the previous step.
|
||||||
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);
|
autoButton.setSelected(false);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
logList.prev();
|
logList.prev();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
textArea.printStep();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
logList.prev();
|
logList.prev();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
textArea.printStep();
|
||||||
@ -217,19 +238,20 @@ public class OurHybridWindow<DRAW extends DrawArea,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NextListener implements ActionListener{
|
/**
|
||||||
public void actionPerformed(ActionEvent event){
|
* ActionListener implementation for moving to the next step.
|
||||||
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);
|
autoButton.setSelected(false);
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
logList.next();
|
logList.next();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
textArea.printStep();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else{
|
|
||||||
logList.next();
|
logList.next();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
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();
|
logList.first();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
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();
|
logList.last();
|
||||||
drawArea.drawStep();
|
drawArea.drawStep();
|
||||||
textArea.printStep();
|
textArea.printStep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ItemListener implementation for handling auto button state changes.
|
||||||
|
*/
|
||||||
class AutoButtonListener implements ItemListener {
|
class AutoButtonListener implements ItemListener {
|
||||||
public void itemStateChanged(ItemEvent event){
|
public void itemStateChanged(ItemEvent event) {
|
||||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||||
setState(AUTOSTATE);
|
setState(AUTOSTATE);
|
||||||
autoTimer.setDelay(10000/((int)Math.pow(autoSlider.getValue(),2)));
|
autoTimer.setDelay(10000 / ((int) Math.pow(autoSlider.getValue(), 2)));
|
||||||
autoTimer.start();
|
autoTimer.start();
|
||||||
}else{
|
} else {
|
||||||
setState(RUNSTATE);
|
setState(RUNSTATE);
|
||||||
autoTimer.stop();
|
autoTimer.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ChangeListener implementation for handling auto slider changes.
|
||||||
|
*/
|
||||||
class AutoSliderListener implements ChangeListener {
|
class AutoSliderListener implements ChangeListener {
|
||||||
public void stateChanged(ChangeEvent event){
|
public void stateChanged(ChangeEvent event) {
|
||||||
if(autoTimer.isRunning()){
|
if (autoTimer.isRunning()) {
|
||||||
autoTimer.stop();
|
autoTimer.stop();
|
||||||
autoTimer.setInitialDelay(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.setDelay(10000 / ((int) Math.pow(autoSlider.getValue(), 2)));
|
||||||
autoTimer.start();
|
autoTimer.start();
|
||||||
autoTimer.setInitialDelay(1);
|
autoTimer.setInitialDelay(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoForwardListener implements ItemListener{
|
/**
|
||||||
public void itemStateChanged(ItemEvent event){
|
* ItemListener implementation for handling auto forward button state changes.
|
||||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
*/
|
||||||
|
class AutoForwardListener implements ItemListener {
|
||||||
|
public void itemStateChanged(ItemEvent event) {
|
||||||
|
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||||
autoTimer.removeActionListener(prevListener);
|
autoTimer.removeActionListener(prevListener);
|
||||||
autoTimer.addActionListener(nextListener);
|
autoTimer.addActionListener(nextListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class AutoBackwardListener implements ItemListener{
|
/**
|
||||||
public void itemStateChanged(ItemEvent event){
|
* ItemListener implementation for handling auto backward button state changes.
|
||||||
if(event.getStateChange()==ItemEvent.SELECTED){
|
*/
|
||||||
|
class AutoBackwardListener implements ItemListener {
|
||||||
|
public void itemStateChanged(ItemEvent event) {
|
||||||
|
if (event.getStateChange() == ItemEvent.SELECTED) {
|
||||||
autoTimer.removeActionListener(nextListener);
|
autoTimer.removeActionListener(nextListener);
|
||||||
autoTimer.addActionListener(prevListener);
|
autoTimer.addActionListener(prevListener);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PauseButtonListener implements ActionListener{
|
/**
|
||||||
public void actionPerformed(ActionEvent event){
|
* ActionListener implementation for handling pause button clicks.
|
||||||
if(autoButton.isSelected()){
|
*/
|
||||||
|
class PauseButtonListener implements ActionListener {
|
||||||
|
public void actionPerformed(ActionEvent event) {
|
||||||
|
if (autoButton.isSelected()) {
|
||||||
setState(RUNSTATE);
|
setState(RUNSTATE);
|
||||||
autoTimer.stop();
|
autoTimer.stop();
|
||||||
autoButton.setSelected(false);
|
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.
|
* 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.
|
* 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{
|
public class OurLegendArea extends LegendArea{
|
||||||
|
|
||||||
@ -36,8 +33,16 @@ public class OurLegendArea extends LegendArea{
|
|||||||
// Erstellt einen neuen TitledBorder für den Legendenbereich
|
// Erstellt einen neuen TitledBorder für den Legendenbereich
|
||||||
setBorder(BorderFactory.createTitledBorder("LegendArea"));
|
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
|
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.setColor(Color.RED);
|
||||||
g.fillOval(10, y, 20, 20); // Zeichnet einen kleinen Kreis (Knoten) mit der Farbe des Elements
|
g.fillOval(10, y, 20, 20); // Zeichnet einen kleinen Kreis (Knoten) mit der Farbe des Elements
|
||||||
g.setColor(Color.BLACK);
|
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.drawOval(10, y, 20, 20); // Zeichnet den Rand des Kreises
|
||||||
g.drawString("Fertiger Weg", 40, y + 15); // Zeichnet die Beschreibung neben dem Kreis
|
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,17 +8,14 @@ import visualizationElements.Edge;
|
|||||||
import visualizationElements.Vertex;
|
import visualizationElements.Vertex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using logging.LogElement.
|
* This class extends logging.LogElement to provide additional functionality
|
||||||
* The super class has been extended by member value and corresponding get method.
|
* for logging various elements related to graph visualization.
|
||||||
* The standard constructor has been overwritten and a new one has been introduced.
|
*
|
||||||
* @see LogElement
|
* @see LogElement
|
||||||
* @author MSch<EFBFBD>fer
|
|
||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
||||||
* <br>
|
|
||||||
*/
|
*/
|
||||||
public class OurLogElement extends LogElement{
|
public class OurLogElement extends LogElement {
|
||||||
|
|
||||||
/** The log elements sum up value. */
|
/** The sum up value associated with this log element. */
|
||||||
protected long value;
|
protected long value;
|
||||||
protected Vertex vertex;
|
protected Vertex vertex;
|
||||||
protected Edge edge;
|
protected Edge edge;
|
||||||
@ -26,7 +23,7 @@ public class OurLogElement extends LogElement{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
* Calls the constructor of super class and sets value 0.
|
* Initializes the log element with default values.
|
||||||
*/
|
*/
|
||||||
public OurLogElement() {
|
public OurLogElement() {
|
||||||
super();
|
super();
|
||||||
@ -35,28 +32,46 @@ public class OurLogElement extends LogElement{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended constructor.
|
* Extended constructor.
|
||||||
* Sets specified step number, description and sum up value.
|
* Initializes the log element with specified step number, description, sum up value, and vertex.
|
||||||
* @param step the log element's step number
|
*
|
||||||
* @param description the log element's step description
|
* @param step the step number of the log element
|
||||||
* @param value the log element's sum up value
|
* @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.step = step;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.vertex = vertex;
|
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.step = step;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.edge = edge;
|
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.step = step;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
@ -64,24 +79,37 @@ public class OurLogElement extends LogElement{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the log element's sum up value.
|
* Retrieves the sum up value associated with this log element.
|
||||||
* @return the log element's sum up value
|
*
|
||||||
|
* @return the sum up value of the log element
|
||||||
*/
|
*/
|
||||||
public long getValue(){
|
public long getValue() {
|
||||||
return this.value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the edge associated with this log element.
|
||||||
|
*
|
||||||
|
* @return the edge associated with the log element
|
||||||
|
*/
|
||||||
public Edge getEdge() {
|
public Edge getEdge() {
|
||||||
return this.edge;
|
return this.edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the vertex associated with this log element.
|
||||||
|
*
|
||||||
|
* @return the vertex associated with the log element
|
||||||
|
*/
|
||||||
public Vertex getVertex() {
|
public Vertex getVertex() {
|
||||||
return this.vertex;
|
return this.vertex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the graph associated with this log element.
|
||||||
|
*
|
||||||
|
* @return the graph associated with the log element
|
||||||
|
*/
|
||||||
public visualizationElements.Graph getGraph() {
|
public visualizationElements.Graph getGraph() {
|
||||||
return this.ourGraph;
|
return this.ourGraph;
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,12 @@ import java.awt.event.ActionEvent;
|
|||||||
import java.awt.event.ActionListener;
|
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
|
* @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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@ -22,32 +21,31 @@ public class OurMethodButtons extends ParameterArea{
|
|||||||
protected JRadioButton button2;
|
protected JRadioButton button2;
|
||||||
private boolean isDjikstra;
|
private boolean isDjikstra;
|
||||||
|
|
||||||
|
|
||||||
/** TextField containing maximum sum up value. */
|
/** TextField containing maximum sum up value. */
|
||||||
protected JTextField maxValue;
|
protected JTextField maxValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
* Creates SumUpMethodArea with an empty JTextField.
|
* Initializes the method buttons panel with default settings.
|
||||||
*/
|
*/
|
||||||
public OurMethodButtons() {
|
public OurMethodButtons() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
isDjikstra = true; // Standardmäßig Djikstra
|
isDjikstra = true; // Default to Djikstra
|
||||||
|
|
||||||
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
|
// Set layout manager to arrange buttons vertically
|
||||||
setLayout(new GridLayout(1, 2, 5, 5)); // 1 Zeile, 2 Spalten, 5 Pixel Abstand
|
setLayout(new GridLayout(1, 2, 5, 5)); // 1 row, 2 columns, 5 pixels gap
|
||||||
|
|
||||||
// Buttons erstellen
|
// Create radio buttons
|
||||||
button1 = new JRadioButton("Djikstra", true);
|
button1 = new JRadioButton("Djikstra", true);
|
||||||
button2 = new JRadioButton("A-Stern");
|
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();
|
ButtonGroup group = new ButtonGroup();
|
||||||
group.add(button1);
|
group.add(button1);
|
||||||
group.add(button2);
|
group.add(button2);
|
||||||
|
|
||||||
// ActionListener hinzufügen
|
// Add action listeners to handle button selections
|
||||||
button1.addActionListener(new ActionListener() {
|
button1.addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent e) {
|
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(button1);
|
||||||
this.add(button2);
|
this.add(button2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieves the selected algorithmic method.
|
||||||
|
*
|
||||||
|
* @return true if Djikstra is selected, false if A-Star is selected
|
||||||
|
*/
|
||||||
public boolean getSelectedMethod() {
|
public boolean getSelectedMethod() {
|
||||||
return isDjikstra;
|
return isDjikstra;
|
||||||
}
|
}
|
||||||
|
@ -5,37 +5,38 @@ import visualisation.ParameterArea;
|
|||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
|
||||||
import java.awt.event.ActionListener;
|
|
||||||
import java.util.Objects;
|
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
|
* @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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// Custom graph instance
|
||||||
private DirectedGraph<VertexMarking, EdgeMarking> customGraph;
|
private DirectedGraph<VertexMarking, EdgeMarking> customGraph;
|
||||||
|
|
||||||
|
// Radio buttons for selecting examples or custom graph
|
||||||
private JRadioButton button1;
|
private JRadioButton button1;
|
||||||
private JRadioButton button2;
|
private JRadioButton button2;
|
||||||
private JRadioButton button3;
|
private JRadioButton button3;
|
||||||
private JRadioButton button4;
|
private JRadioButton button4;
|
||||||
private JRadioButton button5;
|
private JRadioButton button5;
|
||||||
|
|
||||||
|
// Button to add a custom graph
|
||||||
private JButton buttonAddGraph;
|
private JButton buttonAddGraph;
|
||||||
|
|
||||||
|
// Text fields for inputting vertex and edge data
|
||||||
private JTextField textField1;
|
private JTextField textField1;
|
||||||
private JTextField textField2;
|
private JTextField textField2;
|
||||||
|
|
||||||
|
// Selected example identifier
|
||||||
private int selectedExample;
|
private int selectedExample;
|
||||||
|
|
||||||
|
|
||||||
/** TextField containing maximum sum up value. */
|
/** TextField containing maximum sum up value. */
|
||||||
protected JTextField maxValue;
|
protected JTextField maxValue;
|
||||||
|
|
||||||
@ -45,30 +46,31 @@ public class OurParameterArea extends ParameterArea{
|
|||||||
*/
|
*/
|
||||||
public OurParameterArea() {
|
public OurParameterArea() {
|
||||||
super();
|
super();
|
||||||
selectedExample = 1; // Standardmäßig Beispiel 1
|
selectedExample = 1; // Default to example 1
|
||||||
this.customGraph = new DirectedGraph<>();
|
this.customGraph = new DirectedGraph<>();
|
||||||
|
|
||||||
setBorder(BorderFactory.createTitledBorder("ParameterArea"));
|
setBorder(BorderFactory.createTitledBorder("ParameterArea"));
|
||||||
|
|
||||||
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
|
// Set layout manager to arrange buttons vertically
|
||||||
setLayout(new GridLayout(4, 1, 5, 5)); // 4 Zeilen, 1 Spalte, 5 Pixel Abstand
|
setLayout(new GridLayout(4, 1, 5, 5)); // 4 rows, 1 column, 5 pixel gap
|
||||||
|
|
||||||
// Buttons erstellen
|
// Create radio buttons
|
||||||
button1 = new JRadioButton("Beispiel 1", true);
|
button1 = new JRadioButton("Beispiel 1", true);
|
||||||
button2 = new JRadioButton("Beispiel 2");
|
button2 = new JRadioButton("Beispiel 2");
|
||||||
button3 = new JRadioButton("Beispiel 3");
|
button3 = new JRadioButton("Beispiel 3");
|
||||||
button4 = new JRadioButton("Beispiel 4");
|
button4 = new JRadioButton("Beispiel 4");
|
||||||
button5 = new JRadioButton("Eigener Graph");
|
button5 = new JRadioButton("Eigener Graph");
|
||||||
|
|
||||||
|
// Button to add a graph
|
||||||
buttonAddGraph = new JButton("Graph einfügen");
|
buttonAddGraph = new JButton("Graph einfügen");
|
||||||
// Eingabefelder
|
|
||||||
|
// Input text fields
|
||||||
textField1 = new JTextField("A-100-100;Ende-200-200;Start-100-200;D-200-100");
|
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");
|
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()));
|
textField1.setPreferredSize(new Dimension(button5.getWidth(), button5.getHeight()));
|
||||||
textField2.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();
|
ButtonGroup group = new ButtonGroup();
|
||||||
group.add(button1);
|
group.add(button1);
|
||||||
group.add(button2);
|
group.add(button2);
|
||||||
@ -76,39 +78,36 @@ public class OurParameterArea extends ParameterArea{
|
|||||||
group.add(button4);
|
group.add(button4);
|
||||||
group.add(button5);
|
group.add(button5);
|
||||||
|
|
||||||
// ActionListener hinzufügen
|
// Add action listeners to radio buttons
|
||||||
button1.addActionListener(e -> selectedExample = 1);
|
button1.addActionListener(e -> selectedExample = 1);
|
||||||
|
|
||||||
button2.addActionListener(e -> selectedExample = 2);
|
button2.addActionListener(e -> selectedExample = 2);
|
||||||
|
|
||||||
button3.addActionListener(e -> selectedExample = 3);
|
button3.addActionListener(e -> selectedExample = 3);
|
||||||
|
|
||||||
button4.addActionListener(e -> selectedExample = 4);
|
button4.addActionListener(e -> selectedExample = 4);
|
||||||
|
|
||||||
button5.addActionListener(e -> selectedExample = 5);
|
button5.addActionListener(e -> selectedExample = 5);
|
||||||
|
|
||||||
|
// Add action listener to add graph button
|
||||||
buttonAddGraph.addActionListener(e -> {
|
buttonAddGraph.addActionListener(e -> {
|
||||||
|
|
||||||
String input1 = textField1.getText();
|
String input1 = textField1.getText();
|
||||||
String input2 = textField2.getText();
|
String input2 = textField2.getText();
|
||||||
this.customGraph = createGraph(input1, input2);
|
this.customGraph = createGraph(input1, input2);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// Buttons zum Panel hinzufügen
|
// Add components to panel
|
||||||
add(button1);
|
add(button1);
|
||||||
add(button2);
|
add(button2);
|
||||||
add(button3);
|
add(button3);
|
||||||
add(button4);
|
add(button4);
|
||||||
add(button5);
|
add(button5);
|
||||||
|
|
||||||
add(buttonAddGraph);
|
add(buttonAddGraph);
|
||||||
add(textField1);
|
add(textField1);
|
||||||
add(textField2);
|
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() {
|
public DirectedGraph<VertexMarking, EdgeMarking> getSelectedGraph() {
|
||||||
ExampleGraphs temp = new ExampleGraphs();
|
ExampleGraphs temp = new ExampleGraphs();
|
||||||
switch (selectedExample) {
|
switch (selectedExample) {
|
||||||
@ -126,21 +125,26 @@ public class OurParameterArea extends ParameterArea{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
// Vertex Beispiel-Eingabe: A-100-100;Ende-200-200;Start-100-200;D-200-100
|
* Creates a directed graph based on input vertex and edge data.
|
||||||
// Edge Beispiel-Eingabe: A-B-15;C-D-10;D-A-3
|
*
|
||||||
|
* @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.
|
||||||
|
*/
|
||||||
public DirectedGraph<VertexMarking, EdgeMarking> createGraph(String vertices, String edges) {
|
public DirectedGraph<VertexMarking, EdgeMarking> createGraph(String vertices, String edges) {
|
||||||
DirectedGraph<VertexMarking, EdgeMarking> newGraph = new DirectedGraph<>();
|
DirectedGraph<VertexMarking, EdgeMarking> newGraph = new DirectedGraph<>();
|
||||||
|
|
||||||
|
|
||||||
String[] allVertices = vertices.split(";");
|
String[] allVertices = vertices.split(";");
|
||||||
String[] allEdges = edges.split(";");
|
String[] allEdges = edges.split(";");
|
||||||
|
|
||||||
|
// Create vertices
|
||||||
for (String i: allVertices) {
|
for (String i: allVertices) {
|
||||||
String[] current = i.split("-");
|
String[] current = i.split("-");
|
||||||
newGraph.addVertex(new MarkedVertex<>(Integer.parseInt(current[1]), Integer.parseInt(current[2]), current[0], null, Color.BLACK));
|
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> start = null;
|
||||||
MarkedVertex<VertexMarking> end = null;
|
MarkedVertex<VertexMarking> end = null;
|
||||||
for (String i: allEdges) {
|
for (String i: allEdges) {
|
||||||
@ -158,5 +162,4 @@ public class OurParameterArea extends ParameterArea{
|
|||||||
|
|
||||||
return newGraph;
|
return newGraph;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,39 +5,40 @@ import logging.LogElementList;
|
|||||||
import visualisation.TextArea;
|
import visualisation.TextArea;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using visualization.TextArea.
|
* This class extends visualisation.TextArea and provides an example of its usage.
|
||||||
* Constructors and print() method have been overwritten.
|
* It overrides constructors and the print() method.
|
||||||
|
*
|
||||||
* @see TextArea
|
* @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;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Default constructor for creating an instance of OurTextArea.
|
||||||
|
* Initializes with default settings.
|
||||||
*/
|
*/
|
||||||
public OurTextArea() {
|
public OurTextArea() {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extended constructor.
|
* Extended constructor for creating an instance of OurTextArea.
|
||||||
* Sets LogElementList of TestLogElements as log list.
|
* Sets the initial LogElementList of OurLogElement as the log list.
|
||||||
* @param logList the text area's log element list.
|
*
|
||||||
|
* @param logList the LogElementList containing OurLogElement objects for the text area's log.
|
||||||
*/
|
*/
|
||||||
public OurTextArea(LogElementList<OurLogElement>logList){
|
public OurTextArea(LogElementList<OurLogElement> logList) {
|
||||||
super(logList);
|
super(logList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Textual output of a log element.
|
* Outputs the description of a log element to the text area.
|
||||||
* No output.
|
*
|
||||||
|
* @return true if the operation is successful, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean print(){
|
public boolean print() {
|
||||||
LogElement logElement=(LogElement)logList.get();
|
LogElement logElement = (LogElement) logList.get();
|
||||||
setText(logElement.getDescription());
|
setText(logElement.getDescription());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user