This is a static copy of a profile report

Home

imuitools\private\initSize>calculateDimensions (1 call, 0.000 sec)
Generated 15-Mar-2007 12:02:05 using real time.
M-nested-function in file C:\Program Files\MATLAB71\toolbox\images\imuitools\private\initSize.m
[Copy to new window for comparing multiple runs]

Parents (calling functions)

Function NameFunction TypeCalls
imuitools\private\initSizeM-function1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
72
on_screen_image_height = image...
10.000 s50.2%
71
on_screen_image_width = image_...
10.000 s20.9%
77
is_width_bigger_than_screen = ...
10.000 s14.2%
81
end
10.000 s10.0%
79
is_height_bigger_than_screen =...
10.000 s4.7%
Other lines & overhead  0 s0%
Totals  0.000 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
imu...ls\private\initSize>getGutterWidthM-nested-function10 s0%
imu...s\private\initSize>getGutterHeightM-nested-function10 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0.000 s100% 
M-Lint results
No M-Lint messages.
Coverage results
[ Show coverage for parent directory ]
Total lines in file175
Non-code lines (comments, blank lines)76
Code lines (lines that can run)99
Code lines that did run7
Code lines that did not run92
Coverage (did run/can run)7.07 %
Function listing
   time   calls  line
1 function initSize(im_handle,screen_per_image_pixel,isBorderTight)
2 %initSize Initialize size of axes and figure
3
4 % initSize(imH,screenPerImagePixel,isBorderTight) adjusts the display size
5 % of an image by using the image size and the scale factor
6 % screenPerImagePixel. If screenPerImagePixel==1,then the display has one
7 % screen pixel for each image pixel. If isBorderTight is false, then
8 % initSize adds gutters for displaying axes and tick labels.
9 %
10 % Note: The code assumes that it is calculating the size for a figure that
11 % contains a single axes object with a single image. Other uicontrols
12 % and uipanels are not taken into account.
13
14 % Copyright 1993-2004 The MathWorks, Inc.
15 % $Revision: 1.1.8.1 $ $Date: 2004/08/10 01:50:20 $
16
17 ax_handle = ancestor(im_handle,'axes');
18 fig_handle = ancestor(ax_handle,'figure');
19
20 ax_units = get(ax_handle, 'Units');
21 fig_units = get(fig_handle, 'Units');
22 root_units = get(0, 'Units');
23
24 image_width = size(get(im_handle, 'CData'),2);
25 image_height = size(get(im_handle, 'CData'),1);
26
27 if (image_width * image_height == 0)
28 % Don't try to handle the degenerate case.
29 return;
30 end
31
32 % Work in pixels
33 set(ax_handle, 'Units', 'pixels');
34 set(fig_handle, 'Units', 'pixels');
35 set(0, 'Units', 'pixels');
36
37 ax_pos = get(ax_handle, 'Position');
38 fig_pos = get(fig_handle, 'Position');
39 fig_outer_pos = get(fig_handle, 'OuterPosition');
40 horizontal_decorations = fig_outer_pos(3) - fig_pos(3);
41 vertical_decorations = fig_outer_pos(4) - fig_pos(4);
42
43 orig_fig_width = fig_pos(3);
44 orig_fig_height = fig_pos(4);
45
46 % Declare so they're in function scope
47 on_screen_image_width = [];
48 on_screen_image_height = [];
49 new_fig_width = [];
50 new_fig_height = [];
51 is_width_bigger_than_screen = [];
52 is_height_bigger_than_screen = [];
53
54 wa = getWorkArea;
55 screen_width = wa.right - wa.left;
56 screen_height = wa.top - wa.bottom;
57
58 p = figparams;
59
60 calculateDimensions % to initialize dimensions
61
62 warn_about_mag = false;
63 while (is_width_bigger_than_screen || is_height_bigger_than_screen)
64 screen_per_image_pixel = findZoomMag('out',screen_per_image_pixel);
65 warn_about_mag = true;
66 calculateDimensions % to update dimensions
67 end
68
69 %---------------------------
70 function calculateDimensions
< 0.01 1 71 on_screen_image_width = image_width * screen_per_image_pixel;
< 0.01 1 72 on_screen_image_height = image_height * screen_per_image_pixel;
73
1 74 new_fig_width = on_screen_image_width + getGutterWidth;
1 75 new_fig_height = on_screen_image_height + getGutterHeight;
76
< 0.01 1 77 is_width_bigger_than_screen = ...
78 (new_fig_width + horizontal_decorations) > screen_width;
< 0.01 1 79 is_height_bigger_than_screen = ...
80 (new_fig_height + vertical_decorations) > screen_height;
< 0.01 1 81 end
82 %---------------------------
83
84 if warn_about_mag
85 wid = sprintf('Images:%s:adjustingMag',mfilename);
86 warning(wid,...
87 'Image is too big to fit on screen; displaying at %d%%',...
88 round(screen_per_image_pixel*100));
89 end
90
91 % Don't try to display a figure smaller than this:
92 min_fig_width = 128;
93 min_fig_height = 128;
94 new_fig_width = max(new_fig_width, min_fig_width);
95 new_fig_height = max(new_fig_height, min_fig_height);
96
97 % Figure out where to place the axes object in the resized figure.
98 ax_pos(1) = getAxesX;
99 ax_pos(2) = getAxesY;
100 ax_pos(3) = max(on_screen_image_width,1);
101 ax_pos(4) = max(on_screen_image_height,1);
102
103 % Calculate new figure position
104 fig_pos(1) = max(1, fig_pos(1) - floor((new_fig_width - orig_fig_width)/2));
105 fig_pos(2) = max(1, fig_pos(2) - floor((new_fig_height - orig_fig_height)/2));
106
107 fig_pos(3) = new_fig_width;
108 fig_pos(4) = new_fig_height;
109
110 % Translate figure position if necessary
111 dx = (p.ScreenWidth - p.RightDecoration) - (fig_pos(1) + fig_pos(3));
112 if (dx < 0)
113 fig_pos(1) = fig_pos(1) + dx;
114 end
115 dy = (p.ScreenHeight - p.TopDecoration) - (fig_pos(2) + fig_pos(4));
116 if (dy < 0)
117 fig_pos(2) = fig_pos(2) + dy;
118 end
119
120 set(fig_handle, 'Position', fig_pos)
121 set(ax_handle, 'Position', ax_pos);
122
123 % Restore the units
124 set(fig_handle, 'Units', fig_units);
125 set(ax_handle, 'Units', ax_units);
126 set(0, 'Units', root_units);
127
128 constrainToWorkArea(fig_handle);
129
130 %--------------------------
131 function w = getGutterWidth
132
133 if isBorderTight
134 w = 0;
135 else
136 w = 2*ceil(p.YLabelWidth); % make it symmetric for balance
137 end
138
139 end
140
141 %---------------------------
142 function h = getGutterHeight
143
144 if isBorderTight
145 h = 0;
146 else
147 h = ceil(p.XLabelHeight + p.AxesTitleHeight);
148 end
149
150 end
151
152 %--------------------
153 function x = getAxesX
154
155 if isBorderTight
156 x = 0;
157 else
158 x = p.YLabelWidth + 1;
159 end
160
161 end
162
163 %--------------------
164 function y = getAxesY
165
166 if isBorderTight
167 y = 0;
168 else
169 y = p.XLabelHeight + 1;
170 end
171
172 end
173
174 end % initSize
175