time | Calls | line |
---|
| | 1 | function [ax,args,nargs] = axescheck(varargin)
|
| | 2 | % This function is undocumented and may change in a future release.
|
| | 3 |
|
| | 4 | %AXESCHECK Process Axes objects from input list
|
| | 5 | % [AX,ARGS,NARGS] = AXESCHECK(ARG1,ARG2,...) looks for Axes provided in
|
| | 6 | % the input arguments. It first checks if ARG1 is an Axes. If so, it is
|
| | 7 | % removed from the list in ARGS and the count in NARGS. AXESCHECK then
|
| | 8 | % checks the arguments for Name, Value pairs with the name 'Parent'. If a
|
| | 9 | % graphics object is found following the last occurance of 'Parent', then
|
| | 10 | % all 'Parent', Value pairs are removed from the list in ARGS and the
|
| | 11 | % count in NARGS. ARG1 (if it is an Axes), or the value following the
|
| | 12 | % last occurance of 'Parent', is returned in AX. Double handles to
|
| | 13 | % graphics objects are converted to graphics objects. If AX is determined
|
| | 14 | % to be a handle to a deleted graphics object, an error is thrown.
|
| | 15 |
|
| | 16 | % Copyright 1984-2018 The MathWorks, Inc.
|
| | 17 |
|
< 0.001 | 58 | 18 | args = varargin;
|
< 0.001 | 58 | 19 | nargs = nargin;
|
< 0.001 | 58 | 20 | ax=[];
|
| | 21 |
|
| | 22 | % Check for either a scalar numeric Axes handle, or any size array of Axes.
|
| | 23 | % 'isgraphics' will catch numeric graphics handles, but will not catch
|
| | 24 | % deleted graphics handles, so we need to check for both separately.
|
0.002 | 58 | 25 | if (nargs > 0) && ...
|
| 58 | 26 | ((isnumeric(args{1}) && isscalar(args{1}) && isgraphics(args{1}, 'axes')) ...
|
| 58 | 27 | || isa(args{1},'matlab.graphics.axis.AbstractAxes') || isa(args{1},'matlab.ui.control.UIAxes'))
|
| | 28 | ax = handle(args{1});
|
| | 29 | args = args(2:end);
|
| | 30 | nargs = nargs-1;
|
< 0.001 | 58 | 31 | end
|
< 0.001 | 58 | 32 | if nargs > 0
|
| | 33 | % Detect 'Parent' or "Parent" (case insensitive).
|
0.014 | 58 | 34 | inds = find(cellfun(@(x) (isStringScalar(x) || ischar(x)) && strcmpi('parent', x), args));
|
< 0.001 | 58 | 35 | if ~isempty(inds)
|
| | 36 | inds = unique([inds inds+1]);
|
| | 37 | pind = inds(end);
|
| | 38 |
|
| | 39 | % Check for either a scalar numeric handle, or any size array of graphics objects.
|
| | 40 | % If the argument is passed using the 'Parent' P/V pair, then we will
|
| | 41 | % catch any graphics handle(s), and not just Axes.
|
| | 42 | if nargs >= pind && ...
|
| | 43 | ((isnumeric(args{pind}) && isscalar(args{pind}) && isgraphics(args{pind})) ...
|
| | 44 | || isa(args{pind},'matlab.graphics.Graphics'))
|
| | 45 | ax = handle(args{pind});
|
| | 46 | args(inds) = [];
|
| | 47 | nargs = length(args);
|
| | 48 | end
|
< 0.001 | 58 | 49 | end
|
< 0.001 | 58 | 50 | end
|
| | 51 |
|
| | 52 | % Make sure that the graphics handle found is a scalar handle, and not an
|
| | 53 | % empty graphics array or non-scalar graphics array.
|
< 0.001 | 58 | 54 | if (nargs < nargin) && ~isscalar(ax)
|
| | 55 | throwAsCaller(MException(message('MATLAB:graphics:axescheck:NonScalarHandle')));
|
< 0.001 | 58 | 56 | end
|
| | 57 |
|
| | 58 | % Throw an error if a deleted graphics handle is detected.
|
< 0.001 | 58 | 59 | if ~isempty(ax) && ~isvalid(ax)
|
| | 60 | % It is possible for a non-Axes graphics object to get through the code
|
| | 61 | % above if passed as a Name/Value pair. Throw a different error message
|
| | 62 | % for Axes vs. other graphics objects.
|
| | 63 | if(isa(ax,'matlab.graphics.axis.AbstractAxes') || isa(ax,'matlab.ui.control.UIAxes'))
|
| | 64 | throwAsCaller(MException(message('MATLAB:graphics:axescheck:DeletedAxes')));
|
| | 65 | else
|
| | 66 | throwAsCaller(MException(message('MATLAB:graphics:axescheck:DeletedObject')));
|
| | 67 | end
|
< 0.001 | 58 | 68 | end
|
Other subfunctions in this file are not included in this listing.