This is a static copy of a profile report

Home

imuitools\private\initSize (1 call, 0.094 sec)
Generated 15-Mar-2007 12:02:04 using real time.
M-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
imshowM-function1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
58
p = figparams;
10.063 s66.7%
54
wa = getWorkArea;
10.016 s16.7%
47
on_screen_image_width = [];
10.000 s0.0%
104
fig_pos(1) = max(1, fig_pos(1)...
10.000 s0.0%
48
on_screen_image_height = [];
10.000 s0.0%
Other lines & overhead  0.016 s16.7%
Totals  0.094 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
imuitools\private\figparamsM-function10.063 s66.7%
imuitools\private\getWorkAreaM-function10.016 s16.7%
ancestorM-function20 s0%
imu...ivate\initSize>calculateDimensionsM-nested-function10 s0%
imuitools\private\initSize>getAxesXM-nested-function10 s0%
imuitools\private\initSize>getAxesYM-nested-function10 s0%
imuitools\private\constrainToWorkAreaM-function10 s0%
Self time (built-ins, overhead, etc.)  0.016 s16.7%
Totals  0.094 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 run55
Code lines that did not run44
Coverage (did run/can run)55.56 %
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
1 17 ax_handle = ancestor(im_handle,'axes');
1 18 fig_handle = ancestor(ax_handle,'figure');
19
1 20 ax_units = get(ax_handle, 'Units');
1 21 fig_units = get(fig_handle, 'Units');
1 22 root_units = get(0, 'Units');
23
1 24 image_width = size(get(im_handle, 'CData'),2);
1 25 image_height = size(get(im_handle, 'CData'),1);
26
1 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
1 33 set(ax_handle, 'Units', 'pixels');
1 34 set(fig_handle, 'Units', 'pixels');
1 35 set(0, 'Units', 'pixels');
36
1 37 ax_pos = get(ax_handle, 'Position');
1 38 fig_pos = get(fig_handle, 'Position');
1 39 fig_outer_pos = get(fig_handle, 'OuterPosition');
< 0.01 1 40 horizontal_decorations = fig_outer_pos(3) - fig_pos(3);
< 0.01 1 41 vertical_decorations = fig_outer_pos(4) - fig_pos(4);
42
< 0.01 1 43 orig_fig_width = fig_pos(3);
< 0.01 1 44 orig_fig_height = fig_pos(4);
45
46 % Declare so they're in function scope
< 0.01 1 47 on_screen_image_width = [];
< 0.01 1 48 on_screen_image_height = [];
< 0.01 1 49 new_fig_width = [];
< 0.01 1 50 new_fig_height = [];
< 0.01 1 51 is_width_bigger_than_screen = [];
< 0.01 1 52 is_height_bigger_than_screen = [];
53
0.02 1 54 wa = getWorkArea;
< 0.01 1 55 screen_width = wa.right - wa.left;
< 0.01 1 56 screen_height = wa.top - wa.bottom;
57
0.06 1 58 p = figparams;
59
1 60 calculateDimensions % to initialize dimensions
61
< 0.01 1 62 warn_about_mag = false;
1 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
71 on_screen_image_width = image_width * screen_per_image_pixel;
72 on_screen_image_height = image_height * screen_per_image_pixel;
73
74 new_fig_width = on_screen_image_width + getGutterWidth;
75 new_fig_height = on_screen_image_height + getGutterHeight;
76
77 is_width_bigger_than_screen = ...
78 (new_fig_width + horizontal_decorations) > screen_width;
79 is_height_bigger_than_screen = ...
80 (new_fig_height + vertical_decorations) > screen_height;
81 end
82 %---------------------------
83
1 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:
< 0.01 1 92 min_fig_width = 128;
< 0.01 1 93 min_fig_height = 128;
< 0.01 1 94 new_fig_width = max(new_fig_width, min_fig_width);
< 0.01 1 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.
1 98 ax_pos(1) = getAxesX;
1 99 ax_pos(2) = getAxesY;
< 0.01 1 100 ax_pos(3) = max(on_screen_image_width,1);
< 0.01 1 101 ax_pos(4) = max(on_screen_image_height,1);
102
103 % Calculate new figure position
< 0.01 1 104 fig_pos(1) = max(1, fig_pos(1) - floor((new_fig_width - orig_fig_width)/2));
< 0.01 1 105 fig_pos(2) = max(1, fig_pos(2) - floor((new_fig_height - orig_fig_height)/2));
106
< 0.01 1 107 fig_pos(3) = new_fig_width;
< 0.01 1 108 fig_pos(4) = new_fig_height;
109
110 % Translate figure position if necessary
< 0.01 1 111 dx = (p.ScreenWidth - p.RightDecoration) - (fig_pos(1) + fig_pos(3));
< 0.01 1 112 if (dx < 0)
113 fig_pos(1) = fig_pos(1) + dx;
114 end
< 0.01 1 115 dy = (p.ScreenHeight - p.TopDecoration) - (fig_pos(2) + fig_pos(4));
< 0.01 1 116 if (dy < 0)
117 fig_pos(2) = fig_pos(2) + dy;
118 end
119
1 120 set(fig_handle, 'Position', fig_pos)
1 121 set(ax_handle, 'Position', ax_pos);
122
123 % Restore the units
1 124 set(fig_handle, 'Units', fig_units);
1 125 set(ax_handle, 'Units', ax_units);
1 126 set(0, 'Units', root_units);
127
1 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
1 174 end % initSize
175