ProjektGraph/OurApplication/OurDrawArea.java

99 lines
2.4 KiB
Java
Raw Blame History

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;
/**
* This class provides an example for using visualization.DrawArea.
* @see logging.Algorithm
@author MSch<63>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){
OurLogElement logElement=(OurLogElement)logList.get();
drawGraph(logElement.getGraph(), g);
}
private void drawGraph(DirectedGraph<VertexMarking, EdgeMarking> ourGraph, Graphics g) {
String convertedMarking;
Vector<Vertex> vertexes = new Vector<Vertex>();
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, i.getColor()));
}
Vector<Edge> edges = new Vector<Edge>();
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);
/*Vector<Vertex> vertexes = new Vector<Vertex>();
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);
graph.draw(g);*/
}
}