function installtip(this,gobjects,tipfcn,info)
%INSTALLTIP  Installs line tip on specified G-objects.

%   Author(s): P. Gahinet
%   Copyright 1986-2004 The MathWorks, Inc.
%   $Revision: 1.1.6.2 $  $Date: 2004/04/11 00:22:19 $

% RE: TIPFCN is either '' or a MATLAB callback. The tip text is generated by evaluating the
%     tip function according to
%        TIPTEXT = feval(@fcn,INFO,arg1,...,argN)
%     for TIPFCN = {@fcn arg1 ... argN}

if isempty(tipfcn)
    for ct = 1:length(gobjects)
        %% Do not create a new datatip on a click only create on hoverfig
        hb = hggetbehavior(gobjects(ct),'DataCursor');
        set(hb,'CreateNewDatatip',false);
    end
else
    for ct = 1:length(gobjects)
        %% Do not create a new datatip on a click only create on hoverfig
        hb = hggetbehavior(gobjects(ct),'DataCursor');
        set(hb,'UpdateFcn',{tipfcn info});
        set(hb,'CreateFcn',{@LocalSetTipProperties gobjects(ct)});
        set(hb,'CreateNewDatatip',true);
        %% Install the button down function
        set(gobjects(ct),'ButtonDownFcn',@localLineButtonDown);
    end
end

%%%%%%%%%%  Local Functions   %%%%%%%%%%

function tip = localLineButtonDown(EventSrc,EventData)
% Create the data tip
tip = pointtip(EventSrc);

function LocalSetTipProperties(es,ed,gobject)

%% Set the line marker properties.  This is used for the case where the
%% datatip mode object is on
FaceColor = get(gobject,'MarkerFaceColor');
Color = get(gobject,'Color');
LineWidth = get(gobject,'LineWidth');
Marker = get(gobject,'Marker');
MarkerSize = get(gobject,'MarkerSize');
MarkerEdgeColor = get(gobject,'MarkerEdgeColor');
set(es.MarkerHandle,'Marker',Marker,'Color',Color,...
    'LineWidth',LineWidth,...
    'MarkerFaceColor',FaceColor,...
    'MarkerSize',MarkerSize,...
    'MarkerEdgeColor',MarkerEdgeColor);