Mercurial > octave-nkf
comparison scripts/plot/private/__getlegenddata__.m @ 12390:7428d177f00a release-3-4-x
Fix for inline legends (#32022, #32343)
author | David Bateman <dbateman@free.fr> |
---|---|
date | Sat, 05 Feb 2011 10:19:13 -0500 |
parents | |
children | 3347ccb91708 |
comparison
equal
deleted
inserted
replaced
12386:c1ea9b90a272 | 12390:7428d177f00a |
---|---|
1 ## Copyright (C) 2010-2011 David Bateman | |
2 ## | |
3 ## This file is part of Octave. | |
4 ## | |
5 ## Octave is free software; you can redistribute it and/or modify it | |
6 ## under the terms of the GNU General Public License as published by | |
7 ## the Free Software Foundation; either version 3 of the License, or (at | |
8 ## your option) any later version. | |
9 ## | |
10 ## Octave is distributed in the hope that it will be useful, but | |
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 ## General Public License for more details. | |
14 ## | |
15 ## You should have received a copy of the GNU General Public License | |
16 ## along with Octave; see the file COPYING. If not, see | |
17 ## <http://www.gnu.org/licenses/>. | |
18 | |
19 ## -*- texinfo -*- | |
20 ## @deftypefn {Function File} {[@var{hplots}, @var{strings}]} = __getlegenddata__ (@var{h}) | |
21 ## Undocumented internal function. | |
22 ## @end deftypefn | |
23 | |
24 function [hplots, text_strings] = __getlegenddata__ (hlegend) | |
25 hplots = []; | |
26 text_strings = {}; | |
27 ca = getfield (get (hlegend, "userdata"), "handle"); | |
28 kids = []; | |
29 for i = 1 : numel (ca) | |
30 kids = [kids; get(ca (i), "children")]; | |
31 endfor | |
32 k = numel (kids); | |
33 while (k > 0) | |
34 typ = get (kids(k), "type"); | |
35 while (k > 0 | |
36 && ! (strcmp (typ, "line") || strcmp (typ, "surface") | |
37 || strcmp (typ, "patch") || strcmp (typ, "hggroup"))) | |
38 typ = get (kids(--k), "type"); | |
39 endwhile | |
40 if (k > 0) | |
41 if (strcmp (get (kids(k), "type"), "hggroup")) | |
42 hgkids = get (kids(k), "children"); | |
43 for j = 1 : length (hgkids) | |
44 hgobj = get (hgkids (j)); | |
45 if (isfield (hgobj, "displayname") | |
46 && ! isempty (hgobj.displayname)) | |
47 hplots = [hplots, hgkids(j)]; | |
48 text_strings = {text_strings{:}, hbobj.displayname}; | |
49 break; | |
50 endif | |
51 endfor | |
52 else | |
53 if (! isempty (get (kids (k), "displayname"))) | |
54 hplots = [hplots, kids(k)]; | |
55 text_strings = {text_strings{:}, get(kids (k), "displayname")}; | |
56 endif | |
57 endif | |
58 if (--k == 0) | |
59 break; | |
60 endif | |
61 endif | |
62 endwhile | |
63 endfunction |