-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNonWeightedEdge.pde
More file actions
68 lines (64 loc) · 1.7 KB
/
NonWeightedEdge.pde
File metadata and controls
68 lines (64 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
public class NonWeightedEdge extends InteractiveFrame implements Edge, Comparable<NonWeightedEdge> {
Node from, to;
int edgeId;
boolean directed, deleted;
color edgeColor;
NonWeightedEdge(int edgeId, Node from, Node to, boolean directed, Scene scene) {
super(scene);
this.from = from;
this.to = to;
this.edgeId = edgeId;
this.directed = directed;
edgeColor = Utility.DEFAULT_EDGE_COLOR;
setShape("display");
deleted = false;
}
void display(PGraphics pg) {
if(deleted) return;
pg.pushStyle();
pg.strokeWeight(3);
pg.stroke(edgeColor);
Point a = Utility.getPointAlong(to.position().x(), to.position().y(), from.position().x(), from.position().y());
Point b = Utility.getPointAlong(from.position().x(), from.position().y(), to.position().x(), to.position().y());
pg.line(a.x(), a.y(), b.x(), b.y());
if(directed) {
pg.strokeWeight(0);
pg.fill(Utility.DEFAULT_ARROW_COLOR);
pg.ellipse(b.x(),b.y(),2.0*Utility.RADIUS_ARROW,2.0*Utility.RADIUS_ARROW);
}
pg.popStyle();
}
public Node getFrom() {
return from;
}
public Node getTo() {
return to;
}
public void setFrom(Node from) {
this.from = from;
}
public void setTo(Node to) {
this.to = to;
}
public void setDeleted(boolean deleted) {
this.deleted = deleted;
}
public int getEdgeId() {
return edgeId;
}
public boolean getDirected() {
return directed;
}
public void setColor(color newColor) {
edgeColor = newColor;
}
public int getWeight() {
return 1;
}
public void setWeight(int weight) {
}
@Override
public int compareTo(NonWeightedEdge otherEdge) {
return edgeId - otherEdge.edgeId;
}
}