comparison scripts/plot/private/__getlegenddata__.m @ 13232:9b98affe52b9 stable

__getlegenddata__.m: Fix bad subscript index error (Bug #33774). * __getlegenddata__.m: Switch to for loop to avoid difficult indexing scheme which occasionally underindexes to 0.
author Rik <octave@nomad.inbox5.com>
date Mon, 26 Sep 2011 11:19:41 -0700
parents 3347ccb91708
children 72c96de7a403
comparison
equal deleted inserted replaced
13224:0a67c717c652 13232:9b98affe52b9
24 function [hplots, text_strings] = __getlegenddata__ (hlegend) 24 function [hplots, text_strings] = __getlegenddata__ (hlegend)
25 hplots = []; 25 hplots = [];
26 text_strings = {}; 26 text_strings = {};
27 ca = getfield (get (hlegend, "userdata"), "handle"); 27 ca = getfield (get (hlegend, "userdata"), "handle");
28 kids = []; 28 kids = [];
29 for i = 1 : numel (ca) 29 for i = 1:numel (ca)
30 kids = [kids; get(ca (i), "children")]; 30 kids = [kids; get(ca(i), "children")];
31 endfor 31 endfor
32 k = numel (kids); 32
33 while (k > 0) 33 for i = numel (kids):-1:1
34 typ = get (kids(k), "type"); 34 typ = get (kids(i), "type");
35 while (k > 0 35 if (strcmp (typ, "line") || strcmp (typ, "surface")
36 && ! (strcmp (typ, "line") || strcmp (typ, "surface") 36 || strcmp (typ, "patch") || strcmp (typ, "hggroup"))
37 || strcmp (typ, "patch") || strcmp (typ, "hggroup"))) 37
38 typ = get (kids(--k), "type"); 38 if (strcmp (typ, "hggroup"))
39 endwhile 39 hgkids = get (kids(i), "children");
40 if (k > 0)
41 if (strcmp (get (kids(k), "type"), "hggroup"))
42 hgkids = get (kids(k), "children");
43 for j = 1 : length (hgkids) 40 for j = 1 : length (hgkids)
44 hgobj = get (hgkids (j)); 41 hgobj = get (hgkids (j));
45 if (isfield (hgobj, "displayname") 42 if (isfield (hgobj, "displayname") && ! isempty (hgobj.displayname))
46 && ! isempty (hgobj.displayname))
47 hplots = [hplots, hgkids(j)]; 43 hplots = [hplots, hgkids(j)];
48 text_strings = {text_strings{:}, hgobj.displayname}; 44 text_strings = {text_strings{:}, hgobj.displayname};
49 break; 45 break;
50 endif 46 endif
51 endfor 47 endfor
52 else 48 else
53 if (! isempty (get (kids (k), "displayname"))) 49 if (! isempty (get (kids (i), "displayname")))
54 hplots = [hplots, kids(k)]; 50 hplots = [hplots, kids(i)];
55 text_strings = {text_strings{:}, get(kids (k), "displayname")}; 51 text_strings = {text_strings{:}, get(kids (i), "displayname")};
56 endif 52 endif
57 endif 53 endif
58 if (--k == 0) 54
59 break;
60 endif
61 endif 55 endif
62 endwhile 56 endfor
57
63 endfunction 58 endfunction