sis-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From desruisse...@apache.org
Subject svn commit: r1763334 - in /sis/branches/JDK8: core/sis-utility/src/main/java/org/apache/sis/math/ ide-project/NetBeans/nbproject/ storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/
Date Tue, 04 Oct 2016 22:51:03 GMT
Author: desruisseaux
Date: Tue Oct  4 22:51:03 2016
New Revision: 1763334

URL: http://svn.apache.org/viewvc?rev=1763334&view=rev
Log:
Javadoc cleaning and minor code review.

Modified:
    sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
    sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
    sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
    sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java

Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java?rev=1763334&r1=1763333&r2=1763334&view=diff
==============================================================================
--- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8]
(original)
+++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/math/Vector.java [UTF-8]
Tue Oct  4 22:51:03 2016
@@ -952,7 +952,7 @@ public abstract class Vector extends Abs
      * array is small compared to the calculation performed with the values.
      *
      * @param  tolerance  maximal difference allowed between original and compressed vectors
(can be zero).
-     * @return a more compact vector with the same data than this vector, or {@cod this}.
+     * @return a more compact vector with the same data than this vector, or {@code this}.
      */
     @SuppressWarnings("ReturnOfCollectionOrArrayField")
     public Vector compress(final double tolerance) {

Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties?rev=1763334&r1=1763333&r2=1763334&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] (original)
+++ sis/branches/JDK8/ide-project/NetBeans/nbproject/genfiles.properties [ISO-8859-1] Tue
Oct  4 22:51:03 2016
@@ -3,6 +3,6 @@
 build.xml.data.CRC32=58e6b21c
 build.xml.script.CRC32=462eaba0
 build.xml.stylesheet.CRC32=28e38971@1.53.1.46
-nbproject/build-impl.xml.data.CRC32=29ba5e0d
+nbproject/build-impl.xml.data.CRC32=7573d217
 nbproject/build-impl.xml.script.CRC32=b5306d38
 nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48

Modified: sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml?rev=1763334&r1=1763333&r2=1763334&view=diff
==============================================================================
--- sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml (original)
+++ sis/branches/JDK8/ide-project/NetBeans/nbproject/project.xml Tue Oct  4 22:51:03 2016
@@ -66,6 +66,7 @@
         </references>
         <spellchecker-wordlist xmlns="http://www.netbeans.org/ns/spellchecker-wordlist/1">
             <word>accessor</word>
+            <word>bilevel</word>
             <word>bitmask</word>
             <word>classname</word>
             <word>classnames</word>
@@ -74,6 +75,7 @@
             <word>deserialized</word>
             <word>endianness</word>
             <word>geoidal</word>
+            <word>grayscale</word>
             <word>hectopascals</word>
             <word>initially</word>
             <word>javadoc</word>

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java?rev=1763334&r1=1763333&r2=1763334&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/ImageFileDirectory.java
[UTF-8] Tue Oct  4 22:51:03 2016
@@ -47,34 +47,36 @@ final class ImageFileDirectory {
     /**
      * The size of the image described by this FID, or -1 if the information has not been
found.
      * The image may be much bigger than the memory capacity, in which case the image shall
be tiled.
-     * (Java attribut {@link #imageHeight} is named imageLength in tiff specification).
+     *
+     * <p><b>Note:</b>
+     * the {@link #imageHeight} attribute is named {@code ImageLength} in TIFF specification.</p>
      */
     private long imageWidth = -1, imageHeight = -1;
 
     /**
      * The size of each tile, or -1 if the information has not be found.
      * Tiles should be small enough for fitting in memory.
-     * (Java attribut {@link #tileHeight} is named tileLength in tiff specification).
+     *
+     * <p><b>Note:</b>
+     * the {@link #tileHeight} attribute is named {@code TileLength} in TIFF specification.</p>
      */
     private int tileWidth = -1, tileHeight = -1;
 
     /**
      * The number of components per pixel.
-     * SamplesPerPixel is usually 1 for bilevel, grayscale, and palette-color images.
-     * SamplesPerPixel is usually 3 for RGB images.
-     * If this value is higher, ExtraSamples should give an indication of the meaning of
the additional channels.
+     * The {@code samplesPerPixel} value is usually 1 for bilevel, grayscale and palette-color
images,
+     * and 3 for RGB images. If this value is higher, then the {@code ExtraSamples} TIFF
tag should
+     * give an indication of the meaning of the additional channels.
      */
     private short samplesPerPixel = 1;
 
     /**
      * Number of bits per component.
-     * Note that this field allows a different number of bits per component for each component
corresponding to a pixel.
+     * The TIFF specification allows a different number of bits per component for each component
corresponding to a pixel.
      * For example, RGB color data could use a different number of bits per component for
each of the three color planes.
-     * Most RGB files will have the same number of BitsPerSample for each component.
-     * Even in this case, the writer must write all three values.
-     * LibTiff does not support different BitsPerSample values for different components.
+     * However, current Apache SIS implementation requires that all components have the same
{@code BitsPerSample} value.
      */
-    private short bitspersample = 1;
+    private short bitsPerSample = 1;
 
     /**
      * If {@code true}, the components are stored in separate “component planes”.
@@ -92,19 +94,20 @@ final class ImageFileDirectory {
     /**
      * The number of rows per strip.
      * TIFF image data can be organized into strips for faster random access and efficient
I/O buffering.
-     * RowsPerStrip and ImageLength together tell us the number of strips in the entire image.
The equation is:
-     * StripsPerImage = floor ((ImageLength + RowsPerStrip - 1) / RowsPerStrip).
-     * StripsPerImage is not a field. It is merely a value that a TIFF reader will want to
compute
-     * because it specifies the number of StripOffsets and StripByteCounts for the image.
-     * Note that either SHORT or LONG values can be used to specify RowsPerStrip.
-     * SHORT values may be used for small TIFF files. It should be noted, however,
-     * that earlier TIFF specification revisions required LONG values and that some software
may not accept SHORT values.
-     * The default is 2**32 - 1, which is effectively infinity.
-     * That is, the entire image is one strip. Use of a single strip is not recommended.
-     * Choose RowsPerStrip such that each strip is about 8K bytes, even if the data is not
compressed,
-     * since it makes buffering simpler for readers. The 8K value is fairly arbitrary, but
seems to work well.
+     * The {@code rowsPerStrip} and {@link #imageHeight} fields together tell us the number
of strips in the entire image.
+     * The equation is:
+     *
+     * {@preformat math
+     *     StripsPerImage = floor ((ImageLength + RowsPerStrip - 1) / RowsPerStrip)
+     * }
+     *
+     * {@code StripsPerImage} is not a field. It is merely a value that a TIFF reader will
want to compute
+     * because it specifies the number of {@code StripOffsets} and {@code StripByteCounts}
for the image.
+     *
+     * <p>This field should be interpreted as an unsigned value.
+     * The default is 2^32 - 1, which is effectively infinity (i.e. the entire image is one
strip).</p>
      */
-    private long rowPerStrip = 0xFFFFFFFF;
+    private int rowsPerStrip = 0xFFFFFFFF;
 
     /**
      * Creates a new image file directory.
@@ -213,28 +216,27 @@ final class ImageFileDirectory {
              */
             case Tags.BitsPerSample: {
                 final Vector values = type.readVector(reader.input, count);
-                final short value   = values.shortValue(0);
-                //-- temporary check internal bitpersamples values
-                //-- to assert same conformity values.
-                {
-                    //-- count never equal to 0
-                    //-- TODO later : reader support different bitpersample values.
-                    for (int i = 1; i < values.size(); i++) {
-                        if (Math.abs(value - values.shortValue(i)) < 1E-9)
-                            throw new IllegalArgumentException("SIS GeoTiff image reader
does not support "
-                                    + "different BitsPerSample values. Expected : "+value+",
found : "+values.shortValue(i));
-
+                /*
+                 * The current implementation requires that all 'bitsPerSample' elements
have the same value.
+                 * This restriction may be revisited in future Apache SIS versions.
+                 * Note: 'count' is never zero when this method is invoked, so we do not
need to check bounds.
+                 */
+                bitsPerSample = values.shortValue(0);
+                final int length = values.size();
+                for (int i = 1; i < length; i++) {
+                    if (values.shortValue(i) != bitsPerSample) {
+                        throw new IllegalArgumentException("SIS GeoTiff image reader does
not support "
+                                + "different BitsPerSample values. Found: " + values);
                     }
                 }
-                bitspersample = value;
                 break;
             }
             /*
-             * The number of components per pixel. Ssually 1 for bilevel, grayscale, and
palette-color images,
+             * The number of components per pixel. Usually 1 for bilevel, grayscale, and
palette-color images,
              * and 3 for RGB images. Default value is 1.
              */
             case Tags.SamplesPerPixel: {
-                samplesPerPixel = (short) type.readUnsignedLong(reader.input, count);
+                samplesPerPixel = type.readShort(reader.input, count);
                 break;
             }
             /*

Modified: sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
URL: http://svn.apache.org/viewvc/sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java?rev=1763334&r1=1763333&r2=1763334&view=diff
==============================================================================
--- sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
[UTF-8] (original)
+++ sis/branches/JDK8/storage/sis-geotiff/src/main/java/org/apache/sis/storage/geotiff/Type.java
[UTF-8] Tue Oct  4 22:51:03 2016
@@ -438,6 +438,27 @@ enum Type {
     }
 
     /**
+     * Reads a single value and returns it as a signed {@code short} type, performing conversion
if needed.
+     * This method should be invoked when the caller expects a single value.
+     *
+     * @param  input  the input from where to read the value.
+     * @param  count  the amount of values (normally exactly 1).
+     * @return the value as a {@code short}.
+     * @throws IOException if an error occurred while reading the stream.
+     * @throws NumberFormatException if the value was stored in ASCII and can not be parsed.
+     * @throws ArithmeticException if the value can not be represented in the Java signed
{@code short} type.
+     * @throws IllegalArgumentException if the value is not a singleton.
+     * @throws UnsupportedOperationException if this type is {@link #UNDEFINED}.
+     */
+    final short readShort(final ChannelDataInput input, final long count) throws IOException
{
+        final long value = readLong(input, count);
+        if (value >= Short.MIN_VALUE && value <= Short.MAX_VALUE) {
+            return (short) value;
+        }
+        throw new ArithmeticException(canNotConvert(Long.toString(value)));
+    }
+
+    /**
      * Reads a single value which is expected to be positive. A negative value may be an
encoding error in the
      * big TIFF file, or if it was really the intended value then something greater than
what we can support.
      *



Mime
View raw message