Mercurial > octave
changeset 23176:5f7c675b3954
annotation.m: Rename property "edgecolor" to "color" (bug #50227).
* annotation.m: Deprecate rectangle and ellipse property "edgecolor" in
favor of "color". Add test for rectangle properties. Minor white space
changes.
* NEWS: Announce deprecation.
author | Markus Mützel <markus.muetzel@gmx.de> |
---|---|
date | Tue, 07 Feb 2017 20:16:28 +0100 |
parents | 9ab7c15553b8 |
children | 0b59e37dd83e |
files | NEWS scripts/plot/appearance/annotation.m |
diffstat | 2 files changed, 51 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/NEWS Thu Feb 09 09:31:55 2017 -0800 +++ b/NEWS Tue Feb 07 20:16:28 2017 +0100 @@ -60,6 +60,11 @@ that it defined (DECLARE_OCTAVE_ALLOCATOR, DEFINE_OCTAVE_ALLOCATOR, and DEFINE_OCTAVE_ALLOCATOR2). + ** The rectangle and ellipse annotation property "edgecolor" has been + deprecated and will be removed from Octave 4.8 (or whatever version + is the second major release after 4.4). Use the property "color" + instead. + Summary of important user-visible changes for version 4.2: ---------------------------------------------------------
--- a/scripts/plot/appearance/annotation.m Thu Feb 09 09:31:55 2017 -0800 +++ b/scripts/plot/appearance/annotation.m Tue Feb 07 20:16:28 2017 +0100 @@ -480,10 +480,13 @@ hr = patch (x, y, "parent", h); + ## FIXME: Remove warn state switching in Octave 4.8 + old_warn_state = warning ("off", "Octave:deprecated-property"); propnames = rectprops ("names"); for ii = 1:numel (propnames) update_rect (h, {}, propnames{ii}, hr, objtype); endfor + warning (old_warn_state); rectmenu (hui, h); set (hr, "uicontextmenu", hui); @@ -727,9 +730,9 @@ "linestyle", "linelinestyle", "-", ... "linewidth", "linelinewidth", 0.5, ... "string", "textstring", "", ... - "fitboxtotext", "radio","{on}|off", ... + "fitboxtotext", "radio", "{on}|off", ... "margin", "data", 5, ... - "verticalalignment", "textverticalalignment", "middle"}; + "verticalalignment", "textverticalalignment", "middle"}; if (strcmp (varargin, "names")) props = props(1:3:end); endif @@ -797,7 +800,9 @@ function props = rectprops (varargin) - props = {"edgecolor", "patchedgecolor", "k", ... + ## FIXME: Remove "edgecolor" in Octave 4.8 + props = {"color", "patchedgecolor", "k", ... + "edgecolor", "patchedgecolor", "k", ... "facealpha", "patchfacealpha", 1, ... "facecolor", "patchfacecolor", "none", ... "linestyle", "patchlinestyle", "-", ... @@ -813,7 +818,7 @@ prop = "facecolor"; vals = basecolors (); addbasemenu (hui, hpar, prop, vals, "Face Color"); - prop = "edgecolor"; + prop = "color"; vals = basecolors (); addbasemenu (hui, hpar, prop, vals, "Edge Color"); prop = "linestyle"; @@ -1257,7 +1262,7 @@ endfunction -function update_rect (h, dummy, prop, hre, typ) +function update_rect (h, ~, prop, hre, typ) persistent recursive = false; if (! recursive) @@ -1269,10 +1274,22 @@ else [x, y] = pos2ell (pos); endif + set (hre, "xdata", x, "ydata", y); - set (hre, "xdata", x, "ydata", y); + case "color" + set (hre, "edgecolor", get (h, prop)); + + case "edgecolor" + ## FIXME: Remove "edgecolor" in Octave 4.8 + warning ("Octave:deprecated-property", + ['annotation: Property "edgecolor" for ' typ ' annotations'... + ' is deprecated and will be removed from a future version'... + ' of Octave. Use "color" instead.']); + set (hre, "edgecolor", get (h, prop)); + otherwise set (hre, prop, get (h, prop)); + endswitch endif @@ -1494,6 +1511,29 @@ %! close (hf); %! end_unwind_protect +## test rectangle properties +%!test +%! hf = figure ("visible", "off"); +%! hax = axes (); +%! unwind_protect +%! h = annotation ("rectangle", [0.2 0.7 0.2 0.2], "linewidth", 2, +%! "linestyle", "--", "color", "r", "facecolor", "b", +%! "facealpha", .6, "units", "normalized"); +%! hpa = get (h, "children"); +%! assert (get (hpa, "xdata"), [0.2; 0.4; 0.4; 0.2], eps); +%! assert (get (hpa, "ydata"), [0.7; 0.7; 0.9; 0.9], eps); +%! assert (get (hpa, "linewidth"), 2); +%! assert (get (hpa, "linestyle"), "--"); +%! assert (get (hpa, "edgecolor"), [1 0 0]); +%! assert (get (hpa, "edgecolor"), get (h, "color")); +%! assert (get (hpa, "facecolor"), [0 0 1]); +%! assert (get (hpa, "facealpha"), .6); +%! +%! assert (gca (), hax); +%! unwind_protect_cleanup +%! close (hf); +%! end_unwind_protect + ## test units conversion %!test %! hf = figure ("visible", "off");