You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by da...@apache.org on 2012/09/27 20:22:40 UTC

svn commit: r1391156 [3/4] - in /commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging: formats/pcx/ formats/png/ formats/png/chunks/ formats/png/scanlinefilters/ formats/pnm/ formats/psd/ formats/psd/dataparsers/ formats/psd/datareader...

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByte.java Thu Sep 27 18:22:37 2012
@@ -27,21 +27,23 @@ public class FieldTypeByte extends Field
 
     @Override
     public Object getSimpleValue(TiffField entry) {
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return entry.valueOffsetBytes[0];
+        }
 
         return getRawBytes(entry);
     }
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Byte)
+        if (o instanceof Byte) {
             return new byte[] { ((Byte) o).byteValue(), };
-        else if (o instanceof byte[])
+        } else if (o instanceof byte[]) {
             return (byte[]) o;
-        else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeDouble.java Thu Sep 27 18:22:37 2012
@@ -32,21 +32,23 @@ public class FieldTypeDouble extends Fie
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Double)
+        if (o instanceof Double) {
             return convertDoubleToByteArray(((Double) o).doubleValue(),
                     byteOrder);
-        else if (o instanceof double[]) {
+        } else if (o instanceof double[]) {
             double numbers[] = (double[]) o;
             return convertDoubleArrayToByteArray(numbers, byteOrder);
         } else if (o instanceof Double[]) {
             Double numbers[] = (Double[]) o;
             double values[] = new double[numbers.length];
-            for (int i = 0; i < values.length; i++)
+            for (int i = 0; i < values.length; i++) {
                 values[i] = numbers[i].doubleValue();
+            }
             return convertDoubleArrayToByteArray(values, byteOrder);
-        } else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeFloat.java Thu Sep 27 18:22:37 2012
@@ -29,10 +29,11 @@ public class FieldTypeFloat extends Fiel
 
     @Override
     public Object getSimpleValue(TiffField entry) {
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return new Float(convertByteArrayToFloat(name + " ("
                     + entry.tagInfo.name + ")", entry.valueOffsetBytes,
                     entry.byteOrder));
+        }
 
         return convertByteArrayToFloatArray(name + " (" + entry.tagInfo.name
                 + ")", getRawBytes(entry), 0, entry.length, entry.byteOrder);
@@ -40,20 +41,22 @@ public class FieldTypeFloat extends Fiel
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Float)
+        if (o instanceof Float) {
             return convertFloatToByteArray(((Float) o).floatValue(), byteOrder);
-        else if (o instanceof float[]) {
+        } else if (o instanceof float[]) {
             float numbers[] = (float[]) o;
             return convertFloatArrayToByteArray(numbers, byteOrder);
         } else if (o instanceof Float[]) {
             Float numbers[] = (Float[]) o;
             float values[] = new float[numbers.length];
-            for (int i = 0; i < values.length; i++)
+            for (int i = 0; i < values.length; i++) {
                 values[i] = numbers[i].floatValue();
+            }
             return convertFloatArrayToByteArray(values, byteOrder);
-        } else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeLong.java Thu Sep 27 18:22:37 2012
@@ -27,10 +27,11 @@ public class FieldTypeLong extends Field
 
     @Override
     public Object getSimpleValue(TiffField entry) {
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return convertByteArrayToInt(
                     name + " (" + entry.tagInfo.name + ")",
                     entry.valueOffsetBytes, entry.byteOrder);
+        }
 
         return convertByteArrayToIntArray(name + " (" + entry.tagInfo.name
                 + ")", getRawBytes(entry), 0, entry.length, entry.byteOrder);
@@ -38,21 +39,23 @@ public class FieldTypeLong extends Field
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Integer)
+        if (o instanceof Integer) {
             return convertIntArrayToByteArray(
                     new int[] { ((Integer) o).intValue(), }, byteOrder);
-        else if (o instanceof int[]) {
+        } else if (o instanceof int[]) {
             int numbers[] = (int[]) o;
             return convertIntArrayToByteArray(numbers, byteOrder);
         } else if (o instanceof Integer[]) {
             Integer numbers[] = (Integer[]) o;
             int values[] = new int[numbers.length];
-            for (int i = 0; i < values.length; i++)
+            for (int i = 0; i < values.length; i++) {
                 values[i] = numbers[i].intValue();
+            }
             return convertIntArrayToByteArray(values, byteOrder);
-        } else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRational.java Thu Sep 27 18:22:37 2012
@@ -29,9 +29,10 @@ public class FieldTypeRational extends F
 
     @Override
     public Object getSimpleValue(TiffField entry) {
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return convertByteArrayToRational(name + " (" + entry.tagInfo.name
                     + ")", entry.oversizeValue, entry.byteOrder);
+        }
 
         return convertByteArrayToRationalArray(name + " (" + entry.tagInfo.name
                 + ")", getRawBytes(entry), 0, entry.length, entry.byteOrder);
@@ -39,9 +40,9 @@ public class FieldTypeRational extends F
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof RationalNumber)
+        if (o instanceof RationalNumber) {
             return convertRationalToByteArray((RationalNumber) o, byteOrder);
-        else if (o instanceof RationalNumber[]) {
+        } else if (o instanceof RationalNumber[]) {
             return convertRationalArrayToByteArray((RationalNumber[]) o,
                     byteOrder);
         } else if (o instanceof Number) {
@@ -67,9 +68,10 @@ public class FieldTypeRational extends F
                         .getRationalNumber(number);
             }
             return convertRationalArrayToByteArray(rationalNumbers, byteOrder);
-        } else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
     public byte[] writeData(int numerator, int denominator, int byteOrder)

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeShort.java Thu Sep 27 18:22:37 2012
@@ -43,9 +43,10 @@ public class FieldTypeShort extends Fiel
 
     @Override
     public Object getSimpleValue(TiffField entry) throws ImageReadException {
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return BinaryConversions.convertToShort(entry.valueOffsetBytes,
                     entry.byteOrder);
+        }
 
         return BinaryConversions.convertToShortArray(getRawBytes(entry),
                 entry.byteOrder);
@@ -53,21 +54,23 @@ public class FieldTypeShort extends Fiel
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Short)
+        if (o instanceof Short) {
             return BinaryConversions.convertToByteArray(
                     new short[] { ((Short) o).shortValue(), }, byteOrder);
-        else if (o instanceof short[]) {
+        } else if (o instanceof short[]) {
             short numbers[] = (short[]) o;
             return BinaryConversions.convertToByteArray(numbers, byteOrder);
         } else if (o instanceof Short[]) {
             Short numbers[] = (Short[]) o;
             short values[] = new short[numbers.length];
-            for (int i = 0; i < values.length; i++)
+            for (int i = 0; i < values.length; i++) {
                 values[i] = numbers[i].shortValue();
+            }
             return BinaryConversions.convertToByteArray(values, byteOrder);
-        } else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeUnknown.java Thu Sep 27 18:22:37 2012
@@ -37,21 +37,23 @@ public class FieldTypeUnknown extends Fi
         // Debug.debug("unknown field type. entry.oversizeValue",
         // entry.oversizeValue);
 
-        if (entry.length == 1)
+        if (entry.length == 1) {
             return entry.valueOffsetBytes[0];
+        }
 
         return getRawBytes(entry);
     }
 
     @Override
     public byte[] writeData(Object o, int byteOrder) throws ImageWriteException {
-        if (o instanceof Byte)
+        if (o instanceof Byte) {
             return new byte[] { ((Byte) o).byteValue(), };
-        else if (o instanceof byte[])
+        } else if (o instanceof byte[]) {
             return (byte[]) o;
-        else
+        } else {
             throw new ImageWriteException("Invalid data: " + o + " ("
                     + Debug.getType(o) + ")");
+        }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterBiLevel.java Thu Sep 27 18:22:37 2012
@@ -40,8 +40,9 @@ public class PhotometricInterpreterBiLev
             int y) throws ImageReadException, IOException {
         int sample = samples[0];
 
-        if (invert)
+        if (invert) {
             sample = 255 - sample;
+        }
 
         int red = sample;
         int green = sample;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuv.java Thu Sep 27 18:22:37 2012
@@ -61,20 +61,23 @@ public class PhotometricInterpreterLogLu
             float var_y_cube = cube(var_Y);
             float var_z_cube = cube(var_Z);
 
-            if (var_y_cube > 0.008856f)
+            if (var_y_cube > 0.008856f) {
                 var_Y = var_y_cube;
-            else
+            } else {
                 var_Y = (var_Y - 16 / 116.0f) / 7.787f;
+            }
 
-            if (var_x_cube > 0.008856f)
+            if (var_x_cube > 0.008856f) {
                 var_X = var_x_cube;
-            else
+            } else {
                 var_X = (var_X - 16 / 116.0f) / 7.787f;
+            }
 
-            if (var_z_cube > 0.008856f)
+            if (var_z_cube > 0.008856f) {
                 var_Z = var_z_cube;
-            else
+            } else {
                 var_Z = (var_Z - 16 / 116.0f) / 7.787f;
+            }
 
             float ref_X = 95.047f;
             float ref_Y = 100.000f;
@@ -100,19 +103,22 @@ public class PhotometricInterpreterLogLu
             float var_G = var_X * -0.9689f + var_Y * 1.8758f + var_Z * 0.0415f;
             float var_B = var_X * 0.0557f + var_Y * -0.2040f + var_Z * 1.0570f;
 
-            if (var_R > 0.0031308)
+            if (var_R > 0.0031308) {
                 var_R = 1.055f * (float) Math.pow(var_R, (1 / 2.4)) - 0.055f;
-            else
+            } else {
                 var_R = 12.92f * var_R;
-            if (var_G > 0.0031308)
+            }
+            if (var_G > 0.0031308) {
                 var_G = 1.055f * (float) Math.pow(var_G, (1 / 2.4)) - 0.055f;
-            else
+            } else {
                 var_G = 12.92f * var_G;
+            }
 
-            if (var_B > 0.0031308)
+            if (var_B > 0.0031308) {
                 var_B = 1.055f * (float) Math.pow(var_B, (1 / 2.4)) - 0.055f;
-            else
+            } else {
                 var_B = 12.92f * var_B;
+            }
 
             // var_R = (((var_R-)))
             // updateMaxMin(new float[]{

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoGpsText.java Thu Sep 27 18:22:37 2012
@@ -83,9 +83,10 @@ public final class TagInfoGpsText extend
     @Override
     public byte[] encodeValue(FieldType fieldType, Object value, int byteOrder)
             throws ImageWriteException {
-        if (!(value instanceof String))
+        if (!(value instanceof String)) {
             throw new ImageWriteException("GPS text value not String: " + value
                     + " (" + Debug.getType(value) + ")");
+        }
         String s = (String) value;
 
         try {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoXpString.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoXpString.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoXpString.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/taginfos/TagInfoXpString.java Thu Sep 27 18:22:37 2012
@@ -40,9 +40,10 @@ public class TagInfoXpString extends Tag
     @Override
     public byte[] encodeValue(FieldType fieldType, Object value, int byteOrder)
             throws ImageWriteException {
-        if (!(value instanceof String))
+        if (!(value instanceof String)) {
             throw new ImageWriteException("Text value not String: " + value
                     + " (" + Debug.getType(value) + ")");
+        }
         String s = (String) value;
         try {
             return s.getBytes("UTF-16LE");

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterBase.java Thu Sep 27 18:22:37 2012
@@ -64,8 +64,9 @@ public abstract class TiffImageWriterBas
             throws ImageWriteException {
         List<TiffOutputDirectory> directories = outputSet.getDirectories();
 
-        if (1 > directories.size())
+        if (1 > directories.size()) { 
             throw new ImageWriteException("No directories.");
+        }
 
         TiffOutputDirectory exifDirectory = null;
         TiffOutputDirectory gpsDirectory = null;
@@ -86,23 +87,26 @@ public abstract class TiffImageWriterBas
             if (dirType < 0) {
                 switch (dirType) {
                 case DIRECTORY_TYPE_EXIF:
-                    if (exifDirectory != null)
+                    if (exifDirectory != null) {
                         throw new ImageWriteException(
                                 "More than one EXIF directory.");
+                    }
                     exifDirectory = directory;
                     break;
 
                 case DIRECTORY_TYPE_GPS:
-                    if (gpsDirectory != null)
+                    if (gpsDirectory != null) {
                         throw new ImageWriteException(
                                 "More than one GPS directory.");
+                    }
                     gpsDirectory = directory;
                     break;
 
                 case DIRECTORY_TYPE_INTEROPERABILITY:
-                    if (interoperabilityDirectory != null)
+                    if (interoperabilityDirectory != null) {
                         throw new ImageWriteException(
                                 "More than one Interoperability directory.");
+                    }
                     interoperabilityDirectory = directory;
                     break;
                 default:
@@ -110,10 +114,11 @@ public abstract class TiffImageWriterBas
                             + dirType);
                 }
             } else {
-                if (directoryIndices.contains(dirType))
+                if (directoryIndices.contains(dirType)) {
                     throw new ImageWriteException(
                             "More than one directory with index: " + dirType
                                     + ".");
+                }
                 directoryIndices.add(dirType);
                 // dirMap.put(arg0, arg1)
             }
@@ -123,34 +128,39 @@ public abstract class TiffImageWriterBas
             for (int j = 0; j < fields.size(); j++) {
                 TiffOutputField field = (TiffOutputField) fields.get(j);
 
-                if (fieldTags.contains(field.tag))
+                if (fieldTags.contains(field.tag)) {
                     throw new ImageWriteException("Tag ("
                             + field.tagInfo.getDescription()
                             + ") appears twice in directory.");
+                }
                 fieldTags.add(field.tag);
 
                 if (field.tag == ExifTagConstants.EXIF_TAG_EXIF_OFFSET.tag) {
-                    if (exifDirectoryOffsetField != null)
+                    if (exifDirectoryOffsetField != null) {
                         throw new ImageWriteException(
                                 "More than one Exif directory offset field.");
+                    }
                     exifDirectoryOffsetField = field;
                 } else if (field.tag == ExifTagConstants.EXIF_TAG_INTEROP_OFFSET.tag) {
-                    if (interoperabilityDirectoryOffsetField != null)
+                    if (interoperabilityDirectoryOffsetField != null) {
                         throw new ImageWriteException(
                                 "More than one Interoperability directory offset field.");
+                    }
                     interoperabilityDirectoryOffsetField = field;
                 } else if (field.tag == ExifTagConstants.EXIF_TAG_GPSINFO.tag) {
-                    if (gpsDirectoryOffsetField != null)
+                    if (gpsDirectoryOffsetField != null) {
                         throw new ImageWriteException(
                                 "More than one GPS directory offset field.");
+                    }
                     gpsDirectoryOffsetField = field;
                 }
             }
             // directory.
         }
 
-        if (directoryIndices.size() < 1)
+        if (directoryIndices.size() < 1) {
             throw new ImageWriteException("Missing root directory.");
+        }
 
         // "normal" TIFF directories should have continous indices starting with
         // 0, ie. 0, 1, 2...
@@ -159,13 +169,15 @@ public abstract class TiffImageWriterBas
         TiffOutputDirectory previousDirectory = null;
         for (int i = 0; i < directoryIndices.size(); i++) {
             Integer index = directoryIndices.get(i);
-            if (index.intValue() != i)
+            if (index.intValue() != i) {
                 throw new ImageWriteException("Missing directory: " + i + ".");
+            }
 
             // set up chain of directory references for "normal" directories.
             TiffOutputDirectory directory = directoryTypeMap.get(index);
-            if (null != previousDirectory)
+            if (null != previousDirectory) {
                 previousDirectory.setNextDirectory(directory);
+            }
             previousDirectory = directory;
         }
 
@@ -187,8 +199,8 @@ public abstract class TiffImageWriterBas
             }
 
             if (interoperabilityDirectoryOffsetField == null) {
-                interoperabilityDirectoryOffsetField = TiffOutputField
-                        .createOffsetField(
+                interoperabilityDirectoryOffsetField =
+                        TiffOutputField.createOffsetField(
                                 ExifTagConstants.EXIF_TAG_INTEROP_OFFSET,
                                 byteOrder);
                 exifDirectory.add(interoperabilityDirectoryOffsetField);
@@ -238,8 +250,9 @@ public abstract class TiffImageWriterBas
         params = new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
 
         TiffOutputSet userExif = null;
         if (params.containsKey(PARAM_KEY_EXIF)) {
@@ -265,9 +278,10 @@ public abstract class TiffImageWriterBas
         if (params.containsKey(PARAM_KEY_COMPRESSION)) {
             Object value = params.get(PARAM_KEY_COMPRESSION);
             if (value != null) {
-                if (!(value instanceof Number))
+                if (!(value instanceof Number)) {
                     throw new ImageWriteException(
                             "Invalid compression parameter: " + value);
+                }
                 compression = ((Number) value).intValue();
             }
             params.remove(PARAM_KEY_COMPRESSION);
@@ -310,9 +324,10 @@ public abstract class TiffImageWriterBas
         int t4Options = 0;
         int t6Options = 0;
         if (compression == TIFF_COMPRESSION_CCITT_1D) {
-            for (int i = 0; i < strips.length; i++)
+            for (int i = 0; i < strips.length; i++) {
                 strips[i] = T4AndT6Compression.compressModifiedHuffman(
                         strips[i], width, strips[i].length / ((width + 7) / 8));
+            }
         } else if (compression == TIFF_COMPRESSION_CCITT_GROUP_3) {
             Integer t4Parameter = (Integer) rawParams.get(PARAM_KEY_T4_OPTIONS);
             if (t4Parameter != null) {
@@ -348,12 +363,14 @@ public abstract class TiffImageWriterBas
                 throw new ImageWriteException(
                         "T.6 compression with the uncompressed mode extension is not yet supported");
             }
-            for (int i = 0; i < strips.length; i++)
+            for (int i = 0; i < strips.length; i++) {
                 strips[i] = T4AndT6Compression.compressT6(strips[i], width,
                         strips[i].length / ((width + 7) / 8));
+            }
         } else if (compression == TIFF_COMPRESSION_PACKBITS) {
-            for (int i = 0; i < strips.length; i++)
+            for (int i = 0; i < strips.length; i++) {
                 strips[i] = new PackBits().compress(strips[i]);
+            }
         } else if (compression == TIFF_COMPRESSION_LZW) {
             for (int i = 0; i < strips.length; i++) {
                 byte uncompressed[] = strips[i];
@@ -368,14 +385,16 @@ public abstract class TiffImageWriterBas
             }
         } else if (compression == TIFF_COMPRESSION_UNCOMPRESSED) {
             // do nothing.
-        } else
+        } else {
             throw new ImageWriteException(
                     "Invalid compression parameter (Only CCITT 1D/Group 3/Group 4, LZW, Packbits and uncompressed supported).");
+        }
 
         TiffElement.DataElement imageData[] = new TiffElement.DataElement[strips.length];
-        for (int i = 0; i < strips.length; i++)
+        for (int i = 0; i < strips.length; i++) {
             imageData[i] = new TiffImageData.Data(0, strips[i].length,
                     strips[i]);
+        }
 
         TiffOutputSet outputSet = new TiffOutputSet(byteOrder);
         TiffOutputDirectory directory = outputSet.addRootDirectory();
@@ -529,10 +548,11 @@ public abstract class TiffImageWriterBas
 
                         if (bitsPerSample == 1) {
                             int sample = (red + green + blue) / 3;
-                            if (sample > 127)
+                            if (sample > 127) {
                                 sample = 0;
-                            else
+                            } else {
                                 sample = 1;
+                            }
                             bitCache <<= 1;
                             bitCache |= sample;
                             bitsInCache++;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossless.java Thu Sep 27 18:22:37 2012
@@ -93,8 +93,9 @@ public class TiffImageWriterLossless ext
                             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()
@@ -144,21 +145,23 @@ public class TiffImageWriterLossless ext
                         continue;
                     }
                     TiffElement oversizeValue = field.getOversizeValueElement();
-                    if (oversizeValue != null)
+                    if (oversizeValue != null) {
                         elements.add(oversizeValue);
-
+                    }
                 }
 
                 JpegImageData jpegImageData = directory.getJpegImageData();
-                if (jpegImageData != null)
+                if (jpegImageData != null) {
                     elements.add(jpegImageData);
+                }
 
                 TiffImageData tiffImageData = directory.getTiffImageData();
                 if (tiffImageData != null) {
                     TiffElement.DataElement data[] = tiffImageData
                             .getImageData();
-                    for (int i = 0; i < data.length; i++)
+                    for (int i = 0; i < data.length; i++) {
                         elements.add(data[i]);
+                    }
                 }
             }
 
@@ -187,9 +190,10 @@ public class TiffImageWriterLossless ext
                         index = lastElementByte;
                     }
                 }
-                if (null != start)
+                if (null != start) {
                     result.add(new TiffElement.Stub(start.offset, index
                             - start.offset));
+                }
             }
 
             // dumpElements(byteSource, result);
@@ -205,9 +209,9 @@ public class TiffImageWriterLossless ext
             throws IOException, ImageWriteException {
         List<TiffElement> analysis = analyzeOldTiff();
         int oldLength = exifBytes.length;
-        if (analysis.size() < 1)
+        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
@@ -270,8 +274,9 @@ public class TiffImageWriterLossless ext
                 // discarding a tail element. should only happen once.
                 overflowIndex -= element.length;
                 unusedElements.remove(0);
-            } else
+            } else {
                 break;
+            }
         }
 
         Collections.sort(unusedElements, ELEMENT_SIZE_COMPARATOR);
@@ -299,10 +304,11 @@ public class TiffImageWriterLossless ext
             TiffElement bestFit = null;
             for (int i = 0; i < unusedElements.size(); i++) {
                 TiffElement element = unusedElements.get(i);
-                if (element.length >= outputItemLength)
+                if (element.length >= outputItemLength) {
                     bestFit = element;
-                else
+                } else {
                     break;
+                }
             }
             if (null == bestFit) {
                 // we couldn't place this item. overflow.
@@ -357,16 +363,18 @@ public class TiffImageWriterLossless ext
 
         @Override
         public void write(int b) throws IOException {
-            if (index >= buffer.length)
+            if (index >= buffer.length) {
                 throw new IOException("Buffer overflow.");
+            }
 
             buffer[index++] = (byte) b;
         }
 
         @Override
         public void write(byte b[], int off, int len) throws IOException {
-            if (index + len > buffer.length)
+            if (index + len > buffer.length) {
                 throw new IOException("Buffer overflow.");
+            }
             System.arraycopy(b, off, buffer, index, len);
             index += len;
         }
@@ -398,8 +406,9 @@ public class TiffImageWriterLossless ext
             TiffElement element = analysis.get(i);
             for (int j = 0; j < element.length; j++) {
                 int index = element.offset + j;
-                if (index < output.length)
+                if (index < output.length) {
                     output[index] = 0;
+                }
             }
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossy.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossy.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossy.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffImageWriterLossy.java Thu Sep 27 18:22:37 2012
@@ -77,8 +77,9 @@ public class TiffImageWriterLossy extend
             int length = outputItem.getItemLength();
 
             int remainder = imageDataPaddingLength(length);
-            for (int j = 0; j < remainder; j++)
+            for (int j = 0; j < remainder; j++) {
                 bos.write(0);
+            }
         }
 
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputDirectory.java Thu Sep 27 18:22:37 2012
@@ -420,8 +420,9 @@ public final class TiffOutputDirectory e
         List<TiffOutputField> matches = new ArrayList<TiffOutputField>();
         for (int i = 0; i < fields.size(); i++) {
             TiffOutputField field = fields.get(i);
-            if (field.tag == tag)
+            if (field.tag == tag) {
                 matches.add(field);
+            }
         }
         fields.removeAll(matches);
     }
@@ -433,8 +434,9 @@ public final class TiffOutputDirectory e
     public TiffOutputField findField(int tag) {
         for (int i = 0; i < fields.size(); i++) {
             TiffOutputField field = fields.get(i);
-            if (field.tag == tag)
+            if (field.tag == tag) {
                 return field;
+            }
         }
         return null;
     }
@@ -442,8 +444,9 @@ public final class TiffOutputDirectory e
     public void sortFields() {
         Comparator<TiffOutputField> comparator = new Comparator<TiffOutputField>() {
             public int compare(TiffOutputField e1, TiffOutputField e2) {
-                if (e1.tag != e2.tag)
+                if (e1.tag != e2.tag) {
                     return e1.tag - e2.tag;
+                }
                 return e1.getSortHint() - e2.getSortHint();
             }
         };
@@ -472,14 +475,16 @@ public final class TiffOutputDirectory e
         }
 
         int nextDirectoryOffset = 0;
-        if (nextDirectory != null)
+        if (nextDirectory != null) {
             nextDirectoryOffset = nextDirectory.getOffset();
+        }
 
         // Write nextDirectoryOffset
-        if (nextDirectoryOffset == UNDEFINED_VALUE)
+        if (nextDirectoryOffset == UNDEFINED_VALUE) {
             bos.write4Bytes(0);
-        else
+        } else {
             bos.write4Bytes(nextDirectoryOffset);
+        }
     }
 
     private JpegImageData jpegImageData = null;
@@ -517,8 +522,9 @@ public final class TiffOutputDirectory e
 
     private void removeFieldIfPresent(TagInfo tagInfo) {
         TiffOutputField field = findField(tagInfo);
-        if (null != field)
+        if (null != field) {
             fields.remove(field);
+        }
     }
 
     protected List<TiffOutputItem> getOutputItems(
@@ -614,8 +620,9 @@ public final class TiffOutputDirectory e
 
         for (int i = 0; i < fields.size(); i++) {
             TiffOutputField field = fields.get(i);
-            if (field.isLocalValue())
+            if (field.isLocalValue()) {
                 continue;
+            }
 
             TiffOutputItem item = field.getSeperateValue();
             result.add(item);
@@ -623,8 +630,9 @@ public final class TiffOutputDirectory e
         }
 
         if (null != imageDataInfo) {
-            for (int i = 0; i < imageDataInfo.outputItems.length; i++)
+            for (int i = 0; i < imageDataInfo.outputItems.length; i++) {
                 result.add(imageDataInfo.outputItems[i]);
+            }
 
             outputSummary.addTiffImageData(imageDataInfo);
         }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputField.java Thu Sep 27 18:22:37 2012
@@ -47,9 +47,9 @@ public class TiffOutputField implements 
         this.count = count;
         this.bytes = bytes;
 
-        if (isLocalValue())
+        if (isLocalValue()) {
             separateValueItem = null;
-        else {
+        } else {
             String name = "Field Seperate value (" + tagInfo.getDescription()
                     + ")";
             separateValueItem = new TiffOutputItem.Value(name, bytes);
@@ -71,19 +71,23 @@ public class TiffOutputField implements 
         bos.write4Bytes(count);
 
         if (isLocalValue()) {
-            if (separateValueItem != null)
+            if (separateValueItem != null) {
                 throw new ImageWriteException("Unexpected separate value item.");
-            if (bytes.length > 4)
+            }
+            if (bytes.length > 4) {
                 throw new ImageWriteException(
                         "Local value has invalid length: " + bytes.length);
+            }
 
             bos.writeByteArray(bytes);
             int remainder = TIFF_ENTRY_MAX_VALUE_LENGTH - bytes.length;
-            for (int i = 0; i < remainder; i++)
+            for (int i = 0; i < remainder; i++) {
                 bos.write(0);
+            }
         } else {
-            if (separateValueItem == null)
+            if (separateValueItem == null) {
                 throw new ImageWriteException("Missing separate value item.");
+            }
 
             bos.write4Bytes(separateValueItem.getOffset());
         }
@@ -102,13 +106,15 @@ public class TiffOutputField implements 
         // Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
         // + ") setData", bytes);
 
-        if (this.bytes.length != bytes.length)
+        if (this.bytes.length != bytes.length) {
             throw new ImageWriteException("Cannot change size of value.");
+        }
 
         // boolean wasLocalValue = isLocalValue();
         this.bytes = bytes;
-        if (separateValueItem != null)
+        if (separateValueItem != null) {
             separateValueItem.updateValue(bytes);
+        }
         // if (isLocalValue() != wasLocalValue)
         // throw new Error("Bug. Locality disrupted! "
         // + tagInfo.getDescription());
@@ -122,8 +128,9 @@ public class TiffOutputField implements 
     }
 
     public String toString(String prefix) {
-        if (prefix == null)
+        if (prefix == null) {
             prefix = "";
+        }
         StringBuilder result = new StringBuilder();
 
         result.append(prefix);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputItem.java Thu Sep 27 18:22:37 2012
@@ -62,9 +62,10 @@ abstract class TiffOutputItem implements
         }
 
         public void updateValue(byte bytes[]) throws ImageWriteException {
-            if (this.bytes.length != bytes.length)
+            if (this.bytes.length != bytes.length) {
                 throw new ImageWriteException("Updated data size mismatch: "
                         + this.bytes.length + " vs. " + bytes.length);
+            }
             System.arraycopy(bytes, 0, this.bytes, 0, bytes.length);
         }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSet.java Thu Sep 27 18:22:37 2012
@@ -54,9 +54,10 @@ public final class TiffOutputSet impleme
 
     public void addDirectory(TiffOutputDirectory directory)
             throws ImageWriteException {
-        if (null != findDirectory(directory.type))
+        if (null != findDirectory(directory.type)) {
             throw new ImageWriteException(
                     "Output set already contains a directory of that type.");
+        }
         directories.add(directory);
     }
 
@@ -75,8 +76,9 @@ public final class TiffOutputSet impleme
     public TiffOutputDirectory getOrCreateRootDirectory()
             throws ImageWriteException {
         TiffOutputDirectory result = findDirectory(DIRECTORY_TYPE_ROOT);
-        if (null != result)
+        if (null != result) {
             return result;
+        }
         return addRootDirectory();
     }
 
@@ -86,8 +88,9 @@ public final class TiffOutputSet impleme
         getOrCreateRootDirectory();
 
         TiffOutputDirectory result = findDirectory(DIRECTORY_TYPE_EXIF);
-        if (null != result)
+        if (null != result) {
             return result;
+        }
         return addExifDirectory();
     }
 
@@ -97,8 +100,9 @@ public final class TiffOutputSet impleme
         getOrCreateExifDirectory();
 
         TiffOutputDirectory result = findDirectory(DIRECTORY_TYPE_GPS);
-        if (null != result)
+        if (null != result) {
             return result;
+        }
         return addGPSDirectory();
     }
 
@@ -113,8 +117,9 @@ public final class TiffOutputSet impleme
     public TiffOutputDirectory findDirectory(int directoryType) {
         for (int i = 0; i < directories.size(); i++) {
             TiffOutputDirectory directory = directories.get(i);
-            if (directory.type == directoryType)
+            if (directory.type == directoryType) {
                 return directory;
+            }
         }
         return null;
     }
@@ -204,8 +209,9 @@ public final class TiffOutputSet impleme
         for (int i = 0; i < directories.size(); i++) {
             TiffOutputDirectory directory = directories.get(i);
             TiffOutputField field = directory.findField(tag);
-            if (null != field)
+            if (null != field) {
                 return field;
+            }
         }
         return null;
     }
@@ -249,8 +255,9 @@ public final class TiffOutputSet impleme
     }
 
     public String toString(String prefix) {
-        if (prefix == null)
+        if (prefix == null) {
             prefix = "";
+        }
 
         StringBuilder result = new StringBuilder();
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterGrayscale.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterGrayscale.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterGrayscale.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterGrayscale.java Thu Sep 27 18:22:37 2012
@@ -36,8 +36,9 @@ public class TransparencyFilterGrayscale
     @Override
     public int filter(int rgb, int index) throws ImageReadException,
             IOException {
-        if (index != transparent_color)
+        if (index != transparent_color) {
             return rgb;
+        }
         return 0x00;
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterIndexedColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterIndexedColor.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterIndexedColor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterIndexedColor.java Thu Sep 27 18:22:37 2012
@@ -31,13 +31,15 @@ public class TransparencyFilterIndexedCo
     @Override
     public int filter(int rgb, int index) throws ImageReadException,
             IOException {
-        if (index >= bytes.length)
+        if (index >= bytes.length) {
             return rgb;
+        }
 
-        if ((index < 0) || (index > bytes.length))
+        if ((index < 0) || (index > bytes.length)) {
             throw new ImageReadException(
                     "TransparencyFilterIndexedColor index: " + index
                             + ", bytes.length: " + bytes.length);
+        }
 
         int alpha = bytes[index];
         int result = ((0xff & alpha) << 24) | (0x00ffffff & rgb);

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterTrueColor.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterTrueColor.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterTrueColor.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilterTrueColor.java Thu Sep 27 18:22:37 2012
@@ -48,8 +48,9 @@ public class TransparencyFilterTrueColor
     @Override
     public int filter(int rgb, int sample) throws ImageReadException,
             IOException {
-        if ((0x00ffffff & rgb) == transparent_color)
+        if ((0x00ffffff & rgb) == transparent_color) {
             return 0x00;
+        }
 
         return rgb;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/wbmp/WbmpImageParser.java Thu Sep 27 18:22:37 2012
@@ -137,9 +137,10 @@ public class WbmpImageParser extends Ima
             value <<= 7;
             value |= nextByte & 0x7f;
             totalBits += 7;
-            if (totalBits > 31)
+            if (totalBits > 31) {
                 throw new ImageReadException(
                         "Overflow reading WBMP multi-byte field");
+            }
         } while ((nextByte & 0x80) != 0);
         return value;
     }
@@ -165,8 +166,9 @@ public class WbmpImageParser extends Ima
             return readWbmpHeader(is);
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -175,16 +177,18 @@ public class WbmpImageParser extends Ima
     private WbmpHeader readWbmpHeader(InputStream is)
             throws ImageReadException, IOException {
         int typeField = readMultiByteInteger(is);
-        if (typeField != 0)
+        if (typeField != 0) {
             throw new ImageReadException("Invalid/unsupported WBMP type "
                     + typeField);
+        }
 
         byte fixHeaderField = readByte("FixHeaderField", is,
                 "Invalid WBMP File");
-        if ((fixHeaderField & 0x9f) != 0)
+        if ((fixHeaderField & 0x9f) != 0) {
             throw new ImageReadException(
                     "Invalid/unsupported WBMP FixHeaderField 0x"
                             + Integer.toHexString(0xff & fixHeaderField));
+        }
 
         int width = readMultiByteInteger(is);
 
@@ -225,8 +229,9 @@ public class WbmpImageParser extends Ima
             return readImage(wbmpHeader, is);
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -239,8 +244,9 @@ public class WbmpImageParser extends Ima
         params = (params == null) ? new HashMap() : new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -261,8 +267,9 @@ public class WbmpImageParser extends Ima
                 int green = 0xff & (argb >> 8);
                 int blue = 0xff & (argb >> 0);
                 int sample = (red + green + blue) / 3;
-                if (sample > 127)
+                if (sample > 127) {
                     pixel |= nextBit;
+                }
                 nextBit >>>= 1;
                 if (nextBit == 0) {
                     os.write(pixel);
@@ -270,8 +277,9 @@ public class WbmpImageParser extends Ima
                     nextBit = 0x80;
                 }
             }
-            if (nextBit != 0x80)
+            if (nextBit != 0x80) {
                 os.write(pixel);
+            }
         }
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xbm/XbmImageParser.java Thu Sep 27 18:22:37 2012
@@ -159,19 +159,22 @@ public class XbmImageParser extends Imag
                     .iterator(); it.hasNext();) {
                 Map.Entry<String, String> entry = it.next();
                 String name = entry.getKey();
-                if (name.endsWith("_width"))
+                if (name.endsWith("_width")) {
                     width = Integer.parseInt(entry.getValue());
-                else if (name.endsWith("_height"))
+                } else if (name.endsWith("_height")) {
                     height = Integer.parseInt(entry.getValue());
-                else if (name.endsWith("_x_hot"))
+                } else if (name.endsWith("_x_hot")) {
                     xHot = Integer.parseInt(entry.getValue());
-                else if (name.endsWith("_y_hot"))
+                } else if (name.endsWith("_y_hot")) {
                     yHot = Integer.parseInt(entry.getValue());
+                }
             }
-            if (width == -1)
+            if (width == -1) {
                 throw new ImageReadException("width not found");
-            if (height == -1)
+            }
+            if (height == -1) {
                 throw new ImageReadException("height not found");
+            }
 
             XbmParseResult xbmParseResult = new XbmParseResult();
             xbmParseResult.cParser = new BasicCParser(new ByteArrayInputStream(
@@ -180,8 +183,9 @@ public class XbmImageParser extends Imag
             return xbmParseResult;
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -191,77 +195,93 @@ public class XbmImageParser extends Imag
             throws ImageReadException, IOException {
         String token;
         token = cParser.nextToken();
-        if (token == null || !token.equals("static"))
+        if (token == null || !token.equals("static")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no 'static' token");
+        }
         token = cParser.nextToken();
-        if (token == null)
+        if (token == null) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no 'unsigned' "
                             + "or 'char' token");
-        if (token.equals("unsigned"))
+        }
+        if (token.equals("unsigned")) {
             token = cParser.nextToken();
-        if (token == null || !token.equals("char"))
+        }
+        if (token == null || !token.equals("char")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no 'char' token");
+        }
         String name = cParser.nextToken();
-        if (name == null)
+        if (name == null) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no variable name");
-        if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0)))
+        }
+        if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0))) {
             throw new ImageReadException(
                     "Parsing XBM file failed, variable name "
                             + "doesn't start with letter or underscore");
+        }
         for (int i = 0; i < name.length(); i++) {
             char c = name.charAt(i);
-            if (!Character.isLetterOrDigit(c) && c != '_')
+            if (!Character.isLetterOrDigit(c) && c != '_') {
                 throw new ImageReadException(
                         "Parsing XBM file failed, variable name "
                                 + "contains non-letter non-digit non-underscore");
+            }
         }
         token = cParser.nextToken();
-        if (token == null || !token.equals("["))
+        if (token == null || !token.equals("[")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no '[' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("]"))
+        if (token == null || !token.equals("]")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no ']' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("="))
+        if (token == null || !token.equals("=")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no '=' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("{"))
+        if (token == null || !token.equals("{")) {
             throw new ImageReadException(
                     "Parsing XBM file failed, no '{' token");
+        }
 
         int rowLength = (xbmHeader.width + 7) / 8;
         byte[] imageData = new byte[rowLength * xbmHeader.height];
         for (int i = 0; i < imageData.length; i++) {
             token = cParser.nextToken();
-            if (token == null || !token.startsWith("0x"))
+            if (token == null || !token.startsWith("0x")) {
                 throw new ImageReadException("Parsing XBM file failed, "
                         + "hex value missing");
-            if (token.length() > 4)
+            }
+            if (token.length() > 4) {
                 throw new ImageReadException("Parsing XBM file failed, "
                         + "hex value too long");
+            }
             int value = Integer.parseInt(token.substring(2), 16);
             int flipped = 0;
             for (int j = 0; j < 8; j++) {
-                if ((value & (1 << j)) != 0)
+                if ((value & (1 << j)) != 0) {
                     flipped |= (0x80 >>> j);
+                }
             }
             imageData[i] = (byte) flipped;
 
             token = cParser.nextToken();
-            if (token == null)
+            if (token == null) {
                 throw new ImageReadException("Parsing XBM file failed, "
                         + "premature end of file");
+            }
             if (!token.equals(",")
-                    && (i < (imageData.length - 1) || !token.equals("}")))
+                    && (i < (imageData.length - 1) || !token.equals("}"))) {
                 throw new ImageReadException("Parsing XBM file failed, "
                         + "punctuation error");
+            }
         }
 
         int[] palette = { 0xffffff, 0x000000 };
@@ -295,20 +315,23 @@ public class XbmImageParser extends Imag
         StringBuilder stringBuilder = new StringBuilder("a");
         long bits = uuid.getMostSignificantBits();
         // Long.toHexString() breaks for very big numbers
-        for (int i = 64 - 8; i >= 0; i -= 8)
+        for (int i = 64 - 8; i >= 0; i -= 8) {
             stringBuilder.append(Integer
                     .toHexString((int) ((bits >> i) & 0xff)));
+        }
         bits = uuid.getLeastSignificantBits();
-        for (int i = 64 - 8; i >= 0; i -= 8)
+        for (int i = 64 - 8; i >= 0; i -= 8) {
             stringBuilder.append(Integer
                     .toHexString((int) ((bits >> i) & 0xff)));
+        }
         return stringBuilder.toString();
     }
 
     private String toPrettyHex(int value) {
         String s = Integer.toHexString(0xff & value);
-        if (s.length() == 2)
+        if (s.length() == 2) {
             return "0x" + s;
+        }
         return "0x0" + s;
     }
 
@@ -319,8 +342,9 @@ public class XbmImageParser extends Imag
         params = (params == null) ? new HashMap() : new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -347,10 +371,11 @@ public class XbmImageParser extends Imag
                 int green = 0xff & (argb >> 8);
                 int blue = 0xff & (argb >> 0);
                 int sample = (red + green + blue) / 3;
-                if (sample > 127)
+                if (sample > 127) {
                     sample = 0;
-                else
+                } else {
                     sample = 1;
+                }
                 bitcache |= (sample << bits_in_cache);
                 ++bits_in_cache;
                 if (bits_in_cache == 8) {

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1391156&r1=1391155&r2=1391156&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java Thu Sep 27 18:22:37 2012
@@ -58,8 +58,9 @@ public class XpmImageParser extends Imag
     }
 
     private synchronized static boolean loadColorNames() {
-        if (colorNames != null)
+        if (colorNames != null) {
             return true;
+        }
 
         BufferedReader reader = null;
         try {
@@ -73,8 +74,9 @@ public class XpmImageParser extends Imag
             Map<String, Integer> colors = new HashMap<String, Integer>();
             String line;
             while ((line = reader.readLine()) != null) {
-                if (line.startsWith("!"))
+                if (line.startsWith("!")) {
                     continue;
+                }
                 try {
                     int red = Integer.parseInt(line.substring(0, 3).trim());
                     int green = Integer.parseInt(line.substring(4, 7).trim());
@@ -92,8 +94,9 @@ public class XpmImageParser extends Imag
             return false;
         } finally {
             try {
-                if (reader != null)
+                if (reader != null) {
                     reader.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -144,13 +147,15 @@ public class XpmImageParser extends Imag
                 .entrySet().iterator(); it.hasNext();) {
             Map.Entry<Object, PaletteEntry> entry = it.next();
             PaletteEntry paletteEntry = entry.getValue();
-            if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000)
+            if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000) {
                 isTransparent = true;
-            if (paletteEntry.haveColor)
+            }
+            if (paletteEntry.haveColor) {
                 colorType = ImageInfo.COLOR_TYPE_RGB;
-            else if (colorType != ImageInfo.COLOR_TYPE_RGB
-                    && (paletteEntry.haveGray || paletteEntry.haveGray4Level))
+            } else if (colorType != ImageInfo.COLOR_TYPE_RGB
+                    && (paletteEntry.haveGray || paletteEntry.haveGray4Level)) {
                 colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
+            }
         }
         return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
                 new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XPM,
@@ -221,16 +226,17 @@ public class XpmImageParser extends Imag
         String symbolicName = null;
 
         int getBestARGB() {
-            if (haveColor)
+            if (haveColor) {
                 return colorArgb;
-            else if (haveGray)
+            } else if (haveGray) {
                 return grayArgb;
-            else if (haveGray4Level)
+            } else if (haveGray4Level) {
                 return gray4LevelArgb;
-            else if (haveMono)
+            } else if (haveMono) {
                 return monoArgb;
-            else
+            } else {
                 return 0x00000000;
+            }
         }
     }
 
@@ -253,9 +259,10 @@ public class XpmImageParser extends Imag
             StringBuilder firstComment = new StringBuilder();
             ByteArrayOutputStream preprocessedFile = BasicCParser.preprocess(
                     is, firstComment, null);
-            if (!firstComment.toString().trim().equals("XPM"))
+            if (!firstComment.toString().trim().equals("XPM")) {
                 throw new ImageReadException("Parsing XPM file failed, "
                         + "signature isn't '/* XPM */'");
+            }
 
             XpmParseResult xpmParseResult = new XpmParseResult();
             xpmParseResult.cParser = new BasicCParser(new ByteArrayInputStream(
@@ -264,8 +271,9 @@ public class XpmImageParser extends Imag
             return xpmParseResult;
         } finally {
             try {
-                if (is != null)
+                if (is != null) {
                     is.close();
+                }
             } catch (IOException ignored) {
             }
         }
@@ -275,29 +283,32 @@ public class XpmImageParser extends Imag
             StringBuilder stringBuilder) throws IOException, ImageReadException {
         stringBuilder.setLength(0);
         String token = cParser.nextToken();
-        if (token.charAt(0) != '"')
+        if (token.charAt(0) != '"') {
             throw new ImageReadException("Parsing XPM file failed, "
                     + "no string found where expected");
+        }
         BasicCParser.unescapeString(stringBuilder, token);
         for (token = cParser.nextToken(); token.charAt(0) == '"'; token = cParser
                 .nextToken()) {
             BasicCParser.unescapeString(stringBuilder, token);
         }
-        if (token.equals(","))
+        if (token.equals(",")) {
             return true;
-        else if (token.equals("}"))
+        } else if (token.equals("}")) {
             return false;
-        else
+        } else {
             throw new ImageReadException("Parsing XPM file failed, "
                     + "no ',' or '}' found where expected");
+        }
     }
 
     private XpmHeader parseXpmValuesSection(String row)
             throws ImageReadException {
         String[] tokens = BasicCParser.tokenizeRow(row);
-        if (tokens.length < 4 && tokens.length > 7)
+        if (tokens.length < 4 && tokens.length > 7) {
             throw new ImageReadException("Parsing XPM file failed, "
                     + "<Values> section has incorrect tokens");
+        }
         try {
             int width = Integer.parseInt(tokens[0]);
             int height = Integer.parseInt(tokens[1]);
@@ -311,11 +322,12 @@ public class XpmImageParser extends Imag
                 yHotSpot = Integer.parseInt(tokens[5]);
             }
             if (tokens.length == 5 || tokens.length == 7) {
-                if (tokens[tokens.length - 1].equals("XPMEXT"))
+                if (tokens[tokens.length - 1].equals("XPMEXT")) {
                     xpmExt = true;
-                else
+                } else {
                     throw new ImageReadException("Parsing XPM file failed, "
                             + "can't parse <Values> section XPMEXT");
+                }
             }
             return new XpmHeader(width, height, numColors, numCharsPerPixel,
                     xHotSpot, yHotSpot, xpmExt);
@@ -333,9 +345,9 @@ public class XpmImageParser extends Imag
                 int green = Integer.parseInt(color.substring(1, 2), 16);
                 int blue = Integer.parseInt(color.substring(2, 3), 16);
                 return 0xff000000 | (red << 20) | (green << 12) | (blue << 4);
-            } else if (color.length() == 6)
+            } else if (color.length() == 6) {
                 return 0xff000000 | Integer.parseInt(color, 16);
-            else if (color.length() == 9) {
+            } else if (color.length() == 9) {
                 int red = Integer.parseInt(color.substring(0, 1), 16);
                 int green = Integer.parseInt(color.substring(3, 4), 16);
                 int blue = Integer.parseInt(color.substring(6, 7), 16);
@@ -345,20 +357,23 @@ public class XpmImageParser extends Imag
                 int green = Integer.parseInt(color.substring(4, 5), 16);
                 int blue = Integer.parseInt(color.substring(8, 9), 16);
                 return 0xff000000 | (red << 16) | (green << 8) | blue;
-            } else
+            } else {
                 return 0x00000000;
+            }
         } else if (color.charAt(0) == '%') {
             throw new ImageReadException("HSV colors are not implemented "
                     + "even in the XPM specification!");
-        } else if (color.equals("None"))
+        } else if (color.equals("None")) {
             return 0x00000000;
-        else {
-            if (!loadColorNames())
+        } else {
+            if (!loadColorNames()) {
                 return 0x00000000;
-            if (colorNames.containsKey(color))
+            }
+            if (colorNames.containsKey(color)) {
                 return (colorNames.get(color)).intValue();
-            else
+            } else {
                 return 0x00000000;
+            }
         }
     }
 
@@ -368,9 +383,10 @@ public class XpmImageParser extends Imag
         for (int i = 0; i < xpmHeader.numColors; i++) {
             row.setLength(0);
             boolean hasMore = parseNextString(cParser, row);
-            if (!hasMore)
+            if (!hasMore) {
                 throw new ImageReadException("Parsing XPM file failed, "
                         + "file ended while reading palette");
+            }
             String name = row.substring(0, xpmHeader.numCharsPerPixel);
             String[] tokens = BasicCParser.tokenizeRow(row
                     .substring(xpmHeader.numCharsPerPixel));
@@ -412,10 +428,12 @@ public class XpmImageParser extends Imag
                     }
                     previousKeyIndex = j;
                 } else {
-                    if (previousKeyIndex < 0)
+                    if (previousKeyIndex < 0) {
                         break;
-                    if (colorBuffer.length() > 0)
+                    }
+                    if (colorBuffer.length() > 0) {
                         colorBuffer.append(' ');
+                    }
                     colorBuffer.append(token);
                 }
             }
@@ -450,54 +468,65 @@ public class XpmImageParser extends Imag
         String name;
         String token;
         token = cParser.nextToken();
-        if (token == null || !token.equals("static"))
+        if (token == null || !token.equals("static")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no 'static' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("char"))
+        if (token == null || !token.equals("char")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no 'char' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("*"))
+        if (token == null || !token.equals("*")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no '*' token");
+        }
         name = cParser.nextToken();
-        if (name == null)
+        if (name == null) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no variable name");
-        if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0)))
+        }
+        if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0))) {
             throw new ImageReadException(
                     "Parsing XPM file failed, variable name "
                             + "doesn't start with letter or underscore");
+        }
         for (int i = 0; i < name.length(); i++) {
             char c = name.charAt(i);
-            if (!Character.isLetterOrDigit(c) && c != '_')
+            if (!Character.isLetterOrDigit(c) && c != '_') {
                 throw new ImageReadException(
                         "Parsing XPM file failed, variable name "
                                 + "contains non-letter non-digit non-underscore");
+            }
         }
         token = cParser.nextToken();
-        if (token == null || !token.equals("["))
+        if (token == null || !token.equals("[")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no '[' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("]"))
+        if (token == null || !token.equals("]")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no ']' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("="))
+        if (token == null || !token.equals("=")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no '=' token");
+        }
         token = cParser.nextToken();
-        if (token == null || !token.equals("{"))
+        if (token == null || !token.equals("{")) {
             throw new ImageReadException(
                     "Parsing XPM file failed, no '{' token");
+        }
 
         StringBuilder row = new StringBuilder();
         boolean hasMore = parseNextString(cParser, row);
-        if (!hasMore)
+        if (!hasMore) {
             throw new ImageReadException("Parsing XPM file failed, "
                     + "file too short");
+        }
         XpmHeader xpmHeader = parseXpmValuesSection(row.toString());
         parsePaletteEntries(xpmHeader, cParser);
         return xpmHeader;
@@ -553,9 +582,10 @@ public class XpmImageParser extends Imag
         for (int y = 0; y < xpmHeader.height; y++) {
             row.setLength(0);
             hasMore = parseNextString(cParser, row);
-            if (y < (xpmHeader.height - 1) && !hasMore)
+            if (y < (xpmHeader.height - 1) && !hasMore) {
                 throw new ImageReadException("Parsing XPM file failed, "
                         + "insufficient image rows in file");
+            }
             int rowOffset = y * xpmHeader.width;
             for (int x = 0; x < xpmHeader.width; x++) {
                 String index = row.substring(x * xpmHeader.numCharsPerPixel,
@@ -565,11 +595,12 @@ public class XpmImageParser extends Imag
                     throw new ImageReadException(
                             "No palette entry was defined " + "for " + index);
                 }
-                if (bpp <= 16)
+                if (bpp <= 16) {
                     dataBuffer.setElem(rowOffset + x, paletteEntry.index);
-                else
+                } else {
                     dataBuffer.setElem(rowOffset + x,
                             paletteEntry.getBestARGB());
+                }
             }
         }
 
@@ -579,8 +610,9 @@ public class XpmImageParser extends Imag
         }
 
         String token = cParser.nextToken();
-        if (!token.equals(";"))
+        if (!token.equals(";")) {
             throw new ImageReadException("Last token wasn't ';'");
+        }
 
         return image;
     }
@@ -604,21 +636,22 @@ public class XpmImageParser extends Imag
         StringBuilder stringBuilder = new StringBuilder("a");
         long bits = uuid.getMostSignificantBits();
         // Long.toHexString() breaks for very big numbers
-        for (int i = 64 - 8; i >= 0; i -= 8)
-            stringBuilder.append(Integer
-                    .toHexString((int) ((bits >> i) & 0xff)));
+        for (int i = 64 - 8; i >= 0; i -= 8) {
+            stringBuilder.append(Integer.toHexString((int) ((bits >> i) & 0xff)));
+        }
         bits = uuid.getLeastSignificantBits();
-        for (int i = 64 - 8; i >= 0; i -= 8)
-            stringBuilder.append(Integer
-                    .toHexString((int) ((bits >> i) & 0xff)));
+        for (int i = 64 - 8; i >= 0; i -= 8) {
+            stringBuilder.append(Integer.toHexString((int) ((bits >> i) & 0xff)));
+        }
         return stringBuilder.toString();
     }
 
     private String pixelsForIndex(int index, int charsPerPixel) {
         StringBuilder stringBuilder = new StringBuilder();
         int highestPower = 1;
-        for (int i = 1; i < charsPerPixel; i++)
+        for (int i = 1; i < charsPerPixel; i++) {
             highestPower *= writePalette.length;
+        }
         for (int i = 0; i < charsPerPixel; i++) {
             int multiple = index / highestPower;
             index -= (multiple * highestPower);
@@ -634,8 +667,9 @@ public class XpmImageParser extends Imag
             char zeroes[] = new char[6 - hex.length()];
             Arrays.fill(zeroes, '0');
             return "#" + new String(zeroes) + hex;
-        } else
+        } else {
             return "#" + hex;
+        }
     }
 
     @Override
@@ -645,8 +679,9 @@ public class XpmImageParser extends Imag
         params = (params == null) ? new HashMap() : new HashMap(params);
 
         // clear format key.
-        if (params.containsKey(PARAM_KEY_FORMAT))
+        if (params.containsKey(PARAM_KEY_FORMAT)) {
             params.remove(PARAM_KEY_FORMAT);
+        }
 
         if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
@@ -655,8 +690,9 @@ public class XpmImageParser extends Imag
 
         PaletteFactory paletteFactory = new PaletteFactory();
         boolean hasTransparency = false;
-        if (paletteFactory.hasTransparency(src, 1))
+        if (paletteFactory.hasTransparency(src, 1)) {
             hasTransparency = true;
+        }
         SimplePalette palette = null;
         int maxColors = writePalette.length;
         int charsPerPixel = 1;
@@ -669,8 +705,9 @@ public class XpmImageParser extends Imag
             }
         }
         int colors = palette.length();
-        if (hasTransparency)
+        if (hasTransparency) {
             ++colors;
+        }
 
         String line = "/* XPM */\n";
         os.write(line.getBytes("US-ASCII"));
@@ -682,10 +719,11 @@ public class XpmImageParser extends Imag
 
         for (int i = 0; i < colors; i++) {
             String color;
-            if (i < palette.length())
+            if (i < palette.length()) {
                 color = toColor(palette.getEntry(i));
-            else
+            } else {
                 color = "None";
+            }
             line = "\"" + pixelsForIndex(i, charsPerPixel) + " c " + color
                     + "\",\n";
             os.write(line.getBytes("US-ASCII"));
@@ -699,12 +737,13 @@ public class XpmImageParser extends Imag
             os.write(line.getBytes("US-ASCII"));
             for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
-                if ((argb & 0xff000000) == 0)
+                if ((argb & 0xff000000) == 0) {
                     line = pixelsForIndex(palette.length(), charsPerPixel);
-                else
+                } else {
                     line = pixelsForIndex(
                             palette.getPaletteIndex(0xffffff & argb),
                             charsPerPixel);
+                }
                 os.write(line.getBytes("US-ASCII"));
             }
             line = "\"";