forked from SysBioChalmers/RAVEN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getPathwayDimensions.m
executable file
·53 lines (49 loc) · 1.84 KB
/
getPathwayDimensions.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function dimensions=getPathwayDimensions(pathway)
% getPathwayDimensions
% Retrieves the dimensions of metabolic network in a pathway structure.
% Returns the position of the upper left corner, width and height.
%
% pathway pathway structure representing the pathway to be drawn
%
% dimension a 1x4 vector with x and y for the upper left corner,
% height and width
%
% Usage: dimensions=getPathwayDimensions(pathway)
right=0;
left=inf;
top=inf;
bottom=0;
%Loops through the compartments to find the right and bottom border and the
%position of the upper left corner
for i=1:length(pathway.listOfCompartments)
if pathway.listOfCompartments(1,i).x<left
left=pathway.listOfCompartments(1,i).x;
end
if pathway.listOfCompartments(1,i).y<top
top=pathway.listOfCompartments(1,i).y;
end
if (pathway.listOfCompartments(1,i).x+pathway.listOfCompartments(1,i).w)>right
right=pathway.listOfCompartments(1,i).x+pathway.listOfCompartments(1,i).w;
end
if (pathway.listOfCompartments(1,i).y+pathway.listOfCompartments(1,i).h)>bottom
bottom=pathway.listOfCompartments(1,i).y+pathway.listOfCompartments(1,i).h;
end
end
%Loops through the species to find the object furthest to the right, left,
%top and bottom
for i=1:length(pathway.listOfSpecies)
if pathway.listOfSpecies(1,i).x<left
left=pathway.listOfSpecies(1,i).x;
end
if pathway.listOfSpecies(1,i).y<top
top=pathway.listOfSpecies(1,i).y;
end
if (pathway.listOfSpecies(1,i).x+pathway.listOfSpecies(1,i).w)>right
right=pathway.listOfSpecies(1,i).x+pathway.listOfSpecies(1,i).w;
end
if (pathway.listOfSpecies(1,i).y+pathway.listOfSpecies(1,i).h)>bottom
bottom=pathway.listOfSpecies(1,i).y+pathway.listOfSpecies(1,i).h;
end
end
dimensions=[left,top,right-left,bottom-top];
end