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