ProjektGraph/graph/MarkedEdge.java

58 lines
1.2 KiB
Java
Raw Normal View History

2024-06-15 14:48:28 +00:00
package graph;
2024-07-03 17:41:46 +00:00
import java.awt.*;
2024-06-25 15:18:34 +00:00
public class MarkedEdge<U extends EdgeMarking> extends Edge{
2024-06-15 14:48:28 +00:00
// ATTRIBUTE
2024-06-15 14:48:28 +00:00
private U marking;
2024-07-02 22:46:21 +00:00
private visualizationElements.Edge screenEdge;
2024-06-15 14:48:28 +00:00
// KONSTRUKTOREN
2024-06-15 14:48:28 +00:00
public MarkedEdge() {
super();
2024-07-02 22:46:21 +00:00
this.screenEdge = new visualizationElements.Edge(null, null);
2024-06-15 14:48:28 +00:00
}
public MarkedEdge(String s, Vertex n1, Vertex n2, U u) {
super(s, n1, n2);
this.marking = u;
2024-07-07 14:29:45 +00:00
EdgeWeightMarking m = (EdgeWeightMarking) this.marking;
this.screenEdge = new visualizationElements.Edge(n1.getScreenVertex(), n2.getScreenVertex(), Integer.toString(m.getWeight()), Color.BLACK);
2024-06-15 14:48:28 +00:00
}
2024-06-25 15:18:34 +00:00
// GET-ER
2024-06-15 14:48:28 +00:00
public U getMarking() {
return this.marking;
}
2024-07-02 22:46:21 +00:00
public visualizationElements.Edge getScreenEdge() {
return this.screenEdge;
}
// SET-ER
2024-06-15 14:48:28 +00:00
public void setMarking(U u) {
this.marking = u;
2024-07-07 14:29:45 +00:00
EdgeWeightMarking m = (EdgeWeightMarking) this.marking;
this.screenEdge.setMarking(Integer.toString(m.getWeight()));
2024-06-15 14:48:28 +00:00
}
2024-06-25 15:18:34 +00:00
// Ausgabe
2024-06-15 14:48:28 +00:00
public String toString() {
return "MarkedEdge " + this.getName() + " from " + this.getSource().getName() + " to " + this.getDestination().getName();
2024-06-15 14:48:28 +00:00
}
}