jdk/src/java.desktop/share/classes/sun/awt/image/ShortComponentRaster.java
author prr
Sat, 19 Sep 2015 15:45:59 -0700
changeset 32865 f9cb6e427f9e
parent 30948 0a0972d3b58d
child 37544 d07afcfa7730
permissions -rw-r--r--
8136783: Run blessed-modifier-order script on java.desktop Reviewed-by: martin, serb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18246
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt.image;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.awt.image.Raster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.image.WritableRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.image.RasterFormatException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.image.SampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.image.ComponentSampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.image.SinglePixelPackedSampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.image.DataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.image.DataBufferUShort;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Point;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
 * This class defines a Raster with pixels consisting of one or more 16-bit
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
 * data elements stored in close proximity to each other in a short integer
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
 * array.  The bit precision per data element is that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
 * of the data type (that is, the bit precision for this Raster is 16).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * There is only one pixel stride and one scanline stride for all
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * bands.  This type of Raster can be used with a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 * ComponentColorModel if there are multiple bands, or a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * IndexColorModel if there is only one band.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 * For example, 5-6-5 RGB image data can be represented by a
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * ShortComponentRaster using a SinglePixelPackedSampleModel and
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * a ComponentColorModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
public class ShortComponentRaster extends SunWritableRaster {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    /** private band offset for use by native code */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    protected int bandOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    /** Data offsets for each band of image data. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    protected int[]         dataOffsets;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    /** Scanline stride of the image data contained in this Raster. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    protected int           scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    /** Pixel stride of the image data contained in this Raster. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    protected int           pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    /** The image data array. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    protected short[]       data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    int type;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /** A cached copy of minX + width for use in bounds checks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    private int maxX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    /** A cached copy of minY + height for use in bounds checks. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private int maxY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
32865
f9cb6e427f9e 8136783: Run blessed-modifier-order script on java.desktop
prr
parents: 30948
diff changeset
    79
    private static native void initIDs();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        /* ensure that the necessary native libraries are loaded */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
        NativeLibLoader.loadLibraries();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
     *  Constructs a ShortComponentRaster with the given SampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
     *  The Raster's upper left corner is origin and it is the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
     *  size as the SampleModel.  A DataBuffer large enough to describe the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
     *  Raster is automatically created.  SampleModel must be of type
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
     *  ComponentSampleModel or SinglePixelPackedSampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
     *  @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
     *  @param origin          The Point that specified the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    public ShortComponentRaster(SampleModel sampleModel, Point origin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
        this(sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
             sampleModel.createDataBuffer(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
             new Rectangle(origin.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
                           origin.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
                           sampleModel.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
                           sampleModel.getHeight()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
             origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
             null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * Constructs a ShortComponentRaster with the given SampleModel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * and DataBuffer.  The Raster's upper left corner is origin and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     * it is the same sizes the SampleModel.  The DataBuffer is not
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * initialized and must be a DataBufferUShort compatible with SampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * SampleModel must be of type ComponentSampleModel or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     * SinglePixelPackedSampleModel.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     * @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
     * @param dataBuffer      The DataBufferUShort that contains the image data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * @param origin          The Point that specifies the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    public ShortComponentRaster(SampleModel sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
                                   DataBuffer dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                                   Point origin) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        this(sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
             dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
             new Rectangle(origin.x,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                           origin.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                           sampleModel.getWidth(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                           sampleModel.getHeight()),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
             origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
             null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
     * Constructs a ShortComponentRaster with the given SampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * DataBuffer, and parent.  DataBuffer must be a DataBufferUShort and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * SampleModel must be of type ComponentSampleModel or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     * SinglePixelPackedSampleModel.  When translated into the base Raster's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
     * coordinate system, aRegion must be contained by the base Raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
     * Origin is the coodinate in the new Raster's coordinate system of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
     * the origin of the base Raster.  (The base Raster is the Raster's
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
     * ancestor which has no parent.)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Note that this constructor should generally be called by other
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     * constructors or create methods, it should not be used directly.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @param sampleModel     The SampleModel that specifies the layout.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     * @param dataBuffer      The DataBufferUShort that contains the image data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
     * @param aRegion         The Rectangle that specifies the image area.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
     * @param origin          The Point that specifies the origin.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
     * @param parent          The parent (if any) of this raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    public ShortComponentRaster(SampleModel sampleModel,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                                   DataBuffer dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                                   Rectangle aRegion,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                                   Point origin,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                                   ShortComponentRaster parent) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        super(sampleModel, dataBuffer, aRegion, origin, parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
        this.maxX = minX + width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
        this.maxY = minY + height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
        if(!(dataBuffer instanceof DataBufferUShort)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
            throw new RasterFormatException("ShortComponentRasters must have "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                                            "short DataBuffers");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        DataBufferUShort dbus = (DataBufferUShort)dataBuffer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        this.data = stealData(dbus, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        if (dbus.getNumBanks() != 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
            throw new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                RasterFormatException("DataBuffer for ShortComponentRasters"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                                      " must only have 1 bank.");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
        int dbOffset = dbus.getOffset();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        if (sampleModel instanceof ComponentSampleModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            ComponentSampleModel csm = (ComponentSampleModel)sampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            this.type = IntegerComponentRaster.TYPE_USHORT_SAMPLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
            this.scanlineStride = csm.getScanlineStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            this.pixelStride = csm.getPixelStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
            this.dataOffsets = csm.getBandOffsets();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
            int xOffset = aRegion.x - origin.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
            int yOffset = aRegion.y - origin.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
            for (int i = 0; i < getNumDataElements(); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
                dataOffsets[i] += dbOffset +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                    xOffset*pixelStride+yOffset*scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        } else if (sampleModel instanceof SinglePixelPackedSampleModel) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
            SinglePixelPackedSampleModel sppsm =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                    (SinglePixelPackedSampleModel)sampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
            this.type = IntegerComponentRaster.TYPE_USHORT_PACKED_SAMPLES;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
            this.scanlineStride = sppsm.getScanlineStride();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
            this.pixelStride    = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
            this.dataOffsets = new int[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            this.dataOffsets[0] = dbOffset;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            int xOffset = aRegion.x - origin.x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
            int yOffset = aRegion.y - origin.y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            dataOffsets[0] += xOffset+yOffset*scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            throw new RasterFormatException("ShortComponentRasters must have"+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
                "ComponentSampleModel or SinglePixelPackedSampleModel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        this.bandOffset = this.dataOffsets[0];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   201
        verify();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * Returns a copy of the data offsets array. For each band the data offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * is the index into the band's data array, of the first sample of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * band.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    public int[] getDataOffsets() {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18246
diff changeset
   210
        return dataOffsets.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * Returns the data offset for the specified band.  The data offset
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     * is the index into the data array in which the first sample
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
     * of the first scanline is stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
     * @param band  The band whose offset is returned.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    public int getDataOffset(int band) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
        return dataOffsets[band];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * Returns the scanline stride -- the number of data array elements between
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * a given sample and the same sample in the same column of the next row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
    public int getScanlineStride() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        return scanlineStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Returns pixel stride -- the number of data array elements  between two
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * samples for the same band on the same scanline.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    public int getPixelStride() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        return pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
     * Returns a reference to the data array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    public short[] getDataStorage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        return data;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     * Returns the data elements for all bands at the specified
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
     * location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
     * if the pixel coordinate is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     * @param x        The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
     * @param y        The Y coordinate of the pixel location.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   255
     * @param obj      An object reference to an array of type defined by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
     *                 getTransferType() and length getNumDataElements().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
     *                 If null an array of appropriate type and size will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
     *                 allocated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
     * @return         An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
     *                 getTransferType() with the request pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    public Object getDataElements(int x, int y, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
            (x >= this.maxX) || (y >= this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
        short outData[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        if (obj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            outData = new short[numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            outData = (short[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
        int off = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
                  (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
        for (int band = 0; band < numDataElements; band++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            outData[band] = data[dataOffsets[band] + off];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * Returns an array  of data elements from the specified rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     * region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
     *       short[] bandData = (short[])Raster.getDataElements(x, y, w, h, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
     *       int numDataElements = Raster.getBands();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
     *       short[] pixel = new short[numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
     *       // To find the data element at location (x2, y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
     *       System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
     *                        pixel, 0, numDataElements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     * @param y        The Y coordinate of the upper left pixel location.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   301
     * @param w        Width of the pixel rectangle.
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   302
     * @param h        Height of the pixel rectangle.
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   303
     * @param obj      An object reference to an array of type defined by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
     *                 getTransferType() and length w*h*getNumDataElements().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
     *                 If null an array of appropriate type and size will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
     *                 allocated.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
     * @return         An object reference to an array of type defined by
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
     *                 getTransferType() with the request pixel data.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    public Object getDataElements(int x, int y, int w, int h, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        short outData[];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
        if (obj == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            outData = new short[w*h*numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
            outData = (short[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
                for (int c = 0; c < numDataElements; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
                    outData[off++] = data[dataOffsets[c] + xoff];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
     * Returns a short integer array of data elements from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
     * specified rectangular region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
     *       short[] bandData = Raster.getShortData(x, y, w, h, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
     *       // To find the data element at location (x2, y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
     *       short dataElenent = bandData[((y2-y)*w + (x2-x))];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
     * @param y        The Y coordinate of the upper left pixel location.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   354
     * @param w        Width of the sample rectangle.
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   355
     * @param h        Height of the sample rectangle.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
     * @param band     The band to return.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
     * @param outData  If non-null, data elements for all bands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
     *                 at the specified location are returned in this array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
     * @return         Data array with data elements for all bands.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    public short[] getShortData(int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                               int band, short[] outData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        // Bounds check for 'band' will be performed automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        if (outData == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            outData = new short[numDataElements*w*h];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        int yoff =  (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                    (x-minX)*pixelStride+ dataOffsets[band];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (pixelStride == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            if (scanlineStride == w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                System.arraycopy(data, yoff, outData, 0, w*h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
                for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
                    System.arraycopy(data, yoff, outData, off, w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                    off += w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
                    outData[off++] = data[xoff];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
     * Returns a short integer array  of data elements from the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
     * specified rectangular region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
     *       short[] bandData = Raster.getShortData(x, y, w, h, null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
     *       int numDataElements = Raster.getNumBands();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
     *       short[] pixel = new short[numDataElements];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
     *       // To find the data element at location (x2, y2)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
     *       System.arraycopy(bandData, ((y2-y)*w + (x2-x))*numDataElements,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
     *                        pixel, 0, numDataElements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
     * @param y        The Y coordinate of the upper left pixel location.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   417
     * @param w        Width of the pixel rectangle.
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   418
     * @param h        Height of the pixel rectangle.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     * @param outData  If non-null, data elements for all bands
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
     *                 at the specified location are returned in this array.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
     * @return         Data array with data elements for all bands.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
    public short[] getShortData(int x, int y, int w, int h, short[] outData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        if (outData == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            outData = new short[numDataElements*w*h];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
                for (int c = 0; c < numDataElements; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
                    outData[off++] = data[dataOffsets[c] + xoff];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
        return outData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
     * Stores the data elements for all bands at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
     * if the pixel coordinate is out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
     * @param x        The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
     * @param y        The Y coordinate of the pixel location.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   459
     * @param obj      An object reference to an array of type defined by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
     *                 getTransferType() and length getNumDataElements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
     *                 containing the pixel data to place at x,y.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
    public void setDataElements(int x, int y, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
            (x >= this.maxX) || (y >= this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
        short inData[] = (short[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
        int off = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
                  (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
        for (int i = 0; i < numDataElements; i++) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18246
diff changeset
   473
            data[dataOffsets[i] + off] = inData[i];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
     * Stores the Raster data at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * @param x          The X coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     * @param y          The Y coordinate of the pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
     * @param inRaster   Raster of data to place at x,y location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public void setDataElements(int x, int y, Raster inRaster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        int dstOffX = x + inRaster.getMinX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        int dstOffY = y + inRaster.getMinY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        int width  = inRaster.getWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
        int height = inRaster.getHeight();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        if ((dstOffX < this.minX) || (dstOffY < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
            (dstOffX + width > this.maxX) || (dstOffY + height > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
        setDataElements(dstOffX, dstOffY, width, height, inRaster);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * Stores the Raster data at the specified location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * @param dstX The absolute X coordinate of the destination pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     * that will receive a copy of the upper-left pixel of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
     * inRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
     * @param dstY The absolute Y coordinate of the destination pixel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
     * that will receive a copy of the upper-left pixel of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
     * inRaster
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
     * @param width      The number of pixels to store horizontally
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * @param height     The number of pixels to store vertically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     * @param inRaster   Raster of data to place at x,y location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    private void setDataElements(int dstX, int dstY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                                 int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
                                 Raster inRaster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        // Assume bounds checking has been performed previously
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
        if (width <= 0 || height <= 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
        // Write inRaster (minX, minY) to (dstX, dstY)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
        int srcOffX = inRaster.getMinX();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
        int srcOffY = inRaster.getMinY();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
        Object tdata = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
//      // REMIND: Do something faster!
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
//      if (inRaster instanceof ShortComponentRaster) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
//      }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        for (int startY=0; startY < height; startY++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
            // Grab one scanline at a time
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            tdata = inRaster.getDataElements(srcOffX, srcOffY+startY,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                                             width, 1, tdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            setDataElements(dstX, dstY + startY, width, 1, tdata);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
     * Stores an array of data elements into the specified rectangular
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
     * region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
     * A ClassCastException will be thrown if the input object is non null
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
     * and references anything other than an array of transferType.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
     * The data elements in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
     * data array are assumed to be packed.  That is, a data element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
     * for the nth band at location (x2, y2) would be found at:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
     *      inData[((y2-y)*w + (x2-x))*numDataElements + n]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
     * @param y        The Y coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
     * @param w        Width of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
     * @param h        Height of the pixel rectangle.
30948
0a0972d3b58d 6587235: Incorrect javadoc: "no parameter" in 2d source code
serb
parents: 25859
diff changeset
   556
     * @param obj      An object reference to an array of type defined by
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
     *                 getTransferType() and length w*h*getNumDataElements()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
     *                 containing the pixel data to place between x,y and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
     *                 x+h, y+h.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    public void setDataElements(int x, int y, int w, int h, Object obj) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
        short inData[] = (short[])obj;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
                for (int c = 0; c < numDataElements; c++) {
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 18246
diff changeset
   579
                    data[dataOffsets[c] + xoff] = inData[off++];
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
     * Stores a short integer array of data elements into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
     * specified rectangular region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
     * The data elements in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
     * data array are assumed to be packed.  That is, a data element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
     * at location (x2, y2) would be found at:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
     *      inData[((y2-y)*w + (x2-x))]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
     * @param y        The Y coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
     * @param w        Width of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
     * @param h        Height of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
     * @param band     The band to set.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
     * @param inData   The data elements to be stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    public void putShortData(int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
                             int band, short[] inData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
        // Bounds check for 'band' will be performed automatically
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
        int yoff =  (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
                    (x-minX)*pixelStride + dataOffsets[band];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
        if (pixelStride == 1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
            if (scanlineStride == w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                System.arraycopy(inData, 0, data, yoff, w*h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                    System.arraycopy(inData, off, data, yoff, w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                    off += w;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
                xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
                for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
                    data[xoff] = inData[off++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
     * Stores a short integer array of data elements into the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
     * specified rectangular region.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
     * An ArrayIndexOutOfBounds exception will be thrown at runtime
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
     * if the pixel coordinates are out of bounds.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
     * The data elements in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
     * data array are assumed to be packed.  That is, a data element
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
     * for the nth band at location (x2, y2) would be found at:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
     * <pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
     *      inData[((y2-y)*w + (x2-x))*numDataElements + n]
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
     * </pre>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
     * @param x        The X coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
     * @param y        The Y coordinate of the upper left pixel location.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
     * @param w        Width of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
     * @param h        Height of the pixel rectangle.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
     * @param inData   The data elements to be stored.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    public void putShortData(int x, int y, int w, int h, short[] inData) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
        if ((x < this.minX) || (y < this.minY) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
            (x + w > this.maxX) || (y + h > this.maxY)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
            throw new ArrayIndexOutOfBoundsException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
                ("Coordinate out of bounds!");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
        int yoff = (y-minY)*scanlineStride +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
                   (x-minX)*pixelStride;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        int xoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
        int off = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        int xstart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        int ystart;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
        for (ystart=0; ystart < h; ystart++, yoff += scanlineStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            xoff = yoff;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
            for (xstart=0; xstart < w; xstart++, xoff += pixelStride) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
                for (int c = 0; c < numDataElements; c++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
                    data[dataOffsets[c] + xoff] = inData[off++];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
        markDirty();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
     * Creates a subraster given a region of the raster.  The x and y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
     * coordinates specify the horizontal and vertical offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
     * from the upper-left corner of this raster to the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
     * of the subraster.  A subset of the bands of the parent Raster may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
     * be specified.  If this is null, then all the bands are present in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
     * subRaster. A translation to the subRaster may also be specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
     * Note that the subraster will reference the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
     * band objects as the parent raster, but using different offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
     * @param x               X offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
     * @param y               Y offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
     * @param width           Width (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
     * @param height          Height (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
     * @param x0              Translated X origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
     * @param y0              Translated Y origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
     * @param bandList        Array of band indices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
     * @exception RasterFormatException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
     *            if the specified bounding box is outside of the parent raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    public Raster createChild (int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
                               int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
                               int x0, int y0, int[] bandList) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
        WritableRaster newRaster = createWritableChild(x, y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
                                                       width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
                                                       x0, y0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
                                                       bandList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
        return (Raster) newRaster;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
     * Creates a Writable subRaster given a region of the Raster. The x and y
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
     * coordinates specify the horizontal and vertical offsets
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
     * from the upper-left corner of this Raster to the upper-left corner
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
     * of the subRaster.  A subset of the bands of the parent Raster may
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
     * be specified.  If this is null, then all the bands are present in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
     * subRaster. A translation to the subRaster may also be specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
     * Note that the subRaster will reference the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
     * DataBuffers as the parent Raster, but using different offsets.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
     * @param x               X offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
     * @param y               Y offset.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
     * @param width           Width (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
     * @param height          Height (in pixels) of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
     * @param x0              Translated X origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
     * @param y0              Translated Y origin of the subraster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
     * @param bandList        Array of band indices.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
     * @exception RasterFormatException
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
     *            if the specified bounding box is outside of the parent Raster.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    public WritableRaster createWritableChild(int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
                                              int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
                                              int x0, int y0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
                                              int[] bandList) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
        if (x < this.minX) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
            throw new RasterFormatException("x lies outside the raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
        if (y < this.minY) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
            throw new RasterFormatException("y lies outside the raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
        if ((x+width < x) || (x+width > this.minX + this.width)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
            throw new RasterFormatException("(x + width) is outside of Raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
        if ((y+height < y) || (y+height > this.minY + this.height)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
            throw new RasterFormatException("(y + height) is outside of Raster");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
        SampleModel sm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
        if (bandList != null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
            sm = sampleModel.createSubsetSampleModel(bandList);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
            sm = sampleModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
        int deltaX = x0 - x;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
        int deltaY = y0 - y;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
        return new ShortComponentRaster(sm,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
                                       dataBuffer,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
                                       new Rectangle(x0, y0, width, height),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
                                       new Point(sampleModelTranslateX+deltaX,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
                                                 sampleModelTranslateY+deltaY),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
                                       this);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
     * Creates a Raster with the same layout but using a different
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
     * width and height, and with new zeroed data arrays.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
    public WritableRaster createCompatibleWritableRaster(int w, int h) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
        if (w <= 0 || h <=0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
            throw new RasterFormatException("negative "+
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
                                          ((w <= 0) ? "width" : "height"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
        SampleModel sm = sampleModel.createCompatibleSampleModel(w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
        return new ShortComponentRaster(sm, new Point(0, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
     * Creates a Raster with the same layout and the same
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
     * width and height, and with new zeroed data arrays.  If
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
     * the Raster is a subRaster, this will call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
     * createCompatibleRaster(width, height).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
    public WritableRaster createCompatibleWritableRaster() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
        return createCompatibleWritableRaster(width,height);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    /**
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   794
     * Verify that the layout parameters are consistent with the data.
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   795
     *
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   796
     * The method verifies whether scanline stride and pixel stride do not
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   797
     * cause an integer overflow during calculation of a position of the pixel
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   798
     * in data buffer. It also verifies whether the data buffer has enough data
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   799
     *  to correspond the raster layout attributes.
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   800
     *
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   801
     * @throws RasterFormatException if an integer overflow is detected,
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   802
     * or if data buffer has not enough capacity.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
     */
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   804
    protected final void verify() {
16868
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   805
        /* Need to re-verify the dimensions since a sample model may be
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   806
         * specified to the constructor
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   807
         */
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   808
        if (width <= 0 || height <= 0 ||
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   809
            height > (Integer.MAX_VALUE / width))
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   810
        {
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   811
            throw new RasterFormatException("Invalid raster dimension");
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   812
        }
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   813
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   814
        for (int i = 0; i < dataOffsets.length; i++) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
            if (dataOffsets[i] < 0) {
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   816
                throw new RasterFormatException("Data offsets for band " + i
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   817
                            + "(" + dataOffsets[i]
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   818
                            + ") must be >= 0");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
25090
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   822
        if ((long)minX - sampleModelTranslateX < 0 ||
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   823
            (long)minY - sampleModelTranslateY < 0) {
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   824
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   825
            throw new RasterFormatException("Incorrect origin/translate: (" +
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   826
                    minX + ", " + minY + ") / (" +
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   827
                    sampleModelTranslateX + ", " + sampleModelTranslateY + ")");
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   828
        }
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   829
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   830
        // we can be sure that width and height are greater than 0
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   831
        if (scanlineStride < 0 ||
25090
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   832
            scanlineStride > (Integer.MAX_VALUE / height))
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   833
        {
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   834
            // integer overflow
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   835
            throw new RasterFormatException("Incorrect scanline stride: "
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   836
                    + scanlineStride);
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   837
        }
25090
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   838
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   839
        if (height > 1 || minY - sampleModelTranslateY > 0) {
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   840
            // buffer should contain at least one scanline
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   841
            if (scanlineStride > data.length) {
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   842
                throw new RasterFormatException("Incorrect scanline stride: "
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   843
                        + scanlineStride);
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   844
            }
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   845
        }
83a78ff886e6 8038000: java.awt.image.RasterFormatException: Incorrect scanline stride
anashaty
parents: 22584
diff changeset
   846
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   847
        int lastScanOffset = (height - 1) * scanlineStride;
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   848
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   849
        if (pixelStride < 0 ||
18246
5d1d50a81438 8012438: Better image validation
bae
parents: 18226
diff changeset
   850
            pixelStride > (Integer.MAX_VALUE / width) ||
5d1d50a81438 8012438: Better image validation
bae
parents: 18226
diff changeset
   851
            pixelStride > data.length)
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   852
        {
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   853
            // integer overflow
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   854
            throw new RasterFormatException("Incorrect pixel stride: "
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   855
                    + pixelStride);
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   856
        }
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   857
        int lastPixelOffset = (width - 1) * pixelStride;
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   858
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   859
        if (lastPixelOffset > (Integer.MAX_VALUE - lastScanOffset)) {
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   860
            // integer overflow
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   861
            throw new RasterFormatException("Incorrect raster attributes");
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   862
        }
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   863
        lastPixelOffset += lastScanOffset;
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   864
18226
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   865
        int index;
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   866
        int maxIndex = 0;
16093
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   867
        for (int i = 0; i < numDataElements; i++) {
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   868
            if (dataOffsets[i] > (Integer.MAX_VALUE - lastPixelOffset)) {
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   869
                throw new RasterFormatException("Incorrect band offset: "
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   870
                            + dataOffsets[i]);
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   871
            }
b305a8dc867f 8001972: Improve image processing
bae
parents: 5506
diff changeset
   872
18226
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   873
            index = lastPixelOffset + dataOffsets[i];
16868
b5e2827ecc50 8007014: Improve image handling
bae
parents: 16093
diff changeset
   874
18226
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   875
            if (index > maxIndex) {
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   876
                maxIndex = index;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
        }
18226
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   879
        if (data.length <= maxIndex) {
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   880
            throw new RasterFormatException("Data array too small (should be > "
5d1f8fdc54d8 8011253: Better Short Component Rasters
prr
parents: 16868
diff changeset
   881
                    + maxIndex + " )");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
        return new String ("ShortComponentRaster: width = "+width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
                           +" height = " + height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
                           +" #numDataElements "+numDataElements);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
                           // +" xOff = "+xOffset+" yOff = "+yOffset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
}