This is a static copy of a profile report

Home

printing/private/validate (Calls: 12, Time: 0.127 s)
Generated 16-Jul-2020 17:09:15 using performance time.
function in file /Applications/MATLAB_R2020a.app/toolbox/matlab/graphics/printing/private/validate.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
printfunction12
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
17
pj = validateHandleToPrint(pj)...
120.115 s89.9%
151
pt = getprinttemplate(h);
120.002 s1.8%
115
isPage = locIsPageFormatOrPrin...
120.002 s1.6%
116
isAuto = strcmp(get(h, 'PaperP...
120.002 s1.3%
108
h = pj.Handles{1}(1);
120.001 s0.8%
All other lines  0.006 s4.6%
Totals  0.127 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
printing/private/validateHandleToPrintfunction120.114 s89.5%
getprinttemplatefunction120.002 s1.3%
.../validate>locIsPageFormatOrPrintersubfunction120.002 s1.3%
printing/private/isfigurefunction120.000 s0.3%
Self time (built-ins, overhead, etc.)  0.010 s7.6%
Totals  0.127 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function169
Non-code lines (comments, blank lines)60
Code lines (lines that can run)109
Code lines that did run35
Code lines that did not run74
Coverage (did run/can run)32.11 %
Function listing
time 
Calls 
 line
   1 
function pj = validate( pj )
   2 
%VALIDATE Method to check state of PrintJob object.
   3 
%   Values of PrintJob object class variables are checked for consistency.
   4 
%   Errors out if it finds bad combinations. Fills in missing data with
   5 
%   defaults.
   6 
%
   7 
%   Ex:
   8 
%      pj = VALIDATE( pj );
   9 
%
  10 
%   See also PRINT, PRINTOPT, INPUTCHECK.
  11 

  12 
%   Copyright 1984-2018 The MathWorks, Inc.
  13 

< 0.001 
     12 
  14
pj.Validated = 1; 
  15 

  16 
%If no window requested, and none to act as default, error out.
  0.115 
     12 
  17
pj = validateHandleToPrint(pj);  
  18 

< 0.001 
     12 
  19
if ~pj.UseOriginalHGPrinting 
  20 
   % for future use
< 0.001 
     12 
  21
   if pj.RGBImage  
  22 
       if ~isempty(pj.Driver)
  23 
           error(message('MATLAB:print:IncompatibleRGBImageOptionNoDriver', pj.Driver));
  24 
       end
  25 
       
  26 
       if ~isempty(pj.FileName)
  27 
           error(message('MATLAB:print:IncompatibleRGBImageOptionFilename'));
  28 
       end
  29 
       
  30 
       if ~isempty(pj.PrinterName)
  31 
           error(message('MATLAB:print:IncompatibleRGBImageOptionPrinter'));
  32 
       end
< 0.001 
     12 
  33
   end 
  34 
   
< 0.001 
     12 
  35
   if pj.ClipboardOption  
  36 
       if ~isempty(pj.FileName)
  37 
           error(message('MATLAB:print:IncompatibleClipboardOptionFilename'));
  38 
       end
  39 
       
  40 
       if ~isempty(pj.PrinterName)
  41 
           error(message('MATLAB:print:IncompatibleClipboardOptionPrinter'));
  42 
       end
  43 
       
  44 
       if isempty(pj.Driver) 
  45 
           error(message('MATLAB:print:IncompatibleClipboardOptionNoDriver'));
  46 
       end
  47 
       
  48 
       if ~pj.DriverClipboard %driver doesn't support clipboard
  49 
           error(message('MATLAB:print:IncompatibleClipboardOptionDriver', pj.Driver));
  50 
       end
  51 
       
< 0.001 
     12 
  52
   end 
< 0.001 
     12 
  53
end 
  54 

< 0.001 
     12 
  55
if pj.PostScriptPreview && ~strcmp(pj.DriverClass,'EP') 
  56 
    error(message('MATLAB:print:ValidateTiffPreviewOnlyWithEPS'))
< 0.001 
     12 
  57
end 
  58 

  59 
%If no device given, use default from PRINTOPT
< 0.001 
     12 
  60
if ~pj.RGBImage && isempty( pj.Driver ) 
  61 
    %Use method to validate default and set related class variables
  62 
    wasError = 0;
  63 
    try
  64 
        pj = inputcheck( pj, pj.DefaultDevice );
  65 
        pj.DriverColorSet = 0;
  66 
    catch ex  %#ok<NASGU>
  67 
        wasError = 1;
  68 
    end
  69 
    if wasError || isempty( pj.Driver )
  70 
      error(message('MATLAB:print:ValidateUnknownDeviceType', pj.DefaultDevice));
  71 
    end
< 0.001 
     12 
  72
end 
  73 

< 0.001 
     12 
  74
if strcmp(pj.DriverClass, 'MW' )  
  75 
    if isunix
  76 
      error(message('MATLAB:print:ValidateUseWindowsDriver', pj.Driver));
  77 
    end
  78 
    
  79 
    % If user specifies a filename while device is -dwin
  80 
    % or -dwinc, either because the user gave that device or, more
  81 
    % likely, it's the default, and since the filename is useless
  82 
    % with Windows driver anyway, we'll assume the user really wants
  83 
    % a PostScript file. This is because 'print foo' is easier
  84 
    % to type then 'print -dps foo' and probably more commonly
  85 
    % meant if a filename is given. Unless of course the user asked
  86 
    % for the Print Dialog with the -v flag, then s/he really meant it.
  87 
    if (~isempty(pj.FileName) && ~pj.Verbose ) ...
  88 
            && ( strcmp(pj.Driver, 'win') || strcmp(pj.Driver, 'winc') )
  89 
        if pj.DriverColor
  90 
            pj.Driver = 'psc';
  91 
        else
  92 
            pj.Driver = 'ps';
  93 
        end
  94 
        pj.DriverExt = 'ps';
  95 
        pj.DriverClass = 'PS';
  96 
    end
< 0.001 
     12 
  97
end 
  98 
% tight bounding box only applies to Postscript/Encapsulated Postscript
< 0.001 
     12 
  99
if ~any(strcmp(pj.DriverClass, {'PS', 'EP'})) 
< 0.001 
     12 
 100
    pj.PostScriptTightBBox = 0;  
< 0.001 
     12 
 101
end 
 102 

 103 
%TIFF previews imply -loose, historically because ZBuffer TIFF was always "loose".
< 0.001 
     12 
 104
if pj.PostScriptPreview == pj.TiffPreview 
 105 
    pj.PostScriptTightBBox = 0;    
< 0.001 
     12 
 106
end 
 107 

  0.001 
     12 
 108
h = pj.Handles{1}(1); 
 109 

 110 
% Validate use of fillpage/bestfit options
 111 
%    can't do -fillpage and -bestfit at same time
 112 
%    must be with a page format (PS, PDF, or Printer)
 113 
%    must be with a figure (not SL or SF) 
< 0.001 
     12 
 114
isfig = isfigure(h);  
  0.002 
     12 
 115
isPage = locIsPageFormatOrPrinter(pj); 
  0.002 
     12 
 116
isAuto = strcmp(get(h, 'PaperPositionMode'), 'auto');  
< 0.001 
     12 
 117
if pj.FillPage || pj.BestFit 
 118 
  if pj.FillPage
 119 
      option = 'fillpage';
 120 
  else
 121 
      option = 'bestfit';
 122 
  end
 123 
  % must be with figure (not SL/SF) 
 124 
  % can't do -fillpage and -bestfit at same time
 125 
  % must be with a page format (PS, PDF, or Printer)
 126 
  if ~isfig
 127 
      error(message('MATLAB:print:OptionOnlyValidForFigures', option));
 128 
  end
 129 

 130 
  if pj.FillPage && pj.BestFit 
 131 
      error(message('MATLAB:print:FillPageBestFitExclusive'));
 132 
  end
 133 

 134 
  if ~isPage
 135 
      error(message('MATLAB:print:OptionOnlyValidForPageFormats', option));
 136 
  end
 137 
 
< 0.001 
     12 
 138
end 
< 0.001 
     12 
 139
if isfig 
 140 
  % if printing to page format in 'auto' mode (and user hasn't specified either 
 141 
  % -bestfit or -fillpage), warn the user and offer suggestions if the output will get 
 142 
  % cropped (because figure is too large to fit on the page)
< 0.001 
     12 
 143
  if isPage && isAuto && ~(pj.FillPage || pj.BestFit) 
 144 
     paperPos = get(h, 'PaperPosition'); 
 145 
     if any(paperPos(1:2) < 0)
 146 
        warning(message('MATLAB:print:FigureTooLargeForPage'));
 147 
     end
< 0.001 
     12 
 148
  end 
 149 
  %Fill renderer and -noui from the printtemplate (if it exists) if
 150 
  %the user didn't specify these options on the command line
  0.002 
     12 
 151
  pt = getprinttemplate(h); 
< 0.001 
     12 
 152
  if ~isempty(pt) 
 153 
	if ~pj.nouiOption
 154 
	  pj.PrintUI = pt.PrintUI;
 155 
	end
 156 
	if ~pj.rendererOption && ~strcmp( pt.Renderer, 'auto' )
 157 
	  pj.Renderer = pt.Renderer;
 158 
      pj.rendererOption = 1; % overriding figure renderer
 159 
	end
< 0.001 
     12 
 160
  end  
 161 
    
  0.001 
     12 
 162
  if ~pj.UseOriginalHGPrinting && (isfield(pj.temp, 'isFigureShowEnabled') && ... 
     12 
 163
          ~pj.temp.isFigureShowEnabled) 
 164 
      %If user did not specify -noui and there are visible uicontrols, error now
 165 
      if ~pj.nouiOption && ~isempty(validateFindControls(h))
 166 
           error(message('MATLAB:prepareui:UnsupportedPlatform'));
 167 
      end
< 0.001 
     12 
 168
  end 
< 0.001 
     12 
 169
end 

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