81 lines
2.2 KiB
Java
81 lines
2.2 KiB
Java
package OurApplication;
|
||
|
||
import logging.LogElementList;
|
||
import visualisation.DrawArea;
|
||
import visualizationElements.List;
|
||
import visualizationElements.Queue;
|
||
import visualizationElements.*;
|
||
|
||
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){
|
||
|
||
drawGraph(g);
|
||
}
|
||
|
||
private void drawGraph(Graphics g) {
|
||
|
||
// create/add vertexes
|
||
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
|
||
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);
|
||
|
||
graph.draw(g);
|
||
}
|
||
}
|