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 2023/11/27 13:37:28 UTC

(commons-imaging) branch master updated (a579e723 -> bc64d713)

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 a579e723 Share plugin configuration between build and reporting
     new 86513042 Make org.apache.commons.imaging.formats.pcx.PcxWriter.encoding final
     new 8cd5ca33 Make org.apache.commons.imaging.formats.pcx.PcxWriter.pixelDensity final
     new 54178ac2 Make org.apache.commons.imaging.formats.pcx.PcxWriter.bitDepthWanted final
     new 5f2c46d2 Make org.apache.commons.imaging.formats.pcx.PcxWriter.planesWanted final
     new a8de3c14 Make org.apache.commons.imaging.formats.tiff.itu_t4.HuffmanTree.nodes final
     new 57d739d7 A class which only has private constructors should be final
     new 9099b62a A class which only has private constructors should be final
     new 3a2076fa A class which only has private constructors should be final
     new 59fa5f06 Format
     new 3dccb2b5 PMD: System.arraycopy is more efficient
     new bc64d713 PMD: System.arraycopy is more efficient

The 11 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/formats/pcx/PcxWriter.java     | 30 ++++++++--------------
 .../commons/imaging/formats/png/PhysicalScale.java |  2 +-
 .../formats/tiff/fieldtypes/FieldTypeLong.java     |  4 +--
 .../formats/tiff/fieldtypes/FieldTypeLong8.java    |  4 +--
 .../imaging/formats/tiff/itu_t4/HuffmanTree.java   |  2 +-
 .../imaging/internal/ImageParserFactory.java       |  2 +-
 .../commons/imaging/internal/SafeOperations.java   | 13 +++-------
 7 files changed, 19 insertions(+), 38 deletions(-)


(commons-imaging) 07/11: A class which only has private constructors should be final

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 9099b62a08f158efd6cc43dfdd142088d0cd5c00
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:21:14 2023 -0500

    A class which only has private constructors should be final
---
 .../java/org/apache/commons/imaging/internal/ImageParserFactory.java    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java
index 789e6a33..85099dd2 100644
--- a/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java
+++ b/src/main/java/org/apache/commons/imaging/internal/ImageParserFactory.java
@@ -32,7 +32,7 @@ import org.apache.commons.imaging.bytesource.ByteSource;
  *
  * @since 1.0-alpha3
  */
-public class ImageParserFactory {
+public final class ImageParserFactory {
 
     public static <T extends ImagingParameters<T>> AbstractImageParser<T> getImageParser(final ByteSource byteSource) throws IOException {
         // TODO: circular dependency between Imaging and internal Util class below.


(commons-imaging) 01/11: Make org.apache.commons.imaging.formats.pcx.PcxWriter.encoding final

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 86513042a07ce0581985f7bd8ac01193b78560dd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:11:57 2023 -0500

    Make org.apache.commons.imaging.formats.pcx.PcxWriter.encoding final
---
 .../java/org/apache/commons/imaging/formats/pcx/PcxWriter.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index fbe2ee25..5243ca67 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -27,7 +27,7 @@ import org.apache.commons.imaging.palette.PaletteFactory;
 import org.apache.commons.imaging.palette.SimplePalette;
 
 final class PcxWriter {
-    private int encoding;
+    private final int encoding;
     private int bitDepthWanted = -1;
     private int planesWanted = -1;
     private PixelDensity pixelDensity;
@@ -39,11 +39,8 @@ final class PcxWriter {
         if (params == null) {
             params = new PcxImagingParameters();
         }
-        encoding = PcxImageParser.PcxHeader.ENCODING_RLE;
-        final int compression = params.getCompression();
-        if (compression == PcxConstants.PCX_COMPRESSION_UNCOMPRESSED) {
-            encoding = PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED;
-        }
+        encoding = params.getCompression() == PcxConstants.PCX_COMPRESSION_UNCOMPRESSED ? PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED
+                : PcxImageParser.PcxHeader.ENCODING_RLE;
         if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
             rleWriter = new RleWriter(false);
         } else {


(commons-imaging) 05/11: Make org.apache.commons.imaging.formats.tiff.itu_t4.HuffmanTree.nodes final

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 a8de3c147d488871fa18cf2613919e78b6303f0f
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:18:19 2023 -0500

    Make org.apache.commons.imaging.formats.tiff.itu_t4.HuffmanTree.nodes
    final
---
 .../org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java
index 2be4bde4..25fc32f6 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/itu_t4/HuffmanTree.java
@@ -31,7 +31,7 @@ final class HuffmanTree<T> {
         T value;
     }
 
-    private List<Node<T>> nodes = new ArrayList<>();
+    private final List<Node<T>> nodes = new ArrayList<>();
 
     public T decode(final BitInputStreamFlexible bitStream) throws ImagingException {
         int position = 0;


(commons-imaging) 09/11: Format

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 59fa5f06d88886cbb9a01a33417e3665b30fb763
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:21:44 2023 -0500

    Format
---
 .../org/apache/commons/imaging/internal/SafeOperations.java   | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java b/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
index 11edef20..24c309f6 100644
--- a/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
+++ b/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
@@ -19,16 +19,14 @@ package org.apache.commons.imaging.internal;
 import java.util.Arrays;
 
 /**
- * Provides safe arithmetic operations to avoid, for example,
- * numeric overflows.
+ * Provides safe arithmetic operations to avoid, for example, numeric overflows.
  *
  * @since 1.0-alpha4
  */
 public final class SafeOperations {
 
     /**
-     * Applies {@link Math#addExact(int, int)} to a variable
-     * length array of integers.
+     * Applies {@link Math#addExact(int, int)} to a variable length array of integers.
      *
      * @param values variable length array of integers.
      * @return the values safely added.
@@ -37,10 +35,7 @@ public final class SafeOperations {
         if (values == null || values.length < 2) {
             throw new IllegalArgumentException("You must provide at least two elements to be added");
         }
-        return Arrays
-                .stream(values)
-                .reduce(0, Math::addExact)
-                ;
+        return Arrays.stream(values).reduce(0, Math::addExact);
     }
 
     private SafeOperations() {


(commons-imaging) 10/11: PMD: System.arraycopy is more efficient

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 3dccb2b59f5a0b2e5186c9f7bc6d8a35eb94e0ef
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:34:14 2023 -0500

    PMD: System.arraycopy is more efficient
---
 .../commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java       | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java b/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java
index a31098ff..e939e3db 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong8.java
@@ -62,9 +62,7 @@ public class FieldTypeLong8 extends AbstractFieldType {
         }
         final Integer[] numbers = (Integer[]) o;
         final int[] values = Allocator.intArray(numbers.length);
-        for (int i = 0; i < values.length; i++) {
-            values[i] = numbers[i];
-        }
+        System.arraycopy(numbers, 0, values, 0, values.length);
         return ByteConversions.toBytes(values, byteOrder);
     }
 


(commons-imaging) 02/11: Make org.apache.commons.imaging.formats.pcx.PcxWriter.pixelDensity final

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 8cd5ca337a02ca55953c2f6f947cf4b66ab1c359
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:15:40 2023 -0500

    Make org.apache.commons.imaging.formats.pcx.PcxWriter.pixelDensity final
---
 .../apache/commons/imaging/formats/pcx/PcxWriter.java   | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index 5243ca67..c817ab00 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -30,7 +30,7 @@ final class PcxWriter {
     private final int encoding;
     private int bitDepthWanted = -1;
     private int planesWanted = -1;
-    private PixelDensity pixelDensity;
+    private final PixelDensity pixelDensity;
     private final RleWriter rleWriter;
 
     PcxWriter(PcxImagingParameters params) {
@@ -41,19 +41,12 @@ final class PcxWriter {
         }
         encoding = params.getCompression() == PcxConstants.PCX_COMPRESSION_UNCOMPRESSED ? PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED
                 : PcxImageParser.PcxHeader.ENCODING_RLE;
-        if (encoding == PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED) {
-            rleWriter = new RleWriter(false);
-        } else {
-            rleWriter = new RleWriter(true);
-        }
-
+        rleWriter = new RleWriter(encoding != PcxImageParser.PcxHeader.ENCODING_UNCOMPRESSED);
         bitDepthWanted = params.getBitDepth();
         planesWanted = params.getPlanes();
-        pixelDensity = params.getPixelDensity();
-        if (pixelDensity == null) {
-            // DPI is mandatory, so we have to invent something
-            pixelDensity = PixelDensity.createFromPixelsPerInch(72, 72);
-        }
+        final PixelDensity pixelDensityParam = params.getPixelDensity();
+        // DPI is mandatory, so we have to invent something
+        pixelDensity = pixelDensityParam != null ? pixelDensityParam : PixelDensity.createFromPixelsPerInch(72, 72);
     }
 
     public void writeImage(final BufferedImage src, final OutputStream os)


(commons-imaging) 11/11: PMD: System.arraycopy is more efficient

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 bc64d713f32dd76fbe96d11d14e33949c17e7563
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:34:19 2023 -0500

    PMD: System.arraycopy is more efficient
---
 .../apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java b/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java
index 1b520078..37811091 100644
--- a/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java
+++ b/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java
@@ -52,9 +52,7 @@ public class FieldTypeLong extends AbstractFieldType {
         }
         final Integer[] numbers = (Integer[]) o;
         final int[] values = Allocator.intArray(numbers.length);
-        for (int i = 0; i < values.length; i++) {
-            values[i] = numbers[i];
-        }
+        System.arraycopy(numbers, 0, values, 0, values.length);
         return ByteConversions.toBytes(values, byteOrder);
     }
 


(commons-imaging) 08/11: A class which only has private constructors should be final

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 3a2076fa01a446c24e0d592645bb4de4de0e97a0
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:21:33 2023 -0500

    A class which only has private constructors should be final
---
 src/main/java/org/apache/commons/imaging/internal/SafeOperations.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java b/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
index 8187c294..11edef20 100644
--- a/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
+++ b/src/main/java/org/apache/commons/imaging/internal/SafeOperations.java
@@ -24,7 +24,7 @@ import java.util.Arrays;
  *
  * @since 1.0-alpha4
  */
-public class SafeOperations {
+public final class SafeOperations {
 
     /**
      * Applies {@link Math#addExact(int, int)} to a variable


(commons-imaging) 06/11: A class which only has private constructors should be final

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 57d739d7e61b42c0499888c683d571e7f77446fe
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:20:48 2023 -0500

    A class which only has private constructors should be final
---
 src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
index b57bbea4..ee4d84dc 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
@@ -19,7 +19,7 @@ package org.apache.commons.imaging.formats.png;
 /**
  * Used to specify physical scale when reading or storing image information.
  */
-public class PhysicalScale {
+public final class PhysicalScale {
    private static final int METER_UNITS = 1;
    private static final int RADIAN_UNITS = 2;
    public static final PhysicalScale UNDEFINED = createFromMeters(-1.0, -1.0);


(commons-imaging) 03/11: Make org.apache.commons.imaging.formats.pcx.PcxWriter.bitDepthWanted final

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 54178ac2b8edc306bf2322aa966b0fa5e479a7ba
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:15:53 2023 -0500

    Make org.apache.commons.imaging.formats.pcx.PcxWriter.bitDepthWanted
    final
---
 src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index c817ab00..d597950f 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -28,7 +28,7 @@ import org.apache.commons.imaging.palette.SimplePalette;
 
 final class PcxWriter {
     private final int encoding;
-    private int bitDepthWanted = -1;
+    private final int bitDepthWanted;
     private int planesWanted = -1;
     private final PixelDensity pixelDensity;
     private final RleWriter rleWriter;


(commons-imaging) 04/11: Make org.apache.commons.imaging.formats.pcx.PcxWriter.planesWanted final

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 5f2c46d2a67b4c9a617bb435207b3e4627127fcd
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Mon Nov 27 08:17:17 2023 -0500

    Make org.apache.commons.imaging.formats.pcx.PcxWriter.planesWanted final
---
 src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
index d597950f..0b54e410 100644
--- a/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
+++ b/src/main/java/org/apache/commons/imaging/formats/pcx/PcxWriter.java
@@ -29,7 +29,7 @@ import org.apache.commons.imaging.palette.SimplePalette;
 final class PcxWriter {
     private final int encoding;
     private final int bitDepthWanted;
-    private int planesWanted = -1;
+    private final int planesWanted;
     private final PixelDensity pixelDensity;
     private final RleWriter rleWriter;