Skip to content
Permalink
Browse files
8255800: Raster creation methods need some specification clean up
Reviewed-by: serb
  • Loading branch information
Phil Race committed Apr 7, 2021
1 parent eab8455 commit adb860ec1004f6034864a0c518ad2a23d36ab6bc
@@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@@ -78,8 +78,13 @@
* @param h The height (in pixels) of the region of image
* data described.
* @param numBands The number of bands for the image data.
* @throws IllegalArgumentException if {@code w} and {@code h}
* are not both greater than 0
* @throws IllegalArgumentException if the product of {@code w}
* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code numBands} is not > 0
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types
* one of the supported data types for this sample model.
*/
public BandedSampleModel(int dataType, int w, int h, int numBands) {
super(dataType, w, h, 1, w,
@@ -100,8 +105,21 @@ public BandedSampleModel(int dataType, int w, int h, int numBands) {
* @param scanlineStride The line stride of the of the image data.
* @param bankIndices The bank index for each band.
* @param bandOffsets The band offset for each band.
* @throws IllegalArgumentException if {@code w} and {@code h}
* are not both greater than 0
* @throws IllegalArgumentException if the product of {@code w}
* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
* @throws NullPointerException if {@code bankIndices} is {@code null}
* @throws NullPointerException if {@code bandOffsets} is {@code null}
* @throws IllegalArgumentException if {@code bandOffsets.length} is 0
* @throws IllegalArgumentException if the length of
* {@code bankIndices} does not equal the length of
* {@code bandOffsets}
* @throws IllegalArgumentException if any of the bank indices
* of {@code bandIndices} is less than 0
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types
* one of the supported data types for this sample model
*/
public BandedSampleModel(int dataType,
int w, int h,
@@ -853,6 +871,9 @@ public void setSamples(int x, int y, int w, int h, int b,
}

private static int[] createOffsetArray(int numBands) {
if (numBands <= 0) {
throw new IllegalArgumentException("numBands must be > 0");
}
int[] bandOffsets = new int[numBands];
for (int i=0; i < numBands; i++) {
bandOffsets[i] = 0;
@@ -861,6 +882,9 @@ public void setSamples(int x, int y, int w, int h, int b,
}

private static int[] createIndicesArray(int numBands) {
if (numBands <= 0) {
throw new IllegalArgumentException("numBands must be > 0");
}
int[] bankIndices = new int[numBands];
for (int i=0; i < numBands; i++) {
bankIndices[i] = i;
@@ -118,19 +118,16 @@
* @param scanlineStride the line stride of the region of image
* data described
* @param bandOffsets the offsets of all bands
* @throws IllegalArgumentException if {@code w} or
* {@code h} is not greater than 0
* @throws IllegalArgumentException if {@code pixelStride}
* is less than 0
* @throws IllegalArgumentException if {@code scanlineStride}
* is less than 0
* @throws IllegalArgumentException if {@code numBands}
* is less than 1
* @throws IllegalArgumentException if {@code w} and {@code h}
* are not both greater than 0
* @throws IllegalArgumentException if the product of {@code w}
* and {@code h} is greater than
* {@code Integer.MAX_VALUE}
* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
* @throws NullPointerException if {@code bandOffsets} is {@code null}
* @throws IllegalArgumentException if {@code bandOffsets.length} is 0
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types
* one of the supported data types for this sample model.
*/
public ComponentSampleModel(int dataType,
int w, int h,
@@ -150,9 +147,6 @@ public ComponentSampleModel(int dataType,
if (scanlineStride < 0) {
throw new IllegalArgumentException("Scanline stride must be >= 0");
}
if (numBands < 1) {
throw new IllegalArgumentException("Must have at least one band.");
}
if ((dataType < DataBuffer.TYPE_BYTE) ||
(dataType > DataBuffer.TYPE_DOUBLE)) {
throw new IllegalArgumentException("Unsupported dataType.");
@@ -181,19 +175,22 @@ public ComponentSampleModel(int dataType,
* data described
* @param bankIndices the bank indices of all bands
* @param bandOffsets the band offsets of all bands
* @throws IllegalArgumentException if {@code w} or
* {@code h} is not greater than 0
* @throws IllegalArgumentException if {@code pixelStride}
* is less than 0
* @throws IllegalArgumentException if {@code scanlineStride}
* is less than 0
* @throws IllegalArgumentException if {@code w} and {@code h}
* are not both greater than 0
* @throws IllegalArgumentException if the product of {@code w}
* and {@code h} is greater than {@code Integer.MAX_VALUE}
* @throws IllegalArgumentException if {@code pixelStride} is less than 0
* @throws IllegalArgumentException if {@code scanlineStride} is less than 0
* @throws NullPointerException if {@code bankIndices} is {@code null}
* @throws NullPointerException if {@code bandOffsets} is {@code null}
* @throws IllegalArgumentException if {@code bandOffsets.length} is 0
* @throws IllegalArgumentException if the length of
* {@code bankIndices} does not equal the length of
* {@code bankOffsets}
* {@code bandOffsets}
* @throws IllegalArgumentException if any of the bank indices
* of {@code bandIndices} is less than 0
* @throws IllegalArgumentException if {@code dataType} is not
* one of the supported data types
* one of the supported data types for this sample model
*/
public ComponentSampleModel(int dataType,
int w, int h,
@@ -207,6 +204,10 @@ public ComponentSampleModel(int dataType,
this.scanlineStride = scanlineStride;
this.bandOffsets = bandOffsets.clone();
this.bankIndices = bankIndices.clone();
if (this.bandOffsets.length != this.bankIndices.length) {
throw new IllegalArgumentException("Length of bandOffsets must "+
"equal length of bankIndices.");
}
if (pixelStride < 0) {
throw new IllegalArgumentException("Pixel stride must be >= 0");
}
@@ -235,10 +236,6 @@ else if (this.bankIndices[i] < 0) {
}
numBanks = maxBank+1;
numBands = this.bandOffsets.length;
if (this.bandOffsets.length != this.bankIndices.length) {
throw new IllegalArgumentException("Length of bandOffsets must "+
"equal length of bankIndices.");
}
verify();
}

1 comment on commit adb860e

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on adb860e Apr 7, 2021

Please sign in to comment.