jcolibri.util
Class ProgressController

java.lang.Object
  extended by jcolibri.util.ProgressController

public class ProgressController
extends java.lang.Object

This class allows methods to indicate their progress in a long task. This is a modification of the Observer pattern where the notifier of the tasks keeps a list of observers and notifies them its progress. Here we centralize the managing of the observers in this class simplifing the code of the notifiers.
If a method wants to notify its progress it only has to call to:

On the other side observers must implement the ProgressListener interface and register to recieve the events from a concrete class or all the classes.

Version:
1.0
Author:
Juan A. Recio-Garcia
See Also:
ProgressController

Field Summary
static int UNKNOWN_STEPS
          Defines unknown number of steps for a progress
 
Constructor Summary
ProgressController()
           
 
Method Summary
static void clear()
          Removes all listeners
static void deregister(ProgressListener pl)
          Deregisters a listener to recieve the progress of all classes.
static void deregister(ProgressListener pl, java.lang.Class c)
          Deregisters a listener to recieve the progress of a concrete class.
static void finish(java.lang.Class c)
          Finishes the progress of a task.
static void init(java.lang.Class c, java.lang.String info, int numberOfSteps)
          Notifies to all the listeners of a class that the progress is begining.
static void register(ProgressListener pl)
          Registers a listener to recieve the progress of all classes.
static void register(ProgressListener pl, java.lang.Class c)
          Registers a listener to recieve the progress of a concrete class.
static void step(java.lang.Class c)
          Notifies a new step in the task for a concrete class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNKNOWN_STEPS

public static final int UNKNOWN_STEPS
Defines unknown number of steps for a progress

See Also:
Constant Field Values
Constructor Detail

ProgressController

public ProgressController()
Method Detail

clear

public static void clear()
Removes all listeners


register

public static void register(ProgressListener pl,
                            java.lang.Class c)
Registers a listener to recieve the progress of a concrete class.


register

public static void register(ProgressListener pl)
Registers a listener to recieve the progress of all classes.


deregister

public static void deregister(ProgressListener pl,
                              java.lang.Class c)
Deregisters a listener to recieve the progress of a concrete class.


deregister

public static void deregister(ProgressListener pl)
Deregisters a listener to recieve the progress of all classes.


init

public static void init(java.lang.Class c,
                        java.lang.String info,
                        int numberOfSteps)
Notifies to all the listeners of a class that the progress is begining.

Parameters:
c - Class that notifies the progress.
info - Some info about the progress.
numberOfSteps - Number of steps of the task. If unknown it must be -1.

step

public static void step(java.lang.Class c)
Notifies a new step in the task for a concrete class.


finish

public static void finish(java.lang.Class c)
Finishes the progress of a task.


GAIA - Group for Artificial Intelligence Applications
http://gaia.fdi.ucm.es