Class TLcdStatusEvent.Progress<T>

java.lang.Object
com.luciad.util.TLcdStatusEvent.Progress<T>
All Implemented Interfaces:
AutoCloseable
Enclosing class:
TLcdStatusEvent<T>

public static final class TLcdStatusEvent.Progress<T> extends Object implements AutoCloseable
Helper object for sending out status events for a particular task.

A few typical use-cases of this class are listed below:

Reporting progress when the exact progress is known:


 try (Progress task = TLcdStatusEvent.startProgress(...)) {
   // perform task calculations
   ...
   // whenever there is progress:
   task.progress(progressAmount);
   // more task calculations
   ...
 }
 

Reporting progress when the progress is undetermined:


 try (Progress task = TLcdStatusEvent.startIndeterminateProgress(...)) {
   // perform task calculations
   ...
   // whenever you want to update the progress message
   task.indeterminateProgress(updatedMessage);
   // more task calculations
   ...
 }
 

Switching from undetermined to known progress:

An example is reporting progress when downloading a file: while the connection is being established, you have no idea how long the actual download will take. As soon as you can determine the file size, you can start reporting known progress by comparing the number of downloaded bytes to the file size.


 try (Progress task = TLcdStatusEvent.startIndeterminateProgress(...)) {
   // establishing connection
   ...
   // once the file size is known, exact progress reports can be sent
   while(downloading){
     //download some data
     ...
     //update the progress
     task.progress(progressAmount);
   }
 }
 
Since:
2016.1
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Calls end()
    void
    end()
    Creates and dispatches an end status event without a specific message.
    void
    end(String aMessage)
    Creates and dispatches an end status event with the given message.
    void
    Creates and dispatches an indeterminate progress status event with the previously used message.
    void
    Creates and dispatches an indeterminate progress status event with the given message.
    void
    progress(double aProgress)
    Creates and dispatches a progress status event with the given progress and the previously used message.
    void
    progress(double aProgress, String aMessage)
    Creates and dispatches a progress status event with the given progress and message.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • progress

      public void progress(double aProgress)
      Creates and dispatches a progress status event with the given progress and the previously used message.
      Parameters:
      aProgress - the progress to report. A value between 0 and 1.
    • progress

      public void progress(double aProgress, String aMessage)
      Creates and dispatches a progress status event with the given progress and message.
      Parameters:
      aProgress - the progress to report. A value between 0 and 1.
      aMessage - the message to report
    • indeterminateProgress

      public void indeterminateProgress(String aMessage)
      Creates and dispatches an indeterminate progress status event with the given message.
      Parameters:
      aMessage - the message to report
    • indeterminateProgress

      public void indeterminateProgress()
      Creates and dispatches an indeterminate progress status event with the previously used message.
    • end

      public void end(String aMessage)
      Creates and dispatches an end status event with the given message. This method can be called multiple times, but subsequent invocations have no effect.
      Parameters:
      aMessage - the message to report
    • end

      public void end()
      Creates and dispatches an end status event without a specific message. This method can be called multiple times, but subsequent invocations have no effect.
    • close

      public void close()
      Calls end()
      Specified by:
      close in interface AutoCloseable