[Schmitzm-commits] r2320 - in trunk/schmitzm-core/src/main/java/de/schmitzm: io swing

scm-commit at wald.intevation.org scm-commit at wald.intevation.org
Fri May 31 18:28:40 CEST 2013


Author: mojays
Date: 2013-05-31 18:28:40 +0200 (Fri, 31 May 2013)
New Revision: 2320

Modified:
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/AbstractProgressUpdater.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConsoleProgressBar.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/io/ProgressUpdater.java
   trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ProgressBarUpdater.java
Log:
ProgressUpdater: new methods to determine current progress value/percentage and to increase progress value

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/AbstractProgressUpdater.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/AbstractProgressUpdater.java	2013-05-31 15:55:37 UTC (rev 2319)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/AbstractProgressUpdater.java	2013-05-31 16:28:40 UTC (rev 2320)
@@ -56,6 +56,7 @@
    * Returns the minimum value which represents 0%.
    * @throws UnsupportedOperationException if {@link #initProgress(int, int)} was not yet called
    */
+  @Override
   public int getMinimumValue() {
     if ( !isInitialized() )
       throw new UnsupportedOperationException("ProgressUpdater not yet initialized!");
@@ -66,6 +67,7 @@
    * Returns the maximum value which represents 100%.
    * @throws UnsupportedOperationException if {@link #initProgress(int, int)} was not yet called
    */
+  @Override
   public int getMaximumValue() {
     if ( !isInitialized() )
       throw new UnsupportedOperationException("ProgressUpdater not yet initialized!");
@@ -76,6 +78,7 @@
    * Initializes the progress for (integer) values between 0 and 100.
    * Simply calls {@link #initProgress(int, int) initProgress(0, 100)}
    */
+  @Override
   public void initProgress() {
     initProgress(0,100);
   }
@@ -87,6 +90,7 @@
    * @param maxValue value which represents 100%
    * @throws UnsupportedOperationException if {@code minValue >= maxValue}
    */
+  @Override
   public void initProgress(int minValue, int maxValue) {
     if ( minValue >= maxValue )
       throw new UnsupportedOperationException("Progress minimum value has to be lesser than maximum.");
@@ -101,12 +105,31 @@
    * @param value value between {@link #getMinimumValue()} and {@link #getMaximumValue()}
    * @throws UnsupportedOperationException if {@link #initProgress(int, int)} was not yet called
    */
+  @Override
   public void updateProgress(int value) {
     double perc = calculatePercentage(value);
     updateProgress(perc);
   }
 
   /**
+   * Increments the progress by 1.
+   */
+  @Override
+  public void incProgress() {
+    updateProgress( getProgressValue() + 1 );
+  }
+
+  /**
+   * Returns the current progress value.
+   */
+  @Override
+  public int getProgressValue() {
+    double perc = getProgressPerc();
+    return calculateValue(perc);
+  }
+
+
+  /**
    * Calculates the percentage for a given value.
    */
   protected double calculatePercentage(int value) {
@@ -137,6 +160,7 @@
    * Terminates the progress. Should especially called in case of error
    * during process.
    */
+  @Override
   public void dispose() {
     this.initalized = false;
   }

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConsoleProgressBar.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConsoleProgressBar.java	2013-05-31 15:55:37 UTC (rev 2319)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/ConsoleProgressBar.java	2013-05-31 16:28:40 UTC (rev 2320)
@@ -72,6 +72,14 @@
   }
 
   /**
+   * Returns the current progress percentage.
+   */
+  @Override
+  public double getProgressPerc() {
+    return lastPerc;
+  }
+
+  /**
    * Terminates the progress. Should especially called in case of error
    * during process.
    */

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/io/ProgressUpdater.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/io/ProgressUpdater.java	2013-05-31 15:55:37 UTC (rev 2319)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/io/ProgressUpdater.java	2013-05-31 16:28:40 UTC (rev 2320)
@@ -78,6 +78,21 @@
   public void updateProgress(int value);
 
   /**
+   * Increments the progress by 1.
+   */
+  public void incProgress();
+  
+  /**
+   * Returns the current progress value.
+   */
+  public int getProgressValue();
+
+  /**
+   * Returns the current progress percentage.
+   */
+  public double getProgressPerc();
+
+  /**
    * Terminates the progress. Should especially called in case of error
    * during process.
    */

Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ProgressBarUpdater.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ProgressBarUpdater.java	2013-05-31 15:55:37 UTC (rev 2319)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/swing/ProgressBarUpdater.java	2013-05-31 16:28:40 UTC (rev 2320)
@@ -103,4 +103,22 @@
     int value = calculateValue(perc);
     updateProgress(value);
   }
+
+  /**
+   * Returns the current progress value.
+   */
+  @Override
+  public int getProgressValue() {
+    checkInitialized();
+    return getProgressBar().getValue();
+  }
+  
+  /**
+   * Returns the current progress percentage.
+   */
+  public double getProgressPerc() {
+    int value = getProgressValue();
+    return calculatePercentage(value);
+  }
+  
 }



More information about the Schmitzm-commits mailing list