annotate scripts/plot/private/__getlegenddata__.m @ 17394:6dbc866379e2

Replace cellfun() occurrences with faster code where possible. * scripts/help/doc_cache_create.m: Use built-in "isclass" rather than ischar. Use addpath and rmpath with multiple inputs rather than cellfun. * scripts/image/imformats.m: Use isfield with cell string list rather than cellfun. * scripts/image/private/__imread__.m: Use ismember to replace cellfun/strcmpi combo. * scripts/miscellaneous/what.m: Re-order if/elseif tree. * scripts/pkg/private/rebuild.m: Replace cellfun with strcat call. * scripts/plot/axis.m: Use comma-separated lists to replace cellfun. * scripts/plot/pareto.m: Use cellstr on char array to replace cellfun. * scripts/plot/private/__gnuplot_print__.m: Use @times, rather than anonymous function, in cellfun call. * scripts/plot/private/__line__.m: White space cleanup. * scripts/plot/private/__patch__.m: Use ismember to replace cellfun/strcmpi combo. Use in-place '|=' operator for performance. * scripts/plot/struct2hdl.m: Use ismember to replace cellfun/strcmp combo. * scripts/polynomial/splinefit.m: Use built-in "isclass" rather than ischar. * scripts/special-matrix/gallery.m: Remove anonymous functions inside cellfuns. * scripts/strings/strsplit.m: Correct comment character to '#' from '%'. * scripts/strings/untabify.m: Use multiple argument form of cellfun to get rid of anonymous function. * scripts/testfun/__run_test_suite__.m: Remove anonymous function from within cellfun. * scripts/ui/inputdlg.m: Use built-in "isclass" rather than ischar.
author Rik <rik@octave.org>
date Fri, 06 Sep 2013 14:08:42 -0700
parents 1c89599167a6
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
14138
72c96de7a403 maint: update copyright notices for 2012
John W. Eaton <jwe@octave.org>
parents: 13232
diff changeset
1 ## Copyright (C) 2010-2012 David Bateman
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
2 ##
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
3 ## This file is part of Octave.
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
4 ##
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
7 ## the Free Software Foundation; either version 3 of the License, or (at
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
8 ## your option) any later version.
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
9 ##
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
13 ## General Public License for more details.
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
14 ##
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, see
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
17 ## <http://www.gnu.org/licenses/>.
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
18
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
19 ## -*- texinfo -*-
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
20 ## @deftypefn {Function File} {[@var{hplots}, @var{strings}]} = __getlegenddata__ (@var{h})
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
21 ## Undocumented internal function.
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
22 ## @end deftypefn
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
23
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
24 function [hplots, text_strings] = __getlegenddata__ (hlegend)
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
25 hplots = [];
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
26 text_strings = {};
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
27 ca = getfield (get (hlegend, "userdata"), "handle");
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
28 kids = [];
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
29 for i = 1:numel (ca)
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
30 kids = [kids; get(ca(i), "children")];
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
31 endfor
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
32
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
33 for i = numel (kids):-1:1
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
34 typ = get (kids(i), "type");
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
35 if (strcmp (typ, "line") || strcmp (typ, "surface")
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
36 || strcmp (typ, "patch") || strcmp (typ, "hggroup"))
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
37
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
38 if (strcmp (typ, "hggroup"))
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
39 hgkids = get (kids(i), "children");
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
40 for j = 1 : length (hgkids)
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
41 hgobj = get (hgkids (j));
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
42 if (isfield (hgobj, "displayname") && ! isempty (hgobj.displayname))
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
43 hplots = [hplots, hgkids(j)];
12764
3347ccb91708 fix typo in __getlegenddata__
John W. Eaton <jwe@octave.org>
parents: 12339
diff changeset
44 text_strings = {text_strings{:}, hgobj.displayname};
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
45 break;
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
46 endif
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
47 endfor
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
48 else
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
49 if (! isempty (get (kids (i), "displayname")))
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
50 hplots = [hplots, kids(i)];
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
51 text_strings = {text_strings{:}, get(kids (i), "displayname")};
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
52 endif
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
53 endif
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
54
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
55 endif
13232
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
56 endfor
9b98affe52b9 __getlegenddata__.m: Fix bad subscript index error (Bug #33774).
Rik <octave@nomad.inbox5.com>
parents: 12764
diff changeset
57
12339
eda5eabd5d0b Fix for inline legends (#32022, #32343)
David Bateman <dbateman@free.fr>
parents:
diff changeset
58 endfunction
17346
1c89599167a6 maint: End m-files with 1 blank line.
Rik <rik@octave.org>
parents: 14138
diff changeset
59