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�fer * DHBW Stuttgart/Campus Horb AI2008
*
*/ 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 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 ourGraph, Graphics g) { String convertedMarking; Vector vertexes = new Vector(); for(MarkedVertex 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 edges = new Vector(); for(MarkedEdge 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 vertexes = new Vector(); for(MarkedVertex i : ourGraph.getAllVertexes()){ vertexes.add(new Vertex(i.getXCoordinate(), i.getYCoordinate(), i.getName()+i.getDistance(), i.getColor())); } Vector edges = new Vector(); for(MarkedEdge 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);*/ } }