Mercurial > octave
changeset 24479:6d2dc40a7c00
isaxes.m, isgraphics.m, isfigure.m: Clean up related isXXX graphics functions.
* isaxes.m: Add @seealso link to isgraphics. Remove incorrect Author: comment.
Remove unnecessary intermediate variable hlist. Add BIST input validation
tests.
* isfigure.m: Add @seealso link to isgraphics. Remove unnecessary intermediate
variable hlist. Fix operation when multiple input handles are present.
Add new BIST test for multiple handles. Add BIST input validation tests.
* isgraphics.m: Correct Copyright author. Add isaxes, isfigure to
@seealso links. Remove unnecessary intermediate variable typematch.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 27 Dec 2017 15:51:48 -0800 |
parents | 59041be1994b |
children | 04d1a3ea26a3 |
files | scripts/plot/util/isaxes.m scripts/plot/util/isfigure.m scripts/plot/util/isgraphics.m |
diffstat | 3 files changed, 27 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/plot/util/isaxes.m Wed Dec 27 15:22:28 2017 -0800 +++ b/scripts/plot/util/isaxes.m Wed Dec 27 15:51:48 2017 -0800 @@ -22,22 +22,19 @@ ## ## If @var{h} is a matrix then return a logical array which is true where the ## elements of @var{h} are axes graphics handles and false where they are not. -## @seealso{isaxes, ishghandle} +## @seealso{isfigure, ishghandle, isgraphics} ## @end deftypefn -## Author: jwe - function retval = isaxes (h) if (nargin != 1) print_usage (); endif - hlist = ishghandle (h); - retval = hlist; + retval = ishghandle (h); - if (any (hlist)) - retval(hlist) = strcmp (get (h(hlist), "type"), "axes"); + if (any (retval)) + retval(retval) = strcmp (get (h(retval), "type"), "axes"); endif endfunction @@ -61,3 +58,6 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect + +%!error isaxes () +%!error isaxes (1, 2)
--- a/scripts/plot/util/isfigure.m Wed Dec 27 15:22:28 2017 -0800 +++ b/scripts/plot/util/isfigure.m Wed Dec 27 15:51:48 2017 -0800 @@ -23,7 +23,7 @@ ## If @var{h} is a matrix then return a logical array which is true where the ## elements of @var{h} are figure graphics handles and false where they are ## not. -## @seealso{isaxes, ishghandle} +## @seealso{isaxes, ishghandle, isgraphics} ## @end deftypefn ## Author: jwe @@ -34,11 +34,10 @@ print_usage (); endif - hlist = ishghandle (h); - if (any (hlist)) - retval(hlist) = strcmp (get (h(hlist), "type"), "figure"); - else - retval = hlist; + retval = ishghandle (h); + + if (any (retval)) + retval(retval) = strcmp (get (h(retval), "type"), "figure"); endif endfunction @@ -52,3 +51,14 @@ %! unwind_protect_cleanup %! close (hf); %! end_unwind_protect + +%!test +%! hf = figure ("visible", "off"); +%! unwind_protect +%! assert (isfigure ([hf NaN]), [true false]); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + +%!error isfigure () +%!error isfigure (1, 2)
--- a/scripts/plot/util/isgraphics.m Wed Dec 27 15:22:28 2017 -0800 +++ b/scripts/plot/util/isgraphics.m Wed Dec 27 15:51:48 2017 -0800 @@ -1,4 +1,4 @@ -## Copyright (C) 2008-2017 David Bateman +## Copyright (C) 2017 Rik Wehbring ## ## This file is part of Octave. ## @@ -24,7 +24,7 @@ ## ## When no @var{type} is specified the function is equivalent to ## @code{ishghandle}. -## @seealso{ishghandle, ishandle} +## @seealso{ishghandle, ishandle, isaxes, isfigure} ## @end deftypefn function retval = isgraphics (h, type = "") @@ -33,7 +33,7 @@ print_usage (); endif - if (nargin == 2 && (! ischar (type) || ! isrow (type))) + if (nargin == 2 && ! (ischar (type) && isrow (type))) error ("isgraphics: TYPE must be a string"); endif @@ -41,8 +41,7 @@ retval = ishghandle (h); if (nargin == 2 && any (retval)) - typematch = strcmpi (get (h(retval), "type"), type); - retval(retval) = typematch; + retval(retval) = strcmpi (get (h(retval), "type"), type); endif endfunction