Aufgrund einer Wartung wird GitLab am 28.09. zwischen 10:00 und 11:00 Uhr kurzzeitig nicht zur Verfügung stehen. / Due to maintenance, GitLab will be temporarily unavailable on 28.09. between 10:00 and 11:00 am.

Commit dd77a633 authored by Jan-Gerrit Richter's avatar Jan-Gerrit Richter

make waitbar run even if no java environment is available

parent 6098b2ee
......@@ -64,6 +64,7 @@ classdef itaWaitbar < itaHandle
loopNameCell = 0;
loopFactor = 1 % jri: if the loop does not take very long, only update every loopFactor
useJava = 1; % if java is not loaded, don't show the figure but display remaining time
end
properties(Dependent = true, Hidden = false)
......@@ -92,6 +93,11 @@ classdef itaWaitbar < itaHandle
end
end
if usejava('jvm')
this.useJava = 1;
else
this.useJava = 0;
end
this.nNestings = numel(nLoopCount);
......@@ -110,8 +116,12 @@ classdef itaWaitbar < itaHandle
screenSize = get(0, 'screensize');
figPosition = [(screenSize(1,3:4)-figSize)/2 figSize];
if this.useJava == 1
this.figHandle = figure('position', figPosition, 'name', 'itaWaitbar', 'toolbar', 'none', 'menubar', 'none', 'numberTitle', 'off', 'tag', 'itaWaitbar', 'nextPlot', 'new');
if ~isempty(openWaitbars) % if other waitbar is open => put new below old
posOfLastWB = get(openWaitbars(1), 'outerposition');
figPosition = get(this.figHandle, 'outerposition');
......@@ -128,6 +138,7 @@ classdef itaWaitbar < itaHandle
this.txtTimeLeft = uicontrol('style', 'text','units', 'pixels', 'position', [0.1*figSize(1) axSize(2)/2 axSize ], 'string', '', 'parent', this.figHandle, 'HorizontalAlignment', 'center', 'fontsize', 9, 'backgroundcolor', get(this.figHandle, 'color')) ;
this.txtMessage = uicontrol('style', 'text','units', 'pixels', 'position', [0.1*figSize(1) figSize(2)-axSize(2)*1.5 axSize ], 'string', messageStr, 'parent', this.figHandle, 'HorizontalAlignment', 'center', 'fontsize', 11, 'backgroundcolor', get(this.figHandle, 'color')) ;
this.pauseToggle = uicontrol('style', 'toggleButton','units', 'pixels', 'position', [3 3 50 22 ], 'string', 'pause' , 'parent', this.figHandle, 'HorizontalAlignment', 'center', 'fontsize', 11, 'backgroundcolor', [1 1 1] * 0.9, 'callback', {@this.pauseCalculation}) ;
end
this.nLoopsIntern = nLoopCount;
this.updateBar
......@@ -156,6 +167,7 @@ classdef itaWaitbar < itaHandle
end
function updateBar(this, updateMessage)
if this.useJava
% update the bar in the figure
if nargin > 1
set(this.txtMessage, 'string', updateMessage);
......@@ -176,6 +188,7 @@ classdef itaWaitbar < itaHandle
set(this.txtHandle(iNesting), 'string', sprintf('%s %i of %2.0f ', this.loopNameCell{iNesting}, this.iLoopForEveryNesting{iNesting}, this.nLoops(iNesting)));
end
end
% update time left
......@@ -198,8 +211,15 @@ classdef itaWaitbar < itaHandle
end
end
% if no desktop is available, show the remaining time as disp
if ~usejava('desktop')
disp(remainingTimeStr)
end
if this.useJava
set(this.txtTimeLeft, 'string', remainingTimeStr)
drawnow()
end
if this.iLoop == 1
this.startTimeWaitbar = this.startTimeLastLoop;
......@@ -209,8 +229,10 @@ classdef itaWaitbar < itaHandle
end
function close(this) % close itaWaitbar figure
if this.useJava
close(this.figHandle)
end
end
function pauseCalculation(this, self, eventData)
if get(self, 'value') % pause on
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment