ProgressEvent updateProgress ( double val , long now ) { if ( val < 0 || val > 1 ) { throw new IllegalArgumentException ( "Value out of range [0, 1]: " + val ) ; } if ( val <= progress . getProgress ( ) ) { reset ( start ) ; } double pD = val - progress . getProgress ( ) ; long tD = now - tstamp ; if ( step > 0 ) { step = step * 0.3 + ( tD / pD ) * 0.7 ; } else { step = ( tD / pD ) ; } double etcMs = step * ( 1 - val ) ; progress = new ProgressEvent ( val , new Date ( now + ( long ) Math . round ( etcMs ) ) ) ; tstamp = now ; return progress ; }
allows setting the current time for testing