Mercurial > hg > camir-aes2014
comparison toolboxes/MIRtoolbox1.3.2/somtoolbox/vis_footnote.m @ 0:e9a9cd732c1e tip
first hg version after svn
author | wolffd |
---|---|
date | Tue, 10 Feb 2015 15:05:51 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:e9a9cd732c1e |
---|---|
1 function h=vis_footnote(txt) | |
2 | |
3 % VIS_FOOTNOTE Adds a movable text to the current figure | |
4 % | |
5 % h = vis_footnote(T) | |
6 % | |
7 % Input and output arguments ([]'s are optional) | |
8 % [T] (string) text to be written | |
9 % (scalar) font size to use in all strings | |
10 % | |
11 % h (vector) handles to axis objects created by this function | |
12 % | |
13 % This function sets a text to the current figure. If T is a string, | |
14 % it's written as it is to the same place. If T is a scalar, the font | |
15 % size of all text objects created by this function are changed to the | |
16 % pointsize T. If no input argument is given the function only returns | |
17 % the handles to all objects created by this function. The texts may | |
18 % be dragged to a new location at any time using mouse. Note that the | |
19 % current axis will be the parent of the text object after dragging. | |
20 % | |
21 % String 'Info' is set to the Tag property field of the objects. | |
22 % | |
23 % EXAMPLES | |
24 % | |
25 % % add movable texts to the current figure and change their | |
26 % % fontsize to 20 points | |
27 % vis_footnote('Faa'); vis_footnote('Foo'); vis_footnote(20); | |
28 % | |
29 % % delete all objects created by this function from the current figure | |
30 % delete(vis_footnote); | |
31 % | |
32 % See also SOM_SHOW. | |
33 | |
34 % Copyright (c) 1997-2000 by the SOM toolbox programming team. | |
35 % http://www.cis.hut.fi/projects/somtoolbox/ | |
36 | |
37 % Version 2.0beta Johan 080698 | |
38 | |
39 %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
40 | |
41 error(nargchk(0, 1, nargin)) % check no. of input args | |
42 | |
43 %% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
44 | |
45 % Get the handles to the existing Info-axes objects | |
46 | |
47 h_infotxt=findobj(gcf,'tag','Info','type','text'); | |
48 h_infoax=findobj(gcf,'tag','Info','type','axes'); | |
49 | |
50 %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
51 | |
52 % If no arguments are given, return the old axes handles | |
53 | |
54 if nargin == 0 | isempty(txt), | |
55 ; | |
56 elseif ischar(txt) % text: set new text | |
57 [t,h_]=movetext(txt); | |
58 h_infoax=[h_; h_infoax]; | |
59 elseif vis_valuetype(txt,{'1x1'}) % scalar: change font size | |
60 set(h_infotxt,'fontunits','points'); | |
61 set(h_infotxt,'fontsize',txt); | |
62 else | |
63 error('Input argument should be a string or a scalar.'); | |
64 end | |
65 | |
66 %% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
67 | |
68 if nargout>0 % output only if necessary | |
69 h=h_infoax; | |
70 end | |
71 | |
72 %%% SUBFUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% | |
73 | |
74 function [t,h]=movetext(txt) | |
75 % Moves the text. See also VIS_FOOTNOTEBUTTONDOWNFCN | |
76 % | |
77 % | |
78 initpos=[0.05 0.05 0.01 0.01]; | |
79 | |
80 memaxes = gca; % Memorize the gca | |
81 | |
82 %% Create new axis on the lower left corner. | |
83 %% This will be the parent for the text object | |
84 | |
85 h = axes('position',initpos,'units','normalized'); | |
86 set(h,'visible','off'); % hide axis | |
87 | |
88 t = text(0,0,txt); % write text | |
89 set(t,'tag','Info'); % set tag | |
90 set(h,'tag','Info'); % set tag | |
91 | |
92 set(t,'verticalalignment','bottom'); % set text alignment | |
93 set(t,'horizontalalignment','left'); | |
94 | |
95 %% Set ButtonDownFcn | |
96 | |
97 set(t,'buttondownfcn','vis_footnoteButtonDownFcn') | |
98 | |
99 axes(memaxes); % Reset original gca | |
100 | |
101 |