function [theGraphics, theText] = getLegendItems(anAxes)
%GETLEGENDITEMS   The graphics items displayed by a legend.
%
%   GETLEGENDITEMS( anAxes ) is a vector of graphics items in anAxes that
%   are displayed on the legend for the that plot
%
%   [theGraphics, theText] = GETLEGENDITEMS(anAxes) returns the text
%   displayed on the legend as well as the graphics reflected on the
%   legend. The text will be a cell array of strings with one element for each
%   graphic on the legend.

%   Copyright 2011-2014 The MathWorks, Inc.

% Without the DRAWNOW the legend object doesn't have the handles of the objects
% that it is displaying
drawnow( 'expose' )

hLegend = get(anAxes,'Legend');

if isempty( hLegend ) 
    theGraphics = [];
    theText = {};
else
    theGraphics = hLegend.PlotChildren;
    theText = hLegend.String;
end

end
