You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2026/01/04 15:26:09 UTC
(commons-imaging) 38/43: Javadoc
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit 803e46a8ddafc8d8a7a25db8b2f0c7757395fad2
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sun Jan 4 07:28:41 2026 -0500
Javadoc
---
.../commons/imaging/formats/png/PhysicalScale.java | 34 +++++++++++++++++++++
.../imaging/formats/png/chunks/PngChunk.java | 35 ++++++++++++++++++++++
.../imaging/formats/png/chunks/PngChunkGama.java | 17 +++++++++++
3 files changed, 86 insertions(+)
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
index 79509318..9da57f93 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/PhysicalScale.java
@@ -26,10 +26,24 @@ public final class PhysicalScale {
/** Undefined physical scale. */
public static final PhysicalScale UNDEFINED = createFromMeters(-1.0, -1.0);
+ /**
+ * Creates a physical scale from meters.
+ *
+ * @param x horizontal units per pixel in meters.
+ * @param y vertical units per pixel in meters.
+ * @return the physical scale.
+ */
public static PhysicalScale createFromMeters(final double x, final double y) {
return new PhysicalScale(METER_UNITS, x, y);
}
+ /**
+ * Creates a physical scale from radians.
+ *
+ * @param x horizontal units per pixel in radians.
+ * @param y vertical units per pixel in radians.
+ * @return the physical scale.
+ */
public static PhysicalScale createFromRadians(final double x, final double y) {
return new PhysicalScale(RADIAN_UNITS, x, y);
}
@@ -46,18 +60,38 @@ public final class PhysicalScale {
this.verticalUnitsPerPixel = verticalUnitsPerPixel;
}
+ /**
+ * Gets the horizontal units per pixel.
+ *
+ * @return the horizontal units per pixel.
+ */
public double getHorizontalUnitsPerPixel() {
return horizontalUnitsPerPixel;
}
+ /**
+ * Gets the vertical units per pixel.
+ *
+ * @return the vertical units per pixel.
+ */
public double getVerticalUnitsPerPixel() {
return verticalUnitsPerPixel;
}
+ /**
+ * Checks if the units are in meters.
+ *
+ * @return true if units are in meters, false otherwise.
+ */
public boolean isInMeters() {
return METER_UNITS == units;
}
+ /**
+ * Checks if the units are in radians.
+ *
+ * @return true if units are in radians, false otherwise.
+ */
public boolean isInRadians() {
return RADIAN_UNITS == units;
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java b/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java
index 3707deb1..981f54a0 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunk.java
@@ -78,10 +78,20 @@ public class PngChunk extends BinaryFileParser {
return bytes.clone();
}
+ /**
+ * Gets the chunk type.
+ *
+ * @return the chunk type.
+ */
public int getChunkType() {
return chunkType;
}
+ /**
+ * Gets the CRC value.
+ *
+ * @return the CRC.
+ */
public int getCrc() {
return crc;
}
@@ -99,6 +109,11 @@ public class PngChunk extends BinaryFileParser {
return new ByteArrayInputStream(bytes);
}
+ /**
+ * Gets the chunk length.
+ *
+ * @return the length.
+ */
public int getLength() {
return length;
}
@@ -112,18 +127,38 @@ public class PngChunk extends BinaryFileParser {
return propertyBits.clone();
}
+ /**
+ * Checks if this is an ancillary chunk.
+ *
+ * @return true if ancillary, false otherwise.
+ */
public boolean isAncillary() {
return ancillary;
}
+ /**
+ * Checks if this is a private chunk.
+ *
+ * @return true if private, false otherwise.
+ */
public boolean isPrivate() {
return isPrivate;
}
+ /**
+ * Checks if this chunk is reserved.
+ *
+ * @return true if reserved, false otherwise.
+ */
public boolean isReserved() {
return reserved;
}
+ /**
+ * Checks if this chunk is safe to copy.
+ *
+ * @return true if safe to copy, false otherwise.
+ */
public boolean isSafeToCopy() {
return safeToCopy;
}
diff --git a/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java b/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
index f71b46b9..b9cbcbf8 100644
--- a/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
+++ b/src/main/java/org/apache/commons/imaging/formats/png/chunks/PngChunkGama.java
@@ -21,10 +21,22 @@ import static org.apache.commons.imaging.common.BinaryFunctions.read4Bytes;
import java.io.ByteArrayInputStream;
import java.io.IOException;
+/**
+ * PNG gAMA chunk with image gamma.
+ */
public final class PngChunkGama extends PngChunk {
private final int gamma;
+ /**
+ * Constructs a PNG gAMA chunk.
+ *
+ * @param length the chunk length.
+ * @param chunkType the chunk type.
+ * @param crc the CRC.
+ * @param bytes the chunk bytes.
+ * @throws IOException if an I/O error occurs.
+ */
public PngChunkGama(final int length, final int chunkType, final int crc, final byte[] bytes) throws IOException {
super(length, chunkType, crc, bytes);
@@ -32,6 +44,11 @@ public final class PngChunkGama extends PngChunk {
gamma = read4Bytes("Gamma", is, "Not a Valid PNG File: gAMA Corrupt", getByteOrder());
}
+ /**
+ * Gets the gamma value.
+ *
+ * @return the gamma value.
+ */
public double getGamma() {
return 1.0 / (gamma / 100000.0);
}