
fig=createmadfig('timedom'); 
fig=createmadloadmenu(fig);

FrameBackColour=[0.75 0.75 0.75];

% menus
units = uimenu('Parent',fig,'Label','Units','Tag','&Editunits');
  uimenu('Parent',units,'Callback','timedom unitsChanged','Label','Milliseconds','Tag','units');
  uimenu('Parent',units,'Callback','timedom unitsChanged','Checked','on','Label','Samples','Tag','units');
fig=createmadmenus(fig);

% axes
ud.signalAxes = axes('Parent',fig, ...
	'Box','on', ...
	'ButtonDownFcn','timedom playSignal', ...
	'DrawMode','fast', ...
	'NextPlot','replacechildren', ...
	'Position',[0.1 0.77 0.55 0.18], ...
   'XLimMode','manual', ...
   'YLim',[-1.1 1.1]);
   
ud.sigline = line('Parent',ud.signalAxes,...
   'ButtonDownFcn','timedom playSignal','XData',[],'YData',[],'Color','blue');
ud.winline= line('Parent',ud.signalAxes,...
   'ButtonDownFcn','','XData',[],'YData',[],'Color','red');
ylabel('Signal')

ud.energyAxes = axes('Parent',fig, ...
	'Box','on', ...
	'NextPlot','replacechildren', ...
	'Position',[0.1 0.49 0.55 0.18]);
ud.esline = line('Parent',ud.energyAxes,'XData',[],'YData',[],'Color','blue');
ud.emline = line('Parent',ud.energyAxes,'XData',[],'YData',[],'Color','red');
ud.elline = line('Parent',ud.energyAxes,'XData',[],'YData',[],'Color','green');
ylabel('Energy');

ud.magnitudeAxes = axes('Parent',fig, ...
	'Box','on', ...
	'NextPlot','replacechildren', ...
	'Position',[0.1 0.27 0.55 0.18]);  
ud.asline = line('Parent',ud.magnitudeAxes,'XData',[],'YData',[],'Color','blue');
ud.amline = line('Parent',ud.magnitudeAxes,'XData',[],'YData',[],'Color','red');
ud.alline = line('Parent',ud.magnitudeAxes,'XData',[],'YData',[],'Color','green');
ylabel('Average Magnitude');

ud.zcAxes = axes('Parent',fig, ...
	'Box','on', ...
	'NextPlot','replacechildren', ...
	'Position',[0.1 0.05 0.55 0.18]);
ud.zsline = line('Parent',ud.zcAxes,'XData',[],'YData',[],'Color','blue');
ud.zmline = line('Parent',ud.zcAxes,'XData',[],'YData',[],'Color','red');
ud.zlline = line('Parent',ud.zcAxes,'XData',[],'YData',[],'Color','green');
ylabel('Zero Crossings');


% All uicontrols that follow are contained within the window frame
%FRAME
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.68 0.27 0.30 0.71], ...
	'String','WindowFrame', 'Style','frame', ...
	'Tag','WindowFrame');

% TEXT & POPUP FOR WINDOW TYPE
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.78 0.94 0.1 0.03], ...
	'String','Window', 'Style','text', ...
	'Tag','WindowLabel');

ud.windowtype=uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, 'Callback','timedom newWindow', ...
	'ListboxTop',0, 'Position',[0.73 0.88 0.22 0.05], ...
	'Style','popupmenu', 'Tag','WindowPopup', ...
	'Value',1,'String','init');

% 3 RADIO BUTTONS  
  
uicontrol('Parent',fig, ...
  'Callback','timedom radio', 'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.7 0.83 0.27 0.03], ...
	'String','1 size, 3 shifts', ...
	'Style','radiobutton', 'Tag','1size3shift');
uicontrol('Parent',fig, ...
  'Callback','timedom radio', 'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.7 0.79 0.27 0.03], ...
	'String','3 sizes, same shift', ...
	'Style','radiobutton', 'Tag','3size1shift');
uicontrol('Parent',fig, ...
  'Callback','timedom radio',	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.7 0.75 0.27 0.03], ...
	'String','3 sizes, different shifts', ...
	'Style','radiobutton', 'Tag','3size3shift');
  
% EDIT BOXES LEFT COLUMN  
uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newSmallSize', ...
	'ListboxTop',0, 'Position',[0.77 0.65 0.06 0.05], ...
	'String','128', 'Style','edit', ...
	'Tag','SmallWindow');
uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newMediumSize', ...
	'ListboxTop',0, 'Position',[0.77 0.6 0.06 0.05], ...
	'String','256', 'Style','edit', ...
	'Tag','MediumWindow');
uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newLargeSize', ...
	'ListboxTop',0, 'Position',[0.77 0.55 0.06 0.05], ...
	'String','512', 'Style','edit', ...
	'Tag','LargeWindow');
% RIGHT COLUMN
  uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newLargeShift', ...
	'ListboxTop',0, 'Position',[0.84 0.55 0.06 0.05], ...
	'String','100', 'Style','edit', ...
	'Tag','LargeShift');
uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newMediumShift', ...
	'ListboxTop',0, 'Position',[0.84 0.6 0.06 0.05], ...
	'String','100', 'Style','edit', ...
	'Tag','MediumShift');
uicontrol('Parent',fig, ...
	'BackgroundColor',[1 1 1], 'Callback','timedom newSmallShift', ...
	'ListboxTop',0, 'Position',[0.84 0.65 0.06 0.05], ...
	'String','100', 'Style','edit', ...
	'Tag','SmallShift');
  
% TEXT  
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, 'ForegroundColor',[0 0 1], ...
	'HorizontalAlignment','right', ...
	'ListboxTop',0, 'Position',[0.69 0.64 0.08 0.05], ...
	'String','Small', 'Style','text', ...
	'Tag','SmallText');
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, 'ForegroundColor',[1 0 0], ...
	'HorizontalAlignment','right', ...
	'ListboxTop',0, 'Position',[0.69 0.59 0.08 0.05], ...
	'String','Medium', 'Style','text', ...
	'Tag','MediumText');
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, 'ForegroundColor',[0 1 0], ...
	'HorizontalAlignment','right', ...
	'ListboxTop',0, 'Position',[0.69 0.54 0.08 0.05], ...
	'String','Large', 'Style','text', ...
	'Tag','LargeText');
  uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.77 0.71 0.05 0.03], ...
	'String','Size', 'Style','text', ...
	'Tag','SizeLabel');
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.84 0.71 0.05 0.03], ...
	'String','Shift', 'Style','text', ...
	'Tag','ShiftLabel');

% CHECKBOXES
uicontrol('Parent',fig, ...
  'Callback','timedom animateclick',...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, 'Position',[0.7 0.35 0.11 0.04], ...
	'String','Animate', 'Style','checkbox', ...
	'Tag','AnimateCheckBox');
uicontrol('Parent',fig, ...
  'Callback','timedom redraw',...
	'ListboxTop',0, 'Position',[0.82 0.35 0.07 0.04], ...
	'String','Run', ...
  'Tag','AnimateButton');
uicontrol('Parent',fig, ...
   'Callback','timedom pauseon',...
	'ListboxTop',0, 'Position',[0.9 0.35 0.07 0.04], ...
	'String','Pause', ...
   'Tag','PauseButton');
uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ForegroundColor',[0 0 0], ...
	'HorizontalAlignment','left', ...
	'ListboxTop',0, 'Position',[0.73 0.28 0.25 0.05], ...
	'String','Step time (sec):', ...
	'Style','text', ...
	'Tag','PauseText');
uicontrol('Parent',fig,...
	'BackgroundColor',[1 1 1], ...
	'ListboxTop',0, ...
	'Position',[0.88 0.29 0.05 0.05], ...
	'String','0', ...
	'Style','edit', ...
   'Tag','AnimatePause');

   % SHOW CHECKBOXES
   uicontrol('Parent',fig, ...
	'BackgroundColor',FrameBackColour, ...
	'ListboxTop',0, ...
	'Position',[0.69 0.49 0.1 0.03], ...
	'String','Show:', ...
	'Style','text', ...
  'Tag','ShowLabel');
uicontrol('Parent',fig, ...
   'Callback','timedom redraw',...
   'BackgroundColor',FrameBackColour, ...
   'ForegroundColor',[0 0 1], ...
   'ListboxTop',0, ...
	'Position',[0.77 0.48 0.08 0.04], ...
	'String','Small', ...
	'Style','checkbox', ...
   'Value',1,...
	'Tag','SmallCheckBox');
uicontrol('Parent',fig, ...
   'Callback','timedom redraw',...
   'BackgroundColor',FrameBackColour, ...
	'ForegroundColor',[1 0 0], ...
	'ListboxTop',0, ...
	'Position',[0.77 0.44 0.1 0.04], ...
	'String','Medium', ...
   'Style','checkbox', ...
   'Value',1,...
	'Tag','MediumCheckBox');
uicontrol('Parent',fig, ...
   'Callback','timedom redraw',...
   'BackgroundColor',FrameBackColour, ...
	'ForegroundColor',[0 1 0], ...
	'ListboxTop',0, ...
	'Position',[0.77 0.40 0.08 0.04], ...
	'String','Large', ...
	'Style','checkbox', ...
   'Tag','LargeCheckBox',...
   'Value',1);

set(fig,'UserData',ud);
