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