ProjektGraph/OurApplication/OurDrawArea.java

77 lines
1.8 KiB
Java
Raw Normal View History

2024-07-02 19:13:30 +00:00
package OurApplication;
import graph.*;
2024-07-03 17:41:46 +00:00
import graph.Graph;
2024-07-02 19:13:30 +00:00
import logging.LogElementList;
import visualisation.DrawArea;
import visualizationElements.*;
import java.awt.*;
2024-07-02 22:46:21 +00:00
import java.util.Random;
2024-07-02 19:13:30 +00:00
import java.util.Vector;
/**
* 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-03 17:41:46 +00:00
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
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
public void setCurrentGraph(Graph<VertexMarking, EdgeMarking> graph) {
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
this.currentGraph.getScreenGraph().draw(g);
2024-07-02 19:13:30 +00:00
2024-07-03 17:41:46 +00:00
OurLogElement logElement = (OurLogElement) logList.get();
2024-07-02 19:13:30 +00:00
2024-07-03 17:41:46 +00:00
if (logElement.getVertex() != null) {
if (logElement.getVertex().getColor() == Color.BLACK) {
logElement.getVertex().setColor(Color.YELLOW);
} else if (logElement.getVertex().getColor() == Color.YELLOW) {
logElement.getVertex().setColor(Color.BLUE);
}
} else {
if (logElement.getEdge().getColor() == Color.BLACK) {
logElement.getEdge().setColor(Color.YELLOW);
} else if (logElement.getEdge().getColor() == Color.YELLOW) {
logElement.getEdge().setColor(Color.BLUE);
}
}
2024-07-02 19:13:30 +00:00
2024-07-03 17:41:46 +00:00
logElement.getVertex().draw(g);
2024-07-02 19:13:30 +00:00
}
2024-07-03 17:41:46 +00:00
2024-07-02 19:13:30 +00:00
}