function h=annotationlayer(varargin)
%ANNOTATIONLLAYER creates an annotation layer
%  H=GRAPH2D.ANNOTATIONLAYER creates an annotation layer for drawing
%  arrows, lines, and text
%
%  See also PLOTEDIT

%   Copyright 1984-2000 The MathWorks, Inc.  
%   $Revision: 1.5 $  $Date: 2000/06/17 00:58:15 $ 

pkg   = findpackage('graph2d');
pkgHG = findpackage('hg');

if (nargout == 0)
    h = schema.class(pkg, 'annotationlayer' , ...
		     pkgHG.findclass('axes'));
    
    pl = schema.prop(h, 'PropertyChangedListeners', 'handle vector');
    pl.AccessFlags.Serialize = 'off';
    pl.AccessFlags.PublicGet = 'off';
    pl.AccessFlags.PublicSet = 'off';
    
elseif (nargout == 1)

    if (~isempty(varargin))
        h = graph2d.annotationlayer(varargin{:}); % Calls built-in constructor
    else
        h = graph2d.annotationlayer;
    end
    
    jpropeditutils('jforcenavbardisplay',h,0);

    % Make sure that Xlabel, YLabel, etc are created before
    % child added listeners are created.
    
    childHandles=[get(h,'XLabel')
        get(h,'YLabel')
        get(h,'ZLabel')
        get(h,'Title')];
    
    % initialize property values -----------------------------
    
    %set up listeners-----------------------------------------
    
    %cls = classhandle(h);
    
    l       = handle.listener(h, ...
        'ObjectChildAdded',@changedChildren);
    l(end+1)= handle.listener(h, ...
        'ObjectChildRemoved',@changedChildren);
    
    h.PropertyChangedListeners = l;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function changedChildren(hProp,ChildEventData)

hAxes=ChildEventData.Source;
hChildren=get(double(hAxes),'Children');
hChildren=findobj(hChildren,'flat','beingdeleted','off');

jpropeditutils('jforcenavbardisplay',...
    hAxes,...
    length(hChildren)>0);
