2024-06-27 13:05:22 +00:00
|
|
|
|
package OurApplication;
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
import graph.*;
|
|
|
|
|
import logging.LogElement;
|
2024-06-27 13:05:22 +00:00
|
|
|
|
import logging.LogElementList;
|
|
|
|
|
import visualisation.DrawArea;
|
2024-07-01 15:08:11 +00:00
|
|
|
|
import visualizationElements.Edge;
|
|
|
|
|
import visualizationElements.Graph;
|
2024-06-27 13:05:22 +00:00
|
|
|
|
import visualizationElements.List;
|
|
|
|
|
import visualizationElements.Queue;
|
|
|
|
|
import visualizationElements.*;
|
2024-07-01 15:08:11 +00:00
|
|
|
|
import visualizationElements.Vertex;
|
2024-06-27 13:05:22 +00:00
|
|
|
|
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.util.Vector;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* This class provides an example for using visualization.DrawArea.
|
|
|
|
|
* @see logging.Algorithm
|
|
|
|
|
@author MSch<EFBFBD>fer
|
|
|
|
|
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
|
|
|
* <br>
|
|
|
|
|
*/
|
|
|
|
|
public class OurDrawArea extends DrawArea{
|
|
|
|
|
|
|
|
|
|
private static final long serialVersionUID = 1L;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Standard constructor.
|
|
|
|
|
*/
|
|
|
|
|
public OurDrawArea() {
|
|
|
|
|
super();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates a test draw area and sets the specified log list.
|
|
|
|
|
* @param logList the draw area's log list test log elements.
|
|
|
|
|
* @param drawAreaName The display name over the draw area.
|
|
|
|
|
*/
|
|
|
|
|
public OurDrawArea(LogElementList<OurLogElement> logList, String drawAreaName){
|
|
|
|
|
super(logList, drawAreaName);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draws a visualization element.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public void draw(Graphics g){
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
OurLogElement logElement=(OurLogElement)logList.get();
|
|
|
|
|
drawGraph(logElement.getGraph(), g);
|
|
|
|
|
|
2024-06-27 13:05:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
private void drawGraph(DirectedGraph<VertexMarking, EdgeMarking> ourGraph, Graphics g) {
|
|
|
|
|
String convertedMarking;
|
|
|
|
|
|
2024-07-02 15:51:22 +00:00
|
|
|
|
Vector<Vertex> vertexes = new Vector<Vertex>();
|
2024-07-01 15:08:11 +00:00
|
|
|
|
|
|
|
|
|
for(MarkedVertex<VertexMarking> i : ourGraph.getAllVertexes()){
|
|
|
|
|
if(i.getMarking() != null){
|
|
|
|
|
convertedMarking = i.getMarking().toString();
|
|
|
|
|
}else{
|
|
|
|
|
convertedMarking = "";
|
|
|
|
|
}
|
2024-07-02 15:51:22 +00:00
|
|
|
|
vertexes.add(new Vertex(i.getXCoordinate(), i.getYCoordinate(), convertedMarking, i.getColor()));
|
2024-07-01 15:08:11 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 13:05:22 +00:00
|
|
|
|
Vector<Edge> edges = new Vector<Edge>();
|
2024-07-01 15:08:11 +00:00
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
2024-07-02 15:51:22 +00:00
|
|
|
|
graph.draw(g);
|
2024-07-01 18:10:25 +00:00
|
|
|
|
|
2024-07-02 15:51:22 +00:00
|
|
|
|
/*Vector<Vertex> vertexes = new Vector<Vertex>();
|
2024-07-01 18:10:25 +00:00
|
|
|
|
|
|
|
|
|
for(MarkedVertex<VertexMarking> i : ourGraph.getAllVertexes()){
|
|
|
|
|
|
|
|
|
|
vertexes.add(new Vertex(i.getXCoordinate(), i.getYCoordinate(), i.getName()+i.getDistance(), i.getColor()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Vector<Edge> edges = new Vector<Edge>();
|
|
|
|
|
|
|
|
|
|
for(MarkedEdge<EdgeMarking> i : ourGraph.getAllEdges()){
|
|
|
|
|
edges.add(new Edge(i.getSource(), i.getDestination(), "i.getMarking()", Color.BLACK));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Graph graph = new Graph(vertexes, edges, true, EdgeStyle.Direct);
|
|
|
|
|
|
2024-07-02 15:51:22 +00:00
|
|
|
|
graph.draw(g);*/
|
2024-07-01 18:10:25 +00:00
|
|
|
|
|
2024-06-27 13:05:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|