NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/gliderproc/trunk/MATLAB/plots/movetext.m

Revision 495 (checked in by cbc, 12 years ago)

Initial import of Stark code.

Line 
1 function movetext(arg)
2 % MOVETEXT  Used to grab and move text objects.
3 %           To activate, type "movetext" or "movetext('on')".
4 %           Then, move the mouse pointer near the lower left corner of
5 %           the text object you want to move.  Depress and hold down
6 %           the left mouse button.  When the pointer changes from an arrow
7 %           to a fleur, drag the text to the new location.  Release the
8 %           left mouse button.  This action can be done to any text object
9 %           on the figure (including titles and axis labels) at any time
10 %           until "movetext('off')" is executed.  This turns off the
11 %           movetext capability.
12 %
13 %           This function is adapted from a routine written by Drea
14 %           Thomas at Mathworks Inc., and (signifigantly) enhanced by:
15 %
16 % Calls: none
17 %
18 %           Brian O. Blanton
19 %           Curriculum in Marine Science
20 %           Ocean Processes Numerical Modeling Laboratory
21 %           15-1A Venable Hall
22 %           CB# 3300
23 %           Uni. of North Carolina
24 %           Chapel Hill, NC
25 %                    27599-3300
26 %
27 %           919-962-4466
28 %           blanton@marine.unc.edu
29 %
30 %           September  1994
31
32 % get current window button functions
33 if nargin==0,
34   set(gcf,'windowbuttondownf','movetext(1)')
35   return
36 elseif nargin==1
37   if isstr(arg)
38     if strcmp(arg,'off')
39       set(gcf,'WindowButtonMotionfcn','', ...
40               'pointer','arrow',...
41               'windowbuttonupfcn','',...
42               'windowbuttondownfcn','lastouch');                   
43     elseif strcmp(arg,'on')
44       set(gcf,'windowbuttondownf','movetext(1)')
45     else
46       error('Invalid string argument to MOVETEXT; type "help MOVETEXT"')
47     end
48   end
49 else
50   error('Too many arguments to MOVETEXT; type "help MOVETEXT"')
51 end
52    
53 if arg==1
54   if (~strcmp(get(gcf,'Selectiont'),'normal'))
55     return
56   end
57   if(~strcmp(get(gco,'type'),'text')),
58     return
59   end
60   set(gcf,'pointer','fleur');
61   set(gco,'units','data');
62   set(gco,'Selected','on');
63   set(gcf,'windowbuttonmotionfcn','movetext(2)')
64   set(gcf,'windowbuttonupfcn','movetext(3)');
65 elseif arg==2
66   pp = [get(gca,'currentpoint')];
67   yl = get(gca,'ylim');
68   set(gco,'position',[pp(1,:)]);
69 elseif arg==3
70   set(gcf,'WindowButtonMotionfcn','', ...
71           'pointer','arrow',...
72           'windowbuttonupfcn',''); 
73   set(gco,'Selected','off');
74 end
Note: See TracBrowser for help on using the browser.