< prev index next >
src/java.desktop/share/classes/java/awt/image/ComponentSampleModel.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -74,11 +74,11 @@
*/
public class ComponentSampleModel extends SampleModel
{
/** Offsets for all bands in data array elements. */
- protected int bandOffsets[];
+ protected int[] bandOffsets;
/** Index for each bank storing a band of image data. */
protected int[] bankIndices;
/**
@@ -134,11 +134,11 @@
*/
public ComponentSampleModel(int dataType,
int w, int h,
int pixelStride,
int scanlineStride,
- int bandOffsets[]) {
+ int[] bandOffsets) {
super(dataType, w, h, bandOffsets.length);
this.dataType = dataType;
this.pixelStride = pixelStride;
this.scanlineStride = scanlineStride;
this.bandOffsets = bandOffsets.clone();
@@ -197,12 +197,12 @@
*/
public ComponentSampleModel(int dataType,
int w, int h,
int pixelStride,
int scanlineStride,
- int bankIndices[],
- int bandOffsets[]) {
+ int[] bankIndices,
+ int[] bandOffsets) {
super(dataType, w, h, bandOffsets.length);
this.dataType = dataType;
this.pixelStride = pixelStride;
this.scanlineStride = scanlineStride;
this.bandOffsets = bandOffsets.clone();
@@ -290,13 +290,13 @@
}
/**
* Preserves band ordering with new step factor...
*/
- int []orderBands(int orig[], int step) {
- int map[] = new int[orig.length];
- int ret[] = new int[orig.length];
+ int []orderBands(int[] orig, int step) {
+ int[] map = new int[orig.length];
+ int[] ret = new int[orig.length];
for (int i=0; i<map.length; i++) map[i] = i;
for (int i = 0; i < ret.length; i++) {
int index = i;
@@ -332,11 +332,11 @@
maxBandOff = Math.max(maxBandOff,bandOffsets[i]);
}
maxBandOff -= minBandOff;
int bands = bandOffsets.length;
- int bandOff[];
+ int[] bandOff;
int pStride = Math.abs(pixelStride);
int lStride = Math.abs(scanlineStride);
int bStride = Math.abs(maxBandOff);
if (pStride > lStride) {
@@ -400,17 +400,17 @@
* @param bands a subset of bands from this
* {@code ComponentSampleModel}
* @return a {@code ComponentSampleModel} created with a subset
* of bands from this {@code ComponentSampleModel}.
*/
- public SampleModel createSubsetSampleModel(int bands[]) {
+ public SampleModel createSubsetSampleModel(int[] bands) {
if (bands.length > bankIndices.length)
throw new RasterFormatException("There are only " +
bankIndices.length +
" bands");
- int newBankIndices[] = new int[bands.length];
- int newBandOffsets[] = new int[bands.length];
+ int[] newBankIndices = new int[bands.length];
+ int[] newBandOffsets = new int[bands.length];
for (int i=0; i<bands.length; i++) {
newBankIndices[i] = bankIndices[bands[i]];
newBandOffsets[i] = bandOffsets[bands[i]];
}
@@ -497,11 +497,11 @@
* @return an array containing the number of bits per sample
* for all bands, where each element in the array
* represents a band.
*/
public final int[] getSampleSize() {
- int sampleSize[] = new int [numBands];
+ int[] sampleSize = new int [numBands];
int sizeInBits = getSampleSize(0);
for (int i=0; i<numBands; i++)
sampleSize[i] = sizeInBits;
@@ -726,16 +726,16 @@
*
* @throws NullPointerException if data is null.
* @throws ArrayIndexOutOfBoundsException if the coordinates are
* not in bounds, or if iArray is too small to hold the output.
*/
- public int[] getPixel(int x, int y, int iArray[], DataBuffer data) {
+ public int[] getPixel(int x, int y, int[] iArray, DataBuffer data) {
if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
- int pixels[];
+ int[] pixels;
if (iArray != null) {
pixels = iArray;
} else {
pixels = new int [numBands];
}
@@ -760,21 +760,21 @@
* @param data The DataBuffer containing the image data
* @return the samples of the pixels within the specified region.
* @see #setPixels(int, int, int, int, int[], DataBuffer)
*/
public int[] getPixels(int x, int y, int w, int h,
- int iArray[], DataBuffer data) {
+ int[] iArray, DataBuffer data) {
int x1 = x + w;
int y1 = y + h;
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
y < 0 || y >= height || y > height || y1 < 0 || y1 > height)
{
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
- int pixels[];
+ int[] pixels;
if (iArray != null) {
pixels = iArray;
} else {
pixels = new int [w*h*numBands];
}
@@ -884,17 +884,17 @@
* @param data the {@code DataBuffer} containing the image data
* @return the samples in the specified band of the specified pixel
* @see #setSamples(int, int, int, int, int, int[], DataBuffer)
*/
public int[] getSamples(int x, int y, int w, int h, int b,
- int iArray[], DataBuffer data) {
+ int[] iArray, DataBuffer data) {
// Bounds check for 'b' will be performed automatically
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
- int samples[];
+ int[] samples;
if (iArray != null) {
samples = iArray;
} else {
samples = new int [w*h];
}
@@ -1025,11 +1025,11 @@
* @param y The Y coordinate of the pixel location
* @param iArray The input samples in an int array
* @param data The DataBuffer containing the image data
* @see #getPixel(int, int, int[], DataBuffer)
*/
- public void setPixel(int x, int y, int iArray[], DataBuffer data) {
+ public void setPixel(int x, int y, int[] iArray, DataBuffer data) {
if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
int pixelOffset = y*scanlineStride + x*pixelStride;
@@ -1051,11 +1051,11 @@
* @param iArray The input samples in an int array
* @param data The DataBuffer containing the image data
* @see #getPixels(int, int, int, int, int[], DataBuffer)
*/
public void setPixels(int x, int y, int w, int h,
- int iArray[], DataBuffer data) {
+ int[] iArray, DataBuffer data) {
int x1 = x + w;
int y1 = y + h;
if (x < 0 || x >= width || w > width || x1 < 0 || x1 > width ||
y < 0 || y >= height || h > height || y1 < 0 || y1 > height)
@@ -1166,11 +1166,11 @@
* @param iArray The input samples in an int array
* @param data The DataBuffer containing the image data
* @see #getSamples(int, int, int, int, int, int[], DataBuffer)
*/
public void setSamples(int x, int y, int w, int h, int b,
- int iArray[], DataBuffer data) {
+ int[] iArray, DataBuffer data) {
// Bounds check for 'b' will be performed automatically
if ((x < 0) || (y < 0) || (x + w > width) || (y + h > height)) {
throw new ArrayIndexOutOfBoundsException
("Coordinate out of bounds!");
}
< prev index next >