commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1366595 - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/ main/java/org/apache/commons/imaging/formats/gif/ main/java/org/apache/commons/imaging/formats/icns/ main/java/org/apache/commons/imaging/formats/pcx/ ma...
Date Sat, 28 Jul 2012 04:43:54 GMT
Author: damjan
Date: Sat Jul 28 04:43:54 2012
New Revision: 1366595

URL: http://svn.apache.org/viewvc?rev=1366595&view=rev
Log:
Various Findbugs fixes and field encapsulation.


Modified:
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageFormat.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageInfo.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
    commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java
    commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageFormat.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageFormat.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageFormat.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageFormat.java
Sat Jul 28 04:43:54 2012
@@ -20,8 +20,8 @@ package org.apache.commons.imaging;
  * Provides a definition for an image format.
  */
 public class ImageFormat {
-    public final String name;
-    public final String extension;
+    private final String name;
+    private final String extension;
     public final boolean actual;
 
     private ImageFormat(String name, boolean actual) {
@@ -43,18 +43,26 @@ public class ImageFormat {
 
         ImageFormat other = (ImageFormat) o;
 
-        return other.name.equals(name);
+        return other.getName().equals(getName());
 
     }
 
+    public String getName() {
+        return name;
+    }
+    
+    public String getExtension() {
+        return extension;
+    }
+
     @Override
     public String toString() {
-        return "{" + name + ": " + extension + "}";
+        return "{" + getName() + ": " + getExtension() + "}";
     }
 
     @Override
     public int hashCode() {
-        return name.hashCode();
+        return getName().hashCode();
     }
 
     public static final ImageFormat IMAGE_FORMAT_UNKNOWN = new ImageFormat(
@@ -97,5 +105,4 @@ public class ImageFormat {
 
         return result;
     }
-
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageInfo.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/ImageInfo.java Sat
Jul 28 04:43:54 2012
@@ -300,7 +300,7 @@ public class ImageInfo {
             pw.println("\t" + i + ": '" + s + "'");
 
         }
-        pw.println("Format: " + format.name);
+        pw.println("Format: " + format.getName());
         pw.println("Format Name: " + formatName);
         pw.println("Compression Algorithm: " + compressionAlgorithm);
         pw.println("Height: " + height);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/gif/GifImageParser.java
Sat Jul 28 04:43:54 2012
@@ -854,7 +854,6 @@ public class GifImageParser extends Imag
                                             : (palette_size > 2) ? 1 : 0;
 
             int colorTableSizeInFormat = 1 << (colorTableScaleLessOne + 1);
-            int actual_size = 3 * simple_pow(2, colorTableScaleLessOne + 1);
             {
                 byte colorResolution = (byte) colorTableScaleLessOne; // TODO:
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/icns/IcnsImageParser.java
Sat Jul 28 04:43:54 2012
@@ -87,8 +87,7 @@ public class IcnsImageParser extends Ima
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
-        boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
-                false);
+        ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
         if (params.containsKey(PARAM_KEY_VERBOSE))
             params.remove(PARAM_KEY_VERBOSE);
@@ -118,8 +117,7 @@ public class IcnsImageParser extends Ima
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
-        boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
-                false);
+        ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
         if (params.containsKey(PARAM_KEY_VERBOSE))
             params.remove(PARAM_KEY_VERBOSE);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/pcx/PcxImageParser.java
Sat Jul 28 04:43:54 2012
@@ -102,8 +102,6 @@ public class PcxImageParser extends Imag
             throws ImageReadException, IOException {
         PcxHeader pcxHeader = readPcxHeader(byteSource);
         Dimension size = getImageSize(byteSource, params);
-        int metricHDpi = (int) (pcxHeader.hDpi * 1000.0 / 2.54);
-        int metricVDpi = (int) (pcxHeader.vDpi * 1000.0 / 2.54);
         return new ImageInfo(
                 "PCX",
                 pcxHeader.nPlanes * pcxHeader.bitsPerPixel,

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/png/PngImageParser.java
Sat Jul 28 04:43:54 2012
@@ -504,14 +504,12 @@ public class PngImageParser extends Imag
             throw new ImageReadException("PNG contains more than one Header");
 
         PngChunkIhdr pngChunkIHDR = (PngChunkIhdr) IHDRs.get(0);
-        PngChunk pngChunktRNS = null;
 
         boolean isTransparent = false;
 
         List<PngChunk> tRNSs = filterChunks(chunks, tRNS);
         if (tRNSs.size() > 0) {
             isTransparent = true;
-            pngChunktRNS = IHDRs.get(0);
         } else {
             // CE - Fix Alpha.
             isTransparent = hasAlphaChannel(pngChunkIHDR.colorType);
@@ -632,8 +630,7 @@ public class PngImageParser extends Imag
     @Override
     public BufferedImage getBufferedImage(ByteSource byteSource, Map params)
             throws ImageReadException, IOException {
-        boolean verbose = ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE,
-                false);
+        ParamMap.getParamBoolean(params, PARAM_KEY_VERBOSE, false);
 
         if (params.containsKey(PARAM_KEY_VERBOSE))
             params.remove(PARAM_KEY_VERBOSE);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/psd/PsdImageParser.java
Sat Jul 28 04:43:54 2012
@@ -319,8 +319,7 @@ public class PsdImageParser extends Imag
             // byte LayerAndMaskData[] = readByteArray("LayerAndMaskData",
             // LayerAndMaskDataLength, is, "Not a Valid PSD File");
 
-            int Compression = read2Bytes("Compression", is,
-                    "Not a Valid PSD File");
+            read2Bytes("Compression", is, "Not a Valid PSD File");
 
             // byte ImageData[] = readByteArray("ImageData",
             // LayerAndMaskDataLength, is, "Not a Valid PSD File");
@@ -386,8 +385,7 @@ public class PsdImageParser extends Imag
             // byte LayerAndMaskData[] = readByteArray("LayerAndMaskData",
             // LayerAndMaskDataLength, is, "Not a Valid PSD File");
 
-            int Compression = read2Bytes("Compression", is,
-                    "Not a Valid PSD File");
+            read2Bytes("Compression", is, "Not a Valid PSD File");
 
             // byte ImageData[] = readByteArray("ImageData",
             // LayerAndMaskDataLength, is, "Not a Valid PSD File");
@@ -651,7 +649,7 @@ public class PsdImageParser extends Imag
         // GraphicControlExtension gce = (GraphicControlExtension) findBlock(
         // fImageContents.blocks, kGraphicControlExtension);
 
-        List<ImageResourceBlock> blocks = readImageResourceBlocks(byteSource,
+        readImageResourceBlocks(byteSource,
         // fImageContents.ImageResources,
                 null, -1);
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
(original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
Sat Jul 28 04:43:54 2012
@@ -323,8 +323,7 @@ public class IccProfileParser extends Bi
             try {
                 is = byteSource.getInputStream();
 
-                int ProfileSize = read4Bytes("ProfileSize", is,
-                        "Not a Valid ICC Profile");
+                read4Bytes("ProfileSize", is, "Not a Valid ICC Profile");
 
                 // if (length != ProfileSize)
                 // return null;

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/formats/xmp/XmpUpdateTest.java
Sat Jul 28 04:43:54 2012
@@ -72,7 +72,7 @@ public class XmpUpdateTest extends Imagi
                 continue;
 
             File tempFile = this.createTempFile(imageFile.getName() + ".", "."
-                    + imageFormat.extension);
+                    + imageFormat.getExtension());
             BufferedImage image = Imaging.getBufferedImage(imageFile);
 
             // ----

Modified: commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java?rev=1366595&r1=1366594&r2=1366595&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
(original)
+++ commons/proper/imaging/trunk/src/test/java/org/apache/commons/imaging/roundtrip/RoundtripTest.java
Sat Jul 28 04:43:54 2012
@@ -282,7 +282,7 @@ public class RoundtripTest extends Imagi
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
-                Debug.debug("bitmap test: " + formatInfo.format.name);
+                Debug.debug("bitmap test: " + formatInfo.format.getName());
 
                 roundtrip(formatInfo, testImage, "bitmap", true);
             }
@@ -311,7 +311,7 @@ public class RoundtripTest extends Imagi
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
-                Debug.debug("grayscale test: " + formatInfo.format.name);
+                Debug.debug("grayscale test: " + formatInfo.format.getName());
 
                 boolean imageExact = true;
                 if (formatInfo.colorSupport == COLOR_BITMAP)
@@ -339,7 +339,7 @@ public class RoundtripTest extends Imagi
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
-                Debug.debug("indexable test: " + formatInfo.format.name);
+                Debug.debug("indexable test: " + formatInfo.format.getName());
 
                 boolean imageExact = true;
                 if (formatInfo.colorSupport == COLOR_BITMAP)
@@ -369,7 +369,7 @@ public class RoundtripTest extends Imagi
                 if ((!formatInfo.canRead) || (!formatInfo.canWrite))
                     continue;
 
-                Debug.debug("fullColor test: " + formatInfo.format.name);
+                Debug.debug("fullColor test: " + formatInfo.format.getName());
 
                 boolean imageExact = true;
                 if (formatInfo.colorSupport == COLOR_BITMAP)
@@ -391,10 +391,10 @@ public class RoundtripTest extends Imagi
             if (!formatInfo.canRead || !formatInfo.canWrite || !formatInfo.preservesResolution)
                 continue;
             
-            Debug.debug("pixel density test: " + formatInfo.format.name);
+            Debug.debug("pixel density test: " + formatInfo.format.getName());
 
             File temp1 = createTempFile("pixeldensity.", "."
-                    + formatInfo.format.extension);
+                    + formatInfo.format.getExtension());
             
             Map params = new HashMap();
             PixelDensity pixelDensity = PixelDensity.createFromPixelsPerInch(75, 150);
@@ -422,7 +422,7 @@ public class RoundtripTest extends Imagi
             String tempPrefix, boolean imageExact) throws IOException,
             ImageReadException, ImageWriteException {
         File temp1 = createTempFile(tempPrefix + ".", "."
-                + formatInfo.format.extension);
+                + formatInfo.format.getExtension());
         // Debug.debug("tempFile: " + tempFile.getName());
 
         Map params = new HashMap();
@@ -442,7 +442,7 @@ public class RoundtripTest extends Imagi
 
         if (formatInfo.identicalSecondWrite) {
             File temp2 = createTempFile(tempPrefix + ".", "."
-                    + formatInfo.format.extension);
+                    + formatInfo.format.getExtension());
             // Debug.debug("tempFile: " + tempFile.getName());
             Imaging.writeImage(image2, temp2, formatInfo.format, params);
 



Mime
View raw message