2024-07-02 19:13:30 +00:00
|
|
|
|
package OurApplication;
|
|
|
|
|
|
|
|
|
|
import logging.LogElementList;
|
|
|
|
|
import visualisation.DrawArea;
|
2024-07-06 18:37:42 +00:00
|
|
|
|
import visualizationElements.Edge;
|
2024-07-07 18:34:38 +00:00
|
|
|
|
import visualizationElements.Vertex;
|
2024-07-06 18:37:42 +00:00
|
|
|
|
|
2024-07-07 18:34:38 +00:00
|
|
|
|
import javax.swing.*;
|
2024-07-06 18:37:42 +00:00
|
|
|
|
import java.awt.Graphics;
|
2024-07-07 18:34:38 +00:00
|
|
|
|
import java.awt.event.MouseEvent;
|
|
|
|
|
import java.awt.event.MouseListener;
|
2024-07-02 19:13:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
2024-07-04 19:18:57 +00:00
|
|
|
|
private visualizationElements.Graph currentGraph;
|
2024-07-03 17:41:46 +00:00
|
|
|
|
|
2024-07-02 19:13:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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);
|
|
|
|
|
}
|
2024-07-03 17:41:46 +00:00
|
|
|
|
|
|
|
|
|
|
2024-07-04 19:18:57 +00:00
|
|
|
|
public void setCurrentGraph(visualizationElements.Graph graph) {
|
2024-07-03 17:41:46 +00:00
|
|
|
|
this.currentGraph = graph;
|
|
|
|
|
}
|
2024-07-02 19:13:30 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Draws a visualization element.
|
|
|
|
|
*/
|
|
|
|
|
|
2024-07-02 22:46:21 +00:00
|
|
|
|
public void draw(Graphics g) {
|
2024-07-02 19:13:30 +00:00
|
|
|
|
|
2024-07-03 17:41:46 +00:00
|
|
|
|
OurLogElement logElement = (OurLogElement) logList.get();
|
2024-07-07 14:27:22 +00:00
|
|
|
|
this.setCurrentGraph(((OurLogElement) logList.get()).getGraph());
|
2024-07-04 19:18:57 +00:00
|
|
|
|
logElement.getGraph().draw(g);
|
2024-07-06 18:37:42 +00:00
|
|
|
|
for(Edge screenEdge : currentGraph.getEdges()){
|
|
|
|
|
g.drawString(screenEdge.getMarking(), (screenEdge.getSource().getXpos() + screenEdge.getDestination().getXpos())/2, (screenEdge.getSource().getYpos() + screenEdge.getDestination().getYpos())/2);
|
|
|
|
|
}
|
2024-07-02 19:13:30 +00:00
|
|
|
|
|
|
|
|
|
}
|
2024-07-03 17:41:46 +00:00
|
|
|
|
|
2024-07-02 19:13:30 +00:00
|
|
|
|
}
|