Package

net.sf.ij_plugins.ui

progress

Permalink

package progress

Package progress contains tools for reporting progress of computations. Classes can report progress extending trait net.sf.ij_plugins.ui.progress.ProgressReporter. Progress can be observed extendfing trait net.sf.ij_plugins.ui.progress.ProgressListener.

Example usage:

class CounterWithProgress(marker: Char) extends ProgressReporter {
  def count(max: Int) {
    val progressIncrement = Math.max(max / 10, 1)

    println("Counting " + max + " '" + marker + "'.")

    for (i <- 1 to max) {
      print(marker)
      if (i % progressIncrement == 0) notifyProgressListeners(i, max)
    }

    println("\nCounting done.")
  }
}

object ProgressReporterExample extends App {
  // Create counter
  val counter = new CounterWithProgress('+')

  // Add progress listener
  counter.addProgressListener(e => println(f"\nProgress notification: ${e.progressPercent}%3.0f%%"))

  // Count
  counter.count(100)
}
Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. progress
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. class ProgressEvent extends AnyRef

    Permalink

    Event used to notify listeners about current value of progress.

    Event used to notify listeners about current value of progress. Allowed progress values are between 0.0 and 1.0. 0.31 means 31% progress.

  2. trait ProgressListener extends AnyRef

    Permalink

    Listens to net.sf.ij_plugins.ui.progress.ProgressEvent generated by a net.sf.ij_plugins.ui.progress.ProgressReporter.

  3. trait ProgressReporter extends AnyRef

    Permalink

    Reports progress of an operation to its listeners.

    Reports progress of an operation to its listeners. Progress starts at 0.0 and finishes at 1.0, so 0.3 means 30% progress.

    Example usage:

    class CounterWithProgress(marker: Char) extends ProgressReporter {
      def count(max: Int) {
        val progressIncrement = Math.max(max / 10, 1)
    
        println("Counting " + max + " '" + marker + "'.")
    
        for (i <- 1 to max) {
          print(marker)
          if (i % progressIncrement == 0) notifyProgressListeners(i, max)
        }
    
        println("\nCounting done.")
      }
    }
    
    object ProgressReporterExample extends App {
      // Create counter
      val counter = new CounterWithProgress('+')
    
      // Add progress listener
      counter.addProgressListener(e => println(f"\nProgress notification: ${e.progressPercent}%3.0f%%"))
    
      // Count
      counter.count(100)
    }

Inherited from AnyRef

Inherited from Any

Ungrouped