Daniel@0: function h=vis_footnote(txt) Daniel@0: Daniel@0: % VIS_FOOTNOTE Adds a movable text to the current figure Daniel@0: % Daniel@0: % h = vis_footnote(T) Daniel@0: % Daniel@0: % Input and output arguments ([]'s are optional) Daniel@0: % [T] (string) text to be written Daniel@0: % (scalar) font size to use in all strings Daniel@0: % Daniel@0: % h (vector) handles to axis objects created by this function Daniel@0: % Daniel@0: % This function sets a text to the current figure. If T is a string, Daniel@0: % it's written as it is to the same place. If T is a scalar, the font Daniel@0: % size of all text objects created by this function are changed to the Daniel@0: % pointsize T. If no input argument is given the function only returns Daniel@0: % the handles to all objects created by this function. The texts may Daniel@0: % be dragged to a new location at any time using mouse. Note that the Daniel@0: % current axis will be the parent of the text object after dragging. Daniel@0: % Daniel@0: % String 'Info' is set to the Tag property field of the objects. Daniel@0: % Daniel@0: % EXAMPLES Daniel@0: % Daniel@0: % % add movable texts to the current figure and change their Daniel@0: % % fontsize to 20 points Daniel@0: % vis_footnote('Faa'); vis_footnote('Foo'); vis_footnote(20); Daniel@0: % Daniel@0: % % delete all objects created by this function from the current figure Daniel@0: % delete(vis_footnote); Daniel@0: % Daniel@0: % See also SOM_SHOW. Daniel@0: Daniel@0: % Copyright (c) 1997-2000 by the SOM toolbox programming team. Daniel@0: % http://www.cis.hut.fi/projects/somtoolbox/ Daniel@0: Daniel@0: % Version 2.0beta Johan 080698 Daniel@0: Daniel@0: %% Check arguments %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: error(nargchk(0, 1, nargin)) % check no. of input args Daniel@0: Daniel@0: %% Init %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: % Get the handles to the existing Info-axes objects Daniel@0: Daniel@0: h_infotxt=findobj(gcf,'tag','Info','type','text'); Daniel@0: h_infoax=findobj(gcf,'tag','Info','type','axes'); Daniel@0: Daniel@0: %% Action %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: % If no arguments are given, return the old axes handles Daniel@0: Daniel@0: if nargin == 0 | isempty(txt), Daniel@0: ; Daniel@0: elseif ischar(txt) % text: set new text Daniel@0: [t,h_]=movetext(txt); Daniel@0: h_infoax=[h_; h_infoax]; Daniel@0: elseif vis_valuetype(txt,{'1x1'}) % scalar: change font size Daniel@0: set(h_infotxt,'fontunits','points'); Daniel@0: set(h_infotxt,'fontsize',txt); Daniel@0: else Daniel@0: error('Input argument should be a string or a scalar.'); Daniel@0: end Daniel@0: Daniel@0: %% Build output %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: if nargout>0 % output only if necessary Daniel@0: h=h_infoax; Daniel@0: end Daniel@0: Daniel@0: %%% SUBFUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Daniel@0: Daniel@0: function [t,h]=movetext(txt) Daniel@0: % Moves the text. See also VIS_FOOTNOTEBUTTONDOWNFCN Daniel@0: % Daniel@0: % Daniel@0: initpos=[0.05 0.05 0.01 0.01]; Daniel@0: Daniel@0: memaxes = gca; % Memorize the gca Daniel@0: Daniel@0: %% Create new axis on the lower left corner. Daniel@0: %% This will be the parent for the text object Daniel@0: Daniel@0: h = axes('position',initpos,'units','normalized'); Daniel@0: set(h,'visible','off'); % hide axis Daniel@0: Daniel@0: t = text(0,0,txt); % write text Daniel@0: set(t,'tag','Info'); % set tag Daniel@0: set(h,'tag','Info'); % set tag Daniel@0: Daniel@0: set(t,'verticalalignment','bottom'); % set text alignment Daniel@0: set(t,'horizontalalignment','left'); Daniel@0: Daniel@0: %% Set ButtonDownFcn Daniel@0: Daniel@0: set(t,'buttondownfcn','vis_footnoteButtonDownFcn') Daniel@0: Daniel@0: axes(memaxes); % Reset original gca Daniel@0: Daniel@0: