You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/11/21 03:11:48 UTC
[commons-imaging] branch master updated: Use final.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
The following commit(s) were added to refs/heads/master by this push:
new 6b0d99d Use final.
6b0d99d is described below
commit 6b0d99dccdc6a7dad7d5a306c6878bd64e31c77e
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Fri Nov 20 22:11:42 2020 -0500
Use final.
---
.../commons/imaging/common/BinaryFunctions.java | 8 +-
.../commons/imaging/common/ImageBuilder.java | 12 +-
.../apache/commons/imaging/common/ZlibDeflate.java | 2 +-
.../commons/imaging/formats/gif/GifImageData.java | 2 +-
.../imaging/formats/gif/GifImageMetadata.java | 4 +-
.../imaging/formats/gif/GifImageMetadataItem.java | 2 +-
.../imaging/formats/gif/GifImageParser.java | 20 ++--
.../commons/imaging/formats/icns/IcnsDecoder.java | 16 +--
.../imaging/formats/jpeg/decoder/JpegDecoder.java | 8 +-
.../formats/jpeg/decoder/JpegInputStream.java | 2 +-
.../commons/imaging/formats/png/PngWriter.java | 2 +-
.../imaging/formats/tiff/TiffDirectory.java | 4 +-
.../imaging/formats/tiff/TiffImageData.java | 8 +-
.../imaging/formats/tiff/TiffImageParser.java | 10 +-
.../imaging/formats/tiff/TiffRasterData.java | 12 +-
.../imaging/formats/tiff/TiffRasterStatistics.java | 6 +-
.../commons/imaging/formats/tiff/TiffReader.java | 2 +-
.../tiff/constants/TiffPlanarConfiguration.java | 2 +-
.../formats/tiff/datareaders/DataReaderStrips.java | 24 ++--
.../formats/tiff/datareaders/DataReaderTiled.java | 20 ++--
.../formats/tiff/datareaders/ImageDataReader.java | 86 +++++++--------
.../PhotometricInterpreterLogLuv.java | 4 +-
.../floatingpoint/PaletteEntryForRange.java | 42 +++----
.../floatingpoint/PaletteEntryForValue.java | 10 +-
.../floatingpoint/PhotometricInterpreterFloat.java | 36 +++---
.../formats/tiff/write/TiffImageWriterBase.java | 16 +--
.../imaging/formats/xpm/XpmImageParser.java | 4 +-
.../imaging/palette/ColorCountComparator.java | 4 +-
.../commons/imaging/ImagingGuessFormatTest.java | 2 +-
.../org/apache/commons/imaging/TestImageInfo.java | 4 +-
.../commons/imaging/TestImageReadException.java | 4 +-
.../commons/imaging/TestImageWriteException.java | 8 +-
.../apache/commons/imaging/color/ColorCmyTest.java | 4 +-
.../apache/commons/imaging/color/ColorHslTest.java | 4 +-
.../commons/imaging/common/ImageBuilderTest.java | 38 +++----
.../commons/imaging/common/RationalNumberTest.java | 2 +-
.../common/bytesource/ByteSourceDataTest.java | 6 +-
.../common/bytesource/ByteSourceImageTest.java | 2 +-
.../bytesource/ByteSourceInputStreamTest.java | 2 +-
.../tiff/ExampleReadFloatingPointData.java | 48 ++++----
.../examples/tiff/ReadAndRenderFloatingPoint.java | 32 +++---
.../imaging/examples/tiff/ReadTagsAndImages.java | 32 +++---
.../imaging/examples/tiff/SurveyTiffFile.java | 76 ++++++-------
.../imaging/examples/tiff/SurveyTiffFolder.java | 66 +++++------
.../imaging/formats/bmp/BmpImageParserTest.java | 6 +-
.../commons/imaging/formats/bmp/BmpReadTest.java | 8 +-
.../commons/imaging/formats/dcx/DcxReadTest.java | 6 +-
.../commons/imaging/formats/gif/GifReadTest.java | 32 +++---
.../commons/imaging/formats/icns/IcnsReadTest.java | 12 +-
.../commons/imaging/formats/ico/IcoReadTest.java | 6 +-
.../commons/imaging/formats/jpeg/JpegReadTest.java | 2 +-
.../formats/jpeg/decoder/JpegInputStreamTest.java | 8 +-
.../imaging/formats/jpeg/exif/ExifDumpTest.java | 4 +-
.../commons/imaging/formats/jpeg/exif/GpsTest.java | 2 +-
.../formats/jpeg/exif/SpecificExifTagTest.java | 2 +-
.../jpeg/exif/WriteExifMetadataExampleTest.java | 2 +-
.../imaging/formats/jpeg/iptc/IptcAddTest.java | 2 +-
.../imaging/formats/jpeg/iptc/IptcDumpTest.java | 2 +-
.../imaging/formats/jpeg/iptc/IptcParserTest.java | 6 +-
.../imaging/formats/jpeg/iptc/IptcUpdateTest.java | 12 +-
.../formats/jpeg/segments/App2SegmentTest.java | 8 +-
.../imaging/formats/jpeg/xmp/JpegXmpDumpTest.java | 2 +-
.../formats/jpeg/xmp/JpegXmpRewriteTest.java | 2 +-
.../formats/png/chunks/PngChunkIccpTest.java | 8 +-
.../imaging/formats/pnm/PgmFileInfoTest.java | 2 +-
.../formats/tiff/TiffAlphaRoundTripTest.java | 22 ++--
.../formats/tiff/TiffFloatingPointReadTest.java | 50 ++++-----
.../tiff/TiffFloatingPointRoundTripTest.java | 122 ++++++++++-----------
.../imaging/formats/tiff/TiffRasterDataTest.java | 54 ++++-----
.../formats/tiff/TiffRasterStatisticsTest.java | 6 +-
.../imaging/formats/tiff/TiffReadAlphaTest.java | 24 ++--
.../commons/imaging/formats/tiff/TiffReadTest.java | 10 +-
.../imaging/formats/tiff/TiffSubImageTest.java | 34 +++---
.../tiff/fieldtypes/FieldTypeAsciiTest.java | 22 ++--
.../tiff/fieldtypes/FieldTypeRationalTest.java | 10 +-
.../PhotometricInterpreterLogLuvTest.java | 18 +--
.../PhotometricInterpreterRgbTest.java | 16 +--
.../floatingpoint/PaletteEntryForRangeTest.java | 54 ++++-----
.../floatingpoint/PaletteEntryForValueTest.java | 16 +--
.../PhotometricInterpreterFloatTest.java | 70 ++++++------
.../tiff/taginfos/TagInfoByteOrShortTest.java | 20 ++--
.../commons/imaging/palette/DitheringTest.java | 16 +--
.../commons/imaging/roundtrip/RoundtripBase.java | 2 +-
83 files changed, 699 insertions(+), 699 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
index 3c67c18..bc39ccf 100644
--- a/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
+++ b/src/main/java/org/apache/commons/imaging/common/BinaryFunctions.java
@@ -275,8 +275,8 @@ public final class BinaryFunctions {
* @param quad quad
* @return a byte array
*/
- public static byte[] quadsToByteArray(int quad) {
- byte[] arr = new byte[4];
+ public static byte[] quadsToByteArray(final int quad) {
+ final byte[] arr = new byte[4];
arr[0] = (byte) (quad >> 24);
arr[1] = (byte) (quad >> 16);
arr[2] = (byte) (quad >> 8);
@@ -295,8 +295,8 @@ public final class BinaryFunctions {
* @return {@code true} if it found the quad, and {@code false} otherwise
* @throws IOException if it fails to read from the given input stream
*/
- public static boolean searchQuad(int quad, InputStream bis) throws IOException {
- byte[] needle = BinaryFunctions.quadsToByteArray(quad);
+ public static boolean searchQuad(final int quad, final InputStream bis) throws IOException {
+ final byte[] needle = BinaryFunctions.quadsToByteArray(quad);
int b = -1;
int position = 0;
while ((b = bis.read()) != -1) {
diff --git a/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java b/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
index 1d56b52..6d2865d 100644
--- a/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
+++ b/src/main/java/org/apache/commons/imaging/common/ImageBuilder.java
@@ -93,7 +93,7 @@ public class ImageBuilder {
*
*/
public ImageBuilder(final int width, final int height,
- final boolean hasAlpha, boolean isAlphaPremultiplied) {
+ final boolean hasAlpha, final boolean isAlphaPremultiplied) {
checkDimensions(width, height);
data = new int[width * height];
this.width = width;
@@ -102,7 +102,7 @@ public class ImageBuilder {
this.isAlphaPremultiplied = isAlphaPremultiplied;
}
- private void checkDimensions(int width, int height) {
+ private void checkDimensions(final int width, final int height) {
if (width <= 0) {
throw new RasterFormatException("zero or negative width value");
}
@@ -173,7 +173,7 @@ public class ImageBuilder {
* @param w the width of the specified rectangular region
* @param h the height of the specified rectangular region
*/
- private void checkBounds(int x, int y, int w, int h) {
+ private void checkBounds(final int x, final int y, final int w, final int h) {
if (w <= 0) {
throw new RasterFormatException("negative or zero subimage width");
}
@@ -215,10 +215,10 @@ public class ImageBuilder {
*/
public ImageBuilder getSubset(final int x, final int y, final int w, final int h) {
checkBounds(x, y, w, h);
- ImageBuilder b = new ImageBuilder(w, h, hasAlpha, isAlphaPremultiplied);
+ final ImageBuilder b = new ImageBuilder(w, h, hasAlpha, isAlphaPremultiplied);
for(int i=0; i<h; i++){
- int srcDex = (i+y)*width+x;
- int outDex = i*w;
+ final int srcDex = (i+y)*width+x;
+ final int outDex = i*w;
System.arraycopy(data, srcDex, b.data, outDex, w);
}
return b;
diff --git a/src/main/java/org/apache/commons/imaging/common/ZlibDeflate.java b/src/main/java/org/apache/commons/imaging/common/ZlibDeflate.java
index 3667cff..cf676a8 100644
--- a/src/main/java/org/apache/commons/imaging/common/ZlibDeflate.java
+++ b/src/main/java/org/apache/commons/imaging/common/ZlibDeflate.java
@@ -70,7 +70,7 @@ public class ZlibDeflate {
* @see DeflaterOutputStream
*/
public static byte[] compress(final byte[] bytes) throws ImageWriteException {
- ByteArrayOutputStream out = new ByteArrayOutputStream(bytes.length / 2);
+ final ByteArrayOutputStream out = new ByteArrayOutputStream(bytes.length / 2);
try (DeflaterOutputStream compressOut = new DeflaterOutputStream(out)) {
compressOut.write(bytes);
} catch (final IOException e) {
diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageData.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageData.java
index 34378fd..210ad59 100644
--- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageData.java
+++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageData.java
@@ -20,7 +20,7 @@ class GifImageData {
final ImageDescriptor descriptor;
final GraphicControlExtension gce;
- GifImageData(ImageDescriptor descriptor, GraphicControlExtension gce) {
+ GifImageData(final ImageDescriptor descriptor, final GraphicControlExtension gce) {
this.descriptor = descriptor;
this.gce = gce;
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadata.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadata.java
index f734ffc..2726ad4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadata.java
+++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadata.java
@@ -28,7 +28,7 @@ public class GifImageMetadata implements ImageMetadata {
private final int height;
private final List<GifImageMetadataItem> items;
- GifImageMetadata(int width, int height, List<GifImageMetadataItem> items) {
+ GifImageMetadata(final int width, final int height, final List<GifImageMetadataItem> items) {
this.width = width;
this.height = height;
this.items = Collections.unmodifiableList(new ArrayList<>(items));
@@ -43,7 +43,7 @@ public class GifImageMetadata implements ImageMetadata {
result.append(String.format("%sHeight: %d%s", prefix, height, NEWLINE));
result.append(NEWLINE);
result.append(String.format("%sImages:", prefix));
- for (GifImageMetadataItem item : items) {
+ for (final GifImageMetadataItem item : items) {
result.append(NEWLINE);
result.append(item.toString(prefix));
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadataItem.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadataItem.java
index ab423cd..1a894ac 100644
--- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadataItem.java
+++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageMetadataItem.java
@@ -25,7 +25,7 @@ public class GifImageMetadataItem implements ImageMetadata.ImageMetadataItem {
private final int topPosition;
private final DisposalMethod disposalMethod;
- GifImageMetadataItem(int delay, int leftPosition, int topPosition, DisposalMethod disposalMethod) {
+ GifImageMetadataItem(final int delay, final int leftPosition, final int topPosition, final DisposalMethod disposalMethod) {
this.delay = delay;
this.leftPosition = leftPosition;
this.topPosition = topPosition;
diff --git a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
index 84e6fc1..ce7503d 100644
--- a/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
@@ -510,7 +510,7 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
}
// Made internal for testability.
- static DisposalMethod createDisposalMethodFromIntValue(int value) throws ImageReadException {
+ static DisposalMethod createDisposalMethodFromIntValue(final int value) throws ImageReadException {
switch (value) {
case 0:
return DisposalMethod.UNSPECIFIED;
@@ -548,9 +548,9 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
}
final List<GifImageData> imageData = findAllImageData(imageContents);
- List<GifImageMetadataItem> metadataItems = new ArrayList<>(imageData.size());
- for(GifImageData id : imageData) {
- DisposalMethod disposalMethod = createDisposalMethodFromIntValue(id.gce.dispose);
+ final List<GifImageMetadataItem> metadataItems = new ArrayList<>(imageData.size());
+ for(final GifImageData id : imageData) {
+ final DisposalMethod disposalMethod = createDisposalMethodFromIntValue(id.gce.dispose);
metadataItems.add(new GifImageMetadataItem(id.gce.delay, id.descriptor.imageLeftPosition, id.descriptor.imageTopPosition, disposalMethod));
}
return new GifImageMetadata(bhi.logicalScreenWidth, bhi.logicalScreenHeight, metadataItems);
@@ -692,7 +692,7 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
return result;
}
- private List<GifImageData> findAllImageData(GifImageContents imageContents) throws ImageReadException {
+ private List<GifImageData> findAllImageData(final GifImageContents imageContents) throws ImageReadException {
final List<ImageDescriptor> descriptors = findAllBlocks(imageContents.blocks, IMAGE_SEPARATOR);
if (descriptors.isEmpty()) {
@@ -705,7 +705,7 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
throw new ImageReadException("GIF: Invalid amount of Graphic Control Extensions");
}
- List<GifImageData> imageData = new ArrayList<>(descriptors.size());
+ final List<GifImageData> imageData = new ArrayList<>(descriptors.size());
for(int i = 0; i < descriptors.size(); i++) {
final ImageDescriptor descriptor = descriptors.get(i);
if (descriptor == null) {
@@ -720,7 +720,7 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
return imageData;
}
- private GifImageData findFirstImageData(GifImageContents imageContents) throws ImageReadException {
+ private GifImageData findFirstImageData(final GifImageContents imageContents) throws ImageReadException {
final ImageDescriptor descriptor = (ImageDescriptor) findBlock(imageContents.blocks,
IMAGE_SEPARATOR);
@@ -734,7 +734,7 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
return new GifImageData(descriptor, gce);
}
- private BufferedImage getBufferedImage(GifHeaderInfo headerInfo, GifImageData imageData, byte[] globalColorTable)
+ private BufferedImage getBufferedImage(final GifHeaderInfo headerInfo, final GifImageData imageData, final byte[] globalColorTable)
throws ImageReadException {
final ImageDescriptor id = imageData.descriptor;
final GraphicControlExtension gce = imageData.gce;
@@ -827,8 +827,8 @@ public class GifImageParser extends ImageParser implements XmpEmbeddable {
}
final List<GifImageData> imageData = findAllImageData(imageContents);
- List<BufferedImage> result = new ArrayList<>(imageData.size());
- for(GifImageData id : imageData) {
+ final List<BufferedImage> result = new ArrayList<>(imageData.size());
+ for(final GifImageData id : imageData) {
result.add(getBufferedImage(ghi, id, imageContents.globalColorTable));
}
return result;
diff --git a/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java b/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
index c68b544..2e97496 100644
--- a/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
+++ b/src/main/java/org/apache/commons/imaging/formats/icns/IcnsDecoder.java
@@ -195,7 +195,7 @@ final class IcnsDecoder {
throws ImageReadException {
final List<BufferedImage> result = new ArrayList<>();
for (int i = 0; i < icnsElements.length; i++) {
- BufferedImage image = decodeImage(icnsElements, i);
+ final BufferedImage image = decodeImage(icnsElements, i);
if (image != null) {
result.add(image);
}
@@ -203,9 +203,9 @@ final class IcnsDecoder {
return result;
}
- public static BufferedImage decodeImage(final IcnsImageParser.IcnsElement[] icnsElements, int index)
+ public static BufferedImage decodeImage(final IcnsImageParser.IcnsElement[] icnsElements, final int index)
throws ImageReadException {
- IcnsImageParser.IcnsElement imageElement = icnsElements[index];
+ final IcnsImageParser.IcnsElement imageElement = icnsElements[index];
final IcnsType imageType = IcnsType.findImageType(imageElement.type);
if (imageType == null) {
return null;
@@ -226,11 +226,11 @@ final class IcnsDecoder {
BufferedImage image = null;
try {
image = Imaging.getBufferedImage(imageElement.data);
- } catch (Exception ex) {
+ } catch (final Exception ex) {
if (imageType.getWidth() <= 32) {
try {
image = decodeImageImpl(imageType, imageElement, icnsElements);
- } catch (Exception ignored) { }
+ } catch (final Exception ignored) { }
}
if (image == null) {
image = new BufferedImage(imageType.getWidth(), imageType.getHeight(), BufferedImage.TYPE_INT_ARGB);
@@ -242,9 +242,9 @@ final class IcnsDecoder {
return decodeImageImpl(imageType, imageElement, icnsElements);
}
- private static BufferedImage decodeImageImpl(IcnsType imageType,
- IcnsElement imageElement,
- IcnsElement[] icnsElements) throws ImageReadException {
+ private static BufferedImage decodeImageImpl(final IcnsType imageType,
+ final IcnsElement imageElement,
+ final IcnsElement[] icnsElements) throws ImageReadException {
final int expectedSize = (imageType.getWidth() * imageType.getHeight()
* imageType.getBitsPerPixel() + 7) / 8;
byte[] imageData;
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
index 7722067..6449020 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoder.java
@@ -113,7 +113,7 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
switch (sofnSegment.numberOfComponents) {
case 4:
colorModel = new DirectColorModel(24, 0x00ff0000, 0x0000ff00, 0x000000ff);
- int bandMasks[] = new int[] { 0x00ff0000, 0x0000ff00, 0x000000ff };
+ final int bandMasks[] = new int[] { 0x00ff0000, 0x0000ff00, 0x000000ff };
raster = Raster.createPackedRaster(DataBuffer.TYPE_INT, sofnSegment.width, sofnSegment.height, bandMasks, null);
break;
case 3:
@@ -441,9 +441,9 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
final List<Integer> intervalStarts = getIntervalStartPositions(scanPayload);
// get number of intervals in payload to init an array of appropriate length
final int intervalCount = intervalStarts.size();
- JpegInputStream[] streams = new JpegInputStream[intervalCount];
+ final JpegInputStream[] streams = new JpegInputStream[intervalCount];
for (int i = 0; i < intervalCount; i++) {
- int from = intervalStarts.get(i);
+ final int from = intervalStarts.get(i);
int to;
if (i < intervalCount - 1) {
// because each restart marker needs two bytes the end of
@@ -452,7 +452,7 @@ public class JpegDecoder extends BinaryFileParser implements JpegUtils.Visitor {
} else { // the last interval ends with the array
to = scanPayload.length;
}
- int[] interval = Arrays.copyOfRange(scanPayload, from, to);
+ final int[] interval = Arrays.copyOfRange(scanPayload, from, to);
streams[i] = new JpegInputStream(interval);
}
return streams;
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStream.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStream.java
index ee60cba..b95bef0 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStream.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStream.java
@@ -78,7 +78,7 @@ class JpegInputStream {
if (!this.hasNext()) {
throw new IllegalStateException("This stream hasn't any other value, all values were already read.");
}
- int value = this.interval[nextPos];
+ final int value = this.interval[nextPos];
this.nextPos++;
return value;
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java b/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
index 409f3a6..89333ad 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/PngWriter.java
@@ -561,7 +561,7 @@ class PngWriter {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final int chunkSize = 256 * 1024;
- Deflater deflater = new Deflater(compressionLevel);
+ final Deflater deflater = new Deflater(compressionLevel);
final DeflaterOutputStream dos = new DeflaterOutputStream(baos,deflater,chunkSize);
for (int index = 0; index < uncompressed.length; index += chunkSize) {
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
index 68acde5..207f554 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java
@@ -891,7 +891,7 @@ public class TiffDirectory extends TiffElement {
final Map<String, Object> params)
throws ImageReadException, IOException {
- TiffImageParser parser = new TiffImageParser();
+ final TiffImageParser parser = new TiffImageParser();
return parser.getFloatingPointRasterData(this, headerByteOrder, params);
}
@@ -906,7 +906,7 @@ public class TiffDirectory extends TiffElement {
*/
public boolean hasTiffFloatingPointRasterData() throws ImageReadException {
if (this.hasTiffImageData()) {
- short[] sSampleFmt = getFieldValue(
+ final short[] sSampleFmt = getFieldValue(
TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, false);
return sSampleFmt != null && sSampleFmt.length > 0
&& sSampleFmt[0] == TiffTagConstants.SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT;
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageData.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageData.java
index 1f4c43e..973561d 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageData.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageData.java
@@ -60,7 +60,7 @@ public abstract class TiffImageData {
final int compression,
final TiffPlanarConfiguration planarConfiguration,
final ByteOrder byteOrder) throws IOException, ImageReadException {
- int sampleFormat = extractSampleFormat(directory);
+ final int sampleFormat = extractSampleFormat(directory);
return new DataReaderTiled(directory, photometricInterpreter,
tileWidth, tileLength, bitsPerPixel, bitsPerSample,
predictor, samplesPerPixel, sampleFormat, width, height, compression,
@@ -129,7 +129,7 @@ public abstract class TiffImageData {
final int compression,
final TiffPlanarConfiguration planarConfiguration,
final ByteOrder byteorder) throws IOException, ImageReadException {
- int sampleFormat = extractSampleFormat(directory);
+ final int sampleFormat = extractSampleFormat(directory);
return new DataReaderStrips(directory, photometricInterpreter,
bitsPerPixel, bitsPerSample, predictor,
samplesPerPixel, sampleFormat, width, height,
@@ -184,8 +184,8 @@ public abstract class TiffImageData {
}
}
- private static int extractSampleFormat(TiffDirectory directory) throws ImageReadException {
- short[] sSampleFmt = directory.getFieldValue(
+ private static int extractSampleFormat(final TiffDirectory directory) throws ImageReadException {
+ final short[] sSampleFmt = directory.getFieldValue(
TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, false);
if (sSampleFmt != null && sSampleFmt.length > 0) {
return sSampleFmt[0];
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
index 0cd7b5c..b149c11 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java
@@ -564,7 +564,7 @@ public class TiffImageParser extends ImageParser implements XmpEmbeddable {
final int width = directory.getSingleFieldValue(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH);
final int height = directory.getSingleFieldValue(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH);
- Rectangle subImage = checkForSubImage(params);
+ final Rectangle subImage = checkForSubImage(params);
if (subImage != null) {
// Check for valid subimage specification. The following checks
// are consistent with BufferedImage.getSubimage()
@@ -638,14 +638,14 @@ public class TiffImageParser extends ImageParser implements XmpEmbeddable {
final TiffField extraSamplesField =
directory.findField(TiffTagConstants.TIFF_TAG_EXTRA_SAMPLES);
if (extraSamplesField != null) {
- int extraSamplesValue = extraSamplesField.getIntValue();
+ final int extraSamplesValue = extraSamplesField.getIntValue();
isAlphaPremultiplied =
(extraSamplesValue==TiffTagConstants.EXTRA_SAMPLE_ASSOCIATED_ALPHA);
}
}
PhotometricInterpreter photometricInterpreter;
- Object test = params == null
+ final Object test = params == null
? null
: params.get(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER);
if (test instanceof PhotometricInterpreter) {
@@ -810,7 +810,7 @@ public class TiffImageParser extends ImageParser implements XmpEmbeddable {
throw new ImageReadException("TIFF missing entries");
}
- short[] sSampleFmt = directory.getFieldValue(
+ final short[] sSampleFmt = directory.getFieldValue(
TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, true);
if (sSampleFmt[0] != TiffTagConstants.SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT) {
throw new ImageReadException("TIFF does not provide floating-point data");
@@ -912,7 +912,7 @@ public class TiffImageParser extends ImageParser implements XmpEmbeddable {
// The photometric interpreter is not used, but the image-based
// data reader classes require one. So we create a dummy interpreter.
- PhotometricInterpreter photometricInterpreter
+ final PhotometricInterpreter photometricInterpreter
= new PhotometricInterpreterBiLevel(samplesPerPixel,
bitsPerSample, predictor, width, height, false);
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java
index 80ce2cf..9574d59 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterData.java
@@ -34,12 +34,12 @@ public class TiffRasterData {
* @param width a value of 1 or greater
* @param height a value of 1 or greater
*/
- public TiffRasterData(int width, int height) {
+ public TiffRasterData(final int width, final int height) {
if (width <= 0 || height <= 0) {
throw new IllegalArgumentException(
"Raster dimensions less than or equal to zero are not supported");
}
- int nCells = width * height;
+ final int nCells = width * height;
data = new float[nCells];
this.width = width;
this.height = height;
@@ -53,7 +53,7 @@ public class TiffRasterData {
* @param height a value of 1 or greater
* @param data the data to be stored in the raster.
*/
- public TiffRasterData(int width, int height, float[] data) {
+ public TiffRasterData(final int width, final int height, final float[] data) {
if (width <= 0 || height <= 0) {
throw new IllegalArgumentException(
"Raster dimensions less than or equal to zero are not supported");
@@ -76,7 +76,7 @@ public class TiffRasterData {
* @param value the value to be stored at the specified location;
* potentially a Float.NaN.
*/
- public void setValue(int x, int y, float value) {
+ public void setValue(final int x, final int y, final float value) {
if (x < 0 || x >= width || y < 0 || y >= height) {
throw new IllegalArgumentException(
"Coordinates out of range (" + x + ", " + y + ")");
@@ -92,7 +92,7 @@ public class TiffRasterData {
* @return the value stored at the specified location; potentially a
* Float.NaN.
*/
- public float getValue(int x, int y) {
+ public float getValue(final int x, final int y) {
if (x < 0 || x >= width || y < 0 || y >= height) {
throw new IllegalArgumentException(
"Coordinates out of range (" + x + ", " + y + ")");
@@ -117,7 +117,7 @@ public class TiffRasterData {
* @param valueToExclude exclude samples with this specified value.
* @return a valid instance.
*/
- public TiffRasterStatistics getSimpleStatistics(float valueToExclude) {
+ public TiffRasterStatistics getSimpleStatistics(final float valueToExclude) {
return new TiffRasterStatistics(this, valueToExclude);
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatistics.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatistics.java
index e8a9a9d..c903cd9 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatistics.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatistics.java
@@ -36,16 +36,16 @@ public class TiffRasterStatistics {
* @param excludedValue an optional value to ignore; use Float.NaN if no
* value is to be ignored.
*/
- TiffRasterStatistics(TiffRasterData raster, float excludedValue) {
+ TiffRasterStatistics(final TiffRasterData raster, final float excludedValue) {
this.excludedValue = excludedValue;
float vMin = Float.POSITIVE_INFINITY;
float vMax = Float.NEGATIVE_INFINITY;
double vSum = 0;
int nS = 0;
int nN = 0;
- float[] data = raster.getData();
+ final float[] data = raster.getData();
for (int i = 0; i < data.length; i++) {
- float test = data[i];
+ final float test = data[i];
if (Float.isNaN(test)) {
nN++;
continue;
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
index 9be4c9c..48f0ed0 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffReader.java
@@ -390,7 +390,7 @@ public class TiffReader extends BinaryFileParser {
public TiffContents readDirectories(final ByteSource byteSource,
final boolean readImageData, final FormatCompliance formatCompliance)
throws ImageReadException, IOException {
- Map<String, Object> params = Collections.singletonMap(
+ final Map<String, Object> params = Collections.singletonMap(
ImagingConstants.PARAM_KEY_READ_THUMBNAILS, readImageData);
final Collector collector = new Collector(params);
readDirectories(byteSource, formatCompliance, collector);
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffPlanarConfiguration.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffPlanarConfiguration.java
index ac74f8b..d5b69e5 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffPlanarConfiguration.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffPlanarConfiguration.java
@@ -54,7 +54,7 @@ public enum TiffPlanarConfiguration {
* @param codeValue an integer code corresponding to the TIFF specification.
* @return a valid enumeration.
*/
- public static TiffPlanarConfiguration lenientValueOf(int codeValue) {
+ public static TiffPlanarConfiguration lenientValueOf(final int codeValue) {
switch (codeValue) {
case TiffTagConstants.PLANAR_CONFIGURATION_VALUE_CHUNKY:
return CHUNKY;
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
index 943b071..a25daa8 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderStrips.java
@@ -90,7 +90,7 @@ public final class DataReaderStrips extends ImageDataReader {
x = 0;
y += nRows;
final int[] samples = new int[1];
- int[] b = unpackFloatingPointSamples(
+ final int[] b = unpackFloatingPointSamples(
width, i1 - i0, width, bytes, predictor, bitsPerPixel, byteOrder);
for (int i = i0; i < i1; i++) {
@@ -310,7 +310,7 @@ public final class DataReaderStrips extends ImageDataReader {
yLimit);
}
} else {
- int nStripsInPlane = imageData.getImageDataLength() / 3;
+ final int nStripsInPlane = imageData.getImageDataLength() / 3;
for (int strip = strip0; strip <= strip1; strip++) {
final long rowsPerStripLong = 0xFFFFffffL & rowsPerStrip;
final long rowsRemaining = height - (strip * rowsPerStripLong);
@@ -319,9 +319,9 @@ public final class DataReaderStrips extends ImageDataReader {
final long bytesPerStrip = rowsInThisStrip * bytesPerRow;
final long pixelsPerStrip = rowsInThisStrip * width;
- byte[] b = new byte[(int) bytesPerStrip];
+ final byte[] b = new byte[(int) bytesPerStrip];
for (int iPlane = 0; iPlane < 3; iPlane++) {
- int planeStrip = iPlane * nStripsInPlane + strip;
+ final int planeStrip = iPlane * nStripsInPlane + strip;
final byte[] compressed = imageData.getImageData(planeStrip).getData();
final byte[] decompressed = decompress(compressed, compression,
(int) bytesPerStrip, width, (int) rowsInThisStrip);
@@ -352,7 +352,7 @@ public final class DataReaderStrips extends ImageDataReader {
}
@Override
- public TiffRasterData readRasterData(Rectangle subImage)
+ public TiffRasterData readRasterData(final Rectangle subImage)
throws ImageReadException, IOException {
int xRaster;
@@ -370,7 +370,7 @@ public final class DataReaderStrips extends ImageDataReader {
rasterWidth = width;
rasterHeight = height;
}
- float[] rasterData = new float[rasterWidth * rasterHeight];
+ final float[] rasterData = new float[rasterWidth * rasterHeight];
// the legacy code is optimized to the reading of whole
// strips (except for the last strip in the image, which can
@@ -383,17 +383,17 @@ public final class DataReaderStrips extends ImageDataReader {
final int strip1 = (yRaster + rasterHeight - 1) / rowsPerStrip;
for (int strip = strip0; strip <= strip1; strip++) {
- int yStrip = strip * rowsPerStrip;
- int rowsRemaining = height - yStrip;
- int rowsInThisStrip = Math.min(rowsRemaining, rowsPerStrip);
- int bytesPerRow = (bitsPerPixel * width + 7) / 8;
- int bytesPerStrip = rowsInThisStrip * bytesPerRow;
+ final int yStrip = strip * rowsPerStrip;
+ final int rowsRemaining = height - yStrip;
+ final int rowsInThisStrip = Math.min(rowsRemaining, rowsPerStrip);
+ final int bytesPerRow = (bitsPerPixel * width + 7) / 8;
+ final int bytesPerStrip = rowsInThisStrip * bytesPerRow;
final byte[] compressed = imageData.getImageData(strip).getData();
final byte[] decompressed = decompress(compressed, compression,
bytesPerStrip, width, rowsInThisStrip);
- int[] blockData = unpackFloatingPointSamples(
+ final int[] blockData = unpackFloatingPointSamples(
width, (int) rowsInThisStrip, width,
decompressed,
predictor, bitsPerPixel, byteOrder);
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
index fa43254..5d28e34 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/DataReaderTiled.java
@@ -98,14 +98,14 @@ public final class DataReaderTiled extends ImageDataReader {
j1 = xLimit;
}
final int[] samples = new int[4];
- int[] b = unpackFloatingPointSamples(
+ final int[] b = unpackFloatingPointSamples(
j1 - j0, i1 - i0, tileWidth, bytes,
predictor, bitsPerPixel, byteOrder);
for (int i = i0; i < i1; i++) {
- int row = i - startY;
- int rowOffset = row * tileWidth;
+ final int row = i - startY;
+ final int rowOffset = row * tileWidth;
for (int j = j0; j < j1; j++) {
- int column = j - startX;
+ final int column = j - startX;
samples[0] = b[rowOffset + column];
photometricInterpreter.interpretPixel(
imageBuilder, samples, j, i);
@@ -264,8 +264,8 @@ public final class DataReaderTiled extends ImageDataReader {
final byte[] compressed = imageData.tiles[tile].getData();
final byte[] decompressed = decompress(compressed, compression,
bytesPerTile, tileWidth, tileLength);
- int x = iCol * tileWidth - x0;
- int y = iRow * tileLength - y0;
+ final int x = iCol * tileWidth - x0;
+ final int y = iRow * tileLength - y0;
interpretTile(workingBuilder, decompressed, x, y, width, height);
}
}
@@ -305,7 +305,7 @@ public final class DataReaderTiled extends ImageDataReader {
rasterWidth = width;
rasterHeight = height;
}
- float[] rasterData = new float[rasterWidth * rasterHeight];
+ final float[] rasterData = new float[rasterWidth * rasterHeight];
// tileWidth is the width of the tile
// tileLength is the height of the tile
@@ -322,9 +322,9 @@ public final class DataReaderTiled extends ImageDataReader {
final byte[] compressed = imageData.tiles[tile].getData();
final byte[] decompressed = decompress(compressed, compression,
bytesPerTile, tileWidth, tileLength);
- int x = iCol * tileWidth;
- int y = iRow * tileLength;
- int[] blockData = unpackFloatingPointSamples(
+ final int x = iCol * tileWidth;
+ final int y = iRow * tileLength;
+ final int[] blockData = unpackFloatingPointSamples(
tileWidth, tileLength, tileWidth,
decompressed,
predictor, bitsPerPixel, byteOrder);
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java
index ade9052..40d57bc 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/datareaders/ImageDataReader.java
@@ -251,11 +251,11 @@ public abstract class ImageDataReader {
return samples;
}
- protected void applyPredictorToBlock(int width, int height, int nSamplesPerPixel, byte []p ){
+ protected void applyPredictorToBlock(final int width, final int height, final int nSamplesPerPixel, final byte []p ){
final int k = width*nSamplesPerPixel;
for(int i=0; i<height; i++){
- int j0 = i*k+nSamplesPerPixel;
- int j1 = (i+1)*k;
+ final int j0 = i*k+nSamplesPerPixel;
+ final int j1 = (i+1)*k;
for(int j=j0; j<j1; j++){
p[j]+=p[j-nSamplesPerPixel];
}
@@ -382,18 +382,18 @@ public abstract class ImageDataReader {
* @throws ImageReadException in the event of an invalid format.
*/
protected int[] unpackFloatingPointSamples(
- int width,
- int height,
- int scansize,
- byte[] bytes,
- int predictor,
- int bitsPerSample, ByteOrder byteOrder)
+ final int width,
+ final int height,
+ final int scansize,
+ final byte[] bytes,
+ final int predictor,
+ final int bitsPerSample, final ByteOrder byteOrder)
throws ImageReadException {
- int bytesPerSample = bitsPerSample / 8;
- int nBytes = bytesPerSample * scansize * height;
- int length = bytes.length < nBytes ? nBytes / scansize : height;
+ final int bytesPerSample = bitsPerSample / 8;
+ final int nBytes = bytesPerSample * scansize * height;
+ final int length = bytes.length < nBytes ? nBytes / scansize : height;
- int[] samples = new int[scansize * height];
+ final int[] samples = new int[scansize * height];
// floating-point differencing is indicated by a predictor value of 3.
if (predictor == TiffTagConstants.PREDICTOR_VALUE_FLOATING_POINT_DIFFERENCING) {
// at this time, this class supports the 32-bit format. The
@@ -405,12 +405,12 @@ public abstract class ImageDataReader {
+ " with predictor type 3 for "
+ bitsPerSample + " bits per sample");
}
- int bytesInRow = scansize * 4;
+ final int bytesInRow = scansize * 4;
for (int i = 0; i < length; i++) {
- int aOffset = i * bytesInRow;
- int bOffset = aOffset + scansize;
- int cOffset = bOffset + scansize;
- int dOffset = cOffset + scansize;
+ final int aOffset = i * bytesInRow;
+ final int bOffset = aOffset + scansize;
+ final int cOffset = bOffset + scansize;
+ final int dOffset = cOffset + scansize;
// in this loop, the source bytes give delta values.
// we adjust them to give true values. This operation is
// done on a row-by-row basis.
@@ -421,10 +421,10 @@ public abstract class ImageDataReader {
// floating point values
int index = i * scansize;
for (int j = 0; j < width; j++) {
- int a = bytes[aOffset + j];
- int b = bytes[bOffset + j];
- int c = bytes[cOffset + j];
- int d = bytes[dOffset + j];
+ final int a = bytes[aOffset + j];
+ final int b = bytes[bOffset + j];
+ final int c = bytes[cOffset + j];
+ final int d = bytes[dOffset + j];
// Pack the 4 byte components into a single integer
// in the byte order used by the TIFF standard
samples[index++] = ((a & 0xff) << 24)
@@ -442,14 +442,14 @@ public abstract class ImageDataReader {
int index = 0;
for (int i = 0; i < length; i++) {
for (int j = 0; j < scansize; j++) {
- long b0 = bytes[k++] & 0xffL;
- long b1 = bytes[k++] & 0xffL;
- long b2 = bytes[k++] & 0xffL;
- long b3 = bytes[k++] & 0xffL;
- long b4 = bytes[k++] & 0xffL;
- long b5 = bytes[k++] & 0xffL;
- long b6 = bytes[k++] & 0xffL;
- long b7 = bytes[k++] & 0xffL;
+ final long b0 = bytes[k++] & 0xffL;
+ final long b1 = bytes[k++] & 0xffL;
+ final long b2 = bytes[k++] & 0xffL;
+ final long b3 = bytes[k++] & 0xffL;
+ final long b4 = bytes[k++] & 0xffL;
+ final long b5 = bytes[k++] & 0xffL;
+ final long b6 = bytes[k++] & 0xffL;
+ final long b7 = bytes[k++] & 0xffL;
long sbits;
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
sbits = (b7 << 56)
@@ -475,7 +475,7 @@ public abstract class ImageDataReader {
// currently support doubles, we need to replace this
// element with a float. This action is inefficient and
// should be improved.
- float f = (float) Double.longBitsToDouble(sbits);
+ final float f = (float) Double.longBitsToDouble(sbits);
samples[index++] = Float.floatToRawIntBits(f);
}
}
@@ -484,10 +484,10 @@ public abstract class ImageDataReader {
int index = 0;
for (int i = 0; i < length; i++) {
for (int j = 0; j < scansize; j++) {
- int b0 = bytes[k++] & 0xff;
- int b1 = bytes[k++] & 0xff;
- int b2 = bytes[k++] & 0xff;
- int b3 = bytes[k++] & 0xff;
+ final int b0 = bytes[k++] & 0xff;
+ final int b1 = bytes[k++] & 0xff;
+ final int b2 = bytes[k++] & 0xff;
+ final int b3 = bytes[k++] & 0xff;
int sbits;
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
sbits
@@ -533,10 +533,10 @@ public abstract class ImageDataReader {
* data)
* @param rasterData the raster data.
*/
- void transferBlockToRaster(int xBlock, int yBlock,
- int blockWidth, int blockHeight, int blockData[],
- int xRaster, int yRaster,
- int rasterWidth, int rasterHeight, float[] rasterData) {
+ void transferBlockToRaster(final int xBlock, final int yBlock,
+ final int blockWidth, final int blockHeight, final int blockData[],
+ final int xRaster, final int yRaster,
+ final int rasterWidth, final int rasterHeight, final float[] rasterData) {
// xR0, yR0 are the coordinates within the raster (upper-left corner)
// xR1, yR1 are ONE PAST the coordinates of the lower-right corner
@@ -592,10 +592,10 @@ public abstract class ImageDataReader {
}
for (int i = 0; i < h; i++) {
- int yR = yR0 + i;
- int yB = yB0 + i;
- int rOffset = yR * rasterWidth + xR0;
- int bOffset = yB * blockWidth + xB0;
+ final int yR = yR0 + i;
+ final int yB = yB0 + i;
+ final int rOffset = yR * rasterWidth + xR0;
+ final int bOffset = yB * blockWidth + xB0;
for (int j = 0; j < w; j++) {
rasterData[rOffset + j] = Float.intBitsToFloat(blockData[bOffset + j]);
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java
index c75cf7f..20888e4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java
@@ -98,7 +98,7 @@ public class PhotometricInterpreterLogLuv extends PhotometricInterpreter {
* @see <a href="https://en.wikipedia.org/wiki/CIELAB_color_space">CIELAB color space</a>
* @see <a href="https://en.wikipedia.org/wiki/White_point">White point</a>
*/
- TristimulusValues getTristimulusValues(int cieL, int cieA, int cieB) {
+ TristimulusValues getTristimulusValues(final int cieL, final int cieA, final int cieB) {
float var_Y = ((cieL * 100.0f / 255.0f) + 16.0f) / 116.0f;
float var_X = cieA / 500.0f + var_Y;
float var_Z = var_Y - cieB / 200.0f;
@@ -149,7 +149,7 @@ public class PhotometricInterpreterLogLuv extends PhotometricInterpreter {
* @return RGB values
* @see <a href="https://en.wikipedia.org/wiki/CIELAB_color_space">CIELAB color space</a>
*/
- RgbValues getRgbValues(TristimulusValues tristimulusValues) {
+ RgbValues getRgbValues(final TristimulusValues tristimulusValues) {
final float var_X = tristimulusValues.x / 100f; // X = From 0 to ref_X
final float var_Y = tristimulusValues.y / 100f; // Y = From 0 to ref_Y
final float var_Z = tristimulusValues.z / 100f; // Z = From 0 to ref_Y
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java
index 20d6651..8271273 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRange.java
@@ -50,10 +50,10 @@ public class PaletteEntryForRange implements PaletteEntry {
* @param color0 the color assigned to value v0
* @param color1 the color assigned to value v1
*/
- public PaletteEntryForRange(float v0, float v1, Color color0, Color color1) {
+ public PaletteEntryForRange(final float v0, final float v1, final Color color0, final Color color1) {
this.v0 = v0;
this.v1 = v1;
- float deltaV = v1 - v0;
+ final float deltaV = v1 - v0;
// check for range volation
if (deltaV <= 0 || Float.isNaN(deltaV)) {
throw new IllegalArgumentException("Specified values must be v0<v1");
@@ -61,13 +61,13 @@ public class PaletteEntryForRange implements PaletteEntry {
if (color0 == null || color1 == null) {
throw new IllegalArgumentException("Null colors not allowed");
}
- int argb0 = color0.getRGB();
+ final int argb0 = color0.getRGB();
a0 = (argb0 >> 24) & 0xff;
r0 = (argb0 >> 16) & 0xff;
g0 = (argb0 >> 8) & 0xff;
b0 = argb0 & 0xff;
- int argb1 = color1.getRGB();
+ final int argb1 = color1.getRGB();
a1 = (argb1 >> 24) & 0xff;
r1 = (argb1 >> 16) & 0xff;
g1 = (argb1 >> 8) & 0xff;
@@ -82,10 +82,10 @@ public class PaletteEntryForRange implements PaletteEntry {
* @param v1 the upper bounds (non-inclusive) of the covered range of value
* @param color the color assigned to value v0
*/
- public PaletteEntryForRange(float v0, float v1, Color color) {
+ public PaletteEntryForRange(final float v0, final float v1, final Color color) {
this.v0 = v0;
this.v1 = v1;
- float deltaV = v1 - v0;
+ final float deltaV = v1 - v0;
// check for range volation
if (deltaV <= 0 || Float.isNaN(deltaV)) {
throw new IllegalArgumentException("Specified values must be v0<v1");
@@ -94,13 +94,13 @@ public class PaletteEntryForRange implements PaletteEntry {
throw new IllegalArgumentException("Null colors not allowed");
}
- int argb0 = color.getRGB();
+ final int argb0 = color.getRGB();
a0 = (argb0 >> 24) & 0xff;
r0 = (argb0 >> 16) & 0xff;
g0 = (argb0 >> 8) & 0xff;
b0 = argb0 & 0xff;
- int argb1 = color.getRGB();
+ final int argb1 = color.getRGB();
a1 = (argb1 >> 24) & 0xff;
r1 = (argb1 >> 16) & 0xff;
g1 = (argb1 >> 8) & 0xff;
@@ -108,31 +108,31 @@ public class PaletteEntryForRange implements PaletteEntry {
}
@Override
- public boolean isCovered(float f) {
+ public boolean isCovered(final float f) {
return v0 <= f && f < v1;
}
@Override
- public int getARGB(float f) {
+ public int getARGB(final float f) {
if (v0 <= f && f <= v1) {
- float t = (f - v0) / (v1 - v0);
- int a = (int) (t * (a1 - a0) + a0 + 0.5);
- int r = (int) (t * (r1 - r0) + r0 + 0.5);
- int g = (int) (t * (g1 - g0) + g0 + 0.5);
- int b = (int) (t * (b1 - b0) + b0 + 0.5);
+ final float t = (f - v0) / (v1 - v0);
+ final int a = (int) (t * (a1 - a0) + a0 + 0.5);
+ final int r = (int) (t * (r1 - r0) + r0 + 0.5);
+ final int g = (int) (t * (g1 - g0) + g0 + 0.5);
+ final int b = (int) (t * (b1 - b0) + b0 + 0.5);
return (((((a << 8) | r) << 8) | g) << 8) | b;
}
return 0;
}
@Override
- public Color getColor(float f) {
+ public Color getColor(final float f) {
if (v0 <= f && f <= v1) {
- float t = (f - v0) / (v1 - v0);
- int a = (int) (t * (a1 - a0) + a0 + 0.5);
- int r = (int) (t * (r1 - r0) + r0 + 0.5);
- int g = (int) (t * (g1 - g0) + g0 + 0.5);
- int b = (int) (t * (b1 - b0) + b0 + 0.5);
+ final float t = (f - v0) / (v1 - v0);
+ final int a = (int) (t * (a1 - a0) + a0 + 0.5);
+ final int r = (int) (t * (r1 - r0) + r0 + 0.5);
+ final int g = (int) (t * (g1 - g0) + g0 + 0.5);
+ final int b = (int) (t * (b1 - b0) + b0 + 0.5);
return new Color(r, g, b, a);
}
return null;
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValue.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValue.java
index 14733bd..61157b7 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValue.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValue.java
@@ -28,7 +28,7 @@ public class PaletteEntryForValue implements PaletteEntry {
private final float value;
private final int iColor;
private final Color color;
- private boolean isNull;
+ private final boolean isNull;
/**
* Constructs a palette entry for a single value.
@@ -39,7 +39,7 @@ public class PaletteEntryForValue implements PaletteEntry {
* Float.NaN is allowed.
* @param color the color assigned to value
*/
- public PaletteEntryForValue(float value, Color color) {
+ public PaletteEntryForValue(final float value, final Color color) {
if (color == null) {
throw new IllegalArgumentException("Null colors not allowed");
}
@@ -51,7 +51,7 @@ public class PaletteEntryForValue implements PaletteEntry {
}
@Override
- public boolean isCovered(float f) {
+ public boolean isCovered(final float f) {
if (isNull) {
return Float.isNaN(f);
}
@@ -59,7 +59,7 @@ public class PaletteEntryForValue implements PaletteEntry {
}
@Override
- public int getARGB(float f) {
+ public int getARGB(final float f) {
if (isNull && Float.isNaN(f)) {
return iColor;
} else if (f == value) {
@@ -69,7 +69,7 @@ public class PaletteEntryForValue implements PaletteEntry {
}
@Override
- public Color getColor(float f) {
+ public Color getColor(final float f) {
if (isNull && Float.isNaN(f)) {
return color;
} else if (f == value) {
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloat.java b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloat.java
index c2787fd..e06c1d0 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloat.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloat.java
@@ -84,7 +84,7 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
* scale
*/
public PhotometricInterpreterFloat(
- float valueBlack, float valueWhite) {
+ final float valueBlack, final float valueWhite) {
// The abstract base class requires that the following fields
// be set in the constructor:
// samplesPerPixel (int)
@@ -102,11 +102,11 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
if (valueWhite > valueBlack) {
- PaletteEntryForRange entry
+ final PaletteEntryForRange entry
= new PaletteEntryForRange(valueBlack, valueWhite, Color.black, Color.white);
rangePaletteEntries.add(entry);
} else {
- PaletteEntryForRange entry
+ final PaletteEntryForRange entry
= new PaletteEntryForRange(valueWhite, valueBlack, Color.white, Color.black);
rangePaletteEntries.add(entry);
}
@@ -123,7 +123,7 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
*
* @param paletteEntries a valid, non-empty list of palette entries
*/
- public PhotometricInterpreterFloat(List<PaletteEntry> paletteEntries) {
+ public PhotometricInterpreterFloat(final List<PaletteEntry> paletteEntries) {
// The abstract base class requires that the following fields
// be set in the constructor:
// samplesPerPixel (int)
@@ -144,7 +144,7 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
"Palette entries list must be non-null and non-empty");
}
- for (PaletteEntry entry : paletteEntries) {
+ for (final PaletteEntry entry : paletteEntries) {
if (entry.coversSingleEntry()) {
singleValuePaletteEntries.add(entry);
} else {
@@ -152,7 +152,7 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
}
}
- Comparator<PaletteEntry> comparator = (o1, o2) -> {
+ final Comparator<PaletteEntry> comparator = (o1, o2) -> {
if (o1.getLowerBound() == o2.getLowerBound()) {
return Double.compare(o1.getUpperBound(), o2.getUpperBound());
}
@@ -165,17 +165,17 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
@Override
public void interpretPixel(
- ImageBuilder imageBuilder,
- int[] samples, int x, int y)
+ final ImageBuilder imageBuilder,
+ final int[] samples, final int x, final int y)
throws ImageReadException, IOException {
- float f = Float.intBitsToFloat(samples[0]);
+ final float f = Float.intBitsToFloat(samples[0]);
// in the event of NaN, do not store entry in the image builder.
// only the single bound palette entries support NaN
- for (PaletteEntry entry : singleValuePaletteEntries) {
+ for (final PaletteEntry entry : singleValuePaletteEntries) {
if (entry.isCovered(f)) {
- int p = entry.getARGB(f);
+ final int p = entry.getARGB(f);
imageBuilder.setRGB(x, y, p);
return;
}
@@ -199,17 +199,17 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
nFound++;
sumFound += f;
- for (PaletteEntry entry : singleValuePaletteEntries) {
+ for (final PaletteEntry entry : singleValuePaletteEntries) {
if (entry.isCovered(f)) {
- int p = entry.getARGB(f);
+ final int p = entry.getARGB(f);
imageBuilder.setRGB(x, y, p);
return;
}
}
- for (PaletteEntry entry : rangePaletteEntries) {
+ for (final PaletteEntry entry : rangePaletteEntries) {
if (entry.isCovered(f)) {
- int p = entry.getARGB(f);
+ final int p = entry.getARGB(f);
imageBuilder.setRGB(x, y, p);
break;
}
@@ -278,13 +278,13 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
* @return a valid ARGB value, or zero if no palette specification covers
* the input value.
*/
- public int mapValueToARGB(float f) {
+ public int mapValueToARGB(final float f) {
// The single-value palette entries can accept a Float.NaN as
// a target while the range-of-values entries cannot. So
// check the single-values before testing for Float.isNaN()
// because NaN may have special treatment.
- for (PaletteEntry entry : singleValuePaletteEntries) {
+ for (final PaletteEntry entry : singleValuePaletteEntries) {
if (entry.isCovered(f)) {
return entry.getARGB(f);
}
@@ -296,7 +296,7 @@ public class PhotometricInterpreterFloat extends PhotometricInterpreter {
return 0;
}
- for (PaletteEntry entry : rangePaletteEntries) {
+ for (final PaletteEntry entry : rangePaletteEntries) {
if (entry.isCovered(f)) {
return entry.getARGB(f);
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
index 23d8d60..45e11b4 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
@@ -264,7 +264,7 @@ public abstract class TiffImageWriterBase {
* @param src a valid image
* @return true if at least one non-opaque pixel is found.
*/
- private boolean checkForActualAlpha(BufferedImage src){
+ private boolean checkForActualAlpha(final BufferedImage src){
// to conserve memory, very large images may be read
// in pieces.
final int width = src.getWidth();
@@ -273,13 +273,13 @@ public abstract class TiffImageWriterBase {
if(nRowsPerRead<1){
nRowsPerRead = 1;
}
- int nReads = (height+nRowsPerRead-1)/nRowsPerRead;
- int []argb = new int[nRowsPerRead*width];
+ final int nReads = (height+nRowsPerRead-1)/nRowsPerRead;
+ final int []argb = new int[nRowsPerRead*width];
for(int iRead=0; iRead<nReads; iRead++){
final int i0 = iRead*nRowsPerRead;
final int i1 = i0+nRowsPerRead>height? height: i0+nRowsPerRead;
src.getRGB(0, i0, width, i1-i0, argb, 0, width);
- int n = (i1-i0)*width;
+ final int n = (i1-i0)*width;
for(int i=0; i<n; i++){
if((argb[i]&0xff000000)!=0xff000000){
return true;
@@ -289,11 +289,11 @@ public abstract class TiffImageWriterBase {
return false;
}
- private void applyPredictor(int width, int bytesPerSample, byte[] b) {
- int nBytesPerRow = bytesPerSample * width;
- int nRows = b.length / nBytesPerRow;
+ private void applyPredictor(final int width, final int bytesPerSample, final byte[] b) {
+ final int nBytesPerRow = bytesPerSample * width;
+ final int nRows = b.length / nBytesPerRow;
for (int iRow = 0; iRow < nRows; iRow++) {
- int offset = iRow * nBytesPerRow;
+ final int offset = iRow * nBytesPerRow;
for (int i = nBytesPerRow-1; i >= bytesPerSample; i--) {
b[offset + i] -= b[offset + i - bytesPerSample];
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
index b7f4ee0..e7dffcf 100644
--- a/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
@@ -668,8 +668,8 @@ public class XpmImageParser extends ImageParser {
// leave the loop if numbers would go beyond Integer.MAX_VALUE to avoid infinite loops
// test every operation from below if it would increase an int value beyond Integer.MAX_VALUE
- long nextMaxColors = maxColors * WRITE_PALETTE.length;
- long nextCharsPerPixel = charsPerPixel + 1;
+ final long nextMaxColors = maxColors * WRITE_PALETTE.length;
+ final long nextCharsPerPixel = charsPerPixel + 1;
if (nextMaxColors > Integer.MAX_VALUE) {
throw new ImageWriteException("Xpm: Can't write images with more than Integer.MAX_VALUE colors.");
}
diff --git a/src/main/java/org/apache/commons/imaging/palette/ColorCountComparator.java b/src/main/java/org/apache/commons/imaging/palette/ColorCountComparator.java
index dbaec48..22456a4 100644
--- a/src/main/java/org/apache/commons/imaging/palette/ColorCountComparator.java
+++ b/src/main/java/org/apache/commons/imaging/palette/ColorCountComparator.java
@@ -37,14 +37,14 @@ public class ColorCountComparator implements Comparator<ColorCount>, Serializabl
/**
* Color component used during the comparison.
*/
- private ColorComponent colorComponent;
+ private final ColorComponent colorComponent;
public ColorCountComparator(final ColorComponent colorComponent) {
this.colorComponent = colorComponent;
}
@Override
- public int compare(ColorCount c1, ColorCount c2) {
+ public int compare(final ColorCount c1, final ColorCount c2) {
switch (colorComponent) {
case ALPHA:
return c1.alpha - c2.alpha;
diff --git a/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java b/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java
index a39f7ad..3e10a04 100644
--- a/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java
+++ b/src/test/java/org/apache/commons/imaging/ImagingGuessFormatTest.java
@@ -68,7 +68,7 @@ public class ImagingGuessFormatTest extends ImagingTest {
@ParameterizedTest
@MethodSource("data")
- public void testGuessFormat(ImageFormats expectedFormat, String pathToFile) throws Exception {
+ public void testGuessFormat(final ImageFormats expectedFormat, final String pathToFile) throws Exception {
final String imagePath = FilenameUtils.separatorsToSystem(pathToFile);
final File imageFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, imagePath);
diff --git a/src/test/java/org/apache/commons/imaging/TestImageInfo.java b/src/test/java/org/apache/commons/imaging/TestImageInfo.java
index 37ef830..b6fa816 100644
--- a/src/test/java/org/apache/commons/imaging/TestImageInfo.java
+++ b/src/test/java/org/apache/commons/imaging/TestImageInfo.java
@@ -130,7 +130,7 @@ public class TestImageInfo {
"Is Transparent: false\n" +
"Color Type: Black and White\n" +
"Uses Palette: false\n";
- String testString = imageInfo.toString().replaceAll("\\r", "");
+ final String testString = imageInfo.toString().replaceAll("\\r", "");
assertEquals(expected, testString);
}
@@ -158,7 +158,7 @@ public class TestImageInfo {
"Is Transparent: false\n" +
"Color Type: Black and White\n" +
"Uses Palette: false\n";
- String testString = imageInfo.toString().replaceAll("\\r", "");
+ final String testString = imageInfo.toString().replaceAll("\\r", "");
assertEquals(expected, testString);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/TestImageReadException.java b/src/test/java/org/apache/commons/imaging/TestImageReadException.java
index 477a0fe..f0adf5c 100644
--- a/src/test/java/org/apache/commons/imaging/TestImageReadException.java
+++ b/src/test/java/org/apache/commons/imaging/TestImageReadException.java
@@ -29,14 +29,14 @@ public class TestImageReadException {
@Test
public void testCreateExceptionWithMessage() {
- ImageReadException exception = new ImageReadException("imaging");
+ final ImageReadException exception = new ImageReadException("imaging");
assertEquals("imaging", exception.getMessage());
assertNull(exception.getCause());
}
@Test
public void testCreateExceptionWithMessageAndCause() {
- ImageReadException exception = new ImageReadException("imaging", new Exception("cause"));
+ final ImageReadException exception = new ImageReadException("imaging", new Exception("cause"));
assertEquals("imaging", exception.getMessage());
assertNotNull(exception.getCause());
}
diff --git a/src/test/java/org/apache/commons/imaging/TestImageWriteException.java b/src/test/java/org/apache/commons/imaging/TestImageWriteException.java
index dfb229f..6781681 100644
--- a/src/test/java/org/apache/commons/imaging/TestImageWriteException.java
+++ b/src/test/java/org/apache/commons/imaging/TestImageWriteException.java
@@ -50,22 +50,22 @@ public class TestImageWriteException {
@Test
public void testCreateExceptionWithMessage() {
- ImageWriteException exception = new ImageWriteException("imaging");
+ final ImageWriteException exception = new ImageWriteException("imaging");
assertEquals("imaging", exception.getMessage());
assertNull(exception.getCause());
}
@Test
public void testCreateExceptionWithMessageAndCause() {
- ImageWriteException exception = new ImageWriteException("imaging", new Exception("cause"));
+ final ImageWriteException exception = new ImageWriteException("imaging", new Exception("cause"));
assertEquals("imaging", exception.getMessage());
assertNotNull(exception.getCause());
}
@ParameterizedTest
@MethodSource("data")
- public void testCreateExceptionWithData(Object data, String expectedType) {
- ImageWriteException exception = new ImageWriteException("imaging", data);
+ public void testCreateExceptionWithData(final Object data, final String expectedType) {
+ final ImageWriteException exception = new ImageWriteException("imaging", data);
assertEquals(String.format("imaging: %s (%s)", data, expectedType), exception.getMessage());
}
}
diff --git a/src/test/java/org/apache/commons/imaging/color/ColorCmyTest.java b/src/test/java/org/apache/commons/imaging/color/ColorCmyTest.java
index c5fb137..5692d89 100644
--- a/src/test/java/org/apache/commons/imaging/color/ColorCmyTest.java
+++ b/src/test/java/org/apache/commons/imaging/color/ColorCmyTest.java
@@ -58,8 +58,8 @@ public class ColorCmyTest {
@Test
public void testCreatesColorCmy() {
- ColorCmy colorCmy = new ColorCmy(0.0, (-1668.733868772), (-1568.733868772));
- ColorCmy colorCmyTwo = ColorCmy.YELLOW;
+ final ColorCmy colorCmy = new ColorCmy(0.0, (-1668.733868772), (-1568.733868772));
+ final ColorCmy colorCmyTwo = ColorCmy.YELLOW;
assertFalse(colorCmy.equals(colorCmyTwo));
assertEquals((-1568.733868772), colorCmy.Y, 0.01);
diff --git a/src/test/java/org/apache/commons/imaging/color/ColorHslTest.java b/src/test/java/org/apache/commons/imaging/color/ColorHslTest.java
index 77b135f..8bdcd1a 100644
--- a/src/test/java/org/apache/commons/imaging/color/ColorHslTest.java
+++ b/src/test/java/org/apache/commons/imaging/color/ColorHslTest.java
@@ -64,8 +64,8 @@ public class ColorHslTest {
@Test
public void testCreatesColorHslOne() {
- ColorHsl colorHsl = ColorHsl.BLUE;
- ColorHsl colorHslTwo = new ColorHsl(100.0, 667.226, (-687.72287636));
+ final ColorHsl colorHsl = ColorHsl.BLUE;
+ final ColorHsl colorHslTwo = new ColorHsl(100.0, 667.226, (-687.72287636));
assertEquals(667.226, colorHslTwo.S, 0.01);
assertEquals(100.0, colorHslTwo.H, 0.01);
diff --git a/src/test/java/org/apache/commons/imaging/common/ImageBuilderTest.java b/src/test/java/org/apache/commons/imaging/common/ImageBuilderTest.java
index f03d2c2..9caf994 100644
--- a/src/test/java/org/apache/commons/imaging/common/ImageBuilderTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/ImageBuilderTest.java
@@ -45,7 +45,7 @@ public class ImageBuilderTest {
@Test
public void testBoundsCheck() {
- ImageBuilder imageBuilder = new ImageBuilder(100, 100, false );
+ final ImageBuilder imageBuilder = new ImageBuilder(100, 100, false );
executeBadBounds(imageBuilder, -1, 0, 50, 50);
executeBadBounds(imageBuilder, 0, -1, 50, 50);
@@ -60,27 +60,27 @@ public class ImageBuilderTest {
*/
@Test
public void testSubimageAccess() {
- ImageBuilder imageBuilder = new ImageBuilder(100, 100, false );
+ final ImageBuilder imageBuilder = new ImageBuilder(100, 100, false );
populate(imageBuilder);
- BufferedImage bImage = imageBuilder.getSubimage(25, 25, 25, 25);
- int w = bImage.getWidth();
- int h = bImage.getHeight();
+ final BufferedImage bImage = imageBuilder.getSubimage(25, 25, 25, 25);
+ final int w = bImage.getWidth();
+ final int h = bImage.getHeight();
assertEquals(w, 25, "Width of subimage does not match");
assertEquals(h, 25, "Height of subimage does not match");
for(int x=25; x<50; x++){
for(int y=25; y<50; y++){
- int k = bImage.getRGB(x-25, y-25);
- int rgb = imageBuilder.getRGB(x, y);
+ final int k = bImage.getRGB(x-25, y-25);
+ final int rgb = imageBuilder.getRGB(x, y);
assertEquals(k, rgb, "Invalid buffered image subpixel at "+x+", "+y);
}
}
- ImageBuilder testBuilder = imageBuilder.getSubset(25, 25, 25, 25);
+ final ImageBuilder testBuilder = imageBuilder.getSubset(25, 25, 25, 25);
for(int x=25; x<50; x++){
for(int y=25; y<50; y++){
- int k = testBuilder.getRGB(x-25, y-25);
- int rgb = imageBuilder.getRGB(x, y);
+ final int k = testBuilder.getRGB(x-25, y-25);
+ final int rgb = imageBuilder.getRGB(x, y);
assertEquals(k, rgb, "Invalid image builder subpixel at "+x+", "+y);
}
}
@@ -112,30 +112,30 @@ public class ImageBuilderTest {
assertTrue(model.isAlphaPremultiplied(), "Output image does not have alpha pre-multiplied where specified");
}
- void executeBadBounds(ImageBuilder imageBuilder, int x, int y, int w, int h){
+ void executeBadBounds(final ImageBuilder imageBuilder, final int x, final int y, final int w, final int h){
try{
- ImageBuilder sub = imageBuilder.getSubset(x, y, w, h);
+ final ImageBuilder sub = imageBuilder.getSubset(x, y, w, h);
fail("Failed to detect bad bounds "+x+", "+y+", "+w+", "+h);
- }catch(RasterFormatException rfe){
+ }catch(final RasterFormatException rfe){
// success, no action required
}
}
- void executeBadConstructor(int w, int h){
+ void executeBadConstructor(final int w, final int h){
try{
- ImageBuilder iBuilder = new ImageBuilder(w, h, true);
+ final ImageBuilder iBuilder = new ImageBuilder(w, h, true);
fail("Failed to detect bad constructor "+w+", "+h);
- }catch(RasterFormatException rfe){
+ }catch(final RasterFormatException rfe){
// success, no action required
}
}
- void populate(ImageBuilder imageBuilder){
+ void populate(final ImageBuilder imageBuilder){
for(int x=0; x<100; x++){
for(int y=0; y<100; y++){
- int k = y*100+x;
- int rgb = 0xff000000|k;
+ final int k = y*100+x;
+ final int rgb = 0xff000000|k;
imageBuilder.setRGB(x, y, rgb);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java b/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
index 2b07bd3..c91fc4a 100644
--- a/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java
@@ -105,7 +105,7 @@ public class RationalNumberTest extends ImagingTest {
@ParameterizedTest
@MethodSource("data")
- public void testRationalNumber(double testValue) {
+ public void testRationalNumber(final double testValue) {
final RationalNumber rational = RationalNumber.valueOf(testValue);
final double difference = Math.abs(testValue - rational.doubleValue());
diff --git a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
index 46930dd..c0eb8fb 100644
--- a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceDataTest.java
@@ -127,17 +127,17 @@ public class ByteSourceDataTest extends ByteSourceTest {
@ParameterizedTest
@MethodSource("data")
- public void testByteSourceFileFactory(byte[] testByteArray) throws Exception {
+ public void testByteSourceFileFactory(final byte[] testByteArray) throws Exception {
writeAndReadBytes(new ByteSourceFileFactory(), testByteArray);
}
@ParameterizedTest
@MethodSource("data")
- public void testByteSourceInputStreamFileFactory(byte[] testByteArray) throws Exception {
+ public void testByteSourceInputStreamFileFactory(final byte[] testByteArray) throws Exception {
writeAndReadBytes(new ByteSourceInputStreamFileFactory(), testByteArray);
}
@ParameterizedTest
@MethodSource("data")
- public void testByteSourceInputStreamRawFactory(byte[] testByteArray) throws Exception {
+ public void testByteSourceInputStreamRawFactory(final byte[] testByteArray) throws Exception {
writeAndReadBytes(new ByteSourceInputStreamRawFactory(), testByteArray);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
index 8ea3583..143baa5 100644
--- a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceImageTest.java
@@ -51,7 +51,7 @@ public class ByteSourceImageTest extends ByteSourceTest {
@ParameterizedTest
@MethodSource("data")
- public void test(File imageFile) throws Exception {
+ public void test(final File imageFile) throws Exception {
Debug.debug("imageFile", imageFile);
assertNotNull(imageFile);
diff --git a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceInputStreamTest.java b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceInputStreamTest.java
index c1ae094..559bbef 100644
--- a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceInputStreamTest.java
+++ b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceInputStreamTest.java
@@ -45,7 +45,7 @@ class ByteSourceInputStreamTest {
final File imageFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, imagePath);
try(BufferedInputStream imageStream = new BufferedInputStream(new FileInputStream(imageFile))) {
// ByteSourceInputStream is created inside of following method
- BufferedImage bufferedImage = Imaging.getBufferedImage(imageStream,
+ final BufferedImage bufferedImage = Imaging.getBufferedImage(imageStream,
Collections.singletonMap(ImagingConstants.PARAM_KEY_FILENAME, ICO_IMAGE_FILE));
assertEquals(bufferedImage.getWidth(), ICO_IMAGE_WIDTH);
diff --git a/src/test/java/org/apache/commons/imaging/examples/tiff/ExampleReadFloatingPointData.java b/src/test/java/org/apache/commons/imaging/examples/tiff/ExampleReadFloatingPointData.java
index 7c15d76..95d0044 100644
--- a/src/test/java/org/apache/commons/imaging/examples/tiff/ExampleReadFloatingPointData.java
+++ b/src/test/java/org/apache/commons/imaging/examples/tiff/ExampleReadFloatingPointData.java
@@ -66,36 +66,36 @@ public class ExampleReadFloatingPointData {
* internal data format or version compatibility error reading the image.
* @throws java.io.IOException in the event of an I/O error.
*/
- public static void main(String[] args) throws ImageReadException, IOException {
+ public static void main(final String[] args) throws ImageReadException, IOException {
if (args.length == 0) {
// Print usage and exit
- for (String s : USAGE) {
+ for (final String s : USAGE) {
System.err.println(s);
}
System.exit(0);
}
- File target = new File(args[0]);
+ final File target = new File(args[0]);
String outputPath = null;
if (args.length >= 2) {
outputPath = args[1];
}
- boolean optionalImageWritingEnabled
+ final boolean optionalImageWritingEnabled
= outputPath != null && !outputPath.isEmpty();
- ByteSourceFile byteSource = new ByteSourceFile(target);
+ final ByteSourceFile byteSource = new ByteSourceFile(target);
// Establish a TiffReader. This is just a simple constructor that
// does not actually access the file until one of its methods such as
// readDirectories is called.
- TiffReader tiffReader = new TiffReader(true);
+ final TiffReader tiffReader = new TiffReader(true);
// Read the directories in the TIFF file. Directories are the
// main data element of a TIFF file. They usually include an image
// element, but sometimes just carry metadata. This example
// reads all the directories in the file. Typically reading
// the directories is not a time-consuming operation.
- TiffContents contents = tiffReader.readDirectories(
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true, // indicates that application should read image data, if present
FormatCompliance.getDefault());
@@ -103,7 +103,7 @@ public class ExampleReadFloatingPointData {
// Read the first directory in the file. A practical implementation
// could use any of the directories in the file. This demo uses the
// first one just for simplicity.
- TiffDirectory directory = contents.directories.get(0);
+ final TiffDirectory directory = contents.directories.get(0);
// Render the first directory in the file
if (!directory.hasTiffFloatingPointRasterData()) {
System.err.println("Specified directory does not contain floating-point data");
@@ -114,17 +114,17 @@ public class ExampleReadFloatingPointData {
// If only a sub-image is desired, the params Mao can be used
// to specify what section of the data is to be extracted.
// See the Javadoc for readFloatingPointRasterData for more details.
- long time0 = System.nanoTime();
- HashMap<String, Object> params = new HashMap<>();
- TiffRasterData rasterData
+ final long time0 = System.nanoTime();
+ final HashMap<String, Object> params = new HashMap<>();
+ final TiffRasterData rasterData
= directory.getFloatingPointRasterData(params);
- long time1 = System.nanoTime();
+ final long time1 = System.nanoTime();
System.out.println("Data read in " + ((time1 - time0) / 1.0e+6) + " ms");
// One of the test files in the Commons Imaging distribution uses
// the value 9999 as a special "No Data" indicator. In that case,
// we do not want to include 9999 in the simple-statistics survey.
- float excludedValue = Float.NaN;
+ final float excludedValue = Float.NaN;
TiffRasterStatistics simpleStats;
if ("Sample64BitFloatingPointPix451x337.tiff".equals(target.getName())) {
simpleStats = rasterData.getSimpleStatistics(9999);
@@ -133,10 +133,10 @@ public class ExampleReadFloatingPointData {
simpleStats = rasterData.getSimpleStatistics();
}
- int w = rasterData.getWidth();
- int h = rasterData.getHeight();
- float minValue = simpleStats.getMinValue();
- float maxValue = simpleStats.getMaxValue();
+ final int w = rasterData.getWidth();
+ final int h = rasterData.getHeight();
+ final float minValue = simpleStats.getMinValue();
+ final float maxValue = simpleStats.getMaxValue();
System.out.format("Image size %dx%d%n", w, h);
System.out.format("Range of values in TIFF: %f %f%n", minValue, maxValue);
@@ -150,11 +150,11 @@ public class ExampleReadFloatingPointData {
// ReadAndRenderFloatingPoint.java example, But in this case,
// we'll take the approach of building an image from the
// raster data that was obtained above.
- File output = new File(outputPath);
+ final File output = new File(outputPath);
System.out.println("Writing image to " + output.getPath());
// create a new photometric interpreter based on the range
// of values found above.
- List<PaletteEntry> paletteList = new ArrayList();
+ final List<PaletteEntry> paletteList = new ArrayList();
if (!Float.isNaN(excludedValue)) {
// draw the excluded value in red.
paletteList.add(new PaletteEntryForValue(excludedValue, Color.red));
@@ -166,21 +166,21 @@ public class ExampleReadFloatingPointData {
// color-coded unless we add an additional palette entry to
// handle the single-value for the maximum.
paletteList.add(new PaletteEntryForValue(maxValue, Color.white));
- PhotometricInterpreterFloat photometricInterpreter
+ final PhotometricInterpreterFloat photometricInterpreter
= new PhotometricInterpreterFloat(paletteList);
// Now construct an ImageBuilder to store the results
- ImageBuilder builder = new ImageBuilder(w, h, false);
+ final ImageBuilder builder = new ImageBuilder(w, h, false);
for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) {
- float f = rasterData.getValue(x, y);
- int argb
+ final float f = rasterData.getValue(x, y);
+ final int argb
= photometricInterpreter.mapValueToARGB(f);
builder.setRGB(x, y, argb);
}
}
- BufferedImage bImage = builder.getBufferedImage();
+ final BufferedImage bImage = builder.getBufferedImage();
ImageIO.write(bImage, "JPEG", output);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/examples/tiff/ReadAndRenderFloatingPoint.java b/src/test/java/org/apache/commons/imaging/examples/tiff/ReadAndRenderFloatingPoint.java
index 56523fd..c83200c 100644
--- a/src/test/java/org/apache/commons/imaging/examples/tiff/ReadAndRenderFloatingPoint.java
+++ b/src/test/java/org/apache/commons/imaging/examples/tiff/ReadAndRenderFloatingPoint.java
@@ -60,31 +60,31 @@ public class ReadAndRenderFloatingPoint {
* internal data format or version compatibility error reading the image.
* @throws java.io.IOException in the event of an I/O error.
*/
- public static void main(String[] args) throws ImageReadException, IOException {
+ public static void main(final String[] args) throws ImageReadException, IOException {
if (args.length == 0) {
// Print usage and exit
- for (String s : USAGE) {
+ for (final String s : USAGE) {
System.err.println(s);
}
System.exit(0);
}
- File target = new File(args[0]);
+ final File target = new File(args[0]);
String outputPath = null;
if (args.length == 2) {
outputPath = args[1];
}
- boolean optionalImageWritingEnabled
+ final boolean optionalImageWritingEnabled
= outputPath != null && !outputPath.isEmpty();
- ByteSourceFile byteSource = new ByteSourceFile(target);
+ final ByteSourceFile byteSource = new ByteSourceFile(target);
// Establish a TiffReader. This is just a simple constructor that
// does not actually access the file. So the application cannot
// obtain the byteOrder, or other details, until the contents has
// been read. Then read the directories associated with the
// file by passing in the byte source and options.
- TiffReader tiffReader = new TiffReader(true);
+ final TiffReader tiffReader = new TiffReader(true);
// Read the directories in the TIFF file. Directories are the
// main data element of a TIFF file. They usually include an image
@@ -92,7 +92,7 @@ public class ReadAndRenderFloatingPoint {
// reads all the directories in the file, but if we were interested
// in just the first element, Commons Imaging provides alternate API's
// that would be more efficient.
- TiffContents contents = tiffReader.readDirectories(
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true, // indicates that application should read image data, if present
FormatCompliance.getDefault());
@@ -101,7 +101,7 @@ public class ReadAndRenderFloatingPoint {
// Render the first directory in the file. A practical implementation
// could use any of the directories in the file. This demo uses the
// first one just for simplicity.
- TiffDirectory directory = contents.directories.get(0);
+ final TiffDirectory directory = contents.directories.get(0);
// Render the first directory in the file
if (!directory.hasTiffImageData()) {
System.err.println("First directory in file does not have image");
@@ -121,9 +121,9 @@ public class ReadAndRenderFloatingPoint {
// The getFieldValue call allows an application to provide a
// boolean indicating that the field must be present for processing
// to continue. If it does not, an exception is thrown.
- short[] sampleFormat = directory.getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, true);
- short samplesPerPixel = directory.getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL);
- short[] bitsPerPixel = directory.getFieldValue(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, true);
+ final short[] sampleFormat = directory.getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, true);
+ final short samplesPerPixel = directory.getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLES_PER_PIXEL);
+ final short[] bitsPerPixel = directory.getFieldValue(TiffTagConstants.TIFF_TAG_BITS_PER_SAMPLE, true);
if (sampleFormat[0] != TiffTagConstants.SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT) {
System.err.println("This example requires a data source with a floating-point format");
System.exit(-1);
@@ -146,22 +146,22 @@ public class ReadAndRenderFloatingPoint {
// good interpretation, we need to read the data twice.
// For this demo, we store the Photometric Interpreter instance
// as a option-parameter to be passed into the read-image method.
- PhotometricInterpreterFloat pi = new PhotometricInterpreterFloat(0.0f, 1.0f);
+ final PhotometricInterpreterFloat pi = new PhotometricInterpreterFloat(0.0f, 1.0f);
HashMap<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER, pi);
BufferedImage bImage = directory.getTiffImage(params);
- float maxValue = pi.getMaxFound();
- float minValue = pi.getMinFound();
+ final float maxValue = pi.getMaxFound();
+ final float minValue = pi.getMinFound();
// System.out.format("Image size %dx%d%n", bImage.getWidth(), bImage.getHeight());
// System.out.format("Range of values in TIFF: %f %f%n", minValue, maxValue);
if (optionalImageWritingEnabled) {
- File output = new File(outputPath);
+ final File output = new File(outputPath);
// create a new photometric interpreter based on the range
// of values found above.
- PhotometricInterpreterFloat grayScale
+ final PhotometricInterpreterFloat grayScale
= new PhotometricInterpreterFloat(minValue, maxValue);
params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER, grayScale);
diff --git a/src/test/java/org/apache/commons/imaging/examples/tiff/ReadTagsAndImages.java b/src/test/java/org/apache/commons/imaging/examples/tiff/ReadTagsAndImages.java
index 9b9f680..694ad18 100644
--- a/src/test/java/org/apache/commons/imaging/examples/tiff/ReadTagsAndImages.java
+++ b/src/test/java/org/apache/commons/imaging/examples/tiff/ReadTagsAndImages.java
@@ -57,26 +57,26 @@ public class ReadTagsAndImages {
* internal data format or version compatibility error reading the image.
* @throws java.io.IOException in the event of an I/O error.
*/
- public static void main(String[] args)
+ public static void main(final String[] args)
throws ImageReadException, IOException {
if (args.length == 0) {
// Print usage and exit
- for (String s : USAGE) {
+ for (final String s : USAGE) {
System.err.println(s);
}
System.exit(0);
}
- File target = new File(args[0]);
+ final File target = new File(args[0]);
String rootName = null;
if (args.length == 2) {
rootName = args[1];
}
- boolean optionalImageReadingEnabled
+ final boolean optionalImageReadingEnabled
= rootName != null && !rootName.isEmpty();
- ByteSourceFile byteSource = new ByteSourceFile(target);
- HashMap<String, Object> params = new HashMap<>();
+ final ByteSourceFile byteSource = new ByteSourceFile(target);
+ final HashMap<String, Object> params = new HashMap<>();
// Establish a TiffReader. This is just a simple constructor that
@@ -84,8 +84,8 @@ public class ReadTagsAndImages {
// obtain the byteOrder, or other details, until the contents has
// been read. Then read the directories associated with the
// file by passing in the byte source and options.
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
optionalImageReadingEnabled, // read image data, if present
FormatCompliance.getDefault());
@@ -93,16 +93,16 @@ public class ReadTagsAndImages {
// Loop on the directories and fetch the metadata and
// image (if available, and configured to do so)
int iDirectory = 0;
- for (TiffDirectory directory : contents.directories) {
+ for (final TiffDirectory directory : contents.directories) {
// Get the metadata (Tags) and write them to standard output
- boolean hasTiffImageData = directory.hasTiffImageData();
+ final boolean hasTiffImageData = directory.hasTiffImageData();
System.out.format("Directory %2d %s, description: %s%n",
iDirectory,
hasTiffImageData ? "Has TIFF Image Data" : "No TIFF Image Data",
directory.description());
// Loop on the fields, printing the metadata (fields) ----------
- List<TiffField> fieldList = directory.getDirectoryEntries();
- for (TiffField tiffField : fieldList) {
+ final List<TiffField> fieldList = directory.getDirectoryEntries();
+ for (final TiffField tiffField : fieldList) {
String s = tiffField.toString();
if (s.length() > 90) {
s = s.substring(0, 90);
@@ -112,17 +112,17 @@ public class ReadTagsAndImages {
// will be truncated. Therefore, indicate the numnber of entries.
// These fields are indicated by numerical tags 0x144 and 0x145
if (tiffField.getTag() == 0x144 || tiffField.getTag() == 0x145) {
- int i = s.indexOf(')');
- int[] a = tiffField.getIntArrayValue();
+ final int i = s.indexOf(')');
+ final int[] a = tiffField.getIntArrayValue();
s = s.substring(0, i + 2) + " [" + a.length + " entries]";
}
System.out.println(" " + s);
}
if (optionalImageReadingEnabled && hasTiffImageData) {
- File output = new File(rootName + "_" + iDirectory + ".jpg");
+ final File output = new File(rootName + "_" + iDirectory + ".jpg");
System.out.println("Writing image to " + output.getPath());
- BufferedImage bImage = directory.getTiffImage(params);
+ final BufferedImage bImage = directory.getTiffImage(params);
ImageIO.write(bImage, "JPEG", output);
}
System.out.println("");
diff --git a/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFile.java b/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFile.java
index 42ee847..8e2499a 100644
--- a/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFile.java
+++ b/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFile.java
@@ -49,23 +49,23 @@ import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants;
*/
public class SurveyTiffFile {
- public String surveyFile(File file, boolean csv) throws ImageReadException, IOException {
+ public String surveyFile(final File file, final boolean csv) throws ImageReadException, IOException {
String delimiter = " ";
if (csv) {
delimiter = ", ";
}
- StringBuilder sb = new StringBuilder();
- Formatter fmt = new Formatter(sb);
+ final StringBuilder sb = new StringBuilder();
+ final Formatter fmt = new Formatter(sb);
// Establish a TiffReader. This is just a simple constructor that
// does not actually access the file. So the application cannot
// obtain the byteOrder, or other details, until the contents have
// been read. Then read the directories associated with the
// file by passing in the byte source and options.
- ByteSourceFile byteSource = new ByteSourceFile(file);
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final ByteSourceFile byteSource = new ByteSourceFile(file);
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
false, // read image data, if present
FormatCompliance.getDefault());
@@ -73,10 +73,10 @@ public class SurveyTiffFile {
if (contents.directories.isEmpty()) {
throw new ImageReadException("No Image File Directory (IFD) found");
}
- TiffDirectory directory = contents.directories.get(0);
+ final TiffDirectory directory = contents.directories.get(0);
// Get the metadata (Tags) and write them to standard output
- boolean hasTiffImageData = directory.hasTiffImageData();
+ final boolean hasTiffImageData = directory.hasTiffImageData();
if (!hasTiffImageData) {
throw new ImageReadException("No image data in file");
}
@@ -108,7 +108,7 @@ public class SurveyTiffFile {
int tileWidth = 0;
int tileHeight = 0;
- boolean imageDataInStrips = directory.imageDataInStrips();
+ final boolean imageDataInStrips = directory.imageDataInStrips();
if (imageDataInStrips) {
final TiffField rowsPerStripField
= directory.findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP);
@@ -138,13 +138,13 @@ public class SurveyTiffFile {
tileHeight = tileLengthField.getIntValue();
}
- String compressionString = getCompressionString(directory);
- String predictorString = getPredictorString(directory);
- String planarConfigurationString = getPlanarConfigurationString(directory);
- String bitsPerSampleString = getBitsPerSampleString(bitsPerSample);
- String sampleFmtString = getSampleFormatString(directory);
- String piString = getPhotometricInterpreterString(directory, bitsPerSample);
- String iccString = getIccProfileString(directory);
+ final String compressionString = getCompressionString(directory);
+ final String predictorString = getPredictorString(directory);
+ final String planarConfigurationString = getPlanarConfigurationString(directory);
+ final String bitsPerSampleString = getBitsPerSampleString(bitsPerSample);
+ final String sampleFmtString = getSampleFormatString(directory);
+ final String piString = getPhotometricInterpreterString(directory, bitsPerSample);
+ final String iccString = getIccProfileString(directory);
fmt.format("%s%4dx%-4d", delimiter, width, height);
if (imageDataInStrips) {
@@ -168,7 +168,7 @@ public class SurveyTiffFile {
return sb.toString();
}
- private String getCompressionString(TiffDirectory directory) throws ImageReadException {
+ private String getCompressionString(final TiffDirectory directory) throws ImageReadException {
final short compressionFieldValue;
if (directory.findField(TiffTagConstants.TIFF_TAG_COMPRESSION) != null) {
compressionFieldValue
@@ -199,7 +199,7 @@ public class SurveyTiffFile {
}
}
- String getPredictorString(TiffDirectory directory) throws ImageReadException {
+ String getPredictorString(final TiffDirectory directory) throws ImageReadException {
int predictor = -1;
final TiffField predictorField = directory.findField(
@@ -219,8 +219,8 @@ public class SurveyTiffFile {
}
}
- String getSampleFormatString(TiffDirectory directory) throws ImageReadException {
- short[] sSampleFmt = directory.getFieldValue(
+ String getSampleFormatString(final TiffDirectory directory) throws ImageReadException {
+ final short[] sSampleFmt = directory.getFieldValue(
TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, false);
if (sSampleFmt == null || sSampleFmt.length == 0) {
return "Unknown";
@@ -232,7 +232,7 @@ public class SurveyTiffFile {
break;
}
}
- int test = sSampleFmt[0];
+ final int test = sSampleFmt[0];
switch (test) {
case TiffTagConstants.SAMPLE_FORMAT_VALUE_COMPLEX_INTEGER:
return "Comp I" + heterogeneous;
@@ -248,8 +248,8 @@ public class SurveyTiffFile {
}
}
- String getBitsPerSampleString(int[] bitsPerSample) {
- StringBuilder s = new StringBuilder();
+ String getBitsPerSampleString(final int[] bitsPerSample) {
+ final StringBuilder s = new StringBuilder();
for (int i = 0; i < bitsPerSample.length; i++) {
if (i > 0) {
s.append(".");
@@ -259,7 +259,7 @@ public class SurveyTiffFile {
return s.toString();
}
- private String getPhotometricInterpreterString(TiffDirectory directory, int[] bitsPerSample) throws ImageReadException {
+ private String getPhotometricInterpreterString(final TiffDirectory directory, final int[] bitsPerSample) throws ImageReadException {
final int photometricInterpretation = 0xffff & directory.getFieldValue(
TiffTagConstants.TIFF_TAG_PHOTOMETRIC_INTERPRETATION);
@@ -271,7 +271,7 @@ public class SurveyTiffFile {
case 2:
String a = "RGB";
if (bitsPerSample.length == 4) {
- Object o = directory.getFieldValue(TiffTagConstants.TIFF_TAG_EXTRA_SAMPLES);
+ final Object o = directory.getFieldValue(TiffTagConstants.TIFF_TAG_EXTRA_SAMPLES);
short extraSamples = 0;
if (o instanceof Short) {
extraSamples = ((Short) o);
@@ -304,8 +304,8 @@ public class SurveyTiffFile {
}
- String getIccProfileString(TiffDirectory directory) throws ImageReadException {
- byte[] b = directory.getFieldValue(TiffEpTagConstants.EXIF_TAG_INTER_COLOR_PROFILE,
+ String getIccProfileString(final TiffDirectory directory) throws ImageReadException {
+ final byte[] b = directory.getFieldValue(TiffEpTagConstants.EXIF_TAG_INTER_COLOR_PROFILE,
false);
if (b == null || b.length == 0) {
return "N";
@@ -313,7 +313,7 @@ public class SurveyTiffFile {
return "Y";
}
- String getPlanarConfigurationString(TiffDirectory directory) throws ImageReadException {
+ String getPlanarConfigurationString(final TiffDirectory directory) throws ImageReadException {
// Obtain the planar configuration
final TiffField pcField = directory.findField(
@@ -340,7 +340,7 @@ public class SurveyTiffFile {
* files.
* @return a valid string.
*/
- String formatHeader(int maxPathLen, boolean csv) {
+ String formatHeader(final int maxPathLen, final boolean csv) {
// After some false starts, it turned out that the easiest
// way to do this is just to create a regular header and then
// search-and-replace spaces with comma as appropriate.
@@ -348,10 +348,10 @@ public class SurveyTiffFile {
if (n < 10) {
n = 10;
}
- int k0 = (n - 4) / 2;
- int k1 = (n - 4 - k0);
+ final int k0 = (n - 4) / 2;
+ final int k1 = (n - 4 - k0);
- String header = String.format(
+ final String header = String.format(
"%" + k0 + "sPath%" + k1 + "s%s", "", "",
" Size Layout Blk_sz P_conf Compress "
+ "Predict Data_Fmt B/P B/S Photo ICC_Pro");
@@ -366,7 +366,7 @@ public class SurveyTiffFile {
*
* @param ps a valid instance
*/
- void printLegend(PrintStream ps) {
+ void printLegend(final PrintStream ps) {
ps.println("Legend:");
ps.println(" Size Size of image (width-by-height)");
ps.println(" Layout Organization of the image file (strips versus tiles)");
@@ -391,8 +391,8 @@ public class SurveyTiffFile {
* @param s a valid string
* @return a header suitable for a CSV file.
*/
- private String reformatHeaderForCsv(String s) {
- StringBuilder sb = new StringBuilder(s.length());
+ private String reformatHeaderForCsv(final String s) {
+ final StringBuilder sb = new StringBuilder(s.length());
boolean enableComma = false;
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
@@ -418,13 +418,13 @@ public class SurveyTiffFile {
* @param source the standard source file
* @return the equivalent string with spaces removed.
*/
- private String trimForCsv(StringBuilder source) {
+ private String trimForCsv(final StringBuilder source) {
int n = source.length();
- StringBuilder sb = new StringBuilder(n);
+ final StringBuilder sb = new StringBuilder(n);
boolean spaceEnabled = false;
boolean spacePending = false;
for (int i = 0; i < n; i++) {
- char c = source.charAt(i);
+ final char c = source.charAt(i);
if (Character.isWhitespace(c)) {
if (spaceEnabled) {
spacePending = true;
diff --git a/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFolder.java b/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFolder.java
index 5c5e287..fea5b8e 100644
--- a/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFolder.java
+++ b/src/test/java/org/apache/commons/imaging/examples/tiff/SurveyTiffFolder.java
@@ -46,25 +46,25 @@ public class SurveyTiffFolder {
/**
* @param args the command line arguments
*/
- public static void main(String[] args) {
+ public static void main(final String[] args) {
if (args.length < 1) {
System.err.println("Missing directory path");
System.exit(-1);
}
- File topLevelDir = new File(args[0]);
+ final File topLevelDir = new File(args[0]);
if (!topLevelDir.isDirectory() || !topLevelDir.canRead()) {
System.err.println("Path specification is not an accessible directory " + args[0]);
System.exit(-1);
}
// recursively survey file paths
- String[] scratch = new String[256];
- List<String[]> pathList = new ArrayList<>();
+ final String[] scratch = new String[256];
+ final List<String[]> pathList = new ArrayList<>();
collectPaths(topLevelDir, pathList, scratch, 0);
pathList.sort(new PathComparator());
// find maximum lengths of each entry
- int[] maxLen = findMaxLengths(pathList);
+ final int[] maxLen = findMaxLengths(pathList);
// If args.length is 1, write report to System.out,
// otherwise, write to a file.
@@ -74,19 +74,19 @@ public class SurveyTiffFolder {
boolean csv = false;
- int i = args[1].lastIndexOf('.');
+ final int i = args[1].lastIndexOf('.');
if (i > 0) {
- String ext = args[1].substring(i);
+ final String ext = args[1].substring(i);
if (".csv".equalsIgnoreCase(ext)) {
csv = true;
}
}
- File reportFile = new File(args[1]);
+ final File reportFile = new File(args[1]);
try (FileOutputStream fos = new FileOutputStream(reportFile);
BufferedOutputStream bos = new BufferedOutputStream(fos);
PrintStream ps = new PrintStream(bos, true, "UTF-8")) {
surveyFiles(topLevelDir, pathList, maxLen, csv, ps);
- } catch (IOException ioex) {
+ } catch (final IOException ioex) {
System.err.println("IOException writing report to " + args[1]);
System.err.println("" + ioex.getMessage());
}
@@ -94,28 +94,28 @@ public class SurveyTiffFolder {
}
private static int collectPaths(
- File parent,
- List<String[]> pathList,
- String[] scratch,
- int depth) {
+ final File parent,
+ final List<String[]> pathList,
+ final String[] scratch,
+ final int depth) {
if (depth == scratch.length) {
// directory hierarchy is too deep
return 0;
}
- File[] files = parent.listFiles();
- for (File f : files) {
+ final File[] files = parent.listFiles();
+ for (final File f : files) {
if (!f.isHidden()) {
- String name = f.getName();
+ final String name = f.getName();
scratch[depth] = name;
if (f.isDirectory()) {
collectPaths(f, pathList, scratch, depth + 1);
} else {
- int i = name.lastIndexOf('.');
+ final int i = name.lastIndexOf('.');
if (i > 0) {
- String ext = name.substring(i).toLowerCase();
+ final String ext = name.substring(i).toLowerCase();
if (".tif".equals(ext) || ".tiff".equals(ext)) {
- String[] temp = new String[depth + 1];
+ final String[] temp = new String[depth + 1];
System.arraycopy(scratch, 0, temp, 0, depth + 1);
pathList.add(temp);
}
@@ -129,12 +129,12 @@ public class SurveyTiffFolder {
private static class PathComparator implements Comparator<String[]> {
@Override
- public int compare(String[] a, String[] b) {
+ public int compare(final String[] a, final String[] b) {
for (int i = 0; i < a.length && i < b.length; i++) {
int test;
if (isNumeric(a[i]) && isNumeric(b[i])) {
- int iA = Integer.parseInt(a[i]);
- int iB = Integer.parseInt(b[i]);
+ final int iA = Integer.parseInt(a[i]);
+ final int iB = Integer.parseInt(b[i]);
test = iA - iB;
} else {
test = a[i].compareTo(b[i]);
@@ -152,7 +152,7 @@ public class SurveyTiffFolder {
return 1;
}
- private boolean isNumeric(String a) {
+ private boolean isNumeric(final String a) {
for (int i = 0; i < a.length(); i++) {
if (!Character.isDigit(a.charAt(i))) {
return false;
@@ -163,9 +163,9 @@ public class SurveyTiffFolder {
}
- private static int[] findMaxLengths(List<String[]> pathList) {
+ private static int[] findMaxLengths(final List<String[]> pathList) {
int[] m = new int[1];
- for (String[] s : pathList) {
+ for (final String[] s : pathList) {
if (s.length > m.length) {
m = Arrays.copyOf(m, s.length);
}
@@ -178,8 +178,8 @@ public class SurveyTiffFolder {
return m;
}
- private static void surveyFiles(File topDir, List<String[]> pathList, int[] maxLen, boolean csv, PrintStream ps) {
- SurveyTiffFile surveyor = new SurveyTiffFile();
+ private static void surveyFiles(final File topDir, final List<String[]> pathList, final int[] maxLen, final boolean csv, final PrintStream ps) {
+ final SurveyTiffFile surveyor = new SurveyTiffFile();
int n = maxLen.length - 1;
for (int i = 0; i < maxLen.length; i++) {
n += maxLen[i];
@@ -188,14 +188,14 @@ public class SurveyTiffFolder {
n = 10;
}
- String header = surveyor.formatHeader(n, csv);
+ final String header = surveyor.formatHeader(n, csv);
ps.println(header);
- List<String> badFiles = new ArrayList<>();
- for (String[] path : pathList) {
- StringBuilder sBuilder = new StringBuilder();
+ final List<String> badFiles = new ArrayList<>();
+ for (final String[] path : pathList) {
+ final StringBuilder sBuilder = new StringBuilder();
File file = topDir;
- for (String s : path) {
+ for (final String s : path) {
file = new File(file, s);
}
for (int i = 0; i < path.length; i++) {
@@ -224,7 +224,7 @@ public class SurveyTiffFolder {
if (!csv && !badFiles.isEmpty()) {
ps.println();
ps.println("Bad Files:");
- for (String s : badFiles) {
+ for (final String s : badFiles) {
ps.println(s);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java
index 8669337..13ef1d8 100644
--- a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java
@@ -39,10 +39,10 @@ public class BmpImageParserTest {
*/
@Test
public void testImageWidthRounding() throws ImageReadException, IOException {
- String file = "/images/bmp/IMAGING-264/test-72_6-dpi.bmp";
- File bmp = new File(BmpImageParser.class.getResource(file).getFile());
+ final String file = "/images/bmp/IMAGING-264/test-72_6-dpi.bmp";
+ final File bmp = new File(BmpImageParser.class.getResource(file).getFile());
final BmpImageParser parser = new BmpImageParser();
- ImageInfo imageInfo = parser.getImageInfo(bmp, Collections.emptyMap());
+ final ImageInfo imageInfo = parser.getImageInfo(bmp, Collections.emptyMap());
assertEquals(73, imageInfo.getPhysicalWidthDpi(), "Expected 72.6 resolution to be rounded to 73");
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java
index ccaa4fc..a0fb51f 100644
--- a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java
@@ -44,7 +44,7 @@ public class BmpReadTest extends BmpBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testImageInfo(File imageFile) throws ImageReadException, IOException {
+ public void testImageInfo(final File imageFile) throws ImageReadException, IOException {
final Map<String, Object> params = Collections.emptyMap();
final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, params);
assertNotNull(imageInfo);
@@ -54,7 +54,7 @@ public class BmpReadTest extends BmpBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testMetaData(File imageFile) {
+ public void testMetaData(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getMetadata(imageFile);
});
@@ -62,7 +62,7 @@ public class BmpReadTest extends BmpBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testBufferedImage(File imageFile) throws Exception {
+ public void testBufferedImage(final File imageFile) throws Exception {
final BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
// TODO assert more
@@ -77,7 +77,7 @@ public class BmpReadTest extends BmpBaseTest {
*/
@Test
public void testGetMaskShiftZeroMask() throws ImageReadException, IOException {
- File inputFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER +
+ final File inputFile = new File(ImagingTestConstants.TEST_IMAGE_FOLDER +
"/bmp/5/@broken/timeout-bd15dbfa26b4e88070de540c6603039e8a88626f");
new BmpImageParser().dumpImageFile(new ByteSourceFile(inputFile));
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java
index f3c47f0..195ac6c 100644
--- a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java
@@ -39,7 +39,7 @@ public class DcxReadTest extends DcxBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testImageMetadata(File imageFile) {
+ public void testImageMetadata(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getMetadata(imageFile);
});
@@ -48,13 +48,13 @@ public class DcxReadTest extends DcxBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testImageInfo(File imageFile) throws Exception {
+ public void testImageInfo(final File imageFile) throws Exception {
Imaging.getImageInfo(imageFile, Collections.emptyMap());
}
@ParameterizedTest
@MethodSource("data")
- public void testBufferedImage(File imageFile) throws Exception {
+ public void testBufferedImage(final File imageFile) throws Exception {
final BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
// TODO assert more
diff --git a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
index 81ebbb0..ae46679 100644
--- a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java
@@ -52,7 +52,7 @@ public class GifReadTest extends GifBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testMetadata(File imageFile) {
+ public void testMetadata(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getMetadata(imageFile);
});
@@ -60,7 +60,7 @@ public class GifReadTest extends GifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testImageInfo(File imageFile) throws Exception {
+ public void testImageInfo(final File imageFile) throws Exception {
final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
assertNotNull(imageInfo);
// TODO assert more
@@ -68,7 +68,7 @@ public class GifReadTest extends GifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testImageDimensions(File imageFile) throws Exception {
+ public void testImageDimensions(final File imageFile) throws Exception {
final ImageInfo imageInfo = Imaging.getImageInfo(imageFile);
final GifImageMetadata metadata = (GifImageMetadata) Imaging.getMetadata(imageFile);
final List<BufferedImage> images = Imaging.getAllBufferedImages(imageFile);
@@ -92,7 +92,7 @@ public class GifReadTest extends GifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testBufferedImage(File imageFile) throws Exception {
+ public void testBufferedImage(final File imageFile) throws Exception {
final BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
// TODO assert more
@@ -100,36 +100,36 @@ public class GifReadTest extends GifBaseTest {
@ParameterizedTest
@MethodSource("singleImageData")
- public void testBufferedImagesForSingleImageGif(File imageFile) throws Exception {
+ public void testBufferedImagesForSingleImageGif(final File imageFile) throws Exception {
final List<BufferedImage> images = Imaging.getAllBufferedImages(imageFile);
assertTrue(images.size() == 1);
}
@ParameterizedTest
@MethodSource("animatedImageData")
- public void testBufferedImagesForAnimatedImageGif(File imageFile) throws Exception {
+ public void testBufferedImagesForAnimatedImageGif(final File imageFile) throws Exception {
final List<BufferedImage> images = Imaging.getAllBufferedImages(imageFile);
assertTrue(images.size() > 1);
}
@Test
public void testCreateMetadataWithDisposalMethods() {
- for(DisposalMethod disposalMethod : DisposalMethod.values()) {
- GifImageMetadataItem metadataItem = new GifImageMetadataItem(0, 0, 0, disposalMethod);
+ for(final DisposalMethod disposalMethod : DisposalMethod.values()) {
+ final GifImageMetadataItem metadataItem = new GifImageMetadataItem(0, 0, 0, disposalMethod);
Assertions.assertEquals(disposalMethod, metadataItem.getDisposalMethod());
}
}
@Test
public void testConvertValidDisposalMethodValues() throws ImageReadException {
- DisposalMethod unspecified = GifImageParser.createDisposalMethodFromIntValue(0);
- DisposalMethod doNotDispose = GifImageParser.createDisposalMethodFromIntValue(1);
- DisposalMethod restoreToBackground = GifImageParser.createDisposalMethodFromIntValue(2);
- DisposalMethod restoreToPrevious = GifImageParser.createDisposalMethodFromIntValue(3);
- DisposalMethod toBeDefined1 = GifImageParser.createDisposalMethodFromIntValue(4);
- DisposalMethod toBeDefined2 = GifImageParser.createDisposalMethodFromIntValue(5);
- DisposalMethod toBeDefined3 = GifImageParser.createDisposalMethodFromIntValue(6);
- DisposalMethod toBeDefined4 = GifImageParser.createDisposalMethodFromIntValue(7);
+ final DisposalMethod unspecified = GifImageParser.createDisposalMethodFromIntValue(0);
+ final DisposalMethod doNotDispose = GifImageParser.createDisposalMethodFromIntValue(1);
+ final DisposalMethod restoreToBackground = GifImageParser.createDisposalMethodFromIntValue(2);
+ final DisposalMethod restoreToPrevious = GifImageParser.createDisposalMethodFromIntValue(3);
+ final DisposalMethod toBeDefined1 = GifImageParser.createDisposalMethodFromIntValue(4);
+ final DisposalMethod toBeDefined2 = GifImageParser.createDisposalMethodFromIntValue(5);
+ final DisposalMethod toBeDefined3 = GifImageParser.createDisposalMethodFromIntValue(6);
+ final DisposalMethod toBeDefined4 = GifImageParser.createDisposalMethodFromIntValue(7);
Assertions.assertEquals(unspecified, DisposalMethod.UNSPECIFIED);
Assertions.assertEquals(doNotDispose, DisposalMethod.DO_NOT_DISPOSE);
Assertions.assertEquals(restoreToBackground, DisposalMethod.RESTORE_TO_BACKGROUND);
diff --git a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java
index afe4bd7..bc50441 100644
--- a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java
@@ -63,7 +63,7 @@ public class IcnsReadTest extends IcnsBaseTest {
@Disabled(value = "RoundtripTest has to be fixed befor implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testImageMetadata(File imageFile) {
+ public void testImageMetadata(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getMetadata(imageFile);
});
@@ -71,14 +71,14 @@ public class IcnsReadTest extends IcnsBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testImageInfo(File imageFile) throws Exception {
+ public void testImageInfo(final File imageFile) throws Exception {
final ImageInfo imageInfo = Imaging.getImageInfo(imageFile, Collections.emptyMap());
assertNotNull(imageInfo);
}
@ParameterizedTest
@MethodSource("data")
- public void testBufferedImage(File imageFile) throws Exception {
+ public void testBufferedImage(final File imageFile) throws Exception {
final BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
// TODO assert more
@@ -92,9 +92,9 @@ public class IcnsReadTest extends IcnsBaseTest {
*/
@ParameterizedTest()
@MethodSource("provideIcnsImagesWithMonoAndJpegPngData")
- public void testIcnsElementMonoPngJpeg(String file, int numberOfImages) throws ImageReadException, IOException {
- File testFile = new File(IcnsReadTest.class.getResource(file).getFile());
- List<BufferedImage> images = new IcnsImageParser().getAllBufferedImages(testFile);
+ public void testIcnsElementMonoPngJpeg(final String file, final int numberOfImages) throws ImageReadException, IOException {
+ final File testFile = new File(IcnsReadTest.class.getResource(file).getFile());
+ final List<BufferedImage> images = new IcnsImageParser().getAllBufferedImages(testFile);
assertEquals(numberOfImages, images.size());
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java b/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java
index 24bd4f0..b409432 100644
--- a/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java
@@ -39,7 +39,7 @@ public class IcoReadTest extends IcoBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testMetadata(File imageFile) {
+ public void testMetadata(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getMetadata(imageFile);
});
@@ -48,7 +48,7 @@ public class IcoReadTest extends IcoBaseTest {
@Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException")
@ParameterizedTest
@MethodSource("data")
- public void testImageInfo(File imageFile) {
+ public void testImageInfo(final File imageFile) {
Assertions.assertThrows(UnsupportedOperationException.class, () -> {
Imaging.getImageInfo(imageFile, Collections.emptyMap());
});
@@ -56,7 +56,7 @@ public class IcoReadTest extends IcoBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testBufferedImage(File imageFile) throws Exception {
+ public void testBufferedImage(final File imageFile) throws Exception {
final BufferedImage image = Imaging.getBufferedImage(imageFile);
assertNotNull(image);
// TODO assert more
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
index eb8831c..cbab4a3 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegReadTest.java
@@ -43,7 +43,7 @@ public class JpegReadTest extends JpegBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void test(File imageFile) throws Exception {
+ public void test(final File imageFile) throws Exception {
final Map<String, Object> params = new HashMap<>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java
index 6a408a7..509fcc5 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java
@@ -28,10 +28,10 @@ public class JpegInputStreamTest {
@Test
public void testNextBitThrowsImageReadExceptionOne() {
- int[] byteArray = new int[6];
+ final int[] byteArray = new int[6];
byteArray[0] = (byte) (-1);
byteArray[1] = (byte) 74;
- JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
+ final JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
Assertions.assertThrows(ImageReadException.class, () -> {
jpegInputStream.nextBit();
@@ -41,8 +41,8 @@ public class JpegInputStreamTest {
@Test
public void testNextBitThrowsImageReadExceptionTwo() {
- int[] byteArray = new int[0];
- JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
+ final int[] byteArray = new int[0];
+ final JpegInputStream jpegInputStream = new JpegInputStream(byteArray);
Assertions.assertThrows(IllegalStateException.class, () -> {
jpegInputStream.nextBit();
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
index e9eadb1..fdb4e1e 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifDumpTest.java
@@ -42,7 +42,7 @@ public class ExifDumpTest extends ExifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testDumpJFIF(File imageFile) throws Exception {
+ public void testDumpJFIF(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
Debug.debug("Segments:");
new JpegUtils().dumpJFIF(byteSource);
@@ -51,7 +51,7 @@ public class ExifDumpTest extends ExifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testMetadata(File imageFile) throws Exception {
+ public void testMetadata(final File imageFile) throws Exception {
final Map<String, Object> params = new HashMap<>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
index 052b3a4..7cdf91c 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/GpsTest.java
@@ -38,7 +38,7 @@ public class GpsTest extends ExifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void test(File imageFile) throws Exception {
+ public void test(final File imageFile) throws Exception {
if (imageFile.getParentFile().getName().toLowerCase().equals("@broken")) {
return;
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
index 64aefec..ac85c19 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/SpecificExifTagTest.java
@@ -43,7 +43,7 @@ public abstract class SpecificExifTagTest extends ExifBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testAllImages(File imageFile) throws Exception {
+ public void testAllImages(final File imageFile) throws Exception {
if (imageFile.getParentFile().getName().toLowerCase().equals("@broken")) {
return;
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/WriteExifMetadataExampleTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/WriteExifMetadataExampleTest.java
index 0b3aab9..5159d65 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/WriteExifMetadataExampleTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/WriteExifMetadataExampleTest.java
@@ -43,7 +43,7 @@ public class WriteExifMetadataExampleTest extends ExifBaseTest {
*/
@ParameterizedTest
@MethodSource("data")
- public void testOddOffsets(File imageFile) throws Exception {
+ public void testOddOffsets(final File imageFile) throws Exception {
Debug.debug("imageFile", imageFile.getAbsoluteFile());
final File tempFile = File.createTempFile("test", ".jpg");
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcAddTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcAddTest.java
index 6c1c2f3..89f5608 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcAddTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcAddTest.java
@@ -50,7 +50,7 @@ public class IptcAddTest extends IptcBaseTest {
*/
@ParameterizedTest
@MethodSource("data")
- public void testAddIptcData(File imageFile) throws Exception {
+ public void testAddIptcData(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
index e3c28d2..1ee9e22 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcDumpTest.java
@@ -41,7 +41,7 @@ public class IptcDumpTest extends IptcBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void test(File imageFile) throws Exception {
+ public void test(final File imageFile) throws Exception {
final Map<String, Object> params = new HashMap<>();
final boolean ignoreImageData = isPhilHarveyTestImage(imageFile);
params.put(ImagingConstants.PARAM_KEY_READ_THUMBNAILS, Boolean.valueOf(!ignoreImageData));
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParserTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParserTest.java
index 55ce17b..5c178a0 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParserTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParserTest.java
@@ -67,14 +67,14 @@ public class IptcParserTest {
final PhotoshopApp13Data photoshopApp13Data = photoshopMetadata.photoshopApp13Data;
final List<IptcBlock> blocks = photoshopApp13Data.getRawBlocks();
assertEquals(2, blocks.size());
- for (IptcBlock block : blocks) {
+ for (final IptcBlock block : blocks) {
if (block.getBlockType() == 1028) {
// 0x0404 IPTC-NAA record
- byte[] data = block.getBlockData();
+ final byte[] data = block.getBlockData();
assertTrue(data.length > 0);
} else if (block.getBlockType() == 1061) {
// 0x0425 (Photoshop 7.0) Caption digest
- byte[] data = block.getBlockData();
+ final byte[] data = block.getBlockData();
assertTrue(data.length > 0);
} else {
fail("Unexpected block type found: " + block.getBlockType());
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
index 8d2adc6..5a4cf8f 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcUpdateTest.java
@@ -52,7 +52,7 @@ public class IptcUpdateTest extends IptcBaseTest {
*/
@ParameterizedTest
@MethodSource("data")
- public void testRemove(File imageFile) throws Exception {
+ public void testRemove(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
@@ -73,7 +73,7 @@ public class IptcUpdateTest extends IptcBaseTest {
|| outMetadata.getItems().size() == 0);
}
- public File removeIptc(final ByteSource byteSource, File imageFile) throws Exception {
+ public File removeIptc(final ByteSource byteSource, final File imageFile) throws Exception {
final File noIptcFile = File.createTempFile(imageFile.getName() + ".iptc.remove.", ".jpg");
try (OutputStream os = new BufferedOutputStream(new FileOutputStream(noIptcFile))) {
@@ -84,7 +84,7 @@ public class IptcUpdateTest extends IptcBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testInsert(File imageFile) throws Exception {
+ public void testInsert(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
@@ -125,7 +125,7 @@ public class IptcUpdateTest extends IptcBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testUpdate(File imageFile) throws Exception {
+ public void testUpdate(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
@@ -155,7 +155,7 @@ public class IptcUpdateTest extends IptcBaseTest {
assertTrue(outMetadata.getItems().size() == 2);
}
- public File writeIptc(final ByteSource byteSource, final PhotoshopApp13Data newData, File imageFile) throws IOException, ImageReadException, ImageWriteException {
+ public File writeIptc(final ByteSource byteSource, final PhotoshopApp13Data newData, final File imageFile) throws IOException, ImageReadException, ImageWriteException {
final File updated = File.createTempFile(imageFile.getName()
+ ".iptc.update.", ".jpg");
try (FileOutputStream fos = new FileOutputStream(updated);
@@ -167,7 +167,7 @@ public class IptcUpdateTest extends IptcBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testNoChangeUpdate(File imageFile) throws Exception {
+ public void testNoChangeUpdate(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/App2SegmentTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/App2SegmentTest.java
index 02a92e8..5ad7161 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/App2SegmentTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/segments/App2SegmentTest.java
@@ -33,22 +33,22 @@ public class App2SegmentTest {
@Test
public void testEqualsReturningTrue() throws IOException, ImageReadException {
- App2Segment app2Segment = new App2Segment(0, 0, null);
+ final App2Segment app2Segment = new App2Segment(0, 0, null);
assertTrue(app2Segment.equals(app2Segment));
}
@Test
public void testEqualsReturningFalse() throws IOException, ImageReadException {
- byte[] byteArray = new byte[3];
- App2Segment app2Segment = new App2Segment(65475, byteArray);
+ final byte[] byteArray = new byte[3];
+ final App2Segment app2Segment = new App2Segment(65475, byteArray);
assertFalse(app2Segment.equals(byteArray));
}
@Test
public void testCompareTo() throws IOException, ImageReadException {
- App2Segment app2Segment = new App2Segment(0, 0, null);
+ final App2Segment app2Segment = new App2Segment(0, 0, null);
assertEquals(0, app2Segment.compareTo(app2Segment));
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpDumpTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpDumpTest.java
index 8062b39..e9f0d0e 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpDumpTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpDumpTest.java
@@ -38,7 +38,7 @@ public class JpegXmpDumpTest extends JpegXmpBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void test(File imageFile) throws Exception {
+ public void test(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
final String xmpXml = new JpegImageParser().getXmpXml(byteSource, params);
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
index f330ae3..b442920 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriteTest.java
@@ -43,7 +43,7 @@ public class JpegXmpRewriteTest extends JpegXmpBaseTest {
@ParameterizedTest
@MethodSource("data")
- public void testRemoveInsertUpdate(File imageFile) throws Exception {
+ public void testRemoveInsertUpdate(final File imageFile) throws Exception {
final ByteSource byteSource = new ByteSourceFile(imageFile);
final Map<String, Object> params = new HashMap<>();
final String xmpXml = new JpegImageParser().getXmpXml(byteSource, params);
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java
index d83da7f..db0fb78 100644
--- a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java
@@ -50,25 +50,25 @@ public class PngChunkIccpTest {
public void testParsingIccpChunk() throws ImageReadException, IOException {
final List<Byte> bytes = new ArrayList<>();
final String profileName = "my-profile-01";
- for (byte b : profileName.getBytes(StandardCharsets.ISO_8859_1)) {
+ for (final byte b : profileName.getBytes(StandardCharsets.ISO_8859_1)) {
bytes.add(b);
}
bytes.add((byte) 0); // null
bytes.add((byte) 0); // 0=deflate compression method
// generate some 100 bytes of dummy data
- byte[] uncompressedData = new byte[100];
+ final byte[] uncompressedData = new byte[100];
IntStream.range(0, 100).forEach(i -> {
uncompressedData[i] = (byte) (i + 1); // dummy data
});
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(100)) {
// compress the dummy data with deflate
- Deflater def = new Deflater();
+ final Deflater def = new Deflater();
try (DeflaterOutputStream ios = new DeflaterOutputStream(baos, def)) {
ios.write(uncompressedData);
}
baos.flush();
- byte[] compressedData = baos.toByteArray();
+ final byte[] compressedData = baos.toByteArray();
final byte[] data = new byte[bytes.size() + compressedData.length];
// gather everything, except for the compressed data
for (int i = 0; i < bytes.size(); ++i) {
diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java
index 1c9e4dc..a624b50 100644
--- a/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java
@@ -40,7 +40,7 @@ public class PgmFileInfoTest {
@Test
public void testGetBitDepth() throws ImageReadException {
- PgmFileInfo pgmFileInfo = new PgmFileInfo(65535, 65535, false, 65535);
+ final PgmFileInfo pgmFileInfo = new PgmFileInfo(65535, 65535, false, 65535);
assertEquals(65535, pgmFileInfo.getBitDepth());
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffAlphaRoundTripTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffAlphaRoundTripTest.java
index d8c7e08..20f0032 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffAlphaRoundTripTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffAlphaRoundTripTest.java
@@ -52,8 +52,8 @@ public class TiffAlphaRoundTripTest {
// Step 0, create a buffered image that includes transparency
// in the form of two rectangles, one completely opaque,
// and one giving 50 percent opaque red.
- int width = 400;
- int height = 400;
+ final int width = 400;
+ final int height = 400;
BufferedImage image0;
if (i == 0) {
image0 = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
@@ -72,16 +72,16 @@ public class TiffAlphaRoundTripTest {
// Step 1: write the Buffered Image to an output file and
// then read it back in. This action will test the
// correctness of a round-trip test.
- File file = new File(tempDir.toFile(), "TiffAlphaRoundTripTest.tif");
+ final File file = new File(tempDir.toFile(), "TiffAlphaRoundTripTest.tif");
file.delete();
- HashMap<String, Object> params = new HashMap<>();
+ final HashMap<String, Object> params = new HashMap<>();
Imaging.writeImage(image0, file, ImageFormats.TIFF, params);
- BufferedImage image1 = Imaging.getBufferedImage(file);
+ final BufferedImage image1 = Imaging.getBufferedImage(file);
// Step 2: create a composite image overlaying a white background
// with the results from the TIFF file.
- BufferedImage compImage
+ final BufferedImage compImage
= new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
g2d = compImage.createGraphics();
g2d.setColor(Color.white);
@@ -89,8 +89,8 @@ public class TiffAlphaRoundTripTest {
g2d.drawImage(image1, 0, 0, null);
// Step 3, verify that the correct values are in the image.
- int test1 = compImage.getRGB(150, 150); // in the transparent rectangle
- int test2 = compImage.getRGB(250, 250);
+ final int test1 = compImage.getRGB(150, 150); // in the transparent rectangle
+ final int test2 = compImage.getRGB(250, 250);
if (i == 0) {
doPixelsMatch(150, 150, 0xffffffff, test1);
doPixelsMatch(250, 250, 0xffff7f7f, test2);
@@ -101,13 +101,13 @@ public class TiffAlphaRoundTripTest {
}
}
- void doPixelsMatch(int x, int y, int a, int b) {
+ void doPixelsMatch(final int x, final int y, final int a, final int b) {
if (!componentMatch(a, b, 0, 2)
|| !componentMatch(a, b, 8, 2)
|| !componentMatch(a, b, 16, 2)
|| !componentMatch(a, b, 24, 2)) {
- String complaint = String.format("Pixel mismatch at (%d,%d): 0x%08x 0x%08x",
+ final String complaint = String.format("Pixel mismatch at (%d,%d): 0x%08x 0x%08x",
x, y, a, b);
fail(complaint);
}
@@ -124,7 +124,7 @@ public class TiffAlphaRoundTripTest {
* @param iTolerance a small positive integer
* @return true if the components of the values match
*/
- boolean componentMatch(int a, int b, int iShift, int iTolerance) {
+ boolean componentMatch(final int a, final int b, final int iShift, final int iTolerance) {
int delta = ((a >> iShift) & 0xff) - ((b >> iShift) & 0xff);
if (delta < 0) {
delta = -delta;
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointReadTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointReadTest.java
index 1806ad5..264a781 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointReadTest.java
@@ -54,9 +54,9 @@ public class TiffFloatingPointReadTest {
* @param name a valid file name
* @return a valid file reference.
*/
- private File getTiffFile(String name) {
- File tiffFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "tiff");
- File fpFolder = new File(tiffFolder, "9");
+ private File getTiffFile(final String name) {
+ final File tiffFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "tiff");
+ final File fpFolder = new File(tiffFolder, "9");
return new File(fpFolder, name);
}
@@ -75,26 +75,26 @@ public class TiffFloatingPointReadTest {
* @throws IOException in the event of an I/O error
*/
private PhotometricInterpreterFloat readAndInterpretTIFF(
- File target, float f0, float f1, float fNot) throws ImageReadException, IOException {
- ByteSourceFile byteSource = new ByteSourceFile(target);
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final File target, final float f0, final float f1, final float fNot) throws ImageReadException, IOException {
+ final ByteSourceFile byteSource = new ByteSourceFile(target);
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true, // indicates that application should read image data, if present
FormatCompliance.getDefault());
- ByteOrder byteOrder = tiffReader.getByteOrder();
- TiffDirectory directory = contents.directories.get(0);
+ final ByteOrder byteOrder = tiffReader.getByteOrder();
+ final TiffDirectory directory = contents.directories.get(0);
if (!directory.hasTiffFloatingPointRasterData()) {
fail("Internal error, sample file does not have floating-point data "
+ target.getName());
}
- List<PaletteEntry> pList = new ArrayList<>();
+ final List<PaletteEntry> pList = new ArrayList<>();
pList.add(new PaletteEntryForValue(fNot, Color.red));
pList.add(new PaletteEntryForRange(f0, f1, Color.black, Color.white));
- PhotometricInterpreterFloat pInterp = new PhotometricInterpreterFloat(pList);
- HashMap<String, Object> params = new HashMap<>();
+ final PhotometricInterpreterFloat pInterp = new PhotometricInterpreterFloat(pList);
+ final HashMap<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER, pInterp);
- BufferedImage bImage = directory.getTiffImage(byteOrder, params);
+ final BufferedImage bImage = directory.getTiffImage(byteOrder, params);
if (bImage == null) {
return null;
}
@@ -112,21 +112,21 @@ public class TiffFloatingPointReadTest {
* @throws IOException in the event of an I/O error
*/
private TiffRasterData readRasterFromTIFF(
- File target, Map<String, Object> params)
+ final File target, final Map<String, Object> params)
throws ImageReadException, IOException {
- ByteSourceFile byteSource = new ByteSourceFile(target);
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final ByteSourceFile byteSource = new ByteSourceFile(target);
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true, // indicates that application should read image data, if present
FormatCompliance.getDefault());
- TiffDirectory directory = contents.directories.get(0);
+ final TiffDirectory directory = contents.directories.get(0);
return directory.getFloatingPointRasterData(params);
}
@Test
public void test() {
- Map<String, Object> params = new HashMap<>();
+ final Map<String, Object> params = new HashMap<>();
// These TIFF sample data includes files that contain known
// floating-point values in various formats. We know the range
// of values from inspection using separate utilies. This
@@ -171,7 +171,7 @@ public class TiffFloatingPointReadTest {
checkSubImage(target, fullRaster, width-1, 0, 1, height); // right column
// test along the main diagnonal and a parallel that reaches the top-right corner
- int s = width-height;
+ final int s = width-height;
for(int i=0; i<height-8; i++){
checkSubImage(target, fullRaster, i, i, 8, 8);
checkSubImage(target, fullRaster, i+1, i, 8, 8);
@@ -224,20 +224,20 @@ public class TiffFloatingPointReadTest {
}
- private void checkSubImage(File target, TiffRasterData fullRaster, int x0, int y0, int width, int height){
+ private void checkSubImage(final File target, final TiffRasterData fullRaster, final int x0, final int y0, final int width, final int height){
try{
- Map<String, Object> params = new HashMap<>();
+ final Map<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, x0);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, y0);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, width);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, height);
- TiffRasterData partRaster = readRasterFromTIFF(target, params);
+ final TiffRasterData partRaster = readRasterFromTIFF(target, params);
assertEquals(width, partRaster.getWidth(), "Invalid width in partial for " + target.getName());
assertEquals(height, partRaster.getHeight(), "Invalid height in partial for " + target.getName());
for (int y = y0; y < y0+height; y++) {
for (int x = x0; x < x0+width; x++) {
- float vFull = fullRaster.getValue(x, y);
- float vPart = partRaster.getValue(x - x0, y - y0);
+ final float vFull = fullRaster.getValue(x, y);
+ final float vPart = partRaster.getValue(x - x0, y - y0);
assertEquals(vFull, vPart, "Invalid value match for partial at (" + x + "," + y + ") for "+target.getName());
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointRoundTripTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointRoundTripTest.java
index e1b34ad..a21fd6f 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointRoundTripTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointRoundTripTest.java
@@ -68,9 +68,9 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
public TiffFloatingPointRoundTripTest() {
// populate the image data
for (int iCol = 0; iCol < width; iCol++) {
- float s = iCol / (float) (width - 1);
+ final float s = iCol / (float) (width - 1);
for (int iRow = 0; iRow < height; iRow++) {
- int index = iRow * width + iCol;
+ final int index = iRow * width + iCol;
f[index] = s;
}
}
@@ -79,12 +79,12 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
// floating-point input data. The ultimate goal of the test is to verify
// that the values read back from the TIFF file match the input.
try {
- PhotometricInterpreterFloat pi = getPhotometricInterpreter();
- ImageBuilder builder = new ImageBuilder(width, height, false);
- int samples[] = new int[1];
+ final PhotometricInterpreterFloat pi = getPhotometricInterpreter();
+ final ImageBuilder builder = new ImageBuilder(width, height, false);
+ final int samples[] = new int[1];
for (int iCol = 0; iCol < width; iCol++) {
for (int iRow = 0; iRow < height; iRow++) {
- int index = iRow * width + iCol;
+ final int index = iRow * width + iCol;
samples[0] = Float.floatToRawIntBits(f[index]);
pi.interpretPixel(builder, samples, iCol, iRow);
argb[index] = builder.getRGB(iCol, iRow);
@@ -115,7 +115,7 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
// TIFF datareaders classes. So that format is not yet exercised.
// Note also that the compressed floating-point with predictor=3
// is processed in other tests, but not here.
- File[] testFile = new File[8];
+ final File[] testFile = new File[8];
testFile[0] = writeFile(32, ByteOrder.LITTLE_ENDIAN, false);
testFile[1] = writeFile(64, ByteOrder.LITTLE_ENDIAN, false);
testFile[2] = writeFile(32, ByteOrder.BIG_ENDIAN, false);
@@ -125,28 +125,28 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
testFile[6] = writeFile(32, ByteOrder.BIG_ENDIAN, true);
testFile[7] = writeFile(64, ByteOrder.BIG_ENDIAN, true);
for (int i = 0; i < testFile.length; i++) {
- String name = testFile[i].getName();
- ByteSourceFile byteSource = new ByteSourceFile(testFile[i]);
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final String name = testFile[i].getName();
+ final ByteSourceFile byteSource = new ByteSourceFile(testFile[i]);
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true, // indicates that application should read image data, if present
FormatCompliance.getDefault());
- TiffDirectory directory = contents.directories.get(0);
- PhotometricInterpreterFloat pi = getPhotometricInterpreter();
- HashMap<String, Object> params = new HashMap<>();
+ final TiffDirectory directory = contents.directories.get(0);
+ final PhotometricInterpreterFloat pi = getPhotometricInterpreter();
+ final HashMap<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_CUSTOM_PHOTOMETRIC_INTERPRETER, pi);
- ByteOrder byteOrder = tiffReader.getByteOrder();
- BufferedImage bImage = directory.getTiffImage(byteOrder, params);
+ final ByteOrder byteOrder = tiffReader.getByteOrder();
+ final BufferedImage bImage = directory.getTiffImage(byteOrder, params);
assertNotNull(bImage, "Failed to get image from " + name);
- int[] pixel = new int[width * height];
+ final int[] pixel = new int[width * height];
bImage.getRGB(0, 0, width, height, pixel, 0, width);
for (int k = 0; k < pixel.length; k++) {
assertEquals(argb[k], pixel[k],
"Extracted data does not match original, test "
+ i + ", index " + k);
}
- float meanValue = pi.getMeanFound();
+ final float meanValue = pi.getMeanFound();
assertEquals(0.5, meanValue, 1.0e-5, "Invalid numeric values in " + name);
// To write out an image file for inspection, use the following
// (with appropriate adjustments for path and OS)
@@ -156,15 +156,15 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
}
}
- private File writeFile(int bitsPerSample, ByteOrder byteOrder, boolean useTiles)
+ private File writeFile(final int bitsPerSample, final ByteOrder byteOrder, final boolean useTiles)
throws IOException, ImageWriteException {
- String name = String.format("FpRoundTrip_%2d_%s_%s.tiff",
+ final String name = String.format("FpRoundTrip_%2d_%s_%s.tiff",
bitsPerSample,
byteOrder == ByteOrder.LITTLE_ENDIAN ? "LE" : "BE",
useTiles ? "Tiles" : "Strips");
- File outputFile = new File(tempDir.toFile(), name);
+ final File outputFile = new File(tempDir.toFile(), name);
- int bytesPerSample = bitsPerSample / 8;
+ final int bytesPerSample = bitsPerSample / 8;
int nRowsInBlock;
int nColsInBlock;
int nBytesInBlock;
@@ -195,8 +195,8 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
// NOTE: At this time, Tile format is not supported.
// When it is, modify the tags below to populate
// TIFF_TAG_TILE_* appropriately.
- TiffOutputSet outputSet = new TiffOutputSet(byteOrder);
- TiffOutputDirectory outDir = outputSet.addRootDirectory();
+ final TiffOutputSet outputSet = new TiffOutputSet(byteOrder);
+ final TiffOutputDirectory outDir = outputSet.addRootDirectory();
outDir.add(TiffTagConstants.TIFF_TAG_IMAGE_WIDTH, width);
outDir.add(TiffTagConstants.TIFF_TAG_IMAGE_LENGTH, height);
outDir.add(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT,
@@ -237,7 +237,7 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
try (FileOutputStream fos = new FileOutputStream(outputFile);
BufferedOutputStream bos = new BufferedOutputStream(fos)) {
- TiffImageWriterLossy writer = new TiffImageWriterLossy(byteOrder);
+ final TiffImageWriterLossy writer = new TiffImageWriterLossy(byteOrder);
writer.write(bos, outputSet);
bos.flush();
}
@@ -261,26 +261,26 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
* @return a valid array of equally sized array.
*/
private byte[][] getBytesForOutput32(
- float[] f, int width, int height,
- int nRowsInBlock, int nColsInBlock,
- ByteOrder byteOrder) {
- int nColsOfBlocks = (width + nColsInBlock - 1) / nColsInBlock;
- int nRowsOfBlocks = (height + nRowsInBlock + 1) / nRowsInBlock;
- int bytesPerPixel = 4;
- int nBlocks = nRowsOfBlocks * nColsOfBlocks;
- int nBytesInBlock = bytesPerPixel * nRowsInBlock * nColsInBlock;
- byte[][] blocks = new byte[nBlocks][nBytesInBlock];
+ final float[] f, final int width, final int height,
+ final int nRowsInBlock, final int nColsInBlock,
+ final ByteOrder byteOrder) {
+ final int nColsOfBlocks = (width + nColsInBlock - 1) / nColsInBlock;
+ final int nRowsOfBlocks = (height + nRowsInBlock + 1) / nRowsInBlock;
+ final int bytesPerPixel = 4;
+ final int nBlocks = nRowsOfBlocks * nColsOfBlocks;
+ final int nBytesInBlock = bytesPerPixel * nRowsInBlock * nColsInBlock;
+ final byte[][] blocks = new byte[nBlocks][nBytesInBlock];
for (int i = 0; i < height; i++) {
- int blockRow = i / nRowsInBlock;
- int rowInBlock = i - blockRow * nRowsInBlock;
- int blockOffset = rowInBlock * nColsInBlock;
+ final int blockRow = i / nRowsInBlock;
+ final int rowInBlock = i - blockRow * nRowsInBlock;
+ final int blockOffset = rowInBlock * nColsInBlock;
for (int j = 0; j < width; j++) {
- int sample = Float.floatToRawIntBits(f[i * width + j]);
- int blockCol = j / nColsInBlock;
- int colInBlock = j - blockCol * nColsInBlock;
- int index = blockOffset + colInBlock;
- int offset = index * bytesPerPixel;
- byte[] b = blocks[blockRow * nColsOfBlocks + blockCol];
+ final int sample = Float.floatToRawIntBits(f[i * width + j]);
+ final int blockCol = j / nColsInBlock;
+ final int colInBlock = j - blockCol * nColsInBlock;
+ final int index = blockOffset + colInBlock;
+ final int offset = index * bytesPerPixel;
+ final byte[] b = blocks[blockRow * nColsOfBlocks + blockCol];
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
b[offset] = (byte) (sample & 0xff);
b[offset + 1] = (byte) ((sample >> 8) & 0xff);
@@ -315,26 +315,26 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
* @return a valid array of equally sized array.
*/
private byte[][] getBytesForOutput64(
- float[] f, int width, int height,
- int nRowsInBlock, int nColsInBlock,
- ByteOrder byteOrder) {
- int nColsOfBlocks = (width + nColsInBlock - 1) / nColsInBlock;
- int nRowsOfBlocks = (height + nRowsInBlock + 1) / nRowsInBlock;
- int bytesPerPixel = 8;
- int nBlocks = nRowsOfBlocks * nColsOfBlocks;
- int nBytesInBlock = bytesPerPixel * nRowsInBlock * nColsInBlock;
- byte[][] blocks = new byte[nBlocks][nBytesInBlock];
+ final float[] f, final int width, final int height,
+ final int nRowsInBlock, final int nColsInBlock,
+ final ByteOrder byteOrder) {
+ final int nColsOfBlocks = (width + nColsInBlock - 1) / nColsInBlock;
+ final int nRowsOfBlocks = (height + nRowsInBlock + 1) / nRowsInBlock;
+ final int bytesPerPixel = 8;
+ final int nBlocks = nRowsOfBlocks * nColsOfBlocks;
+ final int nBytesInBlock = bytesPerPixel * nRowsInBlock * nColsInBlock;
+ final byte[][] blocks = new byte[nBlocks][nBytesInBlock];
for (int i = 0; i < height; i++) {
- int blockRow = i / nRowsInBlock;
- int rowInBlock = i - blockRow * nRowsInBlock;
- int blockOffset = rowInBlock * nColsInBlock;
+ final int blockRow = i / nRowsInBlock;
+ final int rowInBlock = i - blockRow * nRowsInBlock;
+ final int blockOffset = rowInBlock * nColsInBlock;
for (int j = 0; j < width; j++) {
- long sample = Double.doubleToRawLongBits(f[i * width + j]);
- int blockCol = j / nColsInBlock;
- int colInBlock = j - blockCol * nColsInBlock;
- int index = blockOffset + colInBlock;
- int offset = index * bytesPerPixel;
- byte[] b = blocks[blockRow * nColsOfBlocks + blockCol];
+ final long sample = Double.doubleToRawLongBits(f[i * width + j]);
+ final int blockCol = j / nColsInBlock;
+ final int colInBlock = j - blockCol * nColsInBlock;
+ final int index = blockOffset + colInBlock;
+ final int offset = index * bytesPerPixel;
+ final byte[] b = blocks[blockRow * nColsOfBlocks + blockCol];
if (byteOrder == ByteOrder.LITTLE_ENDIAN) {
b[offset] = (byte) (sample & 0xff);
b[offset + 1] = (byte) ((sample >> 8) & 0xff);
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java
index 1e7ce73..eccaf96 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterDataTest.java
@@ -53,12 +53,12 @@ public class TiffRasterDataTest {
*/
@Test
public void testSetValue() {
- TiffRasterData instance = new TiffRasterData(width, height);
+ final TiffRasterData instance = new TiffRasterData(width, height);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int index = y * width + height;
+ final int index = y * width + height;
instance.setValue(x, y, index);
- int test = (int) instance.getValue(x, y);
+ final int test = (int) instance.getValue(x, y);
assertEquals(index, test, "Set/get value test failed");
}
}
@@ -71,8 +71,8 @@ public class TiffRasterDataTest {
public void testGetValue() {
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
- int index = y * width + x;
- int test = (int) raster.getValue(x, y);
+ final int index = y * width + x;
+ final int test = (int) raster.getValue(x, y);
assertEquals(index, test, "Get into source data test failed at (" + x + "," + y + ")");
}
}
@@ -84,7 +84,7 @@ public class TiffRasterDataTest {
@Test
public void testGetSimpleStatistics_0args() {
- TiffRasterStatistics result = raster.getSimpleStatistics();
+ final TiffRasterStatistics result = raster.getSimpleStatistics();
assertEquals(0, result.getMinValue(), "Min value failure");
assertEquals(width * height - 1, result.getMaxValue(), "Max value failure");
assertEquals(meanValue, result.getMeanValue(), "Mean value failure");
@@ -97,7 +97,7 @@ public class TiffRasterDataTest {
public void testGetSimpleStatistics_float() {
// exclude the maximum value (width*height-1). This will result
// in a max value of width*height-2
- TiffRasterStatistics result = raster.getSimpleStatistics(width * height - 1);
+ final TiffRasterStatistics result = raster.getSimpleStatistics(width * height - 1);
assertEquals(width * height - 2, result.getMaxValue(), "Max value failure");
}
@@ -122,7 +122,7 @@ public class TiffRasterDataTest {
*/
@Test
public void testGetData() {
- float[] result = raster.getData();
+ final float[] result = raster.getData();
assertArrayEquals(data, result);
}
@@ -133,36 +133,36 @@ public class TiffRasterDataTest {
@Test
public void testBadConstructor() {
try{
- TiffRasterData raster = new TiffRasterData(-1, 10);
+ final TiffRasterData raster = new TiffRasterData(-1, 10);
fail("Constructor did not detect bad width");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
try{
- TiffRasterData raster = new TiffRasterData(10, -1);
+ final TiffRasterData raster = new TiffRasterData(10, -1);
fail("Constructor did not detect bad height");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
try{
- float []f = new float[10];
- TiffRasterData raster = new TiffRasterData(2, 10, f);
+ final float []f = new float[10];
+ final TiffRasterData raster = new TiffRasterData(2, 10, f);
fail("Constructor did not detect insufficient input array size");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
try{
- float []f = new float[10];
- TiffRasterData raster = new TiffRasterData(-1, 10, f);
+ final float []f = new float[10];
+ final TiffRasterData raster = new TiffRasterData(-1, 10, f);
fail("Constructor did not detect bad width");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
try{
- float []f = new float[10];
- TiffRasterData raster = new TiffRasterData(10, -1, f);
+ final float []f = new float[10];
+ final TiffRasterData raster = new TiffRasterData(10, -1, f);
fail("Constructor did not detect bad height");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
}
@@ -174,19 +174,19 @@ public class TiffRasterDataTest {
public void testBadCoordinates() {
try{
- float []f = new float[100];
- TiffRasterData raster = new TiffRasterData(10, 10, f);
+ final float []f = new float[100];
+ final TiffRasterData raster = new TiffRasterData(10, 10, f);
raster.getValue(11, 11);
fail("Access method getValue() did not detect bad coordinates");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
try{
- float []f = new float[100];
- TiffRasterData raster = new TiffRasterData(10, 10, f);
+ final float []f = new float[100];
+ final TiffRasterData raster = new TiffRasterData(10, 10, f);
raster.setValue(11, 11, 5.0f);
fail("Access method getValue() did not detect bad coordinates");
- }catch(IllegalArgumentException illArgEx){
+ }catch(final IllegalArgumentException illArgEx){
// success!
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatisticsTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatisticsTest.java
index 0eff9d9..458f0a1 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatisticsTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRasterStatisticsTest.java
@@ -99,10 +99,10 @@ public class TiffRasterStatisticsTest {
public void testGetMeanValue() {
assertNotEquals(0, stat0.getMeanValue());
- float[] zero = new float[100];
+ final float[] zero = new float[100];
Arrays.fill(zero, 10);
- TiffRasterData zeroData = new TiffRasterData(10, 10, zero);
- TiffRasterStatistics zeroStat = zeroData.getSimpleStatistics(10);
+ final TiffRasterData zeroData = new TiffRasterData(10, 10, zero);
+ final TiffRasterStatistics zeroStat = zeroData.getSimpleStatistics(10);
assertEquals(0.0f, zeroStat.getMeanValue(),
"Invalid mean data for excluded value");
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadAlphaTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadAlphaTest.java
index 8f6a709..7891f33 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadAlphaTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadAlphaTest.java
@@ -56,20 +56,20 @@ public class TiffReadAlphaTest {
* @param name a valid file name
* @return a valid file reference.
*/
- private File getTiffFile(String name) {
- File tiffFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "tiff");
- File alphaFolder = new File(tiffFolder, "12");
+ private File getTiffFile(final String name) {
+ final File tiffFolder = new File(ImagingTestConstants.TEST_IMAGE_FOLDER, "tiff");
+ final File alphaFolder = new File(tiffFolder, "12");
return new File(alphaFolder, name);
}
@Test
public void test() {
- for (String name : names) {
+ for (final String name : names) {
try {
- File subject = getTiffFile(name);
- BufferedImage overlay = Imaging.getBufferedImage(subject);
- BufferedImage composite = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
- Graphics2D g2d = composite.createGraphics();
+ final File subject = getTiffFile(name);
+ final BufferedImage overlay = Imaging.getBufferedImage(subject);
+ final BufferedImage composite = new BufferedImage(100, 100, BufferedImage.TYPE_INT_ARGB);
+ final Graphics2D g2d = composite.createGraphics();
g2d.setColor(Color.white);
g2d.fillRect(0, 0, 101, 101);
g2d.setColor(Color.black);
@@ -77,10 +77,10 @@ public class TiffReadAlphaTest {
g2d.drawImage(overlay, 0, 0, null);
for (int i = 0; i < testSite.length; i++) {
- int x = testSite[i][0];
- int y = testSite[i][1];
- int p = testSite[i][2];
- int t = composite.getRGB(x, y);
+ final int x = testSite[i][0];
+ final int y = testSite[i][1];
+ final int p = testSite[i][2];
+ final int t = composite.getRGB(x, y);
assertEquals(t, p, "Error for " + name + " at position " + x + ", " + y);
}
} catch (ImageReadException | IOException ex) {
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadTest.java
index 6a2a595..87a5eba 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffReadTest.java
@@ -59,17 +59,17 @@ public class TiffReadTest extends TiffBaseTest {
// same as above, but test reading the TIFF directories
final List<File> images = getTiffImages();
for (final File imageFile : images) {
- String name = imageFile.getName();
+ final String name = imageFile.getName();
// the "bad offsets" file will cause an exception to be thrown.
// It's not relevant to what this test is trying to discover.
// So skip it.
if(name.toLowerCase().contains("bad")){
continue;
}
- ByteSourceFile byteSource = new ByteSourceFile(imageFile);
- HashMap<String, Object> params = new HashMap<>();
- TiffReader tiffReader = new TiffReader(true);
- TiffContents contents = tiffReader.readDirectories(
+ final ByteSourceFile byteSource = new ByteSourceFile(imageFile);
+ final HashMap<String, Object> params = new HashMap<>();
+ final TiffReader tiffReader = new TiffReader(true);
+ final TiffContents contents = tiffReader.readDirectories(
byteSource,
true,
FormatCompliance.getDefault());
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffSubImageTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffSubImageTest.java
index ae95632..c6001d8 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffSubImageTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffSubImageTest.java
@@ -58,10 +58,10 @@ public class TiffSubImageTest extends TiffBaseTest {
@Test
public void testBadSubImage() throws ImageReadException, IOException{
- File target = imageFileList.get(0);
+ final File target = imageFileList.get(0);
final BufferedImage referenceImage = Imaging.getBufferedImage(target);
- int width = referenceImage.getWidth();
- int height = referenceImage.getHeight();
+ final int width = referenceImage.getWidth();
+ final int height = referenceImage.getHeight();
final Map<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, 0);
@@ -69,7 +69,7 @@ public class TiffSubImageTest extends TiffBaseTest {
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, width);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, height);
- BufferedImage image = Imaging.getBufferedImage(target, params);
+ final BufferedImage image = Imaging.getBufferedImage(target, params);
assertEquals(image.getWidth(), width, "Improper width when sub-imaging entire image");
assertEquals(image.getHeight(), height, "Improper height when sub-imaging entire image");
@@ -81,47 +81,47 @@ public class TiffSubImageTest extends TiffBaseTest {
processBadParams(target, 0, 1, width, height, "sub-image height extends beyond bounds");
}
- private void processBadParams(File target, int x, int y, int width, int height, String comment) throws IOException{
+ private void processBadParams(final File target, final int x, final int y, final int width, final int height, final String comment) throws IOException{
try{
final Map<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, x);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, y);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, width);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, height);
- BufferedImage image = Imaging.getBufferedImage(target, params);
+ final BufferedImage image = Imaging.getBufferedImage(target, params);
fail("Reading TIFF sub-image failed to detect bad parameter: "+comment);
- }catch(ImageReadException ire){
+ }catch(final ImageReadException ire){
// the test passed
}
}
@Test
public void testSubImageCorrectness() throws ImageReadException, IOException {
- for(File target: imageFileList){
+ for(final File target: imageFileList){
final BufferedImage referenceImage = Imaging.getBufferedImage(target);
- int rW = referenceImage.getWidth();
- int rH = referenceImage.getHeight();
+ final int rW = referenceImage.getWidth();
+ final int rH = referenceImage.getHeight();
if(rW<3 || rH<3){
continue;
}
- int []rArgb = new int[rW*rH];
+ final int []rArgb = new int[rW*rH];
referenceImage.getRGB(0, 0, rW, rH, rArgb, 0, rW);
final Map<String, Object> params = new HashMap<>();
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_X, 1);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_Y, 1);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_WIDTH, rW-2);
params.put(TiffConstants.PARAM_KEY_SUBIMAGE_HEIGHT, rH-2);
- BufferedImage image = Imaging.getBufferedImage(target, params);
- int iW = image.getWidth();
- int iH = image.getHeight();
+ final BufferedImage image = Imaging.getBufferedImage(target, params);
+ final int iW = image.getWidth();
+ final int iH = image.getHeight();
assertEquals(iW, rW-2, "Invalid subimage width");
assertEquals(iH, rH-2, "Invalid subimage height");
- int []iArgb= new int[iW*iH];
+ final int []iArgb= new int[iW*iH];
image.getRGB(0, 0, iW, iH, iArgb, 0, iW);
for(int i=0; i<iH; i++){
for(int j=0; j<iW; j++){
- int rTest = rArgb[(i+1)*rW+j+1];
- int iTest = iArgb[i*iW+j];
+ final int rTest = rArgb[(i+1)*rW+j+1];
+ final int iTest = iArgb[i*iW+j];
assertEquals(iTest, rTest, "Invalid pixel lookup for "+target.getName()+" at "+i+", "+j);
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java
index 1507337..f45203e 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java
@@ -34,10 +34,10 @@ public class FieldTypeAsciiTest {
@Test
public void testCreatesFieldTypeAsciiAndCallsWriteData() {
- FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
- byte[] byteArray = new byte[1];
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- TiffField tiffField = new TiffField(0, 0, fieldTypeAscii, 0L, 0, byteArray, byteOrder, 1);
+ final FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
+ final byte[] byteArray = new byte[1];
+ final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ final TiffField tiffField = new TiffField(0, 0, fieldTypeAscii, 0L, 0, byteArray, byteOrder, 1);
Assertions.assertThrows(ImageWriteException.class, () -> {
fieldTypeAscii.writeData(tiffField, byteOrder);
@@ -46,19 +46,19 @@ public class FieldTypeAsciiTest {
@Test
public void testCreatesFieldTypeAsciiAndWriteDataUsingByteArray() throws ImageWriteException {
- FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
- byte[] byteArray = new byte[1];
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- byte[] byteArrayTwo = fieldTypeAscii.writeData(byteArray, byteOrder);
+ final FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
+ final byte[] byteArray = new byte[1];
+ final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ final byte[] byteArrayTwo = fieldTypeAscii.writeData(byteArray, byteOrder);
assertArrayEquals(new byte[] {(byte)0, (byte)0}, byteArrayTwo);
}
@Test
public void testCreatesFieldTypeAsciiAndWriteDataUsingString() throws ImageWriteException {
- FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- byte[] byteArrayTwo = fieldTypeAscii.writeData("asdf", byteOrder);
+ final FieldTypeAscii fieldTypeAscii = new FieldTypeAscii(0, "1");
+ final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ final byte[] byteArrayTwo = fieldTypeAscii.writeData("asdf", byteOrder);
assertArrayEquals(new byte[] {(byte)97, (byte)115, (byte)100, (byte)102, (byte)0}, byteArrayTwo);
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java
index 701f413..d6ad22f 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java
@@ -33,17 +33,17 @@ public class FieldTypeRationalTest {
@Test
public void testWriteDataWithNull() throws ImageWriteException {
- FieldTypeRational fieldTypeRational = new FieldTypeRational(9, null);
- Double doubleOne = 2.2d;
- byte[] byteArray = fieldTypeRational.writeData(doubleOne, null);
+ final FieldTypeRational fieldTypeRational = new FieldTypeRational(9, null);
+ final Double doubleOne = 2.2d;
+ final byte[] byteArray = fieldTypeRational.writeData(doubleOne, null);
assertArrayEquals(new byte[] {(byte)11, (byte)0, (byte)0, (byte)0, (byte)5, (byte)0, (byte)0, (byte)0}, byteArray);
}
@Test
public void testWriteDataWithNonNull() {
- FieldTypeRational fieldTypeRational = new FieldTypeRational((-922), "z_AX");
- ByteOrder byteOrder = ByteOrder.nativeOrder();
+ final FieldTypeRational fieldTypeRational = new FieldTypeRational((-922), "z_AX");
+ final ByteOrder byteOrder = ByteOrder.nativeOrder();
Assertions.assertThrows(ImageWriteException.class, () -> {
fieldTypeRational.writeData("z_AX", byteOrder);
});
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java
index 4024086..76f51a7 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java
@@ -31,11 +31,11 @@ public class PhotometricInterpreterLogLuvTest {
private PhotometricInterpreterLogLuv p;
- private int samplesPerPixel = 8;
- private int[] bitsPerSample = new int[] {1, 2, 3};
- private int predictor = 1;
- private int width = 800;
- private int height = 600;
+ private final int samplesPerPixel = 8;
+ private final int[] bitsPerSample = new int[] {1, 2, 3};
+ private final int predictor = 1;
+ private final int width = 800;
+ private final int height = 600;
@BeforeEach
public void setUp() {
@@ -73,7 +73,7 @@ public class PhotometricInterpreterLogLuvTest {
@Test
public void testGetRgbValues() {
// any value equals 0 will have its pow(N, 3) equal to 0
- TristimulusValues triValues = new TristimulusValues();
+ final TristimulusValues triValues = new TristimulusValues();
triValues.x = 0;
triValues.y = 0;
triValues.z = 0;
@@ -104,9 +104,9 @@ public class PhotometricInterpreterLogLuvTest {
@Test
public void testInterpretPixel() throws ImageReadException, IOException {
- ImageBuilder imgBuilder = new ImageBuilder(600, 400, /*alpha*/ true);
- int x = 10;
- int y = 20;
+ final ImageBuilder imgBuilder = new ImageBuilder(600, 400, /*alpha*/ true);
+ final int x = 10;
+ final int y = 20;
p.interpretPixel(imgBuilder, new int[] {100, (byte) 32, (byte) 2}, x, y);
assertEquals(-7584166, imgBuilder.getRGB(x, y));
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgbTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgbTest.java
index 150fd02..fb21380 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgbTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterRgbTest.java
@@ -29,11 +29,11 @@ public class PhotometricInterpreterRgbTest {
private PhotometricInterpreterRgb p;
- private int samplesPerPixel = 3;
- private int[] bitsPerSample = new int[] {8, 8, 8};
- private int predictor = 1;
- private int width = 800;
- private int height = 600;
+ private final int samplesPerPixel = 3;
+ private final int[] bitsPerSample = new int[] {8, 8, 8};
+ private final int predictor = 1;
+ private final int width = 800;
+ private final int height = 600;
@BeforeEach
public void setUp() {
@@ -54,9 +54,9 @@ public class PhotometricInterpreterRgbTest {
@Test
public void testInterpretPixel() throws ImageReadException, IOException {
- ImageBuilder imgBuilder = new ImageBuilder(600, 400, /*alpha*/ true);
- int x = 10;
- int y = 20;
+ final ImageBuilder imgBuilder = new ImageBuilder(600, 400, /*alpha*/ true);
+ final int x = 10;
+ final int y = 20;
p.interpretPixel(imgBuilder, new int[] {255, 255, 255}, x, y);
assertEquals(0xffffffff, imgBuilder.getRGB(x, y));
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRangeTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRangeTest.java
index 1b8b4b5..e1cd214 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRangeTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForRangeTest.java
@@ -38,9 +38,9 @@ public class PaletteEntryForRangeTest {
*/
@Test
public void testIsCovered() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
assertTrue(instance.isCovered(0.0f), "Zero value must be covered");
assertFalse(instance.isCovered(1.0f), "Value 1.0 must not be covered");
}
@@ -50,11 +50,11 @@ public class PaletteEntryForRangeTest {
*/
@Test
public void testGetARGB() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
- int a0 = instance.getARGB(0.0f);
- int a1 = instance.getARGB(0.5f);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final int a0 = instance.getARGB(0.0f);
+ final int a1 = instance.getARGB(0.5f);
assertEquals(0xff0000ff, a0, "Invalid value for 0.0f");
assertEquals(0xff008080, a1, "Invalid interpolated values");
}
@@ -66,11 +66,11 @@ public class PaletteEntryForRangeTest {
public void testGetColor() {
Color c0 = new Color(0xff0000ff);
Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
c0 = instance.getColor(0.0f);
c1 = instance.getColor(0.5f);
- int a0 = c0.getRGB();
- int a1 = c1.getRGB();
+ final int a0 = c0.getRGB();
+ final int a1 = c1.getRGB();
assertEquals(0xff0000ff, a0, "Invalid value for 0.0f");
assertEquals(0xff008080, a1, "Invalid interpolated values");
@@ -81,9 +81,9 @@ public class PaletteEntryForRangeTest {
*/
@Test
public void testCoversSingleEntry() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
assertFalse(instance.coversSingleEntry());
}
@@ -92,9 +92,9 @@ public class PaletteEntryForRangeTest {
*/
@Test
public void testGetLowerBound() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
assertEquals(0.0f, instance.getLowerBound());
}
@@ -103,36 +103,36 @@ public class PaletteEntryForRangeTest {
*/
@Test
public void testGetUpperBound() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final PaletteEntryForRange instance = new PaletteEntryForRange(0.0f, 1.0f, c0, c1);
assertEquals(1.0f, instance.getUpperBound());
}
@Test
public void testFaultyConstructors() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
PaletteEntryForRange pTest;
// test the two-color variations -----------------------
try {
pTest = new PaletteEntryForRange(0.0f, 0.0f, c0, c1);
fail("Constructor failed to detect invalid range");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
try {
pTest = new PaletteEntryForRange(0.0f, 1.0f, null, c1);
fail("Constructor failed to detect null color");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
try {
pTest = new PaletteEntryForRange(0.0f, 1.0f, c0, null);
fail("Constructor failed to detect invalid color");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
@@ -140,14 +140,14 @@ public class PaletteEntryForRangeTest {
try {
pTest = new PaletteEntryForRange(0.0f, 0.0f, c0);
fail("Constructor failed to detect invalid range");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
try {
pTest = new PaletteEntryForRange(0.0f, 1.0f, null);
fail("Constructor failed to detect null color");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValueTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValueTest.java
index 1cd9bf2..d8e5af7 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValueTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PaletteEntryForValueTest.java
@@ -38,7 +38,7 @@ public class PaletteEntryForValueTest {
*/
@Test
public void testIsCovered() {
- Color c0 = new Color(0xff0000ff);
+ final Color c0 = new Color(0xff0000ff);
PaletteEntryForValue instance = new PaletteEntryForValue(0.0f, c0);
assertTrue(instance.isCovered(0.0f), "Zero value must be covered");
assertFalse(instance.isCovered(1.0f), "Value 1.0 must not be covered");
@@ -53,11 +53,11 @@ public class PaletteEntryForValueTest {
*/
@Test
public void testGetARGB() {
- Color c0 = new Color(0xff0000ff);
+ final Color c0 = new Color(0xff0000ff);
PaletteEntryForValue instance = new PaletteEntryForValue(0.0f, c0);
int a0 = instance.getARGB(0.0f);
int a1 = instance.getARGB(0.5f);
- int a2 = instance.getARGB(Float.NaN);
+ final int a2 = instance.getARGB(Float.NaN);
assertEquals(0xff0000ff, a0, "Invalid value for target 0.0f");
assertEquals(0, a1, "Invalid value for target 0.5f");
assertEquals(0, a2, "Invalid value for target NaN");
@@ -73,10 +73,10 @@ public class PaletteEntryForValueTest {
*/
@Test
public void testGetColor() {
- Color cTest = new Color(0xff0000ff);
+ final Color cTest = new Color(0xff0000ff);
PaletteEntryForValue instance = new PaletteEntryForValue(0.0f, cTest);
Color c0 = instance.getColor(0.0f);
- int a0 = c0.getRGB();
+ final int a0 = c0.getRGB();
assertEquals(0xff0000ff, a0, "Invalid value for 0.0f");
c0 = instance.getColor(1f);
assertTrue(c0 == null, "Non-null return for invalid target 1.0f");
@@ -93,15 +93,15 @@ public class PaletteEntryForValueTest {
@Test
public void testFaultyConstructors() {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
PaletteEntryForValue pTest;
try {
pTest = new PaletteEntryForValue(0.0f, null);
fail("Constructor failed to detect null color");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
// successful test
}
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloatTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloatTest.java
index e273193..9f7afb4 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloatTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/floatingpoint/PhotometricInterpreterFloatTest.java
@@ -55,23 +55,23 @@ public class PhotometricInterpreterFloatTest {
// The floating point values at each pixel are just the
// index divided by 256.
- List<PaletteEntry> paletteList = new ArrayList<>();
- List<PaletteEntry> reverseList = new ArrayList<>();
+ final List<PaletteEntry> paletteList = new ArrayList<>();
+ final List<PaletteEntry> reverseList = new ArrayList<>();
for (int i = 0; i < 256; i += 32) {
- int i1 = i + 31;
- float f0 = i / 256f;
- float f1 = (i + 32) / 256f;
- int argb0 = 0xff000000 | (i << 8) | i;
- int argb1 = 0xff000000 | (i1 << 8) | i;
- Color c0 = new Color(argb0);
- Color c1 = new Color(argb1);
- PaletteEntryForRange entry = new PaletteEntryForRange(f0, f1, c0, c1);
+ final int i1 = i + 31;
+ final float f0 = i / 256f;
+ final float f1 = (i + 32) / 256f;
+ final int argb0 = 0xff000000 | (i << 8) | i;
+ final int argb1 = 0xff000000 | (i1 << 8) | i;
+ final Color c0 = new Color(argb0);
+ final Color c1 = new Color(argb1);
+ final PaletteEntryForRange entry = new PaletteEntryForRange(f0, f1, c0, c1);
paletteList.add(entry);
}
// The interpreter is supposed to sort entries. To test that,
// we copy them to a list in reverse order.
for (int i = paletteList.size() - 1; i >= 0; i--) {
- PaletteEntry entry = paletteList.get(i);
+ final PaletteEntry entry = paletteList.get(i);
reverseList.add(entry);
}
@@ -80,15 +80,15 @@ public class PhotometricInterpreterFloatTest {
// pre-populate the state data for the interpreter with
// some values so that we can test min/max access methods.
imageBuilder = new ImageBuilder(257, 257, false);
- int[] samples = new int[1];
+ final int[] samples = new int[1];
for (int i = 0; i <= 256; i++) {
- float f = i / 256f;
+ final float f = i / 256f;
samples[0] = Float.floatToRawIntBits(f);
pInterp.interpretPixel(imageBuilder, samples, i, i);
}
// Now set up a palette than maps values in a range to a single color.
- List<PaletteEntry> bandedPaletteList = new ArrayList<>();
+ final List<PaletteEntry> bandedPaletteList = new ArrayList<>();
bandedPaletteList.add(new PaletteEntryForRange(0f, 0.33f, green));
bandedPaletteList.add(new PaletteEntryForRange(0.33f, 0.66f, Color.white));
bandedPaletteList.add(new PaletteEntryForRange(0.66f, 1.0f, orange));
@@ -97,7 +97,7 @@ public class PhotometricInterpreterFloatTest {
bandedInterp = new PhotometricInterpreterFloat(bandedPaletteList);
bandedImageBuilder = new ImageBuilder(300, 200, false);
for (int j = 0; j < 300; j++) {
- float f = j / 299.0f;
+ final float f = j / 299.0f;
samples[0] = Float.floatToRawIntBits(f);
for (int i = 0; i < 200; i++) {
bandedInterp.interpretPixel(bandedImageBuilder, samples, j, i);
@@ -121,9 +121,9 @@ public class PhotometricInterpreterFloatTest {
@Test
public void testInterpretPixel() {
for (int i = 0; i < 256; i++) {
- int lowTest = (i / 32) * 32;
- int argb = imageBuilder.getRGB(i, i);
- int b = argb & 0xff;
+ final int lowTest = (i / 32) * 32;
+ final int argb = imageBuilder.getRGB(i, i);
+ final int b = argb & 0xff;
assertEquals(b, lowTest, "Invalid conversion for level " + i);
}
@@ -151,8 +151,8 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testGetMinFound() {
- float expResult = 0.0F;
- float result = pInterp.getMinFound();
+ final float expResult = 0.0F;
+ final float result = pInterp.getMinFound();
assertEquals(expResult, result, 0.0, "Invalid minimum value");
}
@@ -161,8 +161,8 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testGetMaxXY() {
- int[] expResult = new int[]{256, 256};
- int[] result = pInterp.getMaxXY();
+ final int[] expResult = new int[]{256, 256};
+ final int[] result = pInterp.getMaxXY();
assertArrayEquals(expResult, result);
}
@@ -171,8 +171,8 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testGetMaxFound() {
- float expResult = 1.0F;
- float result = pInterp.getMinFound();
+ final float expResult = 1.0F;
+ final float result = pInterp.getMinFound();
assertEquals(expResult, result, 1.0, "Invalid maximum value");
}
@@ -181,8 +181,8 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testGetMinXY() {
- int[] expResult = new int[]{0, 0};
- int[] result = pInterp.getMinXY();
+ final int[] expResult = new int[]{0, 0};
+ final int[] result = pInterp.getMinXY();
assertArrayEquals(expResult, result);
}
@@ -191,8 +191,8 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testGetMeanFound() {
- float expResult = 0.5F;
- float result = pInterp.getMinFound();
+ final float expResult = 0.5F;
+ final float result = pInterp.getMinFound();
assertEquals(expResult, result, 1.0, "Invalid mean value");
}
@@ -228,14 +228,14 @@ public class PhotometricInterpreterFloatTest {
try {
ptest = new PhotometricInterpreterFloat(null);
fail("Constructor failed to detect null arguments");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
}
try {
ptest = new PhotometricInterpreterFloat(0.1f, 0.1f);
fail("Constructor failed to detect bad-range argument values");
- } catch (IllegalArgumentException iex) {
+ } catch (final IllegalArgumentException iex) {
}
@@ -246,16 +246,16 @@ public class PhotometricInterpreterFloatTest {
*/
@Test
public void testOverlappingEntriesEntry() throws ImageReadException, IOException {
- Color c0 = new Color(0xff0000ff);
- Color c1 = new Color(0xff00ff00);
- List<PaletteEntry> overlapList = new ArrayList<>();
+ final Color c0 = new Color(0xff0000ff);
+ final Color c1 = new Color(0xff00ff00);
+ final List<PaletteEntry> overlapList = new ArrayList<>();
overlapList.add(new PaletteEntryForRange(0.0f, 1.0f, c0));
overlapList.add(new PaletteEntryForRange(0.0f, 1.5f, c1));
- PhotometricInterpreterFloat interpreter = new PhotometricInterpreterFloat(overlapList);
+ final PhotometricInterpreterFloat interpreter = new PhotometricInterpreterFloat(overlapList);
imageBuilder = new ImageBuilder(257, 257, false);
- int[] samples = new int[1];
+ final int[] samples = new int[1];
samples[0] = Float.floatToRawIntBits(0.5f);
interpreter.interpretPixel(imageBuilder, samples, 0, 0);
samples[0] = Float.floatToRawIntBits(1.2f);
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShortTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShortTest.java
index 7c01d14..6616481 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShortTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoByteOrShortTest.java
@@ -28,22 +28,22 @@ public class TagInfoByteOrShortTest {
@Test
public void testEncodeValueTakingByteOrderAndByteArrayOne() {
- TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES;
- TagInfoByteOrShort tagInfoByteOrShort = new TagInfoByteOrShort("r", 500, 500, tiffDirectoryType);
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- short[] shortArray = new short[2];
- byte[] byteArray = tagInfoByteOrShort.encodeValue(byteOrder, shortArray);
+ final TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES;
+ final TagInfoByteOrShort tagInfoByteOrShort = new TagInfoByteOrShort("r", 500, 500, tiffDirectoryType);
+ final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ final short[] shortArray = new short[2];
+ final byte[] byteArray = tagInfoByteOrShort.encodeValue(byteOrder, shortArray);
assertArrayEquals(new byte[]{(byte) 0, (byte) 0, (byte) 0, (byte) 0}, byteArray);
}
@Test
public void testEncodeValueTakingByteOrderAndByteArrayTwo() {
- TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES;
- TagInfoByteOrShort tagInfoByteOrShort = new TagInfoByteOrShort("r", 500, 500, tiffDirectoryType);
- ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
- byte[] byteArray = new byte[2];
- byte[] byteArrayTwo = tagInfoByteOrShort.encodeValue(byteOrder, byteArray);
+ final TiffDirectoryType tiffDirectoryType = TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES;
+ final TagInfoByteOrShort tagInfoByteOrShort = new TagInfoByteOrShort("r", 500, 500, tiffDirectoryType);
+ final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN;
+ final byte[] byteArray = new byte[2];
+ final byte[] byteArrayTwo = tagInfoByteOrShort.encodeValue(byteOrder, byteArray);
assertSame(byteArrayTwo, byteArray);
}
diff --git a/src/test/java/org/apache/commons/imaging/palette/DitheringTest.java b/src/test/java/org/apache/commons/imaging/palette/DitheringTest.java
index 4ebd266..78f857c 100644
--- a/src/test/java/org/apache/commons/imaging/palette/DitheringTest.java
+++ b/src/test/java/org/apache/commons/imaging/palette/DitheringTest.java
@@ -32,13 +32,13 @@ public class DitheringTest {
@Test
public void testApplyFloydSteinbergDitheringWithNonNullOne() throws ImageWriteException {
- BufferedImage bufferedImage = new BufferedImage(8, 8, 8);
+ final BufferedImage bufferedImage = new BufferedImage(8, 8, 8);
bufferedImage.setRGB(2, 2, 2);
- List<ColorSpaceSubset> linkedList = new LinkedList<>();
- ColorSpaceSubset colorSpaceSubset = new ColorSpaceSubset((-234), (-352));
+ final List<ColorSpaceSubset> linkedList = new LinkedList<>();
+ final ColorSpaceSubset colorSpaceSubset = new ColorSpaceSubset((-234), (-352));
colorSpaceSubset.rgb = 8;
linkedList.add(colorSpaceSubset);
- QuantizedPalette quantizedPalette = new QuantizedPalette(linkedList, 8);
+ final QuantizedPalette quantizedPalette = new QuantizedPalette(linkedList, 8);
Dithering.applyFloydSteinbergDithering(bufferedImage, quantizedPalette);
assertEquals(-16777208, bufferedImage.getRGB(0,0) );
@@ -49,12 +49,12 @@ public class DitheringTest {
@Test
public void testApplyFloydSteinbergDitheringWithNonNullTwo() throws ImageWriteException {
- BufferedImage bufferedImage = new BufferedImage(3, 3, 3);
+ final BufferedImage bufferedImage = new BufferedImage(3, 3, 3);
bufferedImage.setRGB(1, 2, 4);
- List<ColorSpaceSubset> linkedList = new LinkedList<>();
- ColorSpaceSubset colorSpaceSubset = new ColorSpaceSubset((-234), (-352));
+ final List<ColorSpaceSubset> linkedList = new LinkedList<>();
+ final ColorSpaceSubset colorSpaceSubset = new ColorSpaceSubset((-234), (-352));
linkedList.add(colorSpaceSubset);
- QuantizedPalette quantizedPalette = new QuantizedPalette(linkedList, 3);
+ final QuantizedPalette quantizedPalette = new QuantizedPalette(linkedList, 3);
Dithering.applyFloydSteinbergDithering(bufferedImage, quantizedPalette);
assertEquals(-1, bufferedImage.getRGB(0,0) );
diff --git a/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripBase.java b/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripBase.java
index 0f26c49..75de173 100644
--- a/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripBase.java
+++ b/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripBase.java
@@ -68,7 +68,7 @@ public class RoundtripBase {
}
}
- public static Stream<Arguments> createRoundtripArguments(BufferedImage[] images) {
+ public static Stream<Arguments> createRoundtripArguments(final BufferedImage[] images) {
return Arrays.stream(images).flatMap(i -> Arrays.stream(FormatInfo.READ_WRITE_FORMATS).map(f -> Arguments.of(i, f)));
}
}