Fix test for setting of datasource properties. Add the edgecolor property to contours
authorDavid Bateman <dbateman@free.fr>
Mon Aug 24 10:02:47 2009 +0200 (2009-08-24)
changeset 9411d208ae6e9d74
parent 9410 c3d37d2a2b55
child 9412 8e69b1d41c03
Fix test for setting of datasource properties. Add the edgecolor property to contours
scripts/ChangeLog
scripts/plot/__add_datasource__.m
scripts/plot/__contour__.m
     1.1 --- a/scripts/ChangeLog	Sun Aug 23 11:12:35 2009 +0200
     1.2 +++ b/scripts/ChangeLog	Mon Aug 24 10:02:47 2009 +0200
     1.3 @@ -1,3 +1,9 @@
     1.4 +2009-08-22  David Bateman  <dbateman@free.fr>
     1.5 +
     1.6 +	* plot/__add_datasource__.m: Correct test for "datasource" argument
     1.7 +	* plot/__countour__.m: Add edgecolor properties and make it an alias
     1.8 +	for linecolor with the value "auto" being "flat" for the edgecolor.
     1.9 +
    1.10  2009-08-04  Pieter Eendebak <pieter.eendebak@gmail.com> 
    1.11  
    1.12  	* set/setxor.m: Support cell arrays of strings.
     2.1 --- a/scripts/plot/__add_datasource__.m	Sun Aug 23 11:12:35 2009 +0200
     2.2 +++ b/scripts/plot/__add_datasource__.m	Mon Aug 24 10:02:47 2009 +0200
     2.3 @@ -40,7 +40,7 @@
     2.4    while (i < numel (varargin))
     2.5      arg = varargin{++i};
     2.6      if (i != numel(varargin) && ischar (arg)
     2.7 -	&& length (arg) > 1 && strcmpi (arg(end-9:end), "datasource"))
     2.8 +	&& length (arg) > 9 && strcmpi (arg(end-9:end), "datasource"))
     2.9        arg = tolower (arg);
    2.10        val = varargin{++i};
    2.11        if (ischar (val))
     3.1 --- a/scripts/plot/__contour__.m	Sun Aug 23 11:12:35 2009 +0200
     3.2 +++ b/scripts/plot/__contour__.m	Mon Aug 24 10:02:47 2009 +0200
     3.3 @@ -28,6 +28,7 @@
     3.4  
     3.5    linespec.linestyle = "-";
     3.6    linespec.color = "auto";
     3.7 +  edgecolor = "flat";
     3.8    for i = 3 : nargin
     3.9      arg = varargin {i};
    3.10      if ((ischar (arg) || iscell (arg)))
    3.11 @@ -52,6 +53,17 @@
    3.12  	varargin(i:i+1) = [];
    3.13        elseif (strcmpi (varargin{i}, "linecolor"))
    3.14  	linespec.color = varargin {i + 1};
    3.15 +	edgecolor = linespec.color;
    3.16 +	if (ischar (edgecolor) && strcmpi (edgecolor, "auto"))
    3.17 +	  edgecolor = "flat";
    3.18 +	endif
    3.19 +	varargin(i:i+1) = [];
    3.20 +      elseif (strcmpi (varargin{i}, "edgecolor"))
    3.21 +	linespec.color = varargin {i + 1};
    3.22 +	edgecolor = linespec.color;
    3.23 +	if (ischar (edgecolor) && strcmpi (edgecolor, "flat"))
    3.24 +	  linespec.color = "auto";
    3.25 +	endif
    3.26  	varargin(i:i+1) = [];
    3.27        else
    3.28  	opts{end+1} = varargin{i};
    3.29 @@ -164,6 +176,10 @@
    3.30    addproperty ("linestyle", hg, "linelinestyle", linespec.linestyle);
    3.31    addproperty ("linewidth", hg, "linelinewidth", 0.5);
    3.32  
    3.33 +  ## FIXME It would be good to hide this property which is just an undocumented
    3.34 +  ## alias for linecolor
    3.35 +  addproperty ("edgecolor", hg, "color", edgecolor, "{flat}|none");
    3.36 +
    3.37    addlistener (hg, "fill", @update_data);
    3.38  
    3.39    addlistener (hg, "zlevelmode", @update_zlevel);
    3.40 @@ -185,6 +201,8 @@
    3.41    addlistener (hg, "linestyle", @update_line);
    3.42    addlistener (hg, "linewidth", @update_line);
    3.43  
    3.44 +  addlistener (hg, "edgecolor", @update_edgecolor);
    3.45 +
    3.46    add_patch_children (hg);
    3.47  
    3.48    if (!isempty (opts))
    3.49 @@ -366,11 +384,27 @@
    3.50    endswitch
    3.51  endfunction
    3.52  
    3.53 +function update_edgecolor (h, d)
    3.54 +  ec = get (h, "edgecolor");
    3.55 +  lc = get (h, "linecolor");
    3.56 +  if (ischar (ec) && strcmpi (ec, "flat"))
    3.57 +    if (! strcmpi (lc, "auto"))
    3.58 +      set (h, "linecolor", "auto");
    3.59 +    endif
    3.60 +  elseif (! isequal (ec, lc))
    3.61 +    set (h, "linecolor", ec);
    3.62 +  endif
    3.63 +endfunction
    3.64 +
    3.65  function update_line (h, d)
    3.66    lc = get (h, "linecolor");
    3.67 +  ec = get (h, "edgecolor");
    3.68    if (strcmpi (lc, "auto"))
    3.69      lc = "flat";
    3.70    endif
    3.71 +  if (! isequal (ec, lc))
    3.72 +    set (h, "edgecolor", lc);
    3.73 +  endif
    3.74    set (findobj (h, "type", "patch"), "edgecolor", lc,
    3.75         "linewidth", get (h, "linewidth"), "linestyle", get (h, "linestyle"));
    3.76  endfunction