-
Notifications
You must be signed in to change notification settings - Fork 20
/
updateGraphView.m
39 lines (30 loc) · 1.1 KB
/
updateGraphView.m
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
function [] = updateGraphView()
% Bring globals into scope
global nodes;
global radius;
global graphFig;
% Select graph view to draw on
set(0,'CurrentFigure',graphFig);
% Erase highlight lines
highlightThickness = 2.0;
lines = findobj('type','line','-and','LineWidth',highlightThickness);
delete(lines);
% Erase all old circles
circles = findobj('type','rectangle');
delete(circles)
% Draw each node
for i = 1:numel(nodes)
% Draw the node itself as a circle
nodes(i).circle = drawCircle(i,radius);
% Draw text just below it to label it
delete(nodes(i).text)
nodes(i).text = text(nodes(i).x,nodes(i).y,nodes(i).name,...
'HorizontalAlignment','center','VerticalAlignment','top');
% Draw any path highlights it has stored
for path = nodes(i).pathFrom
plot([nodes(i).x,nodes(path).x],...
[nodes(i).y,nodes(path).y],...
'Color',nodes(i).color,'LineWidth',highlightThickness);
end
end
end