function varargout = plotstuf(varargin)
%  1.  NAME
%
%  plotstuf - Display additionnal stuff on plots
%
%  2.  SYNOPSIS
%
%  plotstuf(what, value, what, value, ...  )
%
%  3.  DESCRIPTION
%
%  This Matlab function will display the specified things on the current
%  plot.  Possible stuff to plot are:
%
%     -title
%        Title for plot.
%
%     -subtitle
%        Subtitle for plot.
%
%     -institute
%        Institute or author stamp.
%
%     -note
%        Additionnal note which will be appended to the time stamp.
%
%     -info
%        Information string such as legend,ranges,or whatever.
%
%     -  Specifies the page ,i.e. landscape or portrait. Default value is
%        portrait. Note that if you plan to create plots in landscape
%        using command orient landscape,you should specify manually axes
%        for the plot like [0.1,0.1,0.8,0.7],so that there will be enough
%        place left for title,subtitle,... on the page.
%
%  4.  PARAMETERS
%
%     what
%        A string specifying which stuff to display.
%
%     value
%        The value for the specified stuff.
%
%  5.  AUTHORS
%
%  Pierre Jaccard, Geophysical Institute, University of Bergen, 1999
%

%--------------------------------------------------------------------------
% 
% plotstuf.m -- 
% 
% Author          : Jaccard Pierre
% Created On      : 2000/06/28 14:29:22
% Last Modified By: Jaccard Pierre
% Last Modified On: 2000/08/23 14:32:07
% Directory       : /dataOS/jaccard/codas/codas3c/gfi/matlab/matlab50/
% ----------------------------------------------------------------------- +
% VERSION CONTROL: 
% 
%   $Author$
%   $Date$
%   $Id$
%   $Name$
%   $Revision$
%   $State$
%   $Log$
% 
%--------------------------------------------------------------------------

%--- Defaults:
title = [];
subtitle = [];
institute = [];
note = [];
info = [];
format = 'portrait';
tid = [];

%--- Arguments:
i = 1;
while i < nargin,
  if isstr(varargin{i}),
	 switch(varargin{i})
		case '-format',
		  format = varargin{i+1};
		case '-note',
		  note = varargin{i+1};
		case '-institute',
		  institute = varargin{i+1};
		case '-info',
		  info = varargin{i+1};
		case '-title',
		  title = varargin{i+1};
		case '-subtitle',
		  subtitle = varargin{i+1};
		otherwise,
		  error([ 'Unknown option ' varargin{i} ]);
	 end
	 i = i+2;
  end
end

ty = 0.98;
if strcmp(format, 'landscape'),
	ty = 0.99;
end

old_axes = gca;
aa = axes('position', [0 0 1 1]);
axis('off');
i = 1;

%--- Date:
tid(i) = date_it(note);
i = i+1;

%--- Plot title:
if ~isempty(title),
  tid(i) = text(0.5, ty, title, 'units', 'normalized', ...
		'FontAngle', 'italic', 'HorizontalAlignment', 'center', ...
		'VerticalAlignment', 'top', 'FontSize', 18, 'FontWeight', 'bold');
  i = i+1;
end

%--- Plot subtitle:
if ~isempty(subtitle),
  tid(i) = text(0.5, ty-0.03, subtitle, 'units', 'normalized', ...
		'FontAngle', 'italic', 'HorizontalAlignment', 'center', ...
		'VerticalAlignment', 'top', 'FontSize', 15, 'FontWeight', 'bold');
  i = i+1;
end

%--- Plot institute:
if ~isempty(institute),
  tid(i) = text(0.05, 0.02, institute, 'units', 'normalized', ...
		'FontAngle', 'italic', 'HorizontalAlignment', 'left', ...
		'VerticalAlignment', 'bottom', 'FontSize', 8, 'FontWeight', 'normal');
  i = i+1;
end

%--- plot information:
if ~isempty(info),
  tid(i) = text(0.95, 0.02, info, 'units', 'normalized', ...
		'FontAngle', 'normal', 'HorizontalAlignment', 'right', ...
		'VerticalAlignment', 'bottom', 'FontSize', 8, 'FontWeight', 'normal');
  i = i+1;
end

axes(old_axes);

if nargout > 0,
  varargout{1} = tid;
end

return;



