sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 02/03: Rename `ImageProcessor.getStatistics(…)` as `valueOfStatistics(…)`. The intent is to make a clearer separation with property getter methods. It also reduces the impression that this method returns a pre-existing value (the computation can be expansive).
Date Fri, 21 Aug 2020 18:05:20 GMT
This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit 563cba79ab1135ff936a849f1bd50d9fef6bbc34
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Fri Aug 21 16:15:34 2020 +0200

    Rename `ImageProcessor.getStatistics(…)` as `valueOfStatistics(…)`.
    The intent is to make a clearer separation with property getter methods.
    It also reduces the impression that this method returns a pre-existing value
    (the computation can be expansive).
---
 .../src/main/java/org/apache/sis/gui/coverage/RenderingData.java  | 2 +-
 .../src/main/java/org/apache/sis/internal/gui/ImageConverter.java | 2 +-
 .../src/main/java/org/apache/sis/image/ImageProcessor.java        | 8 ++++----
 .../src/main/java/org/apache/sis/image/RecoloredImage.java        | 2 +-
 .../src/main/java/org/apache/sis/image/Visualization.java         | 2 +-
 .../test/java/org/apache/sis/image/StatisticsCalculatorTest.java  | 6 +++---
 6 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java
b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java
index b7b2f2a..111a22d 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/gui/coverage/RenderingData.java
@@ -247,7 +247,7 @@ final class RenderingData implements Cloneable {
         if (selectedDerivative != Stretching.NONE) {
             final Map<String,Object> modifiers = new HashMap<>(4);
             if (statistics == null) {
-                statistics = processor.getStatistics(image, null);
+                statistics = processor.valueOfStatistics(image, null);
             }
             modifiers.put("statistics", statistics);
             if (selectedDerivative == Stretching.AUTOMATIC) {
diff --git a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ImageConverter.java
b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ImageConverter.java
index 24ce727..86a58d6 100644
--- a/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ImageConverter.java
+++ b/application/sis-javafx/src/main/java/org/apache/sis/internal/gui/ImageConverter.java
@@ -126,7 +126,7 @@ final class ImageConverter extends Task<Statistics[]> {
         toCanvas.translate(-bounds.x, -bounds.y);
 
         final ImageProcessor processor  = new ImageProcessor();
-        final Statistics[]   statistics = processor.getStatistics(source, bounds);
+        final Statistics[]   statistics = processor.valueOfStatistics(source, bounds);
         final RenderedImage  image      = processor.stretchColorRamp(source, JDK9.mapOf("multStdDev",
3, "statistics", statistics));
         final RenderedImage  mask       = getMask(processor);
         final BufferedImage  buffer     = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/ImageProcessor.java b/core/sis-feature/src/main/java/org/apache/sis/image/ImageProcessor.java
index df2d310..ac69507 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/ImageProcessor.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/ImageProcessor.java
@@ -597,7 +597,7 @@ public class ImageProcessor implements Cloneable {
      * @see #statistics(RenderedImage, Shape)
      * @see StatisticsCalculator#STATISTICS_KEY
      */
-    public Statistics[] getStatistics(final RenderedImage source, final Shape areaOfInterest)
{
+    public Statistics[] valueOfStatistics(final RenderedImage source, final Shape areaOfInterest)
{
         ArgumentChecks.ensureNonNull("source", source);
         if (areaOfInterest == null) {
             final Object property = source.getProperty(StatisticsCalculator.STATISTICS_KEY);
@@ -619,7 +619,7 @@ public class ImageProcessor implements Cloneable {
          */
         final AnnotatedImage calculator = new StatisticsCalculator(source, areaOfInterest,
parallel, failOnException);
         final Object property = calculator.getProperty(StatisticsCalculator.STATISTICS_KEY);
-        calculator.logAndClearError(ImageProcessor.class, "getStatistics", errorListener);
+        calculator.logAndClearError(ImageProcessor.class, "valueOfStatistics", errorListener);
         return (Statistics[]) property;
     }
 
@@ -649,7 +649,7 @@ public class ImageProcessor implements Cloneable {
      * @return an image with an {@value StatisticsCalculator#STATISTICS_KEY} property.
      *         May be {@code image} if the given argument already has a statistics property.
      *
-     * @see #getStatistics(RenderedImage, Shape)
+     * @see #valueOfStatistics(RenderedImage, Shape)
      * @see StatisticsCalculator#STATISTICS_KEY
      */
     public RenderedImage statistics(final RenderedImage source, final Shape areaOfInterest)
{
@@ -674,7 +674,7 @@ public class ImageProcessor implements Cloneable {
      * mapped to their colors.
      *
      * <p>The minimum and maximum value can be either specified explicitly,
-     * or determined from {@linkplain #getStatistics(RenderedImage, Shape) statistics} on
the image.
+     * or determined from {@link #valueOfStatistics(RenderedImage, Shape) statistics} on
the image.
      * In the later case a range of value is determined first from the {@linkplain Statistics#minimum()
minimum}
      * and {@linkplain Statistics#maximum() maximum} values found in the image, optionally
narrowed to an interval
      * of some {@linkplain Statistics#standardDeviation(boolean) standard deviations} around
the mean value.</p>
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/RecoloredImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/RecoloredImage.java
index bb5aafd..67eb19a 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/RecoloredImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/RecoloredImage.java
@@ -161,7 +161,7 @@ final class RecoloredImage extends ImageAdapter {
             if (statistics == null) {
                 if (statsAllBands == null) {
                     final Object areaOfInterest = modifiers.get("areaOfInterest");
-                    statsAllBands = processor.getStatistics(statsSource,
+                    statsAllBands = processor.valueOfStatistics(statsSource,
                             (areaOfInterest instanceof Shape) ? (Shape) areaOfInterest :
null);
                 }
                 if (statsAllBands != null && visibleBand < statsAllBands.length)
{
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/Visualization.java b/core/sis-feature/src/main/java/org/apache/sis/image/Visualization.java
index 62ba955..807f3ba 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/Visualization.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/Visualization.java
@@ -290,7 +290,7 @@ final class Visualization extends ResampledImage {
              * If none of above Colorizer configurations worked, use statistics in last resort.
We do that
              * after we reduced the image to a single band, in order to reduce the amount
of calculations.
              */
-            final Statistics statistics = processor.getStatistics(source, null)[0];
+            final Statistics statistics = processor.valueOfStatistics(source, null)[0];
             colorizer.initialize(statistics.minimum(), statistics.maximum());
         }
         /*
diff --git a/core/sis-feature/src/test/java/org/apache/sis/image/StatisticsCalculatorTest.java
b/core/sis-feature/src/test/java/org/apache/sis/image/StatisticsCalculatorTest.java
index ea9f89b..a0110e4 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/image/StatisticsCalculatorTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/image/StatisticsCalculatorTest.java
@@ -95,7 +95,7 @@ public final strictfp class StatisticsCalculatorTest extends TestCase {
         operations.setExecutionMode(ImageProcessor.Mode.PARALLEL);
         final TiledImageMock image = createImage();
         final Statistics[] expected = computeSequentially(image);
-        final Statistics[] actual = operations.getStatistics(image, null);
+        final Statistics[] actual = operations.valueOfStatistics(image, null);
         for (int i=0; i<expected.length; i++) {
             final Statistics e = expected[i];
             final Statistics a = actual  [i];
@@ -116,7 +116,7 @@ public final strictfp class StatisticsCalculatorTest extends TestCase
{
         final TiledImageMock image = createImage();
         image.failRandomly(new Random(-8739538736973900203L));
         try {
-            operations.getStatistics(image, null);
+            operations.valueOfStatistics(image, null);
             fail("Expected ImagingOpException.");
         } catch (ImagingOpException e) {
             final String message = e.getMessage();
@@ -136,7 +136,7 @@ public final strictfp class StatisticsCalculatorTest extends TestCase
{
         operations.setErrorAction(ImageProcessor.ErrorAction.LOG);
         final TiledImageMock image = createImage();
         image.failRandomly(new Random(8004277484984714811L));
-        final Statistics[] stats = operations.getStatistics(image, null);
+        final Statistics[] stats = operations.valueOfStatistics(image, null);
         for (final Statistics a : stats) {
             assertTrue(a.count() > 0);
         }


Mime
View raw message