com.ca.commons.cbutil
Class CBpbar

java.lang.Object
  |
  +--com.ca.commons.cbutil.CBpbar

public class CBpbar
extends java.lang.Object

A component so cunning you could stick a tail on it and call it a weasel.

The basic idea is to create an easy interface to a progress bar, while navigating a tree. An object of CBpbar class handles the pbar, expecting calls from a separate thread, and enables the programmer to update the pbar with a minimum of fuss. The class is heavily optimised towards tree navigation; it will guess completion depending on what part of a (partially navigated) tree it is in, as well as keeping track of total objects written for label display.


Constructor Summary
CBpbar(java.awt.Component C, java.lang.String uberTitle, java.lang.String notePrefix)
          Constructor for progress bar.
 
Method Summary
 void close()
          Closes the progress bar.
 void inc()
          increments the displayed count by one, and (depending on the depth we're at, and the fanout set by @push) changes the percentage fill of the bar.
 boolean isCanceled()
          returns whether the user has hit the 'cancel' button on the progress bar.
 void pop()
          pop tells the progress bar that the tree process we are tracking has gone up a level.
 void push(int fanout)
          push tells the progress bar that the process we are tracking has gone down a level, and that this level has a certain number of entries (i.e. branches).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CBpbar

public CBpbar(java.awt.Component C,
              java.lang.String uberTitle,
              java.lang.String notePrefix)
Constructor for progress bar.

Parameters:
C - a graphical 'hook' so the Progress Monitior knows where to display itself - usually a Swing Component of some sort...
uberTitle - a general desciption that appears in the box
notePrefix - the active description, that prefixes the changing 'count' value that the progress bar reports.
Method Detail

inc

public void inc()
increments the displayed count by one, and (depending on the depth we're at, and the fanout set by @push) changes the percentage fill of the bar. Note that while every call of this makes a request to SwingUtilities.invokeLater(), not every call actually results in a visible update (Swing queues these request in order to avoid starving worker threads).


pop

public void pop()
pop tells the progress bar that the tree process we are tracking has gone up a level.


push

public void push(int fanout)
push tells the progress bar that the process we are tracking has gone down a level, and that this level has a certain number of entries (i.e. branches). The progress bar uses this info for estimating (based on the assumption of a balanced tree) the proportion of the tree processed.

Parameters:
fanout - the number of branches at this level.

close

public void close()
Closes the progress bar.


isCanceled

public boolean isCanceled()
returns whether the user has hit the 'cancel' button on the progress bar.

Returns:
the canceled status of the bar.