65 lines
1.6 KiB
Java
65 lines
1.6 KiB
Java
package OurApplication;
|
||
|
||
import logging.LogElementList;
|
||
import visualisation.DrawArea;
|
||
import visualizationElements.Edge;
|
||
import visualizationElements.Vertex;
|
||
|
||
import javax.swing.*;
|
||
import java.awt.Graphics;
|
||
import java.awt.event.MouseEvent;
|
||
import java.awt.event.MouseListener;
|
||
|
||
|
||
/**
|
||
* 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;
|
||
|
||
private visualizationElements.Graph currentGraph;
|
||
|
||
|
||
/**
|
||
* 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);
|
||
}
|
||
|
||
|
||
public void setCurrentGraph(visualizationElements.Graph graph) {
|
||
this.currentGraph = graph;
|
||
}
|
||
|
||
/**
|
||
* Draws a visualization element.
|
||
*/
|
||
|
||
public void draw(Graphics g) {
|
||
|
||
OurLogElement logElement = (OurLogElement) logList.get();
|
||
this.setCurrentGraph(((OurLogElement) logList.get()).getGraph());
|
||
logElement.getGraph().draw(g);
|
||
for(Edge screenEdge : currentGraph.getEdges()){
|
||
g.drawString(screenEdge.getMarking(), (screenEdge.getSource().getXpos() + screenEdge.getDestination().getXpos())/2, (screenEdge.getSource().getYpos() + screenEdge.getDestination().getYpos())/2);
|
||
}
|
||
|
||
}
|
||
|
||
}
|