function A = arrowline(varargin)
%ARROWLINE/ARROWLINE

%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 1.12 $  $Date: 1998/10/22 22:23:05 $

switch nargin
case 0
   A.Class = 'arrowline';
   A.arrowhead = [];
   A.line = [];
   A.fullline = [];
   A.hScale = [];
   A.vScale = [];
   A = class(A,'arrowline', editline);
   return
case 1  % reconstructing an arrow object from one of its
        % components.  Appdata has been stripped away.
   HG = varargin{1};  % one of the arrow components
   arrowID = get(HG,'UserData');
   fig = get(get(HG,'Parent'),'Parent');
   components = findall(fig,'UserData',arrowID);
   fulllineH = findobj(components,'Tag','ScribeArrowlineObject');
   lineH     = findobj(components,'Tag','ScribeArrowlineBody');
   headH     = findobj(components,'Tag','ScribeArrowlineHead');

   [fulllineH, lineH, headH, hscale, vscale] ...
           = makearrow(fulllineH,lineH,headH);

otherwise
   [fulllineH, lineH, headH, hscale, vscale] = makearrow(varargin{:});

   % store redundant information so that we can rebuild it
   % use the full line handle as an identifier
   arrowID = sprintf('%d',fulllineH);
   set([fulllineH, lineH, headH], {'Tag' 'UserData'},...
           {'ScribeArrowlineObject'  arrowID;...
            'ScribeArrowlineBody'    arrowID;...
            'ScribeArrowlineHead'    arrowID});
end


A.Class = 'arrowline';
A.arrowhead = headH;
A.line = lineH;
A.fullline = fulllineH;


% this isn't enough: it doesn't change with resize...
A.hScale = hscale;
A.vScale = vscale;

X = get(lineH,'XData');
Y = get(lineH,'YData');

set([fulllineH lineH headH],'EraseMode','normal');

editlineObj = editline(fulllineH);

u = getappdata(fulllineH,'ScribeUIContextMenu');
setappdata(lineH,'ScribeUIContextMenu', u);
setappdata(headH,'ScribeUIContextMenu', u);

A = class(A,'arrowline', editlineObj);
scribehandle(A);

