commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r995628 - in /commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan: color/ common/byteSources/ formats/bmp/ formats/gif/ formats/ico/ formats/jpeg/ formats/png/ formats/pnm/ formats/psd/ formats/tiff/photometricinterpreters/ util/
Date Fri, 10 Sep 2010 01:12:54 GMT
Author: sebb
Date: Fri Sep 10 01:12:53 2010
New Revision: 995628

URL: http://svn.apache.org/viewvc?rev=995628&view=rev
Log:
Fix various Eclipse warnings

Modified:
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/color/ColorConversions.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/common/byteSources/ByteSourceFile.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/bmp/BmpImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/gif/GifImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/ico/IcoImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegUtils.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/PngImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PsdImageParser.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java
    commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/util/Debug.java

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/color/ColorConversions.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/color/ColorConversions.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/color/ColorConversions.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/color/ColorConversions.java
Fri Sep 10 01:12:53 2010
@@ -703,7 +703,7 @@ public abstract class ColorConversions
 
 		{
 
-			double var_Y = (((double) cieL * 100.0 / 255.0) + 16.0) / 116.0;
+			double var_Y = ((cieL * 100.0 / 255.0) + 16.0) / 116.0;
 			double var_X = cieA / 500.0 + var_Y;
 			double var_Z = var_Y - cieB / 200.0;
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/common/byteSources/ByteSourceFile.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/common/byteSources/ByteSourceFile.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/common/byteSources/ByteSourceFile.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/common/byteSources/ByteSourceFile.java
Fri Sep 10 01:12:53 2010
@@ -67,7 +67,9 @@ public class ByteSourceFile extends Byte
 		{
 			try
 			{
-				raf.close();
+				if (raf != null) {
+				    raf.close();
+				}
 			}
 			catch (Exception e)
 			{

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/bmp/BmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/bmp/BmpImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/bmp/BmpImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/bmp/BmpImageParser.java
Fri Sep 10 01:12:53 2010
@@ -388,7 +388,9 @@ public class BmpImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+				if (is != null) {
+				    is.close();
+				}
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -511,10 +513,10 @@ public class BmpImageParser extends Imag
 		// boolean isProgressive = (fPNGChunkIHDR.InterlaceMethod != 0);
 		//
 		// pixels per meter
-		int physicalWidthDpi = (int) ((double) bhi.hResolution * 1000.0 / 2.54);
+		int physicalWidthDpi = (int) (bhi.hResolution * 1000.0 / 2.54);
 		float physicalWidthInch = (float) ((double) width / (double) physicalWidthDpi);
 		// int physicalHeightDpi = 72;
-		int physicalHeightDpi = (int) ((double) bhi.vResolution * 1000.0 / 2.54);
+		int physicalHeightDpi = (int) (bhi.vResolution * 1000.0 / 2.54);
 		float physicalHeightInch = (float) ((double) height / (double) physicalHeightDpi);
 
 		String formatDetails = "Bmp (" + (char) bhi.identifier1

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/gif/GifImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/gif/GifImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/gif/GifImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/gif/GifImageParser.java
Fri Sep 10 01:12:53 2010
@@ -422,8 +422,7 @@ public class GifImageParser extends Imag
 	}
 
 	private byte[] readColorTable(InputStream is, int ct_size,
-			FormatCompliance formatCompliance) throws ImageReadException,
-			IOException
+			FormatCompliance formatCompliance) throws IOException
 	{
 		int actual_size = convertColorTableSize(ct_size);
 
@@ -433,6 +432,7 @@ public class GifImageParser extends Imag
 		return bytes;
 	}
 
+	// TODO - unused
 	private GIFHeaderInfo readHeader(ByteSource byteSource)
 			throws ImageReadException, IOException
 	{
@@ -446,7 +446,9 @@ public class GifImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -500,7 +502,9 @@ public class GifImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -553,8 +557,7 @@ public class GifImageParser extends Imag
 		return null;
 	}
 
-	private ArrayList getComments(ArrayList v) throws ImageReadException,
-			IOException
+	private ArrayList getComments(ArrayList v) throws IOException
 	{
 		ArrayList result = new ArrayList();
 		int code = 0x21fe;
@@ -670,8 +673,7 @@ public class GifImageParser extends Imag
 		return true;
 	}
 
-	private int[] getColorTable(byte bytes[]) throws ImageReadException,
-			IOException
+	private int[] getColorTable(byte bytes[]) throws ImageReadException
 	{
 		if ((bytes.length % 3) != 0)
 			throw new ImageReadException("Bad Color Table Length: "
@@ -1174,7 +1176,9 @@ public class GifImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/ico/IcoImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/ico/IcoImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/ico/IcoImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/ico/IcoImageParser.java
Fri Sep 10 01:12:53 2010
@@ -18,11 +18,6 @@ package org.apache.sanselan.formats.ico;
 
 import java.awt.Dimension;
 import java.awt.image.BufferedImage;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBufferInt;
-import java.awt.image.Raster;
-import java.awt.image.SampleModel;
-import java.awt.image.WritableRaster;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -362,8 +357,8 @@ public class IcoImageParser extends Imag
 		BinaryOutputStream bos = new BinaryOutputStream(baos,
 				BinaryOutputStream.BYTE_ORDER_LITTLE_ENDIAN);
 
-		bos.write((int)'B');
-		bos.write((int)'M');
+		bos.write('B');
+		bos.write('M');
 		bos.write4Bytes(bitmapSize);
 		bos.write4Bytes(0);
 		bos.write4Bytes(bitmapPixelsOffset);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageParser.java
Fri Sep 10 01:12:53 2010
@@ -174,8 +174,7 @@ public class JpegImageParser extends Ima
 
 	public static final boolean permissive = true;
 
-	private byte[] assembleSegments(ArrayList v) throws ImageReadException,
-			IOException
+	private byte[] assembleSegments(ArrayList v) throws ImageReadException
 	{
 		try
 		{
@@ -187,7 +186,7 @@ public class JpegImageParser extends Ima
 	}
 
 	private byte[] assembleSegments(ArrayList v, boolean start_with_zero)
-			throws ImageReadException, IOException
+			throws ImageReadException
 	{
 		if (v.size() < 1)
 			throw new ImageReadException("No App2 Segments Found.");
@@ -336,6 +335,7 @@ public class JpegImageParser extends Ima
 		return result;
 	}
 
+	// TODO unused
 	private ArrayList filterSegments(ArrayList v, List markers)
 	{
 		ArrayList result = new ArrayList();
@@ -780,12 +780,10 @@ public class JpegImageParser extends Ima
 
 		if (units_per_inch > 0)
 		{
-			PhysicalWidthDpi = (int) Math.round((double) x_density
-					/ units_per_inch);
-			PhysicalWidthInch = (float) ((double) Width / (x_density * units_per_inch));
-			PhysicalHeightDpi = (int) Math.round((double) y_density
-					* units_per_inch);
-			PhysicalHeightInch = (float) ((double) Height / (y_density * units_per_inch));
+			PhysicalWidthDpi = (int) Math.round(x_density / units_per_inch);
+			PhysicalWidthInch = (float) (Width / (x_density * units_per_inch));
+			PhysicalHeightDpi = (int) Math.round(y_density 	* units_per_inch);
+			PhysicalHeightInch = (float) (Height / (y_density * units_per_inch));
 		}
 
 		ArrayList Comments = new ArrayList();

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegUtils.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegUtils.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegUtils.java
Fri Sep 10 01:12:53 2010
@@ -106,7 +106,9 @@ public class JpegUtils extends BinaryFil
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/PngImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/PngImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/PngImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/png/PngImageParser.java
Fri Sep 10 01:12:53 2010
@@ -136,7 +136,9 @@ public class PngImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+				if (is != null) {
+				    is.close();
+				}
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -255,7 +257,9 @@ public class PngImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -441,8 +445,7 @@ public class PngImageParser extends Imag
 		return result;
 	}
 
-	private boolean hasAlphaChannel(int ColorType) throws ImageReadException,
-			IOException
+	private boolean hasAlphaChannel(int ColorType) throws ImageReadException
 	{
 		switch (ColorType)
 		{

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/pnm/PNMImageParser.java
Fri Sep 10 01:12:53 2010
@@ -133,7 +133,9 @@ public class PNMImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -283,7 +285,9 @@ public class PNMImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PsdImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PsdImageParser.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PsdImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/psd/PsdImageParser.java
Fri Sep 10 01:12:53 2010
@@ -94,7 +94,9 @@ public class PsdImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -276,7 +278,9 @@ public class PsdImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -409,7 +413,9 @@ public class PsdImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -435,7 +441,9 @@ public class PsdImageParser extends Imag
 		{
 			try
 			{
-				is.close();
+			    if (is != null) {
+			        is.close();
+			    }
 			} catch (Exception e)
 			{
 				Debug.debug(e);
@@ -583,8 +591,8 @@ public class PsdImageParser extends Imag
 		return result;
 	}
 
+	// TODO not used
 	private ImageResourceBlock findImageResourceBlock(ArrayList blocks, int ID)
-			throws ImageReadException, IOException
 	{
 		for (int i = 0; i < blocks.size(); i++)
 		{

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/formats/tiff/photometricinterpreters/PhotometricInterpreterYCbCr.java
Fri Sep 10 01:12:53 2010
@@ -51,10 +51,10 @@ public class PhotometricInterpreterYCbCr
 	 */
 	public int convertYCbCrtoRGB(int Y, int Cb, int Cr)
 	{
-		double r1 = (((1.164 * ((double) Y - 16.0))) + (1.596 * ((double) Cr - 128.0)));
-		double g1 = (((1.164 * ((double) Y - 16.0)))
-				- (0.813 * ((double) Cr - 128.0)) - (0.392 * ((double) Cb - 128.0)));
-		double b1 = (((1.164 * ((double) Y - 16.0))) + (2.017 * ((double) Cb - 128.0)));
+		double r1 = (((1.164 * (Y - 16.0))) + (1.596 * (Cr - 128.0)));
+		double g1 = (((1.164 * (Y - 16.0)))
+				- (0.813 * (Cr - 128.0)) - (0.392 * (Cb - 128.0)));
+		double b1 = (((1.164 * (Y - 16.0))) + (2.017 * (Cb - 128.0)));
 
 		int r = limit((int) r1, 0, 255);
 		int g = limit((int) g1, 0, 255);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/util/Debug.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/util/Debug.java?rev=995628&r1=995627&r2=995628&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/util/Debug.java (original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/sanselan/util/Debug.java Fri Sep
10 01:12:53 2010
@@ -379,15 +379,18 @@ public final class Debug
 
 	public static void debug(String message, Object value[])
 	{
-		if (value == null)
+		if (value == null) {
 			debug(message, "null");
-
-		debug(message, value.length);
-		final int max = 10;
-		for (int i = 0; i < value.length && i < max; i++)
-			debug("\t" + i, value[i]);
-		if (value.length > max)
-			debug("\t...");
+		} else {
+    		debug(message, value.length);
+    		final int max = 10;
+    		for (int i = 0; i < value.length && i < max; i++) {
+    		    debug("\t" + i, value[i]);
+    		}
+    		if (value.length > max) {
+    		    debug("\t...");
+    		}
+		}
 		debug();
 	}
 
@@ -478,15 +481,18 @@ public final class Debug
 	{
 		StringBuffer result = new StringBuffer();
 
-		if (value == null)
+		if (value == null) {
 			result.append(getDebug(message, "null") + newline);
-
-		result.append(getDebug(message, value.length));
-		final int max = 10;
-		for (int i = 0; i < value.length && i < max; i++)
-			result.append(getDebug("\t" + i, value[i]) + newline);
-		if (value.length > max)
-			result.append(getDebug("\t...") + newline);
+		} else {
+    		result.append(getDebug(message, value.length));
+    		final int max = 10;
+    		for (int i = 0; i < value.length && i < max; i++) {
+    		    result.append(getDebug("\t" + i, value[i]) + newline);
+    		}
+    		if (value.length > max) {
+    		    result.append(getDebug("\t...") + newline);
+    		}
+		}
 		result.append(newline);
 
 		return result.toString();



Mime
View raw message