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

root/gliderproc/trunk/MATLAB/opnml/basics/movetext.m

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

Initial import of Stark code.

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