Mercurial > octave
changeset 24478:59041be1994b
Use new function isgraphics to simplify m-files.
* uibuttongroup.m, uicontrol.m, __clabel__.m, clabel.m, shrinkfaces.m:
Use 'isgraphics (h, "type")' to replace separate calls to 'ishghandle (h)'
and 'strcmp (get (h, "type"), "type")'.
* hidden.m, legend.m, __errplot__.m, __plt__.m,__gnuplot_draw_figure__.m:
For performance, call get() just once to get both "type" and "tag" properties.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 27 Dec 2017 15:22:28 -0800 |
parents | e8cb11de9383 |
children | 6d2dc40a7c00 |
files | scripts/gui/uibuttongroup.m scripts/gui/uicontrol.m scripts/plot/appearance/__clabel__.m scripts/plot/appearance/clabel.m scripts/plot/appearance/hidden.m scripts/plot/appearance/legend.m scripts/plot/draw/private/__errplot__.m scripts/plot/draw/private/__plt__.m scripts/plot/draw/shrinkfaces.m scripts/plot/util/private/__gnuplot_draw_figure__.m |
diffstat | 10 files changed, 11 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/gui/uibuttongroup.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/gui/uibuttongroup.m Wed Dec 27 15:22:28 2017 -0800 @@ -64,8 +64,7 @@ function hui = uibuttongroup (varargin) - if (nargin == 1 && ishghandle (varargin{1}) - && strcmpi (get (varargin{1}, "type"), "uibuttongroup")) + if (nargin == 1 && isgraphics (varargin{1}, "uibuttongroup")) error ("uibuttongroup: focusing not implemented yet"); endif
--- a/scripts/gui/uicontrol.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/gui/uicontrol.m Wed Dec 27 15:22:28 2017 -0800 @@ -100,8 +100,7 @@ function hui = uicontrol (varargin) - if (nargin == 1 && ishghandle (varargin{1}) - && strcmpi (get (varargin{1}, "type"), "uicontrol")) + if (nargin == 1 && isgraphics (varargin{1}, "uicontrol")) error ("uicontrol: focusing not implemented yet"); endif
--- a/scripts/plot/appearance/__clabel__.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/appearance/__clabel__.m Wed Dec 27 15:22:28 2017 -0800 @@ -32,8 +32,7 @@ xspacing = axpos(3) / (lims(2) - lims (1)); yspacing = axpos(4) / (lims(4) - lims (3)); - if (isscalar (hparent) && ishghandle (hparent) - && strcmp (get (hparent, "type"), "hggroup")) + if (isscalar (hparent) && isgraphics (hparent, "hggroup")) x = get (hparent, "xdata"); xmin = min (x(:)); xmax = max (x(:));
--- a/scripts/plot/appearance/clabel.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/appearance/clabel.m Wed Dec 27 15:22:28 2017 -0800 @@ -73,8 +73,7 @@ hparent = gca (); else arg = varargin{1}; - if (isscalar (arg) && ishghandle (arg) - && strcmp (get (arg, "type"), "hggroup")) + if (isscalar (arg) && isgraphics (arg, "hggroup")) try get (arg, "contourmatrix"); catch
--- a/scripts/plot/appearance/hidden.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/appearance/hidden.m Wed Dec 27 15:22:28 2017 -0800 @@ -52,8 +52,7 @@ endif for h = (get (gca (), "children")).'; - htype = get (h, "type"); - htag = get (h, "tag"); + [htype, htag] = get (h, {"type", "tag"}){:}; if (strcmp (htype, "surface") || strcmp (htag, "trimesh")) fc = get (h, "facecolor"); if ((! ischar (fc) && is_white (fc))
--- a/scripts/plot/appearance/legend.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/appearance/legend.m Wed Dec 27 15:22:28 2017 -0800 @@ -188,8 +188,7 @@ hlegend = []; fkids = get (fig, "children"); for i = 1 : numel (fkids) - if ( strcmp (get (fkids(i), "type"), "axes") - && strcmp (get (fkids(i), "tag"), "legend")) + if (strcmp (get (fkids(i), {"type", "tag"}), {"axes", "legend"})) handle = getappdata (fkids(i), "handle"); if (any (ismember (handle, ca))) hlegend = fkids(i);
--- a/scripts/plot/draw/private/__errplot__.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/draw/private/__errplot__.m Wed Dec 27 15:22:28 2017 -0800 @@ -255,8 +255,7 @@ hlegend = []; fkids = get (gcf (), "children"); for i = 1 : numel (fkids) - if ( strcmp (get (fkids(i), "type"), "axes") - && strcmp (get (fkids(i), "tag"), "legend")) + if (strcmp (get (fkids(i), {"type", "tag"}), {"axes", "legend"})) leghandle = getappdata (fkids(i), "handle"); if (! isempty (intersect (leghandle, gca ()))) hlegend = fkids(i);
--- a/scripts/plot/draw/private/__plt__.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/draw/private/__plt__.m Wed Dec 27 15:22:28 2017 -0800 @@ -40,8 +40,7 @@ hlegend = []; fkids = get (gcf (), "children"); for i = 1 : numel (fkids) - if ( strcmp (get (fkids(i), "type"), "axes") - && strcmp (get (fkids(i), "tag"), "legend")) + if (strcmp (get (fkids(i), {"type", "tag"}), {"axes", "legend"})) leghandle = getappdata (fkids(i), "handle"); if (! isempty (intersect (leghandle, gca ()))) hlegend = fkids(i);
--- a/scripts/plot/draw/shrinkfaces.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/draw/shrinkfaces.m Wed Dec 27 15:22:28 2017 -0800 @@ -76,8 +76,7 @@ colors = []; p = varargin{1}; - if (isscalar (p) && ishghandle (p) && nargin < 3 - && strcmp (get (p, "type"), "patch")) + if (isscalar (p) && isgraphics (p, "patch") && nargin < 3) faces = get (p, "Faces"); vertices = get (p, "Vertices"); colors = get (p, "FaceVertexCData");
--- a/scripts/plot/util/private/__gnuplot_draw_figure__.m Wed Dec 27 12:41:45 2017 -0800 +++ b/scripts/plot/util/private/__gnuplot_draw_figure__.m Wed Dec 27 15:22:28 2017 -0800 @@ -159,8 +159,8 @@ fkids = get (h, "children"); for j = 1 : numel (fkids) if (ishghandle (fkids (j)) - && strcmp (get (fkids (j), "type"), "axes") - && (strcmp (get (fkids (j), "tag"), "legend"))) + && strcmp (get (fkids(j), {"type", "tag"}), + {"axes", "legend"})) leghandle = getappdata (fkids(j), "handle"); if (! isempty (intersect (leghandle, kids(i)))) hlegend = get (fkids(j));