annotate toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_footnoteButtonDownFcn.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function vis_footnoteButtonDownFcn
wolffd@0 2
wolffd@0 3 % VIS_FOOTNOTEBUTTONDOWNFCN Callback set by VIS_FOOTNOTE
wolffd@0 4 %
wolffd@0 5 % som_showtitleButtonDownFcn
wolffd@0 6 %
wolffd@0 7 % Moves the axis of current callback object using DRAGRECT
wolffd@0 8 % command. This callback is set to all texts added to figures by
wolffd@0 9 % VIS_FOOTNOTE function.
wolffd@0 10 %
wolffd@0 11 % See also DRAGRECT, SOM_SHOWTITLE.
wolffd@0 12
wolffd@0 13 % Copyright (c) 1997-2000 by the SOM toolbox programming team.
wolffd@0 14 % http://www.cis.hut.fi/projects/somtoolbox/
wolffd@0 15
wolffd@0 16 % Version 2.0beta Johan 080698
wolffd@0 17
wolffd@0 18 % Action
wolffd@0 19
wolffd@0 20 [txt,fig]=gcbo; % Get text and figure handles
wolffd@0 21 ax=get(txt,'parent'); % Get axis handle
wolffd@0 22
wolffd@0 23 memunits_fig=get(fig,'units'); % Get figure size in pixels
wolffd@0 24 set(gcf,'units','pixels');
wolffd@0 25 pos_fig=get(fig,'position');
wolffd@0 26
wolffd@0 27 memunits_txt=get(txt,'units'); % Get text field size in pixels
wolffd@0 28 set(txt,'units','pixels');
wolffd@0 29 text_size=get(txt,'extent');
wolffd@0 30
wolffd@0 31 memunits_ax=get(ax,'units'); % Get axis position in pixels
wolffd@0 32 set(ax,'units','pixels');
wolffd@0 33 pos_ax=get(ax,'position');
wolffd@0 34
wolffd@0 35 %%% Move text
wolffd@0 36
wolffd@0 37 pos_final=dragrect([pos_ax(1:2) text_size(3:4)]);
wolffd@0 38
wolffd@0 39 %%% Keep the text inside the figure!
wolffd@0 40
wolffd@0 41 pos_final(1)=max(pos_final(1),0);
wolffd@0 42 pos_final(2)=max(pos_final(2),0);
wolffd@0 43 pos_final(1)=min(pos_final(1),pos_fig(3)-text_size(3));
wolffd@0 44 pos_final(2)=min(pos_final(2),pos_fig(4)-text_size(4));
wolffd@0 45
wolffd@0 46 %%% Set new position
wolffd@0 47
wolffd@0 48 new_pos=[pos_final(1:2) pos_ax(3:4)];
wolffd@0 49 set(ax,'position', new_pos);
wolffd@0 50
wolffd@0 51 %%% Set the text on the top of the object stack
wolffd@0 52
wolffd@0 53 children=get(gcf,'children');
wolffd@0 54 i=find(ismember(children,ax));
wolffd@0 55 new_i=[i 1:i-1 i+1:length(children)];
wolffd@0 56 set(gcf,'children',children(new_i));
wolffd@0 57
wolffd@0 58 set(txt,'position',[0 0 0]);
wolffd@0 59 set(fig,'units',memunits_fig);
wolffd@0 60 set(ax,'units',memunits_ax);
wolffd@0 61 set(txt,'units',memunits_txt);
wolffd@0 62
wolffd@0 63
wolffd@0 64