edu.mit.jmwe.util
Class ProgressBar

java.lang.Object
  extended by edu.mit.jmwe.util.ProgressBar
All Implemented Interfaces:
IProgressBar

public class ProgressBar
extends Object
implements IProgressBar

Default implementation of IProgressBar.

Since:
jMWE 1.0.0
Version:
$Id: ProgressBar.java 561 2011-05-05 19:26:12Z markaf $
Author:
M.A. Finlayson

Field Summary
static int DEFAULT_TICKS
          Default number of ticks for a progress bar.
 
Constructor Summary
ProgressBar(int expected)
          Creates a progress bar that expects the specified number of increments.
ProgressBar(int expected, int ticks)
          Creates a progress bar that expects the specified number of increments, and reports progress across a bar the specified number of ticks wide.
ProgressBar(int expected, int ticks, boolean printDate)
          Constructs a new progress bar that has an expected number of observations compressed into a specified number of ticks, and optionally prints the time and memory delta between instantiation and calling the finish() method.
 
Method Summary
 void finish()
          Stops the progress bar and prints the total time that the progress bar ran.
 int getCount()
          Returns the current state of the progress bar, that is, the number of units of progress that have been reported to it.
 Date getEndTime()
          Returns the date and time on which this progress bar was finished.
 int getExpected()
          Returns the expected number of units of progress.
 int getExpectedTicks()
          Returns the expected number of ticks.
 Date getStartTime()
          Returns the date and time on which this progress bar was started.
 double getStepSize()
          Returns the number of units of progress that are represented by one tick.
 int getTickCount()
          Returns the number of current progress bar ticks that have been used.
 void increment()
          Increments the progress bar by 1.
 void increment(int i)
          Increments the progress bar by a given amount.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_TICKS

public static final int DEFAULT_TICKS
Default number of ticks for a progress bar.

Since:
jMWE 1.0.0
See Also:
Constant Field Values
Constructor Detail

ProgressBar

public ProgressBar(int expected)
Creates a progress bar that expects the specified number of increments.

Parameters:
expected - the number of increments that are expected
Throws:
IllegalArgumentException - if the number of expected increments is not positive.
Since:
jMWE 1.0.0

ProgressBar

public ProgressBar(int expected,
                   int ticks)
Creates a progress bar that expects the specified number of increments, and reports progress across a bar the specified number of ticks wide.

Parameters:
expected - the number of increments that are expected
ticks - the length of the progress bar, in ticks
Throws:
IllegalArgumentException - if the number of expected increments or the number of printed ticks is not positive.
Since:
jMWE 1.0.0

ProgressBar

public ProgressBar(int expected,
                   int ticks,
                   boolean printDate)
Constructs a new progress bar that has an expected number of observations compressed into a specified number of ticks, and optionally prints the time and memory delta between instantiation and calling the finish() method.

Parameters:
expected - the number of increments that are expected
ticks - the length of the progress bar, in ticks
printDate - if true, the progress bar will print the start and end date
Throws:
IllegalArgumentException - if the number of expected increments or the number of printed ticks is not positive.
Since:
jMWE 1.0.0
Method Detail

increment

public void increment()
Description copied from interface: IProgressBar
Increments the progress bar by 1.

Specified by:
increment in interface IProgressBar

increment

public void increment(int i)
Description copied from interface: IProgressBar
Increments the progress bar by a given amount.

Specified by:
increment in interface IProgressBar
Parameters:
i - amount by which the progress bar will be incremented

finish

public void finish()
Description copied from interface: IProgressBar
Stops the progress bar and prints the total time that the progress bar ran.

Specified by:
finish in interface IProgressBar

getExpected

public int getExpected()
Description copied from interface: IProgressBar
Returns the expected number of units of progress.

Specified by:
getExpected in interface IProgressBar
Returns:
the expected number of units of progress.

getExpectedTicks

public int getExpectedTicks()
Description copied from interface: IProgressBar
Returns the expected number of ticks.

Specified by:
getExpectedTicks in interface IProgressBar
Returns:
the expected number of ticks.

getStartTime

public Date getStartTime()
Description copied from interface: IProgressBar
Returns the date and time on which this progress bar was started.

Specified by:
getStartTime in interface IProgressBar
Returns:
the date and time on which this progress bar was started.

getEndTime

public Date getEndTime()
Description copied from interface: IProgressBar
Returns the date and time on which this progress bar was finished. If the progress bar is not yet finished, will return null.

Specified by:
getEndTime in interface IProgressBar
Returns:
the date and time on which this progress bar was finished, or null if not yet finished.

getCount

public int getCount()
Description copied from interface: IProgressBar
Returns the current state of the progress bar, that is, the number of units of progress that have been reported to it.

Specified by:
getCount in interface IProgressBar
Returns:
the number of units of progress so far reported

getTickCount

public int getTickCount()
Description copied from interface: IProgressBar
Returns the number of current progress bar ticks that have been used.

Specified by:
getTickCount in interface IProgressBar
Returns:
the number of current progress bar ticks that have been used.

getStepSize

public double getStepSize()
Description copied from interface: IProgressBar
Returns the number of units of progress that are represented by one tick.

Specified by:
getStepSize in interface IProgressBar
Returns:
the number of units of progress that are represented by one tick.


Copyright © 2011 Massachusetts Institute of Technology. All Rights Reserved.