function varargout = axesFocus(varargin)
% AXESFOCUS MATLAB code for axesFocus.fig
%      AXESFOCUS, by itself, creates a new AXESFOCUS or raises the existing
%      singleton*.
%
%      H = AXESFOCUS returns the handle to a new AXESFOCUS or the handle to
%      the existing singleton*.
%
%      AXESFOCUS('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in AXESFOCUS.M with the given input arguments.
%
%      AXESFOCUS('Property','Value',...) creates a new AXESFOCUS or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before axesFocus_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to axesFocus_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help axesFocus

% Last Modified by GUIDE v2.5 09-Feb-2012 13:46:37

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @axesFocus_OpeningFcn, ...
                   'gui_OutputFcn',  @axesFocus_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end

if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT


% --- Executes just before axesFocus is made visible.
function axesFocus_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to axesFocus (see VARARGIN)

% Choose default command line output for axesFocus
handles.output = hObject;

setappdata(handles.axesFocus,'number',1);

%Listener ueberschreiben
hListener=handle.listener(handles.numbSlider,'ActionEvent',{@continousSlider,handles});

setappdata(handles.numbSlider,'myListener',hListener);

plotNumbers(handles);

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes axesFocus wait for user response (see UIRESUME)
% uiwait(handles.axesFocus);

function plotNumbers(handles)

axes(handles.numberAxes);

cla;

text(0.5,0.5,num2str(getappdata(handles.axesFocus,'number')));


% --- Outputs from this function are returned to the command line.
function varargout = axesFocus_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{1} = handles.output;


% --- Executes on slider movement.
function numbSlider_Callback(hObject, eventdata, handles)
% hObject    handle to numbSlider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'Value') returns position of slider
%        get(hObject,'Min') and get(hObject,'Max') to determine range of slider


% --- Executes during object creation, after setting all properties.
function numbSlider_CreateFcn(hObject, eventdata, handles)
% hObject    handle to numbSlider (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: slider controls usually have a light gray background.
if isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor',[.9 .9 .9]);
end



function numEdit_Callback(hObject, eventdata, handles)
% hObject    handle to numEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of numEdit as text
%        str2double(get(hObject,'String')) returns contents of numEdit as a double
val =  str2double(get(handles.numEdit,'String'));

setappdata(handles.axesFocus,'number',val);

plotNumbers(handles);

% --- Executes during object creation, after setting all properties.
function numEdit_CreateFcn(hObject, eventdata, handles)
% hObject    handle to numEdit (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called

% Hint: edit controls usually have a white background on Windows.
%       See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
    set(hObject,'BackgroundColor','white');
end

function continousSlider(~, event_obj,handles)

slidval=get(handles.numbSlider,'Value');

setappdata(handles.axesFocus,'number',slidval);

plotNumbers(handles);
