package OurApplication; import graph.VertexMarking; import graph.EdgeMarking; import logging.LogElementList; import visualisation.DrawArea; import visualizationElements.Edge; import java.awt.Graphics; /** * This class provides an example for using visualization.DrawArea. * It extends DrawArea to visualize a graph based on logging elements. * * @see DrawArea */ public class OurDrawArea extends DrawArea { private static final long serialVersionUID = 1L; private graph.Graph currentGraph; /** * Standard constructor. * Initializes an empty draw area. */ public OurDrawArea() { super(); } /** * Extended constructor. * Creates a draw area with a specified log list and display name. * * @param logList the draw area's log element list * @param drawAreaName the display name over the draw area */ public OurDrawArea(LogElementList logList, String drawAreaName) { super(logList, drawAreaName); } /** * Draws visualization elements on the draw area. * @param g the graphics context used for drawing */ public void draw(Graphics g) { // Get the current log element from the log list OurLogElement logElement = (OurLogElement) logList.get(); // Draw the graph associated with the log element, if available if (logElement.getGraph() != null) { logElement.getGraph().draw(g); // Draw markings on edges for (Edge screenEdge : logElement.getGraph().getEdges()) { g.drawString(screenEdge.getMarking(), (screenEdge.getSource().getXpos() + screenEdge.getDestination().getXpos()) / 2, (screenEdge.getSource().getYpos() + screenEdge.getDestination().getYpos()) / 2); } } } }