Visualisation progress

This commit is contained in:
i23007 2024-07-01 17:08:11 +02:00
parent 6b0caa1a5e
commit 12dbadf5e1
12 changed files with 239 additions and 85 deletions

124
.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

69
.idea/workspace.xml generated
View File

@ -4,17 +4,19 @@
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="">
<change afterPath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurApplication.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurHybridWindow.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurLegendArea.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/OurApplication/OurTextArea.java" afterDir="false" />
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="OurApplication test">
<change afterPath="$PROJECT_DIR$/.idea/uiDesigner.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/Main.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/OurLogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.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/Display.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Display.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/MarkedVertex.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedVertex.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/Vertex.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Vertex.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/VertexMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/VertexMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/logging/LogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/logging/LogElement.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -24,8 +26,8 @@
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Class" />
<option value="HTML File" />
<option value="Class" />
</list>
</option>
</component>
@ -49,17 +51,18 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"DefaultHtmlFileTemplate": "HTML File",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"git-widget-placeholder": "main",
"kotlin-language-version-configured": "true",
"last_opened_file_path": "C:/Users/jonas/DHBW Dateien/Semester 2/Programmieren 2/Projekt/ProjektGraph/OurApplication",
"settings.editor.selected.configurable": "vcs.Git"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;DefaultHtmlFileTemplate&quot;: &quot;HTML File&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;main&quot;,
&quot;kotlin-language-version-configured&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;C:/Users/jonas/DHBW Dateien/Semester 2/Programmieren 2/Projekt/ProjektGraph/OurApplication&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;vcs.Git&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="C:\Users\jonas\DHBW Dateien\Semester 2\Programmieren 2\Projekt\ProjektGraph\OurApplication" />
@ -88,7 +91,15 @@
<option name="project" value="LOCAL" />
<updated>1719479266810</updated>
</task>
<option name="localTasksCounter" value="2" />
<task id="LOCAL-00002" summary="OurApplication test">
<option name="closed" value="true" />
<created>1719493522512</created>
<option name="number" value="00002" />
<option name="presentableId" value="LOCAL-00002" />
<option name="project" value="LOCAL" />
<updated>1719493522512</updated>
</task>
<option name="localTasksCounter" value="3" />
<servers />
</component>
<component name="Vcs.Log.Tabs.Properties">
@ -104,17 +115,7 @@
</component>
<component name="VcsManagerConfiguration">
<MESSAGE value="Visualisation tests" />
<option name="LAST_COMMIT_MESSAGE" value="Visualisation tests" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<line-breakpoint enabled="true" type="java-line">
<url>file://$PROJECT_DIR$/OurApplication/OurApplication.java</url>
<line>56</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
<MESSAGE value="OurApplication test" />
<option name="LAST_COMMIT_MESSAGE" value="OurApplication test" />
</component>
</project>

View File

@ -1,8 +1,11 @@
package OurApplication;
import graph.*;
import logging.Algorithm;
import logging.LogElementList;
import java.util.Random;
/**
* 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.
@ -33,14 +36,27 @@ public class OurAlgorithm extends Algorithm{
*/
public LogElementList run(){
LogElementList<OurLogElement>logList = new LogElementList<OurLogElement>();
for(int i=1;i<=10;i++){
for(int x=1;x<=10;x++){
Random random = new Random();
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
for (int i = 0; i < 10; i++) {
myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null, random.nextInt(i, 350), random.nextInt(i, 350)));
}
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
try{
logList.add(new OurLogElement(i, "Value", i));
logList.add(new OurLogElement(x, "Value", x, myGraph));
}
catch(OutOfMemoryError e){
System.err.println("Out of memory");
System.err.println("Out of memory");
}
}
return logList;

View File

@ -39,20 +39,6 @@ public class OurApplication {
*/
public static void main(String[]args){
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
for (int i = 0; i < 10; i++) {
myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null));
}
Random random = new Random();
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
}
LogElementList<OurLogElement>logList=new LogElementList<OurLogElement>();
OurParameterArea parameterArea=new OurParameterArea();

View File

@ -1,10 +1,15 @@
package OurApplication;
import graph.*;
import logging.LogElement;
import logging.LogElementList;
import visualisation.DrawArea;
import visualizationElements.Edge;
import visualizationElements.Graph;
import visualizationElements.List;
import visualizationElements.Queue;
import visualizationElements.*;
import visualizationElements.Vertex;
import java.awt.*;
import java.util.Vector;
@ -43,38 +48,33 @@ public class OurDrawArea extends DrawArea{
public void draw(Graphics g){
drawGraph(g);
OurLogElement logElement=(OurLogElement)logList.get();
drawGraph(logElement.getGraph(), g);
}
private void drawGraph(Graphics g) {
// create/add vertexes
private void drawGraph(DirectedGraph<VertexMarking, EdgeMarking> ourGraph, Graphics g) {
String convertedMarking;
Vector<Vertex> vertexes = new Vector<Vertex>();
vertexes.add(new Vertex(20, 20, "1", Color.BLACK));
vertexes.add(new Vertex(80, 20, "2", Color.BLACK));
vertexes.add(new Vertex(100, 80, "3", Color.BLACK));
vertexes.add(new Vertex(180, 60, "4", Color.BLUE));
vertexes.add(new Vertex(20, 80, "5", Color.BLACK));
vertexes.add(new Vertex(120, 140, "6", Color.BLACK));
vertexes.add(new Vertex(20, 180, "7", Color.BLACK));
// create/add edges
for(MarkedVertex<VertexMarking> i : ourGraph.getAllVertexes()){
if(i.getMarking() != null){
convertedMarking = i.getMarking().toString();
}else{
convertedMarking = "";
}
vertexes.add(new Vertex(i.getXCoordinate(), i.getYCoordinate(), convertedMarking, Color.BLUE));
}
Vector<Edge> edges = new Vector<Edge>();
edges.add(new Edge(vertexes.get(0), vertexes.get(1), "1", Color.WHITE));
edges.add(new Edge(vertexes.get(1), vertexes.get(4), "1", Color.BLACK));
edges.add(new Edge(vertexes.get(0), vertexes.get(4), "1", Color.BLACK));
edges.add(new Edge(vertexes.get(2), vertexes.get(3), "1", Color.BLACK));
edges.add(new Edge(vertexes.get(3), vertexes.get(2), "1", Color.BLACK));
edges.add(new Edge(vertexes.get(4), vertexes.get(6), "1", Color.BLACK));
edges.add(new Edge(vertexes.get(6), vertexes.get(6), "1", Color.BLACK));
// create graph
Graph graph = new Graph(vertexes, edges, false, EdgeStyle.Direct);
for(MarkedEdge<EdgeMarking> i : ourGraph.getAllEdges()){
edges.add(new Edge(vertexes.get(0), vertexes.get(5), "i.getMarking()", Color.BLACK));
}
Graph graph = new Graph(vertexes, edges, true, EdgeStyle.Direct);
graph.draw(g);
}
}

View File

@ -1,5 +1,8 @@
package OurApplication;
import graph.DirectedGraph;
import graph.EdgeMarking;
import graph.VertexMarking;
import logging.LogElement;
/**
@ -15,6 +18,7 @@ public class OurLogElement extends LogElement{
/** The log elements sum up value. */
protected long value;
protected DirectedGraph<VertexMarking, EdgeMarking> ourGraph;
/**
* Standard constructor.
@ -32,10 +36,11 @@ public class OurLogElement extends LogElement{
* @param description the log element's step description
* @param value the log element's sum up value
*/
public OurLogElement(int step, String description, long value){
public OurLogElement(int step, String description, long value, DirectedGraph<VertexMarking, EdgeMarking> ourGraph){
this.step=step;
this.description=description;
this.value=value;
this.ourGraph = ourGraph;
}
/**
@ -45,5 +50,8 @@ public class OurLogElement extends LogElement{
public long getValue(){
return value;
}
public DirectedGraph<VertexMarking, EdgeMarking> getGraph(){
return this.ourGraph;
}
}

View File

@ -1,5 +1,6 @@
package graph;
import java.awt.*;
import java.util.HashMap;
import java.util.Objects;
import java.util.PriorityQueue;

View File

@ -8,7 +8,7 @@ public class Display {
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
for (int i = 0; i < 10; i++) {
myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null));
myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null, i, i));
}
Random random = new Random();

View File

@ -14,9 +14,11 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex{
}
public MarkedVertex(String s, T t) {
public MarkedVertex(String s, T t, int x, int y) {
super(s);
this.marking = t;
this.setXCoordinate(x);
this.setYCoordinate(y);
}

View File

@ -5,6 +5,8 @@ public abstract class Vertex {
// ATTRIBUTE
private String name;
private int xCoordinate;
private int yCoordinate;
// KONSTRUKTOREN
@ -24,13 +26,23 @@ public abstract class Vertex {
public String getName() {
return this.name;
}
public int getXCoordinate(){
return this.xCoordinate;
}
public int getYCoordinate(){
return this.yCoordinate;
}
// SET-ER
public void setName(String s) {
this.name = s;
}
public void setXCoordinate(int xCoordinate){
this.xCoordinate=xCoordinate;
}
public void setYCoordinate(int yCoordinate){
this.yCoordinate=yCoordinate;
}
}

View File

@ -1,4 +1,5 @@
package graph;
public abstract class VertexMarking extends Marking {
private String mark;
}

View File

@ -1,5 +1,8 @@
package logging;
import graph.DirectedGraph;
import graph.EdgeMarking;
import graph.VertexMarking;
import visualisation.HybridWindow;
/**