1
1
"""
2
2
Return lines and arrow heads
3
3
"""
4
+ function midpoint (pt1,pt2)
5
+ x = (pt1[1 ] + pt2[1 ]) / 2
6
+ y = (pt1[2 ] + pt2[2 ]) / 2
7
+ return x,y
8
+ end
9
+
4
10
function graphline (edge_list, locs_x, locs_y, nodesize:: Vector{T} , arrowlength, angleoffset) where {T<: Real }
5
11
num_edges = length (edge_list)
6
12
lines = Array {Vector{Tuple{Float64,Float64}}} (undef, num_edges)
@@ -16,8 +22,12 @@ function graphline(edge_list, locs_x, locs_y, nodesize::Vector{T}, arrowlength,
16
22
endx = locs_x[j] + nodesize[j]* cos (θ+ π)
17
23
endy = locs_y[j] + nodesize[j]* sin (θ+ π)
18
24
arr1, arr2 = arrowcoords (θ, endx, endy, arrowlength, angleoffset)
19
- endx0 = (arr1[1 ] + arr2[1 ]) / 2
20
- endy0 = (arr1[2 ] + arr2[2 ]) / 2
25
+ endx0, endy0 = midpoint (arr1, arr2)
26
+ if Edge (j,i) in edge_list[1 : e_idx- 1 ] # check if a reverse arc exists
27
+ e_idx2 = findfirst (== (Edge (j,i)), edge_list) # get index of reverse arc
28
+ startx, starty = midpoint (arrows[e_idx2][[1 ,3 ]]. .. ) # get midopint of reverse arc and use as new start point
29
+ lines[e_idx2][1 ] = (endx0, endy0) # update endpoint of reverse arc
30
+ end
21
31
lines[e_idx] = [(startx, starty), (endx0, endy0)]
22
32
arrows[e_idx] = [arr1, (endx, endy), arr2]
23
33
end
@@ -39,8 +49,12 @@ function graphline(edge_list, locs_x, locs_y, nodesize::Real, arrowlength, angle
39
49
endx = locs_x[j] + nodesize* cos (θ+ π)
40
50
endy = locs_y[j] + nodesize* sin (θ+ π)
41
51
arr1, arr2 = arrowcoords (θ, endx, endy, arrowlength, angleoffset)
42
- endx0 = (arr1[1 ] + arr2[1 ]) / 2
43
- endy0 = (arr1[2 ] + arr2[2 ]) / 2
52
+ endx0, endy0 = midpoint (arr1, arr2)
53
+ if Edge (j,i) in edge_list[1 : e_idx- 1 ] # check if a reverse arc exists
54
+ e_idx2 = findfirst (== (Edge (j,i)), edge_list) # get index of reverse arc
55
+ startx, starty = midpoint (arrows[e_idx2][[1 ,3 ]]. .. ) # get midopint of reverse arc and use as new start point
56
+ lines[e_idx2][1 ] = (endx0, endy0) # update endpoint of reverse arc
57
+ end
44
58
lines[e_idx] = [(startx, starty), (endx0, endy0)]
45
59
arrows[e_idx] = [arr1, (endx, endy), arr2]
46
60
end
0 commit comments