/** * Starts the progress displaying. Should be called at the start of the process whose progress is * to be displayed. */ public void start() { step = 0; update = 0; percent = 0; progress(); }
/** Increases the internal step counter. */ public void step() { if (steps > 0) { ++step; percent = step / steps; final int pup = (int) (percent * updates); if (pup > update) { update = pup; progress(); } } }
/** * Increases the internal step counter by the given amount. * * @param n the number of steps to be added to the internal step counter. * @exception IllegalArgumentException if {@code n} is less than {@code 0}. */ public void step(final int n) { if (n < 0) throw new IllegalArgumentException("Number of steps less than 0"); if (steps > 0) { step += n; percent = step / steps; final int pup = (int) (percent * updates); if (pup > update) { update = pup; progress(); } } }
/** * Stops the progress displaying. Should be called at the end of the process whose progress was * displayed. */ public void stop() { percent = 1; progress(); }