function adjustview(cv,cd,Event,NormalRefresh)
%ADJUSTVIEW  Adjusts view prior to and after picking the axes limits. 
%
%  ADJUSTVIEW(cVIEW,cDATA,'postlim') adjusts the HG object extent once  
%  the axes limits have been finalized (invoked in response, e.g., to a 
%  'LimitChanged' event).

%  Author(s):  
%  Copyright 1986-2002 The MathWorks, Inc.
%  $Revision: 1.1.6.1 $ $Date: 2004/12/26 21:37:34 $

if strcmp(Event,'postlim')
   if strcmp(cv.AxesGrid.YNormalization,'on')
       return
       % Adjust final value line in normalized mode
       for ct=1:prod(size(cv.VLines))
          % Parent axes and limits
          ax = cv.VLines(ct).Parent;
          Xlim = get(ax,'Xlim');
          % Time Interval is restricted to specified start/end  
          Xlim(1) = max(cd.StartTime,Xlim(1));
          Xlim(2) = min(cd.EndTime,Xlim(2));    

          Ymean = cd.MeanValue(ct);
          if isfinite(Ymean)
             Ymean = normalize(cd.Parent,Ymean,Xlim,ct);
          end
          % Position objects
          set(double(cv.VLines(ct)),'XData',Xlim,'YData',[Ymean,Ymean], ...
              'ZData',[-10,-10]) 
       end
   else
       draw(cv,cd,NormalRefresh)
   end
end
