This is a static copy of a profile reportHome
legendcolorbarlayout>doInOutLayout (165 calls, 0.459 sec)
Generated 05-Aug-2011 13:02:19 using cpu time.
subfunction in file /usr/local/MATLAB/R2011a/toolbox/matlab/scribe/legendcolorbarlayout.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 |
491 | siz_norm = methods(handle(obj)... | 93 | 0.175 s | 38.1% |  |
488 | oldpos = get(obj,'Position'); | 93 | 0.055 s | 11.9% |  |
485 | set(obj,'Position',[pos(1:2) o... | 72 | 0.055 s | 11.9% |  |
496 | [newpos,corners] = layoutLegen... | 93 | 0.033 s | 7.1% |  |
473 | location = get(obj,'Location')... | 165 | 0.022 s | 4.8% |  |
All other lines | | | 0.120 s | 26.2% |  |
Totals | | | 0.459 s | 100% | |
Children (called functions)
Code Analyzer results
No Code Analyzer messages.Coverage results
[ Show coverage for parent directory ]
Total lines in function | 172 |
Non-code lines (comments, blank lines) | 15 |
Code lines (lines that can run) | 157 |
Code lines that did run | 63 |
Code lines that did not run | 94 |
Coverage (did run/can run) | 40.13 % |
Function listing
time calls line
456 function doInOutLayout(par,fig,list,corner1,corner2,inner)
165 457 if inner
165 458 corner1 = corner1+[5 -5];
165 459 corner2 = corner2+[-5 5];
165 460 corners = [corner1 ; corner2];
165 461 origc = corners;
462 else
463 % could use TightInsets here but then the legend/colorbars bounce too much
464 % during rotating/panning etc so instead use a fixed offset.
465 origc = [corner1 ; corner2];
466 corner1 = corner1-[10 -10];
467 corner2 = corner2-[-10 10];
468 corners = [corner1 ; corner2];
469 end
165 470 for k=1:length(list)
165 471 obj = list(k);
0.01 165 472 if ~ishandle(obj), continue; end
0.02 165 473 location = get(obj,'Location');
165 474 if strcmp(location,'BestOutside')
475 location = calculate_best_outside(obj);
476 end
0.01 165 477 if strcmp(location,'Best')
0.01 72 478 pos = getappdata(double(obj),'LegendBestLocation');
72 479 ax = get(obj,'Axes');
72 480 axpos = get(ax,'Position');
72 481 axpos = hgconvertunits(fig,axpos,get(ax,'Units'),'normalized',par);
72 482 pos = axpos(1:2) + pos.*axpos(3:4);
0.01 72 483 pos = hgconvertunits(fig,[pos 0 0],'normalized',get(obj,'Units'),par);
72 484 oldpos = get(obj,'Position');
0.05 72 485 set(obj,'Position',[pos(1:2) oldpos(3:4)]);
72 486 continue;
487 end
0.05 93 488 oldpos = get(obj,'Position');
0.01 93 489 oldpos = hgconvertunits(fig,oldpos,get(obj,'Units'),'points', par);
0.01 93 490 if isa(obj,'scribe.legend')
0.17 93 491 siz_norm = methods(handle(obj),'getsize');
93 492 if ~all(isfinite(siz_norm))
493 continue;
494 end
0.01 93 495 siz_point = hgconvertunits(fig,[0 0 siz_norm],'normalized','points',par);
0.03 93 496 [newpos,corners] = layoutLegend(location,corners,origc,siz_point(3:4),inner);
497 else
498 [newpos,corners] = layoutColorbar(location,corners,origc);
499 end
93 500 fpos = getpixelposition(fig);
93 501 fpos = hgconvertunits(fig,fpos,'pixels','points',fig);
93 502 newpos(2) = fpos(4) - newpos(2);
93 503 if par ~= fig
504 parpos = getpixelposition(par,true);
505 parpos = hgconvertunits(fig,parpos,'pixels','points',get(par,'Parent'));
506 newpos(1:2) = newpos(1:2) - parpos(1:2);
507 end
93 508 if any(abs(newpos(1:2)-oldpos(1:2))>2) || ...
509 any(abs(newpos(1:2)+newpos(3:4)-oldpos(1:2)-oldpos(3:4))>2)
37 510 newpos = hgconvertunits(fig,newpos,'points',get(obj,'Units'),par);
511 % In order to ensure that the computations are correct, keep track
512 % of the location of the object and the x and y axes.
37 513 ind = location_to_xy_index(location);
37 514 x = ind(1);
37 515 y = ind(2);
37 516 xAxisLoc = get(obj.Axes,'XAxisLocation');
0.01 37 517 yAxisLoc = get(obj.Axes,'YAxisLocation');
37 518 if ~any(isnan(newpos)) && all(newpos(3:4) > 0)
519 % If we had to shift the computations based on the XLabel and
520 % YLabel, make sure to shift the objects back:
37 521 if ~isa(obj,'scribe.legend')
522 if x ~= 3 %Anything except North* and South*
523 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
524 if strcmpi(xAxisLoc,'Bottom')
525 newpos(2) = newpos(2) + labPos;
526 end
527 newpos(4) = newpos(4) - labPos;
528 labPos = localGetTitleHeight(obj.Axes,obj.Units);
529 newpos(4) = newpos(4) - labPos;
530 elseif x == 3 % North* and South*
531 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
532 if strcmpi(yAxisLoc,'Left')
533 newpos(1) = newpos(1) + labPos;
534 end
535 newpos(3) = newpos(3) - labPos;
536 end
537 if strcmpi(xAxisLoc,'Bottom')
538 if (x == 3) && (y == 4) % South
539 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
540 newpos(2) = newpos(2) + labPos;
541 end
542 else
543 if (x == 3) && (y == 2) % North
544 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
545 newpos(2) = newpos(2) - labPos;
546 end
547 end
548 if strcmpi(yAxisLoc,'Left')
549 if (x == 2) && (y == 3) % West
550 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
551 newpos(1) = newpos(1) + labPos;
552 end
553 else
554 if (x == 4) && (y == 3) % East
555 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
556 newpos(1) = newpos(1) - labPos;
557 end
558 end
559 if (x == 3) && (y == 2) % North
560 labPos = localGetTitleHeight(obj.Axes,obj.Units);
561 newpos(2) = newpos(2) - labPos;
562 end
37 563 else
564 % Legends have a preferred width (not mirroring the axes), so
565 % we need to do a bit more work.
37 566 if strcmpi(yAxisLoc,'Left')
37 567 if x == 2 % Anything West and Inside
7 568 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
7 569 newpos(1) = newpos(1) + labPos;
7 570 end
571 else
572 if x == 4 % Anything East and Inside
573 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
574 newpos(1) = newpos(1) - labPos;
575 end
576 end
37 577 if y == 3 % East or West
578 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
579 % Divide by two because we want to move the center down.
580 if strcmpi(xAxisLoc,'Bottom')
581 newpos(2) = newpos(2) + labPos/2;
582 else
583 newpos(2) = newpos(2) - labPos/2;
584 end
585 labPos = localGetTitleHeight(obj.Axes,obj.Units);
586 newpos(2) = newpos(2) - labPos/2;
587 end
37 588 if (x == 3) && ((y == 2) || (y == 4)) % North or South
589 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
590 if strcmpi(yAxisLoc,'Left')
591 % Divide by two because we want to move the center over.
592 newpos(1) = newpos(1) + labPos/2;
593 else
594 % Divide by two because we want to move the center over.
595 newpos(1) = newpos(1) - labPos/2;
596 end
597 end
37 598 if y == 2 % Anything North, but not Outside
0.01 30 599 labPos = localGetTitleHeight(obj.Axes,obj.Units);
30 600 newpos(2) = newpos(2) - labPos;
30 601 end
37 602 if strcmpi(xAxisLoc,'Bottom')
37 603 if y == 4 % Anything South, but not Outside
7 604 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
7 605 newpos(2) = newpos(2) + labPos;
7 606 end
607 else
608 if y == 2 % Anything North, but not Outside
609 labPos = localGetXLabelHeight(obj.Axes,obj.Units);
610 newpos(2) = newpos(2) - labPos;
611 end
612 end
37 613 if (x == 3) && ((y == 1) || (y == 5)) % North or South Outside
614 labPos = localGetYLabelWidth(obj.Axes,obj.Units);
615 if strcmpi(yAxisLoc,'Left')
616 % Divide by two because we want to move the center over.
617 newpos(1) = newpos(1) + labPos/2;
618 else
619 % Divide by two because we want to move the center over.
620 newpos(1) = newpos(1) - labPos/2;
621 end
622 end
37 623 end
0.01 37 624 set(obj,'Position',newpos);
37 625 end
37 626 end
93 627 end
Other subfunctions in this file are not included in this listing.