This is a static copy of a profile report

Home

scribe.legend.methods>create_legend_items (14 calls, 0.404 sec)
Generated 05-Aug-2011 13:01:45 using cpu time.
subfunction in file /usr/local/MATLAB/R2011a/toolbox/matlab/scribe/@scribe/@legend/methods.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
scribe.legend.methodsfunction14
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
1465
set(texthandle(k),'ButtonDownF...
550.197 s48.6%
1431
lpos(3:4) = methods(h,'getsize...
140.044 s10.8%
1429
s = methods(h,'getsizeinfo');
140.044 s10.8%
1520
tokenhandle(end+1) = line('Par...
550.033 s8.1%
1505
tokenhandle(end+1) = line('Par...
550.033 s8.1%
All other lines  0.055 s13.5%
Totals  0.404 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
scribe.legend.methodsfunction830.273 s67.6%
scribe.legend.methods>localGetTokenItemsubfunction550 s0%
opaque.doublefunction2200 s0%
Self time (built-ins, overhead, etc.)  0.131 s32.4%
Totals  0.404 s100% 
Code Analyzer results
Line numberMessage
1477The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed.
1489The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed.
1505The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed.
1520The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed.
1549The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed.
Coverage results
[ Show coverage for parent directory ]
Total lines in function159
Non-code lines (comments, blank lines)82
Code lines (lines that can run)77
Code lines that did run46
Code lines that did not run31
Coverage (did run/can run)59.74 %
Function listing
   time   calls  line
1423 function create_legend_items(h,children)
14 1424 children = double(children);
1425
1426 % construct strings from string cell and counts
14 1427 strings = h.String;
1428
0.04 14 1429 s = methods(h,'getsizeinfo');
14 1430 lpos = ones(1,4);
0.04 14 1431 lpos(3:4) = methods(h,'getsize',s);
1432
1433 % initial token and text positions
14 1434 tokenx = [s.leftspace s.leftspace+s.tokenwidth]/lpos(3);
14 1435 textx = (s.leftspace+s.tokenwidth+s.tokentotextspace)/lpos(3);
1436 % initial ypos (for text and line items)
14 1437 ypos = 1 - ((s.topspace+(s.strsizes(1,2)/2))/lpos(4)); % middle of token
1438 % initial tokeny (top and bottom of patch) for patch items
14 1439 tokeny = ([s.strsizes(1,2)/-2.5 + s.rowspace/2, s.strsizes(1,2)/2.5 - s.rowspace/2]/lpos(4)) + ypos;
1440 % y increment for vertically oriented legends
14 1441 yinc = (s.rowspace + s.strsizes(:,2))/lpos(4);
1442 % x increment (not including string) for horizontally oriented legends
14 1443 xinc = (s.tokenwidth + s.tokentotextspace + s.colspace)/lpos(3);
1444
14 1445 texthandle = zeros(length(children),1);
14 1446 tokenhandle = [];
1447
14 1448 for k=1:length(children)
55 1449 item = children(k);
1450 % TEXT OBJECT
0.01 55 1451 texthandle(k) = text('Parent',double(h),...
1452 'Interpreter',h.Interpreter,...
1453 'Units','normalized',...
1454 'Color',h.TextColor,...
1455 'String',strings{k},...
1456 'Position',[textx ypos 0],...
1457 'VerticalAlignment','middle',...
1458 'SelectionHighlight','off',...
1459 'Interruptible','off','HitTest','off');
0.01 55 1460 set(texthandle(k),'FontUnits','points',...
1461 'FontAngle',h.FontAngle,...
1462 'FontWeight',h.FontWeight,...
1463 'FontName',h.FontName);
55 1464 set(texthandle(k),'FontSize',h.FontSize);
0.20 55 1465 set(texthandle(k),'ButtonDownFcn',methods(h,'getfunhan','tbdowncb',k));
55 1466 htext = handle(texthandle(k));
55 1467 props = [htext.findprop('FontName'),htext.findprop('FontSize'),...
1468 htext.findprop('FontWeight'),htext.findprop('FontAngle')];
0.01 55 1469 l = handle.listener(htext, props,...
1470 'PropertyPostSet', @changedItemTextFontProperties);
55 1471 setappdata(double(htext), 'Listeners', l);
1472
55 1473 setappdata(item,'legend_texthandle',texthandle(k));
1474 % TOKEN (GRAPHIC)
55 1475 if isa(item,'scribe.legendinfo')
1476 li = item;
1477 tokenhandle(end+1) = hg.hggroup(...
1478 'Parent',double(h),...
1479 'HitTest','off',...
1480 'Tag',strings{k}(:).',...
1481 'SelectionHighlight','off',...
1482 'Interruptible','off');
1483 methods(h,'build_legendinfo_token',tokenhandle(end),li,tokenx,tokeny);
55 1484 else
55 1485 item = localGetTokenItem(item);
0.01 55 1486 type=get(item,'type');
55 1487 if isappdata(item,'LegendLegendInfo')
1488 li = getLegendInfo(h,item);
1489 tokenhandle(end+1) = hg.hggroup(...
1490 'Parent',double(h),...
1491 'HitTest','off',...
1492 'Tag',strings{k}(:).',...
1493 'SelectionHighlight','off',...
1494 'Interruptible','off');
1495 if ishandle(li)
1496 methods(h,'build_legendinfo_token',tokenhandle(end),li,tokenx,tokeny);
1497 else
1498 rmappdata(item, 'LegendLegendInfo');
1499 end
55 1500 else
55 1501 switch type
1502 % FOR LINE
55 1503 case 'line'
1504 % LINE PART OF LINE
0.03 55 1505 tokenhandle(end+1) = line('Parent',double(h),...
1506 'Color',get(item,'Color'),...
1507 'LineWidth',get(item,'LineWidth'),...
1508 'LineStyle',get(item,'LineStyle'),...
1509 'Marker','none',...
1510 'XData',tokenx,...
1511 'YData',[ypos ypos],...
1512 'Tag',strings{k}(:).',...
1513 'SelectionHighlight','off',...
1514 'HitTest','off',...
1515 'Interruptible','off');
55 1516 setappdata(item,'legend_linetokenhandle',tokenhandle(end));
1517 % MARKER PART OF LINE
1518 % line for marker part (having a separate line for the marker
1519 % allows us to center the marker in the line.
0.03 55 1520 tokenhandle(end+1) = line('Parent',double(h),...
1521 'Color',get(item,'Color'),...
1522 'LineWidth',get(item,'LineWidth'),...
1523 'LineStyle','none',...
1524 'Marker',get(item,'Marker'),...
1525 'MarkerSize',get(item,'MarkerSize'),...
1526 'MarkerEdgeColor',get(item,'MarkerEdgeColor'),...
1527 'MarkerFaceColor',get(item,'MarkerFaceColor'),...
1528 'XData', (tokenx(1) + tokenx(2))/2,...
1529 'YData', ypos,...
1530 'HitTest','off',...
1531 'SelectionHighlight','off',...
1532 'Interruptible','off');
55 1533 setappdata(item,'legend_linemarkertokenhandle',tokenhandle(end));
1534 % FOR PATCH
1535 case {'patch','surface'}
1536 pyd = get(item,'xdata');
1537 if length(pyd) == 1
1538 pxdata = sum(tokenx)/length(tokenx);
1539 pydata = ypos;
1540 else
1541 pxdata = [tokenx(1) tokenx(1) tokenx(2) tokenx(2)];
1542 pydata = [tokeny(1) tokeny(2) tokeny(2) tokeny(1)];
1543 end
1544 [edgecolor,facecolor] = patchcolors(h,item);
1545 [facevertcdata,facevertadata] = patchvdata(h,item);
1546 if strcmp(facecolor,'none') && strcmp(type,'patch')
1547 pydata = repmat(mean(pydata),1,numel(pydata));
1548 end
1549 tokenhandle(end+1) = patch('Parent',double(h),...
1550 'FaceColor',facecolor,...
1551 'EdgeColor',edgecolor,...
1552 'LineWidth',get(item,'LineWidth'),...
1553 'LineStyle',get(item,'LineStyle'),...
1554 'Marker',get(item,'Marker'),...
1555 'MarkerSize',h.FontSize,...
1556 'MarkerEdgeColor',get(item,'MarkerEdgeColor'),...
1557 'MarkerFaceColor',get(item,'MarkerFaceColor'),...
1558 'XData', pxdata,...
1559 'YData', pydata,...
1560 'FaceVertexCData',facevertcdata,...
1561 'FaceVertexAlphaData',facevertadata,...
1562 'Tag',strings{k}(:).',...
1563 'SelectionHighlight','off',...
1564 'HitTest','off',...
1565 'Interruptible','off');
1566 setappdata(item,'legend_patchtokenhandle',tokenhandle(end));
1567 end
55 1568 end
55 1569 end
55 1570 if k<length(children)
41 1571 if strcmpi(h.Orientation,'vertical')
41 1572 ypos = ypos - (yinc(k)+yinc(k+1))/2;
41 1573 tokeny = tokeny - (yinc(k)+yinc(k+1))/2;
1574 else
1575 tokenx = tokenx + xinc + s.strsizes(k,1)/lpos(3);
1576 textx = textx + xinc + s.strsizes(k,1)/lpos(3);
1577 end
41 1578 end
55 1579 end
14 1580 h.ItemText = texthandle;
14 1581 h.ItemTokens = tokenhandle;

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