% GUImakemapmenu
% function for the MODIS GUI
% Copyright by Jasmine S Nahorniak, Oregon State University. 
% Feb 29 2000

function GUImakel2mapmenu(mapfig)

% ********************************************************
% menu contents

GUIdefaults;

% ********************************************************
% make menus

% ****************
% ****************
% COLORS

h0=uimenu('Parent',mapfig,'Callback','','Label','Colors');

% ****************
% colormap

choices=guicolormap;

h1=uimenu('Parent',h0,'Callback','','Label','Colormap');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  colmap=cat(1,choicecell{:});   % convert cell to string
  if (colmap(1)=='n' & colmap(2)=='o' & colmap(3)=='n'),  % is 'none'
    uimenu('Parent',h1, ...
	'Callback',['mycolmap=get(gcbf,''Colormap''); nmask=get(gcbf,''UserData''); mycolmap(nmask+1:end,:)=NaN; colormap(mycolmap); clear mycolmap nmask;'], ...
	'Label',colmap)
  else
     uimenu('Parent',h1, ...
	'Callback',['mycolmap=get(gcbf,''Colormap''); colsize=size(mycolmap); nmask=get(gcbf,''UserData''); mycolmap(nmask+1:colsize(1),:)=' colmap '(colsize(1)-nmask); colormap(mycolmap); clear mycolmap colsize nmask;'], ...
	'Label',colmap)
  end
end

% ****************
% background color

choices=guibackgroundcolors;

colns=GUIcol2num(choices);

h1=uimenu('Parent',h0,'Callback','','Label','Background color');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  col=cat(1,choicecell{:});   % convert cell to string
  numcol=['[' num2str(colns(i,:)) ']'];
  uimenu('Parent',h1, ...
	'Callback',['set(gcbf,''Color'',' numcol '); set(findobj(gcbf,''Tag'',''Mapaxes''),''Color'',' numcol ', ''XColor'',' numcol ',''YColor'',' numcol ',''ZColor'',' numcol ');'], ...
	'Label',col)
  end

% ****************
% axis/label color

choices=guiaxiscolors;

colns=GUIcol2num(choices);

h1=uimenu('Parent',h0,'Callback','','Label','Axis/label color');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  col=cat(1,choicecell{:});   % convert cell to string
  numcol=['[' num2str(colns(i,:)) ']'];
  if col(1:3)=='non',  % is 'none'
     uimenu('Parent',h1, ...
	'Callback',['set(findobj(gcbf,''Tag'',''Mapaxes''),''XColor'',get(gcbf,''Color''),''YColor'',get(gcbf,''Color'')); xlabel(''''); ylabel('''');'], ...
	'Label',col)
  else
     uimenu('Parent',h1, ...
	'Callback',['set(findobj(gcbf,''Tag'',''Mapaxes''),''XColor'',' numcol ',''YColor'',' numcol '); set(get(gca,''Title''),''Color'',' numcol '); xlabel(''Longitude'',''Color'',' numcol '); ylabel(''Latitude'',''Color'',' numcol '); set(findobj(gcbf,''Tag'',''Colorbar''),''XColor'',' numcol ',''YColor'',' numcol ');'], ...
	'Label',col) 
  end
end


% ****************
% land color

choices=guilandcolors;

landcolns=GUIcol2num(guilandcolors);

h1=uimenu('Parent',h0,'Callback','','Label','Land color');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  landcol=cat(1,choicecell{:});   % convert cell to string
  uimenu('Parent',h1, ...
	'Callback',['mycolmap=get(gcbf,''Colormap''); nmask=get(gcbf,''UserData''); if nmask>0, mycolmap(1,:)=[' num2str(landcolns(i,:)) ']; colormap(mycolmap); end; clear mycolmap nmask;'], ...
	'Label',landcol)
  end

% ****************
% mask color

choices=guimaskcolors;

maskcolns=GUIcol2num(guimaskcolors);

h1=uimenu('Parent',h0,'Callback','','Label','Mask color');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  maskcol=cat(1,choicecell{:});   % convert cell to string
  uimenu('Parent',h1, ...
	'Callback',['mycolmap=get(gcbf,''Colormap''); nmask=get(gcbf,''UserData''); if nmask==1, mycolmap(1,:)=[' num2str(maskcolns(i,:)) ']; elseif nmask==2, mycolmap(2,:)=[' num2str(maskcolns(i,:)) ']; end; colormap(mycolmap); clear nmask mycolmap;'], ...
	'Label',maskcol)
  end

% ****************
% coastline

choices=guicoastline;

colns=GUIcol2num(choices);

h1=uimenu('Parent',h0,'Callback','','Label','Coastline');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  coastline=cat(1,choicecell{:});   % convert cell to string
  if coastline(1:3)~='non',
    uimenu('Parent',h1, ...
	'Callback',['set(findobj(gcbf,''Tag'',''Coastline''),''Color'', [' num2str(colns(i,:)) '],''Visible'',''on'');'], ...
	'Label',coastline)
  else
    uimenu('Parent',h1, ...
	'Callback',['set(findobj(gcbf,''Tag'',''Coastline''),''Visible'',''off'');'], ...
	'Label',coastline)
  end
end


% ****************
% colorbar

choices=guicolorbar;

h1=uimenu('Parent',mapfig,'Callback','','Label','Colorbar');

for i=1:length(choices(:,1));
  choicecell=choices(i,:);
  colbar=cat(1,choicecell{:});   % convert cell to string
  if colbar(1:3)=='ver',
    uimenu('Parent',h1, ...
	'Callback','delete(findobj(gcbf,''Tag'',''Colorbar'')); hcb=colorbar(''vert''); pause(0.05); set(hcb,''Tag'',''Colorbar'',''YTickLabelMode'',''auto''); clear hcb;', ...
	'Label',colbar)
  elseif colbar(1:3)=='hor',
    uimenu('Parent',h1, ...
	'Callback','delete(findobj(gcbf,''Tag'',''Colorbar'')); hcb=colorbar(''horiz''); pause(0.05); set(hcb,''Tag'',''Colorbar'',''XTickLabelMode'',''auto''); clear hcb;', ...
	'Label',colbar)
  elseif colbar(1:3)=='off',
    uimenu('Parent',h1, ...
	'Callback','delete(findobj(gcbf,''Tag'',''Colorbar''))', ...
	'Label',colbar)
  end
end



% ****************
% grid

choices=guigrid;

h1=uimenu('Parent',mapfig,'Callback','','Label','Grid');

for i=1:length(choices(:,1)),
  choicecell=choices(i,:);
  gridchoice=cat(1,choicecell{:});   % convert cell to string
  uimenu('Parent',h1, ...
	'Callback',['grid ' gridchoice ';'], ...
	'Label',gridchoice)
end

% ****************
% output figure

choices=guioutfig;

h1=uimenu('Parent',mapfig,'Callback','','Label','Save Figure');

for i=1:length(choices(:,1)),
  choicecell=choices(i,:);
  outputchoice=cat(1,choicecell{:});   % convert cell to string
  uimenu('Parent',h1, ...
	'Callback',['GUIoutputfig(''' outputchoice ''')'], ...
	'Label',outputchoice)
end

% ***************
