IRootLab
An Open-Source MATLAB toolbox for vibrational biospectroscopy
maximize_window.m
Go to the documentation of this file.
1 %> @ingroup misc graphicsapi
2 %> @brief Maximizes figure on screen
3 %> @file
4 %>
5 %> Has a workaround to prevent figure from occupying two monitors, which
6 %> consists of dividing the width by two if the width-to-height ratio is
7 %> greater than 2.
8 %
9 %> @param h =gcf() Handle to figure.
10 %> @param aspectratio =1.618. If used, first making the image as big as possible, then reduce one of the dimensions to obbey
11 %> <code>width/height = aspectratio</code>
12 %> @param normalizedsize =1. Multiplying factor for the calculated width and height
13 function maximize_window(h, aspectratio, normalizedsize)
14 if nargin < 1 || isempty(h)
15  h = gcf();
16 end;
17 
18 if nargin < 3 || isempty(normalizedsize)
19  normalizedsize = 1;
20 end;
21 
22 p = get(0,'Screensize'); % p(3) is width, and p(4) is height
23 p(3:4) = floor(p(3:4)*.99);
24 
25 if p(3)/p(4) > 2.5
26  % Likely to be picking the full double monitor screen size
27  p(3) = floor(p(3)/2);
28 end;
29 
30 if nargin >= 2 && ~isempty(aspectratio)
31  ar_original = p(3)/p(4);
32  arar = aspectratio/ar_original;
33 
34  if arar < 1
35  p(3) = p(3)*arar;
36  elseif arar > 1
37  p(4) = p(4)/arar;
38  end;
39 end;
40 
41 
42 p(3:4) = p(3:4)*normalizedsize;
43 
44 figure(h);
45 set(h, 'Position', p);
46 
47 
function maximize_window(in h, in aspectratio, in normalizedsize)
Analysis Session (AS) base class.
Definition: as.m:6