Download this file

37 lines (33 with data), 1.1 kB

 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
function setPosition( o, p, u )
%setPosition Set position of graphics object
%
% setPosition(o,p,u) sets the position of a graphics object o to value p
% with units u.
%
% In contrast to setting the Position property directly, this function
% honors the ActivePositionProperty of axes.
% Copyright 2009-2016 The MathWorks, Inc.
% $Revision: 1765 $ $Date: 2018-10-25 17:11:26 +0100 (Thu, 25 Oct 2018) $
% Set units
if ~isempty( findprop( o, 'Units' ) )
o.Units = u;
else
assert( strcmp( u, 'pixels' ), 'uix:InvalidOperation', ...
'Objects without property ''Units'' have units of ''pixels''.' )
end
% Set position
if ~isempty( findprop( o, 'ActivePositionProperty' ) )
switch o.ActivePositionProperty
case 'position'
o.Position = p;
case 'outerposition'
o.OuterPosition = p;
otherwise
error( 'uix:InvalidState', ...
'Unknown value ''%s'' for property ''ActivePositionProperty'' of %s.', ...
o.ActivePositionProperty, class( o ) )
end
else
o.Position = p;
end
end % setPosition