This is a static copy of a profile reportHome
scribe.legend.methods>create_legend_items (2 calls, 0.062 sec)
Generated 18-Mar-2011 23:32:37 using cpu time.
M-subfunction in file /Applications/MATLAB_R2010a.app/toolbox/matlab/scribe/@scribe/@legend/methods.m
Copy to new window for comparing multiple runs
Parents (calling functions)
Lines where the most time was spent
Line Number | Code | Calls | Total Time | % Time | Time Plot |
1567 | if strcmpi(h.Orientation,'vert... | 5 | 0.010 s | 16.7% |  |
1501 | tokenhandle(end+1) = line('Par... | 7 | 0.010 s | 16.7% |  |
1469 | setappdata(item,'legend_textha... | 7 | 0.010 s | 16.7% |  |
1447 | texthandle(k) = text('Parent',... | 7 | 0.010 s | 16.7% |  |
1427 | lpos(3:4) = methods(h,'getsize... | 2 | 0.010 s | 16.7% |  |
All other lines | | | 0.010 s | 16.7% |  |
Totals | | | 0.062 s | 100% | |
Children (called functions)
M-Lint results
Line number | Message |
1473 | The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed. |
1485 | The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed. |
1501 | The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed. |
1516 | The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed. |
1545 | The variable 'tokenhandle' appears to change size on every loop iteration. Consider preallocating for speed. |
Coverage results
[ Show coverage for parent directory ]
Total lines in function | 159 |
Non-code lines (comments, blank lines) | 82 |
Code lines (lines that can run) | 77 |
Code lines that did run | 46 |
Code lines that did not run | 31 |
Coverage (did run/can run) | 59.74 % |
Function listing
time calls line
1419 function create_legend_items(h,children)
2 1420 children = double(children);
1421
1422 % construct strings from string cell and counts
2 1423 strings = h.String;
1424
2 1425 s = methods(h,'getsizeinfo');
2 1426 lpos = ones(1,4);
0.01 2 1427 lpos(3:4) = methods(h,'getsize',s);
1428
1429 % initial token and text positions
2 1430 tokenx = [s.leftspace s.leftspace+s.tokenwidth]/lpos(3);
2 1431 textx = (s.leftspace+s.tokenwidth+s.tokentotextspace)/lpos(3);
1432 % initial ypos (for text and line items)
2 1433 ypos = 1 - ((s.topspace+(s.strsizes(1,2)/2))/lpos(4)); % middle of token
1434 % initial tokeny (top and bottom of patch) for patch items
2 1435 tokeny = ([s.strsizes(1,2)/-2.5 + s.rowspace/2, s.strsizes(1,2)/2.5 - s.rowspace/2]/lpos(4)) + ypos;
1436 % y increment for vertically oriented legends
2 1437 yinc = (s.rowspace + s.strsizes(:,2))/lpos(4);
1438 % x increment (not including string) for horizontally oriented legends
2 1439 xinc = (s.tokenwidth + s.tokentotextspace + s.colspace)/lpos(3);
1440
2 1441 texthandle = zeros(length(children),1);
2 1442 tokenhandle = [];
1443
2 1444 for k=1:length(children)
7 1445 item = children(k);
1446 % TEXT OBJECT
0.01 7 1447 texthandle(k) = text('Parent',double(h),...
1448 'Interpreter',h.Interpreter,...
1449 'Units','normalized',...
1450 'Color',h.TextColor,...
1451 'String',strings{k},...
1452 'Position',[textx ypos 0],...
1453 'VerticalAlignment','middle',...
1454 'SelectionHighlight','off',...
1455 'Interruptible','off','HitTest','off');
7 1456 set(texthandle(k),'FontUnits','points',...
1457 'FontAngle',h.FontAngle,...
1458 'FontWeight',h.FontWeight,...
1459 'FontName',h.FontName);
7 1460 set(texthandle(k),'FontSize',h.FontSize);
7 1461 set(texthandle(k),'ButtonDownFcn',methods(h,'getfunhan','tbdowncb',k));
7 1462 htext = handle(texthandle(k));
7 1463 props = [htext.findprop('FontName'),htext.findprop('FontSize'),...
1464 htext.findprop('FontWeight'),htext.findprop('FontAngle')];
7 1465 l = handle.listener(htext, props,...
1466 'PropertyPostSet', @changedItemTextFontProperties);
7 1467 setappdata(double(htext), 'Listeners', l);
1468
0.01 7 1469 setappdata(item,'legend_texthandle',texthandle(k));
1470 % TOKEN (GRAPHIC)
7 1471 if isa(item,'scribe.legendinfo')
1472 li = item;
1473 tokenhandle(end+1) = hg.hggroup(...
1474 'Parent',double(h),...
1475 'HitTest','off',...
1476 'Tag',strings{k}(:).',...
1477 'SelectionHighlight','off',...
1478 'Interruptible','off');
1479 methods(h,'build_legendinfo_token',tokenhandle(end),li,tokenx,tokeny);
7 1480 else
7 1481 item = localGetTokenItem(item);
7 1482 type=get(item,'type');
7 1483 if isappdata(item,'LegendLegendInfo')
1484 li = getLegendInfo(h,item);
1485 tokenhandle(end+1) = hg.hggroup(...
1486 'Parent',double(h),...
1487 'HitTest','off',...
1488 'Tag',strings{k}(:).',...
1489 'SelectionHighlight','off',...
1490 'Interruptible','off');
1491 if ishandle(li)
1492 methods(h,'build_legendinfo_token',tokenhandle(end),li,tokenx,tokeny);
1493 else
1494 rmappdata(item, 'LegendLegendInfo');
1495 end
7 1496 else
7 1497 switch type
1498 % FOR LINE
7 1499 case 'line'
1500 % LINE PART OF LINE
0.01 7 1501 tokenhandle(end+1) = line('Parent',double(h),...
1502 'Color',get(item,'Color'),...
1503 'LineWidth',get(item,'LineWidth'),...
1504 'LineStyle',get(item,'LineStyle'),...
1505 'Marker','none',...
1506 'XData',tokenx,...
1507 'YData',[ypos ypos],...
1508 'Tag',strings{k}(:).',...
1509 'SelectionHighlight','off',...
1510 'HitTest','off',...
1511 'Interruptible','off');
7 1512 setappdata(item,'legend_linetokenhandle',tokenhandle(end));
1513 % MARKER PART OF LINE
1514 % line for marker part (having a separate line for the marker
1515 % allows us to center the marker in the line.
7 1516 tokenhandle(end+1) = line('Parent',double(h),...
1517 'Color',get(item,'Color'),...
1518 'LineWidth',get(item,'LineWidth'),...
1519 'LineStyle','none',...
1520 'Marker',get(item,'Marker'),...
1521 'MarkerSize',get(item,'MarkerSize'),...
1522 'MarkerEdgeColor',get(item,'MarkerEdgeColor'),...
1523 'MarkerFaceColor',get(item,'MarkerFaceColor'),...
1524 'XData', (tokenx(1) + tokenx(2))/2,...
1525 'YData', ypos,...
1526 'HitTest','off',...
1527 'SelectionHighlight','off',...
1528 'Interruptible','off');
7 1529 setappdata(item,'legend_linemarkertokenhandle',tokenhandle(end));
1530 % FOR PATCH
1531 case {'patch','surface'}
1532 pyd = get(item,'xdata');
1533 if length(pyd) == 1
1534 pxdata = sum(tokenx)/length(tokenx);
1535 pydata = ypos;
1536 else
1537 pxdata = [tokenx(1) tokenx(1) tokenx(2) tokenx(2)];
1538 pydata = [tokeny(1) tokeny(2) tokeny(2) tokeny(1)];
1539 end
1540 [edgecolor,facecolor] = patchcolors(h,item);
1541 [facevertcdata,facevertadata] = patchvdata(h,item);
1542 if strcmp(facecolor,'none') && strcmp(type,'patch')
1543 pydata = repmat(mean(pydata),1,numel(pydata));
1544 end
1545 tokenhandle(end+1) = patch('Parent',double(h),...
1546 'FaceColor',facecolor,...
1547 'EdgeColor',edgecolor,...
1548 'LineWidth',get(item,'LineWidth'),...
1549 'LineStyle',get(item,'LineStyle'),...
1550 'Marker',get(item,'Marker'),...
1551 'MarkerSize',h.FontSize,...
1552 'MarkerEdgeColor',get(item,'MarkerEdgeColor'),...
1553 'MarkerFaceColor',get(item,'MarkerFaceColor'),...
1554 'XData', pxdata,...
1555 'YData', pydata,...
1556 'FaceVertexCData',facevertcdata,...
1557 'FaceVertexAlphaData',facevertadata,...
1558 'Tag',strings{k}(:).',...
1559 'SelectionHighlight','off',...
1560 'HitTest','off',...
1561 'Interruptible','off');
1562 setappdata(item,'legend_patchtokenhandle',tokenhandle(end));
1563 end
7 1564 end
7 1565 end
7 1566 if k<length(children)
0.01 5 1567 if strcmpi(h.Orientation,'vertical')
5 1568 ypos = ypos - (yinc(k)+yinc(k+1))/2;
5 1569 tokeny = tokeny - (yinc(k)+yinc(k+1))/2;
1570 else
1571 tokenx = tokenx + xinc + s.strsizes(k,1)/lpos(3);
1572 textx = textx + xinc + s.strsizes(k,1)/lpos(3);
1573 end
5 1574 end
7 1575 end
2 1576 h.ItemText = texthandle;
2 1577 h.ItemTokens = tokenhandle;
Other subfunctions in this file are not included in this listing.