%    SGCREDIT - attach author & organization credits to figure window
%
%        th = sgcredit( author, organization )
%
%    B. A. Moran

%    Copyright (C) 1995-1998
%    Massachussetts Institute of Technology
%    Sea Grant AUV Laboratory
%    $Id: sgcredit.m,v 1.1 2000/01/10 19:08:34 rob Exp $

function th = sgcredit( author, organization )

if nargin < 1, author = ['Dr. Bradley A. Moran, ' date]; end
if nargin < 2, organization = 'MIT Sea Grant AUV Laboratory'; end

ch = findobj( get(gcf,'children'), 'Type', 'axes', 'Visible', 'on' );

if isempty(ch)                          % error if no axes exist
    error( 'Nonexistent axes' )
end

pos = get(ch,'position');               % calculate bounding rectangle
if ( iscell(pos) )
    pos = cat(1, pos{:});               % MATLAB 5 cell concatenation
    bndRect = [min(pos(:,1:2)) 0 0];
    bndRect(3:4) = max(pos(:,1:2) + pos(:,3:4)) - bndRect(1:2);
else
    bndRect = pos;
end

newAx = axes( 'Position', bndRect, 'Layer', 'Bottom', 'Visible', 'Off', ...
    'Units', 'Normalized' );

th(2) = text( 'string', organization, 'Position', [0 -0.8*bndRect(2)], ...
    'Vert', 'top', 'Hor', 'left', 'fontangle', 'italic' );

th(1) = text( 'string', author, 'Position', [1 -0.8*bndRect(2)], ...
    'Vert', 'top', 'Hor', 'right', 'fontangle', 'italic' );
