/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package org.apache.sis.image;

import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.image.Raster;
import java.awt.image.RenderedImage;
import java.awt.image.WritableRaster;
import java.awt.image.WritableRenderedImage;
import org.apache.sis.internal.raster.Resources;
import org.opengis.coverage.grid.SequenceType;

/**
 * Linear iterator used when common line y line iteration is requiered.
 * This iterator uses the {@link Raster} API for traversing the pixels of the image.
 * Calls to {@link #next()} move the current position by increasing the following values, in order:
 *
 * <ol>
 *   <li>Column index in image (from left to right)</li>
 *   <li>Row index in image (from top to bottom).</li>
 * </ol>
 *
 * @author  Johann Sorel (Geomatys)
 * @version 1.0
 * @since   1.0
 * @module
 *
 */
public class LinearIterator extends DefaultIterator {

    public LinearIterator(Raster input, WritableRaster output, Rectangle subArea, Dimension window) {
        super(input, output, subArea, window);
    }

    public LinearIterator(final RenderedImage input, final WritableRenderedImage output, final Rectangle subArea, final Dimension window) {
        super(input, output, subArea, window);
    }

    @Override
    public SequenceType getIterationOrder() {
        return SequenceType.LINEAR;
    }

    @Override
    public boolean next() {

        if (++x >= upperX) {
            //move to next line
            x = lowerX;
            if (++y >= upperY) {
                x = lowerX;
                return false;
            }
        } else if (y >= upperY) {
            x = lowerX;
            //second time or more get in the next method, raise error
            throw new IllegalStateException(Resources.format(Resources.Keys.IterationIsFinished));
        }

        if (image != null) {
            final int tx = Math.floorDiv(x - tileGridXOffset, tileWidth);
            final int ty = Math.floorDiv(y - tileGridYOffset, tileHeight);
            if (tx != tileX || ty != tileY) {
                close(); // Release current writable raster, if any.
                tileX = tx;
                tileY = ty;
                int ry = y;
                fetchTile();
                y = ry; //y is changed by fetchTile method
            }
        }
        return true;
    }

}

@@ -3,181 +3,798 @@
 %0A * 
-To change this license header, choose License Headers in Project Properties.%0A * To change this template file, choose Tools %7C Templates%0A * and open the template in the editor
+Licensed to the Apache Software Foundation (ASF) under one or more%0A * contributor license agreements.  See the NOTICE file distributed with%0A * this work for additional information regarding copyright ownership.%0A * The ASF licenses this file to You under the Apache License, Version 2.0%0A * (the %22License%22); you may not use this file except in compliance with%0A * the License.  You may obtain a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License
 .%0A *
@@ -1026,24 +1026,71 @@
 deredImage;%0A
+import org.opengis.coverage.grid.SequenceType;%0A
 import org.a
@@ -1130,54 +1130,8 @@
 es;%0A
-import org.opengis.coverage.grid.SequenceType;
 %0A%0A/*
@@ -1607,21 +1607,17 @@
 ule%0A
- *%0A
  */%0A
-public
+final
  cla
@@ -1661,31 +1661,24 @@
 ator %7B%0A%0A    
-public 
 LinearIterat
@@ -1814,23 +1814,16 @@
  %7D%0A%0A    
-public 
 LinearIt

Add the missing Apache license header. Pixel iterator implementations should be package-private.