time | Calls | line |
---|
| | 1 | function has=hasbehavior(h,name,state)
|
| | 2 | %HASBEHAVIOR sets(enables/disables) or gets behaviors of hg objects
|
| | 3 | %
|
| | 4 | % HASBEHAVIOR(H,NAME,STATE) sets the behavior named NAME for the
|
| | 5 | % hg object with handle H to STATE (true or false). The NAME
|
| | 6 | % is case-insensitive. The name 'legend' is used by the LEGEND
|
| | 7 | % command to enable or disable showing the object in a legend.
|
| | 8 | % HAS = HASBEHAVIOR(H,NAME) returns the boolean value for the
|
| | 9 | % behavior NAME of H. If the behavior has not been previously
|
| | 10 | % set for H, then 'on' is returned.
|
| | 11 | %
|
| | 12 | % Examples:
|
| | 13 | % ax=axes;
|
| | 14 | % l=plot(rand(3,3));
|
| | 15 | % hasbehavior(l(1),'legend',false); % line will not be in legend
|
| | 16 | % hasbehavior(l(2),'legend',true); % line will be in legend
|
| | 17 | %
|
| | 18 | % linelegendable = hasbehavior(l(1),'legend'); % gets legend behavior
|
| | 19 |
|
| | 20 | % Copyright 1984-2012 The MathWorks, Inc.
|
| | 21 |
|
< 0.001 | 434 | 22 | narginchk(2,3);
|
| | 23 |
|
0.003 | 434 | 24 | if ~ishghandle(h)
|
| | 25 | error(message('MATLAB:hasbehavior:InvalidHandle'));
|
< 0.001 | 434 | 26 | end
|
< 0.001 | 434 | 27 | if ~ischar(name)
|
| | 28 | error(message('MATLAB:hasbehavior:InvalidName'));
|
< 0.001 | 434 | 29 | end
|
0.002 | 434 | 30 | behaviorname = [name,'_hgbehavior'];
|
< 0.001 | 434 | 31 | if nargin == 2
|
| | 32 | % if the appdata does not exist then the behavior is true
|
0.006 | 434 | 33 | if ~isappdata(h,behaviorname)
|
< 0.001 | 434 | 34 | has = true;
|
| | 35 | elseif isequal(false,getappdata(h,behaviorname))
|
| | 36 | has = false;
|
| | 37 | else
|
| | 38 | has = true;
|
< 0.001 | 434 | 39 | end
|
| | 40 | else
|
| | 41 | if ~islogical(state) && ~isnumeric(state)
|
| | 42 | error(message('MATLAB:hasbehavior:InvalidBehaviorState'));
|
| | 43 | end
|
| | 44 | setappdata(h,behaviorname,state)
|
< 0.001 | 434 | 45 | end
|
Other subfunctions in this file are not included in this listing.