ProjektGraph/graph/MarkedEdge.java
2024-07-07 16:29:45 +02:00

58 lines
1.2 KiB
Java

package graph;
import java.awt.*;
public class MarkedEdge<U extends EdgeMarking> extends Edge{
// ATTRIBUTE
private U marking;
private visualizationElements.Edge screenEdge;
// KONSTRUKTOREN
public MarkedEdge() {
super();
this.screenEdge = new visualizationElements.Edge(null, null);
}
public MarkedEdge(String s, Vertex n1, Vertex n2, U u) {
super(s, n1, n2);
this.marking = u;
EdgeWeightMarking m = (EdgeWeightMarking) this.marking;
this.screenEdge = new visualizationElements.Edge(n1.getScreenVertex(), n2.getScreenVertex(), Integer.toString(m.getWeight()), Color.BLACK);
}
// GET-ER
public U getMarking() {
return this.marking;
}
public visualizationElements.Edge getScreenEdge() {
return this.screenEdge;
}
// SET-ER
public void setMarking(U u) {
this.marking = u;
EdgeWeightMarking m = (EdgeWeightMarking) this.marking;
this.screenEdge.setMarking(Integer.toString(m.getWeight()));
}
// Ausgabe
public String toString() {
return "MarkedEdge " + this.getName() + " from " + this.getSource().getName() + " to " + this.getDestination().getName();
}
}