From 6d7cb3fffb8cfacf2ecde74e530d1c05feb1cabd Mon Sep 17 00:00:00 2001 From: iuliana Date: Sat, 1 Sep 2018 23:01:05 +0100 Subject: [PATCH 1/2] started migration to JDK 11. Build with JDK 11 eap + Gradle 5.0 --- .gitignore | 27 + README.txt => README.adoc | 42 +- RELEASE_NOTES | 6 + build.gradle | 65 +++ pom.xml | 236 --------- settings.gradle | 20 + src/main/assembly/bin.xml | 45 -- src/main/assembly/src.xml | 45 -- src/main/java/module-info.java | 6 + .../commons/imaging/FormatCompliance.java | 2 +- .../org/apache/commons/imaging/Sanselan.java | 2 +- .../commons/imaging/SanselanConstants.java | 29 +- .../imaging/color/ColorConversions.java | 58 +- .../imaging/common/BinaryConversions.java | 52 +- .../imaging/common/BinaryFileFunctions.java | 42 +- .../imaging/common/BinaryInputStream.java | 6 +- .../commons/imaging/common/ImageMetadata.java | 2 +- .../imaging/formats/bmp/BmpHeaderInfo.java | 12 +- .../imaging/formats/bmp/BmpImageParser.java | 2 +- .../pixelparsers/PixelParserBitFields.java | 2 +- .../bmp/pixelparsers/PixelParserRgb.java | 6 +- .../imaging/formats/dcx/DcxImageParser.java | 4 +- .../imaging/formats/jpeg/JpegConstants.java | 91 ++-- .../formats/jpeg/JpegImageMetadata.java | 2 +- .../formats/jpeg/JpegPhotoshopMetadata.java | 18 +- .../imaging/formats/jpeg/decoder/Dct.java | 2 +- .../formats/jpeg/exif/ExifRewriter.java | 4 +- .../imaging/formats/jpeg/iptc/IptcParser.java | 9 +- .../imaging/formats/jpeg/iptc/IptcRecord.java | 7 +- .../formats/jpeg/segments/DhtSegment.java | 2 +- .../formats/jpeg/segments/DqtSegment.java | 2 +- .../formats/jpeg/xmp/JpegRewriter.java | 205 +++---- .../formats/jpeg/xmp/JpegXmpRewriter.java | 2 +- .../imaging/formats/png/PngImageParser.java | 4 +- .../imaging/formats/png/PngWriter.java | 2 +- .../imaging/formats/pnm/WhiteSpaceReader.java | 2 +- .../imaging/formats/psd/PsdConstants.java | 4 +- .../formats/rgbe/InfoHeaderReader.java | 2 +- .../imaging/formats/tiff/TiffContents.java | 35 +- .../imaging/formats/tiff/TiffDirectory.java | 2 +- .../imaging/formats/tiff/TiffElement.java | 8 +- .../imaging/formats/tiff/TiffField.java | 327 ++++-------- .../formats/tiff/TiffImageMetadata.java | 4 +- .../imaging/formats/tiff/TiffReader.java | 203 +++---- .../AdobePageMaker6TagConstants.java | 35 +- .../constants/AdobePhotoshopTagConstants.java | 16 +- .../AliasSketchbookProTagConstants.java | 13 +- .../tiff/constants/DcfTagConstants.java | 30 +- .../tiff/constants/DngTagConstants.java | 263 ++++----- .../tiff/constants/ExifTagConstants.java | 501 +++++++++--------- .../constants/GdalLibraryTagConstants.java | 17 +- .../tiff/constants/GeoTiffTagConstants.java | 27 +- .../tiff/constants/GpsTagConstants.java | 111 ++-- .../tiff/constants/HylaFaxTagConstants.java | 15 +- .../MicrosoftHdPhotoTagConstants.java | 199 ++----- .../tiff/constants/MicrosoftTagConstants.java | 31 +- .../MolecularDynamicsGelTagConstants.java | 35 +- .../constants/OceScanjobTagConstants.java | 25 +- .../tiff/constants/Rfc2301TagConstants.java | 89 ++-- .../tiff/constants/Tiff4TagConstants.java | 20 +- .../tiff/constants/TiffEpTagConstants.java | 95 ++-- .../constants/TiffFieldTypeConstants.java | 96 ++-- .../tiff/constants/TiffTagConstants.java | 356 ++++++------- .../tiff/constants/WangTagConstants.java | 13 +- .../PhotometricInterpreterLogLuv.java | 4 +- .../formats/tiff/taginfos/TagInfo.java | 2 +- .../tiff/write/TiffImageWriterBase.java | 2 +- .../tiff/write/TiffImageWriterLossless.java | 169 ++---- .../tiff/write/TiffOutputDirectory.java | 169 +++--- .../formats/tiff/write/TiffOutputField.java | 2 +- .../formats/tiff/write/TiffOutputSet.java | 2 +- .../commons/imaging/icc/IccTagTypes.java | 14 +- .../imaging/palette/MedianCutQuantizer.java | 283 ++++------ .../apache/commons/imaging/util/Debug.java | 42 +- .../apache/commons/imaging/SanselanTest.java | 29 +- .../imaging/SanselanTestConstants.java | 11 +- .../common/BinaryFileFunctionsTest.java | 1 - .../imaging/common/RationalNumberTest.java | 8 +- .../common/bytesource/ByteSourceDataTest.java | 11 +- .../bytesource/ByteSourceImageTest.java | 47 +- .../imaging/formats/bmp/BmpBaseTest.java | 18 +- .../imaging/formats/dcx/DcxBaseTest.java | 16 +- .../imaging/formats/gif/GifBaseTest.java | 7 +- .../imaging/formats/icns/IcnsBaseTest.java | 7 +- .../imaging/formats/ico/IcoBaseTest.java | 7 +- .../imaging/formats/jpeg/JpegBaseTest.java | 8 +- .../formats/jpeg/exif/AsciiFieldTest.java | 35 +- .../formats/jpeg/exif/ExifBaseTest.java | 16 +- .../formats/jpeg/exif/ExifRewriteTest.java | 162 ++---- .../formats/jpeg/iptc/IptcBaseTest.java | 16 +- .../formats/jpeg/xmp/JpegXmpBaseTest.java | 16 +- .../imaging/formats/pcx/PcxBaseTest.java | 7 +- .../imaging/formats/png/PngBaseTest.java | 11 +- .../imaging/formats/rgbe/RgbeBaseTest.java | 6 +- .../imaging/formats/tiff/TiffBaseTest.java | 7 +- .../imaging/formats/tiff/TiffLzwTest.java | 89 ++-- .../imaging/formats/wbmp/WbmpBaseTest.java | 20 +- .../imaging/formats/xbm/XbmBaseTest.java | 20 +- .../imaging/formats/xpm/XpmBaseTest.java | 7 +- 99 files changed, 1797 insertions(+), 3109 deletions(-) create mode 100644 .gitignore rename README.txt => README.adoc (83%) create mode 100644 build.gradle delete mode 100644 pom.xml create mode 100644 settings.gradle delete mode 100644 src/main/assembly/bin.xml delete mode 100644 src/main/assembly/src.xml create mode 100644 src/main/java/module-info.java diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a3076e87 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +.idea +.gradle +*.iml +out +build +gradle +gradlew* +*.class +transaction-logs +_site + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.ear +*.log + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +gradlew +gradlew.bat +.DS_Store +generated \ No newline at end of file diff --git a/README.txt b/README.adoc similarity index 83% rename from README.txt rename to README.adoc index 035b5564..747465f9 100644 --- a/README.txt +++ b/README.adoc @@ -1,6 +1,5 @@ -========================================================================= -Welcome to Apache Commons Sanselan -========================================================================= +== Welcome to Apache Commons Sanselan http://commons.apache.org/sanselan/ + License (see also LICENSE) ============================== @@ -21,13 +20,13 @@ distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. +============================== + +== Getting Started -Getting Started -=============== +=== Mailing Lists -Mailing Lists -------------- To get involved with the Apache Commons Sanselan project, start by having a look at our website (link at top of page) and join our mailing @@ -43,8 +42,8 @@ and the dev mailing list archives can be found at Please prefix the subject line of any messages with [sanselan]. -Downloading ------------ +=== Downloading + The Commons Sanselan source code is available via Subversion at @@ -76,8 +75,23 @@ For more instructions, please see the documentation at: http://commons.apache.org/building.html -Credits -======= - -See http://commons.apache.org/sanselan/team-list.html for the list of -Sanselan committers and main contributors. +=== Credits + +Sanselan committers and main contributors: + +* Charles M. Chen +** cmchen +* Philipp Koch +** pkoch +* Jeremias Maerki +** jeremias +* Craig Russell +** clr +* Yoav Shapira +** yoavs +* Carsten Ziegeler +** cziegeler +* Damjan Jovanovic +** damjan +* Iuliana Cosmina +** iuliana \ No newline at end of file diff --git a/RELEASE_NOTES b/RELEASE_NOTES index f6879cf9..6717ad22 100644 --- a/RELEASE_NOTES +++ b/RELEASE_NOTES @@ -12,6 +12,12 @@ http://commons.apache.org/sanselan/ Version History: ---------------- +Release 1.0-SNAPSHOT +------------ +* Build with +** Gradle 5.0-20180826235923+0000 +** JVM: 11 (Oracle Corporation 11+28) + Release 0.98 ------------ * SANSELAN-44 - JpegImageMetadata getEXIFThumbnail may raise a null pointer exception diff --git a/build.gradle b/build.gradle new file mode 100644 index 00000000..cc3056ff --- /dev/null +++ b/build.gradle @@ -0,0 +1,65 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +buildscript { + repositories { + mavenCentral() + } +} + +apply plugin: 'java' +apply plugin: 'eclipse' +apply plugin: 'idea' +apply plugin: 'distribution' + +group = 'org.apache.commons' +version = '1.0-SNAPSHOT' + +jar { + manifest { + attributes( + "Created-By": System.getProperty('java.version'), + "Specification-Title": "Commons Sanselan", + "Implementation-Version": version, + "Class-Path": configurations.compile.collect { it.getName() }.join(' ') + ) + } +} + + +distributions { + main { + baseName = 'commons-sanselan' + contents { + from jar + from { 'src/LICENSE.txt' } + from { 'src/README.adoc' } + from { 'src/NOTICE.txt' } + from { 'src/RELEASE_NOTES' } + } + } +} + +repositories { + mavenCentral() +} + +dependencies { + testCompile("junit:junit:4.12") + testCompile("commons-io:commons-io:1.4") +} + diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 52cdaa6b..00000000 --- a/pom.xml +++ /dev/null @@ -1,236 +0,0 @@ - - - - - - - 4.0.0 - - - - - - - org.apache.commons - commons-parent - 24 - - - org.apache.commons - commons-sanselan - Commons Sanselan - - 1.0-SNAPSHOT - - - Commons Sanselan is a pure-Java image library. - http://commons.apache.org/sanselan/ - - - scm:svn:http://svn.apache.org/repos/asf/commons/proper/sanselan/trunk - scm:svn:https://svn.apache.org/repos/asf/commons/proper/sanselan/trunk - http://svn.apache.org/viewvc/commons/proper/sanselan/trunk - - - - Jira - http://issues.apache.org/jira/browse/SANSELAN - - 2007 - - - 2.0.7 - - - - 1.5 - 1.5 - sanselan - 1.0 - SANSELAN - 12310720 - org.apache.commons.sanselan.*;version=${project.version};-noimport:=true - - UTF-8 - UTF-8 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.3 - - - src/main/assembly/bin.xml - src/maim/assembly/src.xml - - gnu - - - - org.apache.maven.plugins - maven-surefire-plugin - - -Xmx512m - - - - org.codehaus.mojo - animal-sniffer-maven-plugin - 1.7 - - - org.codehaus.mojo.signature - java15 - 1.0 - - - - - check-java-api - test - - check - - - - - - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - - org.apache.maven.plugins - - - maven-antrun-plugin - - [1.6,) - - run - - - - - false - - - - - - org.apache.felix - - maven-bundle-plugin - - - [2.3.5,) - - - manifest - - - - - false - - - - - - - - - - - - - - junit - junit - 4.10 - test - - - commons-io - commons-io - 1.4 - test - - - - - - - org.codehaus.mojo - findbugs-maven-plugin - 2.4.0 - - - - - - - - - - - Charles M. Chen - cmchen - - - Philipp Koch - pkoch - - - Jeremias Maerki - jeremias - - - Craig Russell - clr - - - Yoav Shapira - yoavs - - - Carsten Ziegeler - cziegeler - - - Damjan Jovanovic - damjan - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 00000000..f46b1289 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +rootProject.name = 'commons-sanselan' + +println('Commons Sanselan version compiled with JDK 11, by Iuliana Cosmina [https://github.com/iuliana]') \ No newline at end of file diff --git a/src/main/assembly/bin.xml b/src/main/assembly/bin.xml deleted file mode 100644 index 9eed74b1..00000000 --- a/src/main/assembly/bin.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - bin - - tar.gz - zip - tar.bz2 - - - - - README* - LICENSE* - KEYS* - NOTICE* - RELEASE_NOTES* - - - - target - - - *.jar - - - - \ No newline at end of file diff --git a/src/main/assembly/src.xml b/src/main/assembly/src.xml deleted file mode 100644 index 70f5fab0..00000000 --- a/src/main/assembly/src.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - src - - tar.gz - zip - tar.bz2 - - - - . - - true - - temp/** - tmp/** - **/target/** - - - - diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java new file mode 100644 index 00000000..41493529 --- /dev/null +++ b/src/main/java/module-info.java @@ -0,0 +1,6 @@ +/** + * Created by iuliana.cosmina on 1/9/18. + */ +module common.sanselan { + requires java.desktop; +} \ No newline at end of file diff --git a/src/main/java/org/apache/commons/imaging/FormatCompliance.java b/src/main/java/org/apache/commons/imaging/FormatCompliance.java index 96b4f329..13142ac2 100644 --- a/src/main/java/org/apache/commons/imaging/FormatCompliance.java +++ b/src/main/java/org/apache/commons/imaging/FormatCompliance.java @@ -150,7 +150,7 @@ public boolean compare(String name, int valid[], int actual) if (actual == valid[i]) return true; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(name + ": " + "Unexpected value: (valid: "); if (valid.length > 1) result.append("{"); diff --git a/src/main/java/org/apache/commons/imaging/Sanselan.java b/src/main/java/org/apache/commons/imaging/Sanselan.java index d9c3bbba..46a077e1 100644 --- a/src/main/java/org/apache/commons/imaging/Sanselan.java +++ b/src/main/java/org/apache/commons/imaging/Sanselan.java @@ -50,7 +50,7 @@ * See the source of the SampleUsage class and other classes in the * org.apache.commons.sanselan.examples package for examples. * - * @see org.apache.commons.sanselan.examples.SampleUsage + * @see org.apache.commons.imaging.examples.SampleUsage */ public abstract class Sanselan implements SanselanConstants { diff --git a/src/main/java/org/apache/commons/imaging/SanselanConstants.java b/src/main/java/org/apache/commons/imaging/SanselanConstants.java index e65bb856..3318caee 100644 --- a/src/main/java/org/apache/commons/imaging/SanselanConstants.java +++ b/src/main/java/org/apache/commons/imaging/SanselanConstants.java @@ -20,14 +20,13 @@ import org.apache.commons.imaging.formats.tiff.constants.TiffConstants; -public interface SanselanConstants -{ +public interface SanselanConstants { /** * Parameter key. Applies to read and write operations. *

* Valid values: Boolean.TRUE and Boolean.FALSE. */ - public static final String PARAM_KEY_VERBOSE = "VERBOSE"; + String PARAM_KEY_VERBOSE = "VERBOSE"; /** * Parameter key. Used to hint the filename when reading from a byte array @@ -41,7 +40,7 @@ public interface SanselanConstants * * @see InputStream */ - public static final String PARAM_KEY_FILENAME = "FILENAME"; + String PARAM_KEY_FILENAME = "FILENAME"; /** * Parameter key. Used in write operations to indicate desired image format. @@ -52,7 +51,7 @@ public interface SanselanConstants * * @see ImageFormat */ - public static final String PARAM_KEY_FORMAT = "FORMAT"; + String PARAM_KEY_FORMAT = "FORMAT"; /** * Parameter key. Used in write operations to indicate desired compression @@ -68,9 +67,9 @@ public interface SanselanConstants * * @see TiffConstants */ - public static final String PARAM_KEY_COMPRESSION = "COMPRESSION"; + String PARAM_KEY_COMPRESSION = "COMPRESSION"; - public static final String BUFFERED_IMAGE_FACTORY = "BUFFERED_IMAGE_FACTORY"; + String BUFFERED_IMAGE_FACTORY = "BUFFERED_IMAGE_FACTORY"; /** * Parameter key. Indicates whether to read embedded thumbnails. @@ -82,7 +81,7 @@ public interface SanselanConstants * * @see TiffConstants */ - public static final String PARAM_KEY_READ_THUMBNAILS = "READ_THUMBNAILS"; + String PARAM_KEY_READ_THUMBNAILS = "READ_THUMBNAILS"; /** * Parameter key. Indicates whether to throw exceptions when parsing invalid @@ -94,33 +93,33 @@ public interface SanselanConstants * * @see TiffConstants */ - public static final String PARAM_KEY_STRICT = "STRICT"; + String PARAM_KEY_STRICT = "STRICT"; /** * Parameter key. - * + *

* Only used when writing images. *

* Valid values: TiffOutputSet to write into the image's EXIF metadata. *

*/ - public static final String PARAM_KEY_EXIF = "EXIF"; + String PARAM_KEY_EXIF = "EXIF"; /** * Parameter key. - * + *

* Only used when writing images. *

* Valid values: String of XMP XML. *

*/ - public static final String PARAM_KEY_XMP_XML = "XMP_XML"; - + String PARAM_KEY_XMP_XML = "XMP_XML"; + /** * Parameter key. Used in write operations to indicate the desired * pixel density (DPI), and/or aspect ratio. *

* Valid values: PixelDensity */ - public static final String PARAM_KEY_PIXEL_DENSITY = "PIXEL_DENSITY"; + String PARAM_KEY_PIXEL_DENSITY = "PIXEL_DENSITY"; } diff --git a/src/main/java/org/apache/commons/imaging/color/ColorConversions.java b/src/main/java/org/apache/commons/imaging/color/ColorConversions.java index aaa9db7e..b49f73aa 100644 --- a/src/main/java/org/apache/commons/imaging/color/ColorConversions.java +++ b/src/main/java/org/apache/commons/imaging/color/ColorConversions.java @@ -32,7 +32,7 @@ public static final ColorCieLab convertXYZtoCIELab(ColorXyz xyz) public static final ColorCieLab convertXYZtoCIELab(double X, double Y, double Z) { - double var_X = X / ref_X; //ref_X = 95.047 Observer= 2°, Illuminant= D65 + double var_X = X / ref_X; //ref_X = 95.047 Observer= 2�, Illuminant= D65 double var_Y = Y / ref_Y; //ref_Y = 100.000 double var_Z = Z / ref_Z; //ref_Z = 108.883 @@ -79,7 +79,7 @@ public static final ColorXyz convertCIELabtoXYZ(double L, double a, double b) else var_Z = (var_Z - 16 / 116.0) / 7.787; - double X = ref_X * var_X; //ref_X = 95.047 Observer= 2°, Illuminant= D65 + double X = ref_X * var_X; //ref_X = 95.047 Observer= 2�, Illuminant= D65 double Y = ref_Y * var_Y; //ref_Y = 100.000 double Z = ref_Z * var_Z; //ref_Z = 108.883 @@ -127,10 +127,10 @@ public static final int convertXYZtoRGB(ColorXyz xyz) public static final int convertXYZtoRGB(double X, double Y, double Z) { - //Observer = 2°, Illuminant = D65 - double var_X = X / 100.0; //Where X = 0 ÷ 95.047 - double var_Y = Y / 100.0; //Where Y = 0 ÷ 100.000 - double var_Z = Z / 100.0; //Where Z = 0 ÷ 108.883 + //Observer = 2�, Illuminant = D65 + double var_X = X / 100.0; //Where X = 0 � 95.047 + double var_Y = Y / 100.0; //Where Y = 0 � 100.000 + double var_Z = Z / 100.0; //Where Z = 0 � 108.883 double var_R = var_X * 3.2406 + var_Y * -1.5372 + var_Z * -0.4986; double var_G = var_X * -0.9689 + var_Y * 1.8758 + var_Z * 0.0415; @@ -162,9 +162,9 @@ public static final ColorXyz convertRGBtoXYZ(int rgb) int g = 0xff & (rgb >> 8); int b = 0xff & (rgb >> 0); - double var_R = r / 255.0; //Where R = 0 ÷ 255 - double var_G = g / 255.0; //Where G = 0 ÷ 255 - double var_B = b / 255.0; //Where B = 0 ÷ 255 + double var_R = r / 255.0; //Where R = 0 � 255 + double var_G = g / 255.0; //Where G = 0 � 255 + double var_B = b / 255.0; //Where B = 0 � 255 if (var_R > 0.04045) var_R = Math.pow((var_R + 0.055) / 1.055, 2.4); @@ -183,7 +183,7 @@ public static final ColorXyz convertRGBtoXYZ(int rgb) var_G = var_G * 100; var_B = var_B * 100; - // Observer. = 2°, Illuminant = D65 + // Observer. = 2�, Illuminant = D65 double X = var_R * 0.4124 + var_G * 0.3576 + var_B * 0.1805; double Y = var_R * 0.2126 + var_G * 0.7152 + var_B * 0.0722; double Z = var_R * 0.0193 + var_G * 0.1192 + var_B * 0.9505; @@ -197,8 +197,8 @@ public static final ColorCmy convertRGBtoCMY(int rgb) int G = 0xff & (rgb >> 8); int B = 0xff & (rgb >> 0); - // RGB values = 0 ÷ 255 - // CMY values = 0 ÷ 1 + // RGB values = 0 � 255 + // CMY values = 0 � 1 double C = 1 - (R / 255.0); double M = 1 - (G / 255.0); @@ -215,8 +215,8 @@ public static final int convertCMYtoRGB(ColorCmy cmy) // and similarly for G and B. // This is Ghostscript's formula with K = 0. - // CMY values = 0 ÷ 1 - // RGB values = 0 ÷ 255 + // CMY values = 0 � 1 + // RGB values = 0 � 255 double R = (1 - cmy.C) * 255.0; double G = (1 - cmy.M) * 255.0; @@ -227,7 +227,7 @@ public static final int convertCMYtoRGB(ColorCmy cmy) public static final ColorCmyk convertCMYtoCMYK(ColorCmy cmy) { - // Where CMYK and CMY values = 0 ÷ 1 + // Where CMYK and CMY values = 0 � 1 double C = cmy.C; double M = cmy.M; @@ -264,7 +264,7 @@ public static final ColorCmy convertCMYKtoCMY(ColorCmyk cmyk) public static final ColorCmy convertCMYKtoCMY(double C, double M, double Y, double K) { - // Where CMYK and CMY values = 0 ÷ 1 + // Where CMYK and CMY values = 0 � 1 C = (C * (1 - K) + K); M = (M * (1 - K) + K); @@ -291,7 +291,7 @@ public static final ColorHsl convertRGBtoHSL(int rgb) int G = 0xff & (rgb >> 8); int B = 0xff & (rgb >> 0); - double var_R = (R / 255.0); //Where RGB values = 0 ÷ 255 + double var_R = (R / 255.0); //Where RGB values = 0 � 255 double var_G = (G / 255.0); double var_B = (B / 255.0); @@ -305,7 +305,7 @@ public static final ColorHsl convertRGBtoHSL(int rgb) // Debug.debug("del_Max", del_Max); if (del_Max == 0) //This is a gray, no chroma... { - H = 0; //HSL results = 0 ÷ 1 + H = 0; //HSL results = 0 � 1 S = 0; } else @@ -358,9 +358,9 @@ public static int convertHSLtoRGB(double H, double S, double L) { double R, G, B; - if (S == 0) //HSL values = 0 ÷ 1 + if (S == 0) //HSL values = 0 � 1 { - R = L * 255; //RGB results = 0 ÷ 255 + R = L * 255; //RGB results = 0 � 255 G = L * 255; B = L * 255; } @@ -402,9 +402,9 @@ public static final ColorHsv convertRGBtoHSV(int rgb) { int R = 0xff & (rgb >> 16); int G = 0xff & (rgb >> 8); - int B = 0xff & (rgb >> 0); + int B = 0xff & rgb; - double var_R = (R / 255.0); //RGB values = 0 ÷ 255 + double var_R = (R / 255.0); //RGB values = 0 : 255 double var_G = (G / 255.0); double var_B = (B / 255.0); @@ -417,7 +417,7 @@ public static final ColorHsv convertRGBtoHSV(int rgb) double H, S; if (del_Max == 0) //This is a gray, no chroma... { - H = 0; //HSV results = 0 ÷ 1 + H = 0; //HSV results = 0 : 1 S = 0; } else @@ -459,7 +459,7 @@ public static int convertHSVtoRGB(double H, double S, double V) { double R, G, B; - if (S == 0) //HSV values = 0 ÷ 1 + if (S == 0) //HSV values = 0 : 1 { R = V * 255; G = V * 255; @@ -514,7 +514,7 @@ else if (var_i == 4) var_b = var_2; } - R = var_r * 255; //RGB results = 0 ÷ 255 + R = var_r * 255; //RGB results = 0 ' 255 G = var_g * 255; B = var_b * 255; } @@ -575,7 +575,7 @@ public static final int convertCIELabtoARGBTest(int cieL, int cieA, int cieB) // double ref_Y = 100.000; // double ref_Z = 108.883; - X = ref_X * var_X; //ref_X = 95.047 Observer= 2°, Illuminant= D65 + X = ref_X * var_X; //ref_X = 95.047 Observer= 2, Illuminant= D65 Y = ref_Y * var_Y; //ref_Y = 100.000 Z = ref_Z * var_Z; //ref_Z = 108.883 @@ -669,7 +669,7 @@ public static ColorCieLab convertCIELCHtoCIELab(ColorCieLch cielch) public static ColorCieLab convertCIELCHtoCIELab(double L, double C, double H) { - // Where CIE-H° = 0 ÷ 360° + // Where CIE-H' = 0 ' 360' // CIE-L* = CIE-L; double a = Math.cos(degree_2_radian(H)) * C; @@ -711,7 +711,7 @@ public static ColorCieLuv convertXYZtoCIELuv(double X, double Y, double Z) else var_Y = (7.787 * var_Y) + (16 / 116.0); - double ref_X = 95.047; //Observer= 2°, Illuminant= D65 + double ref_X = 95.047; //Observer= 2, Illuminant= D65 double ref_Y = 100.000; double ref_Z = 108.883; @@ -745,7 +745,7 @@ public static ColorXyz convertCIELuvtoXYZ(double L, double u, double v) else var_Y = (var_Y - 16 / 116) / 7.787; - double ref_X = 95.047; //Observer= 2°, Illuminant= D65 + double ref_X = 95.047; //Observer= 2, Illuminant= D65 double ref_Y = 100.000; double ref_Z = 108.883; diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java b/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java index e78281dd..f5693496 100644 --- a/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java +++ b/src/main/java/org/apache/commons/imaging/common/BinaryConversions.java @@ -31,11 +31,11 @@ public static byte[] convertToByteArray(short[] values, int offset, int length, short value = values[offset + i]; int start = i * 2; if (byteOrder == BYTE_ORDER_MOTOROLA) { - result[start + 0] = (byte) (value >> 8); - result[start + 1] = (byte) (value >> 0); + result[start] = (byte) (value >> 8); + result[start + 1] = (byte) value; } else { result[start + 1] = (byte) (value >> 8); - result[start + 0] = (byte) (value >> 0); + result[start] = (byte) value; } } return result; @@ -55,15 +55,15 @@ public static byte[] convertToByteArray(int[] values, int offset, int length, in int value = values[offset + i]; int start = i * 4; if (byteOrder == BYTE_ORDER_MOTOROLA) { - result[start + 0] = (byte) (value >> 24); + result[start] = (byte) (value >> 24); result[start + 1] = (byte) (value >> 16); result[start + 2] = (byte) (value >> 8); - result[start + 3] = (byte) (value >> 0); + result[start + 3] = (byte) value; } else { result[start + 3] = (byte) (value >> 24); result[start + 2] = (byte) (value >> 16); result[start + 1] = (byte) (value >> 8); - result[start + 0] = (byte) (value >> 0); + result[start] = (byte) value; } } return result; @@ -84,15 +84,15 @@ public static byte[] convertToByteArray(float[] values, int offset, int length, int bits = Float.floatToRawIntBits(value); int start = i * 4; if (byteOrder == BYTE_ORDER_INTEL) { - result[start + 0] = (byte) (0xff & (bits >> 0)); + result[start] = (byte) (0xff & bits); result[start + 1] = (byte) (0xff & (bits >> 8)); result[start + 2] = (byte) (0xff & (bits >> 16)); result[start + 3] = (byte) (0xff & (bits >> 24)); } else { - result[start + 3] = (byte) (0xff & (bits >> 0)); + result[start + 3] = (byte) (0xff & bits); result[start + 2] = (byte) (0xff & (bits >> 8)); result[start + 1] = (byte) (0xff & (bits >> 16)); - result[start + 0] = (byte) (0xff & (bits >> 24)); + result[start] = (byte) (0xff & (bits >> 24)); } } return result; @@ -113,7 +113,7 @@ public static byte[] convertToByteArray(double[] values, int offset, int length, long bits = Double.doubleToRawLongBits(value); int start = i * 8; if (byteOrder == BYTE_ORDER_INTEL) { - result[start + 0] = (byte) (0xff & (bits >> 0)); + result[start] = (byte) (0xff & bits); result[start + 1] = (byte) (0xff & (bits >> 8)); result[start + 2] = (byte) (0xff & (bits >> 16)); result[start + 3] = (byte) (0xff & (bits >> 24)); @@ -122,14 +122,14 @@ public static byte[] convertToByteArray(double[] values, int offset, int length, result[start + 6] = (byte) (0xff & (bits >> 48)); result[start + 7] = (byte) (0xff & (bits >> 56)); } else { - result[start + 7] = (byte) (0xff & (bits >> 0)); + result[start + 7] = (byte) (0xff & bits); result[start + 6] = (byte) (0xff & (bits >> 8)); result[start + 5] = (byte) (0xff & (bits >> 16)); result[start + 4] = (byte) (0xff & (bits >> 24)); result[start + 3] = (byte) (0xff & (bits >> 32)); result[start + 2] = (byte) (0xff & (bits >> 40)); result[start + 1] = (byte) (0xff & (bits >> 48)); - result[start + 0] = (byte) (0xff & (bits >> 56)); + result[start] = (byte) (0xff & (bits >> 56)); } } return result; @@ -149,23 +149,23 @@ public static byte[] convertToByteArray(RationalNumber[] values, int offset, int RationalNumber value = values[offset + i]; int start = i * 8; if (byteOrder == BYTE_ORDER_MOTOROLA) { - result[start + 0] = (byte) (value.numerator >> 24); + result[start] = (byte) (value.numerator >> 24); result[start + 1] = (byte) (value.numerator >> 16); result[start + 2] = (byte) (value.numerator >> 8); - result[start + 3] = (byte) (value.numerator >> 0); + result[start + 3] = (byte) value.numerator; result[start + 4] = (byte) (value.divisor >> 24); result[start + 5] = (byte) (value.divisor >> 16); result[start + 6] = (byte) (value.divisor >> 8); - result[start + 7] = (byte) (value.divisor >> 0); + result[start + 7] = (byte) value.divisor; } else { result[start + 3] = (byte) (value.numerator >> 24); result[start + 2] = (byte) (value.numerator >> 16); result[start + 1] = (byte) (value.numerator >> 8); - result[start + 0] = (byte) (value.numerator >> 0); + result[start] = (byte) value.numerator; result[start + 7] = (byte) (value.divisor >> 24); result[start + 6] = (byte) (value.divisor >> 16); result[start + 5] = (byte) (value.divisor >> 8); - result[start + 4] = (byte) (value.divisor >> 0); + result[start + 4] = (byte) value.divisor; } } return result; @@ -176,7 +176,7 @@ public static short convertToShort(byte[] bytes, int byteOrder) { } public static short convertToShort(byte[] bytes, int offset, int byteOrder) { - int byte0 = 0xff & bytes[offset + 0]; + int byte0 = 0xff & bytes[offset]; int byte1 = 0xff & bytes[offset + 1]; if (byteOrder == BYTE_ORDER_MOTOROLA) { return (short) ((byte0 << 8) | byte1); @@ -206,7 +206,7 @@ public static int convertToInt(byte[] bytes, int byteOrder) { } public static int convertToInt(byte[] bytes, int offset, int byteOrder) { - int byte0 = 0xff & bytes[offset + 0]; + int byte0 = 0xff & bytes[offset]; int byte1 = 0xff & bytes[offset + 1]; int byte2 = 0xff & bytes[offset + 2]; int byte3 = 0xff & bytes[offset + 3]; @@ -240,17 +240,17 @@ public static float convertToFloat(byte[] bytes, int byteOrder) { } public static float convertToFloat(byte[] bytes, int offset, int byteOrder) { - int byte0 = 0xff & bytes[offset + 0]; + int byte0 = 0xff & bytes[offset]; int byte1 = 0xff & bytes[offset + 1]; int byte2 = 0xff & bytes[offset + 2]; int byte3 = 0xff & bytes[offset + 3]; int bits; if (byteOrder == BYTE_ORDER_MOTOROLA) { bits = (byte0 << 24) | (byte1 << 16) | - (byte2 << 8) | (byte3 << 0); + (byte2 << 8) | byte3; } else { bits = (byte3 << 24) | (byte2 << 16) | - (byte1 << 8) | (byte0 << 0); + (byte1 << 8) | byte0; } return Float.intBitsToFloat(bits); } @@ -276,7 +276,7 @@ public static double convertToDouble(byte[] bytes, int byteOrder) { } public static double convertToDouble(byte[] bytes, int offset, int byteOrder) { - long byte0 = 0xffL & bytes[offset + 0]; + long byte0 = 0xffL & bytes[offset]; long byte1 = 0xffL & bytes[offset + 1]; long byte2 = 0xffL & bytes[offset + 2]; long byte3 = 0xffL & bytes[offset + 3]; @@ -289,12 +289,12 @@ public static double convertToDouble(byte[] bytes, int offset, int byteOrder) { bits = (byte0 << 56) | (byte1 << 48) | (byte2 << 40) | (byte3 << 32) | (byte4 << 24) | (byte5 << 16) | - (byte6 << 8) | (byte7 << 0); + (byte6 << 8) | byte7; } else { bits = (byte7 << 56) | (byte6 << 48) | (byte5 << 40) | (byte4 << 32) | (byte3 << 24) | (byte2 << 16) | - (byte1 << 8) | (byte0 << 0); + (byte1 << 8) | byte0; } return Double.longBitsToDouble(bits); } @@ -320,7 +320,7 @@ public static RationalNumber convertToRational(byte[] bytes, int byteOrder) { } public static RationalNumber convertToRational(byte[] bytes, int offset, int byteOrder) { - int byte0 = 0xff & bytes[offset + 0]; + int byte0 = 0xff & bytes[offset]; int byte1 = 0xff & bytes[offset + 1]; int byte2 = 0xff & bytes[offset + 2]; int byte3 = 0xff & bytes[offset + 3]; diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java b/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java index 269d2ef5..6f49ba61 100644 --- a/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java +++ b/src/main/java/org/apache/commons/imaging/common/BinaryFileFunctions.java @@ -256,7 +256,7 @@ protected final RationalNumber convertByteArrayToRational(String name, protected final RationalNumber convertByteArrayToRational(String name, byte bytes[], int start, int byteOrder) { - int numerator = convertByteArrayToInt(name, bytes, start + 0, byteOrder); + int numerator = convertByteArrayToInt(name, bytes, start, byteOrder); int divisor = convertByteArrayToInt(name, bytes, start + 4, byteOrder); return new RationalNumber(numerator, divisor); @@ -271,7 +271,7 @@ protected final int convertByteArrayToInt(String name, byte bytes[], protected final int convertByteArrayToInt(String name, byte bytes[], int start, int byteOrder) { - byte byte0 = bytes[start + 0]; + byte byte0 = bytes[start]; byte byte1 = bytes[start + 1]; byte byte2 = bytes[start + 2]; byte byte3 = bytes[start + 3]; @@ -323,25 +323,25 @@ protected final void writeIntInToByteArray(int value, byte bytes[], { if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian { - bytes[start + 0] = (byte) (value >> 24); + bytes[start] = (byte) (value >> 24); bytes[start + 1] = (byte) (value >> 16); bytes[start + 2] = (byte) (value >> 8); - bytes[start + 3] = (byte) (value >> 0); + bytes[start + 3] = (byte) value; } else { bytes[start + 3] = (byte) (value >> 24); bytes[start + 2] = (byte) (value >> 16); bytes[start + 1] = (byte) (value >> 8); - bytes[start + 0] = (byte) (value >> 0); + bytes[start] = (byte) value; } } protected static final byte[] int2ToByteArray(int value, int byteOrder) { if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian - return new byte[] { (byte) (value >> 8), (byte) (value >> 0), }; + return new byte[] { (byte) (value >> 8), (byte) value, }; else - return new byte[] { (byte) (value >> 0), (byte) (value >> 8), }; + return new byte[] { (byte) value, (byte) (value >> 8), }; } protected final byte[] convertIntArrayToByteArray(int values[], @@ -368,12 +368,12 @@ protected final byte[] convertShortArrayToByteArray(int values[], if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian { - result[i * 2 + 0] = (byte) (value >> 8); - result[i * 2 + 1] = (byte) (value >> 0); + result[i * 2] = (byte) (value >> 8); + result[i * 2 + 1] = (byte) value; } else { result[i * 2 + 1] = (byte) (value >> 8); - result[i * 2 + 0] = (byte) (value >> 0); + result[i * 2] = (byte) value; } } @@ -387,11 +387,11 @@ protected final byte[] convertShortToByteArray(int value, int byteOrder) if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian { result[0] = (byte) (value >> 8); - result[1] = (byte) (value >> 0); + result[1] = (byte) value; } else { result[1] = (byte) (value >> 8); - result[0] = (byte) (value >> 0); + result[0] = (byte) value; } return result; @@ -457,7 +457,7 @@ protected final int convertByteArrayToShort(String name, int index, throw new ImageReadException("Index out of bounds. Array size: " + bytes.length + ", index: " + index); - int byte0 = 0xff & bytes[index + 0]; + int byte0 = 0xff & bytes[index]; int byte1 = 0xff & bytes[index + 1]; int result; @@ -820,7 +820,7 @@ protected final float convertByteArrayToFloat(String name, byte bytes[], { // TODO: not tested; probably wrong. - byte byte0 = bytes[start + 0]; + byte byte0 = bytes[start]; byte byte1 = bytes[start + 1]; byte byte2 = bytes[start + 2]; byte byte3 = bytes[start + 3]; @@ -904,7 +904,7 @@ protected final byte[] convertFloatArrayToByteArray(float values[], int start = i * 4; if (byteOrder == BYTE_ORDER_INTEL) // intel, little endian { - result[start + 0] = (byte) (0xff & (bits >> 0)); + result[start] = (byte) (0xff & (bits >> 0)); result[start + 1] = (byte) (0xff & (bits >> 8)); result[start + 2] = (byte) (0xff & (bits >> 16)); result[start + 3] = (byte) (0xff & (bits >> 24)); @@ -913,7 +913,7 @@ protected final byte[] convertFloatArrayToByteArray(float values[], result[start + 3] = (byte) (0xff & (bits >> 0)); result[start + 2] = (byte) (0xff & (bits >> 8)); result[start + 1] = (byte) (0xff & (bits >> 16)); - result[start + 0] = (byte) (0xff & (bits >> 24)); + result[start] = (byte) (0xff & (bits >> 24)); } } return result; @@ -962,7 +962,7 @@ protected final byte[] convertDoubleArrayToByteArray(double values[], int start = i * 8; if (byteOrder == BYTE_ORDER_INTEL) // intel, little endian { - result[start + 0] = (byte) (0xff & (bits >> 0)); + result[start] = (byte) (0xff & (bits >> 0)); result[start + 1] = (byte) (0xff & (bits >> 8)); result[start + 2] = (byte) (0xff & (bits >> 16)); result[start + 3] = (byte) (0xff & (bits >> 24)); @@ -979,7 +979,7 @@ protected final byte[] convertDoubleArrayToByteArray(double values[], result[start + 3] = (byte) (0xff & (bits >> 32)); result[start + 2] = (byte) (0xff & (bits >> 40)); result[start + 1] = (byte) (0xff & (bits >> 48)); - result[start + 0] = (byte) (0xff & (bits >> 56)); + result[start] = (byte) (0xff & (bits >> 56)); } } return result; @@ -994,7 +994,7 @@ protected final double convertByteArrayToDouble(String name, byte bytes[], protected final double convertByteArrayToDouble(String name, byte bytes[], int start, int byteOrder) { - byte byte0 = bytes[start + 0]; + byte byte0 = bytes[start]; byte byte1 = bytes[start + 1]; byte byte2 = bytes[start + 2]; byte byte3 = bytes[start + 3]; @@ -1032,7 +1032,7 @@ protected final double convertByteArrayToDouble(String name, byte bytes[], // if (byteOrder == BYTE_ORDER_MOTOROLA) // motorola, big endian // // ?? dunno byte order very likely wrong here. // array = new byte[]{ - // bytes[start + 0], bytes[start + 1], bytes[start + 2], + // bytes[start], bytes[start + 1], bytes[start + 2], // bytes[start + 3], bytes[start + 4], bytes[start + 5], // bytes[start + 6], bytes[start + 7], // @@ -1041,7 +1041,7 @@ protected final double convertByteArrayToDouble(String name, byte bytes[], // // ?? dunno byte order very likely wrong here. // array = new byte[]{ // bytes[start + 3], bytes[start + 2], bytes[start + 1], - // bytes[start + 0], bytes[start + 7], bytes[start + 6], + // bytes[start], bytes[start + 7], bytes[start + 6], // bytes[start + 5], bytes[start + 4], // }; // diff --git a/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java b/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java index b039c9d4..f882a60f 100644 --- a/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java +++ b/src/main/java/org/apache/commons/imaging/common/BinaryInputStream.java @@ -271,7 +271,7 @@ protected final RationalNumber convertByteArrayToRational(String name, protected final RationalNumber convertByteArrayToRational(String name, byte bytes[], int start, int byteOrder) { - int numerator = convertByteArrayToInt(name, bytes, start + 0, 4, + int numerator = convertByteArrayToInt(name, bytes, start, 4, byteOrder); int divisor = convertByteArrayToInt(name, bytes, start + 4, 4, byteOrder); @@ -288,7 +288,7 @@ protected final int convertByteArrayToInt(String name, byte bytes[], protected final int convertByteArrayToInt(String name, byte bytes[], int start, int length, int byteOrder) { - byte byte0 = bytes[start + 0]; + byte byte0 = bytes[start]; byte byte1 = bytes[start + 1]; byte byte2 = bytes[start + 2]; byte byte3 = 0; @@ -350,7 +350,7 @@ protected final int convertByteArrayToShort(String name, byte bytes[], protected final int convertByteArrayToShort(String name, int start, byte bytes[], int byteOrder) { - byte byte0 = bytes[start + 0]; + byte byte0 = bytes[start]; byte byte1 = bytes[start + 1]; // return convert2BytesToShort(name, byte0, byte1, byteOrder); diff --git a/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java b/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java index 6f5dbded..f79215a3 100644 --- a/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java +++ b/src/main/java/org/apache/commons/imaging/common/ImageMetadata.java @@ -51,7 +51,7 @@ public String toString(String prefix) if (null == prefix) prefix = ""; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < items.size(); i++) { if (i > 0) diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpHeaderInfo.java b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpHeaderInfo.java index d5af8a63..e02cd318 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpHeaderInfo.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpHeaderInfo.java @@ -18,12 +18,12 @@ public class BmpHeaderInfo { - // ‘BM’ - Windows 3.1x, 95, NT, … - // ‘BA’ - OS/2 Bitmap Array - // ‘CI’ - OS/2 Color Icon‘ - // CP’ - OS/2 Color Pointer - // ‘IC’ - OS/2 Icon - // ‘PT’ - OS/2 Pointer + // BM - Windows 3.1x, 95, NT, + // BA - OS/2 Bitmap Array + // CI - OS/2 Color Icon + // CP - OS/2 Color Pointer + // IC - OS/2 Icon + // PT - OS/2 Pointer public final byte identifier1; public final byte identifier2; diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java index f44db93e..09bc3293 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/BmpImageParser.java @@ -629,7 +629,7 @@ public ImageInfo getImageInfo(ByteSource byteSource, Map params) int height = bhi.height; int width = bhi.width; - List comments = new ArrayList(); + List comments = new ArrayList<>(); // TODO: comments... int bitsPerPixel = bhi.bitsPerPixel; diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java b/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java index 49a73447..5a78e850 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserBitFields.java @@ -79,7 +79,7 @@ public int getNextRGB() throws ImageReadException, IOException if (bhi.bitsPerPixel == 8) { - data = 0xff & imageData[bytecount + 0]; + data = 0xff & imageData[bytecount]; bytecount += 1; } else if (bhi.bitsPerPixel == 24) diff --git a/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java b/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java index 8f5b97b0..2607299a 100644 --- a/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java +++ b/src/main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/PixelParserRgb.java @@ -65,7 +65,7 @@ public int getNextRGB() throws ImageReadException, IOException return rgb; } else if (bhi.bitsPerPixel == 8) // always grayscale? { - int sample = 0xff & imageData[bytecount + 0]; + int sample = 0xff & imageData[bytecount]; int rgb = getColorTableRGB(sample); @@ -88,7 +88,7 @@ public int getNextRGB() throws ImageReadException, IOException return rgb; } else if (bhi.bitsPerPixel == 24) { - int blue = 0xff & imageData[bytecount + 0]; + int blue = 0xff & imageData[bytecount]; int green = 0xff & imageData[bytecount + 1]; int red = 0xff & imageData[bytecount + 2]; int alpha = 0xff; @@ -100,7 +100,7 @@ public int getNextRGB() throws ImageReadException, IOException return rgb; } else if (bhi.bitsPerPixel == 32) { - int blue = 0xff & imageData[bytecount + 0]; + int blue = 0xff & imageData[bytecount]; int green = 0xff & imageData[bytecount + 1]; int red = 0xff & imageData[bytecount + 2]; int alpha = 0xff; diff --git a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java index d44c6391..a488bd2c 100644 --- a/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/dcx/DcxImageParser.java @@ -148,7 +148,7 @@ private DcxHeader readDcxHeader(ByteSource byteSource) { is = byteSource.getInputStream(); int id = read4Bytes("Id", is, "Not a Valid DCX File"); - List pageTable = new ArrayList(1024); + List pageTable = new ArrayList<>(1024); for (int i = 0; i < 1024; i++) { int pageOffset = read4Bytes("PageTable", is, "Not a Valid DCX File"); @@ -207,7 +207,7 @@ public List getAllBufferedImages(ByteSource byteSource) throws ImageReadException, IOException { DcxHeader dcxHeader = readDcxHeader(byteSource); - List images = new ArrayList(); + List images = new ArrayList<>(); PcxImageParser pcxImageParser = new PcxImageParser(); for (int i = 0; i < dcxHeader.pageTable.length; i++) { diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java index 42e414e5..fbb1af8b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegConstants.java @@ -16,24 +16,20 @@ */ package org.apache.commons.imaging.formats.jpeg; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.common.BinaryConstant; public interface JpegConstants { - public static final int MAX_SEGMENT_SIZE = 0xffff; + int MAX_SEGMENT_SIZE = 0xffff; - public static final BinaryConstant JFIF0_SIGNATURE = new BinaryConstant(new byte[] { + BinaryConstant JFIF0_SIGNATURE = new BinaryConstant(new byte[] { 0x4a, // J 0x46, // F 0x49, // I 0x46, // F 0x0, // }); - public static final BinaryConstant JFIF0_SIGNATURE_ALTERNATIVE = new BinaryConstant(new byte[] { + BinaryConstant JFIF0_SIGNATURE_ALTERNATIVE = new BinaryConstant(new byte[] { 0x4a, // J 0x46, // F 0x49, // I @@ -41,14 +37,14 @@ public interface JpegConstants 0x20, // }); - public static final BinaryConstant EXIF_IDENTIFIER_CODE = new BinaryConstant(new byte[] { + BinaryConstant EXIF_IDENTIFIER_CODE = new BinaryConstant(new byte[] { 0x45, // E 0x78, // x 0x69, // i 0x66, // f }); - public static final BinaryConstant XMP_IDENTIFIER = new BinaryConstant(new byte[] { + BinaryConstant XMP_IDENTIFIER = new BinaryConstant(new byte[] { 0x68, // h 0x74, // t 0x74, // t @@ -80,57 +76,48 @@ public interface JpegConstants 0, // 0-terminated us-ascii string. }); - public static final BinaryConstant SOI = new BinaryConstant(new byte[] { (byte) 0xff, (byte) 0xd8 }); - public static final BinaryConstant EOI = new BinaryConstant(new byte[] { (byte) 0xff, (byte) 0xd9 }); - - public static final int JPEG_APP0 = 0xE0; - public static final int JPEG_APP0_Marker = (0xff00) | (JPEG_APP0); - public static final int JPEG_APP1_Marker = (0xff00) | (JPEG_APP0 + 1); - public static final int JPEG_APP2_Marker = (0xff00) | (JPEG_APP0 + 2); - public static final int JPEG_APP13_Marker = (0xff00) | (JPEG_APP0 + 13); - public static final int JPEG_APP14_Marker = (0xff00) | (JPEG_APP0 + 14); - public static final int JPEG_APP15_Marker = (0xff00) | (JPEG_APP0 + 15); + BinaryConstant SOI = new BinaryConstant(new byte[] { (byte) 0xff, (byte) 0xd8 }); + BinaryConstant EOI = new BinaryConstant(new byte[] { (byte) 0xff, (byte) 0xd9 }); - public static final int JFIFMarker = 0xFFE0; - public static final int SOF0Marker = 0xFFc0; - public static final int SOF1Marker = 0xFFc0 + 0x1; - public static final int SOF2Marker = 0xFFc0 + 0x2; - public static final int SOF3Marker = 0xFFc0 + 0x3; - public static final int DHTMarker = 0xFFc0 + 0x4; - public static final int SOF5Marker = 0xFFc0 + 0x5; - public static final int SOF6Marker = 0xFFc0 + 0x6; - public static final int SOF7Marker = 0xFFc0 + 0x7; - public static final int SOF8Marker = 0xFFc0 + 0x8; - public static final int SOF9Marker = 0xFFc0 + 0x9; - public static final int SOF10Marker = 0xFFc0 + 0xa; - public static final int SOF11Marker = 0xFFc0 + 0xb; - public static final int DACMarker = 0xFFc0 + 0xc; - public static final int SOF13Marker = 0xFFc0 + 0xd; - public static final int SOF14Marker = 0xFFc0 + 0xe; - public static final int SOF15Marker = 0xFFc0 + 0xf; + int JPEG_APP0 = 0xE0; + int JPEG_APP0_Marker = (0xff00) | (JPEG_APP0); + int JPEG_APP1_Marker = (0xff00) | (JPEG_APP0 + 1); + int JPEG_APP2_Marker = (0xff00) | (JPEG_APP0 + 2); + int JPEG_APP13_Marker = (0xff00) | (JPEG_APP0 + 13); + int JPEG_APP14_Marker = (0xff00) | (JPEG_APP0 + 14); + int JPEG_APP15_Marker = (0xff00) | (JPEG_APP0 + 15); - public static final int EOIMarker = 0xFFd9; - public static final int SOS_Marker = 0xFFda; - public static final int DQTMarker = 0xFFdb; - public static final int DNLMarker = 0xFFdc; - public static final int COMMarker = 0xFFfe; + int JFIFMarker = 0xFFE0; + int SOF0Marker = 0xFFc0; + int SOF1Marker = 0xFFc0 + 0x1; + int SOF2Marker = 0xFFc0 + 0x2; + int SOF3Marker = 0xFFc0 + 0x3; + int DHTMarker = 0xFFc0 + 0x4; + int SOF5Marker = 0xFFc0 + 0x5; + int SOF6Marker = 0xFFc0 + 0x6; + int SOF7Marker = 0xFFc0 + 0x7; + int SOF8Marker = 0xFFc0 + 0x8; + int SOF9Marker = 0xFFc0 + 0x9; + int SOF10Marker = 0xFFc0 + 0xa; + int SOF11Marker = 0xFFc0 + 0xb; + int DACMarker = 0xFFc0 + 0xc; + int SOF13Marker = 0xFFc0 + 0xd; + int SOF14Marker = 0xFFc0 + 0xe; + int SOF15Marker = 0xFFc0 + 0xf; - public static final List MARKERS = Collections.unmodifiableList(Arrays.asList( - JPEG_APP0, JPEG_APP0_Marker, JPEG_APP1_Marker, JPEG_APP2_Marker, - JPEG_APP13_Marker, JPEG_APP14_Marker, JPEG_APP15_Marker, - JFIFMarker, SOF0Marker, SOF1Marker, SOF2Marker, SOF3Marker, - DHTMarker, SOF5Marker, SOF6Marker, SOF7Marker, SOF8Marker, - SOF9Marker, SOF10Marker, SOF11Marker, DACMarker, SOF13Marker, - SOF14Marker, SOF15Marker, EOIMarker, SOS_Marker, - DQTMarker, DNLMarker, COMMarker )); + int EOIMarker = 0xFFd9; + int SOS_Marker = 0xFFda; + int DQTMarker = 0xFFdb; + int DNLMarker = 0xFFdc; + int COMMarker = 0xFFfe; - public static final BinaryConstant icc_profile_label = new BinaryConstant(new byte[] { + BinaryConstant icc_profile_label = new BinaryConstant(new byte[] { 0x49, 0x43, 0x43, 0x5F, 0x50, 0x52, 0x4F, 0x46, 0x49, 0x4C, 0x45, 0x0 }); - public static final BinaryConstant PHOTOSHOP_IDENTIFICATION_STRING = new BinaryConstant(new byte[] { + BinaryConstant PHOTOSHOP_IDENTIFICATION_STRING = new BinaryConstant(new byte[] { 0x50, // P 0x68, // h 0x6F, // o @@ -146,7 +133,7 @@ public interface JpegConstants 0x30, // 0 0, }); - public static final BinaryConstant CONST_8BIM = new BinaryConstant(new byte[] { + BinaryConstant CONST_8BIM = new BinaryConstant(new byte[] { 0x38, // 8 0x42, // B 0x49, // I diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java index a6770f8f..d0b0cb3f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegImageMetadata.java @@ -187,7 +187,7 @@ public String toString(String prefix) { if (prefix == null) prefix = ""; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(prefix); if (null == exif) diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java index 34a90fca..70aa4ac8 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/JpegPhotoshopMetadata.java @@ -27,27 +27,25 @@ import org.apache.commons.imaging.util.Debug; public class JpegPhotoshopMetadata extends ImageMetadata implements - IptcConstants -{ + IptcConstants { public final PhotoshopApp13Data photoshopApp13Data; - public JpegPhotoshopMetadata(final PhotoshopApp13Data photoshopApp13Data) - { + public JpegPhotoshopMetadata(final PhotoshopApp13Data photoshopApp13Data) { this.photoshopApp13Data = photoshopApp13Data; List records = photoshopApp13Data.getRecords(); - Collections.sort(records, IptcRecord.COMPARATOR); - for (int j = 0; j < records.size(); j++) - { + records.sort(IptcRecord.COMPARATOR); + + for (int j = 0; j < records.size(); j++) { IptcRecord element = records.get(j); - if (element.iptcType != IptcTypes.RECORD_VERSION) + if (element.iptcType != IptcTypes.RECORD_VERSION) { add(element.getIptcTypeName(), element.getValue()); + } } } - public void dump() - { + public void dump() { Debug.debug(this.toString()); } diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java index 35e20314..579c8c90 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/decoder/Dct.java @@ -42,7 +42,7 @@ public class Dct * * Benchmarks, Intel Core i3 @ 2.93 GHz in long mode, 4 GB RAM * Time taken to do 100 million IDCTs (less is better): - * Rene' Stöckel's Feig, int: 45.07 seconds + * Rene' Stockel's Feig, int: 45.07 seconds * My Feig, floating point: 36.252 seconds * AA&N, unrolled loops, double[][] -> double[][]: 25.167 seconds * diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java index 27b0921c..919f7b8e 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/exif/ExifRewriter.java @@ -45,7 +45,7 @@ *

* See the source of the ExifMetadataUpdateExample class for example usage. * - * @see org.apache.commons.sanselan.examples.WriteExifMetadataExample + * @see org.apache.commons.imaging.examples.WriteExifMetadataExample */ public class ExifRewriter extends BinaryFileParser implements JpegConstants { @@ -62,7 +62,7 @@ public ExifRewriter() *

* @param byteOrder byte order of EXIF segment. Optional. See BinaryConstants class. * - * @see org.apache.commons.sanselan.common.BinaryConstants + * @see org.apache.commons.imaging.common.BinaryConstants */ public ExifRewriter(int byteOrder) { diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java index f59b5086..a69321ae 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcParser.java @@ -403,15 +403,10 @@ public byte[] writeIPTCBlock(List elements) throws ImageWriteExcepti bos.write2Bytes(2); // record version value // make a copy of the list. - elements = new ArrayList(elements); + elements = new ArrayList<>(elements); // sort the list. Records must be in numerical order. - Comparator comparator = new Comparator() { - public int compare(IptcRecord e1, IptcRecord e2) - { - return e2.iptcType.getType() - e1.iptcType.getType(); - } - }; + Comparator comparator = (e1, e2) -> e2.iptcType.getType() - e1.iptcType.getType(); Collections.sort(elements, comparator); // TODO: make sure order right diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java index fb788ea9..87e73928 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcRecord.java @@ -62,11 +62,6 @@ public String getIptcTypeName() return iptcType.getName(); } - public static final Comparator COMPARATOR = new Comparator() { - public int compare(IptcRecord e1, IptcRecord e2) - { - return e1.iptcType.getType() - e2.iptcType.getType(); - } - }; + public static final Comparator COMPARATOR = (e1, e2) -> e1.iptcType.getType() - e2.iptcType.getType(); } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java index ddc17235..cecafbcc 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DhtSegment.java @@ -23,7 +23,7 @@ public class DhtSegment extends Segment { - public final List huffmanTables = new ArrayList(); + public final List huffmanTables = new ArrayList<>(); public static class HuffmanTable { diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java index e9b6896b..ec56b4d1 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/segments/DqtSegment.java @@ -25,7 +25,7 @@ public class DqtSegment extends Segment { - public final List quantizationTables = new ArrayList(); + public final List quantizationTables = new ArrayList<>(); public static class QuantizationTable { 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 6d3fd004..2d2c43ab 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 @@ -37,60 +37,51 @@ * * @see org.apache.commons.sanselan.examples.WriteXmpXmlExample */ -public class JpegRewriter extends BinaryFileParser implements JpegConstants -{ +public class JpegRewriter extends BinaryFileParser implements JpegConstants { private static final int JPEG_BYTE_ORDER = BYTE_ORDER_NETWORK; /** * Constructor. to guess whether a file contains an image based on its file * extension. */ - public JpegRewriter() - { + public JpegRewriter() { setByteOrder(JPEG_BYTE_ORDER); } - protected static class JFIFPieces - { + protected static class JFIFPieces { public final List pieces; public final List segmentPieces; - public JFIFPieces(final List pieces, final List segmentPieces) - { + public JFIFPieces(final List pieces, final List segmentPieces) { this.pieces = pieces; this.segmentPieces = segmentPieces; } } - protected abstract static class JFIFPiece - { + protected abstract static class JFIFPiece { protected abstract void write(OutputStream os) throws IOException; @Override - public String toString() - { + public String toString() { return "[" + this.getClass().getName() + "]"; } } - protected static class JFIFPieceSegment extends JFIFPiece - { + protected static class JFIFPieceSegment extends JFIFPiece { public final int marker; public final byte markerBytes[]; public final byte segmentLengthBytes[]; public final byte segmentData[]; - public JFIFPieceSegment(final int marker, final byte[] segmentData) - { + public JFIFPieceSegment(final int marker, final byte[] segmentData) { this(marker, int2ToByteArray(marker, JPEG_BYTE_ORDER), int2ToByteArray(segmentData.length + 2, JPEG_BYTE_ORDER), segmentData); } public JFIFPieceSegment(final int marker, final byte[] markerBytes, - final byte[] segmentLengthBytes, final byte[] segmentData) - { + final byte[] segmentLengthBytes, final byte[] segmentData) { this.marker = marker; this.markerBytes = markerBytes; this.segmentLengthBytes = segmentLengthBytes; @@ -98,31 +89,26 @@ public JFIFPieceSegment(final int marker, final byte[] markerBytes, } @Override - public String toString() - { + public String toString() { return "[" + this.getClass().getName() + " (0x" + Integer.toHexString(marker) + ")]"; } @Override - protected void write(OutputStream os) throws IOException - { + protected void write(OutputStream os) throws IOException { os.write(markerBytes); os.write(segmentLengthBytes); os.write(segmentData); } - public boolean isApp1Segment() - { + public boolean isApp1Segment() { return marker == JPEG_APP1_Marker; } - public boolean isAppSegment() - { + public boolean isAppSegment() { return marker >= JPEG_APP0_Marker && marker <= JPEG_APP15_Marker; } - public boolean isExifSegment() - { + public boolean isExifSegment() { if (marker != JPEG_APP1_Marker) return false; if (!byteArrayHasPrefix(segmentData, EXIF_IDENTIFIER_CODE)) @@ -130,8 +116,7 @@ public boolean isExifSegment() return true; } - public boolean isPhotoshopApp13Segment() - { + public boolean isPhotoshopApp13Segment() { if (marker != JPEG_APP13_Marker) return false; if (!new IptcParser().isPhotoshopJpegSegment(segmentData)) @@ -139,8 +124,7 @@ public boolean isPhotoshopApp13Segment() return true; } - public boolean isXmpSegment() - { + public boolean isXmpSegment() { if (marker != JPEG_APP1_Marker) return false; if (!byteArrayHasPrefix(segmentData, XMP_IDENTIFIER)) @@ -150,22 +134,19 @@ public boolean isXmpSegment() } - protected static class JFIFPieceImageData extends JFIFPiece - { + protected static class JFIFPieceImageData extends JFIFPiece { public final byte markerBytes[]; public final byte imageData[]; public JFIFPieceImageData(final byte[] markerBytes, - final byte[] imageData) - { + final byte[] imageData) { super(); this.markerBytes = markerBytes; this.imageData = imageData; } @Override - protected void write(OutputStream os) throws IOException - { + protected void write(OutputStream os) throws IOException { os.write(markerBytes); os.write(imageData); } @@ -180,22 +161,19 @@ protected JFIFPieces analyzeJFIF(ByteSource byteSource) JpegUtils.Visitor visitor = new JpegUtils.Visitor() { // return false to exit before reading image data. - public boolean beginSOS() - { + public boolean beginSOS() { return true; } public void visitSOS(int marker, byte markerBytes[], - byte imageData[]) - { + byte imageData[]) { pieces.add(new JFIFPieceImageData(markerBytes, imageData)); } // return false to exit traversal. public boolean visitSegment(int marker, byte markerBytes[], - int segmentLength, byte segmentLengthBytes[], - byte segmentData[]) throws ImageReadException, IOException - { + int segmentLength, byte segmentLengthBytes[], + byte segmentData[]) throws ImageReadException, IOException { JFIFPiece piece = new JFIFPieceSegment(marker, markerBytes, segmentLengthBytes, segmentData); pieces.add(piece); @@ -210,72 +188,48 @@ public boolean visitSegment(int marker, byte markerBytes[], return new JFIFPieces(pieces, segmentPieces); } - private static interface SegmentFilter - { + private static interface SegmentFilter { public boolean filter(JFIFPieceSegment segment); } - private static final SegmentFilter EXIF_SEGMENT_FILTER = new SegmentFilter() { - public boolean filter(JFIFPieceSegment segment) - { - return segment.isExifSegment(); - } - }; + private static final SegmentFilter EXIF_SEGMENT_FILTER = JFIFPieceSegment::isExifSegment; - private static final SegmentFilter XMP_SEGMENT_FILTER = new SegmentFilter() { - public boolean filter(JFIFPieceSegment segment) - { - return segment.isXmpSegment(); - } - }; + private static final SegmentFilter XMP_SEGMENT_FILTER = JFIFPieceSegment::isXmpSegment; - private static final SegmentFilter PHOTOSHOP_APP13_SEGMENT_FILTER = new SegmentFilter() { - public boolean filter(JFIFPieceSegment segment) - { - return segment.isPhotoshopApp13Segment(); - } - }; + private static final SegmentFilter PHOTOSHOP_APP13_SEGMENT_FILTER = JFIFPieceSegment::isPhotoshopApp13Segment; - protected List removeXmpSegments(List segments) - { + protected List removeXmpSegments(List segments) { return filterSegments(segments, XMP_SEGMENT_FILTER); } - protected List removePhotoshopApp13Segments(List segments) - { + protected List removePhotoshopApp13Segments(List segments) { return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER); } - protected List findPhotoshopApp13Segments(List segments) - { + protected List findPhotoshopApp13Segments(List segments) { return filterSegments(segments, PHOTOSHOP_APP13_SEGMENT_FILTER, true); } - protected List removeExifSegments(List segments) - { + protected List removeExifSegments(List segments) { return filterSegments(segments, EXIF_SEGMENT_FILTER); } - protected List filterSegments(List segments, SegmentFilter filter) - { + protected List filterSegments(List segments, SegmentFilter filter) { return filterSegments(segments, filter, false); } protected List filterSegments( List segments, SegmentFilter filter, - boolean reverse) - { + boolean reverse) { List result = new ArrayList(); - for (int i = 0; i < segments.size(); i++) - { + for (int i = 0; i < segments.size(); i++) { T piece = segments.get(i); - if (piece instanceof JFIFPieceSegment) - { + if (piece instanceof JFIFPieceSegment) { if (filter.filter((JFIFPieceSegment) piece) ^ !reverse) result.add(piece); - } else if(!reverse) + } else if (!reverse) result.add(piece); } @@ -285,113 +239,72 @@ protected List filterSegments( protected List insertBeforeFirstAppSegments( List segments, List newSegments) - throws ImageWriteException - { + throws ImageWriteException { int firstAppIndex = -1; - for (int i = 0; i < segments.size(); i++) - { + for (int i = 0; i < segments.size(); i++) { JFIFPiece piece = segments.get(i); if (!(piece instanceof JFIFPieceSegment)) continue; JFIFPieceSegment segment = (JFIFPieceSegment) piece; - if (segment.isAppSegment()) - { + if (segment.isAppSegment()) { if (firstAppIndex == -1) firstAppIndex = i; } } - List result = new ArrayList(segments); + List result = new ArrayList<>(segments); if (firstAppIndex == -1) throw new ImageWriteException("JPEG file has no APP segments."); result.addAll(firstAppIndex, newSegments); return result; } - protected List insertAfterLastAppSegments( - List segments, - List newSegments) - throws ImageWriteException - { + protected List insertAfterLastAppSegments(List segments, List newSegments) throws ImageWriteException { int lastAppIndex = -1; - for (int i = 0; i < segments.size(); i++) - { + for (int i = 0; i < segments.size(); i++) { JFIFPiece piece = segments.get(i); - if (!(piece instanceof JFIFPieceSegment)) + if (!(piece instanceof JFIFPieceSegment)) { continue; + } JFIFPieceSegment segment = (JFIFPieceSegment) piece; - if (segment.isAppSegment()) + if (segment.isAppSegment()) { lastAppIndex = i; + } } - List result = new ArrayList(segments); - if (lastAppIndex == -1) - { - if(segments.size()<1) + List result = new ArrayList<>(segments); + if (lastAppIndex == -1) { + if (segments.size() < 1) { throw new ImageWriteException("JPEG file has no APP segments."); + } result.addAll(1, newSegments); - } - else + } else { result.addAll(lastAppIndex + 1, newSegments); + } return result; } - protected void writeSegments( - OutputStream os, - List segments) - throws IOException - { - try - { + protected void writeSegments(OutputStream os, List segments) + throws IOException { + try { SOI.writeTo(os); - for (int i = 0; i < segments.size(); i++) - { + for (int i = 0; i < segments.size(); i++) { JFIFPiece piece = segments.get(i); piece.write(os); } os.close(); os = null; - } finally - { - try - { + } finally { + try { if (os != null) os.close(); - } catch (Exception e) - { + } catch (Exception e) { // swallow exception; already in the context of an exception. } } } - - // private void writeSegment(OutputStream os, JFIFPieceSegment piece) - // throws ImageWriteException, IOException - // { - // byte markerBytes[] = convertShortToByteArray(JPEG_APP1_Marker, - // JPEG_BYTE_ORDER); - // if (piece.segmentData.length > 0xffff) - // throw new JpegSegmentOverflowException("Jpeg segment is too long: " - // + piece.segmentData.length); - // int segmentLength = piece.segmentData.length + 2; - // byte segmentLengthBytes[] = convertShortToByteArray(segmentLength, - // JPEG_BYTE_ORDER); - // - // os.write(markerBytes); - // os.write(segmentLengthBytes); - // os.write(piece.segmentData); - // } - - public static class JpegSegmentOverflowException extends - ImageWriteException - { - public JpegSegmentOverflowException(String s) - { - super(s); - } - } - } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java index 007ca307..d2e359f3 100644 --- a/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java +++ b/src/main/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpRewriter.java @@ -37,7 +37,7 @@ *

* See the source of the XmpXmlUpdateExample class for example usage. * - * @see org.apache.commons.sanselan.examples.WriteXmpXmlExample + * @see org.apache.commons.imaging.examples.WriteXmpXmlExample */ public class JpegXmpRewriter extends JpegRewriter { 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 08067b48..70bc90b9 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 @@ -102,11 +102,11 @@ protected ImageFormat[] getAcceptedTypes() // private final static int tRNS = CharsToQuad('t', 'R', 'N', 's'); public static final String getChunkTypeName(int chunkType) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append((char) (0xff & (chunkType >> 24))); result.append((char) (0xff & (chunkType >> 16))); result.append((char) (0xff & (chunkType >> 8))); - result.append((char) (0xff & (chunkType >> 0))); + result.append((char) (0xff & chunkType)); return result.toString(); } 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 6c79ac4a..46c0ffa7 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 @@ -362,7 +362,7 @@ private byte getBitDepth(final byte colorType, Map params) } /* - * between two chunk types indicates alternatives. Table 5.3 — Chunk + * between two chunk types indicates alternatives. Table 5.3 Chunk * ordering rules Critical chunks (shall appear in this order, except PLTE * is optional) Chunk name Multiple allowed Ordering constraints IHDR No * Shall be first PLTE No Before first IDAT IDAT Yes Multiple IDAT chunks diff --git a/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java b/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java index 1d67ac3d..477addde 100644 --- a/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/pnm/WhiteSpaceReader.java @@ -59,7 +59,7 @@ public String readtoWhiteSpace() throws IOException while (Character.isWhitespace(c)) c = nextChar(); - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); while (!Character.isWhitespace(c)) { diff --git a/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java b/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java index f8777196..c18e3085 100644 --- a/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/psd/PsdConstants.java @@ -152,7 +152,7 @@ public String getDescription(int id) new ImageResourceType( 0x0414, 1044, - "Document specific IDs, layer IDs will be generated starting at this base value or a greater value if we find existing IDs to already exceed it. It’s purpose is to avoid the case where we add layers, flatten, save, open, and then add more layers that end up with the same IDs as the first set. 4 bytes."), + "Document specific IDs, layer IDs will be generated starting at this base value or a greater value if we find existing IDs to already exceed it. It's purpose is to avoid the case where we add layers, flatten, save, open, and then add more layers that end up with the same IDs as the first set. 4 bytes."), new ImageResourceType(0x0415, 1045, "Unicode Alpha Names. 4 bytes for length and the string as a unicode string."), new ImageResourceType( @@ -170,7 +170,7 @@ public String getDescription(int id) new ImageResourceType( 0x041C, 1052, - "Jump To XPEP. 2 bytes major version, 2 bytes minor version, 4 bytes count. Following is repeated for count: 4 bytes block size, 4 bytes key, if key = 'jtDd' then next is a Boolean for the dirty flag otherwise it’s a 4 byte entry for the mod date."), + "Jump To XPEP. 2 bytes major version, 2 bytes minor version, 4 bytes count. Following is repeated for count: 4 bytes block size, 4 bytes key, if key = 'jtDd' then next is a Boolean for the dirty flag otherwise it's a 4 byte entry for the mod date."), new ImageResourceType( 0x041D, 1053, diff --git a/src/main/java/org/apache/commons/imaging/formats/rgbe/InfoHeaderReader.java b/src/main/java/org/apache/commons/imaging/formats/rgbe/InfoHeaderReader.java index 929f90b5..bb616eb4 100644 --- a/src/main/java/org/apache/commons/imaging/formats/rgbe/InfoHeaderReader.java +++ b/src/main/java/org/apache/commons/imaging/formats/rgbe/InfoHeaderReader.java @@ -35,7 +35,7 @@ private char read() throws IOException { } public String readLine() throws IOException { - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); char c; while ( ( c = read() ) != '\n' ) { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java index 4f8a75a4..0065025b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffContents.java @@ -24,32 +24,27 @@ import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.util.Debug; -public class TiffContents -{ +public class TiffContents { public final TiffHeader header; public final List directories; - public TiffContents(TiffHeader tiffHeader, List directories) - { + public TiffContents(TiffHeader tiffHeader, List directories) { this.header = tiffHeader; this.directories = directories; } - public List getElements() throws ImageReadException - { + public List getElements() throws ImageReadException { List result = new ArrayList(); result.add(header); - for (int i = 0; i < directories.size(); i++) - { + for (int i = 0; i < directories.size(); i++) { TiffDirectory directory = directories.get(i); result.add(directory); List fields = directory.entries; - for (int j = 0; j < fields.size(); j++) - { + for (int j = 0; j < fields.size(); j++) { TiffField field = fields.get(j); TiffElement oversizeValue = field.getOversizeValueElement(); if (null != oversizeValue) @@ -65,10 +60,8 @@ public List getElements() throws ImageReadException return result; } - public TiffField findField(TagInfo tag) throws ImageReadException - { - for (int i = 0; i < directories.size(); i++) - { + public TiffField findField(TagInfo tag) throws ImageReadException { + for (int i = 0; i < directories.size(); i++) { TiffDirectory directory = directories.get(i); TiffField field = directory.findField(tag); @@ -79,17 +72,12 @@ public TiffField findField(TagInfo tag) throws ImageReadException return null; } - public void dissect(boolean verbose) throws ImageReadException - { + public void dissect(boolean verbose) throws ImageReadException { List elements = getElements(); - - Collections.sort(elements, TiffElement.COMPARATOR); + elements.sort(TiffElement.COMPARATOR); int lastEnd = 0; - for (int i = 0; i < elements.size(); i++) - { - TiffElement element = elements.get(i); - + for (TiffElement element : elements) { if (element.offset > lastEnd) Debug.debug("\t" + "gap: " + (element.offset - lastEnd)); if (element.offset < lastEnd) @@ -99,8 +87,7 @@ public void dissect(boolean verbose) throws ImageReadException + element.length + ", end: " + (element.offset + element.length) + ": " + element.getElementDescription(false)); - if (verbose) - { + if (verbose) { String verbosity = element.getElementDescription(true); if (null != verbosity) Debug.debug(verbosity); 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 cfa1af16..a0653984 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 @@ -58,7 +58,7 @@ public String getElementDescription(boolean verbose) int entryOffset = offset + TIFF_DIRECTORY_HEADER_LENGTH; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); for (int i = 0; i < entries.size(); i++) { TiffField entry = entries.get(i); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java index c9b81381..491b6b88 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffElement.java @@ -36,13 +36,7 @@ public String getElementDescription() public abstract String getElementDescription(boolean verbose); - public static final Comparator COMPARATOR = new Comparator() - { - public int compare(TiffElement e1, TiffElement e2) - { - return e1.offset - e2.offset; - } - }; + public static final Comparator COMPARATOR = Comparator.comparingInt(e -> e.offset); public static abstract class DataElement extends TiffElement { diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java index e8aa2955..8be102af 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffField.java @@ -36,8 +36,7 @@ import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -public class TiffField implements TiffConstants -{ +public class TiffField implements TiffConstants { public final TagInfo tagInfo; public final FieldType fieldType; @@ -52,8 +51,7 @@ public class TiffField implements TiffConstants public final int byteOrder; public TiffField(int tag, int directoryType, int type, int Length, - int ValueOffset, byte ValueOffsetBytes[], int byteOrder) - { + int ValueOffset, byte ValueOffsetBytes[], int byteOrder) { this.tag = tag; this.directoryType = directoryType; @@ -69,26 +67,21 @@ public TiffField(int tag, int directoryType, int type, int Length, private int sortHint = -1; - public boolean isLocalValue() - { + public boolean isLocalValue() { return fieldType.isLocalValue(this); } - public int getBytesLength() throws ImageReadException - { + public int getBytesLength() throws ImageReadException { return fieldType.getBytesLength(this); } - public final class OversizeValueElement extends TiffElement - { - public OversizeValueElement(int offset, int length) - { + public final class OversizeValueElement extends TiffElement { + public OversizeValueElement(int offset, int length) { super(offset, length); } @Override - public String getElementDescription(boolean verbose) - { + public String getElementDescription(boolean verbose) { if (verbose) return null; @@ -97,23 +90,19 @@ public String getElementDescription(boolean verbose) } } - public TiffElement getOversizeValueElement() - { + public TiffElement getOversizeValueElement() { if (fieldType.isLocalValue(this)) return null; return new OversizeValueElement(valueOffset, oversizeValue.length); } - public void setOversizeValue(byte bytes[]) - { + public void setOversizeValue(byte bytes[]) { this.oversizeValue = bytes; } - private static FieldType getFieldType(int value) - { - for (int i = 0; i < FIELD_TYPES.size(); i++) - { + private static FieldType getFieldType(int value) { + for (int i = 0; i < FIELD_TYPES.size(); i++) { FieldType fieldType = FIELD_TYPES.get(i); if (fieldType.type == value) return fieldType; @@ -123,8 +112,7 @@ private static FieldType getFieldType(int value) } private static TagInfo getTag(int directoryType, int tag, - List possibleMatches) - { + List possibleMatches) { // Please keep this method in sync with TiffImageMetadata's findField() if (possibleMatches.size() < 1) @@ -136,8 +124,7 @@ private static TagInfo getTag(int directoryType, int tag, // } // first search for exact match. - for (int i = 0; i < possibleMatches.size(); i++) - { + for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) // pass @@ -147,8 +134,7 @@ else if (directoryType == tagInfo.directoryType.directoryType) } // accept an inexact match. - for (int i = 0; i < possibleMatches.size(); i++) - { + for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) @@ -163,8 +149,7 @@ else if (directoryType < 0 } // accept a wildcard match. - for (int i = 0; i < possibleMatches.size(); i++) - { + for (int i = 0; i < possibleMatches.size(); i++) { TagInfo tagInfo = possibleMatches.get(i); if (tagInfo.directoryType == TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN) @@ -252,12 +237,10 @@ else if (directoryType < 0 // return TIFF_TAG_UNKNOWN; } - private static TagInfo getTag(int directoryType, int tag) - { + private static TagInfo getTag(int directoryType, int tag) { List possibleMatches = ALL_TAG_MAP.get(tag); - if (null == possibleMatches) - { + if (null == possibleMatches) { return TiffTagConstants.TIFF_TAG_UNKNOWN; } @@ -265,8 +248,7 @@ private static TagInfo getTag(int directoryType, int tag) return result; } - private int getValueLengthInBytes() - { + private int getValueLengthInBytes() { int unit_length = fieldType.length; int valueLength = unit_length * length; @@ -276,8 +258,7 @@ private int getValueLengthInBytes() return valueLength; } - public void fillInValue(ByteSource byteSource) throws IOException, TiffValueOutsideFileBoundsException - { + public void fillInValue(ByteSource byteSource) throws IOException, TiffValueOutsideFileBoundsException { if (fieldType.isLocalValue(this)) return; @@ -290,53 +271,43 @@ public void fillInValue(ByteSource byteSource) throws IOException, TiffValueOuts // Debug.debug("fillInValue valueLength", valueLength); if (valueOffset < 0 || - valueOffset + valueLengthLong > byteSource.getLength()) { + valueOffset + valueLengthLong > byteSource.getLength()) { throw new TiffValueOutsideFileBoundsException( - "Attempt to read byte range starting from " + valueOffset + " " + - "of length " + valueLength + " " + - "which is outside the file's size of " + byteSource.getLength()); + "Attempt to read byte range starting from " + valueOffset + " " + + "of length " + valueLength + " " + + "which is outside the file's size of " + byteSource.getLength()); } byte bytes[] = byteSource.getBlock(valueOffset, valueLength); setOversizeValue(bytes); } - public String getValueDescription() - { - try - { + public String getValueDescription() { + try { return getValueDescription(getValue()); - } catch (ImageReadException e) - { + } catch (ImageReadException e) { return "Invalid value: " + e.getMessage(); } } - private String getValueDescription(Object o) - { + private String getValueDescription(Object o) { if (o == null) return null; - if (o instanceof Number) - { + if (o instanceof Number) { return o.toString(); - } else if (o instanceof String) - { + } else if (o instanceof String) { return "'" + o.toString().trim() + "'"; - } else if (o instanceof Date) - { + } else if (o instanceof Date) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ"); return df.format((Date) o); - } else if (o instanceof Object[]) - { + } else if (o instanceof Object[]) { Object objects[] = (Object[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < objects.length; i++) - { + for (int i = 0; i < objects.length; i++) { Object object = objects[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + objects.length + ")"); break; } @@ -349,7 +320,7 @@ private String getValueDescription(Object o) // else if (o instanceof Number[]) // { // Number numbers[] = (Number[]) o; - // StringBuffer result = new StringBuffer(); + // StringBuilder result = new StringBuilder(); // // for (int i = 0; i < numbers.length; i++) // { @@ -361,17 +332,14 @@ private String getValueDescription(Object o) // } // return result.toString(); // } - else if (o instanceof short[]) - { + else if (o instanceof short[]) { short values[] = (short[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { short value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -380,18 +348,14 @@ else if (o instanceof short[]) result.append("" + value); } return result.toString(); - } - else if (o instanceof int[]) - { + } else if (o instanceof int[]) { int values[] = (int[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { int value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -400,17 +364,14 @@ else if (o instanceof int[]) result.append("" + value); } return result.toString(); - } else if (o instanceof long[]) - { + } else if (o instanceof long[]) { long values[] = (long[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { long value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -419,17 +380,14 @@ else if (o instanceof int[]) result.append("" + value); } return result.toString(); - } else if (o instanceof double[]) - { + } else if (o instanceof double[]) { double values[] = (double[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { double value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -438,17 +396,14 @@ else if (o instanceof int[]) result.append("" + value); } return result.toString(); - } else if (o instanceof byte[]) - { + } else if (o instanceof byte[]) { byte values[] = (byte[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { byte value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -457,17 +412,14 @@ else if (o instanceof int[]) result.append("" + value); } return result.toString(); - } else if (o instanceof char[]) - { + } else if (o instanceof char[]) { char values[] = (char[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { char value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -476,17 +428,14 @@ else if (o instanceof int[]) result.append("" + value); } return result.toString(); - } else if (o instanceof float[]) - { + } else if (o instanceof float[]) { float values[] = (float[]) o; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); - for (int i = 0; i < values.length; i++) - { + for (int i = 0; i < values.length; i++) { float value = values[i]; - if (i > 50) - { + if (i > 50) { result.append("... (" + values.length + ")"); break; } @@ -499,7 +448,7 @@ else if (o instanceof int[]) // else if (o instanceof short[]) // { // short numbers[] = (short[]) o; - // StringBuffer result = new StringBuffer(); + // StringBuilder result = new StringBuilder(); // // for (int i = 0; i < numbers.length; i++) // { @@ -515,20 +464,17 @@ else if (o instanceof int[]) return "Unknown: " + o.getClass().getName(); } - public void dump() - { + public void dump() { PrintWriter pw = new PrintWriter(System.out); dump(pw); pw.flush(); } - public void dump(PrintWriter pw) - { + public void dump(PrintWriter pw) { dump(pw, null); } - public void dump(PrintWriter pw, String prefix) - { + public void dump(PrintWriter pw, String prefix) { if (prefix != null) pw.print(prefix + ": "); @@ -549,16 +495,14 @@ public void dump(PrintWriter pw, String prefix) // Debug.debug("byteOrder", byteOrder); // } - public String getDescriptionWithoutValue() - { + public String getDescriptionWithoutValue() { return tag + " (0x" + Integer.toHexString(tag) + ": " + tagInfo.name + "): "; } @Override - public String toString() - { - StringBuffer result = new StringBuffer(); + public String toString() { + StringBuilder result = new StringBuilder(); result.append(tag + " (0x" + Integer.toHexString(tag) + ": " + tagInfo.name + "): "); @@ -568,28 +512,24 @@ public String toString() return result.toString(); } - public String getTagName() - { + public String getTagName() { if (tagInfo == TiffTagConstants.TIFF_TAG_UNKNOWN) return tagInfo.name + " (0x" + Integer.toHexString(tag) + ")"; return tagInfo.name; } - public String getFieldTypeName() - { + public String getFieldTypeName() { return fieldType.name; } public static final String Attribute_Tag = "Tag"; - public Object getValue() throws ImageReadException - { + public Object getValue() throws ImageReadException { // System.out.print("getValue"); return tagInfo.getValue(this); } - public String getStringValue() throws ImageReadException - { + public String getStringValue() throws ImageReadException { Object o = getValue(); if (o == null) return null; @@ -599,84 +539,32 @@ public String getStringValue() throws ImageReadException return (String) o; } - private static final Map> makeTagMap(List tags, - boolean ignoreDuplicates, String name) - { + private static final Map> makeTagMap(List tags) { // make sure to use the thread-safe version; this is shared state. - Map> map = new Hashtable>(); + Map> map = new Hashtable<>(); - for (int i = 0; i < tags.size(); i++) - { + for (int i = 0; i < tags.size(); i++) { TagInfo tag = tags.get(i); List tagList = map.get(tag.tag); - if (tagList == null) - { + if (tagList == null) { tagList = new ArrayList(); map.put(tag.tag, tagList); } tagList.add(tag); - - // if (map.get(key) == null) - // map.put(key, tag); - // else if (!ignoreDuplicates) - // { - // System.out.println("Duplicate tag in " + name + ": " + tag.tag - // + " (0x" + Integer.toHexString(tag.tag) + ")"); - // System.out.println("\t" + "New name: " + tag.name); - // System.out.println("\t" + "Old name: " - // + ((TagInfo) map.get(key)).name); - // } } return map; } - private static final Map> GPS_TAG_MAP = makeTagMap(GpsTagConstants.ALL_GPS_TAGS, false, - "GPS"); - private static final Map> TIFF_TAG_MAP = makeTagMap(TiffTagConstants.ALL_TIFF_TAGS, false, - "TIFF"); - private static final Map> EXIF_TAG_MAP = makeTagMap(ExifTagConstants.ALL_EXIF_TAGS, true, - "EXIF"); - private static final Map> ALL_TAG_MAP = makeTagMap(ALL_TAGS, true, "All"); + private static final Map> ALL_TAG_MAP = makeTagMap(ALL_TAGS); - // static - // { - // Map map = new HashMap(); - // - // for (int i = 0; i < ALL_TAGS.length; i++) - // { - // TagInfo2 tag = ALL_TAGS[i]; - // Object o = map.get("" + tag.tag); - // if (o == null) - // map.put("" + tag.tag, tag); - // else - // { - // System.out.println("Duplicate tag: " + tag.tag); - // System.out.println("\t" + "New name: " + tag.name); - // System.out.println("\t" + "Old name: " + ((TagInfo2) o).name); - // } - // } - // - // } - - // public static final TagInfo2 ALL_TAGS[] = TagConstantsUtils - // .mergeTagLists(new TagInfo2[][]{ - // ALL_EXIF_TAGS, ALL_TIFF_TAGS, ALL_GPS_TAGS, - // }); - // - // - - public int[] getIntArrayValue() throws ImageReadException - { + public int[] getIntArrayValue() throws ImageReadException { Object o = getValue(); - // if (o == null) - // return null; if (o instanceof Number) - return new int[] { ((Number) o).intValue() }; - else if (o instanceof Number[]) - { + return new int[]{((Number) o).intValue()}; + else if (o instanceof Number[]) { Number numbers[] = (Number[]) o; int result[] = new int[numbers.length]; for (int i = 0; i < numbers.length; i++) @@ -688,8 +576,7 @@ else if (o instanceof Number[]) for (int i = 0; i < numbers.length; i++) result[i] = 0xffff & numbers[i]; return result; - } else if (o instanceof int[]) - { + } else if (o instanceof int[]) { int numbers[] = (int[]) o; int result[] = new int[numbers.length]; for (int i = 0; i < numbers.length; i++) @@ -697,22 +584,15 @@ else if (o instanceof Number[]) return result; } - throw new ImageReadException("Unknown value: " + o + " for: " - + tagInfo.getDescription()); - // return null; + throw new ImageReadException("Unknown value: " + o + " for: " + tagInfo.getDescription()); } - public double[] getDoubleArrayValue() throws ImageReadException - { + public double[] getDoubleArrayValue() throws ImageReadException { Object o = getValue(); - // if (o == null) - // return null; - if (o instanceof Number) - { - return new double[] { ((Number) o).doubleValue() }; - } else if (o instanceof Number[]) - { + if (o instanceof Number) { + return new double[]{((Number) o).doubleValue()}; + } else if (o instanceof Number[]) { Number numbers[] = (Number[]) o; double result[] = new double[numbers.length]; for (int i = 0; i < numbers.length; i++) @@ -724,22 +604,19 @@ public double[] getDoubleArrayValue() throws ImageReadException for (int i = 0; i < numbers.length; i++) result[i] = numbers[i]; return result; - } else if (o instanceof int[]) - { + } else if (o instanceof int[]) { int numbers[] = (int[]) o; double result[] = new double[numbers.length]; for (int i = 0; i < numbers.length; i++) result[i] = numbers[i]; return result; - } else if (o instanceof float[]) - { + } else if (o instanceof float[]) { float numbers[] = (float[]) o; double result[] = new double[numbers.length]; for (int i = 0; i < numbers.length; i++) result[i] = numbers[i]; return result; - } else if (o instanceof double[]) - { + } else if (o instanceof double[]) { double numbers[] = (double[]) o; double result[] = new double[numbers.length]; for (int i = 0; i < numbers.length; i++) @@ -752,8 +629,7 @@ public double[] getDoubleArrayValue() throws ImageReadException // return null; } - public int getIntValueOrArraySum() throws ImageReadException - { + public int getIntValueOrArraySum() throws ImageReadException { Object o = getValue(); // if (o == null) // return -1; @@ -780,13 +656,10 @@ else if (o instanceof Number[]) { return sum; } - throw new ImageReadException("Unknown value: " + o + " for: " - + tagInfo.getDescription()); - // return -1; + throw new ImageReadException("Unknown value: " + o + " for: " + tagInfo.getDescription()); } - public int getIntValue() throws ImageReadException - { + public int getIntValue() throws ImageReadException { Object o = getValue(); if (o == null) throw new ImageReadException("Missing value: " @@ -795,8 +668,7 @@ public int getIntValue() throws ImageReadException return ((Number) o).intValue(); } - public double getDoubleValue() throws ImageReadException - { + public double getDoubleValue() throws ImageReadException { Object o = getValue(); if (o == null) throw new ImageReadException("Missing value: " @@ -805,18 +677,15 @@ public double getDoubleValue() throws ImageReadException return ((Number) o).doubleValue(); } - public byte[] getByteArrayValue() - { + public byte[] getByteArrayValue() { return fieldType.getRawBytes(this); } - public int getSortHint() - { + public int getSortHint() { return sortHint; } - public void setSortHint(int sortHint) - { + public void setSortHint(int sortHint) { this.sortHint = sortHint; } } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java index 5eccde95..c3a2c2bc 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffImageMetadata.java @@ -492,7 +492,7 @@ public TiffDirectory findDirectory(int directoryType) public List getAllFields() { - List result = new ArrayList(); + List result = new ArrayList<>(); List directories = getDirectories(); for (int i = 0; i < directories.size(); i++) { @@ -584,7 +584,7 @@ public String toString() // latitude: 8 degrees, 40 minutes, 42.2 seconds S // longitude: 115 degrees, 26 minutes, 21.8 seconds E - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append("[GPS. "); result.append("Latitude: " + latitudeDegrees.toDisplayString() + " degrees, " + latitudeMinutes.toDisplayString() 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 82b791de..2dcc8616 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 @@ -32,42 +32,34 @@ import org.apache.commons.imaging.formats.tiff.constants.TiffTagConstants; import org.apache.commons.imaging.util.Debug; -public class TiffReader extends BinaryFileParser implements TiffConstants -{ +public class TiffReader extends BinaryFileParser implements TiffConstants { private final boolean strict; - public TiffReader(boolean strict) - { + public TiffReader(boolean strict) { this.strict = strict; } private TiffHeader readTiffHeader(ByteSource byteSource, - FormatCompliance formatCompliance) throws ImageReadException, - IOException - { + FormatCompliance formatCompliance) throws ImageReadException, + IOException { InputStream is = null; - try - { + try { is = byteSource.getInputStream(); return readTiffHeader(is, formatCompliance); - } finally - { - try - { + } finally { + try { if (is != null) is.close(); - } catch (Exception e) - { + } catch (Exception e) { Debug.debug(e); } } } private TiffHeader readTiffHeader(InputStream is, - FormatCompliance formatCompliance) throws ImageReadException, - IOException - { + FormatCompliance formatCompliance) throws ImageReadException, + IOException { int BYTE_ORDER_1 = readByte("BYTE_ORDER_1", is, "Not a Valid TIFF File"); int BYTE_ORDER_2 = readByte("BYTE_ORDER_2", is, "Not a Valid TIFF File"); setByteOrder(BYTE_ORDER_1, BYTE_ORDER_2); @@ -89,9 +81,8 @@ private TiffHeader readTiffHeader(InputStream is, } private void readDirectories(ByteSource byteSource, - FormatCompliance formatCompliance, Listener listener) - throws ImageReadException, IOException - { + FormatCompliance formatCompliance, Listener listener) + throws ImageReadException, IOException { TiffHeader tiffHeader = readTiffHeader(byteSource, formatCompliance); if (!listener.setTiffHeader(tiffHeader)) return; @@ -105,38 +96,25 @@ private void readDirectories(ByteSource byteSource, } private boolean readDirectory(ByteSource byteSource, int offset, - int dirType, FormatCompliance formatCompliance, Listener listener, - List visited) throws ImageReadException, IOException - { + int dirType, FormatCompliance formatCompliance, Listener listener, + List visited) throws ImageReadException, IOException { boolean ignoreNextDirectory = false; return readDirectory(byteSource, offset, dirType, formatCompliance, listener, ignoreNextDirectory, visited); } private boolean readDirectory(ByteSource byteSource, int offset, - int dirType, FormatCompliance formatCompliance, Listener listener, - boolean ignoreNextDirectory, List visited) - throws ImageReadException, IOException - { - - // Debug.debug(); - // Debug.debug("dir offset", offset + " (0x" + - // Integer.toHexString(offset) - // + ")"); - // Debug.debug("dir key", key); - // Debug.debug("dir visited", visited); - // Debug.debug("dirType", dirType); - // Debug.debug(); + int dirType, FormatCompliance formatCompliance, Listener listener, + boolean ignoreNextDirectory, List visited) + throws ImageReadException, IOException { if (visited.contains(offset)) return false; visited.add(offset); InputStream is = null; - try - { - if (offset >= byteSource.getLength()) - { + try { + if (offset >= byteSource.getLength()) { // Debug.debug("skipping invalid directory!"); return true; } @@ -147,12 +125,10 @@ private boolean readDirectory(ByteSource byteSource, int offset, List fields = new ArrayList(); int entryCount; - try - { + try { entryCount = read2Bytes("DirectoryEntryCount", is, "Not a Valid TIFF File"); - } catch (IOException e) - { + } catch (IOException e) { if (strict) throw e; else @@ -161,8 +137,7 @@ private boolean readDirectory(ByteSource byteSource, int offset, // Debug.debug("entryCount", entryCount); - for (int i = 0; i < entryCount; i++) - { + for (int i = 0; i < entryCount; i++) { int tag = read2Bytes("Tag", is, "Not a Valid TIFF File"); int type = read2Bytes("Type", is, "Not a Valid TIFF File"); int length = read4Bytes("Length", is, "Not a Valid TIFF File"); @@ -175,8 +150,7 @@ private boolean readDirectory(ByteSource byteSource, int offset, int valueOffset = convertByteArrayToInt("ValueOffset", valueOffsetBytes); - if (tag == 0) - { + if (tag == 0) { // skip invalid fields. // These are seen very rarely, but can have invalid value // lengths, @@ -221,16 +195,13 @@ private boolean readDirectory(ByteSource byteSource, int offset, TiffDirectory directory = new TiffDirectory(dirType, fields, offset, nextDirectoryOffset); - if (listener.readImageData()) - { - if (directory.hasTiffImageData()) - { + if (listener.readImageData()) { + if (directory.hasTiffImageData()) { TiffImageData rawImageData = getTiffRawImageData( byteSource, directory); directory.setTiffImageData(rawImageData); } - if (directory.hasJpegImageData()) - { + if (directory.hasJpegImageData()) { JpegImageData rawJpegImageData = getJpegRawImageData( byteSource, directory); directory.setJpegImageData(rawJpegImageData); @@ -240,18 +211,14 @@ private boolean readDirectory(ByteSource byteSource, int offset, if (!listener.addDirectory(directory)) return true; - if (listener.readOffsetDirectories()) - { + if (listener.readOffsetDirectories()) { List fieldsToRemove = new ArrayList(); - for (int j = 0; j < fields.size(); j++) - { + for (int j = 0; j < fields.size(); j++) { TiffField entry = fields.get(j); if (entry.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag || entry.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag - || entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) - { /* do nothing */ } - else + || entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) { /* do nothing */ } else continue; int subDirectoryOffset = ((Number) entry.getValue()) @@ -272,8 +239,7 @@ else if (entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) subDirectoryOffset, subDirectoryType, formatCompliance, listener, true, visited); - if (!subDirectoryRead) - { + if (!subDirectoryRead) { // Offset field pointed to invalid location. // This is a bug in certain cameras. Ignore offset // field. @@ -284,29 +250,24 @@ else if (entry.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) fields.removeAll(fieldsToRemove); } - if (!ignoreNextDirectory && directory.nextDirectoryOffset > 0) - { + if (!ignoreNextDirectory && directory.nextDirectoryOffset > 0) { // Debug.debug("next dir", directory.nextDirectoryOffset ); readDirectory(byteSource, directory.nextDirectoryOffset, dirType + 1, formatCompliance, listener, visited); } return true; - } finally - { - try - { + } finally { + try { if (is != null) is.close(); - } catch (Exception e) - { + } catch (Exception e) { Debug.debug(e); } } } - public static interface Listener - { + public static interface Listener { public boolean setTiffHeader(TiffHeader tiffHeader); public boolean addDirectory(TiffDirectory directory); @@ -318,20 +279,17 @@ public static interface Listener public boolean readOffsetDirectories(); } - private static class Collector implements Listener - { + private static class Collector implements Listener { private TiffHeader tiffHeader = null; - private List directories = new ArrayList(); - private List fields = new ArrayList(); + private List directories = new ArrayList<>(); + private List fields = new ArrayList<>(); private final boolean readThumbnails; - public Collector() - { + public Collector() { this(null); } - public Collector(Map params) - { + public Collector(Map params) { boolean readThumbnails = true; if (params != null && params.containsKey(PARAM_KEY_READ_THUMBNAILS)) readThumbnails = Boolean.TRUE.equals(params @@ -339,90 +297,75 @@ public Collector(Map params) this.readThumbnails = readThumbnails; } - public boolean setTiffHeader(TiffHeader tiffHeader) - { + public boolean setTiffHeader(TiffHeader tiffHeader) { this.tiffHeader = tiffHeader; return true; } - public boolean addDirectory(TiffDirectory directory) - { + public boolean addDirectory(TiffDirectory directory) { directories.add(directory); return true; } - public boolean addField(TiffField field) - { + public boolean addField(TiffField field) { fields.add(field); return true; } - public boolean readImageData() - { + public boolean readImageData() { return readThumbnails; } - public boolean readOffsetDirectories() - { + public boolean readOffsetDirectories() { return true; } - public TiffContents getContents() - { + public TiffContents getContents() { return new TiffContents(tiffHeader, directories); } } - private static class FirstDirectoryCollector extends Collector - { + private static class FirstDirectoryCollector extends Collector { private final boolean readImageData; - public FirstDirectoryCollector(final boolean readImageData) - { + public FirstDirectoryCollector(final boolean readImageData) { this.readImageData = readImageData; } @Override - public boolean addDirectory(TiffDirectory directory) - { + public boolean addDirectory(TiffDirectory directory) { super.addDirectory(directory); return false; } @Override - public boolean readImageData() - { + public boolean readImageData() { return readImageData; } } - private static class DirectoryCollector extends Collector - { + private static class DirectoryCollector extends Collector { private final boolean readImageData; - public DirectoryCollector(final boolean readImageData) - { + public DirectoryCollector(final boolean readImageData) { this.readImageData = readImageData; } @Override - public boolean addDirectory(TiffDirectory directory) - { + public boolean addDirectory(TiffDirectory directory) { super.addDirectory(directory); return false; } @Override - public boolean readImageData() - { + public boolean readImageData() { return readImageData; } } public TiffContents readFirstDirectory(ByteSource byteSource, Map params, - boolean readImageData, FormatCompliance formatCompliance) - throws ImageReadException, IOException - { + boolean readImageData, FormatCompliance formatCompliance) + throws ImageReadException, IOException { Collector collector = new FirstDirectoryCollector(readImageData); read(byteSource, params, formatCompliance, collector); TiffContents contents = collector.getContents(); @@ -433,9 +376,8 @@ public TiffContents readFirstDirectory(ByteSource byteSource, Map params, } public TiffContents readDirectories(ByteSource byteSource, - boolean readImageData, FormatCompliance formatCompliance) - throws ImageReadException, IOException - { + boolean readImageData, FormatCompliance formatCompliance) + throws ImageReadException, IOException { Collector collector = new Collector(null); readDirectories(byteSource, formatCompliance, collector); TiffContents contents = collector.getContents(); @@ -446,9 +388,8 @@ public TiffContents readDirectories(ByteSource byteSource, } public TiffContents readContents(ByteSource byteSource, Map params, - FormatCompliance formatCompliance) throws ImageReadException, - IOException - { + FormatCompliance formatCompliance) throws ImageReadException, + IOException { Collector collector = new Collector(params); read(byteSource, params, formatCompliance, collector); @@ -457,32 +398,28 @@ public TiffContents readContents(ByteSource byteSource, Map params, } public void read(ByteSource byteSource, Map params, - FormatCompliance formatCompliance, Listener listener) - throws ImageReadException, IOException - { + FormatCompliance formatCompliance, Listener listener) + throws ImageReadException, IOException { // TiffContents contents = readDirectories(byteSource, formatCompliance, listener); } private TiffImageData getTiffRawImageData(ByteSource byteSource, - TiffDirectory directory) throws ImageReadException, IOException - { + TiffDirectory directory) throws ImageReadException, IOException { List elements = directory.getTiffRawImageDataElements(); TiffImageData.Data data[] = new TiffImageData.Data[elements.size()]; - for (int i = 0; i < elements.size(); i++) - { + for (int i = 0; i < elements.size(); i++) { TiffDirectory.ImageDataElement element = elements.get(i); byte bytes[] = byteSource.getBlock(element.offset, element.length); data[i] = new TiffImageData.Data(element.offset, element.length, bytes); } - if (directory.imageDataInStrips()) - { + if (directory.imageDataInStrips()) { TiffField rowsPerStripField = directory .findField(TiffTagConstants.TIFF_TAG_ROWS_PER_STRIP); - int rowsPerStrip ; + int rowsPerStrip; if (null != rowsPerStripField) { rowsPerStrip = rowsPerStripField.getIntValue(); @@ -492,12 +429,11 @@ private TiffImageData getTiffRawImageData(ByteSource byteSource, * if rows per strip not present then rowsPerStrip * is equal to imageLength or an infinity value; */ - rowsPerStrip = imageHeight.getIntValue(); + rowsPerStrip = imageHeight.getIntValue(); } return new TiffImageData.Strips(data, rowsPerStrip); - } else - { + } else { TiffField tileWidthField = directory.findField(TiffTagConstants.TIFF_TAG_TILE_WIDTH); if (null == tileWidthField) throw new ImageReadException("Can't find tile width field."); @@ -514,8 +450,7 @@ private TiffImageData getTiffRawImageData(ByteSource byteSource, } private JpegImageData getJpegRawImageData(ByteSource byteSource, - TiffDirectory directory) throws ImageReadException, IOException - { + TiffDirectory directory) throws ImageReadException, IOException { ImageDataElement element = directory.getJpegRawImageDataElement(); int offset = element.offset; int length = element.length; diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePageMaker6TagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePageMaker6TagConstants.java index 9f8d7649..fe9c2c97 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePageMaker6TagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePageMaker6TagConstants.java @@ -1,14 +1,8 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; +import java.util.List; /** * TIFF specification supplement 1 @@ -18,45 +12,40 @@ * http://partners.adobe.com/public/developer/en/tiff/TIFFPM6.pdf */ public interface AdobePageMaker6TagConstants extends TiffFieldTypeConstants { - public static final TagInfoLong TIFF_TAG_SUB_IFD = new TagInfoLong( + TagInfoLong TIFF_TAG_SUB_IFD = new TagInfoLong( "Sub IFD", 0x014a, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - public static final TagInfoByte TIFF_TAG_CLIP_PATH = new TagInfoByte( + TagInfoByte TIFF_TAG_CLIP_PATH = new TagInfoByte( "Clip Path", 0x0157, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong TIFF_TAG_XCLIP_PATH_UNITS = new TagInfoLong( + TagInfoLong TIFF_TAG_XCLIP_PATH_UNITS = new TagInfoLong( "XClip Path Units", 0x0158, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong TIFF_TAG_YCLIP_PATH_UNITS = new TagInfoLong( + TagInfoLong TIFF_TAG_YCLIP_PATH_UNITS = new TagInfoLong( "YClip Path Units", 0x0159, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort TIFF_TAG_INDEXED = new TagInfoShort( + TagInfoShort TIFF_TAG_INDEXED = new TagInfoShort( "Indexed", 0x015a, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int INDEXED_VALUE_NOT_INDEXED = 0; - public static final int INDEXED_VALUE_INDEXED = 1; - public static final TagInfoShort TIFF_TAG_OPIPROXY = new TagInfoShort( + TagInfoShort TIFF_TAG_OPIPROXY = new TagInfoShort( "OPIProxy", 0x015f, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int OPIPROXY_VALUE_HIGHER_RESOLUTION_IMAGE_DOES_NOT_EXIST = 0; - public static final int OPIPROXY_VALUE_HIGHER_RESOLUTION_IMAGE_EXISTS = 1; - public static final TagInfoAscii TIFF_TAG_IMAGE_ID = new TagInfoAscii( + TagInfoAscii TIFF_TAG_IMAGE_ID = new TagInfoAscii( "Image ID", 0x800d, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_ADOBE_PAGEMAKER_6_TAGS = - Collections.unmodifiableList(Arrays.asList( - TIFF_TAG_SUB_IFD, + List ALL_ADOBE_PAGEMAKER_6_TAGS = + List.of(TIFF_TAG_SUB_IFD, TIFF_TAG_CLIP_PATH, TIFF_TAG_XCLIP_PATH_UNITS, TIFF_TAG_YCLIP_PATH_UNITS, TIFF_TAG_INDEXED, TIFF_TAG_OPIPROXY, - TIFF_TAG_IMAGE_ID)); + TIFF_TAG_IMAGE_ID); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePhotoshopTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePhotoshopTagConstants.java index e3b88263..7a3319c0 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePhotoshopTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AdobePhotoshopTagConstants.java @@ -1,12 +1,10 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefined; +import java.util.List; + /** * TIFF specification supplement 2 *
@@ -15,17 +13,17 @@ * http://partners.adobe.com/public/developer/en/tiff/TIFFphotoshop.pdf */ public interface AdobePhotoshopTagConstants { - public static final TagInfoUndefined EXIF_TAG_JPEGTABLES = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_JPEGTABLES = new TagInfoUndefined( "JPEGTables", 0x015b, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_IMAGE_SOURCE_DATA = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_IMAGE_SOURCE_DATA = new TagInfoUndefined( "Image Source Data", 0x935c, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final List ALL_ADOBE_PHOTOSHOP_TAGS = - Collections.unmodifiableList(Arrays.asList(new TagInfo[] { + List ALL_ADOBE_PHOTOSHOP_TAGS = + List.of( EXIF_TAG_JPEGTABLES, EXIF_TAG_IMAGE_SOURCE_DATA - })); + ); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AliasSketchbookProTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AliasSketchbookProTagConstants.java index 03ecde4a..6eedd19b 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AliasSketchbookProTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/AliasSketchbookProTagConstants.java @@ -1,23 +1,20 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; +import java.util.List; + /** * Alias Sketchbook Pro multi-layer TIFF *
* http://www.awaresystems.be/imaging/tiff/tifftags/docs/alias.html */ public interface AliasSketchbookProTagConstants extends TiffFieldTypeConstants { - public static final TagInfoAscii EXIF_TAG_ALIAS_LAYER_METADATA = new TagInfoAscii( + TagInfoAscii EXIF_TAG_ALIAS_LAYER_METADATA = new TagInfoAscii( "Alias Layer Metadata", 0xc660, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_ALIAS_SKETCHBOOK_PRO_TAGS = - Collections.unmodifiableList(Arrays.asList(new TagInfo[] { - EXIF_TAG_ALIAS_LAYER_METADATA})); + List ALL_ALIAS_SKETCHBOOK_PRO_TAGS = + List.of(EXIF_TAG_ALIAS_LAYER_METADATA); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java index 3bcf819a..7723cc11 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DcfTagConstants.java @@ -1,42 +1,36 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; +import java.util.List; + /** * Design rule for Camera Filesystem *
* http://www.exif.org/dcf.PDF */ public interface DcfTagConstants extends TiffFieldTypeConstants { - public static final TagInfoAscii EXIF_TAG_RELATED_IMAGE_FILE_FORMAT = new TagInfoAscii( + TagInfoAscii EXIF_TAG_RELATED_IMAGE_FILE_FORMAT = new TagInfoAscii( "Related Image File Format", 0x1000, -1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); - - public static final TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_WIDTH = new TagInfoShortOrLong( + + TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_WIDTH = new TagInfoShortOrLong( "Related Image Width", 0x1001, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); - - public static final TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_LENGTH = new TagInfoShortOrLong( + + TagInfoShortOrLong EXIF_TAG_RELATED_IMAGE_LENGTH = new TagInfoShortOrLong( "Related Image Length", 0x1002, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); - - public static final TagInfoShort EXIF_TAG_COLOR_SPACE = new TagInfoShort( + + TagInfoShort EXIF_TAG_COLOR_SPACE = new TagInfoShort( "Color Space", 0xa001, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int COLOR_SPACE_VALUE_SRGB = 1; - public static final int COLOR_SPACE_VALUE_ADOBE_RGB = 2; - public static final int COLOR_SPACE_VALUE_UNCALIBRATED = 65535; - public static final List ALL_DCF_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_RELATED_IMAGE_FILE_FORMAT, + List ALL_DCF_TAGS = + List.of(EXIF_TAG_RELATED_IMAGE_FILE_FORMAT, EXIF_TAG_RELATED_IMAGE_WIDTH, EXIF_TAG_RELATED_IMAGE_LENGTH, - EXIF_TAG_COLOR_SPACE)); + EXIF_TAG_COLOR_SPACE); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java index b7821618..b2a23b5d 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/DngTagConstants.java @@ -1,23 +1,8 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAsciiOrByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoDouble; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoFloat; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoSRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLongOrRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefined; +import java.util.List; /** * Digital Negative (DNG) Specification @@ -25,387 +10,337 @@ * http://www.adobe.com/products/dng/pdfs/dng_spec_1_3_0_0.pdf */ public interface DngTagConstants extends TiffFieldTypeConstants { - public static final TagInfoByte EXIF_TAG_DNG_VERSION = new TagInfoByte( + TagInfoByte EXIF_TAG_DNG_VERSION = new TagInfoByte( "DNG Version", 0xc612, 4, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoByte EXIF_TAG_DNG_BACKWARD_VERSION = new TagInfoByte( + TagInfoByte EXIF_TAG_DNG_BACKWARD_VERSION = new TagInfoByte( "DNG Backward Version", 0xc613, 4, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAscii EXIF_TAG_UNIQUE_CAMERA_MODEL = new TagInfoAscii( + TagInfoAscii EXIF_TAG_UNIQUE_CAMERA_MODEL = new TagInfoAscii( "Unique Camera Model", 0xc614, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAsciiOrByte EXIF_TAG_LOCALIZED_CAMERA_MODEL = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_LOCALIZED_CAMERA_MODEL = new TagInfoAsciiOrByte( "Localized Camera Model", 0xc615, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoByte EXIF_TAG_CFAPLANE_COLOR = new TagInfoByte( + TagInfoByte EXIF_TAG_CFAPLANE_COLOR = new TagInfoByte( "CFAPlane Color", 0xc616, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_CFALAYOUT = new TagInfoShort( + TagInfoShort EXIF_TAG_CFALAYOUT = new TagInfoShort( "CFALayout", 0xc617, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int CFALAYOUT_VALUE_RECTANGULAR = 1; - public static final int CFALAYOUT_VALUE_EVEN_COLUMNS_OFFSET_DOWN_1_2_ROW = 2; - public static final int CFALAYOUT_VALUE_EVEN_COLUMNS_OFFSET_UP_1_2_ROW = 3; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_RIGHT_1_2_COLUMN = 4; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_LEFT_1_2_COLUMN = 5; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_UP_1_2_ROW_EVEN_COLUMNS_OFFSET_LEFT_1_2_COLUMN = 6; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_UP_1_2_ROW_EVEN_COLUMNS_OFFSET_RIGHT_1_2_COLUMN = 7; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_DOWN_1_2_ROW_EVEN_COLUMNS_OFFSET_LEFT_1_2_COLUMN = 8; - public static final int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_DOWN_1_2_ROW_EVEN_COLUMNS_OFFSET_RIGHT_1_2_COLUMN = 9; + int CFALAYOUT_VALUE_RECTANGULAR = 1; + int CFALAYOUT_VALUE_EVEN_COLUMNS_OFFSET_DOWN_1_2_ROW = 2; + int CFALAYOUT_VALUE_EVEN_COLUMNS_OFFSET_UP_1_2_ROW = 3; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_RIGHT_1_2_COLUMN = 4; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_LEFT_1_2_COLUMN = 5; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_UP_1_2_ROW_EVEN_COLUMNS_OFFSET_LEFT_1_2_COLUMN = 6; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_UP_1_2_ROW_EVEN_COLUMNS_OFFSET_RIGHT_1_2_COLUMN = 7; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_DOWN_1_2_ROW_EVEN_COLUMNS_OFFSET_LEFT_1_2_COLUMN = 8; + int CFALAYOUT_VALUE_EVEN_ROWS_OFFSET_DOWN_1_2_ROW_EVEN_COLUMNS_OFFSET_RIGHT_1_2_COLUMN = 9; - public static final TagInfoShort EXIF_TAG_LINEARIZATION_TABLE = new TagInfoShort( + TagInfoShort EXIF_TAG_LINEARIZATION_TABLE = new TagInfoShort( "Linearization Table", 0xc618, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_BLACK_LEVEL_REPEAT_DIM = new TagInfoShort( + TagInfoShort EXIF_TAG_BLACK_LEVEL_REPEAT_DIM = new TagInfoShort( "Black Level Repeat Dim", 0xc619, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLongOrRational EXIF_TAG_BLACK_LEVEL = new TagInfoShortOrLongOrRational( + TagInfoShortOrLongOrRational EXIF_TAG_BLACK_LEVEL = new TagInfoShortOrLongOrRational( "Black Level", 0xc61a, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_BLACK_LEVEL_DELTA_H = new TagInfoSRational( + TagInfoSRational EXIF_TAG_BLACK_LEVEL_DELTA_H = new TagInfoSRational( "Black Level Delta H", 0xc61b, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_BLACK_LEVEL_DELTA_V = new TagInfoSRational( + TagInfoSRational EXIF_TAG_BLACK_LEVEL_DELTA_V = new TagInfoSRational( "Black Level Delta V", 0xc61c, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLong EXIF_TAG_WHITE_LEVEL = new TagInfoShortOrLong( + TagInfoShortOrLong EXIF_TAG_WHITE_LEVEL = new TagInfoShortOrLong( "White Level", 0xc61d, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_DEFAULT_SCALE = new TagInfoRational( + TagInfoRational EXIF_TAG_DEFAULT_SCALE = new TagInfoRational( "Default Scale", 0xc61e, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLongOrRational EXIF_TAG_DEFAULT_CROP_ORIGIN = new TagInfoShortOrLongOrRational( + TagInfoShortOrLongOrRational EXIF_TAG_DEFAULT_CROP_ORIGIN = new TagInfoShortOrLongOrRational( "Default Crop Origin", 0xc61f, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLongOrRational EXIF_TAG_DEFAULT_CROP_SIZE = new TagInfoShortOrLongOrRational( + TagInfoShortOrLongOrRational EXIF_TAG_DEFAULT_CROP_SIZE = new TagInfoShortOrLongOrRational( "Default Crop Size", 0xc620, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_COLOR_MATRIX_1 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_COLOR_MATRIX_1 = new TagInfoSRational( "Color Matrix 1", 0xc621, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_COLOR_MATRIX_2 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_COLOR_MATRIX_2 = new TagInfoSRational( "Color Matrix 2", 0xc622, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_CAMERA_CALIBRATION_1 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_CAMERA_CALIBRATION_1 = new TagInfoSRational( "Camera Calibration 1", 0xc623, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_CAMERA_CALIBRATION_2 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_CAMERA_CALIBRATION_2 = new TagInfoSRational( "Camera Calibration 2", 0xc624, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_REDUCTION_MATRIX_1 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_REDUCTION_MATRIX_1 = new TagInfoSRational( "Reduction Matrix 1", 0xc625, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_REDUCTION_MATRIX_2 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_REDUCTION_MATRIX_2 = new TagInfoSRational( "Reduction Matrix 2", 0xc626, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_ANALOG_BALANCE = new TagInfoRational( + TagInfoRational EXIF_TAG_ANALOG_BALANCE = new TagInfoRational( "Analog Balance", 0xc627, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShortOrRational EXIF_TAG_AS_SHOT_NEUTRAL = new TagInfoShortOrRational( + TagInfoShortOrRational EXIF_TAG_AS_SHOT_NEUTRAL = new TagInfoShortOrRational( "As Shot Neutral", 0xc628, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_AS_SHOT_WHITE_XY = new TagInfoRational( + TagInfoRational EXIF_TAG_AS_SHOT_WHITE_XY = new TagInfoRational( "As Shot White XY", 0xc629, 2, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoSRational EXIF_TAG_BASELINE_EXPOSURE = new TagInfoSRational( + TagInfoSRational EXIF_TAG_BASELINE_EXPOSURE = new TagInfoSRational( "Baseline Exposure", 0xc62a, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_BASELINE_NOISE = new TagInfoRational( + TagInfoRational EXIF_TAG_BASELINE_NOISE = new TagInfoRational( "Baseline Noise", 0xc62b, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_BASELINE_SHARPNESS = new TagInfoRational( + TagInfoRational EXIF_TAG_BASELINE_SHARPNESS = new TagInfoRational( "Baseline Sharpness", 0xc62c, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoLong EXIF_TAG_BAYER_GREEN_SPLIT = new TagInfoLong( + TagInfoLong EXIF_TAG_BAYER_GREEN_SPLIT = new TagInfoLong( "Bayer Green Split", 0xc62d, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_LINEAR_RESPONSE_LIMIT = new TagInfoRational( + TagInfoRational EXIF_TAG_LINEAR_RESPONSE_LIMIT = new TagInfoRational( "Linear Response Limit", 0xc62e, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAscii EXIF_TAG_CAMERA_SERIAL_NUMBER = new TagInfoAscii( + TagInfoAscii EXIF_TAG_CAMERA_SERIAL_NUMBER = new TagInfoAscii( "Camera Serial Number", 0xc62f, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_DNG_LENS_INFO = new TagInfoRational( + TagInfoRational EXIF_TAG_DNG_LENS_INFO = new TagInfoRational( "DNG Lens Info", 0xc630, 4, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_CHROMA_BLUR_RADIUS = new TagInfoRational( + TagInfoRational EXIF_TAG_CHROMA_BLUR_RADIUS = new TagInfoRational( "Chroma Blur Radius", 0xc631, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_ANTI_ALIAS_STRENGTH = new TagInfoRational( + TagInfoRational EXIF_TAG_ANTI_ALIAS_STRENGTH = new TagInfoRational( "Anti Alias Strength", 0xc632, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_SHADOW_SCALE = new TagInfoRational( + TagInfoRational EXIF_TAG_SHADOW_SCALE = new TagInfoRational( "Shadow Scale", 0xc633, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoByte EXIF_TAG_DNG_PRIVATE_DATA = new TagInfoByte( + TagInfoByte EXIF_TAG_DNG_PRIVATE_DATA = new TagInfoByte( "DNG Private Data", 0xc634, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShort EXIF_TAG_MAKER_NOTE_SAFETY = new TagInfoShort( + TagInfoShort EXIF_TAG_MAKER_NOTE_SAFETY = new TagInfoShort( "Maker Note Safety", 0xc635, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final int MAKER_NOTE_SAFETY_VALUE_UNSAFE = 0; - public static final int MAKER_NOTE_SAFETY_VALUE_SAFE = 1; + int MAKER_NOTE_SAFETY_VALUE_UNSAFE = 0; + int MAKER_NOTE_SAFETY_VALUE_SAFE = 1; - public static final TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_1 = new TagInfoShort( + TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_1 = new TagInfoShort( "Calibration Illuminant 1", 0xc65a, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAYLIGHT = 1; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_FLUORESCENT = 2; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_TUNGSTEN = 3; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_FLASH = 4; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_FINE_WEATHER = 9; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_CLOUDY = 10; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_SHADE = 11; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAYLIGHT_FLUORESCENT = 12; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_DAY_WHITE_FLUORESCENT = 13; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_COOL_WHITE_FLUORESCENT = 14; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_WHITE_FLUORESCENT = 15; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_A = 17; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_B = 18; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_STANDARD_LIGHT_C = 19; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_D55 = 20; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_D65 = 21; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_D75 = 22; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_D50 = 23; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_ISO_STUDIO_TUNGSTEN = 24; - public static final int CALIBRATION_ILLUMINANT_1_VALUE_OTHER = 255; - - public static final TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_2 = new TagInfoShort( + + TagInfoShort EXIF_TAG_CALIBRATION_ILLUMINANT_2 = new TagInfoShort( "Calibration Illuminant 2", 0xc65b, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final int CALIBRATION_ILLUMINANT_2_VALUE_DAYLIGHT = 1; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_FLUORESCENT = 2; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_TUNGSTEN = 3; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_FLASH = 4; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_FINE_WEATHER = 9; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_CLOUDY = 10; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_SHADE = 11; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_DAYLIGHT_FLUORESCENT = 12; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_DAY_WHITE_FLUORESCENT = 13; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_COOL_WHITE_FLUORESCENT = 14; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_WHITE_FLUORESCENT = 15; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_STANDARD_LIGHT_A = 17; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_STANDARD_LIGHT_B = 18; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_STANDARD_LIGHT_C = 19; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_D55 = 20; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_D65 = 21; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_D75 = 22; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_D50 = 23; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_ISO_STUDIO_TUNGSTEN = 24; - public static final int CALIBRATION_ILLUMINANT_2_VALUE_OTHER = 255; - - public static final TagInfoRational EXIF_TAG_BEST_QUALITY_SCALE = new TagInfoRational( + + TagInfoRational EXIF_TAG_BEST_QUALITY_SCALE = new TagInfoRational( "Best Quality Scale", 0xc65c, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_RAW_DATA_UNIQUE_ID = new TagInfoByte( + TagInfoByte EXIF_TAG_RAW_DATA_UNIQUE_ID = new TagInfoByte( "Raw Data Unique ID", 0xc65d, 16, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAsciiOrByte EXIF_TAG_ORIGINAL_RAW_FILE_NAME = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_ORIGINAL_RAW_FILE_NAME = new TagInfoAsciiOrByte( "Original Raw File Name", 0xc68b, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoUndefined EXIF_TAG_ORIGINAL_RAW_FILE_DATA = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_ORIGINAL_RAW_FILE_DATA = new TagInfoUndefined( "Original Raw File Data", 0xc68c, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShortOrLong EXIF_TAG_ACTIVE_AREA = new TagInfoShortOrLong( + TagInfoShortOrLong EXIF_TAG_ACTIVE_AREA = new TagInfoShortOrLong( "Active Area", 0xc68d, 4, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLong EXIF_TAG_MASKED_AREAS = new TagInfoShortOrLong( + TagInfoShortOrLong EXIF_TAG_MASKED_AREAS = new TagInfoShortOrLong( "Masked Areas", 0xc68e, 4, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_AS_SHOT_ICCPROFILE = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_AS_SHOT_ICCPROFILE = new TagInfoUndefined( "As Shot ICCProfile", 0xc68f, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_AS_SHOT_PRE_PROFILE_MATRIX = new TagInfoSRational( + TagInfoSRational EXIF_TAG_AS_SHOT_PRE_PROFILE_MATRIX = new TagInfoSRational( "As Shot Pre Profile Matrix", 0xc690, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoUndefined EXIF_TAG_CURRENT_ICCPROFILE = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_CURRENT_ICCPROFILE = new TagInfoUndefined( "Current ICCProfile", 0xc691, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoSRational EXIF_TAG_CURRENT_PRE_PROFILE_MATRIX = new TagInfoSRational( + TagInfoSRational EXIF_TAG_CURRENT_PRE_PROFILE_MATRIX = new TagInfoSRational( "Current Pre Profile Matrix", 0xc692, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShort EXIF_TAG_COLORIMETRIC_REFERENCE = new TagInfoShort( + TagInfoShort EXIF_TAG_COLORIMETRIC_REFERENCE = new TagInfoShort( "Colorimetric Reference", 0xc6bf, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final short COLORIMETRIC_REFERENCE_VALUE_SCENE_REFERRED = 0; - public static final short COLORIMETRIC_REFERENCE_VALUE_OUTPUT_REFERRED = 1; + short COLORIMETRIC_REFERENCE_VALUE_SCENE_REFERRED = 0; + short COLORIMETRIC_REFERENCE_VALUE_OUTPUT_REFERRED = 1; - public static final TagInfoAsciiOrByte EXIF_TAG_CAMERA_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_CAMERA_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte( "Camera Calibration Signature", 0xc6f3, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAsciiOrByte EXIF_TAG_PROFILE_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_PROFILE_CALIBRATION_SIGNATURE = new TagInfoAsciiOrByte( "Profile Calibration Signature", 0xc6f4, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoLong EXIF_TAG_EXTRA_CAMERA_PROFILES = new TagInfoLong( + TagInfoLong EXIF_TAG_EXTRA_CAMERA_PROFILES = new TagInfoLong( "Extra Camera Profiles", 0xc6f5, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAsciiOrByte EXIF_TAG_AS_SHOT_PROFILE_NAME = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_AS_SHOT_PROFILE_NAME = new TagInfoAsciiOrByte( "As Shot Profile Name", 0xc6f6, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoRational EXIF_TAG_NOISE_REDUCTION_APPLIED = new TagInfoRational( + TagInfoRational EXIF_TAG_NOISE_REDUCTION_APPLIED = new TagInfoRational( "Noise Reduction Applied", 0xc6f7, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_PROFILE_NAME = new TagInfoAscii( + TagInfoAscii EXIF_TAG_PROFILE_NAME = new TagInfoAscii( "Profile Name", 0xc6f8, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_PROFILE_HUE_SAT_MAP_DIMS = new TagInfoLong( + TagInfoLong EXIF_TAG_PROFILE_HUE_SAT_MAP_DIMS = new TagInfoLong( "Profile Hue/Sat/Map", 0xc6f9, 3, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoFloat EXIF_TAG_PROFILE_HUE_SAT_MAP_DATA1 = new TagInfoFloat( + TagInfoFloat EXIF_TAG_PROFILE_HUE_SAT_MAP_DATA1 = new TagInfoFloat( "Profile Hue/Sat/Map Data1", 0xc6fa, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoFloat EXIF_TAG_PROFILE_HUE_SAT_MAP_DATA2 = new TagInfoFloat( + TagInfoFloat EXIF_TAG_PROFILE_HUE_SAT_MAP_DATA2 = new TagInfoFloat( "Profile Hue/Sat/Map Data2", 0xc6fb, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoFloat EXIF_TAG_PROFILE_TONE_CURVE = new TagInfoFloat( + TagInfoFloat EXIF_TAG_PROFILE_TONE_CURVE = new TagInfoFloat( "Profile Tone Curve", 0xc6fc, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_PROFILE_EMBED_POLICY = new TagInfoLong( + TagInfoLong EXIF_TAG_PROFILE_EMBED_POLICY = new TagInfoLong( "Profile Embed Policy", 0xc6fd, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int PROFILE_EMBED_POLICY_VALUE_ALLOW_COPYING = 0; - public static final int PROFILE_EMBED_POLICY_VALUE_EMBED_IF_USED = 1; - public static final int PROFILE_EMBED_POLICY_VALUE_EMBED_NEVER = 2; - public static final int PROFILE_EMBED_POLICY_VALUE_NO_RESTRICTIONS = 3; - public static final TagInfoAsciiOrByte EXIF_TAG_PROFILE_COPYRIGHT = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_PROFILE_COPYRIGHT = new TagInfoAsciiOrByte( "Profile Copyright", 0xc6fe, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_FORWARD_MATRIX1 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_FORWARD_MATRIX1 = new TagInfoSRational( "Forward Matrix 1", 0xc714, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSRational EXIF_TAG_FORWARD_MATRIX2 = new TagInfoSRational( + TagInfoSRational EXIF_TAG_FORWARD_MATRIX2 = new TagInfoSRational( "Forward Matrix 2", 0xc715, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_NAME = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_NAME = new TagInfoAsciiOrByte( "Preview Application Name", 0xc716, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_VERSION = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_PREVIEW_APPLICATION_VERSION = new TagInfoAsciiOrByte( "Preview Application Version", 0xc717, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAsciiOrByte EXIF_TAG_PREVIEW_SETTINGS_NAME = new TagInfoAsciiOrByte( + TagInfoAsciiOrByte EXIF_TAG_PREVIEW_SETTINGS_NAME = new TagInfoAsciiOrByte( "Preview Settings Name", 0xc718, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_PREVIEW_SETTINGS_DIGEST = new TagInfoByte( + TagInfoByte EXIF_TAG_PREVIEW_SETTINGS_DIGEST = new TagInfoByte( "Preview Settings Digest", 0xc719, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_PREVIEW_COLORSPACE = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_COLORSPACE = new TagInfoLong( "Preview Colorspace", 0xc71a, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int PREVIEW_COLORSPACE_VALUE_UNKNOWN = 0; - public static final int PREVIEW_COLORSPACE_VALUE_GRAY_GAMMA_2_2 = 1; - public static final int PREVIEW_COLORSPACE_VALUE_sRGB = 2; - public static final int PREVIEW_COLORSPACE_VALUE_ADOBE_RGB = 3; - public static final int PREVIEW_COLORSPACE_VALUE_PROPHOTO_RGB = 4; - public static final TagInfoAscii EXIF_TAG_PREVIEW_DATE_TIME = new TagInfoAscii( + TagInfoAscii EXIF_TAG_PREVIEW_DATE_TIME = new TagInfoAscii( "Preview DateTime", 0xc71b, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_RAW_IMAGE_DIGEST = new TagInfoByte( + TagInfoByte EXIF_TAG_RAW_IMAGE_DIGEST = new TagInfoByte( "Raw Image Digest", 0xc71c, 16, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoByte EXIF_TAG_ORIGINAL_RAW_FILE_DIGEST = new TagInfoByte( + TagInfoByte EXIF_TAG_ORIGINAL_RAW_FILE_DIGEST = new TagInfoByte( "Original Raw File Digest", 0xc71d, 16, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShortOrLong EXIF_TAG_SUB_TILE_BLOCK_SIZE = new TagInfoShortOrLong( + TagInfoShortOrLong EXIF_TAG_SUB_TILE_BLOCK_SIZE = new TagInfoShortOrLong( "Sub Tile Block Size", 0xc71e, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLong EXIF_TAG_ROW_INTERLEAVE_FACTOR = new TagInfoShortOrLong( + TagInfoShortOrLong EXIF_TAG_ROW_INTERLEAVE_FACTOR = new TagInfoShortOrLong( "Row Interleave Factor", 0xc71f, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_PROFILE_LOOK_TABLE_DIMS = new TagInfoLong( + TagInfoLong EXIF_TAG_PROFILE_LOOK_TABLE_DIMS = new TagInfoLong( "Profile Look Table Dims", 0xc725, 3, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoFloat EXIF_TAG_PROFILE_LOOK_TABLE_DATA = new TagInfoFloat( + TagInfoFloat EXIF_TAG_PROFILE_LOOK_TABLE_DATA = new TagInfoFloat( "Profile Look Table Data", 0xc726, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_OPCODE_LIST_1 = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_OPCODE_LIST_1 = new TagInfoUndefined( "Opcode List 1", 0xc740, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_OPCODE_LIST_2 = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_OPCODE_LIST_2 = new TagInfoUndefined( "Opcode List 2", 0xc741, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_OPCODE_LIST_3 = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_OPCODE_LIST_3 = new TagInfoUndefined( "Opcode List 3", 0xc74E, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoDouble EXIF_TAG_NOISE_PROFILE = new TagInfoDouble( + TagInfoDouble EXIF_TAG_NOISE_PROFILE = new TagInfoDouble( "Noise Profile", 0xc761, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_DNG_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_DNG_VERSION, + List ALL_DNG_TAGS = + List.of(EXIF_TAG_DNG_VERSION, EXIF_TAG_DNG_BACKWARD_VERSION, EXIF_TAG_UNIQUE_CAMERA_MODEL, EXIF_TAG_LOCALIZED_CAMERA_MODEL, @@ -483,5 +418,5 @@ public interface DngTagConstants extends TiffFieldTypeConstants { EXIF_TAG_OPCODE_LIST_1, EXIF_TAG_OPCODE_LIST_2, EXIF_TAG_OPCODE_LIST_3, - EXIF_TAG_NOISE_PROFILE)); + EXIF_TAG_NOISE_PROFILE); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java index ba418135..a683cde5 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/ExifTagConstants.java @@ -16,23 +16,9 @@ */ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoDouble; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoGpsText; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoSLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoSRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefined; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUnknown; +import java.util.List; /** * References: @@ -48,477 +34,476 @@ public interface ExifTagConstants extends TiffFieldTypeConstants { - public static final TagInfoAscii EXIF_TAG_INTEROP_INDEX = new TagInfoAscii( + TagInfoAscii EXIF_TAG_INTEROP_INDEX = new TagInfoAscii( "Interop Index", 0x0001, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); - public static final TagInfoUndefined EXIF_TAG_INTEROP_VERSION = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_INTEROP_VERSION = new TagInfoUndefined( "Interop Version", 0x0002, 1, TiffDirectoryType.EXIF_DIRECTORY_INTEROP_IFD); - public static final TagInfoAscii EXIF_TAG_PROCESSING_SOFTWARE = new TagInfoAscii( + TagInfoAscii EXIF_TAG_PROCESSING_SOFTWARE = new TagInfoAscii( "Processing Software", 0x000b, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoAscii EXIF_TAG_SOFTWARE = new TagInfoAscii("Software", + TagInfoAscii EXIF_TAG_SOFTWARE = new TagInfoAscii("Software", 0x0131, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_IFD0 = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_IFD0 = new TagInfoLong( "Preview Image Start", 0x0111, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0, true); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_SUB_IFD1 = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_SUB_IFD1 = new TagInfoLong( "Preview Image Start", 0x0111, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD1, true); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_SUB_IFD2 = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_SUB_IFD2 = new TagInfoLong( "Jpg From Raw Start", 0x0111, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD2, true); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_IFD0 = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_IFD0 = new TagInfoLong( "Preview Image Length", 0x0117, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_SUB_IFD1 = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_SUB_IFD1 = new TagInfoLong( "Preview Image Length", 0x0117, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD1); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_SUB_IFD2 = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_SUB_IFD2 = new TagInfoLong( "Jpg From Raw Length", 0x0117, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD2); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_MAKER_NOTES = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_START_MAKER_NOTES = new TagInfoLong( "Preview Image Start", 0x0201, 1, TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_SUB_IFD = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_SUB_IFD = new TagInfoLong( "Jpg From Raw Start", 0x0201, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD, true); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_IFD2 = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_START_IFD2 = new TagInfoLong( "Jpg From Raw Start", 0x0201, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD2, true); - public static final TagInfoLong EXIF_TAG_OTHER_IMAGE_START = new TagInfoLong( + TagInfoLong EXIF_TAG_OTHER_IMAGE_START = new TagInfoLong( "Other Image Start", 0x0201, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - public static final TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_MAKER_NOTES = new TagInfoLong( + TagInfoLong EXIF_TAG_PREVIEW_IMAGE_LENGTH_MAKER_NOTES = new TagInfoLong( "Preview Image Length", 0x0202, 1, TiffDirectoryType.EXIF_DIRECTORY_MAKER_NOTES); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_SUB_IFD = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_SUB_IFD = new TagInfoLong( "Jpg From Raw Length", 0x0202, 1, TiffDirectoryType.EXIF_DIRECTORY_SUB_IFD); - public static final TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_IFD2 = new TagInfoLong( + TagInfoLong EXIF_TAG_JPG_FROM_RAW_LENGTH_IFD2 = new TagInfoLong( "Jpg From Raw Length", 0x0202, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD2); - public static final TagInfoLong EXIF_TAG_OTHER_IMAGE_LENGTH = new TagInfoLong( + TagInfoLong EXIF_TAG_OTHER_IMAGE_LENGTH = new TagInfoLong( "Other Image Length", 0x0202, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_APPLICATION_NOTES = new TagInfoByte( + TagInfoByte EXIF_TAG_APPLICATION_NOTES = new TagInfoByte( "Application Notes", 0x02bc, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_MATTEING = new TagInfoUnknown("Matteing", + TagInfoUnknown EXIF_TAG_MATTEING = new TagInfoUnknown("Matteing", 0x80e3, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_DATA_TYPE = new TagInfoUnknown("Data Type", + TagInfoUnknown EXIF_TAG_DATA_TYPE = new TagInfoUnknown("Data Type", 0x80e4, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_IMAGE_DEPTH = new TagInfoUnknown( + TagInfoUnknown EXIF_TAG_IMAGE_DEPTH = new TagInfoUnknown( "Image Depth", 0x80e5, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_TILE_DEPTH = new TagInfoUnknown("Tile Depth", + TagInfoUnknown EXIF_TAG_TILE_DEPTH = new TagInfoUnknown("Tile Depth", 0x80e6, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_MODEL_2 = new TagInfoUnknown("Model 2", + TagInfoUnknown EXIF_TAG_MODEL_2 = new TagInfoUnknown("Model 2", 0x827d, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_EXPOSURE_TIME = new TagInfoRational( + TagInfoRational EXIF_TAG_EXPOSURE_TIME = new TagInfoRational( "Exposure Time", 0x829a, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_FNUMBER = new TagInfoRational( + TagInfoRational EXIF_TAG_FNUMBER = new TagInfoRational( "FNumber", 0x829d, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); // FIXME: other types? - public static final TagInfoLong EXIF_TAG_IPTC_NAA = new TagInfoLong("IPTC-NAA", + TagInfoLong EXIF_TAG_IPTC_NAA = new TagInfoLong("IPTC-NAA", 0x83bb, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoShort EXIF_TAG_INTERGRAPH_PACKET_DATA = new TagInfoShort( + TagInfoShort EXIF_TAG_INTERGRAPH_PACKET_DATA = new TagInfoShort( "Intergraph Packet Data", 0x847e, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_INTERGRAPH_FLAG_REGISTERS = new TagInfoLong( + TagInfoLong EXIF_TAG_INTERGRAPH_FLAG_REGISTERS = new TagInfoLong( "Intergraph Flag Registers", 0x847f, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_SITE = new TagInfoAscii("Site", 0x84e0, + TagInfoAscii EXIF_TAG_SITE = new TagInfoAscii("Site", 0x84e0, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_COLOR_SEQUENCE = new TagInfoAscii( + TagInfoAscii EXIF_TAG_COLOR_SEQUENCE = new TagInfoAscii( "Color Sequence", 0x84e1, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_IT8HEADER = new TagInfoAscii("IT8 Header", + TagInfoAscii EXIF_TAG_IT8HEADER = new TagInfoAscii("IT8 Header", 0x84e2, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_RASTER_PADDING = new TagInfoShort( + TagInfoShort EXIF_TAG_RASTER_PADDING = new TagInfoShort( "Raster Padding", 0x84e3, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_BITS_PER_RUN_LENGTH = new TagInfoShort( + TagInfoShort EXIF_TAG_BITS_PER_RUN_LENGTH = new TagInfoShort( "Bits Per Run Length", 0x84e4, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_BITS_PER_EXTENDED_RUN_LENGTH = new TagInfoShort( + TagInfoShort EXIF_TAG_BITS_PER_EXTENDED_RUN_LENGTH = new TagInfoShort( "Bits Per Extended Run Length", 0x84e5, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_COLOR_TABLE = new TagInfoByte( + TagInfoByte EXIF_TAG_COLOR_TABLE = new TagInfoByte( "Color Table", 0x84e6, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_IMAGE_COLOR_INDICATOR = new TagInfoByte( + TagInfoByte EXIF_TAG_IMAGE_COLOR_INDICATOR = new TagInfoByte( "Image Color Indicator", 0x84e7, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_BACKGROUND_COLOR_INDICATOR = new TagInfoByte( + TagInfoByte EXIF_TAG_BACKGROUND_COLOR_INDICATOR = new TagInfoByte( "Background Color Indicator", 0x84e8, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_IMAGE_COLOR_VALUE = new TagInfoByte( + TagInfoByte EXIF_TAG_IMAGE_COLOR_VALUE = new TagInfoByte( "Image Color Value", 0x84e9, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_BACKGROUND_COLOR_VALUE = new TagInfoByte( + TagInfoByte EXIF_TAG_BACKGROUND_COLOR_VALUE = new TagInfoByte( "Background Color Value", 0x84ea, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_PIXEL_INTENSITY_RANGE = new TagInfoByte( + TagInfoByte EXIF_TAG_PIXEL_INTENSITY_RANGE = new TagInfoByte( "Pixel Intensity Range", 0x84eb, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_TRANSPARENCY_INDICATOR = new TagInfoByte( + TagInfoByte EXIF_TAG_TRANSPARENCY_INDICATOR = new TagInfoByte( "Transparency Indicator", 0x84ec, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_COLOR_CHARACTERIZATION = new TagInfoAscii( + TagInfoAscii EXIF_TAG_COLOR_CHARACTERIZATION = new TagInfoAscii( "Color Characterization", 0x84ed, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLong EXIF_TAG_HCUSAGE = new TagInfoShortOrLong("HCUsage", + TagInfoShortOrLong EXIF_TAG_HCUSAGE = new TagInfoShortOrLong("HCUsage", 0x84ee, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_SEMINFO = new TagInfoAscii("SEMInfo", + TagInfoAscii EXIF_TAG_SEMINFO = new TagInfoAscii("SEMInfo", 0x8546, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoLong EXIF_TAG_AFCP_IPTC = new TagInfoLong("AFCP_IPTC", + TagInfoLong EXIF_TAG_AFCP_IPTC = new TagInfoLong("AFCP_IPTC", 0x8568, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_LEAF_DATA = new TagInfoLong("Leaf Data", + TagInfoLong EXIF_TAG_LEAF_DATA = new TagInfoLong("Leaf Data", 0x8606, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_PHOTOSHOP_SETTINGS = new TagInfoByte( + TagInfoByte EXIF_TAG_PHOTOSHOP_SETTINGS = new TagInfoByte( "Photoshop Settings", 0x8649, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_EXIF_OFFSET = new TagInfoLong( + TagInfoLong EXIF_TAG_EXIF_OFFSET = new TagInfoLong( "Exif Offset", 0x8769, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - public static final TagInfoShort EXIF_TAG_EXPOSURE_PROGRAM = new TagInfoShort( + TagInfoShort EXIF_TAG_EXPOSURE_PROGRAM = new TagInfoShort( "Exposure Program", 0x8822, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int EXPOSURE_PROGRAM_VALUE_MANUAL = 1; - public static final int EXPOSURE_PROGRAM_VALUE_PROGRAM_AE = 2; - public static final int EXPOSURE_PROGRAM_VALUE_APERTURE_PRIORITY_AE = 3; - public static final int EXPOSURE_PROGRAM_VALUE_SHUTTER_SPEED_PRIORITY_AE = 4; - public static final int EXPOSURE_PROGRAM_VALUE_CREATIVE_SLOW_SPEED = 5; - public static final int EXPOSURE_PROGRAM_VALUE_ACTION_HIGH_SPEED = 6; - public static final int EXPOSURE_PROGRAM_VALUE_PORTRAIT = 7; - public static final int EXPOSURE_PROGRAM_VALUE_LANDSCAPE = 8; - public static final TagInfoAscii EXIF_TAG_SPECTRAL_SENSITIVITY = new TagInfoAscii( + int EXPOSURE_PROGRAM_VALUE_MANUAL = 1; + int EXPOSURE_PROGRAM_VALUE_PROGRAM_AE = 2; + int EXPOSURE_PROGRAM_VALUE_APERTURE_PRIORITY_AE = 3; + int EXPOSURE_PROGRAM_VALUE_SHUTTER_SPEED_PRIORITY_AE = 4; + int EXPOSURE_PROGRAM_VALUE_CREATIVE_SLOW_SPEED = 5; + int EXPOSURE_PROGRAM_VALUE_ACTION_HIGH_SPEED = 6; + int EXPOSURE_PROGRAM_VALUE_PORTRAIT = 7; + int EXPOSURE_PROGRAM_VALUE_LANDSCAPE = 8; + TagInfoAscii EXIF_TAG_SPECTRAL_SENSITIVITY = new TagInfoAscii( "Spectral Sensitivity", 0x8824, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoLong EXIF_TAG_GPSINFO = new TagInfoLong( + TagInfoLong EXIF_TAG_GPSINFO = new TagInfoLong( "GPSInfo", 0x8825, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - public static final TagInfoShort EXIF_TAG_ISO = new TagInfoShort( + TagInfoShort EXIF_TAG_ISO = new TagInfoShort( "PhotographicSensitivity", 0x8827, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUndefined EXIF_TAG_OPTO_ELECTRIC_CONV_FACTOR = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_OPTO_ELECTRIC_CONV_FACTOR = new TagInfoUndefined( "Opto - Electric Conv Factor", 0x8828, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_LEAF_SUB_IFD = new TagInfoLong( + TagInfoLong EXIF_TAG_LEAF_SUB_IFD = new TagInfoLong( "Leaf Sub IFD", 0x888a, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_EXIF_VERSION = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_EXIF_VERSION = new TagInfoUndefined( "Exif Version", 0x9000, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_DATE_TIME_ORIGINAL = new TagInfoAscii( + TagInfoAscii EXIF_TAG_DATE_TIME_ORIGINAL = new TagInfoAscii( "Date Time Original", 0x9003, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_CREATE_DATE = new TagInfoAscii( + TagInfoAscii EXIF_TAG_CREATE_DATE = new TagInfoAscii( "Create Date", 0x9004, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUndefined EXIF_TAG_COMPONENTS_CONFIGURATION = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_COMPONENTS_CONFIGURATION = new TagInfoUndefined( "Components Configuration", 0x9101, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_COMPRESSED_BITS_PER_PIXEL = new TagInfoRational( + TagInfoRational EXIF_TAG_COMPRESSED_BITS_PER_PIXEL = new TagInfoRational( "Compressed Bits Per Pixel", 0x9102, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoSRational EXIF_TAG_SHUTTER_SPEED_VALUE = new TagInfoSRational( + TagInfoSRational EXIF_TAG_SHUTTER_SPEED_VALUE = new TagInfoSRational( "Shutter Speed Value", 0x9201, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_APERTURE_VALUE = new TagInfoRational( + TagInfoRational EXIF_TAG_APERTURE_VALUE = new TagInfoRational( "Aperture Value", 0x9202, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoSRational EXIF_TAG_BRIGHTNESS_VALUE = new TagInfoSRational( + TagInfoSRational EXIF_TAG_BRIGHTNESS_VALUE = new TagInfoSRational( "Brightness Value", 0x9203, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoSRational EXIF_TAG_EXPOSURE_COMPENSATION = new TagInfoSRational( + TagInfoSRational EXIF_TAG_EXPOSURE_COMPENSATION = new TagInfoSRational( "Exposure Compensation", 0x9204, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_MAX_APERTURE_VALUE = new TagInfoRational( + TagInfoRational EXIF_TAG_MAX_APERTURE_VALUE = new TagInfoRational( "Max Aperture Value", 0x9205, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_SUBJECT_DISTANCE = new TagInfoRational( + TagInfoRational EXIF_TAG_SUBJECT_DISTANCE = new TagInfoRational( "Subject Distance", 0x9206, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_METERING_MODE = new TagInfoShort( + TagInfoShort EXIF_TAG_METERING_MODE = new TagInfoShort( "Metering Mode", 0x9207, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int METERING_MODE_VALUE_AVERAGE = 1; - public static final int METERING_MODE_VALUE_CENTER_WEIGHTED_AVERAGE = 2; - public static final int METERING_MODE_VALUE_SPOT = 3; - public static final int METERING_MODE_VALUE_MULTI_SPOT = 4; - public static final int METERING_MODE_VALUE_MULTI_SEGMENT = 5; - public static final int METERING_MODE_VALUE_PARTIAL = 6; - public static final int METERING_MODE_VALUE_OTHER = 255; - public static final TagInfoShort EXIF_TAG_LIGHT_SOURCE = new TagInfoShort( + int METERING_MODE_VALUE_AVERAGE = 1; + int METERING_MODE_VALUE_CENTER_WEIGHTED_AVERAGE = 2; + int METERING_MODE_VALUE_SPOT = 3; + int METERING_MODE_VALUE_MULTI_SPOT = 4; + int METERING_MODE_VALUE_MULTI_SEGMENT = 5; + int METERING_MODE_VALUE_PARTIAL = 6; + int METERING_MODE_VALUE_OTHER = 255; + TagInfoShort EXIF_TAG_LIGHT_SOURCE = new TagInfoShort( "Light Source", 0x9208, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int LIGHT_SOURCE_VALUE_DAYLIGHT = 1; - public static final int LIGHT_SOURCE_VALUE_FLUORESCENT = 2; - public static final int LIGHT_SOURCE_VALUE_TUNGSTEN = 3; - public static final int LIGHT_SOURCE_VALUE_FLASH = 4; - public static final int LIGHT_SOURCE_VALUE_FINE_WEATHER = 9; - public static final int LIGHT_SOURCE_VALUE_CLOUDY = 10; - public static final int LIGHT_SOURCE_VALUE_SHADE = 11; - public static final int LIGHT_SOURCE_VALUE_DAYLIGHT_FLUORESCENT = 12; - public static final int LIGHT_SOURCE_VALUE_DAY_WHITE_FLUORESCENT = 13; - public static final int LIGHT_SOURCE_VALUE_COOL_WHITE_FLUORESCENT = 14; - public static final int LIGHT_SOURCE_VALUE_WHITE_FLUORESCENT = 15; - public static final int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_A = 17; - public static final int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_B = 18; - public static final int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_C = 19; - public static final int LIGHT_SOURCE_VALUE_D55 = 20; - public static final int LIGHT_SOURCE_VALUE_D65 = 21; - public static final int LIGHT_SOURCE_VALUE_D75 = 22; - public static final int LIGHT_SOURCE_VALUE_D50 = 23; - public static final int LIGHT_SOURCE_VALUE_ISO_STUDIO_TUNGSTEN = 24; - public static final int LIGHT_SOURCE_VALUE_OTHER = 255; - public static final TagInfoShort EXIF_TAG_FLASH = new TagInfoShort( + int LIGHT_SOURCE_VALUE_DAYLIGHT = 1; + int LIGHT_SOURCE_VALUE_FLUORESCENT = 2; + int LIGHT_SOURCE_VALUE_TUNGSTEN = 3; + int LIGHT_SOURCE_VALUE_FLASH = 4; + int LIGHT_SOURCE_VALUE_FINE_WEATHER = 9; + int LIGHT_SOURCE_VALUE_CLOUDY = 10; + int LIGHT_SOURCE_VALUE_SHADE = 11; + int LIGHT_SOURCE_VALUE_DAYLIGHT_FLUORESCENT = 12; + int LIGHT_SOURCE_VALUE_DAY_WHITE_FLUORESCENT = 13; + int LIGHT_SOURCE_VALUE_COOL_WHITE_FLUORESCENT = 14; + int LIGHT_SOURCE_VALUE_WHITE_FLUORESCENT = 15; + int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_A = 17; + int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_B = 18; + int LIGHT_SOURCE_VALUE_STANDARD_LIGHT_C = 19; + int LIGHT_SOURCE_VALUE_D55 = 20; + int LIGHT_SOURCE_VALUE_D65 = 21; + int LIGHT_SOURCE_VALUE_D75 = 22; + int LIGHT_SOURCE_VALUE_D50 = 23; + int LIGHT_SOURCE_VALUE_ISO_STUDIO_TUNGSTEN = 24; + int LIGHT_SOURCE_VALUE_OTHER = 255; + TagInfoShort EXIF_TAG_FLASH = new TagInfoShort( "Flash", 0x9209, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int FLASH_VALUE_NO_FLASH = 0x0; - public static final int FLASH_VALUE_FIRED = 0x1; - public static final int FLASH_VALUE_FIRED_RETURN_NOT_DETECTED = 0x5; - public static final int FLASH_VALUE_FIRED_RETURN_DETECTED = 0x7; - public static final int FLASH_VALUE_ON_DID_NOT_FIRE = 0x8; - public static final int FLASH_VALUE_ON = 0x9; - public static final int FLASH_VALUE_ON_RETURN_NOT_DETECTED = 0xd; - public static final int FLASH_VALUE_ON_RETURN_DETECTED = 0xf; - public static final int FLASH_VALUE_OFF = 0x10; - public static final int FLASH_VALUE_OFF_DID_NOT_FIRE_RETURN_NOT_DETECTED = 0x14; - public static final int FLASH_VALUE_AUTO_DID_NOT_FIRE = 0x18; - public static final int FLASH_VALUE_AUTO_FIRED = 0x19; - public static final int FLASH_VALUE_AUTO_FIRED_RETURN_NOT_DETECTED = 0x1d; - public static final int FLASH_VALUE_AUTO_FIRED_RETURN_DETECTED = 0x1f; - public static final int FLASH_VALUE_NO_FLASH_FUNCTION = 0x20; - public static final int FLASH_VALUE_OFF_NO_FLASH_FUNCTION = 0x30; - public static final int FLASH_VALUE_FIRED_RED_EYE_REDUCTION = 0x41; - public static final int FLASH_VALUE_FIRED_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x45; - public static final int FLASH_VALUE_FIRED_RED_EYE_REDUCTION_RETURN_DETECTED = 0x47; - public static final int FLASH_VALUE_ON_RED_EYE_REDUCTION = 0x49; - public static final int FLASH_VALUE_ON_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x4d; - public static final int FLASH_VALUE_ON_RED_EYE_REDUCTION_RETURN_DETECTED = 0x4f; - public static final int FLASH_VALUE_OFF_RED_EYE_REDUCTION = 0x50; - public static final int FLASH_VALUE_AUTO_DID_NOT_FIRE_RED_EYE_REDUCTION = 0x58; - public static final int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION = 0x59; - public static final int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x5d; - public static final int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION_RETURN_DETECTED = 0x5f; - public static final TagInfoRational EXIF_TAG_FOCAL_LENGTH = new TagInfoRational( + int FLASH_VALUE_NO_FLASH = 0x0; + int FLASH_VALUE_FIRED = 0x1; + int FLASH_VALUE_FIRED_RETURN_NOT_DETECTED = 0x5; + int FLASH_VALUE_FIRED_RETURN_DETECTED = 0x7; + int FLASH_VALUE_ON_DID_NOT_FIRE = 0x8; + int FLASH_VALUE_ON = 0x9; + int FLASH_VALUE_ON_RETURN_NOT_DETECTED = 0xd; + int FLASH_VALUE_ON_RETURN_DETECTED = 0xf; + int FLASH_VALUE_OFF = 0x10; + int FLASH_VALUE_OFF_DID_NOT_FIRE_RETURN_NOT_DETECTED = 0x14; + int FLASH_VALUE_AUTO_DID_NOT_FIRE = 0x18; + int FLASH_VALUE_AUTO_FIRED = 0x19; + int FLASH_VALUE_AUTO_FIRED_RETURN_NOT_DETECTED = 0x1d; + int FLASH_VALUE_AUTO_FIRED_RETURN_DETECTED = 0x1f; + int FLASH_VALUE_NO_FLASH_FUNCTION = 0x20; + int FLASH_VALUE_OFF_NO_FLASH_FUNCTION = 0x30; + int FLASH_VALUE_FIRED_RED_EYE_REDUCTION = 0x41; + int FLASH_VALUE_FIRED_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x45; + int FLASH_VALUE_FIRED_RED_EYE_REDUCTION_RETURN_DETECTED = 0x47; + int FLASH_VALUE_ON_RED_EYE_REDUCTION = 0x49; + int FLASH_VALUE_ON_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x4d; + int FLASH_VALUE_ON_RED_EYE_REDUCTION_RETURN_DETECTED = 0x4f; + int FLASH_VALUE_OFF_RED_EYE_REDUCTION = 0x50; + int FLASH_VALUE_AUTO_DID_NOT_FIRE_RED_EYE_REDUCTION = 0x58; + int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION = 0x59; + int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION_RETURN_NOT_DETECTED = 0x5d; + int FLASH_VALUE_AUTO_FIRED_RED_EYE_REDUCTION_RETURN_DETECTED = 0x5f; + TagInfoRational EXIF_TAG_FOCAL_LENGTH = new TagInfoRational( "Focal Length", 0x920a, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_SUBJECT_LOCATION_1 = new TagInfoShort( + TagInfoShort EXIF_TAG_SUBJECT_LOCATION_1 = new TagInfoShort( "Subject Location", 0x9214, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoDouble EXIF_TAG_STO_NITS = new TagInfoDouble("Sto Nits", + TagInfoDouble EXIF_TAG_STO_NITS = new TagInfoDouble("Sto Nits", 0x923f, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); // skipping Maker Note! - public static final TagInfoUndefined EXIF_TAG_MAKER_NOTE = new TagInfoUndefined("Maker Note", + TagInfoUndefined EXIF_TAG_MAKER_NOTE = new TagInfoUndefined("Maker Note", 0x927c, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoGpsText EXIF_TAG_USER_COMMENT = new TagInfoGpsText( + TagInfoGpsText EXIF_TAG_USER_COMMENT = new TagInfoGpsText( "UserComment", 0x9286, FIELD_TYPE_UNDEFINED, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SUB_SEC_TIME = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SUB_SEC_TIME = new TagInfoAscii( "Sub Sec Time", 0x9290, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SUB_SEC_TIME_ORIGINAL = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SUB_SEC_TIME_ORIGINAL = new TagInfoAscii( "Sub Sec Time Original", 0x9291, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SUB_SEC_TIME_DIGITIZED = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SUB_SEC_TIME_DIGITIZED = new TagInfoAscii( "Sub Sec Time Digitized", 0x9292, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUndefined EXIF_TAG_FLASHPIX_VERSION = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_FLASHPIX_VERSION = new TagInfoUndefined( "Flashpix Version", 0xa000, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_EXIF_IMAGE_WIDTH = new TagInfoShort( + TagInfoShort EXIF_TAG_EXIF_IMAGE_WIDTH = new TagInfoShort( "Exif Image Width", 0xa002, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_EXIF_IMAGE_LENGTH = new TagInfoShort( + TagInfoShort EXIF_TAG_EXIF_IMAGE_LENGTH = new TagInfoShort( "Exif Image Length", 0xa003, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_RELATED_SOUND_FILE = new TagInfoAscii( + TagInfoAscii EXIF_TAG_RELATED_SOUND_FILE = new TagInfoAscii( "Related Sound File", 0xa004, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoLong EXIF_TAG_INTEROP_OFFSET = new TagInfoLong( + TagInfoLong EXIF_TAG_INTEROP_OFFSET = new TagInfoLong( "Interop Offset", 0xa005, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - public static final TagInfoRational EXIF_TAG_FLASH_ENERGY_EXIF_IFD = new TagInfoRational( + TagInfoRational EXIF_TAG_FLASH_ENERGY_EXIF_IFD = new TagInfoRational( "Flash Energy", 0xa20b, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUndefined EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE_2 = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE_2 = new TagInfoUndefined( "Spatial Frequency Response", 0xa20c, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_NOISE_2 = new TagInfoUnknown("Noise", 0xa20d, + TagInfoUnknown EXIF_TAG_NOISE_2 = new TagInfoUnknown("Noise", 0xa20d, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_FOCAL_PLANE_XRESOLUTION_EXIF_IFD = new TagInfoRational( + TagInfoRational EXIF_TAG_FOCAL_PLANE_XRESOLUTION_EXIF_IFD = new TagInfoRational( "Focal Plane XResolution", 0xa20e, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_FOCAL_PLANE_YRESOLUTION_EXIF_IFD = new TagInfoRational( + TagInfoRational EXIF_TAG_FOCAL_PLANE_YRESOLUTION_EXIF_IFD = new TagInfoRational( "Focal Plane YResolution", 0xa20f, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD = new TagInfoShort( + TagInfoShort EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD = new TagInfoShort( "Focal Plane Resolution Unit", 0xa210, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_NONE = 1; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_INCHES = 2; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_CM = 3; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_MM = 4; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_UM = 5; - public static final TagInfoUnknown EXIF_TAG_IMAGE_NUMBER = new TagInfoUnknown( + int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_NONE = 1; + int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_INCHES = 2; + int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_CM = 3; + int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_MM = 4; + int FOCAL_PLANE_RESOLUTION_UNIT_EXIF_IFD_VALUE_UM = 5; + TagInfoUnknown EXIF_TAG_IMAGE_NUMBER = new TagInfoUnknown( "Image Number", 0xa211, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_SECURITY_CLASSIFICATION = new TagInfoUnknown( + TagInfoUnknown EXIF_TAG_SECURITY_CLASSIFICATION = new TagInfoUnknown( "Security Classification", 0xa212, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUnknown EXIF_TAG_IMAGE_HISTORY = new TagInfoUnknown( + TagInfoUnknown EXIF_TAG_IMAGE_HISTORY = new TagInfoUnknown( "Image History", 0xa213, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_SUBJECT_LOCATION_2 = new TagInfoShort( + TagInfoShort EXIF_TAG_SUBJECT_LOCATION_2 = new TagInfoShort( "Subject Location", 0xa214, 2, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_EXPOSURE_INDEX_EXIF_IFD = new TagInfoRational( + TagInfoRational EXIF_TAG_EXPOSURE_INDEX_EXIF_IFD = new TagInfoRational( "Exposure Index", 0xa215, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUnknown EXIF_TAG_TIFF_EPSTANDARD_ID_2 = new TagInfoUnknown( + TagInfoUnknown EXIF_TAG_TIFF_EPSTANDARD_ID_2 = new TagInfoUnknown( "TIFF-EPStandard ID", 0xa216, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_SENSING_METHOD_EXIF_IFD = new TagInfoShort( + TagInfoShort EXIF_TAG_SENSING_METHOD_EXIF_IFD = new TagInfoShort( "Sensing Method", 0xa217, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int SENSING_METHOD_EXIF_IFD_VALUE_NOT_DEFINED = 1; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_ONE_CHIP_COLOR_AREA = 2; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_TWO_CHIP_COLOR_AREA = 3; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_THREE_CHIP_COLOR_AREA = 4; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_COLOR_SEQUENTIAL_AREA = 5; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_TRILINEAR = 7; - public static final int SENSING_METHOD_EXIF_IFD_VALUE_COLOR_SEQUENTIAL_LINEAR = 8; - public static final TagInfoUndefined EXIF_TAG_FILE_SOURCE = new TagInfoUndefined( + int SENSING_METHOD_EXIF_IFD_VALUE_NOT_DEFINED = 1; + int SENSING_METHOD_EXIF_IFD_VALUE_ONE_CHIP_COLOR_AREA = 2; + int SENSING_METHOD_EXIF_IFD_VALUE_TWO_CHIP_COLOR_AREA = 3; + int SENSING_METHOD_EXIF_IFD_VALUE_THREE_CHIP_COLOR_AREA = 4; + int SENSING_METHOD_EXIF_IFD_VALUE_COLOR_SEQUENTIAL_AREA = 5; + int SENSING_METHOD_EXIF_IFD_VALUE_TRILINEAR = 7; + int SENSING_METHOD_EXIF_IFD_VALUE_COLOR_SEQUENTIAL_LINEAR = 8; + TagInfoUndefined EXIF_TAG_FILE_SOURCE = new TagInfoUndefined( "File Source", 0xa300, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int FILE_SOURCE_VALUE_FILM_SCANNER = 1; - public static final int FILE_SOURCE_VALUE_REFLECTION_PRINT_SCANNER = 2; - public static final int FILE_SOURCE_VALUE_DIGITAL_CAMERA = 3; - public static final TagInfoUndefined EXIF_TAG_SCENE_TYPE = new TagInfoUndefined("Scene Type", + int FILE_SOURCE_VALUE_FILM_SCANNER = 1; + int FILE_SOURCE_VALUE_REFLECTION_PRINT_SCANNER = 2; + int FILE_SOURCE_VALUE_DIGITAL_CAMERA = 3; + TagInfoUndefined EXIF_TAG_SCENE_TYPE = new TagInfoUndefined("Scene Type", 0xa301, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUndefined EXIF_TAG_CFAPATTERN = new TagInfoUndefined("CFAPattern", + TagInfoUndefined EXIF_TAG_CFAPATTERN = new TagInfoUndefined("CFAPattern", 0xa302, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_CUSTOM_RENDERED = new TagInfoShort( + TagInfoShort EXIF_TAG_CUSTOM_RENDERED = new TagInfoShort( "Custom Rendered", 0xa401, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int CUSTOM_RENDERED_VALUE_NORMAL = 0; - public static final int CUSTOM_RENDERED_VALUE_CUSTOM = 1; - public static final TagInfoShort EXIF_TAG_EXPOSURE_MODE = new TagInfoShort( + int CUSTOM_RENDERED_VALUE_NORMAL = 0; + int CUSTOM_RENDERED_VALUE_CUSTOM = 1; + TagInfoShort EXIF_TAG_EXPOSURE_MODE = new TagInfoShort( "Exposure Mode", 0xa402, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int EXPOSURE_MODE_VALUE_AUTO = 0; - public static final int EXPOSURE_MODE_VALUE_MANUAL = 1; - public static final int EXPOSURE_MODE_VALUE_AUTO_BRACKET = 2; - public static final TagInfoShort EXIF_TAG_WHITE_BALANCE_1 = new TagInfoShort( + int EXPOSURE_MODE_VALUE_AUTO = 0; + int EXPOSURE_MODE_VALUE_MANUAL = 1; + int EXPOSURE_MODE_VALUE_AUTO_BRACKET = 2; + TagInfoShort EXIF_TAG_WHITE_BALANCE_1 = new TagInfoShort( "White Balance", 0xa403, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int WHITE_BALANCE_1_VALUE_AUTO = 0; - public static final int WHITE_BALANCE_1_VALUE_MANUAL = 1; - public static final TagInfoRational EXIF_TAG_DIGITAL_ZOOM_RATIO = new TagInfoRational( + int WHITE_BALANCE_1_VALUE_AUTO = 0; + int WHITE_BALANCE_1_VALUE_MANUAL = 1; + TagInfoRational EXIF_TAG_DIGITAL_ZOOM_RATIO = new TagInfoRational( "Digital Zoom Ratio", 0xa404, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_FOCAL_LENGTH_IN_35MM_FORMAT = new TagInfoShort( + TagInfoShort EXIF_TAG_FOCAL_LENGTH_IN_35MM_FORMAT = new TagInfoShort( "Focal Length In 3 5mm Format", 0xa405, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_SCENE_CAPTURE_TYPE = new TagInfoShort( + TagInfoShort EXIF_TAG_SCENE_CAPTURE_TYPE = new TagInfoShort( "Scene Capture Type", 0xa406, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int SCENE_CAPTURE_TYPE_VALUE_STANDARD = 0; - public static final int SCENE_CAPTURE_TYPE_VALUE_LANDSCAPE = 1; - public static final int SCENE_CAPTURE_TYPE_VALUE_PORTRAIT = 2; - public static final int SCENE_CAPTURE_TYPE_VALUE_NIGHT = 3; - public static final TagInfoShort EXIF_TAG_GAIN_CONTROL = new TagInfoShort( + int SCENE_CAPTURE_TYPE_VALUE_STANDARD = 0; + int SCENE_CAPTURE_TYPE_VALUE_LANDSCAPE = 1; + int SCENE_CAPTURE_TYPE_VALUE_PORTRAIT = 2; + int SCENE_CAPTURE_TYPE_VALUE_NIGHT = 3; + TagInfoShort EXIF_TAG_GAIN_CONTROL = new TagInfoShort( "Gain Control", 0xa407, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int GAIN_CONTROL_VALUE_NONE = 0; - public static final int GAIN_CONTROL_VALUE_LOW_GAIN_UP = 1; - public static final int GAIN_CONTROL_VALUE_HIGH_GAIN_UP = 2; - public static final int GAIN_CONTROL_VALUE_LOW_GAIN_DOWN = 3; - public static final int GAIN_CONTROL_VALUE_HIGH_GAIN_DOWN = 4; - public static final TagInfoShort EXIF_TAG_CONTRAST_1 = new TagInfoShort("Contrast", + int GAIN_CONTROL_VALUE_NONE = 0; + int GAIN_CONTROL_VALUE_LOW_GAIN_UP = 1; + int GAIN_CONTROL_VALUE_HIGH_GAIN_UP = 2; + int GAIN_CONTROL_VALUE_LOW_GAIN_DOWN = 3; + int GAIN_CONTROL_VALUE_HIGH_GAIN_DOWN = 4; + TagInfoShort EXIF_TAG_CONTRAST_1 = new TagInfoShort("Contrast", 0xa408, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int CONTRAST_1_VALUE_NORMAL = 0; - public static final int CONTRAST_1_VALUE_LOW = 1; - public static final int CONTRAST_1_VALUE_HIGH = 2; - public static final TagInfoShort EXIF_TAG_SATURATION_1 = new TagInfoShort( + int CONTRAST_1_VALUE_NORMAL = 0; + int CONTRAST_1_VALUE_LOW = 1; + int CONTRAST_1_VALUE_HIGH = 2; + TagInfoShort EXIF_TAG_SATURATION_1 = new TagInfoShort( "Saturation", 0xa409, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int SATURATION_1_VALUE_NORMAL = 0; - public static final int SATURATION_1_VALUE_LOW = 1; - public static final int SATURATION_1_VALUE_HIGH = 2; - public static final TagInfoShort EXIF_TAG_SHARPNESS_1 = new TagInfoShort("Sharpness", + int SATURATION_1_VALUE_NORMAL = 0; + int SATURATION_1_VALUE_LOW = 1; + int SATURATION_1_VALUE_HIGH = 2; + TagInfoShort EXIF_TAG_SHARPNESS_1 = new TagInfoShort("Sharpness", 0xa40a, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int SHARPNESS_1_VALUE_NORMAL = 0; - public static final int SHARPNESS_1_VALUE_SOFT = 1; - public static final int SHARPNESS_1_VALUE_HARD = 2; - public static final TagInfoUndefined EXIF_TAG_DEVICE_SETTING_DESCRIPTION = new TagInfoUndefined( + int SHARPNESS_1_VALUE_NORMAL = 0; + int SHARPNESS_1_VALUE_SOFT = 1; + int SHARPNESS_1_VALUE_HARD = 2; + TagInfoUndefined EXIF_TAG_DEVICE_SETTING_DESCRIPTION = new TagInfoUndefined( "Device Setting Description", 0xa40b, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_SUBJECT_DISTANCE_RANGE = new TagInfoShort( + TagInfoShort EXIF_TAG_SUBJECT_DISTANCE_RANGE = new TagInfoShort( "Subject Distance Range", 0xa40c, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final int SUBJECT_DISTANCE_RANGE_VALUE_MACRO = 1; - public static final int SUBJECT_DISTANCE_RANGE_VALUE_CLOSE = 2; - public static final int SUBJECT_DISTANCE_RANGE_VALUE_DISTANT = 3; - public static final TagInfoAscii EXIF_TAG_IMAGE_UNIQUE_ID = new TagInfoAscii( + int SUBJECT_DISTANCE_RANGE_VALUE_MACRO = 1; + int SUBJECT_DISTANCE_RANGE_VALUE_CLOSE = 2; + int SUBJECT_DISTANCE_RANGE_VALUE_DISTANT = 3; + TagInfoAscii EXIF_TAG_IMAGE_UNIQUE_ID = new TagInfoAscii( "Image Unique ID", 0xa420, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_GAMMA = new TagInfoRational("Gamma", 0xa500, + TagInfoRational EXIF_TAG_GAMMA = new TagInfoRational("Gamma", 0xa500, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoUnknown EXIF_TAG_ANNOTATIONS = new TagInfoUnknown( + TagInfoUnknown EXIF_TAG_ANNOTATIONS = new TagInfoUnknown( "Annotations", 0xc44f, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_PRINT_IM = new TagInfoUndefined("Print IM", + TagInfoUndefined EXIF_TAG_PRINT_IM = new TagInfoUndefined("Print IM", 0xc4a5, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoByte EXIF_TAG_DNG_ADOBE_DATA = new TagInfoByte( + TagInfoByte EXIF_TAG_DNG_ADOBE_DATA = new TagInfoByte( "DNG Adobe Data", 0xc634, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_DNG_PENTAX_DATA = new TagInfoByte( + TagInfoByte EXIF_TAG_DNG_PENTAX_DATA = new TagInfoByte( "DNG Pentax Data", 0xc634, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSLong EXIF_TAG_OFFSET_SCHEMA = new TagInfoSLong( + TagInfoSLong EXIF_TAG_OFFSET_SCHEMA = new TagInfoSLong( "Offset Schema", 0xea1d, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_OWNER_NAME = new TagInfoAscii("Owner Name", + TagInfoAscii EXIF_TAG_OWNER_NAME = new TagInfoAscii("Owner Name", 0xfde8, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SERIAL_NUMBER = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SERIAL_NUMBER = new TagInfoAscii( "Serial Number", 0xfde9, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_LENS = new TagInfoAscii("Lens", 0xfdea, + TagInfoAscii EXIF_TAG_LENS = new TagInfoAscii("Lens", 0xfdea, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_RAW_FILE = new TagInfoAscii("Raw File", + TagInfoAscii EXIF_TAG_RAW_FILE = new TagInfoAscii("Raw File", 0xfe4c, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_CONVERTER = new TagInfoAscii("Converter", + TagInfoAscii EXIF_TAG_CONVERTER = new TagInfoAscii("Converter", 0xfe4d, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_WHITE_BALANCE_2 = new TagInfoAscii( + TagInfoAscii EXIF_TAG_WHITE_BALANCE_2 = new TagInfoAscii( "White Balance", 0xfe4e, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_EXPOSURE = new TagInfoAscii("Exposure", + TagInfoAscii EXIF_TAG_EXPOSURE = new TagInfoAscii("Exposure", 0xfe51, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SHADOWS = new TagInfoAscii("Shadows", + TagInfoAscii EXIF_TAG_SHADOWS = new TagInfoAscii("Shadows", 0xfe52, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_BRIGHTNESS = new TagInfoAscii("Brightness", + TagInfoAscii EXIF_TAG_BRIGHTNESS = new TagInfoAscii("Brightness", 0xfe53, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_CONTRAST_2 = new TagInfoAscii("Contrast", + TagInfoAscii EXIF_TAG_CONTRAST_2 = new TagInfoAscii("Contrast", 0xfe54, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SATURATION_2 = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SATURATION_2 = new TagInfoAscii( "Saturation", 0xfe55, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SHARPNESS_2 = new TagInfoAscii("Sharpness", + TagInfoAscii EXIF_TAG_SHARPNESS_2 = new TagInfoAscii("Sharpness", 0xfe56, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SMOOTHNESS = new TagInfoAscii("Smoothness", + TagInfoAscii EXIF_TAG_SMOOTHNESS = new TagInfoAscii("Smoothness", 0xfe57, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_MOIRE_FILTER = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MOIRE_FILTER = new TagInfoAscii( "Moire Filter", 0xfe58, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final List ALL_EXIF_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_INTEROP_INDEX, EXIF_TAG_INTEROP_VERSION, + List ALL_EXIF_TAGS = + List.of(EXIF_TAG_INTEROP_INDEX, EXIF_TAG_INTEROP_VERSION, EXIF_TAG_PROCESSING_SOFTWARE, EXIF_TAG_SOFTWARE, EXIF_TAG_PREVIEW_IMAGE_START_IFD0, @@ -593,8 +578,6 @@ public interface ExifTagConstants EXIF_TAG_SHADOWS, EXIF_TAG_BRIGHTNESS, EXIF_TAG_CONTRAST_2, EXIF_TAG_SATURATION_2, EXIF_TAG_SHARPNESS_2, EXIF_TAG_SMOOTHNESS, EXIF_TAG_MOIRE_FILTER, - - EXIF_TAG_USER_COMMENT, // - - EXIF_TAG_MAKER_NOTE)); + EXIF_TAG_USER_COMMENT, + EXIF_TAG_MAKER_NOTE); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GdalLibraryTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GdalLibraryTagConstants.java index 8a41f464..0ba26f32 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GdalLibraryTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GdalLibraryTagConstants.java @@ -1,12 +1,10 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; +import java.util.List; + /** * GDAL library. *
@@ -15,16 +13,15 @@ * http://www.awaresystems.be/imaging/tiff/tifftags/gdal_nodata.html */ public interface GdalLibraryTagConstants { - public static final TagInfoAscii EXIF_TAG_GDALMETADATA = new TagInfoAscii( + TagInfoAscii EXIF_TAG_GDALMETADATA = new TagInfoAscii( "GDALMetadata", 0xa480, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_GDALNO_DATA = new TagInfoAscii( + TagInfoAscii EXIF_TAG_GDALNO_DATA = new TagInfoAscii( "GDALNo Data", 0xa481, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_GDAL_LIBRARY_TAGS = - Collections.unmodifiableList(Arrays.asList(new TagInfo[] { - EXIF_TAG_GDALMETADATA, - EXIF_TAG_GDALNO_DATA})); + List ALL_GDAL_LIBRARY_TAGS = + List.of(EXIF_TAG_GDALMETADATA, + EXIF_TAG_GDALNO_DATA); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GeoTiffTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GeoTiffTagConstants.java index 6ae3ec62..fef58495 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GeoTiffTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GeoTiffTagConstants.java @@ -1,56 +1,53 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoDouble; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; +import java.util.List; + /** * Geo Tiff. *
* http://www.remotesensing.org/geotiff/spec/contents.html */ public interface GeoTiffTagConstants { - public static final TagInfoDouble EXIF_TAG_MODEL_PIXEL_SCALE = new TagInfoDouble( + TagInfoDouble EXIF_TAG_MODEL_PIXEL_SCALE = new TagInfoDouble( "Model Pixel Scale", 0x830e, 3, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoDouble EXIF_TAG_INTERGRAPH_MATRIX = new TagInfoDouble( + TagInfoDouble EXIF_TAG_INTERGRAPH_MATRIX = new TagInfoDouble( "Intergraph Matrix", 0x8480, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoDouble EXIF_TAG_MODEL_TIE_POINT = new TagInfoDouble( + TagInfoDouble EXIF_TAG_MODEL_TIE_POINT = new TagInfoDouble( "Model Tie Point", 0x8482, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoDouble EXIF_TAG_MODEL_TRANSFORMATION = new TagInfoDouble( + TagInfoDouble EXIF_TAG_MODEL_TRANSFORMATION = new TagInfoDouble( "Model Transformation", 0x85d8, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_GEO_TIFF_DIRECTORY = new TagInfoShort( + TagInfoShort EXIF_TAG_GEO_TIFF_DIRECTORY = new TagInfoShort( "Geo Tiff Directory", 0x87af, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoDouble EXIF_TAG_GEO_TIFF_DOUBLE_PARAMS = new TagInfoDouble( + TagInfoDouble EXIF_TAG_GEO_TIFF_DOUBLE_PARAMS = new TagInfoDouble( "Geo Tiff Double Params", 0x87b0, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_GEO_TIFF_ASCII_PARAMS = new TagInfoAscii( + TagInfoAscii EXIF_TAG_GEO_TIFF_ASCII_PARAMS = new TagInfoAscii( "Geo Tiff Ascii Params", 0x87b1, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_GEO_TIFF_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_MODEL_PIXEL_SCALE, + List ALL_GEO_TIFF_TAGS = + List.of(EXIF_TAG_MODEL_PIXEL_SCALE, EXIF_TAG_INTERGRAPH_MATRIX, EXIF_TAG_MODEL_TIE_POINT, EXIF_TAG_MODEL_TRANSFORMATION, EXIF_TAG_GEO_TIFF_DIRECTORY, EXIF_TAG_GEO_TIFF_DOUBLE_PARAMS, - EXIF_TAG_GEO_TIFF_ASCII_PARAMS)); + EXIF_TAG_GEO_TIFF_ASCII_PARAMS); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java index d15a7c94..b663981d 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/GpsTagConstants.java @@ -16,207 +16,172 @@ */ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoGpsText; +import java.util.List; public interface GpsTagConstants extends TiffFieldTypeConstants { - public static final TagInfoByte GPS_TAG_GPS_VERSION_ID = new TagInfoByte( + TagInfoByte GPS_TAG_GPS_VERSION_ID = new TagInfoByte( "GPS Version ID", 0x0000, 4, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_LATITUDE_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_LATITUDE_REF = new TagInfoAscii( "GPS Latitude Ref", 0x0001, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_LATITUDE_REF_VALUE_NORTH = "N"; - public static final String GPS_TAG_GPS_LATITUDE_REF_VALUE_SOUTH = "S"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_LATITUDE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_LATITUDE = new TagInfoRational( "GPS Latitude", 0x0002, 3, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_LONGITUDE_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_LONGITUDE_REF = new TagInfoAscii( "GPS Longitude Ref", 0x0003, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_LONGITUDE_REF_VALUE_EAST = "E"; - public static final String GPS_TAG_GPS_LONGITUDE_REF_VALUE_WEST = "W"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_LONGITUDE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_LONGITUDE = new TagInfoRational( "GPS Longitude", 0x0004, 3, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoByte GPS_TAG_GPS_ALTITUDE_REF = new TagInfoByte( + TagInfoByte GPS_TAG_GPS_ALTITUDE_REF = new TagInfoByte( "GPS Altitude Ref", 0x0005, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final int GPS_TAG_GPS_ALTITUDE_REF_VALUE_ABOVE_SEA_LEVEL = 0; - public static final int GPS_TAG_GPS_ALTITUDE_REF_VALUE_BELOW_SEA_LEVEL = 1; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_ALTITUDE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_ALTITUDE = new TagInfoRational( "GPS Altitude", 0x0006, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_TIME_STAMP = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_TIME_STAMP = new TagInfoRational( "GPS Time Stamp", 0x0007, 3, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_SATELLITES = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_SATELLITES = new TagInfoAscii( "GPS Satellites", 0x0008, -1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_STATUS = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_STATUS = new TagInfoAscii( "GPS Status", 0x0009, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_STATUS_VALUE_MEASUREMENT_IN_PROGRESS = "A"; - public static final String GPS_TAG_GPS_STATUS_VALUE_MEASUREMENT_INTEROPERABILITY = "V"; // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_MEASURE_MODE = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_MEASURE_MODE = new TagInfoAscii( "GPS Measure Mode", 0x000a, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final int GPS_TAG_GPS_MEASURE_MODE_VALUE_2_DIMENSIONAL_MEASUREMENT = 2; - public static final int GPS_TAG_GPS_MEASURE_MODE_VALUE_3_DIMENSIONAL_MEASUREMENT = 3; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_DOP = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_DOP = new TagInfoRational( "GPS DOP", 0x000b, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_SPEED_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_SPEED_REF = new TagInfoAscii( "GPS Speed Ref", 0x000c, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_SPEED_REF_VALUE_KMPH = "K"; - public static final String GPS_TAG_GPS_SPEED_REF_VALUE_MPH = "M"; - public static final String GPS_TAG_GPS_SPEED_REF_VALUE_KNOTS = "N"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_SPEED = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_SPEED = new TagInfoRational( "GPS Speed", 0x000d, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_TRACK_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_TRACK_REF = new TagInfoAscii( "GPS Track Ref", 0x000e, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_TRACK_REF_VALUE_MAGNETIC_NORTH = "M"; - public static final String GPS_TAG_GPS_TRACK_REF_VALUE_TRUE_NORTH = "T"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_TRACK = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_TRACK = new TagInfoRational( "GPS Track", 0x000f, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_IMG_DIRECTION_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_IMG_DIRECTION_REF = new TagInfoAscii( "GPS Img Direction Ref", 0x0010, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_IMG_DIRECTION_REF_VALUE_MAGNETIC_NORTH = "M"; - public static final String GPS_TAG_GPS_IMG_DIRECTION_REF_VALUE_TRUE_NORTH = "T"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_IMG_DIRECTION = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_IMG_DIRECTION = new TagInfoRational( "GPS Img Direction", 0x0011, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_MAP_DATUM = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_MAP_DATUM = new TagInfoAscii( "GPS Map Datum", 0x0012, -1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_DEST_LATITUDE_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_DEST_LATITUDE_REF = new TagInfoAscii( "GPS Dest Latitude Ref", 0x0013, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_NORTH = "N"; - public static final String GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_SOUTH = "S"; + String GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_NORTH = "N"; + String GPS_TAG_GPS_DEST_LATITUDE_REF_VALUE_SOUTH = "S"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_DEST_LATITUDE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_DEST_LATITUDE = new TagInfoRational( "GPS Dest Latitude", 0x0014, 3, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_DEST_LONGITUDE_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_DEST_LONGITUDE_REF = new TagInfoAscii( "GPS Dest Longitude Ref", 0x0015, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_DEST_LONGITUDE_REF_VALUE_EAST = "E"; - public static final String GPS_TAG_GPS_DEST_LONGITUDE_REF_VALUE_WEST = "W"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_DEST_LONGITUDE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_DEST_LONGITUDE = new TagInfoRational( "GPS Dest Longitude", 0x0016, 3, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_DEST_BEARING_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_DEST_BEARING_REF = new TagInfoAscii( "GPS Dest Bearing Ref", 0x0017, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - public static final String GPS_TAG_GPS_DEST_BEARING_REF_VALUE_MAGNETIC_NORTH = "M"; - public static final String GPS_TAG_GPS_DEST_BEARING_REF_VALUE_TRUE_NORTH = "T"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_DEST_BEARING = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_DEST_BEARING = new TagInfoRational( "GPS Dest Bearing", 0x0018, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_DEST_DISTANCE_REF = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_DEST_DISTANCE_REF = new TagInfoAscii( "GPS Dest Distance Ref", 0x0019, 2, TiffDirectoryType.EXIF_DIRECTORY_GPS); - - public static final String GPS_TAG_GPS_DEST_DISTANCE_REF_VALUE_KILOMETERS = "K"; - public static final String GPS_TAG_GPS_DEST_DISTANCE_REF_VALUE_MILES = "M"; - public static final String GPS_TAG_GPS_DEST_DISTANCE_REF_VALUE_NAUTICAL_MILES = "N"; // ************************************************************ - public static final TagInfoRational GPS_TAG_GPS_DEST_DISTANCE = new TagInfoRational( + TagInfoRational GPS_TAG_GPS_DEST_DISTANCE = new TagInfoRational( "GPS Dest Distance", 0x001a, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoGpsText GPS_TAG_GPS_PROCESSING_METHOD = new TagInfoGpsText( + TagInfoGpsText GPS_TAG_GPS_PROCESSING_METHOD = new TagInfoGpsText( "GPS Processing Method", 0x001b, FIELD_TYPE_UNKNOWN, -1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoGpsText GPS_TAG_GPS_AREA_INFORMATION = new TagInfoGpsText( + TagInfoGpsText GPS_TAG_GPS_AREA_INFORMATION = new TagInfoGpsText( "GPS Area Information", 0x001c, FIELD_TYPE_UNKNOWN, -1, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoAscii GPS_TAG_GPS_DATE_STAMP = new TagInfoAscii( + TagInfoAscii GPS_TAG_GPS_DATE_STAMP = new TagInfoAscii( "GPS Date Stamp", 0x001d, 11, TiffDirectoryType.EXIF_DIRECTORY_GPS); // ************************************************************ - public static final TagInfoShort GPS_TAG_GPS_DIFFERENTIAL = new TagInfoShort( + TagInfoShort GPS_TAG_GPS_DIFFERENTIAL = new TagInfoShort( "GPS Differential", 0x001e, 1, TiffDirectoryType.EXIF_DIRECTORY_GPS); - - public static final int GPS_TAG_GPS_DIFFERENTIAL_VALUE_NO_CORRECTION = 0; - public static final int GPS_TAG_GPS_DIFFERENTIAL_VALUE_DIFFERENTIAL_CORRECTED = 1; // ************************************************************ - public static final List ALL_GPS_TAGS = - Collections.unmodifiableList(Arrays.asList( + List ALL_GPS_TAGS = + List.of( GPS_TAG_GPS_VERSION_ID, GPS_TAG_GPS_LATITUDE_REF, GPS_TAG_GPS_LATITUDE, GPS_TAG_GPS_LONGITUDE_REF, GPS_TAG_GPS_LONGITUDE, GPS_TAG_GPS_ALTITUDE_REF, @@ -231,5 +196,5 @@ public interface GpsTagConstants GPS_TAG_GPS_DEST_BEARING, GPS_TAG_GPS_DEST_DISTANCE_REF, GPS_TAG_GPS_DEST_DISTANCE, GPS_TAG_GPS_PROCESSING_METHOD, GPS_TAG_GPS_AREA_INFORMATION, GPS_TAG_GPS_DATE_STAMP, - GPS_TAG_GPS_DIFFERENTIAL)); + GPS_TAG_GPS_DIFFERENTIAL); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/HylaFaxTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/HylaFaxTagConstants.java index 31e99217..bb83ec09 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/HylaFaxTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/HylaFaxTagConstants.java @@ -1,13 +1,11 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; +import java.util.List; + public interface HylaFaxTagConstants extends TiffFieldTypeConstants { public static final TagInfoLong EXIF_TAG_FAX_RECV_PARAMS = new TagInfoLong( "Fax Recv Params", 0x885c, 1, @@ -26,9 +24,8 @@ public interface HylaFaxTagConstants extends TiffFieldTypeConstants { TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); public static final List ALL_HYLAFAX_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_FAX_RECV_PARAMS, - EXIF_TAG_FAX_SUB_ADDRESS, - EXIF_TAG_FAX_RECV_TIME, - EXIF_TAG_FAX_DCS)); + List.of(EXIF_TAG_FAX_RECV_PARAMS, + EXIF_TAG_FAX_SUB_ADDRESS, + EXIF_TAG_FAX_RECV_TIME, + EXIF_TAG_FAX_DCS); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftHdPhotoTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftHdPhotoTagConstants.java index f8790970..227d06ae 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftHdPhotoTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftHdPhotoTagConstants.java @@ -1,18 +1,12 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.common.BinaryConstant; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoFloat; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefined; +import org.apache.commons.imaging.formats.tiff.taginfos.*; + +import java.util.List; /** - * Microsoft's HDP/WDP file format. + * Microsoft's HDP/WDP file format. */ public interface MicrosoftHdPhotoTagConstants extends TiffFieldTypeConstants { /* @@ -20,198 +14,67 @@ public interface MicrosoftHdPhotoTagConstants extends TiffFieldTypeConstants { * Data1 (int), Data2 (short), Data3 (short) are little-endian, * Data4 (char[8]) is endian-independent. */ - public static final TagInfoByte EXIF_TAG_PIXEL_FORMAT = new TagInfoByte( + TagInfoByte EXIF_TAG_PIXEL_FORMAT = new TagInfoByte( "Pixel Format", 0xbc01, 16, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final BinaryConstant PIXEL_FORMAT_VALUE_BLACK_AND_WHITE = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x05); - public static final BinaryConstant PIXEL_FORMAT_VALUE_8_BIT_GRAY = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x08); - public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR555 = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x9); - public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_BGR565 = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xa); - public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xb); - public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_BGR = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xc); - public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_RGB = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xd); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xe); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGRA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0xf); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_PBGRA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x10); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FLOAT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x11); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_FIXED_POINT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x12); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_BGR101010 = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x13); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x15); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x16); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_PRGBA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x17); - public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_RGB_FIXED_POINT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x18); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FLOAT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x19); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_PRGBA_FLOAT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1a); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGB_FLOAT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1b); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_CMYK = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1c); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_FIXED_POINT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1d); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_RGBA_FIXED_POINT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1e); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_CMYK = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x1f); - public static final BinaryConstant PIXEL_FORMAT_VALUE_24_BIT_3_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x20); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_4_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x21); - public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_5_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x22); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_6_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x23); - public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_7_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x24); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_8_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x25); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_3_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x26); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_4_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x27); - public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_5_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x28); - public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_6_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x29); - public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_7_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2a); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_8_CHANNELS = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2b); - public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_CMYK_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2c); - public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_CMYK_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2d); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_3_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2e); - public static final BinaryConstant PIXEL_FORMAT_VALUE_40_BIT_4_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x2f); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_5_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x30); - public static final BinaryConstant PIXEL_FORMAT_VALUE_56_BIT_6_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x31); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_7_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x32); - public static final BinaryConstant PIXEL_FORMAT_VALUE_72_BIT_8_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x33); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_3_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x34); - public static final BinaryConstant PIXEL_FORMAT_VALUE_80_BIT_4_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x35); - public static final BinaryConstant PIXEL_FORMAT_VALUE_96_BIT_5_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x36); - public static final BinaryConstant PIXEL_FORMAT_VALUE_112_BIT_6_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x37); - public static final BinaryConstant PIXEL_FORMAT_VALUE_128_BIT_7_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x38); - public static final BinaryConstant PIXEL_FORMAT_VALUE_144_BIT_8_CHANNELS_ALPHA = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x39); - public static final BinaryConstant PIXEL_FORMAT_VALUE_64_BIT_RGBA_HALF = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x3a); - public static final BinaryConstant PIXEL_FORMAT_VALUE_48_BIT_RGB_HALF = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x3b); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_RGBE = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x3d); - public static final BinaryConstant PIXEL_FORMAT_VALUE_16_BIT_GRAY_HALF = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x3e); - public static final BinaryConstant PIXEL_FORMAT_VALUE_32_BIT_GRAY_FIXED_POINT = - TagConstantsUtils.createMicrosoftHdPhotoGuidEndingWith((byte)0x3f); - - public static final TagInfoLong EXIF_TAG_TRANSFOMATION = new TagInfoLong( + + TagInfoLong EXIF_TAG_TRANSFOMATION = new TagInfoLong( "Transfomation", 0xbc02, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int TRANSFOMATION_VALUE_HORIZONTAL_NORMAL = 0; - public static final int TRANSFOMATION_VALUE_MIRROR_VERTICAL = 1; - public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL = 2; - public static final int TRANSFOMATION_VALUE_ROTATE_180 = 3; - public static final int TRANSFOMATION_VALUE_ROTATE_90_CW = 4; - public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_90_CW = 5; - public static final int TRANSFOMATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_270_CW = 6; - public static final int TRANSFOMATION_VALUE_ROTATE_270_CW = 7; - - public static final TagInfoLong EXIF_TAG_UNCOMPRESSED = new TagInfoLong( + TagInfoLong EXIF_TAG_UNCOMPRESSED = new TagInfoLong( "Uncompressed", 0xbc03, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int UNCOMPRESSED_VALUE_NO = 0; - public static final int UNCOMPRESSED_VALUE_YES = 1; - - public static final TagInfoLong EXIF_TAG_IMAGE_TYPE = new TagInfoLong("Image Type", + TagInfoLong EXIF_TAG_IMAGE_TYPE = new TagInfoLong("Image Type", 0xbc04, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong EXIF_TAG_IMAGE_WIDTH = new TagInfoLong( + TagInfoLong EXIF_TAG_IMAGE_WIDTH = new TagInfoLong( "Image Width", 0xbc80, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoLong EXIF_TAG_IMAGE_HEIGHT = new TagInfoLong( + + TagInfoLong EXIF_TAG_IMAGE_HEIGHT = new TagInfoLong( "Image Height", 0xbc81, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoFloat EXIF_TAG_WIDTH_RESOLUTION = new TagInfoFloat( + + TagInfoFloat EXIF_TAG_WIDTH_RESOLUTION = new TagInfoFloat( "Width Resolution", 0xbc82, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoFloat EXIF_TAG_HEIGHT_RESOLUTION = new TagInfoFloat( + + TagInfoFloat EXIF_TAG_HEIGHT_RESOLUTION = new TagInfoFloat( "Height Resolution", 0xbc83, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - + // FIXME: might be an offset? - public static final TagInfoLong EXIF_TAG_IMAGE_OFFSET = new TagInfoLong( + TagInfoLong EXIF_TAG_IMAGE_OFFSET = new TagInfoLong( "Image Offset", 0xbcc0, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoLong EXIF_TAG_IMAGE_BYTE_COUNT = new TagInfoLong( + + TagInfoLong EXIF_TAG_IMAGE_BYTE_COUNT = new TagInfoLong( "Image Byte Count", 0xbcc1, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - + // FIXME: might be an offset? - public static final TagInfoLong EXIF_TAG_ALPHA_OFFSET = new TagInfoLong( + TagInfoLong EXIF_TAG_ALPHA_OFFSET = new TagInfoLong( "Alpha Offset", 0xbcc2, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoLong EXIF_TAG_ALPHA_BYTE_COUNT = new TagInfoLong( + + TagInfoLong EXIF_TAG_ALPHA_BYTE_COUNT = new TagInfoLong( "Alpha Byte Count", 0xbcc3, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoByte EXIF_TAG_IMAGE_DATA_DISCARD = new TagInfoByte( + TagInfoByte EXIF_TAG_IMAGE_DATA_DISCARD = new TagInfoByte( "Image Data Discard", 0xbcc4, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int IMAGE_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0; - public static final int IMAGE_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1; - public static final int IMAGE_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2; - public static final int IMAGE_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3; - public static final TagInfoByte EXIF_TAG_ALPHA_DATA_DISCARD = new TagInfoByte( + TagInfoByte EXIF_TAG_ALPHA_DATA_DISCARD = new TagInfoByte( "Alpha Data Discard", 0xbcc5, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int ALPHA_DATA_DISCARD_VALUE_FULL_RESOLUTION = 0; - public static final int ALPHA_DATA_DISCARD_VALUE_FLEXBITS_DISCARDED = 1; - public static final int ALPHA_DATA_DISCARD_VALUE_HIGH_PASS_FREQUENCY_DATA_DISCARDED = 2; - public static final int ALPHA_DATA_DISCARD_VALUE_HIGHPASS_AND_LOW_PASS_FREQUENCY_DATA_DISCARDED = 3; - public static final TagInfoUndefined EXIF_TAG_PADDING = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_PADDING = new TagInfoUndefined( "Padding", 0xea1c, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final List ALL_MICROSOFT_HD_PHOTO_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_PIXEL_FORMAT, + + List ALL_MICROSOFT_HD_PHOTO_TAGS = + List.of(EXIF_TAG_PIXEL_FORMAT, EXIF_TAG_TRANSFOMATION, EXIF_TAG_UNCOMPRESSED, EXIF_TAG_IMAGE_TYPE, @@ -225,5 +88,5 @@ public interface MicrosoftHdPhotoTagConstants extends TiffFieldTypeConstants { EXIF_TAG_ALPHA_BYTE_COUNT, EXIF_TAG_IMAGE_DATA_DISCARD, EXIF_TAG_ALPHA_DATA_DISCARD, - EXIF_TAG_PADDING)); + EXIF_TAG_PADDING); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftTagConstants.java index be79cc26..ff1cfabd 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MicrosoftTagConstants.java @@ -1,52 +1,49 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoXpString; +import java.util.List; + /** * Largely undocumented and derived by experimentation. */ public interface MicrosoftTagConstants { - public static final TagInfoShort EXIF_TAG_RATING = new TagInfoShort( + TagInfoShort EXIF_TAG_RATING = new TagInfoShort( "Rating", 0x4746, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - - public static final TagInfoShort EXIF_TAG_RATING_PERCENT = new TagInfoShort( + + TagInfoShort EXIF_TAG_RATING_PERCENT = new TagInfoShort( "Rating Percent", 0x4749, 1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoXpString EXIF_TAG_XPTITLE = new TagInfoXpString( + TagInfoXpString EXIF_TAG_XPTITLE = new TagInfoXpString( "XPTitle", 0x9c9b, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoXpString EXIF_TAG_XPCOMMENT = new TagInfoXpString( + TagInfoXpString EXIF_TAG_XPCOMMENT = new TagInfoXpString( "XPComment", 0x9c9c, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoXpString EXIF_TAG_XPAUTHOR = new TagInfoXpString( + TagInfoXpString EXIF_TAG_XPAUTHOR = new TagInfoXpString( "XPAuthor", 0x9c9d, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoXpString EXIF_TAG_XPKEYWORDS = new TagInfoXpString( + TagInfoXpString EXIF_TAG_XPKEYWORDS = new TagInfoXpString( "XPKeywords", 0x9c9e, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final TagInfoXpString EXIF_TAG_XPSUBJECT = new TagInfoXpString( - "XPSubject", 0x9c9f, -1, + TagInfoXpString EXIF_TAG_XPSUBJECT = new TagInfoXpString( + "XPSubject", 0x9c9f, -1, TiffDirectoryType.EXIF_DIRECTORY_IFD0); - public static final List ALL_MICROSOFT_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_RATING, + List ALL_MICROSOFT_TAGS = + List.of(EXIF_TAG_RATING, EXIF_TAG_RATING_PERCENT, EXIF_TAG_XPTITLE, EXIF_TAG_XPCOMMENT, EXIF_TAG_XPAUTHOR, EXIF_TAG_XPKEYWORDS, - EXIF_TAG_XPSUBJECT)); + EXIF_TAG_XPSUBJECT); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MolecularDynamicsGelTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MolecularDynamicsGelTagConstants.java index fbf41555..ba27a4ee 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MolecularDynamicsGelTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/MolecularDynamicsGelTagConstants.java @@ -1,61 +1,54 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; +import java.util.List; /** * Molecular Dynamics GEL file format - *
+ *
* http://www.awaresystems.be/imaging/tiff/tifftags/docs/gel.html */ public interface MolecularDynamicsGelTagConstants extends TiffFieldTypeConstants { - public static final TagInfoLong EXIF_TAG_MDFILE_TAG = new TagInfoLong( + TagInfoLong EXIF_TAG_MDFILE_TAG = new TagInfoLong( "MDFile Tag", 0x82a5, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational EXIF_TAG_MDSCALE_PIXEL = new TagInfoRational( + TagInfoRational EXIF_TAG_MDSCALE_PIXEL = new TagInfoRational( "MDScale Pixel", 0x82a6, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_MDCOLOR_TABLE = new TagInfoShort( + TagInfoShort EXIF_TAG_MDCOLOR_TABLE = new TagInfoShort( "MDColor Table", 0x82a7, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_MDLAB_NAME = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MDLAB_NAME = new TagInfoAscii( "MDLab Name", 0x82a8, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_MDSAMPLE_INFO = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MDSAMPLE_INFO = new TagInfoAscii( "MDSample Info", 0x82a9, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_MDPREP_DATE = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MDPREP_DATE = new TagInfoAscii( "MDPrep Date", 0x82aa, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_MDPREP_TIME = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MDPREP_TIME = new TagInfoAscii( "MDPrep Time", 0x82ab, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_MDFILE_UNITS = new TagInfoAscii( + TagInfoAscii EXIF_TAG_MDFILE_UNITS = new TagInfoAscii( "MDFile Units", 0x82ac, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_MOLECULAR_DYNAMICS_GEL_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_MDFILE_TAG, + List ALL_MOLECULAR_DYNAMICS_GEL_TAGS = + List.of(EXIF_TAG_MDFILE_TAG, EXIF_TAG_MDSCALE_PIXEL, EXIF_TAG_MDCOLOR_TABLE, EXIF_TAG_MDLAB_NAME, EXIF_TAG_MDSAMPLE_INFO, EXIF_TAG_MDPREP_DATE, EXIF_TAG_MDPREP_TIME, - EXIF_TAG_MDFILE_UNITS)); + EXIF_TAG_MDFILE_UNITS); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/OceScanjobTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/OceScanjobTagConstants.java index d8507729..3e8f7cde 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/OceScanjobTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/OceScanjobTagConstants.java @@ -1,38 +1,35 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; +import java.util.List; + /** * Oce Scanjob. *
* http://www.awaresystems.be/imaging/tiff/tifftags/docs/oce.html */ public interface OceScanjobTagConstants { - public static final TagInfoAscii EXIF_TAG_OCE_SCANJOB_DESC = new TagInfoAscii( + TagInfoAscii EXIF_TAG_OCE_SCANJOB_DESC = new TagInfoAscii( "Oce Scanjob Desc", 0xc427, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAscii EXIF_TAG_OCE_APPLICATION_SELECTOR = new TagInfoAscii( + TagInfoAscii EXIF_TAG_OCE_APPLICATION_SELECTOR = new TagInfoAscii( "Oce Application Selector", 0xc428, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoAscii EXIF_TAG_OCE_IDNUMBER = new TagInfoAscii( + + TagInfoAscii EXIF_TAG_OCE_IDNUMBER = new TagInfoAscii( "Oce IDNumber", 0xc429, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoAscii EXIF_TAG_OCE_IMAGE_LOGIC = new TagInfoAscii( + + TagInfoAscii EXIF_TAG_OCE_IMAGE_LOGIC = new TagInfoAscii( "Oce Image Logic", 0xc42a, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_OCE_SCANJOB_TAGS = - Collections.unmodifiableList(Arrays.asList(new TagInfo[] { - EXIF_TAG_OCE_SCANJOB_DESC, + List ALL_OCE_SCANJOB_TAGS = + List.of(EXIF_TAG_OCE_SCANJOB_DESC, EXIF_TAG_OCE_APPLICATION_SELECTOR, EXIF_TAG_OCE_IDNUMBER, - EXIF_TAG_OCE_IMAGE_LOGIC})); + EXIF_TAG_OCE_IMAGE_LOGIC); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Rfc2301TagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Rfc2301TagConstants.java index aa5a780f..a12a8877 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Rfc2301TagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Rfc2301TagConstants.java @@ -1,15 +1,8 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; +import java.util.List; /** * RFC 2301: File Format for Internet Fax @@ -21,78 +14,72 @@ * http://cool.conservation-us.org/bytopic/imaging/std/tiff-f.html */ public interface Rfc2301TagConstants extends TiffFieldTypeConstants { - public static final TagInfoShortOrLong TIFF_TAG_BAD_FAX_LINES = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_BAD_FAX_LINES = new TagInfoShortOrLong( "Bad Fax Lines", 0x0146, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoShort TIFF_TAG_CLEAN_FAX_DATA = new TagInfoShort( + + TagInfoShort TIFF_TAG_CLEAN_FAX_DATA = new TagInfoShort( "Clean Fax Data", 0x0147, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int CLEAN_FAX_DATA_VALUE_CLEAN = 0; - public static final int CLEAN_FAX_DATA_VALUE_REGENERATED = 1; - public static final int CLEAN_FAX_DATA_VALUE_UNCLEAN = 2; - - public static final TagInfoShortOrLong TIFF_TAG_CONSECUTIVE_BAD_FAX_LINES = new TagInfoShortOrLong( + int CLEAN_FAX_DATA_VALUE_CLEAN = 0; + int CLEAN_FAX_DATA_VALUE_REGENERATED = 1; + int CLEAN_FAX_DATA_VALUE_UNCLEAN = 2; + + TagInfoShortOrLong TIFF_TAG_CONSECUTIVE_BAD_FAX_LINES = new TagInfoShortOrLong( "Consecutive Bad Fax Lines", 0x0148, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong TIFF_TAG_GLOBAL_PARAMETERS_IFD = new TagInfoLong( + TagInfoLong TIFF_TAG_GLOBAL_PARAMETERS_IFD = new TagInfoLong( "Global Parameters IFD", 0x0190, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN, true); - - public static final TagInfoLong TIFF_TAG_PROFILE_TYPE = new TagInfoLong( + + TagInfoLong TIFF_TAG_PROFILE_TYPE = new TagInfoLong( "Profile Type", 0x0191, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int PROFILE_TYPE_VALUE_UNSPECIFIED = 0; - public static final int PROFILE_TYPE_VALUE_GROUP_3_FAX = 1; - - public static final TagInfoByte TIFF_TAG_FAX_PROFILE = new TagInfoByte( + int PROFILE_TYPE_VALUE_UNSPECIFIED = 0; + int PROFILE_TYPE_VALUE_GROUP_3_FAX = 1; + + TagInfoByte TIFF_TAG_FAX_PROFILE = new TagInfoByte( "Fax Profile", 0x0192, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int FAX_PROFILE_VALUE_UNKNOWN = 0; - public static final int FAX_PROFILE_VALUE_MINIMAL_B_AND_W_LOSSLESS_S = 1; - public static final int FAX_PROFILE_VALUE_EXTENDED_B_AND_W_LOSSLESS_F = 2; - public static final int FAX_PROFILE_VALUE_LOSSLESS_JBIG_B_AND_W_J = 3; - public static final int FAX_PROFILE_VALUE_LOSSY_COLOR_AND_GRAYSCALE_C = 4; - public static final int FAX_PROFILE_VALUE_LOSSLESS_COLOR_AND_GRAYSCALE_L = 5; - public static final int FAX_PROFILE_VALUE_MIXED_RASTER_CONTENT_M = 6; - - public static final TagInfoLong TIFF_TAG_CODING_METHODS = new TagInfoLong( + int FAX_PROFILE_VALUE_UNKNOWN = 0; + int FAX_PROFILE_VALUE_MINIMAL_B_AND_W_LOSSLESS_S = 1; + int FAX_PROFILE_VALUE_EXTENDED_B_AND_W_LOSSLESS_F = 2; + int FAX_PROFILE_VALUE_LOSSLESS_JBIG_B_AND_W_J = 3; + int FAX_PROFILE_VALUE_LOSSY_COLOR_AND_GRAYSCALE_C = 4; + int FAX_PROFILE_VALUE_LOSSLESS_COLOR_AND_GRAYSCALE_L = 5; + int FAX_PROFILE_VALUE_MIXED_RASTER_CONTENT_M = 6; + + TagInfoLong TIFF_TAG_CODING_METHODS = new TagInfoLong( "Coding Methods", 0x0193, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int CODING_METHODS_VALUE_T4_1D = 2; - public static final int CODING_METHODS_VALUE_T4_2D = 4; - public static final int CODING_METHODS_VALUE_T6 = 8; - public static final int CODING_METHODS_VALUE_T82_T85 = 16; - public static final int CODING_METHODS_VALUE_T81 = 32; - public static final int CODING_METHODS_VALUE_T82_T43 = 64; - - public static final TagInfoByte TIFF_TAG_VERSION_YEAR = new TagInfoByte( + + TagInfoByte TIFF_TAG_VERSION_YEAR = new TagInfoByte( "Version Year", 0x0194, 4, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoByte TIFF_TAG_MODE_NUMBER = new TagInfoByte( + + TagInfoByte TIFF_TAG_MODE_NUMBER = new TagInfoByte( "Mode Number", 0x0195, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoRational TIFF_TAG_DECODE = new TagInfoRational( + TagInfoRational TIFF_TAG_DECODE = new TagInfoRational( "Decode", 0x01b1, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoShort TIFF_TAG_DEFAULT_IMAGE_COLOR = new TagInfoShort( + + TagInfoShort TIFF_TAG_DEFAULT_IMAGE_COLOR = new TagInfoShort( "Default Image Color", 0x01b2, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoLong TIFF_TAG_STRIP_ROW_COUNTS = new TagInfoLong( + TagInfoLong TIFF_TAG_STRIP_ROW_COUNTS = new TagInfoLong( "Strip Row Counts", 0x022f, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShortOrLong TIFF_TAG_IMAGE_LAYER = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_IMAGE_LAYER = new TagInfoShortOrLong( "Image Layer", 0x87ac, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_RFC_2301_TAGS = - Collections.unmodifiableList(Arrays.asList( + List ALL_RFC_2301_TAGS = + List.of( TIFF_TAG_BAD_FAX_LINES, TIFF_TAG_CLEAN_FAX_DATA, TIFF_TAG_CONSECUTIVE_BAD_FAX_LINES, @@ -105,5 +92,5 @@ public interface Rfc2301TagConstants extends TiffFieldTypeConstants { TIFF_TAG_DECODE, TIFF_TAG_DEFAULT_IMAGE_COLOR, TIFF_TAG_STRIP_ROW_COUNTS, - TIFF_TAG_IMAGE_LAYER)); + TIFF_TAG_IMAGE_LAYER); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Tiff4TagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Tiff4TagConstants.java index c3da3583..c31a3cbd 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Tiff4TagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/Tiff4TagConstants.java @@ -1,28 +1,20 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; +import java.util.List; + /** * Tags in TIFF4 but NOT in TIFF6. *
* http://cool.conservation-us.org/bytopic/imaging/std/tiff4.html */ public interface Tiff4TagConstants { - public static final TagInfoShort TIFF_TAG_COLOR_RESPONSE_UNIT = new TagInfoShort( + TagInfoShort TIFF_TAG_COLOR_RESPONSE_UNIT = new TagInfoShort( "Color Response Unit", 0x12C, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int COLOR_RESPONSE_UNIT_VALUE_0_1 = 1; - public static final int COLOR_RESPONSE_UNIT_VALUE_0_01 = 2; - public static final int COLOR_RESPONSE_UNIT_VALUE_0_001 = 3; - public static final int COLOR_RESPONSE_UNIT_VALUE_0_0001 = 4; - public static final int COLOR_RESPONSE_UNIT_VALUE_0_00001 = 5; - - public static final List ALL_TIFF_4_TAGS = - Collections.unmodifiableList(Arrays.asList( - new TagInfo[] {TIFF_TAG_COLOR_RESPONSE_UNIT})); + + List ALL_TIFF_4_TAGS = + List.of(TIFF_TAG_COLOR_RESPONSE_UNIT); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffEpTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffEpTagConstants.java index b5755081..e48a513c 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffEpTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffEpTagConstants.java @@ -1,115 +1,96 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAsciiOrRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoSShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUndefined; +import java.util.List; /** - * + * */ public interface TiffEpTagConstants extends TiffFieldTypeConstants { - public static final TagInfoShort EXIF_TAG_CFAREPEAT_PATTERN_DIM = new TagInfoShort( + TagInfoShort EXIF_TAG_CFAREPEAT_PATTERN_DIM = new TagInfoShort( "CFARepeat Pattern Dim", 0x828d, 2, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoByte EXIF_TAG_CFAPATTERN_2 = new TagInfoByte( + + TagInfoByte EXIF_TAG_CFAPATTERN_2 = new TagInfoByte( "CFAPattern 2", 0x828e, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoAsciiOrRational EXIF_TAG_BATTERY_LEVEL = new TagInfoAsciiOrRational( + TagInfoAsciiOrRational EXIF_TAG_BATTERY_LEVEL = new TagInfoAsciiOrRational( "Battery Level", 0x828f, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - - public static final TagInfoUndefined EXIF_TAG_ICC_PROFILE = new TagInfoUndefined( + + TagInfoUndefined EXIF_TAG_ICC_PROFILE = new TagInfoUndefined( "ICC_Profile", 0x8773, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_INTERLACE = new TagInfoShort( + TagInfoShort EXIF_TAG_INTERLACE = new TagInfoShort( "Interlace", 0x8829, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoSShort EXIF_TAG_TIME_ZONE_OFFSET = new TagInfoSShort( + TagInfoSShort EXIF_TAG_TIME_ZONE_OFFSET = new TagInfoSShort( "Time Zone Offset", 0x882a, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoShort EXIF_TAG_SELF_TIMER_MODE = new TagInfoShort( + TagInfoShort EXIF_TAG_SELF_TIMER_MODE = new TagInfoShort( "Self Timer Mode", 0x882b, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_FLASH_ENERGY = new TagInfoRational( + TagInfoRational EXIF_TAG_FLASH_ENERGY = new TagInfoRational( "Flash Energy", 0x920b, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoUndefined EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE_1 = new TagInfoUndefined( + TagInfoUndefined EXIF_TAG_SPATIAL_FREQUENCY_RESPONSE_1 = new TagInfoUndefined( "Spatial Frequency Response", 0x920c, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoUndefined EXIF_TAG_NOISE_1 = new TagInfoUndefined( + + TagInfoUndefined EXIF_TAG_NOISE_1 = new TagInfoUndefined( "Noise", 0x920d, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoRational EXIF_TAG_FOCAL_PLANE_XRESOLUTION = new TagInfoRational( + + TagInfoRational EXIF_TAG_FOCAL_PLANE_XRESOLUTION = new TagInfoRational( "Focal Plane XResolution", 0x920e, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoRational EXIF_TAG_FOCAL_PLANE_YRESOLUTION = new TagInfoRational( + + TagInfoRational EXIF_TAG_FOCAL_PLANE_YRESOLUTION = new TagInfoRational( "Focal Plane YResolution", 0x920f, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoShort EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT = new TagInfoShort( + + TagInfoShort EXIF_TAG_FOCAL_PLANE_RESOLUTION_UNIT = new TagInfoShort( "Focal Plane Resolution Unit", 0x9210, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_NONE = 1; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_INCHES = 2; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_CM = 3; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_MM = 4; - public static final int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_UM = 5; + int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_NONE = 1; + int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_INCHES = 2; + int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_CM = 3; + int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_MM = 4; + int FOCAL_PLANE_RESOLUTION_UNIT_VALUE_UM = 5; - public static final TagInfoLong EXIF_TAG_IMAGE_NUMBER_EXIF_IFD = new TagInfoLong( + TagInfoLong EXIF_TAG_IMAGE_NUMBER_EXIF_IFD = new TagInfoLong( "Image Number", 0x9211, 1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_SECURITY_CLASSIFICATION_EXIF_IFD = new TagInfoAscii( + TagInfoAscii EXIF_TAG_SECURITY_CLASSIFICATION_EXIF_IFD = new TagInfoAscii( "Security Classification", 0x9212, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoAscii EXIF_TAG_IMAGE_HISTORY_EXIF_IFD = new TagInfoAscii( + TagInfoAscii EXIF_TAG_IMAGE_HISTORY_EXIF_IFD = new TagInfoAscii( "Image History", 0x9213, -1, TiffDirectoryType.EXIF_DIRECTORY_EXIF_IFD); - public static final TagInfoRational EXIF_TAG_EXPOSURE_INDEX = new TagInfoRational( + TagInfoRational EXIF_TAG_EXPOSURE_INDEX = new TagInfoRational( "Exposure Index", 0x9215, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - - public static final TagInfoByte EXIF_TAG_TIFF_EPSTANDARD_ID_1 = new TagInfoByte( + + TagInfoByte EXIF_TAG_TIFF_EPSTANDARD_ID_1 = new TagInfoByte( "TIFF/EP Standard ID", 0x9216, 4, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final TagInfoShort EXIF_TAG_SENSING_METHOD = new TagInfoShort( + TagInfoShort EXIF_TAG_SENSING_METHOD = new TagInfoShort( "Sensing Method", 0x9217, 1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final int SENSING_METHOD_VALUE_MONOCHROME_AREA = 1; - public static final int SENSING_METHOD_VALUE_ONE_CHIP_COLOR_AREA = 2; - public static final int SENSING_METHOD_VALUE_TWO_CHIP_COLOR_AREA = 3; - public static final int SENSING_METHOD_VALUE_THREE_CHIP_COLOR_AREA = 4; - public static final int SENSING_METHOD_VALUE_COLOR_SEQUENTIAL_AREA = 5; - public static final int SENSING_METHOD_VALUE_MONOCHROME_LINEAR = 6; - public static final int SENSING_METHOD_VALUE_TRILINEAR = 7; - public static final int SENSING_METHOD_VALUE_COLOR_SEQUENTIAL_LINEAR = 8; - - public static final List ALL_TIFF_EP_TAGS = - Collections.unmodifiableList(Arrays.asList( - EXIF_TAG_CFAREPEAT_PATTERN_DIM, + + List ALL_TIFF_EP_TAGS = + List.of(EXIF_TAG_CFAREPEAT_PATTERN_DIM, EXIF_TAG_CFAPATTERN_2, EXIF_TAG_BATTERY_LEVEL, EXIF_TAG_ICC_PROFILE, @@ -127,5 +108,5 @@ public interface TiffEpTagConstants extends TiffFieldTypeConstants { EXIF_TAG_IMAGE_HISTORY_EXIF_IFD, EXIF_TAG_EXPOSURE_INDEX, EXIF_TAG_TIFF_EPSTANDARD_ID_1, - EXIF_TAG_SENSING_METHOD)); + EXIF_TAG_SENSING_METHOD); } diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java index 69c71812..bfb43bd0 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffFieldTypeConstants.java @@ -16,92 +16,62 @@ */ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; +import org.apache.commons.imaging.SanselanConstants; +import org.apache.commons.imaging.formats.tiff.fieldtypes.*; + import java.util.List; -import org.apache.commons.imaging.SanselanConstants; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeAscii; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeByte; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeDouble; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeFloat; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeLong; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeRational; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeShort; -import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldTypeUnknown; - -public interface TiffFieldTypeConstants extends SanselanConstants -{ - - public static final FieldTypeByte FIELD_TYPE_BYTE = new FieldTypeByte(1, +public interface TiffFieldTypeConstants extends SanselanConstants { + + FieldTypeByte FIELD_TYPE_BYTE = new FieldTypeByte(1, "Byte"); - public static final FieldTypeAscii FIELD_TYPE_ASCII = new FieldTypeAscii(2, + FieldTypeAscii FIELD_TYPE_ASCII = new FieldTypeAscii(2, "ASCII"); - public static final FieldTypeShort FIELD_TYPE_SHORT = new FieldTypeShort(3, + FieldTypeShort FIELD_TYPE_SHORT = new FieldTypeShort(3, "Short"); - public static final FieldTypeLong FIELD_TYPE_LONG = new FieldTypeLong(4, + FieldTypeLong FIELD_TYPE_LONG = new FieldTypeLong(4, "Long"); - public static final FieldTypeRational FIELD_TYPE_RATIONAL = new FieldTypeRational( + FieldTypeRational FIELD_TYPE_RATIONAL = new FieldTypeRational( 5, "Rational"); - public static final FieldType FIELD_TYPE_SBYTE = new FieldTypeByte(6, + FieldType FIELD_TYPE_SBYTE = new FieldTypeByte(6, "SByte"); - public static final FieldType FIELD_TYPE_UNDEFINED = new FieldTypeByte(7, + FieldType FIELD_TYPE_UNDEFINED = new FieldTypeByte(7, "Undefined"); - public static final FieldType FIELD_TYPE_SSHORT = new FieldTypeShort(8, + FieldType FIELD_TYPE_SSHORT = new FieldTypeShort(8, "SShort"); - public static final FieldType FIELD_TYPE_SLONG = new FieldTypeLong(9, + FieldType FIELD_TYPE_SLONG = new FieldTypeLong(9, "SLong"); - public static final FieldType FIELD_TYPE_SRATIONAL = new FieldTypeRational( + FieldType FIELD_TYPE_SRATIONAL = new FieldTypeRational( 10, "SRational"); - public static final FieldType FIELD_TYPE_FLOAT = new FieldTypeFloat(); + FieldType FIELD_TYPE_FLOAT = new FieldTypeFloat(); - public static final FieldType FIELD_TYPE_DOUBLE = new FieldTypeDouble(); + FieldType FIELD_TYPE_DOUBLE = new FieldTypeDouble(); - public static final FieldType FIELD_TYPE_UNKNOWN = new FieldTypeUnknown(); + FieldType FIELD_TYPE_UNKNOWN = new FieldTypeUnknown(); - public static final List FIELD_TYPES = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_BYTE, FIELD_TYPE_ASCII, FIELD_TYPE_SHORT, + List FIELD_TYPES = + List.of(FIELD_TYPE_BYTE, FIELD_TYPE_ASCII, FIELD_TYPE_SHORT, FIELD_TYPE_LONG, FIELD_TYPE_RATIONAL, FIELD_TYPE_SBYTE, FIELD_TYPE_UNDEFINED, FIELD_TYPE_SSHORT, FIELD_TYPE_SLONG, - FIELD_TYPE_SRATIONAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE)); - - public static final List FIELD_TYPE_ANY = FIELD_TYPES; - - public static final List FIELD_TYPE_DESCRIPTION_SHORT_OR_LONG = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_SHORT, FIELD_TYPE_LONG)); - - public static final List FIELD_TYPE_DESCRIPTION_SHORT_OR_RATIONAL = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_SHORT, FIELD_TYPE_RATIONAL)); - - public static final List FIELD_TYPE_DESCRIPTION_SHORT_OR_LONG_OR_RATIONAL = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_SHORT, FIELD_TYPE_LONG, FIELD_TYPE_RATIONAL)); - - public static final List FIELD_TYPE_DESCRIPTION_LONG_OR_SHORT = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_SHORT, FIELD_TYPE_LONG)); - - public static final List FIELD_TYPE_DESCRIPTION_BYTE_OR_SHORT = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_SHORT, FIELD_TYPE_BYTE)); - - public static final List FIELD_TYPE_DESCRIPTION_ASCII_OR_RATIONAL = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_ASCII, FIELD_TYPE_RATIONAL)); - - public static final List FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE = - Collections.unmodifiableList(Arrays.asList( - FIELD_TYPE_ASCII, FIELD_TYPE_BYTE)); + FIELD_TYPE_SRATIONAL, FIELD_TYPE_FLOAT, FIELD_TYPE_DOUBLE); + + List FIELD_TYPE_ANY = FIELD_TYPES; + + List FIELD_TYPE_DESCRIPTION_SHORT_OR_LONG = List.of(FIELD_TYPE_SHORT, FIELD_TYPE_LONG); + + List FIELD_TYPE_DESCRIPTION_SHORT_OR_RATIONAL = List.of(FIELD_TYPE_SHORT, FIELD_TYPE_RATIONAL); + + List FIELD_TYPE_DESCRIPTION_BYTE_OR_SHORT = List.of(FIELD_TYPE_SHORT, FIELD_TYPE_BYTE); + + List FIELD_TYPE_DESCRIPTION_ASCII_OR_RATIONAL = List.of(FIELD_TYPE_ASCII, FIELD_TYPE_RATIONAL); + + List FIELD_TYPE_DESCRIPTION_ASCII_OR_BYTE = List.of(FIELD_TYPE_ASCII, FIELD_TYPE_BYTE); } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java index ff044dcc..b41dc928 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/TiffTagConstants.java @@ -16,20 +16,9 @@ */ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import org.apache.commons.imaging.formats.tiff.taginfos.*; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAny; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoAscii; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByteOrShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoRational; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShort; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrLong; -import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoUnknown; +import java.util.List; /** * Tags from the TIFF6 specification. @@ -38,409 +27,394 @@ */ public interface TiffTagConstants extends - TiffFieldTypeConstants -{ - public static final TagInfoLong TIFF_TAG_NEW_SUBFILE_TYPE = new TagInfoLong( + TiffFieldTypeConstants { + TagInfoLong TIFF_TAG_NEW_SUBFILE_TYPE = new TagInfoLong( "New Subfile Type", 0xFE, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int SUBFILE_TYPE_VALUE_FULL_RESOLUTION_IMAGE = 0; - public static final int SUBFILE_TYPE_VALUE_REDUCED_RESOLUTION_IMAGE = 1; - public static final int SUBFILE_TYPE_VALUE_SINGLE_PAGE_OF_MULTI_PAGE_IMAGE = 2; - public static final int SUBFILE_TYPE_VALUE_SINGLE_PAGE_OF_MULTI_PAGE_REDUCED_RESOLUTION_IMAGE = 3; - public static final int SUBFILE_TYPE_VALUE_TRANSPARENCY_MASK = 4; - public static final int SUBFILE_TYPE_VALUE_TRANSPARENCY_MASK_OF_REDUCED_RESOLUTION_IMAGE = 5; - public static final int SUBFILE_TYPE_VALUE_TRANSPARENCY_MASK_OF_MULTI_PAGE_IMAGE = 6; - public static final int SUBFILE_TYPE_VALUE_TRANSPARENCY_MASK_OF_REDUCED_RESOLUTION_MULTI_PAGE_IMAGE = 7; - public static final TagInfoShort TIFF_TAG_SUBFILE_TYPE = new TagInfoShort( + TagInfoShort TIFF_TAG_SUBFILE_TYPE = new TagInfoShort( "Subfile Type", 0xFF, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int OLD_SUBFILE_TYPE_VALUE_FULL_RESOLUTION_IMAGE = 1; - public static final int OLD_SUBFILE_TYPE_VALUE_REDUCED_RESOLUTION_IMAGE = 2; - public static final int OLD_SUBFILE_TYPE_VALUE_SINGLE_PAGE_OF_MULTI_PAGE_IMAGE = 3; - public static final TagInfoShortOrLong TIFF_TAG_IMAGE_WIDTH = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_IMAGE_WIDTH = new TagInfoShortOrLong( "Image Width", 0x100, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_IMAGE_LENGTH = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_IMAGE_LENGTH = new TagInfoShortOrLong( "Image Length", 0x101, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_BITS_PER_SAMPLE = new TagInfoShort( + TagInfoShort TIFF_TAG_BITS_PER_SAMPLE = new TagInfoShort( "Bits Per Sample", 0x102, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_COMPRESSION = new TagInfoShort( + TagInfoShort TIFF_TAG_COMPRESSION = new TagInfoShort( "Compression", 0x103, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int COMPRESSION_VALUE_UNCOMPRESSED = 1; - public static final int COMPRESSION_VALUE_CCITT_1D = 2; - public static final int COMPRESSION_VALUE_T4_GROUP_3_FAX = 3; - public static final int COMPRESSION_VALUE_T6_GROUP_4_FAX = 4; - public static final int COMPRESSION_VALUE_LZW = 5; - public static final int COMPRESSION_VALUE_JPEG_OLD_STYLE = 6; - public static final int COMPRESSION_VALUE_JPEG = 7; - public static final int COMPRESSION_VALUE_ADOBE_DEFLATE = 8; - public static final int COMPRESSION_VALUE_JBIG_B_AND_W = 9; - public static final int COMPRESSION_VALUE_JBIG_COLOR = 10; - public static final int COMPRESSION_VALUE_NEXT = 32766; - public static final int COMPRESSION_VALUE_EPSON_ERF_COMPRESSED = 32769; - public static final int COMPRESSION_VALUE_CCIRLEW = 32771; - public static final int COMPRESSION_VALUE_PACK_BITS = 32773; - public static final int COMPRESSION_VALUE_THUNDERSCAN = 32809; - public static final int COMPRESSION_VALUE_IT8CTPAD = 32895; - public static final int COMPRESSION_VALUE_IT8LW = 32896; - public static final int COMPRESSION_VALUE_IT8MP = 32897; - public static final int COMPRESSION_VALUE_IT8BL = 32898; - public static final int COMPRESSION_VALUE_PIXAR_FILM = 32908; - public static final int COMPRESSION_VALUE_PIXAR_LOG = 32909; - public static final int COMPRESSION_VALUE_DEFLATE = 32946; - public static final int COMPRESSION_VALUE_DCS = 32947; - public static final int COMPRESSION_VALUE_JBIG = 34661; - public static final int COMPRESSION_VALUE_SGILOG = 34676; - public static final int COMPRESSION_VALUE_SGILOG_24 = 34677; - public static final int COMPRESSION_VALUE_JPEG_2000 = 34712; - public static final int COMPRESSION_VALUE_NIKON_NEF_COMPRESSED = 34713; - public static final int COMPRESSION_VALUE_KODAK_DCR_COMPRESSED = 65000; - public static final int COMPRESSION_VALUE_PENTAX_PEF_COMPRESSED = 65535; - - public static final TagInfoShort TIFF_TAG_PHOTOMETRIC_INTERPRETATION = new TagInfoShort( + int COMPRESSION_VALUE_UNCOMPRESSED = 1; + int COMPRESSION_VALUE_CCITT_1D = 2; + int COMPRESSION_VALUE_T4_GROUP_3_FAX = 3; + int COMPRESSION_VALUE_T6_GROUP_4_FAX = 4; + int COMPRESSION_VALUE_LZW = 5; + int COMPRESSION_VALUE_JPEG_OLD_STYLE = 6; + int COMPRESSION_VALUE_JPEG = 7; + int COMPRESSION_VALUE_ADOBE_DEFLATE = 8; + int COMPRESSION_VALUE_JBIG_B_AND_W = 9; + int COMPRESSION_VALUE_JBIG_COLOR = 10; + int COMPRESSION_VALUE_NEXT = 32766; + int COMPRESSION_VALUE_EPSON_ERF_COMPRESSED = 32769; + int COMPRESSION_VALUE_CCIRLEW = 32771; + int COMPRESSION_VALUE_PACK_BITS = 32773; + int COMPRESSION_VALUE_THUNDERSCAN = 32809; + int COMPRESSION_VALUE_IT8CTPAD = 32895; + int COMPRESSION_VALUE_IT8LW = 32896; + int COMPRESSION_VALUE_IT8MP = 32897; + int COMPRESSION_VALUE_IT8BL = 32898; + int COMPRESSION_VALUE_PIXAR_FILM = 32908; + int COMPRESSION_VALUE_PIXAR_LOG = 32909; + int COMPRESSION_VALUE_DEFLATE = 32946; + int COMPRESSION_VALUE_DCS = 32947; + int COMPRESSION_VALUE_JBIG = 34661; + int COMPRESSION_VALUE_SGILOG = 34676; + int COMPRESSION_VALUE_SGILOG_24 = 34677; + int COMPRESSION_VALUE_JPEG_2000 = 34712; + int COMPRESSION_VALUE_NIKON_NEF_COMPRESSED = 34713; + int COMPRESSION_VALUE_KODAK_DCR_COMPRESSED = 65000; + int COMPRESSION_VALUE_PENTAX_PEF_COMPRESSED = 65535; + + TagInfoShort TIFF_TAG_PHOTOMETRIC_INTERPRETATION = new TagInfoShort( "Photometric Interpretation", 0x106, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_WHITE_IS_ZERO = 0; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_BLACK_IS_ZERO = 1; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_RGB = 2; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_RGB_PALETTE = 3; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_TRANSPARENCY_MASK = 4; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_CMYK = 5; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_YCB_CR = 6; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_CIELAB = 8; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_ICCLAB = 9; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_ITULAB = 10; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_COLOR_FILTER_ARRAY = 32803; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_PIXAR_LOG_L = 32844; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_PIXAR_LOG_LUV = 32845; - public static final int PHOTOMETRIC_INTERPRETATION_VALUE_LINEAR_RAW = 34892; - - public static final TagInfoShort TIFF_TAG_THRESHHOLDING = new TagInfoShort( + int PHOTOMETRIC_INTERPRETATION_VALUE_WHITE_IS_ZERO = 0; + int PHOTOMETRIC_INTERPRETATION_VALUE_BLACK_IS_ZERO = 1; + int PHOTOMETRIC_INTERPRETATION_VALUE_RGB = 2; + int PHOTOMETRIC_INTERPRETATION_VALUE_RGB_PALETTE = 3; + int PHOTOMETRIC_INTERPRETATION_VALUE_TRANSPARENCY_MASK = 4; + int PHOTOMETRIC_INTERPRETATION_VALUE_CMYK = 5; + int PHOTOMETRIC_INTERPRETATION_VALUE_YCB_CR = 6; + int PHOTOMETRIC_INTERPRETATION_VALUE_CIELAB = 8; + int PHOTOMETRIC_INTERPRETATION_VALUE_ICCLAB = 9; + int PHOTOMETRIC_INTERPRETATION_VALUE_ITULAB = 10; + int PHOTOMETRIC_INTERPRETATION_VALUE_COLOR_FILTER_ARRAY = 32803; + int PHOTOMETRIC_INTERPRETATION_VALUE_PIXAR_LOG_L = 32844; + int PHOTOMETRIC_INTERPRETATION_VALUE_PIXAR_LOG_LUV = 32845; + int PHOTOMETRIC_INTERPRETATION_VALUE_LINEAR_RAW = 34892; + + TagInfoShort TIFF_TAG_THRESHHOLDING = new TagInfoShort( "Threshholding", 0x107, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int THRESHOLDING_VALUE_NO_DITHERING_OR_HALFTONING = 1; - public static final int THRESHOLDING_VALUE_ORDERED_DITHER_OR_HALFTONE = 2; - public static final int THRESHOLDING_VALUE_RANDOMIZED_DITHER = 3; + int THRESHOLDING_VALUE_NO_DITHERING_OR_HALFTONING = 1; + int THRESHOLDING_VALUE_ORDERED_DITHER_OR_HALFTONE = 2; + int THRESHOLDING_VALUE_RANDOMIZED_DITHER = 3; - public static final TagInfoShort TIFF_TAG_CELL_WIDTH = new TagInfoShort( + TagInfoShort TIFF_TAG_CELL_WIDTH = new TagInfoShort( "Cell Width", 0x108, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_CELL_LENGTH = new TagInfoShort( + TagInfoShort TIFF_TAG_CELL_LENGTH = new TagInfoShort( "Cell Length", 0x109, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_FILL_ORDER = new TagInfoShort( + TagInfoShort TIFF_TAG_FILL_ORDER = new TagInfoShort( "Fill Order", 0x10A, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int FILL_ORDER_VALUE_NORMAL = 1; - public static final int FILL_ORDER_VALUE_REVERSED = 2; + int FILL_ORDER_VALUE_NORMAL = 1; + int FILL_ORDER_VALUE_REVERSED = 2; - public static final TagInfoAscii TIFF_TAG_DOCUMENT_NAME = new TagInfoAscii( + TagInfoAscii TIFF_TAG_DOCUMENT_NAME = new TagInfoAscii( "Document Name", 0x10D, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_IMAGE_DESCRIPTION = new TagInfoAscii( + TagInfoAscii TIFF_TAG_IMAGE_DESCRIPTION = new TagInfoAscii( "Image Description", 0x10E, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_MAKE = new TagInfoAscii( + TagInfoAscii TIFF_TAG_MAKE = new TagInfoAscii( "Make", 0x10F, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_MODEL = new TagInfoAscii( + TagInfoAscii TIFF_TAG_MODEL = new TagInfoAscii( "Model", 0x110, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_STRIP_OFFSETS = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_STRIP_OFFSETS = new TagInfoShortOrLong( "Strip Offsets", 0x111, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT, true); - public static final TagInfoShort TIFF_TAG_ORIENTATION = new TagInfoShort( + TagInfoShort TIFF_TAG_ORIENTATION = new TagInfoShort( "Orientation", 0x112, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int ORIENTATION_VALUE_HORIZONTAL_NORMAL = 1; - public static final int ORIENTATION_VALUE_MIRROR_HORIZONTAL = 2; - public static final int ORIENTATION_VALUE_ROTATE_180 = 3; - public static final int ORIENTATION_VALUE_MIRROR_VERTICAL = 4; - public static final int ORIENTATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_270_CW = 5; - public static final int ORIENTATION_VALUE_ROTATE_90_CW = 6; - public static final int ORIENTATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_90_CW = 7; - public static final int ORIENTATION_VALUE_ROTATE_270_CW = 8; + int ORIENTATION_VALUE_HORIZONTAL_NORMAL = 1; + int ORIENTATION_VALUE_MIRROR_HORIZONTAL = 2; + int ORIENTATION_VALUE_ROTATE_180 = 3; + int ORIENTATION_VALUE_MIRROR_VERTICAL = 4; + int ORIENTATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_270_CW = 5; + int ORIENTATION_VALUE_ROTATE_90_CW = 6; + int ORIENTATION_VALUE_MIRROR_HORIZONTAL_AND_ROTATE_90_CW = 7; + int ORIENTATION_VALUE_ROTATE_270_CW = 8; - public static final TagInfoShort TIFF_TAG_SAMPLES_PER_PIXEL = new TagInfoShort( + TagInfoShort TIFF_TAG_SAMPLES_PER_PIXEL = new TagInfoShort( "Samples Per Pixel", 0x115, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_ROWS_PER_STRIP = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_ROWS_PER_STRIP = new TagInfoShortOrLong( "Rows Per Strip", 0x116, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_STRIP_BYTE_COUNTS = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_STRIP_BYTE_COUNTS = new TagInfoShortOrLong( "Strip Byte Counts", 0x117, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_MIN_SAMPLE_VALUE = new TagInfoShort( + TagInfoShort TIFF_TAG_MIN_SAMPLE_VALUE = new TagInfoShort( "Min Sample Value", 0x118, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_MAX_SAMPLE_VALUE = new TagInfoShort( + TagInfoShort TIFF_TAG_MAX_SAMPLE_VALUE = new TagInfoShort( "Max Sample Value", 0x119, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_XRESOLUTION = new TagInfoRational( + TagInfoRational TIFF_TAG_XRESOLUTION = new TagInfoRational( "XResolution", 0x11A, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_YRESOLUTION = new TagInfoRational( + TagInfoRational TIFF_TAG_YRESOLUTION = new TagInfoRational( "YResolution", 0x11B, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_PLANAR_CONFIGURATION = new TagInfoShort( + TagInfoShort TIFF_TAG_PLANAR_CONFIGURATION = new TagInfoShort( "Planar Configuration", 0x11C, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int PLANAR_CONFIGURATION_VALUE_CHUNKY = 1; - public static final int PLANAR_CONFIGURATION_VALUE_PLANAR = 2; + int PLANAR_CONFIGURATION_VALUE_CHUNKY = 1; + int PLANAR_CONFIGURATION_VALUE_PLANAR = 2; - public static final TagInfoAscii TIFF_TAG_PAGE_NAME = new TagInfoAscii( + TagInfoAscii TIFF_TAG_PAGE_NAME = new TagInfoAscii( "Page Name", 0x11D, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_XPOSITION = new TagInfoRational( + TagInfoRational TIFF_TAG_XPOSITION = new TagInfoRational( "XPosition", 0x11E, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_YPOSITION = new TagInfoRational( - "YPosition", 0x11F, -1, + TagInfoRational TIFF_TAG_YPOSITION = new TagInfoRational( + "YPosition", 0x11F, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_FREE_OFFSETS = new TagInfoLong( + TagInfoLong TIFF_TAG_FREE_OFFSETS = new TagInfoLong( "Free Offsets", 0x120, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_FREE_BYTE_COUNTS = new TagInfoLong( + TagInfoLong TIFF_TAG_FREE_BYTE_COUNTS = new TagInfoLong( "Free Byte Counts", 0x121, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_GRAY_RESPONSE_UNIT = new TagInfoShort( + TagInfoShort TIFF_TAG_GRAY_RESPONSE_UNIT = new TagInfoShort( "Gray Response Unit", 0x122, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int GRAY_RESPONSE_UNIT_VALUE_0_1 = 1; - public static final int GRAY_RESPONSE_UNIT_VALUE_0_01 = 2; - public static final int GRAY_RESPONSE_UNIT_VALUE_0_001 = 3; - public static final int GRAY_RESPONSE_UNIT_VALUE_0_0001 = 4; - public static final int GRAY_RESPONSE_UNIT_VALUE_0_00001 = 5; + int GRAY_RESPONSE_UNIT_VALUE_0_1 = 1; + int GRAY_RESPONSE_UNIT_VALUE_0_01 = 2; + int GRAY_RESPONSE_UNIT_VALUE_0_001 = 3; + int GRAY_RESPONSE_UNIT_VALUE_0_0001 = 4; + int GRAY_RESPONSE_UNIT_VALUE_0_00001 = 5; - public static final TagInfoShort TIFF_TAG_GRAY_RESPONSE_CURVE = new TagInfoShort( + TagInfoShort TIFF_TAG_GRAY_RESPONSE_CURVE = new TagInfoShort( "Gray Response Curve", 0x123, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_T4_OPTIONS = new TagInfoLong( + TagInfoLong TIFF_TAG_T4_OPTIONS = new TagInfoLong( "T4 Options", 0x124, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_T6_OPTIONS = new TagInfoLong( + TagInfoLong TIFF_TAG_T6_OPTIONS = new TagInfoLong( "T6 Options", 0x125, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_RESOLUTION_UNIT = new TagInfoShort( + TagInfoShort TIFF_TAG_RESOLUTION_UNIT = new TagInfoShort( "Resolution Unit", 0x128, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int RESOLUTION_UNIT_VALUE_NONE = 1; - public static final int RESOLUTION_UNIT_VALUE_INCHES = 2; - public static final int RESOLUTION_UNIT_VALUE_CM = 3; + int RESOLUTION_UNIT_VALUE_NONE = 1; + int RESOLUTION_UNIT_VALUE_INCHES = 2; + int RESOLUTION_UNIT_VALUE_CM = 3; - public static final TagInfoShort TIFF_TAG_PAGE_NUMBER = new TagInfoShort( + TagInfoShort TIFF_TAG_PAGE_NUMBER = new TagInfoShort( "Page Number", 0x129, 2, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_TRANSFER_FUNCTION = new TagInfoShort( + TagInfoShort TIFF_TAG_TRANSFER_FUNCTION = new TagInfoShort( "Transfer Function", 0x12D, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_SOFTWARE = new TagInfoAscii( + TagInfoAscii TIFF_TAG_SOFTWARE = new TagInfoAscii( "Software", 0x131, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_DATE_TIME = new TagInfoAscii( + TagInfoAscii TIFF_TAG_DATE_TIME = new TagInfoAscii( "Date Time", 0x132, 20, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_ARTIST = new TagInfoAscii( + TagInfoAscii TIFF_TAG_ARTIST = new TagInfoAscii( "Artist", 0x13B, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_HOST_COMPUTER = new TagInfoAscii( + TagInfoAscii TIFF_TAG_HOST_COMPUTER = new TagInfoAscii( "Host Computer", 0x13C, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_PREDICTOR = new TagInfoShort( + TagInfoShort TIFF_TAG_PREDICTOR = new TagInfoShort( "Predictor", 0x13D, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int PREDICTOR_VALUE_NONE = 1; - public static final int PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING = 2; + int PREDICTOR_VALUE_NONE = 1; + int PREDICTOR_VALUE_HORIZONTAL_DIFFERENCING = 2; - public static final TagInfoRational TIFF_TAG_WHITE_POINT = new TagInfoRational( + TagInfoRational TIFF_TAG_WHITE_POINT = new TagInfoRational( "White Point", 0x13E, 2, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_PRIMARY_CHROMATICITIES = new TagInfoRational( + TagInfoRational TIFF_TAG_PRIMARY_CHROMATICITIES = new TagInfoRational( "Primary Chromaticities", 0x13F, 6, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_COLOR_MAP = new TagInfoShort( + TagInfoShort TIFF_TAG_COLOR_MAP = new TagInfoShort( "Color Map", 0x140, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_HALFTONE_HINTS = new TagInfoShort( + TagInfoShort TIFF_TAG_HALFTONE_HINTS = new TagInfoShort( "Halftone Hints", 0x141, 2, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_TILE_WIDTH = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_TILE_WIDTH = new TagInfoShortOrLong( "Tile Width", 0x142, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShortOrLong TIFF_TAG_TILE_LENGTH = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_TILE_LENGTH = new TagInfoShortOrLong( "Tile Length", 0x143, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_TILE_OFFSETS = new TagInfoLong( + TagInfoLong TIFF_TAG_TILE_OFFSETS = new TagInfoLong( "Tile Offsets", 0x144, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT, true); - public static final TagInfoShortOrLong TIFF_TAG_TILE_BYTE_COUNTS = new TagInfoShortOrLong( + TagInfoShortOrLong TIFF_TAG_TILE_BYTE_COUNTS = new TagInfoShortOrLong( "Tile Byte Counts", 0x145, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_INK_SET = new TagInfoShort( + TagInfoShort TIFF_TAG_INK_SET = new TagInfoShort( "Ink Set", 0x14C, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int INK_SET_VALUE_CMYK = 1; - public static final int INK_SET_VALUE_NOT_CMYK = 2; + int INK_SET_VALUE_CMYK = 1; + int INK_SET_VALUE_NOT_CMYK = 2; - public static final TagInfoAscii TIFF_TAG_INK_NAMES = new TagInfoAscii( + TagInfoAscii TIFF_TAG_INK_NAMES = new TagInfoAscii( "Ink Names", 0x14D, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_NUMBER_OF_INKS = new TagInfoShort( + TagInfoShort TIFF_TAG_NUMBER_OF_INKS = new TagInfoShort( "Number Of Inks", 0x14E, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoByteOrShort TIFF_TAG_DOT_RANGE = new TagInfoByteOrShort( + TagInfoByteOrShort TIFF_TAG_DOT_RANGE = new TagInfoByteOrShort( "Dot Range", 0x150, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_TARGET_PRINTER = new TagInfoAscii( + TagInfoAscii TIFF_TAG_TARGET_PRINTER = new TagInfoAscii( "Target Printer", 0x151, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_EXTRA_SAMPLES = new TagInfoShort( + TagInfoShort TIFF_TAG_EXTRA_SAMPLES = new TagInfoShort( "Extra Samples", 0x152, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_SAMPLE_FORMAT = new TagInfoShort( + TagInfoShort TIFF_TAG_SAMPLE_FORMAT = new TagInfoShort( "Sample Format", 0x153, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int SAMPLE_FORMAT_VALUE_UNSIGNED_INTEGER = 1; - public static final int SAMPLE_FORMAT_VALUE_TWOS_COMPLEMENT_SIGNED_INTEGER = 2; - public static final int SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT = 3; - public static final int SAMPLE_FORMAT_VALUE_UNDEFINED = 4; - public static final int SAMPLE_FORMAT_VALUE_COMPLEX_INTEGER = 5; - public static final int SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT_1 = 6; + int SAMPLE_FORMAT_VALUE_UNSIGNED_INTEGER = 1; + int SAMPLE_FORMAT_VALUE_TWOS_COMPLEMENT_SIGNED_INTEGER = 2; + int SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT = 3; + int SAMPLE_FORMAT_VALUE_UNDEFINED = 4; + int SAMPLE_FORMAT_VALUE_COMPLEX_INTEGER = 5; + int SAMPLE_FORMAT_VALUE_IEEE_FLOATING_POINT_1 = 6; - public static final TagInfoAny TIFF_TAG_SMIN_SAMPLE_VALUE = new TagInfoAny( + TagInfoAny TIFF_TAG_SMIN_SAMPLE_VALUE = new TagInfoAny( "SMin Sample Value", 0x154, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAny TIFF_TAG_SMAX_SAMPLE_VALUE = new TagInfoAny( + TagInfoAny TIFF_TAG_SMAX_SAMPLE_VALUE = new TagInfoAny( "SMax Sample Value", 0x155, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_TRANSFER_RANGE = new TagInfoShort( + TagInfoShort TIFF_TAG_TRANSFER_RANGE = new TagInfoShort( "Transfer Range", 0x156, 6, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_JPEG_PROC = new TagInfoShort( + TagInfoShort TIFF_TAG_JPEG_PROC = new TagInfoShort( "JPEGProc", 0x200, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int JPEGPROC_VALUE_BASELINE = 1; - public static final int JPEGPROC_VALUE_LOSSLESS = 14; + int JPEGPROC_VALUE_BASELINE = 1; + int JPEGPROC_VALUE_LOSSLESS = 14; - public static final TagInfoLong TIFF_TAG_JPEG_INTERCHANGE_FORMAT = new TagInfoLong( + TagInfoLong TIFF_TAG_JPEG_INTERCHANGE_FORMAT = new TagInfoLong( "JPEGInterchange Format", 0x201, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT, true); - public static final TagInfoLong TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = new TagInfoLong( + TagInfoLong TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH = new TagInfoLong( "JPEGInterchange Format Length", 0x202, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_JPEG_RESTART_INTERVAL = new TagInfoShort( + TagInfoShort TIFF_TAG_JPEG_RESTART_INTERVAL = new TagInfoShort( "JPEGRestart Interval", 0x203, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_JPEG_LOSSLESS_PREDICTORS = new TagInfoShort( + TagInfoShort TIFF_TAG_JPEG_LOSSLESS_PREDICTORS = new TagInfoShort( "JPEGLossless Predictors", 0x205, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_JPEG_POINT_TRANSFORMS = new TagInfoShort( + TagInfoShort TIFF_TAG_JPEG_POINT_TRANSFORMS = new TagInfoShort( "JPEGPoint Transforms", 0x206, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_JPEG_QTABLES = new TagInfoLong( + TagInfoLong TIFF_TAG_JPEG_QTABLES = new TagInfoLong( "JPEGQTables", 0x207, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_JPEG_DCTABLES = new TagInfoLong( + TagInfoLong TIFF_TAG_JPEG_DCTABLES = new TagInfoLong( "JPEGDCTables", 0x208, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoLong TIFF_TAG_JPEG_ACTABLES = new TagInfoLong( + TagInfoLong TIFF_TAG_JPEG_ACTABLES = new TagInfoLong( "JPEGACTables", 0x209, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoRational TIFF_TAG_YCBCR_COEFFICIENTS = new TagInfoRational( + TagInfoRational TIFF_TAG_YCBCR_COEFFICIENTS = new TagInfoRational( "YCbCr Coefficients", 0x211, 3, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_YCBCR_SUB_SAMPLING = new TagInfoShort( + TagInfoShort TIFF_TAG_YCBCR_SUB_SAMPLING = new TagInfoShort( "YCbCr Sub Sampling", 0x212, 2, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoShort TIFF_TAG_YCBCR_POSITIONING = new TagInfoShort( + TagInfoShort TIFF_TAG_YCBCR_POSITIONING = new TagInfoShort( "YCbCr Positioning", 0x213, 1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final int YCB_CR_POSITIONING_VALUE_CENTERED = 1; - public static final int YCB_CR_POSITIONING_VALUE_CO_SITED = 2; - public static final TagInfoLong TIFF_TAG_REFERENCE_BLACK_WHITE = new TagInfoLong( + TagInfoLong TIFF_TAG_REFERENCE_BLACK_WHITE = new TagInfoLong( "Reference Black White", 0x214, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoAscii TIFF_TAG_COPYRIGHT = new TagInfoAscii( + TagInfoAscii TIFF_TAG_COPYRIGHT = new TagInfoAscii( "Copyright", 0x8298, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); - public static final TagInfoByte TIFF_TAG_XMP = new TagInfoByte( + TagInfoByte TIFF_TAG_XMP = new TagInfoByte( "XMP", 0x2BC, -1, TiffDirectoryType.TIFF_DIRECTORY_ROOT); // TODO: - // public static final TagInfo2 TIFF_TAG_UNKNOWN = null; - public static final TagInfo TIFF_TAG_UNKNOWN = new TagInfoUnknown( + // TagInfo2 TIFF_TAG_UNKNOWN = null; + TagInfo TIFF_TAG_UNKNOWN = new TagInfoUnknown( "Unknown Tag", -1, TagInfo.LENGTH_UNKNOWN, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_TIFF_TAGS = - Collections.unmodifiableList(Arrays.asList( - TIFF_TAG_NEW_SUBFILE_TYPE, TIFF_TAG_SUBFILE_TYPE, + List ALL_TIFF_TAGS = + List.of(TIFF_TAG_NEW_SUBFILE_TYPE, TIFF_TAG_SUBFILE_TYPE, TIFF_TAG_IMAGE_WIDTH, TIFF_TAG_IMAGE_LENGTH, TIFF_TAG_BITS_PER_SAMPLE, TIFF_TAG_COMPRESSION, TIFF_TAG_PHOTOMETRIC_INTERPRETATION, TIFF_TAG_THRESHHOLDING, @@ -473,5 +447,5 @@ public interface TiffTagConstants TIFF_TAG_YCBCR_COEFFICIENTS, TIFF_TAG_YCBCR_SUB_SAMPLING, TIFF_TAG_YCBCR_POSITIONING, TIFF_TAG_REFERENCE_BLACK_WHITE, TIFF_TAG_COPYRIGHT, - TIFF_TAG_XMP)); + TIFF_TAG_XMP); } \ No newline at end of file diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/WangTagConstants.java b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/WangTagConstants.java index 65f0d069..2933eb63 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/constants/WangTagConstants.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/constants/WangTagConstants.java @@ -1,22 +1,19 @@ package org.apache.commons.imaging.formats.tiff.constants; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoByte; +import java.util.List; + /** * Wang/Eastman Software/Kodac/eiStream/Imaging for Windows tags, * undocumented and in need of more work. */ public interface WangTagConstants { - public static final TagInfoByte EXIF_TAG_WANG_ANNOTATION = new TagInfoByte( + TagInfoByte EXIF_TAG_WANG_ANNOTATION = new TagInfoByte( "Wang Annotation", 0x80a4, -1, TiffDirectoryType.EXIF_DIRECTORY_UNKNOWN); - public static final List ALL_WANG_TAGS = - Collections.unmodifiableList(Arrays.asList(new TagInfo[] { - EXIF_TAG_WANG_ANNOTATION })); + List ALL_WANG_TAGS = + List.of(EXIF_TAG_WANG_ANNOTATION); } 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 75dc2aaf..bbdd9d7c 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 @@ -85,13 +85,13 @@ public void interpretPixel(ImageBuilder imageBuilder, int samples[], int x, int float ref_Y = 100.000f; float ref_Z = 108.883f; - X = ref_X * var_X; //ref_X = 95.047 Observer= 2°, Illuminant= D65 + X = ref_X * var_X; //ref_X = 95.047 Observer= 2', Illuminant= D65 Y = ref_Y * var_Y; //ref_Y = 100.000 Z = ref_Z * var_Z; //ref_Z = 108.883 } - // ref_X = 95.047 //Observer = 2°, Illuminant = D65 + // ref_X = 95.047 //Observer = 2', Illuminant = D65 // ref_Y = 100.000 // ref_Z = 108.883 diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java index 024902ea..343a827d 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfo.java @@ -75,7 +75,7 @@ public TagInfo(String name, int tag, List dataTypes, int length, { this.name = name; this.tag = tag; - this.dataTypes = Collections.unmodifiableList(new ArrayList(dataTypes)); + this.dataTypes = Collections.unmodifiableList(new ArrayList<>(dataTypes)); this.length = length; this.directoryType = exifDirectory; this.isOffset = isOffset; 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 17196478..29f8acd0 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 @@ -491,7 +491,7 @@ public void writeImage(BufferedImage src, OutputStream os, Map params) private void combineUserExifIntoFinalExif(TiffOutputSet userExif, TiffOutputSet outputSet) throws ImageWriteException { List outputDirectories = outputSet.getDirectories(); - Collections.sort(outputDirectories, TiffOutputDirectory.COMPARATOR); + outputDirectories.sort(TiffOutputDirectory.COMPARATOR); for (TiffOutputDirectory userDirectory : userExif.getDirectories()) { int location = Collections.binarySearch(outputDirectories, userDirectory, TiffOutputDirectory.COMPARATOR); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java index 9f6f4d88..eb03c0db 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java @@ -41,17 +41,14 @@ import org.apache.commons.imaging.formats.tiff.constants.ExifTagConstants; import org.apache.commons.imaging.util.Debug; -public class TiffImageWriterLossless extends TiffImageWriterBase -{ +public class TiffImageWriterLossless extends TiffImageWriterBase { private final byte exifBytes[]; - public TiffImageWriterLossless(byte exifBytes[]) - { + public TiffImageWriterLossless(byte exifBytes[]) { this.exifBytes = exifBytes; } - public TiffImageWriterLossless(int byteOrder, byte exifBytes[]) - { + public TiffImageWriterLossless(int byteOrder, byte exifBytes[]) { super(byteOrder); this.exifBytes = exifBytes; } @@ -68,8 +65,7 @@ public TiffImageWriterLossless(int byteOrder, byte exifBytes[]) // } // } - private void dumpElements(List elements) throws IOException - { + private void dumpElements(List elements) throws IOException { // try // { ByteSource byteSource = new ByteSourceArray(exifBytes); @@ -83,34 +79,28 @@ private void dumpElements(List elements) throws IOException } private void dumpElements(ByteSource byteSource, List elements) - throws IOException - { + throws IOException { int last = TIFF_HEADER_SIZE; - for (int i = 0; i < elements.size(); i++) - { + for (int i = 0; i < elements.size(); i++) { TiffElement element = elements.get(i); - if (element.offset > last) - { + if (element.offset > last) { final int SLICE_SIZE = 32; int gepLength = element.offset - last; Debug.debug("gap of " + gepLength + " bytes."); byte bytes[] = byteSource.getBlock(last, gepLength); - if (bytes.length > 2 * SLICE_SIZE) - { + if (bytes.length > 2 * SLICE_SIZE) { Debug.debug("\t" + "head", BinaryFileFunctions.head(bytes, SLICE_SIZE)); Debug.debug("\t" + "tail", BinaryFileFunctions.tail(bytes, SLICE_SIZE)); - } - else + } else Debug.debug("\t" + "bytes", bytes); } Debug.debug("element[" + i + "]:" + element.getElementDescription() + " (" + element.offset + " + " + element.length + " = " + (element.offset + element.length) + ")"); - if (element instanceof TiffDirectory) - { + if (element instanceof TiffDirectory) { TiffDirectory dir = (TiffDirectory) element; Debug.debug("\t" + "next Directory Offset: " + dir.nextDirectoryOffset); @@ -120,10 +110,8 @@ private void dumpElements(ByteSource byteSource, List elements) Debug.debug(); } - private List analyzeOldTiff() throws ImageWriteException, IOException - { - try - { + private List analyzeOldTiff() throws ImageWriteException, IOException { + try { ByteSource byteSource = new ByteSourceArray(exifBytes); Map params = null; FormatCompliance formatCompliance = FormatCompliance.getDefault(); @@ -134,14 +122,12 @@ private List analyzeOldTiff() throws ImageWriteException, IOExcepti // result.add(contents.header); // ? List directories = contents.directories; - for (int d = 0; d < directories.size(); d++) - { + for (int d = 0; d < directories.size(); d++) { TiffDirectory directory = directories.get(d); elements.add(directory); List fields = directory.getDirectoryEntrys(); - for (int f = 0; f < fields.size(); f++) - { + for (int f = 0; f < fields.size(); f++) { TiffField field = fields.get(f); if (field.tag == ExifTagConstants.EXIF_TAG_MAKER_NOTE.tag) { // Some maker notes reference values stored @@ -167,8 +153,7 @@ private List analyzeOldTiff() throws ImageWriteException, IOExcepti elements.add(jpegImageData); TiffImageData tiffImageData = directory.getTiffImageData(); - if (tiffImageData != null) - { + if (tiffImageData != null) { TiffElement.DataElement data[] = tiffImageData .getImageData(); for (int i = 0; i < data.length; i++) @@ -176,7 +161,7 @@ private List analyzeOldTiff() throws ImageWriteException, IOExcepti } } - Collections.sort(elements, TiffElement.COMPARATOR); + elements.sort(TiffElement.COMPARATOR); // dumpElements(byteSource, elements); @@ -186,24 +171,18 @@ private List analyzeOldTiff() throws ImageWriteException, IOExcepti // int last = TIFF_HEADER_SIZE; TiffElement start = null; int index = -1; - for (int i = 0; i < elements.size(); i++) - { + for (int i = 0; i < elements.size(); i++) { TiffElement element = elements.get(i); int lastElementByte = element.offset + element.length; - if (start == null) - { + if (start == null) { start = element; index = lastElementByte; - } - else if (element.offset - index > TOLERANCE) - { + } else if (element.offset - index > TOLERANCE) { result.add(new TiffElement.Stub(start.offset, index - start.offset)); start = element; index = lastElementByte; - } - else - { + } else { index = lastElementByte; } } @@ -215,29 +194,24 @@ else if (element.offset - index > TOLERANCE) // dumpElements(byteSource, result); return result; - } - catch (ImageReadException e) - { + } catch (ImageReadException e) { throw new ImageWriteException(e.getMessage(), e); } } @Override public void write(OutputStream os, TiffOutputSet outputSet) - throws IOException, ImageWriteException - { + throws IOException, ImageWriteException { List analysis = analyzeOldTiff(); int oldLength = exifBytes.length; if (analysis.size() < 1) throw new ImageWriteException("Couldn't analyze old tiff data."); - else if (analysis.size() == 1) - { + else if (analysis.size() == 1) { TiffElement onlyElement = analysis.get(0); // Debug.debug("onlyElement", onlyElement.getElementDescription()); if (onlyElement.offset == TIFF_HEADER_SIZE && onlyElement.offset + onlyElement.length - + TIFF_HEADER_SIZE == oldLength) - { + + TIFF_HEADER_SIZE == oldLength) { // no gaps in old data, safe to complete overwrite. new TiffImageWriterLossy(byteOrder).write(os, outputSet); return; @@ -262,49 +236,41 @@ else if (analysis.size() == 1) } - private static final Comparator ELEMENT_SIZE_COMPARATOR = new Comparator() - { - public int compare(TiffElement e1, TiffElement e2) - { + private static final Comparator ELEMENT_SIZE_COMPARATOR = new Comparator() { + public int compare(TiffElement e1, TiffElement e2) { return e1.length - e2.length; } }; - private static final Comparator ITEM_SIZE_COMPARATOR = new Comparator() - { - public int compare(TiffOutputItem e1, TiffOutputItem e2) - { + private static final Comparator ITEM_SIZE_COMPARATOR = new Comparator() { + public int compare(TiffOutputItem e1, TiffOutputItem e2) { return e1.getItemLength() - e2.getItemLength(); } }; - private int updateOffsetsStep(List analysis, List outputItems) - { + private int updateOffsetsStep(List analysis, List outputItems) { // items we cannot fit into a gap, we shall append to tail. int overflowIndex = exifBytes.length; // make copy. - List unusedElements = new ArrayList(analysis); + List unusedElements = new ArrayList<>(analysis); // should already be in order of offset, but make sure. - Collections.sort(unusedElements, TiffElement.COMPARATOR); + unusedElements.sort(TiffElement.COMPARATOR); Collections.reverse(unusedElements); // any items that represent a gap at the end of the exif segment, can be discarded. - while (unusedElements.size() > 0) - { + while (unusedElements.size() > 0) { TiffElement element = unusedElements.get(0); int elementEnd = element.offset + element.length; - if (elementEnd == overflowIndex) - { + if (elementEnd == overflowIndex) { // discarding a tail element. should only happen once. overflowIndex -= element.length; unusedElements.remove(0); - } - else + } else break; } - Collections.sort(unusedElements, ELEMENT_SIZE_COMPARATOR); + unusedElements.sort(ELEMENT_SIZE_COMPARATOR); Collections.reverse(unusedElements); // Debug.debug("unusedElements"); @@ -312,11 +278,10 @@ private int updateOffsetsStep(List analysis, List o // make copy. List unplacedItems = new ArrayList(outputItems); - Collections.sort(unplacedItems, ITEM_SIZE_COMPARATOR); + unplacedItems.sort(ITEM_SIZE_COMPARATOR); Collections.reverse(unplacedItems); - while (unplacedItems.size() > 0) - { + while (unplacedItems.size() > 0) { // pop off largest unplaced item. TiffOutputItem outputItem = unplacedItems.remove(0); int outputItemLength = outputItem.getItemLength(); @@ -326,73 +291,48 @@ private int updateOffsetsStep(List analysis, List o // search for the smallest possible element large enough to hold the item. TiffElement bestFit = null; - for (int i = 0; i < unusedElements.size(); i++) - { + for (int i = 0; i < unusedElements.size(); i++) { TiffElement element = unusedElements.get(i); if (element.length >= outputItemLength) bestFit = element; else break; } - if (null == bestFit) - { + if (null == bestFit) { // we couldn't place this item. overflow. outputItem.setOffset(overflowIndex); overflowIndex += outputItemLength; - } - else - { + } else { outputItem.setOffset(bestFit.offset); unusedElements.remove(bestFit); - if (bestFit.length > outputItemLength) - { + if (bestFit.length > outputItemLength) { // not a perfect fit. int excessOffset = bestFit.offset + outputItemLength; int excessLength = bestFit.length - outputItemLength; unusedElements.add(new TiffElement.Stub(excessOffset, excessLength)); // make sure the new element is in the correct order. - Collections.sort(unusedElements, ELEMENT_SIZE_COMPARATOR); + unusedElements.sort(ELEMENT_SIZE_COMPARATOR); Collections.reverse(unusedElements); } } } return overflowIndex; - // - // if (true) - // throw new IOException("mew"); - // - // // int offset = TIFF_HEADER_SIZE; - // int offset = exifBytes.length; - // - // for (int i = 0; i < outputItems.size(); i++) - // { - // TiffOutputItem outputItem = (TiffOutputItem) outputItems.get(i); - // - // outputItem.setOffset(offset); - // int itemLength = outputItem.getItemLength(); - // offset += itemLength; - // - // int remainder = imageDataPaddingLength(itemLength); - // offset += remainder; - // } } - private static class BufferOutputStream extends OutputStream - { + + private static class BufferOutputStream extends OutputStream { private final byte buffer[]; private int index; - public BufferOutputStream(final byte[] buffer, final int index) - { + public BufferOutputStream(final byte[] buffer, final int index) { this.buffer = buffer; this.index = index; } @Override - public void write(int b) throws IOException - { + public void write(int b) throws IOException { if (index >= buffer.length) throw new IOException("Buffer overflow."); @@ -400,8 +340,7 @@ public void write(int b) throws IOException } @Override - public void write(byte b[], int off, int len) throws IOException - { + public void write(byte b[], int off, int len) throws IOException { if (index + len > buffer.length) throw new IOException("Buffer overflow."); System.arraycopy(b, off, buffer, index, len); @@ -410,9 +349,8 @@ public void write(byte b[], int off, int len) throws IOException } private void writeStep(OutputStream os, TiffOutputSet outputSet, - List analysis, List outputItems, int outputLength) - throws IOException, ImageWriteException - { + List analysis, List outputItems, int outputLength) + throws IOException, ImageWriteException { TiffOutputDirectory rootDirectory = outputSet.getRootDirectory(); byte output[] = new byte[outputLength]; @@ -431,11 +369,9 @@ private void writeStep(OutputStream os, TiffOutputSet outputSet, } // zero out the parsed pieces of old exif segment, in case we don't overwrite them. - for (int i = 0; i < analysis.size(); i++) - { + for (int i = 0; i < analysis.size(); i++) { TiffElement element = analysis.get(i); - for (int j = 0; j < element.length; j++) - { + for (int j = 0; j < element.length; j++) { int index = element.offset + j; if (index < output.length) output[index] = 0; @@ -443,8 +379,7 @@ private void writeStep(OutputStream os, TiffOutputSet outputSet, } // write in the new items - for (int i = 0; i < outputItems.size(); i++) - { + for (int i = 0; i < outputItems.size(); i++) { TiffOutputItem outputItem = outputItems.get(i); BufferOutputStream tos = new BufferOutputStream(output, outputItem diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java index 47ebfaef..3a683d49 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java @@ -56,36 +56,31 @@ import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoShortOrRational; import org.apache.commons.imaging.formats.tiff.taginfos.TagInfoXpString; -public final class TiffOutputDirectory extends TiffOutputItem implements - TiffConstants -{ +public final class TiffOutputDirectory extends TiffOutputItem implements TiffConstants { public final int type; - private final List fields = new ArrayList(); + private final List fields = new ArrayList<>(); private final int byteOrder; private TiffOutputDirectory nextDirectory = null; - public static final Comparator COMPARATOR = new Comparator() { - public int compare(TiffOutputDirectory o1, TiffOutputDirectory o2) { - if (o1.type < o2.type) { - return -1; - } else if (o1.type > o2.type) { - return 1; - } else { - return 0; - } + + public static final Comparator COMPARATOR = (o1, o2) -> { + if (o1.type < o2.type) { + return -1; + } else if (o1.type > o2.type) { + return 1; + } else { + return 0; } }; - public void setNextDirectory(TiffOutputDirectory nextDirectory) - { + public void setNextDirectory(TiffOutputDirectory nextDirectory) { this.nextDirectory = nextDirectory; } - public TiffOutputDirectory(final int type, final int byteOrder) - { + public TiffOutputDirectory(final int type, final int byteOrder) { this.type = type; this.byteOrder = byteOrder; } - + public void add(TagInfoByte tagInfo, byte... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -96,7 +91,7 @@ public void add(TagInfoByte tagInfo, byte... values) throws ImageWriteException TiffFieldTypeConstants.FIELD_TYPE_BYTE, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoAscii tagInfo, String... values) throws ImageWriteException { byte[] bytes = tagInfo.encodeValue(byteOrder, values); if (tagInfo.length > 0 && tagInfo.length != bytes.length) { @@ -107,7 +102,7 @@ public void add(TagInfoAscii tagInfo, String... values) throws ImageWriteExcepti TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes); add(tiffOutputField); } - + public void add(TagInfoShort tagInfo, short... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -118,7 +113,7 @@ public void add(TagInfoShort tagInfo, short... values) throws ImageWriteExceptio TiffFieldTypeConstants.FIELD_TYPE_SHORT, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoLong tagInfo, int... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -129,7 +124,7 @@ public void add(TagInfoLong tagInfo, int... values) throws ImageWriteException { TiffFieldTypeConstants.FIELD_TYPE_LONG, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoRational tagInfo, RationalNumber... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -140,7 +135,7 @@ public void add(TagInfoRational tagInfo, RationalNumber... values) throws ImageW TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoSByte tagInfo, byte... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -151,7 +146,7 @@ public void add(TagInfoSByte tagInfo, byte... values) throws ImageWriteException TiffFieldTypeConstants.FIELD_TYPE_SBYTE, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoSShort tagInfo, short... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -162,7 +157,7 @@ public void add(TagInfoSShort tagInfo, short... values) throws ImageWriteExcepti TiffFieldTypeConstants.FIELD_TYPE_SSHORT, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoSLong tagInfo, int... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -184,7 +179,7 @@ public void add(TagInfoSRational tagInfo, RationalNumber... values) throws Image TiffFieldTypeConstants.FIELD_TYPE_SRATIONAL, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoFloat tagInfo, float... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -261,7 +256,7 @@ public void add(TagInfoShortOrLongOrRational tagInfo, short... values) throws Im TiffFieldTypeConstants.FIELD_TYPE_SHORT, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoShortOrLongOrRational tagInfo, int... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -283,7 +278,7 @@ public void add(TagInfoShortOrLongOrRational tagInfo, RationalNumber... values) TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, values.length, bytes); add(tiffOutputField); } - + public void add(TagInfoShortOrRational tagInfo, short... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -312,14 +307,14 @@ public void add(TagInfoGpsText tagInfo, String value) throws ImageWriteException tagInfo.dataTypes.get(0), bytes.length, bytes); add(tiffOutputField); } - + public void add(TagInfoXpString tagInfo, String value) throws ImageWriteException { byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_BYTE, value, byteOrder); TiffOutputField tiffOutputField = new TiffOutputField(tagInfo.tag, tagInfo, TiffFieldTypeConstants.FIELD_TYPE_BYTE, bytes.length, bytes); add(tiffOutputField); } - + public void add(TagInfoAsciiOrByte tagInfo, String... values) throws ImageWriteException { byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, values, byteOrder); if (tagInfo.length > 0 && tagInfo.length != bytes.length) { @@ -330,7 +325,7 @@ public void add(TagInfoAsciiOrByte tagInfo, String... values) throws ImageWriteE TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes); add(tiffOutputField); } - + public void add(TagInfoAsciiOrRational tagInfo, String... values) throws ImageWriteException { byte[] bytes = tagInfo.encodeValue(TiffFieldTypeConstants.FIELD_TYPE_ASCII, values, byteOrder); if (tagInfo.length > 0 && tagInfo.length != bytes.length) { @@ -341,7 +336,7 @@ public void add(TagInfoAsciiOrRational tagInfo, String... values) throws ImageWr TiffFieldTypeConstants.FIELD_TYPE_ASCII, bytes.length, bytes); add(tiffOutputField); } - + public void add(TagInfoAsciiOrRational tagInfo, RationalNumber... values) throws ImageWriteException { if (tagInfo.length > 0 && tagInfo.length != values.length) { throw new ImageWriteException("Tag expects " + tagInfo.length + @@ -352,27 +347,22 @@ public void add(TagInfoAsciiOrRational tagInfo, RationalNumber... values) throws TiffFieldTypeConstants.FIELD_TYPE_RATIONAL, bytes.length, bytes); add(tiffOutputField); } - - public void add(TiffOutputField field) - { + + public void add(TiffOutputField field) { fields.add(field); } - public List getFields() - { + public List getFields() { return new ArrayList(fields); } - public void removeField(TagInfo tagInfo) - { + public void removeField(TagInfo tagInfo) { removeField(tagInfo.tag); } - public void removeField(int tag) - { + public void removeField(int tag) { List matches = new ArrayList(); - for (int i = 0; i < fields.size(); i++) - { + for (int i = 0; i < fields.size(); i++) { TiffOutputField field = fields.get(i); if (field.tag == tag) matches.add(field); @@ -380,15 +370,12 @@ public void removeField(int tag) fields.removeAll(matches); } - public TiffOutputField findField(TagInfo tagInfo) - { + public TiffOutputField findField(TagInfo tagInfo) { return findField(tagInfo.tag); } - public TiffOutputField findField(int tag) - { - for (int i = 0; i < fields.size(); i++) - { + public TiffOutputField findField(int tag) { + for (int i = 0; i < fields.size(); i++) { TiffOutputField field = fields.get(i); if (field.tag == tag) return field; @@ -396,41 +383,29 @@ public TiffOutputField findField(int tag) return null; } - public void sortFields() - { - Comparator comparator = new Comparator() { - public int compare(TiffOutputField e1, TiffOutputField e2) - { - if (e1.tag != e2.tag) - return e1.tag - e2.tag; - return e1.getSortHint() - e2.getSortHint(); - } + public void sortFields() { + Comparator comparator = (e1, e2) -> { + if (e1.tag != e2.tag) + return e1.tag - e2.tag; + return e1.getSortHint() - e2.getSortHint(); }; - Collections.sort(fields, comparator); + fields.sort(comparator); } - public String description() - { + public String description() { return TiffDirectory.description(type); } @Override public void writeItem(BinaryOutputStream bos) throws IOException, - ImageWriteException - { + ImageWriteException { // Write Directory Field Count bos.write2Bytes(fields.size()); // DirectoryFieldCount // Write Fields - for (int i = 0; i < fields.size(); i++) - { + for (int i = 0; i < fields.size(); i++) { TiffOutputField field = fields.get(i); field.writeField(bos); - -// Debug.debug("\t" + "writing field (" + field.tag + ", 0x" + -// Integer.toHexString(field.tag) + ")", field.tagInfo); -// if(field.tagInfo.isOffset()) -// Debug.debug("\t\tOFFSET!", field.bytes); } int nextDirectoryOffset = 0; @@ -446,68 +421,59 @@ public void writeItem(BinaryOutputStream bos) throws IOException, private JpegImageData jpegImageData = null; - public void setJpegImageData(JpegImageData rawJpegImageData) - { + public void setJpegImageData(JpegImageData rawJpegImageData) { this.jpegImageData = rawJpegImageData; } - public JpegImageData getRawJpegImageData() - { + public JpegImageData getRawJpegImageData() { return jpegImageData; } private TiffImageData tiffImageData = null; - public void setTiffImageData(TiffImageData rawTiffImageData) - { + public void setTiffImageData(TiffImageData rawTiffImageData) { this.tiffImageData = rawTiffImageData; } - public TiffImageData getRawTiffImageData() - { + public TiffImageData getRawTiffImageData() { return tiffImageData; } @Override - public int getItemLength() - { + public int getItemLength() { return TIFF_ENTRY_LENGTH * fields.size() + TIFF_DIRECTORY_HEADER_LENGTH + TIFF_DIRECTORY_FOOTER_LENGTH; } @Override - public String getItemDescription() - { + public String getItemDescription() { TiffDirectoryType dirType = TagConstantsUtils .getExifDirectoryType(type); return "Directory: " + dirType.name + " (" + type + ")"; } - private void removeFieldIfPresent(TagInfo tagInfo) - { + private void removeFieldIfPresent(TagInfo tagInfo) { TiffOutputField field = findField(tagInfo); if (null != field) fields.remove(field); } protected List getOutputItems(TiffOutputSummary outputSummary) - throws ImageWriteException - { + throws ImageWriteException { // first validate directory fields. removeFieldIfPresent(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT); removeFieldIfPresent(TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT_LENGTH); TiffOutputField jpegOffsetField = null; - if (null != jpegImageData) - { + if (null != jpegImageData) { jpegOffsetField = new TiffOutputField( TiffTagConstants.TIFF_TAG_JPEG_INTERCHANGE_FORMAT, FIELD_TYPE_LONG, 1, FieldType.getStubLocalValue()); add(jpegOffsetField); byte lengthValue[] = FIELD_TYPE_LONG.writeData( - new int[] { jpegImageData.length, }, + new int[]{jpegImageData.length,}, outputSummary.byteOrder); TiffOutputField jpegLengthField = new TiffOutputField( @@ -526,18 +492,15 @@ protected List getOutputItems(TiffOutputSummary outputSummary) TiffOutputField imageDataOffsetField; ImageDataOffsets imageDataInfo = null; - if (null != tiffImageData) - { + if (null != tiffImageData) { boolean stripsNotTiles = tiffImageData.stripsNotTiles(); TagInfo offsetTag; TagInfo byteCountsTag; - if (stripsNotTiles) - { + if (stripsNotTiles) { offsetTag = TiffTagConstants.TIFF_TAG_STRIP_OFFSETS; byteCountsTag = TiffTagConstants.TIFF_TAG_STRIP_BYTE_COUNTS; - } else - { + } else { offsetTag = TiffTagConstants.TIFF_TAG_TILE_OFFSETS; byteCountsTag = TiffTagConstants.TIFF_TAG_TILE_BYTE_COUNTS; } @@ -552,8 +515,7 @@ protected List getOutputItems(TiffOutputSummary outputSummary) imageDataOffsets = new int[imageData.length]; imageDataByteCounts = new int[imageData.length]; - for (int i = 0; i < imageData.length; i++) - { + for (int i = 0; i < imageData.length; i++) { imageDataByteCounts[i] = imageData[i].length; } @@ -562,8 +524,8 @@ protected List getOutputItems(TiffOutputSummary outputSummary) // Append imageData-related fields to first directory imageDataOffsetField = new TiffOutputField(offsetTag, FIELD_TYPE_LONG, imageDataOffsets.length, FIELD_TYPE_LONG - .writeData(imageDataOffsets, - outputSummary.byteOrder)); + .writeData(imageDataOffsets, + outputSummary.byteOrder)); add(imageDataOffsetField); // -------- @@ -587,8 +549,7 @@ protected List getOutputItems(TiffOutputSummary outputSummary) result.add(this); sortFields(); - for (int i = 0; i < fields.size(); i++) - { + for (int i = 0; i < fields.size(); i++) { TiffOutputField field = fields.get(i); if (field.isLocalValue()) continue; @@ -598,16 +559,14 @@ protected List getOutputItems(TiffOutputSummary outputSummary) // outputSummary.add(item, field); } - if (null != imageDataInfo) - { + if (null != imageDataInfo) { for (int i = 0; i < imageDataInfo.outputItems.length; i++) result.add(imageDataInfo.outputItems[i]); outputSummary.addTiffImageData(imageDataInfo); } - if (null != jpegImageData) - { + if (null != jpegImageData) { TiffOutputItem item = new TiffOutputItem.Value("JPEG image data", jpegImageData.data); result.add(item); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java index 03e3fd1a..b63d9c5a 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java @@ -137,7 +137,7 @@ public String toString(String prefix) { if (prefix == null) prefix = ""; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(prefix); result.append(tagInfo); diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java index aacab650..37e9087f 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java @@ -277,7 +277,7 @@ public String toString(String prefix) if (prefix == null) prefix = ""; - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(prefix); result.append("TiffOutputSet {"); diff --git a/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java b/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java index 7cf0d610..86681a75 100644 --- a/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java +++ b/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java @@ -25,7 +25,7 @@ public enum IccTagTypes implements IccTagType { // public static final IccTagType AToB0Tag = new IccTagType( // "AToB0Tag", // "lut8Type or lut16Type or lutAtoBType", - // "‘A2B0’ (41324230h)", + // "'A2B0' (41324230h)", // "This tag defines a color transform from Device to PCS using lookup table tag element structures. The processing", // "mechanisms are described in lut8Type or lut16Type or lutAtoBType.", // ); @@ -73,8 +73,8 @@ public enum IccTagTypes implements IccTagType { CALIBRATION_DATE_TIME_TAG( "calibrationDateTimeTag", "dateTimeType", 0x63616C74 - // "Profile calibration date and time. Initially, this tag matches the contents of the profile header’s creation", - // "date/time field. This allows applications and utilities to verify if this profile matches a vendor’s profile and", + // "Profile calibration date and time. Initially, this tag matches the contents of the profile header's creation", + // "date/time field. This allows applications and utilities to verify if this profile matches a vendor's profile and", // "how recently calibration has been performed.", ), @@ -124,7 +124,7 @@ public enum IccTagTypes implements IccTagType { // "the chromatically adapted value in the PCS.", // "The chromatic adaptation matrix is a combination of three separate conversions:", // "1) Conversion of source CIE XYZ tristimulus values to cone response tristimulus values.", - // "2) Adjustment of the cone response values for an observer’s chromatic adaptation.", + // "2) Adjustment of the cone response values for an observer's chromatic adaptation.", // "3) Conversion of the adjusted cone response tristimulus back to CIE XYZ values.", ), @@ -166,8 +166,8 @@ public enum IccTagTypes implements IccTagType { "lut8Type or lut16Type or lutBtoAType", 0x67616D74 // "Out of gamut tag. The processing mechanisms are described in lut8Type or lut16Type or lutBtoAType.", // "This tag takes PCS values as its input and produces a single channel of output. If the output value is 0, the", - // "PCS color is in-gamut. If the output is non-zero, the PCS color is out-of-gamut, with the output value “n+1”", - // "being at least as far out of gamut as the output value “n”.", + // "PCS color is in-gamut. If the output is non-zero, the PCS color is out-of-gamut, with the output value 'n+1'", + // "being at least as far out of gamut as the output value 'n'.", ), GRAY_TRC_TAG("grayTRCTag", @@ -234,7 +234,7 @@ public enum IccTagTypes implements IccTagType { "outputResponseTag", "responseCurveSet16Type", 0x72657370 // "Structure containing a description of the device response for which the profile is intended. The content of", // "this structure is described in 6.5.16.", - // "NOTE The user’s attention is called to the possibility that the use of this tag for device calibration may", + // "NOTE The user�s attention is called to the possibility that the use of this tag for device calibration may", // "require use of an invention covered by patent rights. By publication of this specification, no position is", // "taken with respect to the validity of this claim or of any patent rights in connection therewith. The patent", // "holder has, however, filed a statement of willingness to grant a license under these rights on reasonable", diff --git a/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java b/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java index 2c3b69e0..4bd71214 100644 --- a/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java +++ b/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java @@ -27,42 +27,36 @@ import org.apache.commons.imaging.ImageWriteException; import org.apache.commons.imaging.util.Debug; -public class MedianCutQuantizer -{ +public class MedianCutQuantizer { private final boolean ignoreAlpha; - public MedianCutQuantizer(boolean ignore_alpha) - { + public MedianCutQuantizer(boolean ignore_alpha) { this.ignoreAlpha = ignore_alpha; } - private static class ColorCount - { + private static class ColorCount { public final int argb; public int count = 0; public final int alpha, red, green, blue; - public ColorCount(int argb) - { + ColorCount(int argb) { this.argb = argb; alpha = 0xff & (argb >> 24); red = 0xff & (argb >> 16); green = 0xff & (argb >> 8); - blue = 0xff & (argb >> 0); + blue = 0xff & argb; // super.hashCode(); } @Override - public int hashCode() - { + public int hashCode() { return argb; } @Override - public boolean equals(Object o) - { + public boolean equals(Object o) { if (o instanceof ColorCount) { ColorCount other = (ColorCount) o; return other.argb == this.argb; @@ -72,42 +66,35 @@ public boolean equals(Object o) } - private class ColorGroup - { - // public final ColorGroup parent; - public ColorGroupCut cut = null; - // public final List children = new ArrayList(); - public int palette_index = -1; - - public final List color_counts; - public int min_red = Integer.MAX_VALUE; - public int max_red = Integer.MIN_VALUE; - public int min_green = Integer.MAX_VALUE; - public int max_green = Integer.MIN_VALUE; - public int min_blue = Integer.MAX_VALUE; - public int max_blue = Integer.MIN_VALUE; - public int min_alpha = Integer.MAX_VALUE; - public int max_alpha = Integer.MIN_VALUE; - - public final int alpha_diff; - public final int red_diff; - public final int green_diff; - public final int blue_diff; - - public final int max_diff; - public final int diff_total; - - public ColorGroup(final List color_counts) throws ImageWriteException - { + private class ColorGroup { + ColorGroupCut cut = null; + int palette_index = -1; + + final List color_counts; + int min_red = Integer.MAX_VALUE; + int max_red = Integer.MIN_VALUE; + int min_green = Integer.MAX_VALUE; + int max_green = Integer.MIN_VALUE; + int min_blue = Integer.MAX_VALUE; + int max_blue = Integer.MIN_VALUE; + int min_alpha = Integer.MAX_VALUE; + int max_alpha = Integer.MIN_VALUE; + + final int alpha_diff; + final int red_diff; + final int green_diff; + final int blue_diff; + + final int max_diff; + final int diff_total; + + ColorGroup(final List color_counts) throws ImageWriteException { this.color_counts = color_counts; if (color_counts.size() < 1) throw new ImageWriteException("empty color_group"); - for (int i = 0; i < color_counts.size(); i++) - { - ColorCount color = color_counts.get(i); - + for (ColorCount color : color_counts) { min_alpha = Math.min(min_alpha, color.alpha); max_alpha = Math.max(max_alpha, color.alpha); min_red = Math.min(min_red, color.red); @@ -129,12 +116,11 @@ public ColorGroup(final List color_counts) throws ImageWriteExceptio } - public boolean contains(int argb) - { + public boolean contains(int argb) { int alpha = 0xff & (argb >> 24); int red = 0xff & (argb >> 16); int green = 0xff & (argb >> 8); - int blue = 0xff & (argb >> 0); + int blue = 0xff & argb; if (!ignoreAlpha && (alpha < min_alpha || alpha > max_alpha)) return false; @@ -147,13 +133,11 @@ public boolean contains(int argb) return true; } - public int getMedianValue() - { + public int getMedianValue() { long count_total = 0; long alpha_total = 0, red_total = 0, green_total = 0, blue_total = 0; - for (int i = 0; i < color_counts.size(); i++) - { + for (int i = 0; i < color_counts.size(); i++) { ColorCount color = color_counts.get(i); count_total += color.count; @@ -173,8 +157,7 @@ public int getMedianValue() } @Override - public String toString() - { + public String toString() { return "{ColorGroup. min_red: " + Integer.toHexString(min_red) + ", max_red: " + Integer.toHexString(max_red) + ", min_green: " + Integer.toHexString(min_green) @@ -189,19 +172,16 @@ public String toString() } - public Map groupColors1(BufferedImage image, int max, int mask) - { - Map color_map = new HashMap(); + public Map groupColors1(BufferedImage image, int max, int mask) { + Map color_map = new HashMap<>(); int width = image.getWidth(); int height = image.getHeight(); int row[] = new int[width]; - for (int y = 0; y < height; y++) - { + for (int y = 0; y < height; y++) { image.getRGB(0, y, width, 1, row, 0, width); - for (int x = 0; x < width; x++) - { + for (int x = 0; x < width; x++) { int argb = row[x]; if (ignoreAlpha) @@ -210,8 +190,7 @@ public Map groupColors1(BufferedImage image, int max, int m ColorCount color = color_map .get(argb); - if (color == null) - { + if (color == null) { color = new ColorCount(argb); color_map.put(argb, color); if (color_map.keySet().size() > max) @@ -224,12 +203,10 @@ public Map groupColors1(BufferedImage image, int max, int m return color_map; } - public Map groupColors(BufferedImage image, int max_colors) - { + Map groupColors(BufferedImage image) { int max = Integer.MAX_VALUE; - for (int i = 0; i < 8; i++) - { + for (int i = 0; i < 8; i++) { int mask = 0xff & (0xff << i); mask = mask | (mask << 8) | (mask << 16) | (mask << 24); @@ -242,53 +219,45 @@ public Map groupColors(BufferedImage image, int max_colors) throw new Error(""); } - public Palette process(BufferedImage image, int max_colors, boolean verbose) - throws ImageWriteException - { - Map color_map = groupColors(image, max_colors); + public Palette process(BufferedImage image, int max_colors, boolean verbose) throws ImageWriteException { + Map color_map = groupColors(image); int discrete_colors = color_map.keySet().size(); - if (discrete_colors <= max_colors) - { - if (verbose) + if (discrete_colors <= max_colors) { + if (verbose) { Debug.debug("lossless palette: " + discrete_colors); - + } int palette[] = new int[discrete_colors]; - List color_counts = new ArrayList(color_map.values()); + List color_counts = new ArrayList<>(color_map.values()); - for (int i = 0; i < color_counts.size(); i++) - { + for (int i = 0; i < color_counts.size(); i++) { ColorCount color_count = color_counts.get(i); palette[i] = color_count.argb; - if (ignoreAlpha) + if (ignoreAlpha) { palette[i] |= 0xff000000; + } } return new SimplePalette(palette); } - if (verbose) + if (verbose) { Debug.debug("discrete colors: " + discrete_colors); + } - List color_groups = new ArrayList(); - ColorGroup root = new ColorGroup(new ArrayList(color_map.values())); + List color_groups = new ArrayList<>(); + ColorGroup root = new ColorGroup(new ArrayList<>(color_map.values())); { color_groups.add(root); - final Comparator comparator = new Comparator() - { - public int compare(ColorGroup cg1, ColorGroup cg2) - { - if (cg1.max_diff == cg2.max_diff) - return cg2.diff_total - cg1.diff_total; - return cg2.max_diff - cg1.max_diff; - } + final Comparator comparator = (cg1, cg2) -> { + if (cg1.max_diff == cg2.max_diff) + return cg2.diff_total - cg1.diff_total; + return cg2.max_diff - cg1.max_diff; }; - while (color_groups.size() < max_colors) - { - Collections.sort(color_groups, comparator); - + while (color_groups.size() < max_colors) { + color_groups.sort(comparator); ColorGroup color_group = color_groups.get(0); if (color_group.max_diff == 0) @@ -296,21 +265,14 @@ public int compare(ColorGroup cg1, ColorGroup cg2) if (!ignoreAlpha && color_group.alpha_diff > color_group.red_diff && color_group.alpha_diff > color_group.green_diff - && color_group.alpha_diff > color_group.blue_diff) - { + && color_group.alpha_diff > color_group.blue_diff) { doCut(color_group, ALPHA, color_groups); - } - else if (color_group.red_diff > color_group.green_diff - && color_group.red_diff > color_group.blue_diff) - { + } else if (color_group.red_diff > color_group.green_diff + && color_group.red_diff > color_group.blue_diff) { doCut(color_group, RED, color_groups); - } - else if (color_group.green_diff > color_group.blue_diff) - { + } else if (color_group.green_diff > color_group.blue_diff) { doCut(color_group, GREEN, color_groups); - } - else - { + } else { doCut(color_group, BLUE, color_groups); } } @@ -323,8 +285,7 @@ else if (color_group.green_diff > color_group.blue_diff) int palette[] = new int[palette_size]; - for (int i = 0; i < color_groups.size(); i++) - { + for (int i = 0; i < color_groups.size(); i++) { ColorGroup color_group = color_groups.get(i); palette[i] = color_group.getMedianValue(); @@ -353,32 +314,25 @@ else if (color_group.green_diff > color_group.blue_diff) private static final int GREEN = 2; private static final int BLUE = 3; - private void doCut(ColorGroup color_group, final int mode, final List color_groups) throws ImageWriteException - { + private void doCut(ColorGroup color_group, final int mode, final List color_groups) throws ImageWriteException { int count_total = 0; - for (int i = 0; i < color_group.color_counts.size(); i++) - { + for (int i = 0; i < color_group.color_counts.size(); i++) { ColorCount color_count = color_group.color_counts.get(i); count_total += color_count.count; } - Comparator comparator = new Comparator() - { - public int compare(ColorCount c1, ColorCount c2) - { - switch (mode) - { - case ALPHA : - return c1.alpha - c2.alpha; - case RED : - return c1.red - c2.red; - case GREEN : - return c1.green - c2.green; - case BLUE : - return c1.blue - c2.blue; - default : - return 0; - } + Comparator comparator = (c1, c2) -> { + switch (mode) { + case ALPHA: + return c1.alpha - c2.alpha; + case RED: + return c1.red - c2.red; + case GREEN: + return c1.green - c2.green; + case BLUE: + return c1.blue - c2.blue; + default: + return 0; } }; @@ -386,14 +340,12 @@ public int compare(ColorCount c1, ColorCount c2) int count_half = (int) Math.round((double) count_total / 2); int old_count = 0, new_count = 0; int median_index; - for (median_index = 0; median_index < color_group.color_counts.size(); median_index++) - { + for (median_index = 0; median_index < color_group.color_counts.size(); median_index++) { ColorCount color_count = color_group.color_counts.get(median_index); new_count += color_count.count; - if (new_count < count_half) - { + if (new_count < count_half) { old_count = new_count; continue; } @@ -402,8 +354,7 @@ public int compare(ColorCount c1, ColorCount c2) if (median_index == color_group.color_counts.size() - 1) median_index--; - else if (median_index > 0) - { + else if (median_index > 0) { int new_diff = Math.abs(new_count - count_half); int old_diff = Math.abs(count_half - old_count); if (old_diff < new_diff) @@ -412,74 +363,70 @@ else if (median_index > 0) color_groups.remove(color_group); { - List color_counts1 = new ArrayList(color_group.color_counts.subList(0, median_index + 1)); - List color_counts2 = new ArrayList(color_group.color_counts.subList(median_index + 1, color_group.color_counts.size())); + List color_counts1 = new ArrayList<>(color_group.color_counts.subList(0, median_index + 1)); + List color_counts2 = new ArrayList<>(color_group.color_counts.subList(median_index + 1, color_group.color_counts.size())); ColorGroup less, more; { - less = new ColorGroup(new ArrayList(color_counts1)); + less = new ColorGroup(new ArrayList<>(color_counts1)); color_groups.add(less); } { - more = new ColorGroup(new ArrayList(color_counts2)); + more = new ColorGroup(new ArrayList<>(color_counts2)); color_groups.add(more); } ColorCount median_value = color_group.color_counts.get(median_index); int limit; - switch (mode) - { - case ALPHA : + switch (mode) { + case ALPHA: limit = median_value.alpha; break; - case RED : + case RED: limit = median_value.red; break; - case GREEN : + case GREEN: limit = median_value.green; break; - case BLUE : + case BLUE: limit = median_value.blue; break; - default : + default: throw new Error("Bad mode."); } color_group.cut = new ColorGroupCut(less, more, mode, limit); } } - private static class ColorGroupCut - { - public final ColorGroup less, more; - public final int mode, limit; - public ColorGroupCut(ColorGroup less, ColorGroup more, int mode, - int limit) - { + private static class ColorGroupCut { + final ColorGroup less, more; + final int mode, limit; + + ColorGroupCut(ColorGroup less, ColorGroup more, int mode, + int limit) { this.less = less; this.more = more; this.mode = mode; this.limit = limit; } - public ColorGroup getColorGroup(int argb) - { + ColorGroup getColorGroup(int argb) { int value; - switch (mode) - { - case ALPHA : + switch (mode) { + case ALPHA: value = 0xff & (argb >> 24); break; - case RED : + case RED: value = 0xff & (argb >> 16); break; - case GREEN : + case GREEN: value = 0xff & (argb >> 8); break; - case BLUE : - value = 0xff & (argb >> 0); + case BLUE: + value = 0xff & argb; break; - default : + default: throw new Error("bad mode."); } if (value <= limit) @@ -489,23 +436,19 @@ public ColorGroup getColorGroup(int argb) } - public static class MedianCutPalette extends SimplePalette - { + public static class MedianCutPalette extends SimplePalette { private final ColorGroup root; - public MedianCutPalette(ColorGroup root, int palette[]) - { + MedianCutPalette(ColorGroup root, int palette[]) { super(palette); this.root = root; } @Override - public int getPaletteIndex(int rgb) - { + public int getPaletteIndex(int rgb) { ColorGroup cg = root; - while (cg.cut != null) - { + while (cg.cut != null) { cg = cg.cut.getColorGroup(rgb); } diff --git a/src/main/java/org/apache/commons/imaging/util/Debug.java b/src/main/java/org/apache/commons/imaging/util/Debug.java index 9192dcdb..377bc67a 100644 --- a/src/main/java/org/apache/commons/imaging/util/Debug.java +++ b/src/main/java/org/apache/commons/imaging/util/Debug.java @@ -88,7 +88,7 @@ public static String getDebug(String message, long value) public static String getDebug(String message, int v[]) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (v == null) result.append(message + " (" + null + ")" + newline); @@ -111,7 +111,7 @@ public static String getDebug(String message, byte v[]) public static String getDebug(String message, byte v[], int max) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (v == null) result.append(message + " (" + null + ")" + newline); @@ -141,7 +141,7 @@ public static String getDebug(String message, byte v[], int max) public static String getDebug(String message, char v[]) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (v == null) result.append(getDebug(message + " (" + null + ")") + newline); @@ -160,7 +160,7 @@ public static String getDebug(String message, char v[]) public static String getDebug(String message, java.util.List v) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); String suffix = " [" + counter++ + "]"; @@ -181,7 +181,7 @@ public static void debug(String message, Map map) public static String getDebug(String message, Map map) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (map == null) return getDebug(message + " map: " + null); @@ -210,7 +210,7 @@ public static boolean compare(String prefix, Map a, Map b) // public static String newline = System.getProperty("line.separator"); public static final String newline = "\r\n"; - private static void log(StringBuffer buffer, String s) + private static void log(StringBuilder buffer, String s) { Debug.debug(s); if (buffer != null) @@ -218,7 +218,7 @@ private static void log(StringBuffer buffer, String s) } public static boolean compare(String prefix, Map a, Map b, - List ignore, StringBuffer buffer) + List ignore, StringBuilder buffer) { if ((a == null) && (b == null)) { @@ -294,23 +294,23 @@ private static final String byteQuadToString(int bytequad) char c3 = (char) b3; char c4 = (char) b4; // return new String(new char[] { c1, c2, c3, c4 }); - StringBuffer fStringBuffer = new StringBuffer(); - fStringBuffer.append(new String(new char[]{ + StringBuilder fStringBuilder = new StringBuilder(); + fStringBuilder.append(new String(new char[]{ c1, c2, c3, c4 })); - fStringBuffer.append(" bytequad: " + bytequad); - fStringBuffer.append(" b1: " + b1); - fStringBuffer.append(" b2: " + b2); - fStringBuffer.append(" b3: " + b3); - fStringBuffer.append(" b4: " + b4); + fStringBuilder.append(" bytequad: " + bytequad); + fStringBuilder.append(" b1: " + b1); + fStringBuilder.append(" b2: " + b2); + fStringBuilder.append(" b3: " + b3); + fStringBuilder.append(" b4: " + b4); - return fStringBuffer.toString(); + return fStringBuilder.toString(); } public static String getDebug(String message, ICC_Profile value) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); result.append(getDebug("ICC_Profile " + message + ": " + ((value == null) ? "null" : value.toString())) @@ -488,7 +488,7 @@ else if (value instanceof boolean[]) public static String getDebug(String message, Object value[]) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (value == null) { result.append(getDebug(message, "null") + newline); @@ -657,7 +657,7 @@ public static String getDebug(Throwable e) public static String getDebug(Throwable e, int max) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); final SimpleDateFormat timestamp = new SimpleDateFormat( "yyyy-MM-dd kk:mm:ss:SSS"); @@ -692,7 +692,7 @@ public static String getStackTrace(Throwable e, int limit) public static String getStackTrace(Throwable e, int limit, int skip) { - StringBuffer result = new StringBuffer(); + StringBuilder result = new StringBuilder(); if (e != null) { @@ -723,7 +723,7 @@ public static void debugByteQuad(String message, int i) int alpha = (i >> 24) & 0xff; int red = (i >> 16) & 0xff; int green = (i >> 8) & 0xff; - int blue = (i >> 0) & 0xff; + int blue = i & 0xff; System.out.println(message + ": " + "alpha: " + alpha + ", " + "red: " + red + ", " + "green: " + green + ", " + "blue: " + blue); @@ -734,7 +734,7 @@ public static void debugIPQuad(String message, int i) int b1 = (i >> 24) & 0xff; int b2 = (i >> 16) & 0xff; int b3 = (i >> 8) & 0xff; - int b4 = (i >> 0) & 0xff; + int b4 = i & 0xff; System.out.println(message + ": " + "b1: " + b1 + ", " + "b2: " + b2 + ", " + "b3: " + b3 + ", " + "b4: " + b4); diff --git a/src/test/java/org/apache/commons/imaging/SanselanTest.java b/src/test/java/org/apache/commons/imaging/SanselanTest.java index 3f2aaa2a..3ef6fe32 100644 --- a/src/test/java/org/apache/commons/imaging/SanselanTest.java +++ b/src/test/java/org/apache/commons/imaging/SanselanTest.java @@ -17,19 +17,15 @@ package org.apache.commons.imaging; +import junit.framework.TestCase; +import org.apache.commons.imaging.test.util.FileSystemTraversal; +import org.apache.commons.imaging.util.Debug; + import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; -import junit.framework.TestCase; - -import org.apache.commons.imaging.ImageReadException; -import org.apache.commons.imaging.Sanselan; -import org.apache.commons.imaging.SanselanConstants; -import org.apache.commons.imaging.test.util.FileSystemTraversal; -import org.apache.commons.imaging.util.Debug; - public abstract class SanselanTest extends TestCase implements SanselanTestConstants, SanselanConstants { @@ -80,11 +76,7 @@ protected File getTestImage() throws IOException, ImageReadException { protected File getTestImageByName(final String filename) throws IOException, ImageReadException { - return getTestImage(new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException { - return file.getName().equals(filename); - } - }); + return getTestImage(file -> file.getName().equals(filename)); } protected File getTestImage(ImageFilter filter) throws IOException, @@ -118,14 +110,11 @@ protected List getTestImages(ImageFilter filter) throws IOException, Debug.debug("imagesFolder", imagesFolder); assertTrue(imagesFolder.exists()); - FileSystemTraversal.Visitor visitor = new FileSystemTraversal.Visitor() { - - public boolean visit(File file, double progressEstimate) { - if (!Sanselan.hasImageFileExtension(file)) - return true; - ALL_IMAGES.add(file); + FileSystemTraversal.Visitor visitor = (file, progressEstimate) -> { + if (!Sanselan.hasImageFileExtension(file)) return true; - } + ALL_IMAGES.add(file); + return true; }; new FileSystemTraversal().traverseFiles(imagesFolder, visitor); } diff --git a/src/test/java/org/apache/commons/imaging/SanselanTestConstants.java b/src/test/java/org/apache/commons/imaging/SanselanTestConstants.java index b3932784..a961c211 100644 --- a/src/test/java/org/apache/commons/imaging/SanselanTestConstants.java +++ b/src/test/java/org/apache/commons/imaging/SanselanTestConstants.java @@ -18,17 +18,18 @@ package org.apache.commons.imaging; import java.io.File; + import org.apache.commons.io.FilenameUtils; public interface SanselanTestConstants { - static final File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File( + File PHIL_HARVEY_TEST_IMAGE_FOLDER = new File( FilenameUtils.separatorsToSystem("src\\test\\data\\images\\exif\\philHarvey\\")); - static final File SOURCE_FOLDER = new File("src"); - static final File TEST_SOURCE_FOLDER = new File(SOURCE_FOLDER, "test"); - static final File TEST_DATA_SOURCE_FOLDER = new File(TEST_SOURCE_FOLDER, + File SOURCE_FOLDER = new File("src"); + File TEST_SOURCE_FOLDER = new File(SOURCE_FOLDER, "test"); + File TEST_DATA_SOURCE_FOLDER = new File(TEST_SOURCE_FOLDER, "data"); - static final File TEST_IMAGE_FOLDER = new File(TEST_DATA_SOURCE_FOLDER, + File TEST_IMAGE_FOLDER = new File(TEST_DATA_SOURCE_FOLDER, "images"); } diff --git a/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java b/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java index 243da21f..840bdb06 100644 --- a/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java +++ b/src/test/java/org/apache/commons/imaging/common/BinaryFileFunctionsTest.java @@ -16,7 +16,6 @@ package org.apache.commons.imaging.common; import org.apache.commons.imaging.SanselanTest; -import org.apache.commons.imaging.common.BinaryFileFunctions; public class BinaryFileFunctionsTest extends SanselanTest { // Work around that pesky "protected"... 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 9576a523..e8381e3a 100644 --- a/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java +++ b/src/test/java/org/apache/commons/imaging/common/RationalNumberTest.java @@ -17,14 +17,12 @@ package org.apache.commons.imaging.common; -import java.text.DecimalFormat; -import java.text.NumberFormat; - import org.apache.commons.imaging.SanselanTest; -import org.apache.commons.imaging.common.RationalNumber; -import org.apache.commons.imaging.common.RationalNumberUtilities; import org.apache.commons.imaging.util.Debug; +import java.text.DecimalFormat; +import java.text.NumberFormat; + public class RationalNumberTest extends SanselanTest { // public RationalNumberTest() 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 804c30c1..54c8e290 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 @@ -17,17 +17,10 @@ package org.apache.commons.imaging.common.bytesource; -import java.io.ByteArrayInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.IOException; -import java.io.InputStream; - -import org.apache.commons.imaging.common.bytesource.ByteSource; -import org.apache.commons.imaging.common.bytesource.ByteSourceFile; -import org.apache.commons.imaging.common.bytesource.ByteSourceInputStream; import org.apache.commons.imaging.util.IoUtils; +import java.io.*; + public class ByteSourceDataTest extends ByteSourceTest { 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 93607ad8..b1922220 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 @@ -35,14 +35,11 @@ import org.apache.commons.imaging.util.Debug; import org.apache.commons.imaging.util.IoUtils; -public class ByteSourceImageTest extends ByteSourceTest -{ +public class ByteSourceImageTest extends ByteSourceTest { - public void test() throws Exception - { + public void test() throws Exception { List imageFiles = getTestImages(); - for (int i = 0; i < imageFiles.size(); i++) - { + for (int i = 0; i < imageFiles.size(); i++) { if (i % 1 == 0) Debug.purgeMemory(); @@ -62,8 +59,7 @@ public void test() throws Exception || imageFile.getName().toLowerCase().endsWith(".psd") || imageFile.getName().toLowerCase().endsWith(".wbmp") || imageFile.getName().toLowerCase().endsWith(".xbm") - || imageFile.getName().toLowerCase().endsWith(".xpm")) - { + || imageFile.getName().toLowerCase().endsWith(".xpm")) { // these formats can't be parsed without a filename hint. // they have ambiguous "magic number" signatures. continue; @@ -73,7 +69,7 @@ public void test() throws Exception if (imageFile.getName().toLowerCase().endsWith(".png") && imageFile.getParentFile().getName().equalsIgnoreCase( - "pngsuite") + "pngsuite") && imageFile.getName().toLowerCase().startsWith("x")) continue; @@ -87,15 +83,13 @@ public void test() throws Exception ImageFormat imageFormat = Sanselan.guessFormat(imageFile); if (ImageFormat.IMAGE_FORMAT_JPEG != imageFormat - && ImageFormat.IMAGE_FORMAT_UNKNOWN != imageFormat) - { + && ImageFormat.IMAGE_FORMAT_UNKNOWN != imageFormat) { checkGetBufferedImage(imageFile, imageFileBytes); } } } - public void checkGetBufferedImage(File file, byte[] bytes) throws Exception - { + public void checkGetBufferedImage(File file, byte[] bytes) throws Exception { BufferedImage imageFile = Sanselan.getBufferedImage(file); assertNotNull(imageFile); assertTrue(imageFile.getWidth() > 0); @@ -110,8 +104,7 @@ public void checkGetBufferedImage(File file, byte[] bytes) throws Exception assertTrue(imageFileHeight == imageBytes.getHeight()); } - public void checkGetImageSize(File imageFile, byte[] imageFileBytes) throws Exception - { + public void checkGetImageSize(File imageFile, byte[] imageFileBytes) throws Exception { Dimension imageSizeFile = Sanselan.getImageSize(imageFile); assertNotNull(imageSizeFile); assertTrue(imageSizeFile.width > 0); @@ -123,24 +116,22 @@ public void checkGetImageSize(File imageFile, byte[] imageFileBytes) throws Exce assertTrue(imageSizeFile.height == imageSizeBytes.height); } - public void checkGuessFormat(File imageFile, byte[] imageFileBytes) throws Exception - { + public void checkGuessFormat(File imageFile, byte[] imageFileBytes) throws Exception { // check guessFormat() ImageFormat imageFormatFile = Sanselan.guessFormat(imageFile); assertNotNull(imageFormatFile); - assertTrue(imageFormatFile != ImageFormat.IMAGE_FORMAT_UNKNOWN); + assertNotSame(imageFormatFile, ImageFormat.IMAGE_FORMAT_UNKNOWN); // Debug.debug("imageFormatFile", imageFormatFile); ImageFormat imageFormatBytes = Sanselan.guessFormat(imageFileBytes); assertNotNull(imageFormatBytes); - assertTrue(imageFormatBytes != ImageFormat.IMAGE_FORMAT_UNKNOWN); + assertNotSame(imageFormatBytes, ImageFormat.IMAGE_FORMAT_UNKNOWN); // Debug.debug("imageFormatBytes", imageFormatBytes); - assertTrue(imageFormatBytes == imageFormatFile); + assertSame(imageFormatBytes, imageFormatFile); } - public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes) throws Exception - { + public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes) throws Exception { // check guessFormat() byte iccBytesFile[] = Sanselan.getICCProfileBytes(imageFile); @@ -156,16 +147,13 @@ public void checkGetICCProfileBytes(File imageFile, byte[] imageFileBytes) thro public void checkGetImageInfo(File imageFile, byte[] imageFileBytes) throws IOException, ImageReadException, IllegalAccessException, - IllegalArgumentException, InvocationTargetException - { - Map params = new HashMap(); + IllegalArgumentException, InvocationTargetException { + Map params = new HashMap<>(); boolean ignoreImageData = isPhilHarveyTestImage(imageFile); ImageFormat imageFormat = Sanselan.guessFormat(imageFile); if (imageFormat.equals(ImageFormat.IMAGE_FORMAT_TIFF) || imageFormat.equals(ImageFormat.IMAGE_FORMAT_JPEG)) - params - .put(PARAM_KEY_READ_THUMBNAILS, new Boolean( - !ignoreImageData)); + params.put(PARAM_KEY_READ_THUMBNAILS, !ignoreImageData); ImageInfo imageInfoFile = Sanselan.getImageInfo(imageFile, params); @@ -176,8 +164,7 @@ public void checkGetImageInfo(File imageFile, byte[] imageFileBytes) assertNotNull(imageInfoBytes); Method methods[] = ImageInfo.class.getMethods(); - for (int i = 0; i < methods.length; i++) - { + for (int i = 0; i < methods.length; i++) { Method method = methods[i]; method.getModifiers(); if (!Modifier.isPublic(method.getModifiers())) diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java index 375e05b5..b5f3cc39 100644 --- a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpBaseTest.java @@ -26,27 +26,17 @@ import org.apache.commons.imaging.Sanselan; import org.apache.commons.imaging.SanselanTest; -public abstract class BmpBaseTest extends SanselanTest -{ +public abstract class BmpBaseTest extends SanselanTest { - private static boolean isBmp(File file) throws IOException, - ImageReadException - { + private static boolean isBmp(File file) throws IOException, ImageReadException { ImageFormat format = Sanselan.guessFormat(file); return format == ImageFormat.IMAGE_FORMAT_BMP; } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isBmp(file); - } - }; + private static final ImageFilter IMAGE_FILTER = BmpBaseTest::isBmp; - protected List getBmpImages() throws IOException, ImageReadException - { + protected List getBmpImages() throws IOException, ImageReadException { return getTestImages(IMAGE_FILTER); } - } diff --git a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java index ac0d0374..ca3e6ef9 100644 --- a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxBaseTest.java @@ -26,24 +26,16 @@ import org.apache.commons.imaging.Sanselan; import org.apache.commons.imaging.SanselanTest; -public abstract class DcxBaseTest extends SanselanTest -{ +public abstract class DcxBaseTest extends SanselanTest { - private static boolean isDcx(File file) throws IOException, ImageReadException - { + private static boolean isDcx(File file) throws IOException, ImageReadException { ImageFormat format = Sanselan.guessFormat(file); return format == ImageFormat.IMAGE_FORMAT_DCX; } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isDcx(file); - } - }; + private static final ImageFilter IMAGE_FILTER = DcxBaseTest::isDcx; - protected List getDcxImages() throws IOException, ImageReadException - { + protected List getDcxImages() throws IOException, ImageReadException { return getTestImages(IMAGE_FILTER); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java index f8258713..f45c256e 100644 --- a/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/gif/GifBaseTest.java @@ -36,12 +36,7 @@ private static boolean isGif(File file) throws IOException, return format == ImageFormat.IMAGE_FORMAT_GIF; } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isGif(file); - } - }; + private static final ImageFilter IMAGE_FILTER = GifBaseTest::isGif; protected List getGifImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java index 80ca3c08..cc8b5e84 100644 --- a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsBaseTest.java @@ -35,12 +35,7 @@ private static boolean isIcns(File file) throws IOException, ImageReadException return format == ImageFormat.IMAGE_FORMAT_ICNS; } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isIcns(file); - } - }; + private static final ImageFilter IMAGE_FILTER = IcnsBaseTest::isIcns; protected List getIcnsImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/ico/IcoBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/ico/IcoBaseTest.java index cc68a84d..76e1f84b 100644 --- a/src/test/java/org/apache/commons/imaging/formats/ico/IcoBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/ico/IcoBaseTest.java @@ -33,12 +33,7 @@ private static boolean isIco(File file) file.getName().toLowerCase().endsWith(".cur"); } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isIco(file); - } - }; + private static final ImageFilter IMAGE_FILTER = IcoBaseTest::isIco; protected List getIcoImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java index f35e24af..1e983883 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegBaseTest.java @@ -36,13 +36,7 @@ protected static boolean isJpeg(File file) throws IOException, return format == ImageFormat.IMAGE_FORMAT_JPEG; } - public static final ImageFilter imageFilter = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return isJpeg(file); - } - }; + public static final ImageFilter imageFilter = JpegBaseTest::isJpeg; diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java index 89c25d51..849a66e1 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/AsciiFieldTest.java @@ -24,6 +24,7 @@ import java.util.List; import java.util.Map; +import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.Sanselan; import org.apache.commons.imaging.common.IImageMetadata; import org.apache.commons.imaging.formats.jpeg.JpegImageMetadata; @@ -34,8 +35,7 @@ public class AsciiFieldTest extends ExifBaseTest implements AllTagConstants { - public void testSingleImage() throws Exception - { + public void testSingleImage() throws Exception { File imageFile = getTestImageByName("Canon Powershot SD750 - 2007.12.26.n.IMG_3704.JPG"); Map params = new HashMap(); @@ -49,30 +49,27 @@ public void testSingleImage() throws Exception if (null == exif) return; - List fields = exif.getAllFields(); - Map fieldMap = new Hashtable(); + List fields = exif.getAllFields(); + Map fieldMap = new Hashtable<>(); // Build a simplified field tag -> field map, ignoring directory structures. // Good enough for our purposes, since the image in question is known. - for (int i = 0; i < fields.size(); i++) { - TiffField field = (TiffField) fields.get(i); - fieldMap.put(new Integer(field.tag), field); - } - - Map expectedFieldValues = new Hashtable(); - expectedFieldValues.put(new Integer(TiffTagConstants.TIFF_TAG_MAKE.tag), "Canon"); - expectedFieldValues.put(new Integer(TiffTagConstants.TIFF_TAG_MODEL.tag), "Canon PowerShot SD750"); - expectedFieldValues.put(new Integer(TiffTagConstants.TIFF_TAG_DATE_TIME.tag), "2007:12:25 13:34:39"); - Iterator expectedTags = expectedFieldValues.keySet().iterator(); - while (expectedTags.hasNext()) { - Integer tag = (Integer) expectedTags.next(); - Object expectedValue = expectedFieldValues.get(tag); + fields.forEach(field -> fieldMap.put(field.tag, field)); + Map expectedFieldValues = new Hashtable<>(); + expectedFieldValues.put(TiffTagConstants.TIFF_TAG_MAKE.tag, "Canon"); + expectedFieldValues.put(TiffTagConstants.TIFF_TAG_MODEL.tag, "Canon PowerShot SD750"); + expectedFieldValues.put(TiffTagConstants.TIFF_TAG_DATE_TIME.tag, "2007:12:25 13:34:39"); + expectedFieldValues.forEach((tag, expectedValue) -> { + try { assertTrue(fieldMap.containsKey(tag)); - TiffField field = (TiffField) fieldMap.get(tag); + TiffField field = fieldMap.get(tag); assertNotNull(field); Object value = field.getValue(); assertNotNull(value); assertEquals(value, expectedValue); - } + } catch (ImageReadException e) { + fail("Something went wrong " + e.getMessage()); + } + }); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java index 1272a3eb..6cb97b0f 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/exif/ExifBaseTest.java @@ -59,21 +59,9 @@ protected static boolean hasExifData(File file) } } - private static final ImageFilter HAS_EXIF_IMAGE_FILTER = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return hasExifData(file); - } - }; + private static final ImageFilter HAS_EXIF_IMAGE_FILTER = ExifBaseTest::hasExifData; - private static final ImageFilter JPEG_IMAGE_FILTER = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return file.getName().toLowerCase().endsWith(".jpg"); - } - }; + private static final ImageFilter JPEG_IMAGE_FILTER = file -> file.getName().toLowerCase().endsWith(".jpg"); protected File getImageWithExifData() throws IOException, ImageReadException 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 f0ca33fe..ec58c05d 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 @@ -45,20 +45,17 @@ import org.apache.commons.imaging.util.Debug; import org.apache.commons.imaging.util.IoUtils; -public class ExifRewriteTest extends ExifBaseTest implements AllTagConstants -{ +public class ExifRewriteTest extends ExifBaseTest implements AllTagConstants { // public ExifRewriteTest(String name) // { // super(name); // } - public void testRemove() throws Exception - { + public void testRemove() throws Exception { List images = getImagesWithExifData(); - for (int i = 0; i < images.size(); i++) - { - if(i%10==0) - Debug.purgeMemory(); + for (int i = 0; i < images.size(); i++) { + if (i % 10 == 0) + Debug.purgeMemory(); File imageFile = (File) images.get(i); Debug.debug("imageFile", imageFile); @@ -93,13 +90,11 @@ public void testRemove() throws Exception } } - public void testInsert() throws Exception - { + public void testInsert() throws Exception { List images = getImagesWithExifData(); - for (int i = 0; i < images.size(); i++) - { - if(i%10==0) - Debug.purgeMemory(); + for (int i = 0; i < images.size(); i++) { + if (i % 10 == 0) + Debug.purgeMemory(); File imageFile = (File) images.get(i); Debug.debug("imageFile", imageFile); @@ -167,26 +162,22 @@ public void testInsert() throws Exception } } - private interface Rewriter - { + private interface Rewriter { public void rewrite(ByteSource byteSource, OutputStream os, - TiffOutputSet outputSet) throws ImageReadException, + TiffOutputSet outputSet) throws ImageReadException, IOException, ImageWriteException; } private void rewrite(Rewriter rewriter, String name) throws IOException, - ImageReadException, ImageWriteException - { + ImageReadException, ImageWriteException { List images = getImagesWithExifData(); - for (int i = 0; i < images.size(); i++) - { - if(i%10==0) - Debug.purgeMemory(); + for (int i = 0; i < images.size(); i++) { + if (i % 10 == 0) + Debug.purgeMemory(); File imageFile = (File) images.get(i); - try - { + try { Debug.debug("imageFile", imageFile); @@ -236,21 +227,15 @@ private void rewrite(Rewriter rewriter, String name) throws IOException, // newMetadata.dump(); compare(imageFile, oldExifMetadata, newExifMetadata); - } - catch (IOException e) - { + } catch (IOException e) { Debug.debug("imageFile", imageFile.getAbsoluteFile()); Debug.debug(e); throw e; - } - catch (ImageReadException e) - { + } catch (ImageReadException e) { Debug.debug("imageFile", imageFile.getAbsoluteFile()); Debug.debug(e); throw e; - } - catch (ImageWriteException e) - { + } catch (ImageWriteException e) { Debug.debug("imageFile", imageFile.getAbsoluteFile()); Debug.debug(e); // FIXME: this image has 28kB of Maker Notes, causing the APP1 segment @@ -263,58 +248,36 @@ private void rewrite(Rewriter rewriter, String name) throws IOException, } } - public void testRewriteLossy() throws Exception - { - Rewriter rewriter = new Rewriter() - { - public void rewrite(ByteSource byteSource, OutputStream os, - TiffOutputSet outputSet) throws ImageReadException, - IOException, ImageWriteException - { - new ExifRewriter().updateExifMetadataLossy(byteSource, os, - outputSet); - } - }; + public void testRewriteLossy() throws Exception { + Rewriter rewriter = (byteSource, os, outputSet) -> new ExifRewriter().updateExifMetadataLossy(byteSource, os, + outputSet); rewrite(rewriter, "lossy"); } - public void testRewriteLossless() throws Exception - { - Rewriter rewriter = new Rewriter() - { - public void rewrite(ByteSource byteSource, OutputStream os, - TiffOutputSet outputSet) throws ImageReadException, - IOException, ImageWriteException - { - new ExifRewriter().updateExifMetadataLossless(byteSource, os, - outputSet); - } - }; + public void testRewriteLossless() throws Exception { + Rewriter rewriter = (byteSource, os, outputSet) -> new ExifRewriter().updateExifMetadataLossless(byteSource, os, + outputSet); rewrite(rewriter, "lossless"); } - private Hashtable makeDirectoryMap(List directories) - { - Hashtable directoryMap = new Hashtable(); - for (int i = 0; i < directories.size(); i++) - { + private Hashtable makeDirectoryMap(List directories) { + Hashtable directoryMap = new Hashtable<>(); + for (int i = 0; i < directories.size(); i++) { TiffImageMetadata.Directory directory = (TiffImageMetadata.Directory) directories .get(i); - directoryMap.put(new Integer(directory.type), directory); + directoryMap.put(directory.type, directory); } return directoryMap; } - private Hashtable makeFieldMap(List items) - { - Hashtable fieldMap = new Hashtable(); - for (int i = 0; i < items.size(); i++) - { + private Hashtable makeFieldMap(List items) { + Hashtable fieldMap = new Hashtable<>(); + for (int i = 0; i < items.size(); i++) { TiffImageMetadata.Item item = (TiffImageMetadata.Item) items.get(i); TiffField field = item.getTiffField(); - Object key = new Integer(field.tag); + Integer key = field.tag; if (!fieldMap.containsKey(key)) fieldMap.put(key, field); } @@ -322,15 +285,14 @@ private Hashtable makeFieldMap(List items) } private void compare(File imageFile, TiffImageMetadata oldExifMetadata, - TiffImageMetadata newExifMetadata) throws ImageReadException - { + TiffImageMetadata newExifMetadata) throws ImageReadException { assertNotNull(oldExifMetadata); assertNotNull(newExifMetadata); List oldDirectories = oldExifMetadata.getDirectories(); List newDirectories = newExifMetadata.getDirectories(); - assertTrue(oldDirectories.size() == newDirectories.size()); + assertEquals(oldDirectories.size(), newDirectories.size()); Hashtable oldDirectoryMap = makeDirectoryMap(oldDirectories); Hashtable newDirectoryMap = makeDirectoryMap(newDirectories); @@ -342,8 +304,7 @@ private void compare(File imageFile, TiffImageMetadata oldExifMetadata, Collections.sort(newDirectoryTypes); assertEquals(oldDirectoryTypes, newDirectoryTypes); - for (int i = 0; i < oldDirectoryTypes.size(); i++) - { + for (int i = 0; i < oldDirectoryTypes.size(); i++) { Integer dirType = (Integer) oldDirectoryTypes.get(i); // Debug.debug("dirType", dirType); @@ -401,8 +362,7 @@ private void compare(File imageFile, TiffImageMetadata oldExifMetadata, Collections.sort(newFieldTags); assertEquals(oldFieldTags, newFieldTags); - for (int j = 0; j < oldFieldTags.size(); j++) - { + for (int j = 0; j < oldFieldTags.size(); j++) { Integer fieldTag = (Integer) oldFieldTags.get(j); TiffField oldField = (TiffField) oldFieldMap.get(fieldTag); @@ -422,24 +382,20 @@ private void compare(File imageFile, TiffImageMetadata oldExifMetadata, assertEquals(oldField.length, newField.length); assertEquals(oldField.isLocalValue(), newField.isLocalValue()); - if (oldField.tag == 0x202) - { + if (oldField.tag == 0x202) { // ignore "jpg from raw length" value. may have off-by-one bug in certain cameras. // i.e. Sony DCR-PC110 continue; } - if (oldField.fieldType == TiffFieldTypeConstants.FIELD_TYPE_ASCII) - { + if (oldField.fieldType == TiffFieldTypeConstants.FIELD_TYPE_ASCII) { // Sanselan currently doesn't correctly rewrite // strings if any byte had the highest bit set, // so if the source had that, all bets are off. byte[] rawBytes = oldField.fieldType.getRawBytes(oldField); boolean hasInvalidByte = false; - for (int k = 0; k < rawBytes.length; k++) - { - if ((rawBytes[k] & 0x80) != 0) - { + for (int k = 0; k < rawBytes.length; k++) { + if ((rawBytes[k] & 0x80) != 0) { hasInvalidByte = true; break; } @@ -448,12 +404,8 @@ private void compare(File imageFile, TiffImageMetadata oldExifMetadata, continue; } - if (!oldField.tagInfo.isOffset()) - { - if (oldField.tagInfo.isText()) - { /* do nothing */ } - else if (oldField.isLocalValue()) - { + if (!oldField.tagInfo.isOffset()) { + if (oldField.tagInfo.isText()) { /* do nothing */ } else if (oldField.isLocalValue()) { // Debug.debug("oldField.tag", oldField.tag); // Debug.debug("newField.tag", newField.tag); // Debug.debug("oldField.tagInfo", oldField.tagInfo); @@ -470,20 +422,18 @@ else if (oldField.isLocalValue()) // Debug.debug("newField.valueOffsetBytes", // newField.valueOffsetBytes); - String label = imageFile.getName() + - ", dirType[" + i + "]=" + dirType + - ", fieldTag[" + j + "]=" + fieldTag; + String label = imageFile.getName() + + ", dirType[" + i + "]=" + dirType + + ", fieldTag[" + j + "]=" + fieldTag; if (oldField.tag == 0x116 || oldField.tag == 0x117) compare(label, oldField, newField); else { compare(label, oldField.valueOffsetBytes, - newField.valueOffsetBytes, - oldField.getBytesLength(), - newField.getBytesLength()); + newField.valueOffsetBytes, + oldField.getBytesLength(), + newField.getBytesLength()); } - } - else - { + } else { // Debug.debug("oldField.tagInfo", oldField.tagInfo); // Debug.debug("oldField.fieldType", oldField.fieldType); // Debug.debug("newField.fieldType", newField.fieldType); @@ -505,8 +455,7 @@ else if (oldField.isLocalValue()) } } - private void compare(String label, byte a[], byte b[], int aLength, int bLength) - { + private void compare(String label, byte a[], byte b[], int aLength, int bLength) { // Debug.debug("c0 a", a); // Debug.debug("c0 b", b); assertEquals(aLength, bLength); @@ -516,8 +465,7 @@ private void compare(String label, byte a[], byte b[], int aLength, int bLength) assertNotNull(b); assertEquals(a.length, b.length); int length = aLength; - for (int i = 0; i < length; i++) - { + for (int i = 0; i < length; i++) { // byte ba = a[i]; // byte bb = b[i]; // boolean eq = ba == bb; @@ -535,8 +483,7 @@ private void compare(String label, byte a[], byte b[], int aLength, int bLength) } } - private void compare(String label, TiffField a, TiffField b) throws ImageReadException - { + private void compare(String label, TiffField a, TiffField b) throws ImageReadException { Object v1 = a.getValue(); Object v2 = b.getValue(); @@ -545,8 +492,7 @@ private void compare(String label, TiffField a, TiffField b) throws ImageReadExc assertEquals(label, v1, v2); } - private void compare(byte a[], byte b[]) - { + private void compare(byte a[], byte b[]) { // Debug.debug("c1 a", a); // Debug.debug("c1 b", b); assertNotNull(a); diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java index cb8e142c..b9b84540 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/iptc/IptcBaseTest.java @@ -52,21 +52,9 @@ protected static boolean hasIptcData(File file) } } - private static final ImageFilter HAS_IPTC_IMAGE_FILTER = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return hasIptcData(file); - } - }; + private static final ImageFilter HAS_IPTC_IMAGE_FILTER = IptcBaseTest::hasIptcData; - private static final ImageFilter JPEG_IMAGE_FILTER = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return file.getName().toLowerCase().endsWith(".jpg"); - } - }; + private static final ImageFilter JPEG_IMAGE_FILTER = file -> file.getName().toLowerCase().endsWith(".jpg"); protected File getImageWithIptcData() throws IOException, ImageReadException diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpBaseTest.java index d4d58fa9..f3505821 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/xmp/JpegXmpBaseTest.java @@ -53,21 +53,7 @@ protected static boolean hasJpegXmpData(File file) } } - private static final ImageFilter HAS_JPEG_XMP_IMAGE_FILTER = new ImageFilter() - { - public boolean accept(File file) throws IOException, ImageReadException - { - return hasJpegXmpData(file); - } - }; - -// private static final ImageFilter JPEG_IMAGE_FILTER = new ImageFilter() -// { -// public boolean accept(File file) throws IOException, ImageReadException -// { -// return file.getName().toLowerCase().endsWith(".jpg"); -// } -// }; + private static final ImageFilter HAS_JPEG_XMP_IMAGE_FILTER = file -> hasJpegXmpData(file); protected File getImageWithXmpData() throws IOException, ImageReadException diff --git a/src/test/java/org/apache/commons/imaging/formats/pcx/PcxBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/pcx/PcxBaseTest.java index bda4317b..ee0543b0 100644 --- a/src/test/java/org/apache/commons/imaging/formats/pcx/PcxBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/pcx/PcxBaseTest.java @@ -32,12 +32,7 @@ private static boolean isPcx(File file) return file.getName().toLowerCase().endsWith(".pcx"); } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isPcx(file); - } - }; + private static final ImageFilter IMAGE_FILTER = PcxBaseTest::isPcx; protected List getPcxImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngBaseTest.java index f1a12f13..6150187a 100644 --- a/src/test/java/org/apache/commons/imaging/formats/png/PngBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/png/PngBaseTest.java @@ -29,19 +29,12 @@ public abstract class PngBaseTest extends SanselanTest { - private static boolean isPng(File file) throws IOException, - ImageReadException - { + private static boolean isPng(File file) throws IOException, ImageReadException { ImageFormat format = Sanselan.guessFormat(file); return format == ImageFormat.IMAGE_FORMAT_PNG; } - private static final ImageFilter imageFilter = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isPng(file); - } - }; + private static final ImageFilter imageFilter = PngBaseTest::isPng; protected List getPngImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeBaseTest.java index 175f7592..ad32b6d5 100644 --- a/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeBaseTest.java @@ -33,11 +33,7 @@ private static boolean isRgbe( File file ) throws IOException, return format == ImageFormat.IMAGE_FORMAT_RGBE; } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept( File file ) throws IOException, ImageReadException { - return isRgbe( file ); - } - }; + private static final ImageFilter IMAGE_FILTER = RgbeBaseTest::isRgbe; protected List getRgbeImages() throws IOException, ImageReadException { return getTestImages( IMAGE_FILTER ); diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffBaseTest.java index df65cd3d..3da7f2df 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffBaseTest.java @@ -36,12 +36,7 @@ private static boolean isTiff(File file) throws IOException, return format == ImageFormat.IMAGE_FORMAT_TIFF; } - private static final ImageFilter imageFilter = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isTiff(file); - } - }; + private static final ImageFilter imageFilter = TiffBaseTest::isTiff; protected List getTiffImages() throws IOException, ImageReadException { diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffLzwTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffLzwTest.java index a4555371..5f61a37a 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/TiffLzwTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/TiffLzwTest.java @@ -28,21 +28,17 @@ import org.apache.commons.imaging.common.mylzw.MyLzwDecompressor; import org.apache.commons.imaging.util.Debug; -public class TiffLzwTest extends TiffBaseTest implements BinaryConstants -{ +public class TiffLzwTest extends TiffBaseTest implements BinaryConstants { - public void testTrivial() throws Exception - { - byte bytes[] = { 0, }; + public void testTrivial() throws Exception { + byte bytes[] = {0,}; compressRoundtripAndValidate(bytes); } - public void testMedium() throws Exception - { + public void testMedium() throws Exception { int LENGTH = 1024 * 32; byte bytes[] = new byte[LENGTH]; - for (int modulator = 1; modulator < 255; modulator += 3) - { + for (int modulator = 1; modulator < 255; modulator += 3) { for (int i = 0; i < LENGTH; i++) bytes[i] = (byte) (0xff & (i % modulator)); @@ -75,12 +71,10 @@ public void testMedium() throws Exception // } // } - private void compressRoundtripAndValidate(byte src[]) throws IOException - { + private void compressRoundtripAndValidate(byte src[]) throws IOException { final boolean DEBUG = false; - if (DEBUG) - { + if (DEBUG) { Debug.debug(); Debug.debug("roundtripAndValidate: " + src.length); Debug.debug(); @@ -89,23 +83,19 @@ private void compressRoundtripAndValidate(byte src[]) throws IOException int LZW_MINIMUM_CODE_SIZE = 8; final List codes = new ArrayList(); MyLzwCompressor.Listener compressionListener = new MyLzwCompressor.Listener() { - public void dataCode(int code) - { - codes.add(new Integer(code)); + public void dataCode(int code) { + codes.add(code); } - public void eoiCode(int code) - { - codes.add(new Integer(code)); + public void eoiCode(int code) { + codes.add(code); } - public void clearCode(int code) - { - codes.add(new Integer(code)); + public void clearCode(int code) { + codes.add(code); } - public void init(int clearCode, int eoiCode) - { + public void init(int clearCode, int eoiCode) { } }; @@ -118,24 +108,19 @@ public void init(int clearCode, int eoiCode) int index = 0; int clearCode, eoiCode; - public void code(int code) - { - if (DEBUG) - { - if (code == clearCode) - { + public void code(int code) { + if (DEBUG) { + if (code == clearCode) { Debug.debug("clearCode: " + index + "/" + codes.size()); Debug.debug(); } - if (code == eoiCode) - { + if (code == eoiCode) { Debug.debug("eoiCode: " + index + "/" + codes.size()); Debug.debug(); } } Integer expectedCode = (Integer) codes.get(index++); - if (code != expectedCode.intValue()) - { + if (code != expectedCode.intValue()) { Debug.debug("bad code: " + index + "/" + codes.size()); Debug.debug("code: " + code + " (0x" + Integer.toHexString(code) + ") " @@ -154,8 +139,7 @@ public void code(int code) } } - public void init(int clearCode, int eoiCode) - { + public void init(int clearCode, int eoiCode) { this.clearCode = clearCode; this.eoiCode = eoiCode; } @@ -173,8 +157,7 @@ public void init(int clearCode, int eoiCode) assertEquals(src[i], decompressed[i]); } - private void decompressRoundtripAndValidate(byte src[]) throws IOException - { + private void decompressRoundtripAndValidate(byte src[]) throws IOException { Debug.debug(); Debug.debug("roundtripAndValidate: " + src.length); Debug.debug(); @@ -184,8 +167,7 @@ private void decompressRoundtripAndValidate(byte src[]) throws IOException MyLzwDecompressor.Listener decompressionListener = new MyLzwDecompressor.Listener() { - public void code(int code) - { + public void code(int code) { Debug.debug("listener code: " + code + " (0x" + Integer.toHexString(code) + ") " + Integer.toBinaryString(code) + ", index: " @@ -193,8 +175,7 @@ public void code(int code) codes.add(new Integer(code)); } - public void init(int clearCode, int eoiCode) - { + public void init(int clearCode, int eoiCode) { } }; @@ -209,30 +190,25 @@ public void init(int clearCode, int eoiCode) int clearCode, eoiCode; - public void init(int clearCode, int eoiCode) - { + public void init(int clearCode, int eoiCode) { this.clearCode = clearCode; this.eoiCode = eoiCode; } int index = 0; - private void code(int code) - { + private void code(int code) { - if (code == clearCode) - { + if (code == clearCode) { Debug.debug("clearCode: " + index + "/" + codes.size()); Debug.debug(); } - if (code == eoiCode) - { + if (code == eoiCode) { Debug.debug("eoiCode: " + index + "/" + codes.size()); Debug.debug(); } Integer expectedCode = (Integer) codes.get(index++); - if (code != expectedCode.intValue()) - { + if (code != expectedCode.intValue()) { Debug.debug("bad code: " + index + "/" + codes.size()); Debug.debug("code: " + code + " (0x" + Integer.toHexString(code) + ") " @@ -251,18 +227,15 @@ private void code(int code) } } - public void dataCode(int code) - { + public void dataCode(int code) { code(code); } - public void eoiCode(int code) - { + public void eoiCode(int code) { code(code); } - public void clearCode(int code) - { + public void clearCode(int code) { code(code); } diff --git a/src/test/java/org/apache/commons/imaging/formats/wbmp/WbmpBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/wbmp/WbmpBaseTest.java index 0b81b81f..d18f1aa6 100644 --- a/src/test/java/org/apache/commons/imaging/formats/wbmp/WbmpBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/wbmp/WbmpBaseTest.java @@ -2,9 +2,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,22 +22,14 @@ import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.SanselanTest; -public abstract class WbmpBaseTest extends SanselanTest -{ - private static boolean isWbmp(File file) - { +public abstract class WbmpBaseTest extends SanselanTest { + private static boolean isWbmp(File file) { return file.getName().toLowerCase().endsWith(".wbmp"); } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isWbmp(file); - } - }; + private static final ImageFilter IMAGE_FILTER = WbmpBaseTest::isWbmp; - protected List getWbmpImages() throws IOException, ImageReadException - { + protected List getWbmpImages() throws IOException, ImageReadException { return getTestImages(IMAGE_FILTER); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/xbm/XbmBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/xbm/XbmBaseTest.java index 94fd8a27..372fb410 100644 --- a/src/test/java/org/apache/commons/imaging/formats/xbm/XbmBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/xbm/XbmBaseTest.java @@ -2,9 +2,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -22,23 +22,15 @@ import org.apache.commons.imaging.ImageReadException; import org.apache.commons.imaging.SanselanTest; -public abstract class XbmBaseTest extends SanselanTest -{ +public abstract class XbmBaseTest extends SanselanTest { - private static boolean isXbm(File file) - { + private static boolean isXbm(File file) { return file.getName().toLowerCase().endsWith(".xbm"); } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isXbm(file); - } - }; + private static final ImageFilter IMAGE_FILTER = XbmBaseTest::isXbm; - protected List getXbmImages() throws IOException, ImageReadException - { + protected List getXbmImages() throws IOException, ImageReadException { return getTestImages(IMAGE_FILTER); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/xpm/XpmBaseTest.java b/src/test/java/org/apache/commons/imaging/formats/xpm/XpmBaseTest.java index 0f91f27e..a1d6fac6 100644 --- a/src/test/java/org/apache/commons/imaging/formats/xpm/XpmBaseTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/xpm/XpmBaseTest.java @@ -30,12 +30,7 @@ private static boolean isXpm(File file) return file.getName().toLowerCase().endsWith(".xpm"); } - private static final ImageFilter IMAGE_FILTER = new ImageFilter() { - public boolean accept(File file) throws IOException, ImageReadException - { - return isXpm(file); - } - }; + private static final ImageFilter IMAGE_FILTER = XpmBaseTest::isXpm; protected List getXpmImages() throws IOException, ImageReadException { From 166b32488b3209a2ac3811699241f8c96709e46b Mon Sep 17 00:00:00 2001 From: iuliana Date: Sat, 1 Sep 2018 23:31:49 +0100 Subject: [PATCH 2/2] added a few more packages to export --- src/main/java/module-info.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 41493529..67597ae5 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -2,5 +2,12 @@ * Created by iuliana.cosmina on 1/9/18. */ module common.sanselan { - requires java.desktop; + requires java.desktop; + exports org.apache.commons.imaging; + exports org.apache.commons.imaging.color; + exports org.apache.commons.imaging.common; + exports org.apache.commons.imaging.icc; + exports org.apache.commons.imaging.palette; + exports org.apache.commons.imaging.util; + exports org.apache.commons.imaging.formats.jpeg.exif; } \ No newline at end of file