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 2024/09/12 12:59:23 UTC
(commons-imaging) branch master updated (17815d15 -> 902eda07)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
from 17815d15 Merge pull request #433 from apache/dependabot/github_actions/actions/upload-artifact-4.4.0
new 0ececb46 Remove redundant keyword
new 29f71409 Use Collections.sort()
new ce9ab6ec Use Collections.sort(List)
new c1116197 Merge nested if clauses
new 2d4be294 Merge nested if clauses
new 742c999c Merge nested if clauses
new 086b3c5e Use Collections.sort(List)
new eb0f5e8a Remove redundant keyword
new 86a70282 Merge nested if clauses
new 86882946 Merge nested if clauses
new 77448604 Merge nested if clauses
new 6ca068cc Merge nested if clauses
new 2d457ddc Convert cascading if-else to switch
new 32a3b240 Remove redundant keyword
new 147555b5 Merge nested if clauses
new 03ac7fd5 Remove redundant keyword
new 709796df Remove redundant keyword
new 82d276ef Remove redundant keyword
new 59c88a70 Remove redundant keyword
new 053fbc14 Remove redundant keyword
new 60a5afcd Remove redundant keyword
new 902eda07 Convert cascading if-else to switch
The 22 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
.../commons/imaging/common/RationalNumber.java | 34 ++++++++++-----------
.../imaging/formats/gif/GifImageParser.java | 6 ++--
.../imaging/formats/jpeg/JpegImageParser.java | 35 +++++++++-------------
.../formats/jpeg/decoder/JpegInputStream.java | 6 ++--
.../imaging/formats/jpeg/xmp/JpegRewriter.java | 6 ++--
.../imaging/formats/pcx/PcxImageParser.java | 10 +++----
.../imaging/formats/png/AbstractScanExpediter.java | 2 +-
.../imaging/formats/png/PngImageParser.java | 12 +++-----
.../imaging/formats/psd/PsdImageParser.java | 2 +-
.../imaging/formats/tiff/TiffDirectory.java | 4 +--
.../imaging/formats/tiff/TiffImageParser.java | 4 +--
.../tiff/write/AbstractTiffImageWriter.java | 6 ++--
.../imaging/formats/xpm/XpmImageParser.java | 16 +++++++---
.../palette/MostPopulatedBoxesMedianCut.java | 8 ++---
.../imaging/formats/jpeg/exif/ExifRewriteTest.java | 9 +++---
.../commons/imaging/formats/png/PngTextTest.java | 13 +++++---
.../tiff/TiffFloatingPointMultivariableTest.java | 2 +-
.../tiff/TiffFloatingPointRoundTripTest.java | 2 +-
.../formats/tiff/TiffRoundTripInt32Test.java | 2 +-
.../formats/tiff/TiffShortIntRoundTripTest.java | 2 +-
.../commons/imaging/roundtrip/ImageAsserts.java | 6 ++--
.../commons/imaging/test/FileSystemTraversal.java | 16 ++++------
22 files changed, 94 insertions(+), 109 deletions(-)
(commons-imaging) 05/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 2d4be294f5ce0fdfffb087c4cf56cab01e40d385
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:56:55 2024 -0400
Merge nested if clauses
---
.../java/org/apache/commons/imaging/formats/gif/GifImageParser.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
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 f13a5e78..352693d3 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
@@ -742,10 +742,8 @@ public class GifImageParser extends AbstractImageParser<GifImagingParameters> im
LOGGER.finest("SizeofGlobalColorTable: " + sizeofGlobalColorTable);
}
- if (formatCompliance != null) {
- if (globalColorTableFlag && backgroundColorIndex != -1) {
- formatCompliance.checkBounds("Background Color Index", 0, convertColorTableSize(sizeofGlobalColorTable), backgroundColorIndex);
- }
+ if (formatCompliance != null && globalColorTableFlag && backgroundColorIndex != -1) {
+ formatCompliance.checkBounds("Background Color Index", 0, convertColorTableSize(sizeofGlobalColorTable), backgroundColorIndex);
}
return new GifHeaderInfo(identifier1, identifier2, identifier3, version1, version2, version3, logicalScreenWidth, logicalScreenHeight, packedFields,
(commons-imaging) 04/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit c1116197881a49c888024301b268c1badaee6895
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:56:48 2024 -0400
Merge nested if clauses
---
.../apache/commons/imaging/test/FileSystemTraversal.java | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/src/test/java/org/apache/commons/imaging/test/FileSystemTraversal.java b/src/test/java/org/apache/commons/imaging/test/FileSystemTraversal.java
index 7cd151ff..6034d3ce 100644
--- a/src/test/java/org/apache/commons/imaging/test/FileSystemTraversal.java
+++ b/src/test/java/org/apache/commons/imaging/test/FileSystemTraversal.java
@@ -51,10 +51,8 @@ public class FileSystemTraversal {
private boolean traverse(final File file, final int mode, final Visitor visitor, final double estimate, final double estimateIncrement) {
if (file.isFile()) {
- if (mode == MODE_FILES || mode == MODE_FILES_AND_FOLDERS || mode == MODE_ALL) {
- if (!visitor.visit(file, estimate)) {
- return false;
- }
+ if ((mode == MODE_FILES || mode == MODE_FILES_AND_FOLDERS || mode == MODE_ALL) && !visitor.visit(file, estimate)) {
+ return false;
}
} else if (file.isDirectory()) {
final File[] files = file.listFiles();
@@ -76,15 +74,11 @@ public class FileSystemTraversal {
}
}
- if (mode == MODE_FOLDERS || mode == MODE_FILES_AND_FOLDERS || mode == MODE_ALL) {
- if (!visitor.visit(file, estimate)) {
- return false;
- }
- }
- } else if (mode == MODE_ALL) {
- if (!visitor.visit(file, estimate)) {
+ if ((mode == MODE_FOLDERS || mode == MODE_FILES_AND_FOLDERS || mode == MODE_ALL) && !visitor.visit(file, estimate)) {
return false;
}
+ } else if (mode == MODE_ALL && !visitor.visit(file, estimate)) {
+ return false;
}
return true;
(commons-imaging) 02/22: Use Collections.sort()
Posted by gg...@apache.org.
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
commit 29f71409b16991b03e692e8b59e4b94e70762697
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:55:29 2024 -0400
Use Collections.sort()
---
.../commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java
index f762bcb4..29f686b8 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/AbstractTiffImageWriter.java
@@ -294,7 +294,7 @@ public abstract class AbstractTiffImageWriter {
// "normal" TIFF directories should have continous indices starting with
// 0, ie. 0, 1, 2...
- directoryIndices.sort(null);
+ Collections.sort(directoryIndices);
TiffOutputDirectory previousDirectory = null;
for (int i = 0; i < directoryIndices.size(); i++) {
@@ -493,7 +493,7 @@ public abstract class AbstractTiffImageWriter {
predictor = TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING;
for (int i = 0; i < strips.length; i++) {
final byte[] uncompressed = strips[i];
- this.applyPredictor(width, samplesPerPixel, strips[i]);
+ applyPredictor(width, samplesPerPixel, strips[i]);
final int LZW_MINIMUM_CODE_SIZE = 8;
final MyLzwCompressor compressor = new MyLzwCompressor(LZW_MINIMUM_CODE_SIZE, ByteOrder.BIG_ENDIAN, true);
@@ -504,7 +504,7 @@ public abstract class AbstractTiffImageWriter {
case TIFF_COMPRESSION_DEFLATE_ADOBE:
predictor = TiffTagConstants.PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING;
for (int i = 0; i < strips.length; i++) {
- this.applyPredictor(width, samplesPerPixel, strips[i]);
+ applyPredictor(width, samplesPerPixel, strips[i]);
strips[i] = ZlibDeflate.compress(strips[i]);
}
break;
(commons-imaging) 17/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 709796dfe0c5d4bc55d9a4455cf333777386f114
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:47 2024 -0400
Remove redundant keyword
---
.../imaging/formats/tiff/TiffFloatingPointMultivariableTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointMultivariableTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointMultivariableTest.java
index e86139e6..9196c865 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointMultivariableTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffFloatingPointMultivariableTest.java
@@ -270,7 +270,7 @@ public class TiffFloatingPointMultivariableTest extends TiffBaseTest {
nBytesInBlock = nRowsInBlock * nColsInBlock * bytesPerSample;
byte[][] blocks;
- blocks = this.getBytesForOutput32(nRowsInBlock, nColsInBlock, byteOrder, useTiles, planarConfiguration);
+ blocks = getBytesForOutput32(nRowsInBlock, nColsInBlock, byteOrder, useTiles, planarConfiguration);
final TiffOutputSet outputSet = new TiffOutputSet(byteOrder);
final TiffOutputDirectory outDir = outputSet.addRootDirectory();
(commons-imaging) 07/22: Use Collections.sort(List)
Posted by gg...@apache.org.
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
commit 086b3c5ea606d96edc29c68b08a593eab436024a
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:24 2024 -0400
Use Collections.sort(List)
Merge nested if clauses
---
.../imaging/formats/jpeg/JpegImageParser.java | 35 +++++++++-------------
1 file changed, 14 insertions(+), 21 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
index bef6370a..8d46887f 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageParser.java
@@ -27,6 +27,7 @@ import java.nio.charset.StandardCharsets;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -92,7 +93,7 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
throw new ImagingException("App2 Segments Missing. Found: " + segments.size() + ", Expected: " + markerCount + ".");
}
- segments.sort(null);
+ Collections.sort(segments);
final int offset = startWithZero ? 0 : 1;
@@ -710,11 +711,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
return false;
}
- if (marker == JpegConstants.JPEG_APP1_MARKER) {
- if (new JpegXmpParser().isXmpJpegSegment(segmentData)) {
- result.add(new JpegXmpParser().parseXmpJpegSegment(segmentData));
- return false;
- }
+ if (marker == JpegConstants.JPEG_APP1_MARKER && new JpegXmpParser().isXmpJpegSegment(segmentData)) {
+ result.add(new JpegXmpParser().parseXmpJpegSegment(segmentData));
+ return false;
}
return true;
@@ -754,11 +753,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
return false;
}
- if (marker == JpegConstants.JPEG_APP1_MARKER) {
- if (startsWith(segmentData, JpegConstants.EXIF_IDENTIFIER_CODE)) {
- result[0] = true;
- return false;
- }
+ if (marker == JpegConstants.JPEG_APP1_MARKER && startsWith(segmentData, JpegConstants.EXIF_IDENTIFIER_CODE)) {
+ result[0] = true;
+ return false;
}
return true;
@@ -793,11 +790,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
return false;
}
- if (marker == JpegConstants.JPEG_APP13_MARKER) {
- if (new IptcParser().isPhotoshopJpegSegment(segmentData)) {
- result[0] = true;
- return false;
- }
+ if (marker == JpegConstants.JPEG_APP13_MARKER && new IptcParser().isPhotoshopJpegSegment(segmentData)) {
+ result[0] = true;
+ return false;
}
return true;
@@ -832,11 +827,9 @@ public class JpegImageParser extends AbstractImageParser<JpegImagingParameters>
return false;
}
- if (marker == JpegConstants.JPEG_APP1_MARKER) {
- if (new JpegXmpParser().isXmpJpegSegment(segmentData)) {
- result[0] = true;
- return false;
- }
+ if (marker == JpegConstants.JPEG_APP1_MARKER && new JpegXmpParser().isXmpJpegSegment(segmentData)) {
+ result[0] = true;
+ return false;
}
return true;
(commons-imaging) 03/22: Use Collections.sort(List)
Posted by gg...@apache.org.
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
commit ce9ab6ec3318fe22c203967a7cae468b418e87d1
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:55:52 2024 -0400
Use Collections.sort(List)
---
.../commons/imaging/formats/jpeg/exif/ExifRewriteTest.java | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
index 2dc3f715..2b451c14 100644
--- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriteTest.java
@@ -29,6 +29,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -72,9 +73,9 @@ public class ExifRewriteTest extends AbstractExifTest {
assertEquals(oldDirectories.size(), oldDirectoryMap.size());
final List<Integer> oldDirectoryTypes = new ArrayList<>(oldDirectoryMap.keySet());
- oldDirectoryTypes.sort(null);
+ Collections.sort(oldDirectoryTypes);
final List<Integer> newDirectoryTypes = new ArrayList<>(newDirectoryMap.keySet());
- newDirectoryTypes.sort(null);
+ Collections.sort(newDirectoryTypes);
assertEquals(oldDirectoryTypes, newDirectoryTypes);
for (final Integer dirType : oldDirectoryTypes) {
@@ -106,9 +107,9 @@ public class ExifRewriteTest extends AbstractExifTest {
assertEquals(oldFieldMap.keySet(), newFieldMap.keySet());
final List<Integer> oldFieldTags = new ArrayList<>(oldFieldMap.keySet());
- oldFieldTags.sort(null);
+ Collections.sort(oldFieldTags);
final List<Integer> newFieldTags = new ArrayList<>(newFieldMap.keySet());
- newFieldTags.sort(null);
+ Collections.sort(newFieldTags);
assertEquals(oldFieldTags, newFieldTags);
for (final Integer fieldTag : oldFieldTags) {
(commons-imaging) 19/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 59c88a7059d3bcd3e46a7967f32ca6212ceb6947
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:59 2024 -0400
Remove redundant keyword
---
.../java/org/apache/commons/imaging/formats/tiff/TiffImageParser.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 8b737fbc..6ac89b7a 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
@@ -607,7 +607,7 @@ public class TiffImageParser extends AbstractImageParser<TiffImagingParameters>
@Override
public ImageMetadata getMetadata(final ByteSource byteSource, TiffImagingParameters params) throws ImagingException, IOException {
if (params == null) {
- params = this.getDefaultParameters();
+ params = getDefaultParameters();
}
final FormatCompliance formatCompliance = FormatCompliance.getDefault();
final TiffReader tiffReader = new TiffReader(params.isStrict());
@@ -723,7 +723,7 @@ public class TiffImageParser extends AbstractImageParser<TiffImagingParameters>
*/
TiffRasterData getRasterData(final TiffDirectory directory, final ByteOrder byteOrder, TiffImagingParameters params) throws ImagingException, IOException {
if (params == null) {
- params = this.getDefaultParameters();
+ params = getDefaultParameters();
}
final short[] sSampleFmt = directory.getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, true);
(commons-imaging) 16/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 03ac7fd5ff6e011014d8dde6e8f1f61e3433884c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:40 2024 -0400
Remove redundant keyword
---
.../java/org/apache/commons/imaging/formats/tiff/TiffDirectory.java | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
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 97fe21c2..7e30f129 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
@@ -761,7 +761,7 @@ public class TiffDirectory extends AbstractTiffElement implements Iterable<TiffF
* @throws ImagingException in the event of an invalid or malformed specification.
*/
public boolean hasTiffFloatingPointRasterData() throws ImagingException {
- if (!this.hasTiffImageData()) {
+ if (!hasTiffImageData()) {
return false;
}
final short[] s = getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, false);
@@ -785,7 +785,7 @@ public class TiffDirectory extends AbstractTiffElement implements Iterable<TiffF
* @throws ImagingException in the event of an invalid or malformed specification.
*/
public boolean hasTiffRasterData() throws ImagingException {
- if (!this.hasTiffImageData()) {
+ if (!hasTiffImageData()) {
return false;
}
final short[] s = getFieldValue(TiffTagConstants.TIFF_TAG_SAMPLE_FORMAT, false);
(commons-imaging) 01/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 0ececb46075ee5a43be98ba57c417279dc997aed
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:54:12 2024 -0400
Remove redundant keyword
---
.../org/apache/commons/imaging/formats/png/AbstractScanExpediter.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/AbstractScanExpediter.java b/src/main/java/org/apache/commons/imaging/formats/png/AbstractScanExpediter.java
index 0517200b..890ea1a2 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/AbstractScanExpediter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/AbstractScanExpediter.java
@@ -56,7 +56,7 @@ abstract class AbstractScanExpediter {
this.bi = bi;
this.pngColorType = pngColorType;
this.bitDepth = bitDepth;
- this.bytesPerPixel = this.getBitsToBytesRoundingUp(bitsPerPixel);
+ this.bytesPerPixel = getBitsToBytesRoundingUp(bitsPerPixel);
this.bitsPerPixel = bitsPerPixel;
this.pngChunkPlte = pngChunkPLTE;
this.gammaCorrection = gammaCorrection;
(commons-imaging) 22/22: Convert cascading if-else to switch
Posted by gg...@apache.org.
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
commit 902eda07c1ddec186800defc2146b4bfdfe23a7c
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:59:17 2024 -0400
Convert cascading if-else to switch
---
.../commons/imaging/formats/xpm/XpmImageParser.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
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 f2022aa7..52d385a5 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
@@ -468,18 +468,26 @@ public class XpmImageParser extends AbstractImageParser<XpmImagingParameters> {
}
private void populatePaletteEntry(final PaletteEntry paletteEntry, final String key, final String color) throws ImagingException {
- if ("m".equals(key)) {
+ switch (key) {
+ case "m":
paletteEntry.monoArgb = parseColor(color);
paletteEntry.haveMono = true;
- } else if ("g4".equals(key)) {
+ break;
+ case "g4":
paletteEntry.gray4LevelArgb = parseColor(color);
paletteEntry.haveGray4Level = true;
- } else if ("g".equals(key)) {
+ break;
+ case "g":
paletteEntry.grayArgb = parseColor(color);
paletteEntry.haveGray = true;
- } else if ("s".equals(key) || "c".equals(key)) {
+ break;
+ case "s":
+ case "c":
paletteEntry.colorArgb = parseColor(color);
paletteEntry.haveColor = true;
+ break;
+ default:
+ break;
}
}
(commons-imaging) 13/22: Convert cascading if-else to switch
Posted by gg...@apache.org.
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
commit 2d457ddcb0da2a39ac5b36061b6d482c32f97b7f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:18 2024 -0400
Convert cascading if-else to switch
---
.../org/apache/commons/imaging/formats/png/PngTextTest.java | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngTextTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngTextTest.java
index 5337e6c1..5a16c515 100644
--- a/src/test/java/org/apache/commons/imaging/formats/png/PngTextTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/png/PngTextTest.java
@@ -75,14 +75,19 @@ public class PngTextTest extends AbstractPngTest {
final List<AbstractPngText> readTexts = imageInfo.getTextChunks();
assertEquals(readTexts.size(), 3);
for (final AbstractPngText text : readTexts) {
- if (text.keyword.equals("a")) {
+ switch (text.keyword) {
+ case "a":
assertEquals(text.text, "b");
- } else if (text.keyword.equals("c")) {
+ break;
+ case "c":
assertEquals(text.text, "d");
- } else if (text.keyword.equals("e")) {
+ break;
+ case "e":
assertEquals(text.text, "f");
- } else {
+ break;
+ default:
fail("unknown text chunk.");
+ break;
}
}
}
(commons-imaging) 11/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 774486041d9c7a025cb0e9725b3a9022abda1826
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:00 2024 -0400
Merge nested if clauses
---
.../org/apache/commons/imaging/formats/pcx/PcxImageParser.java | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
index 603ddbba..502917d6 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
@@ -407,12 +407,10 @@ public class PcxImageParser extends AbstractImageParser<PcxImagingParameters> {
if (manufacturer != 10) {
throw new ImagingException("Not a Valid PCX File: manufacturer is " + manufacturer);
}
- if (isStrict) {
- // Note that reserved is sometimes set to a non-zero value
- // by Paintbrush itself, so it shouldn't be enforced.
- if (bytesPerLine % 2 != 0) {
- throw new ImagingException("Not a Valid PCX File: bytesPerLine is odd");
- }
+ // Note that reserved is sometimes set to a non-zero value
+ // by Paintbrush itself, so it shouldn't be enforced.
+ if (isStrict && bytesPerLine % 2 != 0) {
+ throw new ImagingException("Not a Valid PCX File: bytesPerLine is odd");
}
return new PcxHeader(manufacturer, version, encoding, bitsPerPixel, xMin, yMin, xMax, yMax, hDpi, vDpi, colormap, reserved, nPlanes, bytesPerLine,
(commons-imaging) 10/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 86882946821ec4b973e577b29bed30495ba03c72
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:51 2024 -0400
Merge nested if clauses
---
.../commons/imaging/palette/MostPopulatedBoxesMedianCut.java | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java b/src/main/java/org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java
index 99cb9a34..2a563639 100644
--- a/src/main/java/org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java
+++ b/src/main/java/org/apache/commons/imaging/palette/MostPopulatedBoxesMedianCut.java
@@ -28,11 +28,9 @@ public class MostPopulatedBoxesMedianCut implements MedianCut {
int maxPoints = 0;
ColorGroup colorGroup = null;
for (final ColorGroup group : colorGroups) {
- if (group.maxDiff > 0) {
- if (group.totalPoints > maxPoints) {
- colorGroup = group;
- maxPoints = group.totalPoints;
- }
+ if (group.maxDiff > 0 && group.totalPoints > maxPoints) {
+ colorGroup = group;
+ maxPoints = group.totalPoints;
}
}
if (colorGroup == null) {
(commons-imaging) 06/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 742c999c4bf8060c756c2a2d667c39431a7020a6
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:04 2024 -0400
Merge nested if clauses
---
.../java/org/apache/commons/imaging/roundtrip/ImageAsserts.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/test/java/org/apache/commons/imaging/roundtrip/ImageAsserts.java b/src/test/java/org/apache/commons/imaging/roundtrip/ImageAsserts.java
index 2b297950..83b717ec 100644
--- a/src/test/java/org/apache/commons/imaging/roundtrip/ImageAsserts.java
+++ b/src/test/java/org/apache/commons/imaging/roundtrip/ImageAsserts.java
@@ -64,10 +64,8 @@ final class ImageAsserts {
for (int y = 0; y < a.getHeight(); y++) {
final int aArgb = a.getRGB(x, y);
final int bArgb = b.getRGB(x, y);
- if (aArgb != bArgb) {
- if (calculateARGBDistance(aArgb, bArgb) <= tolerance) {
- continue; // ignore.
- }
+ if (aArgb != bArgb && calculateARGBDistance(aArgb, bArgb) <= tolerance) {
+ continue; // ignore.
}
if (aArgb != bArgb) {
Debug.debug("width: " + a.getWidth());
(commons-imaging) 15/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 147555b561bc0f459b33b4db6bc102093e885a05
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:32 2024 -0400
Merge nested if clauses
---
.../commons/imaging/common/RationalNumber.java | 34 ++++++++++------------
1 file changed, 16 insertions(+), 18 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/common/RationalNumber.java b/src/main/java/org/apache/commons/imaging/common/RationalNumber.java
index 32d67f67..cfdfba03 100644
--- a/src/main/java/org/apache/commons/imaging/common/RationalNumber.java
+++ b/src/main/java/org/apache/commons/imaging/common/RationalNumber.java
@@ -256,25 +256,23 @@ public class RationalNumber extends Number {
public RationalNumber negate() {
long n = numerator;
long d = divisor;
- if (unsignedType) {
- // An instance of an unsigned type can be negated if and only if
- // its high-order bit (the sign bit) is clear. If the bit is set,
- // the value will be too large to convert to a signed type.
- // In such a case it is necessary to adjust the numerator and denominator
- // by their greatest common divisor (gcd), if one exists.
- // If no non-zero common divisor exists, an exception is thrown.
+ // An instance of an unsigned type can be negated if and only if
+ // its high-order bit (the sign bit) is clear. If the bit is set,
+ // the value will be too large to convert to a signed type.
+ // In such a case it is necessary to adjust the numerator and denominator
+ // by their greatest common divisor (gcd), if one exists.
+ // If no non-zero common divisor exists, an exception is thrown.
+ if (unsignedType && n >> 31 == 1) {
+ // the unsigned value is so large that the high-order bit is set
+ // it cannot be converted to a negative number. Check to see
+ // whether there is an option to reduce its magnitude.
+ final long g = gcd(numerator, divisor);
+ if (g != 0) {
+ n /= g;
+ d /= g;
+ }
if (n >> 31 == 1) {
- // the unsigned value is so large that the high-order bit is set
- // it cannot be converted to a negative number. Check to see
- // whether there is an option to reduce its magnitude.
- final long g = gcd(numerator, divisor);
- if (g != 0) {
- n /= g;
- d /= g;
- }
- if (n >> 31 == 1) {
- throw new NumberFormatException("Unsigned numerator is too large to negate " + numerator);
- }
+ throw new NumberFormatException("Unsigned numerator is too large to negate " + numerator);
}
}
return new RationalNumber(-n, d, false);
(commons-imaging) 08/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit eb0f5e8a1cb3119ed47c35ca1a69b36dea231b72
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:36 2024 -0400
Remove redundant keyword
---
.../commons/imaging/formats/jpeg/decoder/JpegInputStream.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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 1bf6c404..96e94ce0 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
@@ -45,13 +45,13 @@ final class JpegInputStream {
public int nextBit() throws ImagingException {
if (cnt == 0) {
- b = this.read();
+ b = read();
if (b < 0) {
throw new ImagingException("Premature End of File");
}
cnt = 8;
if (b == 0xff) {
- final int b2 = this.read();
+ final int b2 = read();
if (b2 < 0) {
throw new ImagingException("Premature End of File");
}
@@ -76,7 +76,7 @@ final class JpegInputStream {
* @throws IllegalStateException if the stream hasn't any other value.
*/
int read() {
- if (!this.hasNext()) {
+ if (!hasNext()) {
throw new IllegalStateException("This stream hasn't any other value, all values were already read.");
}
final int value = this.interval[nextPos];
(commons-imaging) 14/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 32a3b240f23ad1c5885e145e4b1d781d1839c665
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:24 2024 -0400
Remove redundant keyword
---
.../java/org/apache/commons/imaging/formats/psd/PsdImageParser.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java b/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
index 58adc6a6..44cf5db1 100644
--- a/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
@@ -574,7 +574,7 @@ public class PsdImageParser extends AbstractImageParser<PsdImagingParameters> im
private List<ImageResourceBlock> readImageResourceBlocks(final ByteSource byteSource, final int[] imageResourceIDs, final int maxBlocksToRead)
throws ImagingException, IOException {
try (InputStream imageStream = byteSource.getInputStream();
- InputStream resourceStream = this.getInputStream(byteSource, PSD_SECTION_IMAGE_RESOURCES)) {
+ InputStream resourceStream = getInputStream(byteSource, PSD_SECTION_IMAGE_RESOURCES)) {
final PsdImageContents imageContents = readImageContents(imageStream);
(commons-imaging) 21/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 60a5afcd33955d8f3f2eecdafbecbb1f6d8f8ecb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:59:11 2024 -0400
Remove redundant keyword
---
.../apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java
index bd515e16..b815a1f1 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffShortIntRoundTripTest.java
@@ -168,7 +168,7 @@ public class TiffShortIntRoundTripTest extends TiffBaseTest {
nBytesInBlock = nRowsInBlock * nColsInBlock * bytesPerSample;
byte[][] blocks;
- blocks = this.getBytesForOutput16(sample, width, height, nRowsInBlock, nColsInBlock, byteOrder);
+ blocks = getBytesForOutput16(sample, width, height, nRowsInBlock, nColsInBlock, byteOrder);
// NOTE: At this time, Tile format is not supported.
// When it is, modify the tags below to populate
(commons-imaging) 09/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 86a70282aa0115210285a1ed35c551c600f47ea9
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:57:45 2024 -0400
Merge nested if clauses
---
.../org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
index 9ec7cea9..4ccf602f 100644
--- a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegRewriter.java
@@ -261,10 +261,8 @@ public class JpegRewriter extends BinaryFileParser {
}
final JFIFPieceSegment segment = (JFIFPieceSegment) piece;
- if (segment.isAppSegment()) {
- if (firstAppIndex == -1) {
- firstAppIndex = i;
- }
+ if (segment.isAppSegment() && firstAppIndex == -1) {
+ firstAppIndex = i;
}
}
(commons-imaging) 12/22: Merge nested if clauses
Posted by gg...@apache.org.
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
commit 6ca068cca31cdb40809d7422bae29a329f02ddbd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:06 2024 -0400
Merge nested if clauses
---
.../apache/commons/imaging/formats/png/PngImageParser.java | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java b/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
index f21761f5..24c11f14 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
@@ -242,10 +242,8 @@ public class PngImageParser extends AbstractImageParser<PngImagingParameters> im
gammaCorrection = new GammaCorrection(gamma, targetGamma);
}
- if (gammaCorrection != null) {
- if (pngChunkPLTE != null) {
- pngChunkPLTE.correct(gammaCorrection);
- }
+ if (gammaCorrection != null && pngChunkPLTE != null) {
+ pngChunkPLTE.correct(gammaCorrection);
}
}
@@ -633,10 +631,8 @@ public class PngImageParser extends AbstractImageParser<PngImagingParameters> im
BinaryFunctions.skipBytes(is, length, "Not a Valid PNG File");
}
- if (LOGGER.isLoggable(Level.FINEST)) {
- if (bytes != null) {
- debugNumber("bytes", bytes.length, 4);
- }
+ if (LOGGER.isLoggable(Level.FINEST) && bytes != null) {
+ debugNumber("bytes", bytes.length, 4);
}
final int crc = BinaryFunctions.read4Bytes("CRC", is, "Not a Valid PNG File", getByteOrder());
(commons-imaging) 20/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 053fbc14b1d55c6b0a3c8ae5989ed9c2d9e21efb
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:59:05 2024 -0400
Remove redundant keyword
---
.../org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java
index 4fb6e5f2..f10ba2aa 100644
--- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java
+++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffRoundTripInt32Test.java
@@ -172,7 +172,7 @@ public class TiffRoundTripInt32Test extends TiffBaseTest {
nBytesInBlock = nRowsInBlock * nColsInBlock * bytesPerSample;
byte[][] blocks;
- blocks = this.getBytesForOutput32(sample, width, height, nRowsInBlock, nColsInBlock, byteOrder);
+ blocks = getBytesForOutput32(sample, width, height, nRowsInBlock, nColsInBlock, byteOrder);
// NOTE: At this time, Tile format is not supported.
// When it is, modify the tags below to populate
(commons-imaging) 18/22: Remove redundant keyword
Posted by gg...@apache.org.
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
commit 82d276efe452bcbf6265272262af9aab0aef96e7
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Thu Sep 12 08:58:53 2024 -0400
Remove redundant keyword
---
.../commons/imaging/formats/tiff/TiffFloatingPointRoundTripTest.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 e57885c6..c13c168d 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
@@ -270,7 +270,7 @@ public class TiffFloatingPointRoundTripTest extends TiffBaseTest {
byte[][] blocks;
if (bitsPerSample == 32) {
- blocks = this.getBytesForOutput32(f, width, height, nRowsInBlock, nColsInBlock, byteOrder);
+ blocks = getBytesForOutput32(f, width, height, nRowsInBlock, nColsInBlock, byteOrder);
} else {
blocks = getBytesForOutput64(f, width, height, nRowsInBlock, nColsInBlock, byteOrder);
}