Compare commits

..

No commits in common. "80d48d53352e4343902b98e14f656fc95ecb59d7" and "73d4a6b9aa80a975697df384cf87d9c81c6aee90" have entirely different histories.

9 changed files with 59 additions and 125 deletions

15
.idea/workspace.xml generated
View File

@ -5,29 +5,22 @@
</component>
<component name="ChangeListManager">
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="LegendArea gestaltet">
<change afterPath="$PROJECT_DIR$/graph/EdgeWeightMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/OurApplication/OurApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurApplication.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/DirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/DirectedGraph.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/EdgeMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/EdgeMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/UndirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/UndirectedGraph.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/OurParameterArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurParameterArea.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/EdgeWeightMarking.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/EdgeWeightMarking.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/DirectedGraph.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/DirectedGraph.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/ExampleGraphs.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/ExampleGraphs.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/UndirectedGraph.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/UndirectedGraph.class" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_BRANCH_BY_REPOSITORY">
<map>

View File

@ -6,7 +6,6 @@ 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;
@ -54,7 +53,7 @@ public class OurApplication {
LogElementList<OurLogElement> logList = new LogElementList<>();
LogElementList<OurLogElement> logList=new LogElementList<OurLogElement>();
OurParameterArea parameterArea = new OurParameterArea();
OurMethodButtons methodButtons = new OurMethodButtons();
OurDrawArea drawArea = new OurDrawArea(logList,"GraphVisualization");
@ -77,4 +76,5 @@ public class OurApplication {
frame.setVisible(true);
}
}

View File

@ -1,6 +1,9 @@
package OurApplication;
import graph.*;
import graph.DirectedGraph;
import graph.EdgeMarking;
import graph.ExampleGraphs;
import graph.VertexMarking;
import visualisation.ParameterArea;
import javax.swing.*;
@ -19,19 +22,13 @@ public class OurParameterArea extends ParameterArea{
private static final long serialVersionUID = 1L;
private DirectedGraph<VertexMarking, EdgeMarking> customGraph;
private JRadioButton button1;
private JRadioButton button2;
private JRadioButton button3;
private JRadioButton button4;
private JRadioButton button5;
private JButton buttonAddGraph;
private JTextField textField1;
private JTextField textField2;
private ExampleGraphs temp;
private int selectedExample;
@ -44,8 +41,8 @@ public class OurParameterArea extends ParameterArea{
*/
public OurParameterArea() {
super();
temp = new ExampleGraphs();
selectedExample = 1; // Standardmäßig Beispiel 1
this.customGraph = new DirectedGraph<>();
setBorder(BorderFactory.createTitledBorder("ParameterArea"));
@ -59,11 +56,6 @@ public class OurParameterArea extends ParameterArea{
button4 = new JRadioButton("Beispiel 4");
button5 = new JRadioButton("Eigener Graph");
buttonAddGraph = new JButton("Graph einfügen");
// Eingabefelder
textField1 = new JTextField("Knoten");
textField2 = new JTextField("Kanten");
// ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten
ButtonGroup group = new ButtonGroup();
@ -74,33 +66,47 @@ public class OurParameterArea extends ParameterArea{
group.add(button5);
// ActionListener hinzufügen
button1.addActionListener(e -> selectedExample = 1);
button2.addActionListener(e -> selectedExample = 2);
button3.addActionListener(e -> selectedExample = 3);
button4.addActionListener(e -> selectedExample = 4);
button5.addActionListener(e -> selectedExample = 5);
buttonAddGraph.addActionListener(e -> {
String input1 = textField1.getText();
String input2 = textField2.getText();
this.customGraph = createGraph(input1, input2);
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedExample = 1;
}
});
// Buttons zum Panel hinzufügen
add(button1);
add(button2);
add(button3);
add(button4);
add(button5);
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedExample = 2;
}
});
add(buttonAddGraph);
add(textField1);
add(textField2);
button3.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedExample = 3;
}
});
button4.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedExample = 4;
}
});
button5.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectedExample = 5;
}
});
// Buttons zum Panel hinzufügen
add(button1);
add(button2);
add(button3);
add(button4);
add(button5);
}
public DirectedGraph<VertexMarking, EdgeMarking> getSelectedGraph() {
@ -113,43 +119,11 @@ public class OurParameterArea extends ParameterArea{
case 4:
return temp.example4();
case 5:
return this.customGraph;
return new DirectedGraph<>();
case 1:
default:
return temp.example1();
}
}
// Vertex Eingabe: A-23-23;A-23-23
// Edge Eingabe: A-B-15;A-B-15
public DirectedGraph<VertexMarking, EdgeMarking> createGraph(String vertices, String edges) {
DirectedGraph<VertexMarking, EdgeMarking> newGraph = new DirectedGraph<>();
String[] allVertices = vertices.split(";");
String[] allEdges = edges.split(";");
for (String i: allVertices) {
String[] current = i.split("-");
newGraph.addVertex(new MarkedVertex<>(Integer.parseInt(current[1]), Integer.parseInt(current[2]), current[0], null, Color.BLACK));
}
MarkedVertex<VertexMarking> start = null;
MarkedVertex<VertexMarking> end = null;
for (String i: allEdges) {
String[] current = i.split("-");
for (MarkedVertex<VertexMarking> j: newGraph.getAllVertexes()) {
if (j.getName() == current[0]) {
start = j;
} else if (j.getName() == current[1]) {
end = j;
}
}
newGraph.addEdge(new MarkedEdge<>(i, start, end, new EdgeWeightMarking(Integer.parseInt(current[2]))));
}
return newGraph;
}
}

View File

@ -254,9 +254,7 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// Logging
textDescription = "Visit " + nextVertex.getElement().getName();
System.out.println(textDescription);
if (nextVertex.getElement().getScreenVertex().getColor() != Color.RED) {
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
}
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
@ -307,9 +305,7 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// Logging
textDescription = "Add " + i.getName() + " with " + dist + " weight to queue.";
System.out.println(textDescription);
if (i.getScreenVertex().getColor() != Color.RED) {
i.getScreenVertex().setColor(Color.YELLOW);
}
i.getScreenVertex().setColor(Color.YELLOW);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
// Nehme nächsten Knoten in die Queue auf
@ -391,9 +387,7 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// Logging
textDescription = "Visit " + nextVertex.getElement().getName();
System.out.println(textDescription);
if (nextVertex.getElement().getScreenVertex().getColor() != Color.RED) {
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
}
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
// Wenn Weg gefunden, brich ab
@ -448,9 +442,7 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// Logging
textDescription = "Add " + i.getName() + " with " + dist + " weight to queue.";
System.out.println(textDescription);
if (i.getScreenVertex().getColor() != Color.RED) {
i.getScreenVertex().setColor(Color.YELLOW);
}
i.getScreenVertex().setColor(Color.YELLOW);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
// Nehme nächsten Knoten in die Queue auf

View File

@ -1,17 +0,0 @@
package graph;
public class EdgeWeightMarking extends EdgeMarking {
private int weight;
public EdgeWeightMarking(int weight){
this.weight = weight;
}
public void setWeight(int weight){
this.weight=weight;
}
public int getWeight(){
return this.weight;
}
}

View File

@ -260,9 +260,7 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
// Logging
textDescription = "Visit " + nextVertex.getElement().getName();
System.out.println(textDescription);
if (nextVertex.getElement().getScreenVertex().getColor() != Color.RED) {
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
}
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
@ -313,9 +311,7 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
// Logging
textDescription = "Add " + i.getName() + " with " + dist + " weight to queue.";
System.out.println(textDescription);
if (i.getScreenVertex().getColor() != Color.RED) {
i.getScreenVertex().setColor(Color.YELLOW);
}
i.getScreenVertex().setColor(Color.YELLOW);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
// Nehme nächsten Knoten in die Queue auf
@ -404,9 +400,7 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
// Logging
textDescription = "Visit " + nextVertex.getElement().getName();
System.out.println(textDescription);
if (nextVertex.getElement().getScreenVertex().getColor() != Color.RED) {
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
}
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
@ -459,9 +453,7 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
// Logging
textDescription = "Add " + i.getName() + " with " + dist + " weight to queue.";
System.out.println(textDescription);
if (i.getScreenVertex().getColor() != Color.RED) {
i.getScreenVertex().setColor(Color.YELLOW);
}
i.getScreenVertex().setColor(Color.YELLOW);
this.logList.add(new OurLogElement(step, textDescription, 0, this.getScreenGraphCopy()));
// Nehme nächsten Knoten in die Queue auf