sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject [sis] 08/10: Move BandedSampleConverter together with other PlanarImage implementations.
Date Wed, 29 Jul 2020 16:19:01 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 e92226fdb0d9e5bbaa7198050215d0ad9ba7b3aa
Author: Martin Desruisseaux <martin.desruisseaux@geomatys.com>
AuthorDate: Wed Jul 29 14:47:47 2020 +0200

    Move BandedSampleConverter together with other PlanarImage implementations.
---
 .../sis/coverage/grid/ConvertedGridCoverage.java   |  2 +-
 .../org/apache/sis/coverage/grid/GridCoverage.java | 13 +++-
 .../j2d => image}/BandedSampleConverter.java       | 71 +++++++++++-----------
 .../java/org/apache/sis/image/ImageProcessor.java  | 47 ++++++++++++++
 .../java/org/apache/sis/image/RecoloredImage.java  |  5 +-
 .../org/apache/sis/image/SourceAlignedImage.java   |  4 ++
 .../coverage/j2d => image}/Transferer.java         |  6 +-
 .../sis/internal/coverage/j2d/ImageLayout.java     | 16 +++++
 .../sis/internal/coverage/j2d/WriteSupport.java    | 10 +--
 .../j2d => image}/BandedSampleConverterTest.java   |  9 +--
 .../apache/sis/test/suite/FeatureTestSuite.java    |  2 +-
 11 files changed, 132 insertions(+), 53 deletions(-)

diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
index b846cae..336b8ab 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/ConvertedGridCoverage.java
@@ -266,7 +266,7 @@ final class ConvertedGridCoverage extends GridCoverage {
          * That image should never be null. But if an implementation wants to do so, respect
that.
          */
         if (image != null) {
-            return convert(image, dataType, converters);
+            image = convert(image, dataType, converters);
         }
         return image;
     }
diff --git a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage.java
b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage.java
index 20bb9fb..e44eb62 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/coverage/grid/GridCoverage.java
@@ -31,7 +31,7 @@ import org.apache.sis.internal.util.UnmodifiableArrayList;
 import org.apache.sis.measure.NumberRange;
 import org.apache.sis.coverage.SampleDimension;
 import org.apache.sis.coverage.SubspaceNotSpecifiedException;
-import org.apache.sis.internal.coverage.j2d.BandedSampleConverter;
+import org.apache.sis.image.ImageProcessor;
 import org.apache.sis.internal.coverage.j2d.ImageUtilities;
 import org.apache.sis.internal.coverage.j2d.Colorizer;
 import org.apache.sis.util.collection.DefaultTreeTable;
@@ -60,6 +60,15 @@ import org.opengis.coverage.CannotEvaluateException;
  */
 public abstract class GridCoverage {
     /**
+     * The processor to use for {@link #convert(RenderedImage, int, MathTransform1D[])} operations.
+     * Wrapped in a class for lazy instantiation.
+     */
+    private static final class Lazy {
+        private Lazy() {}
+        private static final ImageProcessor PROCESSOR = new ImageProcessor();
+    }
+
+    /**
      * The grid extent, coordinate reference system (CRS) and conversion from cell indices
to CRS.
      *
      * @see #getGridGeometry()
@@ -252,7 +261,7 @@ public abstract class GridCoverage {
         } else {
             colors = Colorizer.NULL_COLOR_MODEL;
         }
-        return BandedSampleConverter.create(source, null, dataType, colors, getRanges(),
converters);
+        return Lazy.PROCESSOR.convertSampleValues(source, getRanges(), converters, dataType,
colors);
     }
 
     /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverter.java
b/core/sis-feature/src/main/java/org/apache/sis/image/BandedSampleConverter.java
similarity index 89%
rename from core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverter.java
rename to core/sis-feature/src/main/java/org/apache/sis/image/BandedSampleConverter.java
index 7592aca..2584a6b 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverter.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/BandedSampleConverter.java
@@ -14,9 +14,8 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.coverage.j2d;
+package org.apache.sis.image;
 
-import java.awt.Dimension;
 import java.awt.Rectangle;
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
@@ -30,10 +29,12 @@ import java.lang.reflect.Array;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.TransformException;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
-import org.apache.sis.image.ComputedImage;
+import org.apache.sis.internal.coverage.j2d.ImageLayout;
+import org.apache.sis.internal.coverage.j2d.ImageUtilities;
+import org.apache.sis.internal.coverage.j2d.TileOpExecutor;
+import org.apache.sis.internal.coverage.j2d.WriteSupport;
 import org.apache.sis.internal.system.Modules;
 import org.apache.sis.util.Numbers;
-import org.apache.sis.util.ArgumentChecks;
 import org.apache.sis.util.logging.Logging;
 import org.apache.sis.math.DecimalFunctions;
 import org.apache.sis.measure.NumberRange;
@@ -63,7 +64,12 @@ import org.apache.sis.measure.NumberRange;
  * @since   1.1
  * @module
  */
-public class BandedSampleConverter extends ComputedImage {
+class BandedSampleConverter extends ComputedImage {
+    /*
+     * Do not extend `SourceAlignedImage` because we want to inherit the `getNumTiles()`
+     * and `getTileGridOffset()` methods defined by `PlanarImage`.
+     */
+
     /**
      * The transfer functions to apply on each band of the source image.
      */
@@ -87,6 +93,7 @@ public class BandedSampleConverter extends ComputedImage {
      * @param  colorModel   the color model for the expected range of values, or {@code null}.
      * @param  ranges       the expected range of values for each band, or {@code null} if
unknown.
      * @param  converters   the transfer functions to apply on each band of the source image.
+     *                      If this array was a user-provided parameter, should be cloned
by caller.
      */
     private BandedSampleConverter(final RenderedImage source,  final BandedSampleModel sampleModel,
                                   final ColorModel colorModel, final NumberRange<?>[]
ranges,
@@ -110,7 +117,7 @@ public class BandedSampleConverter extends ComputedImage {
              * If no range was explicitly given, use the approximate average of all possible
values.
              */
             double middle = Double.NaN;
-            if (ranges != null) {
+            if (ranges != null && i < ranges.length) {
                 final NumberRange<?> range = ranges[i];
                 if (range != null) {
                     middle = range.getMedian();
@@ -159,28 +166,22 @@ public class BandedSampleConverter extends ComputedImage {
      * The number of bands is the length of the {@code converters} array, which must be greater
than 0
      * and not greater than the number of bands in the source image.
      *
-     * @param  source      the image for which to convert sample values.
-     * @param  layout      object to use for computing tile size, or {@code null} for the
default.
-     * @param  targetType  the type of this image resulting from conversion of given image.
-     * @param  colorModel  the color model for the expected range of values, or {@code null}.
-     * @param  ranges      the expected range of values for each band, or {@code null} if
unknown.
-     * @param  converters  the transfer functions to apply on each band of the source image.
+     * @param  source        the image for which to convert sample values.
+     * @param  layout        object to use for computing tile size.
+     * @param  sourceRanges  the expected range of values for each band in source image,
or {@code null} if unknown.
+     * @param  converters    the transfer functions to apply on each band of the source image.
+     * @param  targetType    the type of this image resulting from conversion of given image.
+     * @param  colorModel    the color model for the expected range of values, or {@code
null}.
      * @return the image which compute converted values from the given source.
+     *
+     * @see ImageProcessor#convertSampleValues(RenderedImage, NumberRange[], MathTransform1D[],
int, ColorModel)
      */
-    public static BandedSampleConverter create(final RenderedImage source, ImageLayout layout,
-            final int targetType, final ColorModel colorModel, final NumberRange<?>[]
ranges,
-            final MathTransform1D... converters)
+    static BandedSampleConverter create(final RenderedImage source, final ImageLayout layout,
+            final NumberRange<?>[] sourceRanges, final MathTransform1D[] converters,
+            final int targetType, final ColorModel colorModel)
     {
-        ArgumentChecks.ensureNonNull("source", source);
-        ArgumentChecks.ensureNonNull("converters", converters);
         final int numBands = converters.length;
-        ArgumentChecks.ensureSizeBetween("converters", 1, source.getSampleModel().getNumBands(),
numBands);
-        if (layout == null) {
-            layout = ImageLayout.DEFAULT;
-        }
-        final Dimension tile = layout.suggestTileSize(source, null);
-        final BandedSampleModel sampleModel = RasterFactory.unique(
-                new BandedSampleModel(targetType, tile.width, tile.height, numBands));
+        final BandedSampleModel sampleModel = layout.createBandedSampleModel(targetType,
numBands, source);
         /*
          * If the source image is writable, then changes in the converted image may be retro-propagated
          * to that source image. If we fail to compute the required inverse transforms, log
a notice at
@@ -192,11 +193,11 @@ public class BandedSampleConverter extends ComputedImage {
             for (int i=0; i<numBands; i++) {
                 inverses[i] = converters[i].inverse();
             }
-            return new Writable((WritableRenderedImage) source, sampleModel, colorModel,
ranges, converters, inverses);
+            return new Writable((WritableRenderedImage) source, sampleModel, colorModel,
sourceRanges, converters, inverses);
         } catch (NoninvertibleTransformException e) {
-            Logging.recoverableException(Logging.getLogger(Modules.RASTER), BandedSampleConverter.class,
"create", e);
+            Logging.recoverableException(Logging.getLogger(Modules.RASTER), ImageProcessor.class,
"convertSampleValues", e);
         }
-        return new BandedSampleConverter(source, sampleModel, colorModel, ranges, converters);
+        return new BandedSampleConverter(source, sampleModel, colorModel, sourceRanges, converters);
     }
 
     /**
@@ -244,7 +245,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getWidth() {
-        return getSource(0).getWidth();
+        return getSource().getWidth();
     }
 
     /**
@@ -255,7 +256,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getHeight() {
-        return getSource(0).getHeight();
+        return getSource().getHeight();
     }
 
     /**
@@ -266,7 +267,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getMinX() {
-        return getSource(0).getMinX();
+        return getSource().getMinX();
     }
 
     /**
@@ -277,7 +278,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getMinY() {
-        return getSource(0).getMinY();
+        return getSource().getMinY();
     }
 
     /**
@@ -288,7 +289,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getMinTileX() {
-        return getSource(0).getMinTileX();
+        return getSource().getMinTileX();
     }
 
     /**
@@ -299,7 +300,7 @@ public class BandedSampleConverter extends ComputedImage {
      */
     @Override
     public int getMinTileY() {
-        return getSource(0).getMinTileY();
+        return getSource().getMinTileY();
     }
 
     /**
@@ -316,7 +317,7 @@ public class BandedSampleConverter extends ComputedImage {
         if (target == null) {
             target = createTile(tileX, tileY);
         }
-        Transferer.create(getSource(0), target).compute(converters);
+        Transferer.create(getSource(), target).compute(converters);
         return target;
     }
 
@@ -430,7 +431,7 @@ public class BandedSampleConverter extends ComputedImage {
         @Override
         public void setData(final Raster data) {
             final Rectangle bounds = data.getBounds();
-            final WritableRenderedImage target = (WritableRenderedImage) getSource(0);
+            final WritableRenderedImage target = (WritableRenderedImage) getSource();
             ImageUtilities.clipBounds(target, bounds);
             final TileOpExecutor executor = new TileOpExecutor(target, bounds) {
                 @Override protected void writeTo(final WritableRaster target) throws TransformException
{
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 7b8c5b2..cf62dbe 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
@@ -26,18 +26,23 @@ import java.util.logging.LogRecord;
 import java.awt.Color;
 import java.awt.Shape;
 import java.awt.Rectangle;
+import java.awt.image.DataBuffer;
 import java.awt.image.ColorModel;
 import java.awt.image.SampleModel;
 import java.awt.image.BufferedImage;
 import java.awt.image.RenderedImage;
 import java.awt.image.ImagingOpException;
 import java.awt.image.IndexColorModel;
+import java.awt.image.WritableRenderedImage;
 import javax.measure.Quantity;
 import org.apache.sis.coverage.Category;
 import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
 import org.apache.sis.coverage.SampleDimension;
+import org.apache.sis.internal.coverage.j2d.ImageLayout;
+import org.apache.sis.internal.coverage.j2d.ImageUtilities;
 import org.apache.sis.math.Statistics;
 import org.apache.sis.util.ArraysExt;
 import org.apache.sis.util.ArgumentChecks;
@@ -672,6 +677,48 @@ public class ImageProcessor implements Cloneable {
     }
 
     /**
+     * Returns an image with sample values converted by the given functions. The results
can be stored as
+     * {@code byte}, {@code short}, {@code int}, {@code float} or {@code double} values,
not necessarily
+     * the same type than the source values. If the result values are stored as integers,
then they are
+     * {@linkplain Math#round(double) rounded to nearest integers} and clamped in the valid
range of the
+     * target integer type.
+     *
+     * <p>If the source image is a {@link WritableRenderedImage} and the given converters
are invertible, then
+     * the returned image will also be a {@link WritableRenderedImage} instance. In such
case values written in
+     * the returned image will be reflected in the source image, with {@linkplain Math#round(double)
rounding}
+     * and clamping if the source values are stored as integers.</p>
+     *
+     * <p>The number of bands in the returned image is the length of the {@code converters}
array,
+     * which must be greater than 0 and not greater than the number of bands in the source
image.
+     * If the {@code converters} array length is less than the number of source bands, all
source
+     * bands at index ≥ {@code converters.length} will be ignored.</p>
+     *
+     * <p>The {@code sourceRanges} array is only a hint for this method. The array
may be {@code null}
+     * or contain {@code null} elements, and may be of any length. Missing elements are considered
null
+     * and extraneous elements are ignored.</p>
+     *
+     * @param  source        the image for which to convert sample values.
+     * @param  sourceRanges  approximate ranges of values for each band in source image,
or {@code null} if unknown.
+     * @param  converters    the transfer functions to apply on each band of the source image.
+     * @param  targetType    the type of image resulting from conversions. Shall be one of
{@link DataBuffer} constants.
+     * @param  colorModel    color model of resulting image, or {@code null}.
+     * @return the image which compute converted values from the given source.
+     */
+    public RenderedImage convertSampleValues(final RenderedImage source, final NumberRange<?>[]
sourceRanges,
+                            MathTransform1D[] converters, final int targetType, final ColorModel
colorModel)
+    {
+        ArgumentChecks.ensureNonNull("source", source);
+        ArgumentChecks.ensureNonNull("converters", converters);
+        ArgumentChecks.ensureSizeBetween("converters", 1, ImageUtilities.getNumBands(source),
converters.length);
+        converters = converters.clone();
+        for (int i=0; i<converters.length; i++) {
+            ArgumentChecks.ensureNonNullElement("converters", i, converters[i]);
+        }
+        // No need to clone `sourceRanges` because it is not stored by `BandedSampleConverter`.
+        return unique(BandedSampleConverter.create(source, ImageLayout.DEFAULT, sourceRanges,
converters, targetType, colorModel));
+    }
+
+    /**
      * Creates a new image which will resample the given image. The resampling operation
is defined
      * by a non-linear transform from the <em>new</em> image to the specified
<em>source</em> image.
      * That transform should map {@linkplain org.opengis.referencing.datum.PixelInCell#CELL_CENTER
pixel centers}.
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 fb91497..578cbba 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
@@ -31,7 +31,6 @@ import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.NoninvertibleTransformException;
 import org.apache.sis.coverage.Category;
 import org.apache.sis.coverage.SampleDimension;
-import org.apache.sis.internal.coverage.j2d.BandedSampleConverter;
 import org.apache.sis.internal.coverage.j2d.ColorModelFactory;
 import org.apache.sis.internal.coverage.j2d.Colorizer;
 import org.apache.sis.internal.coverage.j2d.ImageUtilities;
@@ -275,8 +274,8 @@ final class RecoloredImage extends ImageAdapter {
         final ColorModel      colorModel = colorizer.compactColorModel(1, 0);           //
Must be first.
         final MathTransform1D converter  = colorizer.getSampleToIndexValues();
         final NumberRange<?>  range      = colorizer.getRepresentativeRange();
-        return BandedSampleConverter.create(source, null, Colorizer.TYPE_COMPACT, colorModel,
-                                            new NumberRange<?>[] {range}, converter);
+        return processor.convertSampleValues(source, new NumberRange<?>[] {range},
+                new MathTransform1D[] {converter}, Colorizer.TYPE_COMPACT, colorModel);
     }
 
     /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/image/SourceAlignedImage.java b/core/sis-feature/src/main/java/org/apache/sis/image/SourceAlignedImage.java
index bc654db..05209fe 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/image/SourceAlignedImage.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/SourceAlignedImage.java
@@ -26,6 +26,8 @@ import org.apache.sis.util.Workaround;
 
 /**
  * An image computed from a single source and sharing the same coordinate system.
+ * In addition of pixel coordinate system, images share also the same tile indices.
+ * Tiles in this image have the same size than tiles in the source image.
  *
  * @author  Martin Desruisseaux (Geomatys)
  * @version 1.1
@@ -48,6 +50,8 @@ abstract class SourceAlignedImage extends ComputedImage {
     SourceAlignedImage(final RenderedImage source, final ColorModel colorModel, final SampleModel
sampleModel) {
         super(sampleModel, source);
         this.colorModel = colorModel;
+        assert source.getSampleModel().getWidth()  == sampleModel.getWidth() &&
+               source.getSampleModel().getHeight() == sampleModel.getHeight();
     }
 
     /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/Transferer.java
b/core/sis-feature/src/main/java/org/apache/sis/image/Transferer.java
similarity index 99%
rename from core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/Transferer.java
rename to core/sis-feature/src/main/java/org/apache/sis/image/Transferer.java
index 2f802ef..f0b1b32 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/Transferer.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/image/Transferer.java
@@ -14,7 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.coverage.j2d;
+package org.apache.sis.image;
 
 import java.awt.Rectangle;
 import java.awt.image.Raster;
@@ -25,9 +25,11 @@ import java.awt.image.DataBuffer;
 import java.awt.image.DataBufferFloat;
 import java.awt.image.DataBufferDouble;
 import java.awt.image.RenderedImage;
-import org.apache.sis.internal.util.Numerics;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.opengis.referencing.operation.TransformException;
+import org.apache.sis.internal.coverage.j2d.ImageUtilities;
+import org.apache.sis.internal.coverage.j2d.ImageLayout;
+import org.apache.sis.internal.util.Numerics;
 
 
 /**
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java
index 7fe2994..d1fff0c 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/ImageLayout.java
@@ -23,6 +23,7 @@ import java.awt.image.ColorModel;
 import java.awt.image.IndexColorModel;
 import java.awt.image.RenderedImage;
 import java.awt.image.SampleModel;
+import java.awt.image.BandedSampleModel;
 import org.apache.sis.math.MathFunctions;
 import org.apache.sis.image.ComputedImage;
 import org.apache.sis.util.ArgumentChecks;
@@ -224,6 +225,20 @@ public class ImageLayout {
     }
 
     /**
+     * Creates a banded sample model of the given type with a {@linkplain #suggestTileSize(RenderedImage,
Rectangle)
+     * the suggested size} for the given image.
+     *
+     * @param  type      desired data type as a {@link java.awt.image.DataBuffer} constant.
+     * @param  numBands  desired number of bands.
+     * @param  image     the image which will be the source of the image for which a sample
model is created.
+     * @return a banded sample model of the given type with the given number of bands.
+     */
+    public BandedSampleModel createBandedSampleModel(final int type, final int numBands,
final RenderedImage image) {
+        final Dimension tile = suggestTileSize(image, null);
+        return RasterFactory.unique(new BandedSampleModel(type, tile.width, tile.height,
numBands));
+    }
+
+    /**
      * Creates a sample model compatible with the sample model of the given image
      * but with a size matching the preferred tile size. This method can be used
      * for determining the {@code sampleModel} argument of {@link ComputedImage}
@@ -241,6 +256,7 @@ public class ImageLayout {
         SampleModel sm = image.getSampleModel();
         if (sm.getWidth() != tile.width || sm.getHeight() != tile.height) {
             sm = sm.createCompatibleSampleModel(tile.width, tile.height);
+            sm = RasterFactory.unique(sm);
         }
         return sm;
     }
diff --git a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/WriteSupport.java
b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/WriteSupport.java
index 694c68a..5990430 100644
--- a/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/WriteSupport.java
+++ b/core/sis-feature/src/main/java/org/apache/sis/internal/coverage/j2d/WriteSupport.java
@@ -33,7 +33,7 @@ import org.apache.sis.util.ArraysExt;
  * @since   1.1
  * @module
  */
-final class WriteSupport {
+public final class WriteSupport {
     /**
      * Do not allow (for now) instantiation of this class.
      */
@@ -48,7 +48,7 @@ final class WriteSupport {
      * @param  observer   the observer to add. Null values are ignored.
      * @return the updated array of observers.
      */
-    static TileObserver[] addTileObserver(TileObserver[] observers, final TileObserver observer)
{
+    public static TileObserver[] addTileObserver(TileObserver[] observers, final TileObserver
observer) {
         if (observer != null) {
             if (observers == null) {
                 return new TileObserver[] {observer};
@@ -69,7 +69,7 @@ final class WriteSupport {
      * @param  observer   the observer to remove.
      * @return the updated array of observers.
      */
-    static TileObserver[] removeTileObserver(final TileObserver[] observers, final TileObserver
observer) {
+    public static TileObserver[] removeTileObserver(final TileObserver[] observers, final
TileObserver observer) {
         if (observers != null) {
             for (int i=observers.length; --i >= 0;) {
                 if (observers[i] == observer) {
@@ -89,8 +89,8 @@ final class WriteSupport {
      * @param tileY           the <var>y</var> index of the tile that is being
updated.
      * @param willBeWritable  if {@code true}, the tile will be grabbed for writing; otherwise
it is being released.
      */
-    static void fireTileUpdate(final TileObserver[] observers, final WritableRenderedImage
image,
-                               final int tileX, final int tileY, final boolean willBeWritable)
+    public static void fireTileUpdate(final TileObserver[] observers, final WritableRenderedImage
image,
+                                      final int tileX, final int tileY, final boolean willBeWritable)
     {
         if (observers != null) {
             for (final TileObserver observer : observers) {
diff --git a/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverterTest.java
b/core/sis-feature/src/test/java/org/apache/sis/image/BandedSampleConverterTest.java
similarity index 95%
rename from core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverterTest.java
rename to core/sis-feature/src/test/java/org/apache/sis/image/BandedSampleConverterTest.java
index 5b6dd2f..526064f 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/internal/coverage/j2d/BandedSampleConverterTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/image/BandedSampleConverterTest.java
@@ -14,13 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.coverage.j2d;
+package org.apache.sis.image;
 
 import java.util.Random;
 import java.awt.image.DataBuffer;
 import org.opengis.referencing.operation.MathTransform1D;
 import org.apache.sis.referencing.operation.transform.MathTransforms;
-import org.apache.sis.image.TiledImageMock;
+import org.apache.sis.internal.coverage.j2d.ImageLayout;
 import org.apache.sis.test.TestUtilities;
 import org.apache.sis.test.TestCase;
 import org.junit.Test;
@@ -70,8 +70,9 @@ public final strictfp class BandedSampleConverterTest extends TestCase {
                 random.nextInt(20) - 10);       // minTileY
         source.validate();
         source.initializeAllTiles(0);
-        image = BandedSampleConverter.create(source, null, targetType, null, null,
-                (MathTransform1D) MathTransforms.linear(scale, 0));
+        image = BandedSampleConverter.create(source, ImageLayout.DEFAULT, null,
+                new MathTransform1D[] {(MathTransform1D) MathTransforms.linear(scale, 0)},
+                targetType, null);
     }
 
     /**
diff --git a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
index f09eea8..b623240 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/test/suite/FeatureTestSuite.java
@@ -88,6 +88,7 @@ import org.junit.runners.Suite;
     org.apache.sis.image.InterpolationTest.class,
     org.apache.sis.image.ResamplingGridTest.class,
     org.apache.sis.image.ResampledImageTest.class,
+    org.apache.sis.image.BandedSampleConverterTest.class,
     org.apache.sis.coverage.CategoryTest.class,
     org.apache.sis.coverage.CategoryListTest.class,
     org.apache.sis.coverage.SampleDimensionTest.class,
@@ -103,7 +104,6 @@ import org.junit.runners.Suite;
     org.apache.sis.coverage.grid.GridCoverageBuilderTest.class,
     org.apache.sis.coverage.grid.ConvertedGridCoverageTest.class,
     org.apache.sis.coverage.grid.ResampledGridCoverageTest.class,
-    org.apache.sis.internal.coverage.j2d.BandedSampleConverterTest.class,
 
     // Index
     org.apache.sis.index.tree.PointTreeNodeTest.class,


Mime
View raw message