sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1803658 - in /sis/branches/JDK8: core/sis-raster/src/main/java/org/apache/sis/image/ core/sis-raster/src/main/java/org/apache/sis/internal/ core/sis-raster/src/main/java/org/apache/sis/internal/raster/ core/sis-raster/src/test/java/org/apa...
Date Tue, 01 Aug 2017 15:39:06 GMT
Author: desruisseaux
Date: Tue Aug  1 15:39:06 2017
New Revision: 1803658

URL: http://svn.apache.org/viewvc?rev=1803658&view=rev
Log:
Enable PixelIterator tests on Raster (not yet on RenderedImage).

Added:
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.java
      - copied, changed from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.java
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.properties
      - copied, changed from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.properties
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources_fr.properties
      - copied, changed from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources_fr.properties
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/package-info.java
      - copied, changed from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java
Modified:
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/DefaultIterator.java
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/PixelIterator.java
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/WritablePixelIterator.java
    sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/package-info.java
    sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/PixelIteratorTest.java
    sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/TiledImage.java
    sis/branches/JDK8/ide-project/NetBeans/build.xml

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/DefaultIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/DefaultIterator.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/DefaultIterator.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/DefaultIterator.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -22,6 +22,7 @@ import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
 import java.awt.image.RasterFormatException;
 import org.opengis.coverage.grid.SequenceType;
+import org.apache.sis.internal.raster.Resources;
 
 
 /**
@@ -30,8 +31,8 @@ import org.opengis.coverage.grid.Sequenc
  * Calls to {@link #next()} move the current position by increasing the following values, in order:
  *
  * <ol>
- *   <li>Column index in a single tile varies fastest (from left to right)</li>
- *   <li>Then, row index in a single tile varies from top to bottom.</li>
+ *   <li>Column index in a single tile (from left to right)</li>
+ *   <li>Row index in a single tile (from top to bottom).</li>
  *   <li>Then, {@code tileX} index from left to right.</li>
  *   <li>Then, {@code tileY} index from top to bottom.</li>
  * </ol>
@@ -41,6 +42,8 @@ import org.opengis.coverage.grid.Sequenc
  * @version 0.8
  * @since   0.8
  * @module
+ *
+ * @todo Change iteration order on tiles for using Hilbert iterator.
  */
 final class DefaultIterator extends PixelIterator {
     /**
@@ -112,9 +115,9 @@ final class DefaultIterator extends Pixe
             tileX = tileLowerX - 1;     // Note: no need for decrementExact(…) because already checked by constructor.
             tileY = tileLowerY;
             currentUpperX = lowerX;     // Really 'lower', so the position is the tile before the first tile.
+            currentUpperY = lowerY;
         }
         currentLowerX = lowerX;
-        currentUpperY = lowerY;
         x = lowerX - 1;                 // Set the position before first pixel.
         y = lowerY;
     }
@@ -136,19 +139,19 @@ final class DefaultIterator extends Pixe
      *
      * @return column and row indices of current iterator position.
      * @throws IllegalStateException if this method is invoked before the first call to {@link #next()}
-     *         or after {@code next()} returned {@code false}.
+     *         or {@link #moveTo(int, int)}, or after {@code next()} returned {@code false}.
      */
     @Override
     public Point getPosition() {
-        final String message;
+        final short message;
         if (x < lowerX) {
-            message = "Iteration did not started.";
+            message = Resources.Keys.IterationNotStarted;
         } else if (x >= upperX) {
-            message = "Iteration is finished.";
+            message = Resources.Keys.IterationIsFinished;
         } else {
             return new Point(x,y);
         }
-        throw new IllegalStateException(message);       // TODO: localize
+        throw new IllegalStateException(Resources.format(message));
     }
 
     /**
@@ -161,7 +164,7 @@ final class DefaultIterator extends Pixe
     @Override
     public void moveTo(final int px, final int py) {
         if (px < lowerX || px >= upperX ||  py < lowerY || py >= upperY) {
-            throw new IndexOutOfBoundsException("Coordinate is outside iterator domain.");      // TODO: localize
+            throw new IndexOutOfBoundsException(Resources.format(Resources.Keys.CoordinateOutsideDomain_2, px, py));
         }
         if (image != null) {
             final int tx = Math.floorDiv(px - tileGridXOffset, tileWidth);
@@ -185,10 +188,11 @@ final class DefaultIterator extends Pixe
      */
     @Override
     public boolean next() {
-        if (++x == currentUpperX) {
-            if (++y == currentUpperY) {
-                if (++tileX == tileUpperX) {
-                    if (Math.incrementExact(tileY) >= tileUpperY) {
+        if (++x >= currentUpperX) {
+            if (++y >= currentUpperY) {
+                if (++tileX >= tileUpperX) {
+                    tileY = Math.incrementExact(tileY);
+                    if (tileY >= tileUpperY) {
                         /*
                          * Paranoiac safety: keep the x, y and tileX values before their maximal values
                          * in order to avoid overflow. The 'tileY' value is used for checking if next()
@@ -198,7 +202,7 @@ final class DefaultIterator extends Pixe
                         y =  currentUpperY - 1;
                         tileX = tileUpperX - 1;
                         if (tileY > tileUpperY) {
-                            throw new IllegalStateException("Iteration is finished.");      // TODO: localize
+                            throw new IllegalStateException(Resources.format(Resources.Keys.IterationIsFinished));
                         }
                         return false;
                     }
@@ -213,7 +217,8 @@ final class DefaultIterator extends Pixe
 
     /**
      * Fetches from the image a tile for the current {@link #tileX} and {@link #tileY} coordinates.
-     * All fields prefixed by {@code current} are updated by this method.
+     * All fields prefixed by {@code current} are updated by this method. This method also updates
+     * the {@link #y} field, but caller is responsible for updating the {@link #x} field.
      */
     private void fetchTile() {
         currentRaster  = image.getTile(tileX, tileY);
@@ -223,23 +228,21 @@ final class DefaultIterator extends Pixe
         y              = Math.max(lowerY, minY);
         currentUpperX  = Math.min(upperX, minX + tileWidth);
         currentUpperY  = Math.min(upperY, minY + tileHeight);
-        x = currentLowerX - 1;
         if (currentRaster.getNumBands() != numBands) {
-            throw new RasterFormatException("Mismatched number of bands.");     // TODO: localize
+            throw new RasterFormatException(Resources.format(Resources.Keys.IncompatibleTile_2, tileX, tileY));
         }
     }
 
     /**
-     * Returns the sample value in the specified band of current pixel, without precision lost.
+     * Returns the sample value in the specified band of current pixel, rounded toward zero.
      */
     @Override
-    public double getSample(final int band) {
-        return currentRaster.getSampleDouble(x, y, band);
+    public int getSample(final int band) {
+        return currentRaster.getSample(x, y, band);
     }
 
     /**
-     * Returns the sample value in the specified band of current pixel,
-     * casted to a single-precision floating point number.
+     * Returns the sample value in the specified band of current pixel as a single-precision floating point number.
      */
     @Override
     public float getSampleFloat(final int band) {
@@ -247,11 +250,11 @@ final class DefaultIterator extends Pixe
     }
 
     /**
-     * Returns the sample value in the specified band of current pixel, casted to an integer.
+     * Returns the sample value in the specified band of current pixel, without precision lost.
      */
     @Override
-    public int getSampleInt(final int band) {
-        return currentRaster.getSample(x, y, band);
+    public double getSampleDouble(final int band) {
+        return currentRaster.getSampleDouble(x, y, band);
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/PixelIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/PixelIterator.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/PixelIterator.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/PixelIterator.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -20,7 +20,6 @@ import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.image.Raster;
 import java.awt.image.RenderedImage;
-import java.awt.image.SampleModel;
 import java.util.NoSuchElementException;
 import org.opengis.coverage.grid.SequenceType;
 import org.apache.sis.util.ArgumentChecks;
@@ -29,9 +28,22 @@ import static java.lang.Math.floorDiv;
 
 
 /**
- * An iterator over sample values in a raster or an image. This iterator simplifies accesses to pixel or sample values
- * by hiding {@linkplain SampleModel sample model} and tiling complexity. Iteration may be performed on full image or
- * on image sub-region. Iteration order is implementation specific.
+ * An iterator over sample values in a raster or an image.  This iterator makes easier to read and write efficiently
+ * pixel or sample values. The iterator {@linkplain RenderedImage#getTile(int,int) acquires tiles} and releases them
+ * automatically. Unless otherwise specified, iterators are free to use an {@linkplain #getIterationOrder() iteration
+ * order} that minimize the "acquire / release tile" operations (in other words, iterations are not necessarily from
+ * left to right). Iteration can be performed on a complete image or only a sub-region of it. Some optimized iterator
+ * implementations exist for a few commonly used {@linkplain java.awt.image.SampleModel sample models}.
+ *
+ * <p>Usage example:</p>
+ * {@preformat java
+ *     PixelIterator it = PixelIterator.create(image, null);
+ *     double[] samples = null;
+ *     while (it.next()) {
+ *         samples = it.getPixel(samples);      // Get values in all bands.
+ *         // Perform computation here...
+ *     }
+ * }
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -92,7 +104,7 @@ public abstract class PixelIterator {
      * @param  subArea  the raster region where to perform the iteration, or {@code null}
      *                  for iterating over all the raster domain.
      */
-    protected PixelIterator(final Raster data, final Rectangle subArea) {
+    PixelIterator(final Raster data, final Rectangle subArea) {
         ArgumentChecks.ensureNonNull("data", data);
         image           = null;
         currentRaster   = data;
@@ -108,6 +120,8 @@ public abstract class PixelIterator {
         Rectangle bounds = new Rectangle(tileGridXOffset, tileGridYOffset, tileWidth, tileHeight);
         if (subArea != null) {
             bounds = bounds.intersection(subArea);
+            if (bounds.width  < 0) bounds.width  = 0;
+            if (bounds.height < 0) bounds.height = 0;
         }
         lowerX = bounds.x;
         lowerY = bounds.y;
@@ -122,7 +136,7 @@ public abstract class PixelIterator {
      * @param  subArea  the image region where to perform the iteration, or {@code null}
      *                  for iterating over all the image domain.
      */
-    protected PixelIterator(final RenderedImage data, final Rectangle subArea) {
+    PixelIterator(final RenderedImage data, final Rectangle subArea) {
         ArgumentChecks.ensureNonNull("data", data);
         image            = data;
         numBands         = data.getSampleModel().getNumBands();
@@ -153,6 +167,8 @@ public abstract class PixelIterator {
 
     /**
      * Returns the pixel coordinates of the region where this iterator is doing the iteration.
+     * If no region was specified at construction time, then this method returns the image or
+     * raster bounds.
      *
      * @return pixel coordinates of the iteration region.
      */
@@ -171,20 +187,21 @@ public abstract class PixelIterator {
 
     /**
      * Returns the column (x) and row (y) indices of the current pixel.
-     * The {@link #next()} method must have been invoked before this method.
+     * The {@link #next()} or {@link #moveTo(int,int)} method must have been invoked before this method.
      * Indices of the first pixel are not necessarily zero; they can even be negative.
      *
      * @return column and row indices of current iterator position.
      * @throws IllegalStateException if this method is invoked before the first call to {@link #next()}
-     *         or after {@code next()} returned {@code false}.
+     *         or {@link #moveTo(int,int)}, or after {@code next()} returned {@code false}.
      */
     public abstract Point getPosition();
 
     /**
      * Moves the pixel iterator to the given column (x) and row (y) indices. After this method invocation,
      * the iterator state is as if the {@link #next()} method has been invoked just before to reach the
-     * specified position. Usage example:
+     * specified position.
      *
+     * <div class="note"><b>Usage example:</b>
      * {@preformat java
      *     iterator.moveTo(x, y);
      *     do {
@@ -192,6 +209,7 @@ public abstract class PixelIterator {
      *         // Use sample value here...
      *     } while (iterator.next());
      * }
+     * </div>
      *
      * @param  x  the column index of the pixel to make current.
      * @param  y  the row index of the pixel to make current.
@@ -216,18 +234,25 @@ public abstract class PixelIterator {
     public abstract boolean next();
 
     /**
-     * Returns the sample value in the specified band of current pixel, without precision lost.
+     * Returns the sample value in the specified band of current pixel, rounded toward zero.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getSample(int)} method is invoked. If above condition is not met,
+     * then this method behavior is undefined: it may throw any runtime exception or return a meaningless value
+     * (there is no explicit bounds check for performance reasons).
      *
      * @param  band  the band for which to get the sample value.
      * @return sample value in specified band of current pixel.
      *
-     * @see Raster#getSampleDouble(int, int, int)
+     * @see Raster#getSample(int, int, int)
      */
-    public abstract double getSample(int band);
+    public abstract int getSample(int band);
 
     /**
-     * Returns the sample value in the specified band of current pixel,
-     * casted to a single-precision floating point number.
+     * Returns the sample value in the specified band of current pixel as a single-precision floating point number.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getSampleFloat(int)} method is invoked. If above condition is
+     * not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless
+     * value (there is no explicit bounds check for performance reasons).
      *
      * @param  band  the band for which to get the sample value.
      * @return sample value in specified band of current pixel.
@@ -237,18 +262,25 @@ public abstract class PixelIterator {
     public abstract float getSampleFloat(int band);
 
     /**
-     * Returns the sample value in the specified band of current pixel, casted to an integer.
-     * Floating-point values are rounded toward zero.
+     * Returns the sample value in the specified band of current pixel, without precision lost.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getSampleDouble(int)} method is invoked. If above condition is
+     * not met, then this method behavior is undefined: it may throw any runtime exception or return a meaningless
+     * value (there is no explicit bounds check for performance reasons).
      *
      * @param  band  the band for which to get the sample value.
      * @return sample value in specified band of current pixel.
      *
-     * @see Raster#getSample(int, int, int)
+     * @see Raster#getSampleDouble(int, int, int)
      */
-    public abstract int getSampleInt(int band);
+    public abstract double getSampleDouble(int band);
 
     /**
      * Returns the sample values of current pixel for all bands.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getPixel(…)} method is invoked. If above condition is not met,
+     * then this method behavior is undefined: it may throw any runtime exception or return a meaningless value
+     * (there is no explicit bounds check for performance reasons).
      *
      * @param  dest  a pre-allocated array where to store the sample values, or {@code null} if none.
      * @return the sample values for current pixel.
@@ -259,6 +291,10 @@ public abstract class PixelIterator {
 
     /**
      * Returns the sample values of current pixel for all bands.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getPixel(…)} method is invoked. If above condition is not met,
+     * then this method behavior is undefined: it may throw any runtime exception or return a meaningless value
+     * (there is no explicit bounds check for performance reasons).
      *
      * @param  dest  a pre-allocated array where to store the sample values, or {@code null} if none.
      * @return the sample values for current pixel.
@@ -269,6 +305,10 @@ public abstract class PixelIterator {
 
     /**
      * Returns the sample values of current pixel for all bands.
+     * The {@link #next()} method must have returned {@code true}, or the {@link #moveTo(int,int)} method must have
+     * been invoked successfully, before this {@code getPixel(…)} method is invoked. If above condition is not met,
+     * then this method behavior is undefined: it may throw any runtime exception or return a meaningless value
+     * (there is no explicit bounds check for performance reasons).
      *
      * @param  dest  a pre-allocated array where to store the sample values, or {@code null} if none.
      * @return the sample values for current pixel.
@@ -316,7 +356,7 @@ public abstract class PixelIterator {
      * in the second column of the first row, <i>etc.</i></div>
      *
      * Regions are created by call to {@link PixelIterator#region(int, int)}.
-     * Once created, the same instance can be used for all regions traversed during iteration.
+     * Once created, the same instance can be used for all regions of the given size traversed during iteration.
      */
     public abstract static class Region {
         /**

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/WritablePixelIterator.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/WritablePixelIterator.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/WritablePixelIterator.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/WritablePixelIterator.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -24,6 +24,7 @@ import java.awt.image.RasterFormatExcept
 import java.awt.image.RenderedImage;
 import java.awt.image.WritableRaster;
 import java.awt.image.WritableRenderedImage;
+import org.apache.sis.internal.raster.Resources;
 
 
 /**
@@ -57,40 +58,40 @@ abstract class WritablePixelIterator ext
      * Ensures that the given output raster has the same grid geometry than the input raster.
      */
     private static void checkCompatibility(final Raster input, final WritableRaster output) {
-        final String message;
+        final short message;
         if (!input.getSampleModel().equals(output.getSampleModel())) {
-            message = "Incompatible sample model.";
+            message = Resources.Keys.MismatchedSampleModel;
         } else if (!input.getBounds().equals(output.getBounds())) {
-            message = "Mismatched location.";
+            message = Resources.Keys.MismatchedImageLocation;
         } else {
             return;
         }
-        throw new RasterFormatException(message);       // TODO: localize
+        throw new RasterFormatException(Resources.format(message));
     }
 
     /**
      * Ensures that the given output image has the same grid geometry than the input image.
      */
     private static void checkCompatibility(final RenderedImage input, final WritableRenderedImage output) {
-        final String message;
+        final short message;
         if (!input.getSampleModel().equals(output.getSampleModel())) {
-            message = "Incompatible sample model.";
-        } else if (input.getMinX()   != output.getMinX()   ||
-                   input.getMinY()   != output.getMinY()   ||
-                   input.getWidth()  != output.getWidth()  ||
+            message = Resources.Keys.MismatchedSampleModel;
+        } else if (input.getMinX()   != output.getMinX()  ||
+                   input.getMinY()   != output.getMinY()  ||
+                   input.getWidth()  != output.getWidth() ||
                    input.getHeight() != output.getHeight())
         {
-            message = "Mismatched location.";
+            message = Resources.Keys.MismatchedImageLocation;
         } else if (input.getMinTileX()   != output.getMinTileX()  ||
                    input.getMinTileY()   != output.getMinTileY()  ||
                    input.getTileWidth()  != output.getTileWidth() ||
                    input.getTileHeight() != output.getTileHeight())
         {
-            message = "Mismatched tile grid.";
+            message = Resources.Keys.MismatchedTileGrid;
         } else {
             return;
         }
-        throw new RasterFormatException(message);       // TODO: localize
+        throw new RasterFormatException(Resources.format(message));
     }
 
     /**

Modified: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/package-info.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/package-info.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/image/package-info.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -19,7 +19,7 @@
  * Provides helper classes for handling Java2D rendered images together with some operations.
  * This package does not provide any geospatial functionalities;
  * it works only on sample or pixel values stored in {@link java.awt.image.RenderedImage}s.
- * Note that Java2D {@code RenderedImage}s have the following capabilities:
+ * Those rendered images have the following capabilities:
  *
  * <ul>
  *   <li>Images may have an arbitrary number of bands (not necessarily RGB).</li>
@@ -27,7 +27,10 @@
  *   <li>Images can be tiled.</li>
  * </ul>
  *
- * This package is used as a basis for georeferenced or georeferenceable <cite>grid coverages</cite>.
+ * This package is used as a basis for
+ * {@linkplain org.apache.sis.metadata.iso.spatial.DefaultGeorectified georectified} or
+ * {@linkplain org.apache.sis.metadata.iso.spatial.DefaultGeoreferenceable georeferenceable}
+ * <cite>grid coverages</cite>.
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)

Copied: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.java (from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.java?p2=sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.java&r1=1803373&r2=1803658&rev=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -14,10 +14,9 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sis.internal.feature;
+package org.apache.sis.internal.raster;
 
 import java.net.URL;
-import java.util.Map;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import javax.annotation.Generated;
@@ -26,11 +25,11 @@ import org.apache.sis.util.resources.Ind
 
 
 /**
- * Warning and error messages that are specific to the {@code sis-feature} module.
+ * Warning and error messages that are specific to the {@code sis-raster} module.
  * Resources in this file should not be used by any other module. For resources shared by
  * all modules in the Apache SIS project, see {@link org.apache.sis.util.resources} package.
  *
- * @author  Martin Desruisseaux (IRD, Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
  * @version 0.8
  * @since   0.8
  * @module
@@ -42,7 +41,7 @@ public final class Resources extends Ind
      * inlines final integer values, using long identifiers will not bloat the constant
      * pools of compiled classes.
      *
-     * @author  Martin Desruisseaux (IRD, Geomatys)
+     * @author  Martin Desruisseaux (Geomatys)
      * @since   0.8
      * @module
      */
@@ -60,119 +59,39 @@ public final class Resources extends Ind
         }
 
         /**
-         * Feature type ‘{0}’ is abstract.
+         * The ({0}, {1}) pixel coordinate is outside iterator domain.
          */
-        public static final short AbstractFeatureType_1 = 1;
+        public static final short CoordinateOutsideDomain_2 = 1;
 
         /**
-         * Can not assign characteristics to the “{0}” property.
+         * The ({0}, {1}) tile has an unexpected size, number of bands or sample layout.
          */
-        public static final short CanNotAssignCharacteristics_1 = 2;
+        public static final short IncompatibleTile_2 = 2;
 
         /**
-         * Property “{0}” is not a type that can be instantiated.
+         * Iteration is finished.
          */
-        public static final short CanNotInstantiateProperty_1 = 3;
+        public static final short IterationIsFinished = 3;
 
         /**
-         * Can not set a value of type ‘{1}’ to characteristic “{0}”.
+         * Iteration did not started.
          */
-        public static final short CanNotSetCharacteristics_2 = 4;
+        public static final short IterationNotStarted = 4;
 
         /**
-         * Type of the “{0}” property does not allow to set a value.
+         * The two images have different size or pixel coordinates.
          */
-        public static final short CanNotSetPropertyValue_1 = 5;
+        public static final short MismatchedImageLocation = 5;
 
         /**
-         * Characteristics “{1}” already exists in attribute “{0}”.
+         * The two images use different sample models.
          */
-        public static final short CharacteristicsAlreadyExists_2 = 6;
+        public static final short MismatchedSampleModel = 6;
 
         /**
-         * No characteristics named “{1}” has been found in “{0}” attribute.
+         * The two images have different tile grid.
          */
-        public static final short CharacteristicsNotFound_2 = 7;
-
-        /**
-         * Operation “{0}” requires a “{1}” property, but no such property has been found in “{2}”.
-         */
-        public static final short DependencyNotFound_3 = 8;
-
-        /**
-         * Association “{0}” does not accept features of type ‘{2}’. Expected an instance of ‘{1}’ or
-         * derived type.
-         */
-        public static final short IllegalFeatureType_3 = 9;
-
-        /**
-         * Type or result of “{0}” property can not be ‘{1}’ for this operation.
-         */
-        public static final short IllegalPropertyType_2 = 10;
-
-        /**
-         * Property “{0}” does not accept values of type ‘{2}’. Expected an instance of ‘{1}’ or
-         * derived type.
-         */
-        public static final short IllegalPropertyValueClass_3 = 11;
-
-        /**
-         * Mismatched type for “{0}” property.
-         */
-        public static final short MismatchedPropertyType_1 = 12;
-
-        /**
-         * An attribute for ‘{1}’ values where expected, but the “{0}” attribute specifies values of
-         * type ‘{2}’.
-         */
-        public static final short MismatchedValueClass_3 = 13;
-
-        /**
-         * Property “{0}” contains more than one value.
-         */
-        public static final short NotASingleton_1 = 14;
-
-        /**
-         * The {0} optional library is not available. Geometric operations will ignore that library.
-         * Cause is {1}.
-         */
-        public static final short OptionalLibraryNotFound_2 = 19;
-
-        /**
-         * Property “{1}” already exists in feature “{0}”.
-         */
-        public static final short PropertyAlreadyExists_2 = 15;
-
-        /**
-         * No property named “{1}” has been found in “{0}” feature.
-         */
-        public static final short PropertyNotFound_2 = 16;
-
-        /**
-         * The {0} geometry library is not available in current runtime environment.
-         */
-        public static final short UnavailableGeometryLibrary_1 = 21;
-
-        /**
-         * The “{1}” value given to “{0}” property should be separable in {2} components, but we got
-         * {3}.
-         */
-        public static final short UnexpectedNumberOfComponents_4 = 17;
-
-        /**
-         * The “{0}” feature at {1} has a {3} ordinate values, while we expected a multiple of {2}.
-         */
-        public static final short UnexpectedNumberOfOrdinates_4 = 22;
-
-        /**
-         * Feature named “{0}” has not yet been resolved.
-         */
-        public static final short UnresolvedFeatureName_1 = 18;
-
-        /**
-         * Unsupported geometry {0}D object.
-         */
-        public static final short UnsupportedGeometryObject_1 = 20;
+        public static final short MismatchedTileGrid = 7;
     }
 
     /**
@@ -207,21 +126,6 @@ public final class Resources extends Ind
     }
 
     /**
-     * Returns resources in the locale specified in the given property map. This convenience method looks
-     * for the {@link #LOCALE_KEY} entry. If the given map is null, or contains no entry for the locale key,
-     * or the value is not an instance of {@link Locale}, then this method fallback on the default locale.
-     *
-     * @param  properties  the map of properties, or {@code null} if none.
-     * @return resources in the given locale.
-     * @throws MissingResourceException if resources can't be found.
-     *
-     * @since 0.4
-     */
-    public static Resources forProperties(final Map<?,?> properties) throws MissingResourceException {
-        return forLocale(getLocale(properties));
-    }
-
-    /**
      * Gets a string for the given key from this resource bundle or one of its parents.
      *
      * @param  key  the key for the desired string.
@@ -263,44 +167,4 @@ public final class Resources extends Ind
     {
         return forLocale(null).getString(key, arg0, arg1);
     }
-
-    /**
-     * Gets a string for the given key are replace all occurrence of "{0}",
-     * "{1}", with values of {@code arg0}, {@code arg1}, etc.
-     *
-     * @param  key   the key for the desired string.
-     * @param  arg0  value to substitute to "{0}".
-     * @param  arg1  value to substitute to "{1}".
-     * @param  arg2  value to substitute to "{2}".
-     * @return the formatted string for the given key.
-     * @throws MissingResourceException if no object for the given key can be found.
-     */
-    public static String format(final short  key,
-                                final Object arg0,
-                                final Object arg1,
-                                final Object arg2) throws MissingResourceException
-    {
-        return forLocale(null).getString(key, arg0, arg1, arg2);
-    }
-
-    /**
-     * Gets a string for the given key are replace all occurrence of "{0}",
-     * "{1}", with values of {@code arg0}, {@code arg1}, etc.
-     *
-     * @param  key   the key for the desired string.
-     * @param  arg0  value to substitute to "{0}".
-     * @param  arg1  value to substitute to "{1}".
-     * @param  arg2  value to substitute to "{2}".
-     * @param  arg3  value to substitute to "{3}".
-     * @return the formatted string for the given key.
-     * @throws MissingResourceException if no object for the given key can be found.
-     */
-    public static String format(final short  key,
-                                final Object arg0,
-                                final Object arg1,
-                                final Object arg2,
-                                final Object arg3) throws MissingResourceException
-    {
-        return forLocale(null).getString(key, arg0, arg1, arg2, arg3);
-    }
 }

Copied: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.properties (from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.properties)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.properties?p2=sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.properties&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.properties&r1=1803373&r2=1803658&rev=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources.properties [ISO-8859-1] Tue Aug  1 15:39:06 2017
@@ -16,28 +16,13 @@
 #
 
 #
-# Resources in this file are for "sis-feature" usage only and should not be used by any other module.
+# Resources in this file are for "sis-raster" usage only and should not be used by any other module.
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
 #
-AbstractFeatureType_1             = Feature type \u2018{0}\u2019 is abstract.
-CanNotAssignCharacteristics_1     = Can not assign characteristics to the \u201c{0}\u201d property.
-CanNotInstantiateProperty_1       = Property \u201c{0}\u201d is not a type that can be instantiated.
-CanNotSetCharacteristics_2        = Can not set a value of type \u2018{1}\u2019 to characteristic \u201c{0}\u201d.
-CanNotSetPropertyValue_1          = Type of the \u201c{0}\u201d property does not allow to set a value.
-CharacteristicsAlreadyExists_2    = Characteristics \u201c{1}\u201d already exists in attribute \u201c{0}\u201d.
-CharacteristicsNotFound_2         = No characteristics named \u201c{1}\u201d has been found in \u201c{0}\u201d attribute.
-DependencyNotFound_3              = Operation \u201c{0}\u201d requires a \u201c{1}\u201d property, but no such property has been found in \u201c{2}\u201d.
-IllegalFeatureType_3              = Association \u201c{0}\u201d does not accept features of type \u2018{2}\u2019. Expected an instance of \u2018{1}\u2019 or derived type.
-IllegalPropertyType_2             = Type or result of \u201c{0}\u201d property can not be \u2018{1}\u2019 for this operation.
-IllegalPropertyValueClass_3       = Property \u201c{0}\u201d does not accept values of type \u2018{2}\u2019. Expected an instance of \u2018{1}\u2019 or derived type.
-MismatchedPropertyType_1          = Mismatched type for \u201c{0}\u201d property.
-MismatchedValueClass_3            = An attribute for \u2018{1}\u2019 values where expected, but the \u201c{0}\u201d attribute specifies values of type \u2018{2}\u2019.
-NotASingleton_1                   = Property \u201c{0}\u201d contains more than one value.
-OptionalLibraryNotFound_2         = The {0} optional library is not available. Geometric operations will ignore that library.\nCause is {1}.
-PropertyAlreadyExists_2           = Property \u201c{1}\u201d already exists in feature \u201c{0}\u201d.
-PropertyNotFound_2                = No property named \u201c{1}\u201d has been found in \u201c{0}\u201d feature.
-UnavailableGeometryLibrary_1      = The {0} geometry library is not available in current runtime environment.
-UnexpectedNumberOfComponents_4    = The \u201c{1}\u201d value given to \u201c{0}\u201d property should be separable in {2} components, but we got {3}.
-UnexpectedNumberOfOrdinates_4     = The \u201c{0}\u201d feature at {1} has a {3} ordinate values, while we expected a multiple of {2}.
-UnresolvedFeatureName_1           = Feature named \u201c{0}\u201d has not yet been resolved.
-UnsupportedGeometryObject_1       = Unsupported geometry {0}D object.
+CoordinateOutsideDomain_2         = The ({0}, {1}) pixel coordinate is outside iterator domain.
+IncompatibleTile_2                = The ({0}, {1}) tile has an unexpected size, number of bands or sample layout.
+IterationIsFinished               = Iteration is finished.
+IterationNotStarted               = Iteration did not started.
+MismatchedImageLocation           = The two images have different size or pixel coordinates.
+MismatchedSampleModel             = The two images use different sample models.
+MismatchedTileGrid                = The two images have different tile grid.

Copied: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources_fr.properties (from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources_fr.properties)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources_fr.properties?p2=sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources_fr.properties&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources_fr.properties&r1=1803373&r2=1803658&rev=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/Resources_fr.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/Resources_fr.properties [ISO-8859-1] Tue Aug  1 15:39:06 2017
@@ -16,7 +16,7 @@
 #
 
 #
-# Resources in this file are for "sis-feature" usage only and should not be used by any other module.
+# Resources in this file are for "sis-raster" usage only and should not be used by any other module.
 # For resources shared by all modules in the Apache SIS project, see "org.apache.sis.util.resources" package.
 #
 # Punctuation rules in French (source: http://unicode.org/udhr/n/notes_fra.html)
@@ -24,25 +24,10 @@
 #   U+202F NARROW NO-BREAK SPACE  before  ; ! and ?
 #   U+00A0 NO-BREAK SPACE         before  :
 #
-AbstractFeatureType_1             = Le type d\u2019entit\u00e9 \u2018{0}\u2019 est abstrait.
-CanNotAssignCharacteristics_1     = Ne peut pas assigner des caract\u00e9ristiques \u00e0 la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb.
-CanNotInstantiateProperty_1       = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019est pas d\u2019un type qui peut \u00eatre instanci\u00e9.
-CanNotSetCharacteristics_2        = Ne peut pas assigner une valeur de type \u2018{1}\u2019 \u00e0 la caract\u00e9ristique \u00ab\u202f{0}\u202f\u00bb.
-CanNotSetPropertyValue_1          = Le type de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne permet pas de d\u00e9finir une valeur.
-CharacteristicsAlreadyExists_2    = La caract\u00e9ristique \u00ab\u202f{1}\u202f\u00bb existe d\u00e9j\u00e0 dans l\u2019attribut \u00ab\u202f{0}\u202f\u00bb.
-CharacteristicsNotFound_2         = Aucune caract\u00e9ristique nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb n\u2019a \u00e9t\u00e9 trouv\u00e9e dans l\u2019attribut \u00ab\u202f{0}\u202f\u00bb.
-DependencyNotFound_3              = L\u2019op\u00e9ration \u00ab\u202f{0}\u202f\u00bb n\u00e9cessite une propri\u00e9t\u00e9 \u00ab\u202f{1}\u202f\u00bb, mais cette propri\u00e9t\u00e9 n\u2019a pas \u00e9t\u00e9 trouv\u00e9e dans \u00ab\u202f{2}\u202f\u00bb.
-IllegalFeatureType_3              = L\u2019association \u00ab\u202f{0}\u202f\u00bb n\u2019accepte pas les entit\u00e9s de type \u2018{2}\u2019. Une instance de \u2018{1}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.
-IllegalPropertyType_2             = Le type ou le r\u00e9sultat de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne peut pas \u00eatre \u2018{1}\u2019 pour cette op\u00e9ration.
-IllegalPropertyValueClass_3       = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb n\u2019accepte pas les valeurs de type \u2018{2}\u2019. Une instance de \u2018{1}\u2019 ou d\u2019un type d\u00e9riv\u00e9 \u00e9tait attendue.
-MismatchedPropertyType_1          = Le type de la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb ne correspond pas.
-MismatchedValueClass_3            = Un attribut pour des valeurs de type \u2018{1}\u2019 \u00e9tait attendu, mais l\u2019attribut \u00ab\u202f{0}\u202f\u00bb sp\u00e9cifie des valeurs de type \u2018{2}\u2019.
-NotASingleton_1                   = La propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb contient plus de une valeur.
-OptionalLibraryNotFound_2         = La biblioth\u00e8que optionnelle {0} n\u2019est pas disponible. Les op\u00e9rations g\u00e9om\u00e9triques ignoreront cette biblioth\u00e8que.\nLa cause est {1}.
-PropertyNotFound_2                = Aucune propri\u00e9t\u00e9 nomm\u00e9e \u00ab\u202f{1}\u202f\u00bb n\u2019a \u00e9t\u00e9 trouv\u00e9e dans l\u2019entit\u00e9 \u00ab\u202f{0}\u202f\u00bb.
-PropertyAlreadyExists_2           = La propri\u00e9t\u00e9 \u00ab\u202f{1}\u202f\u00bb existe d\u00e9j\u00e0 dans l\u2019entit\u00e9 \u00ab\u202f{0}\u202f\u00bb.
-UnavailableGeometryLibrary_1      = La biblioth\u00e8que de g\u00e9om\u00e9tries {0} n\u2019est pas disponible dans l\u2019environnement d\u2019ex\u00e9cution actuel.
-UnexpectedNumberOfComponents_4    = La valeur \u00ab\u202f{1}\u202f\u00bb donn\u00e9e \u00e0 la propri\u00e9t\u00e9 \u00ab\u202f{0}\u202f\u00bb devrait \u00eatre s\u00e9parable en {2} composantes, mais on en a obtenus {3}.
-UnexpectedNumberOfOrdinates_4     = L\u2019entit\u00e9 nomm\u00e9e \u00ab\u202f{0}\u202f\u00bb \u00e0 {1} contient {3} ordonn\u00e9es, alors qu\u2019on attendait un multiple de {2}.
-UnresolvedFeatureName_1           = L\u2019entit\u00e9 nomm\u00e9e \u00ab\u202f{0}\u202f\u00bb n\u2019a pas encore \u00e9t\u00e9 r\u00e9solue.
-UnsupportedGeometryObject_1       = Object g\u00e9om\u00e9trique {0}D non-support\u00e9.
+CoordinateOutsideDomain_2         = La coordonn\u00e9e pixel ({0}, {1}) est en dehors du domaine de l\u2019it\u00e9rateur.
+IncompatibleTile_2                = La tuile ({0}, {1}) a une taille, un nombre de bandes ou une disposition des valeurs inattendu.
+IterationIsFinished               = L\u2019it\u00e9ration est termin\u00e9e.
+IterationNotStarted               = L\u2019it\u00e9ration n\u2019a pas commenc\u00e9e.
+MismatchedImageLocation           = Les deux images ont une taille ou des coordonn\u00e9es pixels diff\u00e9rentes.
+MismatchedSampleModel             = Les deux images disposent les pixels diff\u00e9remment.
+MismatchedTileGrid                = Les deux images utilisent des grilles de tuiles diff\u00e9rentes.

Copied: sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/package-info.java (from r1803373, sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java)
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/package-info.java?p2=sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/package-info.java&p1=sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java&r1=1803373&r2=1803658&rev=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-feature/src/main/java/org/apache/sis/internal/feature/package-info.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/main/java/org/apache/sis/internal/raster/package-info.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -17,17 +17,15 @@
 
 /**
  * A set of helper classes for the SIS implementation.
- * contains also classes that may move to the public API someday,
- * but are considered not yet ready.
  *
  * <p><strong>Do not use!</strong></p>
  *
  * This package is for internal use by SIS only. Classes in this package
  * may change in incompatible ways in any future version without notice.
  *
- * @author  Johann Sorel (Geomatys)
- * @version 0.7
- * @since   0.7
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 0.8
+ * @since   0.8
  * @module
  */
-package org.apache.sis.internal.feature;
+package org.apache.sis.internal.raster;

Modified: sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/PixelIteratorTest.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/PixelIteratorTest.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/PixelIteratorTest.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/PixelIteratorTest.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -16,6 +16,7 @@
  */
 package org.apache.sis.image;
 
+import java.util.Arrays;
 import java.awt.Point;
 import java.awt.Rectangle;
 import java.awt.image.DataBuffer;
@@ -23,7 +24,6 @@ import java.awt.image.PixelInterleavedSa
 import java.awt.image.Raster;
 import java.awt.image.WritableRaster;
 import java.awt.image.WritableRenderedImage;
-import java.util.Arrays;
 import org.opengis.coverage.grid.SequenceType;
 import org.apache.sis.test.DependsOnMethod;
 import org.apache.sis.test.TestCase;
@@ -35,7 +35,7 @@ import static org.junit.Assert.*;
 
 /**
  * Base class of {@link PixelIterator} tests. This base class tests the default read-only iterator
- * on integer values. Subclasses will test variants, for example the read-write iterator.
+ * on signed short integer values. Subclasses will test variants, for example the read-write iterator.
  *
  * @author  Rémi Maréchal (Geomatys)
  * @author  Martin Desruisseaux (Geomatys)
@@ -111,7 +111,7 @@ public strictfp class PixelIteratorTest
      * Creates a new test case.
      */
     public PixelIteratorTest() {
-        this(DataBuffer.TYPE_INT);
+        this(DataBuffer.TYPE_SHORT);
     }
 
     /**
@@ -140,7 +140,7 @@ public strictfp class PixelIteratorTest
             subMaxX = StrictMath.min(xmax, subArea.x + subArea.width);
             subMaxY = StrictMath.min(ymax, subArea.y + subArea.height);
         }
-        expected = new float[(subMaxX - subMinX) * (subMaxY - subMinY) * numBands];
+        expected = new float[StrictMath.max(subMaxX - subMinX, 0) * StrictMath.max(subMaxY - subMinY, 0) * numBands];
         final WritableRaster raster = Raster.createWritableRaster(new PixelInterleavedSampleModel(dataType,
                 width, height, numBands, width * numBands, TiledImage.bandOffsets(numBands)), new Point(xmin, ymin));
         /*
@@ -148,7 +148,7 @@ public strictfp class PixelIteratorTest
          * Now fill the data structures with arbitrary values.
          */
         int n = 0;
-        float value = (dataType == DataBuffer.TYPE_FLOAT) ? -2000.5f : 0f;
+        float value = (dataType == DataBuffer.TYPE_FLOAT) ? -100.5f : 100f;
         for (int y=ymin; y<ymax; y++) {
             final boolean rowIncluded = (y >= subMinY && y < subMaxY);
             for (int x=xmin; x<xmax; x++) {
@@ -195,13 +195,13 @@ public strictfp class PixelIteratorTest
             subMaxY = StrictMath.min(ymax, subArea.y + subArea.height);
         }
         expected = new float[(subMaxX - subMinX) * (subMaxY - subMinY) * numBands];
-        final TiledImage image = new TiledImage(dataType, numBands, xmin, ymin, width, height, tileWidth, tileHeight, -1, 2);
+        final TiledImage image = new TiledImage(dataType, numBands, xmin, ymin, width, height, tileWidth, tileHeight, 0, 0);
         /*
          * At this point, all data structures have been created an initialized to zero sample values.
          * Now fill the data structures with arbitrary values. We fill them tile-by-tile.
          */
         int n = 0;
-        float value = (dataType == DataBuffer.TYPE_FLOAT) ? -200.5f : 0f;
+        float value = (dataType == DataBuffer.TYPE_FLOAT) ? -100.5f : 100f;
         for (int j=0; j<numYTiles; j++) {
             for (int i=0; i<numXTiles; i++) {
                 final int yNextTile = ymin + (j+1) * tileHeight;
@@ -235,7 +235,7 @@ public strictfp class PixelIteratorTest
      * @param  raster  the data on which to perform iteration.
      */
     void createPixelIterator(WritableRaster raster) {
-        iterator = PixelIteratorFactory.createReadOnlyIterator(raster);
+        iterator = new DefaultIterator(raster, null);
         assertEquals("getIterationOrder()", SequenceType.LINEAR, iterator.getIterationOrder());
     }
 
@@ -250,7 +250,7 @@ public strictfp class PixelIteratorTest
      * @param  subArea  the boundary of the raster sub-area where to perform iteration.
      */
     void createPixelIterator(WritableRaster raster, Rectangle subArea) {
-        iterator = PixelIteratorFactory.createReadOnlyIterator(raster, subArea);
+        iterator = new DefaultIterator(raster, subArea);
         assertEquals("getIterationOrder()", SequenceType.LINEAR, iterator.getIterationOrder());
     }
 
@@ -264,7 +264,7 @@ public strictfp class PixelIteratorTest
      * @param  image  the data on which to perform iteration.
      */
     void createPixelIterator(WritableRenderedImage image) {
-        iterator = PixelIteratorFactory.createReadOnlyIterator(image);
+        iterator = new DefaultIterator(image, null);
     }
 
     /**
@@ -278,7 +278,7 @@ public strictfp class PixelIteratorTest
      * @param  subArea  the boundary of the image sub-area where to perform iteration.
      */
     void createPixelIterator(WritableRenderedImage image, Rectangle subArea) {
-        iterator = PixelIteratorFactory.createReadOnlyIterator(image, subArea);
+        iterator = new DefaultIterator(image, subArea);
     }
 
     /**
@@ -291,7 +291,7 @@ public strictfp class PixelIteratorTest
         int i = 0;
         while (iterator.next()) {
             for (int b=0; b<numBands; b++) {
-                final float e = expected[i++];
+                final float e = expected[i];
                 final float a = iterator.getSampleFloat(b);
                 if (Float.floatToRawIntBits(a) != Float.floatToRawIntBits(e)) {
                     fail("Pixel iteration at index " + i + ": expected " + e + " but got " + a);
@@ -302,6 +302,7 @@ public strictfp class PixelIteratorTest
                     assertEquals("x", (p % width) + xmin, position.x);
                     assertEquals("y", (p / width) + ymin, position.y);
                 }
+                i++;
             }
         }
         assertEquals("Too few elements in iteration.", expected.length, i);
@@ -310,39 +311,27 @@ public strictfp class PixelIteratorTest
     /**
      * Tests iteration over all pixels in a single raster.
      * This method uses different (<var>x</var>,<var>y</var>) origins.
-     * Tests also {@link PixelIterator#rewind()}.
      */
     @Test
-    @Ignore
     public void testOnRaster() {
-        xmin     =  0;
-        ymin     =  0;
-        width    = 10;
-        height   = 12;
+        width    =  7;
+        height   = 10;
         numBands =  3;
         createPixelIterator(createRaster(null));
         verifyIteration(true);
+    }
 
-        xmin = 3;
-        ymin = 5;
-        createPixelIterator(createRaster(null));
-        verifyIteration(true);
-
-        xmin   = -3;
-        ymin   =  5;
-        height =  9;
-        createPixelIterator(createRaster(null));
-        verifyIteration(true);
-
-        xmin   =  3;
-        ymin   = -5;
-        height =  7;
-        createPixelIterator(createRaster(null));
-        verifyIteration(true);
-
-        xmin  = -3;
-        ymin  = -5;
-        width =  7;
+    /**
+     * Tests {@link PixelIterator#rewind()}.
+     */
+    @Test
+    @DependsOnMethod("testOnRaster")
+    public void testRasterRewind() {
+        xmin     = -3;
+        ymin     = -5;
+        width    =  8;
+        height   =  7;
+        numBands =  3;
         createPixelIterator(createRaster(null));
         verifyIteration(true);
 
@@ -355,13 +344,12 @@ public strictfp class PixelIteratorTest
      * This test iterates in the upper-left corner of the raster.
      */
     @Test
-    @Ignore
     @DependsOnMethod("testOnRaster")
     public void testOnRasterUpperLeft() {
         xmin     =  5;
         ymin     =  7;
-        width    = 12;
-        height   = 15;
+        width    =  9;
+        height   =  8;
         numBands =  3;
         final Rectangle subArea = new Rectangle(4, 6, 5, 4);
         createPixelIterator(createRaster(subArea), subArea);
@@ -374,15 +362,14 @@ public strictfp class PixelIteratorTest
      * This test iterates in the upper-right corner of the raster.
      */
     @Test
-    @Ignore
     @DependsOnMethod("testOnRaster")
     public void testOnRasterUpperRight() {
-        width    = 15;
-        height   = 14;
-        xmin     = 6;
-        ymin     = 9;
-        numBands = 3;
-        final Rectangle subArea = new Rectangle(16, 6, 10, 6);
+        xmin     = 11;
+        ymin     = 12;
+        width    = 10;
+        height   = 11;
+        numBands =  3;
+        final Rectangle subArea = new Rectangle(16, 9, 10, 6);
         createPixelIterator(createRaster(subArea), subArea);
         assertTrue("Expected a non-empty set of values.", expected.length != 0);
         verifyIteration(false);
@@ -393,15 +380,14 @@ public strictfp class PixelIteratorTest
      * This test iterates in the lower-right corner of the raster.
      */
     @Test
-    @Ignore
     @DependsOnMethod("testOnRaster")
     public void testOnRasterLowerRight() {
-        xmin     =  6;
-        ymin     =  7;
-        width    = 15;
-        height   = 16;
+        xmin     = -4;
+        ymin     = -6;
+        width    =  8;
+        height   =  8;
         numBands =  3;
-        final Rectangle subArea = new Rectangle(14, 20, 15, 9);
+        final Rectangle subArea = new Rectangle(2, -2, 10, 12);
         createPixelIterator(createRaster(subArea), subArea);
         assertTrue("Expected a non-empty set of values.", expected.length != 0);
         verifyIteration(false);
@@ -412,15 +398,14 @@ public strictfp class PixelIteratorTest
      * This test iterates in the lower-left corner of the raster.
      */
     @Test
-    @Ignore
     @DependsOnMethod("testOnRaster")
     public void testOnRasterLowerLeft() {
-        xmin     =  4;
-        ymin     =  6;
-        width    = 16;
-        height   = 15;
+        xmin     =  6;
+        ymin     =  7;
+        width    =  5;
+        height   =  9;
         numBands =  3;
-        final Rectangle subArea = new Rectangle(2, 12, 10, 6);
+        final Rectangle subArea = new Rectangle(3, 10, 4, 9);
         createPixelIterator(createRaster(subArea), subArea);
         assertTrue("Expected a non-empty set of values.", expected.length != 0);
         verifyIteration(false);
@@ -431,8 +416,7 @@ public strictfp class PixelIteratorTest
      * Tests also {@link PixelIterator#rewind()}.
      */
     @Test
-    @Ignore
-    @DependsOnMethod("testOnRaster")
+    @DependsOnMethod({"testOnRaster", "testRasterRewind"})
     public void testOnRasterSubArea() {
         xmin     =  5;
         ymin     =  7;
@@ -453,36 +437,41 @@ public strictfp class PixelIteratorTest
      * Tests also {@link PixelIterator#rewind()}.
      */
     @Test
-    @Ignore
-    @DependsOnMethod("testOnRaster")
+    @DependsOnMethod({"testOnRaster", "testRasterRewind"})
     public void testOnRasterFullArea() {
         xmin     =  7;
         ymin     =  9;
         width    = 11;
-        height   = 13;
+        height   = 17;
         numBands =  3;
         final Rectangle subArea = new Rectangle(2, 3, 25, 17);
         createPixelIterator(createRaster(subArea), subArea);
         assertTrue("Expected a non-empty set of values.", expected.length != 0);
         verifyIteration(true);
+
+        iterator.rewind();
+        verifyIteration(false);
     }
 
     /**
      * Tests iteration over a sub-area that do not intersect the raster area.
+     * Tests also {@link PixelIterator#rewind()}.
      */
     @Test
-    @Ignore
-    @DependsOnMethod("testOnRaster")
+    @DependsOnMethod({"testOnRaster", "testRasterRewind"})
     public void testOnRasterEmptyArea() {
-        width    = 7;
-        height   = 10;
         xmin     = 6;
         ymin     = 5;
+        width    = 3;
+        height   = 2;
         numBands = 3;
         final Rectangle subArea = new Rectangle(-17, -20, 5, 15);
         createPixelIterator(createRaster(subArea), subArea);
         assertEquals("Expected an empty set of values.", 0, expected.length);
         verifyIteration(true);
+
+        iterator.rewind();
+        verifyIteration(false);
     }
 
     /**
@@ -490,32 +479,31 @@ public strictfp class PixelIteratorTest
      * an exception to be thrown.
      */
     @Test
-    @Ignore
     public void testIllegalMoveOnRaster() {
         xmin     =  4;
         ymin     =  7;
-        width    = 13;
-        height   = 10;
+        width    =  5;
+        height   =  4;
         numBands =  3;
         createPixelIterator(createRaster(null));
         assertTrue("Expected a non-empty set of values.", expected.length != 0);
         try {
             iterator.moveTo(2, 3);
-            fail("Expected IllegalArgumentException.");
-        } catch (IllegalArgumentException e) {
-            // ok
+            fail("Expected IndexOutOfBoundsException.");
+        } catch (IndexOutOfBoundsException e) {
+            assertNotNull(e.getMessage());
         }
         try {
             iterator.moveTo(9, 3);
-            fail("Expected IllegalArgumentException.");
-        } catch (IllegalArgumentException e) {
-            // ok
+            fail("Expected IndexOutOfBoundsException.");
+        } catch (IndexOutOfBoundsException e) {
+            assertNotNull(e.getMessage());
         }
         try {
             iterator.moveTo(2, 10);
-            fail("Expected IllegalArgumentException.");
-        } catch (IllegalArgumentException e) {
-            // ok
+            fail("Expected IndexOutOfBoundsException.");
+        } catch (IndexOutOfBoundsException e) {
+            assertNotNull(e.getMessage());
         }
     }
 
@@ -525,14 +513,32 @@ public strictfp class PixelIteratorTest
      * Tests also {@link PixelIterator#rewind()}.
      */
     @Test
-    @Ignore
     @DependsOnMethod("testOnRaster")
     public void testOnImage() {
-        xmin       =   0;
-        ymin       =   0;
-        width      = 100;
+        width      =  40;
+        height     =  50;
+        tileWidth  =   8;
+        tileHeight =   5;
+        numBands   =   3;
+        createPixelIterator(createImage(null));
+        assertNull("getIterationOrder()", iterator.getIterationOrder());
+        verifyIteration(false);
+    }
+
+    /**
+     * Tests iteration over all pixels in a tiled image.
+     * This method uses different (<var>x</var>,<var>y</var>) origins.
+     * Tests also {@link PixelIterator#rewind()}.
+     */
+    @Test
+    @Ignore
+    @DependsOnMethod("testOnRaster")
+    public void testImageRewind() {
+        xmin       =   1;
+        ymin       = -50;
+        width      =  40;
         height     =  50;
-        tileWidth  =  10;
+        tileWidth  =   8;
         tileHeight =   5;
         numBands   =   3;
         createPixelIterator(createImage(null));

Modified: sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/TiledImage.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/TiledImage.java?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/TiledImage.java [UTF-8] (original)
+++ sis/branches/JDK8/core/sis-raster/src/test/java/org/apache/sis/image/TiledImage.java [UTF-8] Tue Aug  1 15:39:06 2017
@@ -175,8 +175,7 @@ final class TiledImage implements Writab
         final int i = tileY * numXTiles + tileX;
         WritableRaster raster = tiles[i];
         if (raster == null) {
-            tiles[i] = raster = Raster.createInterleavedRaster(sampleModel.getDataType(),
-                    tileWidth, tileHeight, sampleModel.getNumBands(),
+            tiles[i] = raster = Raster.createWritableRaster(sampleModel,
                     new Point(tileX * tileWidth  + minX,
                               tileY * tileHeight + minY));
         }

Modified: sis/branches/JDK8/ide-project/NetBeans/build.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/build.xml?rev=1803658&r1=1803657&r2=1803658&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/build.xml (original)
+++ sis/branches/JDK8/ide-project/NetBeans/build.xml Tue Aug  1 15:39:06 2017
@@ -45,6 +45,9 @@
       <fileset dir="${project.root}/core/sis-feature/target/generated-resources">
         <include name="**/*.utf"/>
       </fileset>
+      <fileset dir="${project.root}/core/sis-raster/target/generated-resources">
+        <include name="**/*.utf"/>
+      </fileset>
       <fileset dir="${project.root}/storage/sis-storage/target/generated-resources">
         <include name="**/*.utf"/>
       </fileset>



Mime
View raw message