This is a static copy of a profile report

Home

graphics/private/modifyUnitsForPrint (12 calls, 0.071 sec)
Generated 14-Nov-2016 07:47:19 using cpu time.
function in file /usr/local/MATLAB/MATLAB_Production_Server/R2015a/toolbox/matlab/graphics/private/modifyUnitsForPrint.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
...vate/alternatePrintPath>printSetupsubfunction6
...ivate/alternatePrintPath>doCleanupsubfunction6
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
40
objUnitsModified = getObjWithU...
60.040 s57.1%
37
hUnits = findall(h, '-property...
60.030 s42.9%
99
end
120 s0%
75
end
300 s0%
74
end
300 s0%
All other lines  0 s0%
Totals  0.071 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
...odifyUnitsForPrint>getObjWithUnitsnested function60.040 s57.1%
findallfunction60.030 s42.9%
...odifyUnitsForPrint>@(x)~isempty(x)anonymous function300 s0%
...nitsForPrint>create@(x)~isempty(x)anonymous function60 s0%
Self time (built-ins, overhead, etc.)  0 s0%
Totals  0.071 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function99
Non-code lines (comments, blank lines)61
Code lines (lines that can run)38
Code lines that did run28
Code lines that did not run10
Coverage (did run/can run)73.68 %
Function listing
time 
calls 
 line
   1 
function objUnitsModified = modifyUnitsForPrint(...
   2 
    modifyRevertFlag, varargin)
   3 
% MODIFYUNITSFORPRINT Modifies or restores a figure's axes and other
   4 
% object's units for printing. This undocumented helper function is for
   5 
% internal use.
   6 

   7 
% This function is called during the print path.  See usage in
   8 
% alternatePrintPath.m
   9 

  10 
% MODIFYUNITSFORPRINT('modify', h) can be used to modify the units of the
  11 
% axes and other objects.  The return will be: objUnitsModified
  12 
% which is a struct of cell arrays of the objects whose units
  13 
% were set to normalized. The modifyRevertFlag can be used when calling this function
  14 
% to 'revert'.
  15 

  16 
% MODIFYUNITSFORPRINT('revert', h, pixelObjects) reverts
  17 
% the units to their original values, before 'modify' was called.
  18 

  19 
% Copyright 2013-2014 The MathWorks, Inc.
  20 

     12 
  21 
narginchk(2, 2) 
  22 

  23 
% The set of units to modify
     12 
  24 
unitsToModify = {'centimeters', 'inches', 'characters', 'pixels', 'points'}; 
  25 

     12 
  26 
if strcmp(modifyRevertFlag, 'modify') 
      6 
  27 
    h = varargin{1}; 
  28 
    % Find all objects with units of centimeters, inches, characters, or
  29 
    % pixels, and change them to normalized so they can be printed
  30 
    % appropriately.  They will be stored as fields in struct
  31 
    % objUnitsModified
      6 
  32 
    if ishghandle(h, 'figure') 
  33 
        hUnits = findall(h, '-property', 'units');
      6 
  34 
    else 
  35 
        % caller passed in list of handles to check... find those that have
  36 
        % a units property
  0.03 
      6 
  37 
        hUnits = findall(h, '-property', 'units', '-depth', 0);  
      6 
  38 
    end 
  39 
    
  0.04 
      6 
  40 
    objUnitsModified = getObjWithUnits(hUnits, ... 
  41 
        'Units', unitsToModify);
  42 

      6 
  43 
    unitsModified = structfun(@(x) ~isempty(x), objUnitsModified); 
      6 
  44 
    if any(unitsModified) 
  45 
        % If any units need changing, set them to normalized
      6 
  46 
        unitsToChange = unitsToModify(unitsModified); 
      6 
  47 
        for idx=1:length(unitsToChange) 
     30 
  48 
            set(objUnitsModified.(unitsToChange{idx}).handles, ... 
  49 
                'Units', 'normalized')
     30 
  50 
        end 
      6 
  51 
    end 
  52 
    
      6 
  53 
elseif strcmp(modifyRevertFlag, 'revert') 
      6 
  54 
    objUnitsModified = varargin{1}; 
  55 
    
      6 
  56 
    if isempty(objUnitsModified) 
  57 
        return
  58 
    end
  59 
    
  60 
    % Revert units and position for objects which were modified
  61 
    % Need to loop over property sets because vectorized sets with cell
  62 
    % array inputs is not enabled.
      6 
  63 
    for idx=1:length(unitsToModify) 
     30 
  64 
        units = unitsToModify{idx}; 
     30 
  65 
        if ~isempty(objUnitsModified.(units)) 
     30 
  66 
            if all(ishghandle(objUnitsModified.(units).handles)) 
     30 
  67 
                for idx2=1:length(objUnitsModified.(units).handles) 
  68 
                    hdl = objUnitsModified.(units).handles(idx2);
  69 
                    pos = objUnitsModified.(units).positions{idx2};
  70 
                    % Restore Position to fix g1025926
  71 
                    set(hdl, 'Units', units, 'Position', pos)
  72 
                end
     30 
  73 
            end 
     30 
  74 
        end 
     30 
  75 
    end 
  76 
else
  77 
    error(message('MATLAB:modifyunitsforprint:invalidFirstArgument'))
  78 
end
  79 

  80 
    function objUnitsModified = getObjWithUnits(h, unitsProp, units)
  81 
        % Returns an array of objects which have the unitsProp property
  82 
        % value set to the specified units.
  83 
        for unitsIdx = 1:length(units) 
  84 
            objWithUnits = findall(h, 'flat', unitsProp, units{unitsIdx});
  85 
        
  86 
            % Don't include the figure itself in this list
  87 
            objUnitsModified.(units{unitsIdx}).handles = objWithUnits(~ishghandle(objWithUnits, 'figure'));
  88 

  89 
            % The get command returns a cell array when passed multiple
  90 
            % handles. To keep the code simple downstream, wrap the single
  91 
            % handle result in a cell array too.
  92 
            if length(objUnitsModified.(units{unitsIdx}).handles) == 1
  93 
                objUnitsModified.(units{unitsIdx}).positions = {get(objUnitsModified.(units{unitsIdx}).handles,'Position')};
  94 
            else
  95 
                objUnitsModified.(units{unitsIdx}).positions = get(objUnitsModified.(units{unitsIdx}).handles,'Position');
  96 
            end
  97 
        end
  98 
    end
     12 
  99 
end 

Other subfunctions in this file are not included in this listing.