commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1342971 [14/20] - in /commons/proper/imaging/trunk/src: main/java/org/apache/commons/imaging/formats/bmp/ main/java/org/apache/commons/imaging/formats/bmp/pixelparsers/ main/java/org/apache/commons/imaging/formats/bmp/writers/ main/java/or...
Date Sat, 26 May 2012 21:19:22 GMT
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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -24,8 +24,7 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.fieldtypes.FieldType;
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
 
-public class TiffOutputField implements TiffConstants
-{
+public class TiffOutputField implements TiffConstants {
     public final int tag;
     public final TagInfo tagInfo;
     public final FieldType fieldType;
@@ -36,14 +35,12 @@ public class TiffOutputField implements 
     private final TiffOutputItem.Value separateValueItem;
 
     public TiffOutputField(TagInfo tagInfo, FieldType tagtype, int count,
-            byte bytes[])
-    {
+            byte bytes[]) {
         this(tagInfo.tag, tagInfo, tagtype, count, bytes);
     }
 
     public TiffOutputField(final int tag, TagInfo tagInfo, FieldType fieldType,
-            int count, byte bytes[])
-    {
+            int count, byte bytes[]) {
         this.tag = tag;
         this.tagInfo = tagInfo;
         this.fieldType = fieldType;
@@ -52,8 +49,7 @@ public class TiffOutputField implements 
 
         if (isLocalValue())
             separateValueItem = null;
-        else
-        {
+        else {
             String name = "Field Seperate value (" + tagInfo.getDescription()
                     + ")";
             separateValueItem = new TiffOutputItem.Value(name, bytes);
@@ -63,21 +59,18 @@ public class TiffOutputField implements 
     private int sortHint = -1;
 
     protected static final TiffOutputField createOffsetField(TagInfo tagInfo,
-            int byteOrder) throws ImageWriteException
-    {
-        return new TiffOutputField(tagInfo, FIELD_TYPE_LONG, 1, FIELD_TYPE_LONG
-                .writeData(new int[] { 0, }, byteOrder));
+            int byteOrder) throws ImageWriteException {
+        return new TiffOutputField(tagInfo, FIELD_TYPE_LONG, 1,
+                FIELD_TYPE_LONG.writeData(new int[] { 0, }, byteOrder));
     }
 
     protected void writeField(BinaryOutputStream bos) throws IOException,
-            ImageWriteException
-    {
+            ImageWriteException {
         bos.write2Bytes(tag);
         bos.write2Bytes(fieldType.type);
         bos.write4Bytes(count);
 
-        if (isLocalValue())
-        {
+        if (isLocalValue()) {
             if (separateValueItem != null)
                 throw new ImageWriteException("Unexpected separate value item.");
             if (bytes.length > 4)
@@ -88,8 +81,7 @@ public class TiffOutputField implements 
             int remainder = TIFF_ENTRY_MAX_VALUE_LENGTH - bytes.length;
             for (int i = 0; i < remainder; i++)
                 bos.write(0);
-        } else
-        {
+        } else {
             if (separateValueItem == null)
                 throw new ImageWriteException("Missing separate value item.");
 
@@ -97,18 +89,15 @@ public class TiffOutputField implements 
         }
     }
 
-    protected TiffOutputItem getSeperateValue()
-    {
+    protected TiffOutputItem getSeperateValue() {
         return separateValueItem;
     }
 
-    protected boolean isLocalValue()
-    {
+    protected boolean isLocalValue() {
         return bytes.length <= TIFF_ENTRY_MAX_VALUE_LENGTH;
     }
 
-    protected void setData(byte bytes[]) throws ImageWriteException
-    {
+    protected void setData(byte bytes[]) throws ImageWriteException {
         // if(tagInfo.isUnknown())
         // Debug.debug("unknown tag(0x" + Integer.toHexString(tag)
         // + ") setData", bytes);
@@ -128,13 +117,11 @@ public class TiffOutputField implements 
     private static final String newline = System.getProperty("line.separator");
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return toString(null);
     }
 
-    public String toString(String prefix)
-    {
+    public String toString(String prefix) {
         if (prefix == null)
             prefix = "";
         StringBuffer result = new StringBuffer();
@@ -154,13 +141,11 @@ public class TiffOutputField implements 
         return result.toString();
     }
 
-    public int getSortHint()
-    {
+    public int getSortHint() {
         return sortHint;
     }
 
-    public void setSortHint(int sortHint)
-    {
+    public void setSortHint(int sortHint) {
         this.sortHint = sortHint;
     }
 }

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -22,19 +22,16 @@ import org.apache.commons.imaging.ImageW
 import org.apache.commons.imaging.common.BinaryOutputStream;
 import org.apache.commons.imaging.formats.tiff.constants.AllTagConstants;
 
-abstract class TiffOutputItem implements AllTagConstants
-{
+abstract class TiffOutputItem implements AllTagConstants {
     public static final int UNDEFINED_VALUE = -1;
 
     private int offset = UNDEFINED_VALUE;
 
-    protected int getOffset()
-    {
+    protected int getOffset() {
         return offset;
     }
 
-    protected void setOffset(int offset)
-    {
+    protected void setOffset(int offset) {
         this.offset = offset;
     }
 
@@ -45,31 +42,26 @@ abstract class TiffOutputItem implements
     public abstract void writeItem(BinaryOutputStream bos) throws IOException,
             ImageWriteException;
 
-    public static class Value extends TiffOutputItem
-    {
+    public static class Value extends TiffOutputItem {
         private final byte bytes[];
         private final String name;
 
-        public Value(final String name, final byte[] bytes)
-        {
+        public Value(final String name, final byte[] bytes) {
             this.name = name;
             this.bytes = bytes;
         }
 
         @Override
-        public int getItemLength()
-        {
+        public int getItemLength() {
             return bytes.length;
         }
 
         @Override
-        public String getItemDescription()
-        {
+        public String getItemDescription() {
             return name;
         }
 
-        public void updateValue(byte bytes[]) throws ImageWriteException
-        {
+        public void updateValue(byte bytes[]) throws ImageWriteException {
             if (this.bytes.length != bytes.length)
                 throw new ImageWriteException("Updated data size mismatch: "
                         + this.bytes.length + " vs. " + bytes.length);
@@ -78,9 +70,8 @@ abstract class TiffOutputItem implements
 
         @Override
         public void writeItem(BinaryOutputStream bos) throws IOException,
-                ImageWriteException
-        {
+                ImageWriteException {
             bos.write(bytes);
         }
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -26,31 +26,25 @@ import org.apache.commons.imaging.format
 import org.apache.commons.imaging.formats.tiff.taginfos.TagInfo;
 import org.apache.commons.imaging.util.Debug;
 
-public final class TiffOutputSet implements TiffConstants
-{
+public final class TiffOutputSet implements TiffConstants {
     public final int byteOrder;
     private final List<TiffOutputDirectory> directories = new ArrayList<TiffOutputDirectory>();
 
-    public TiffOutputSet()
-    {
+    public TiffOutputSet() {
         this(TiffConstants.DEFAULT_TIFF_BYTE_ORDER);
     }
 
-    public TiffOutputSet(final int byteOrder)
-    {
+    public TiffOutputSet(final int byteOrder) {
         super();
         this.byteOrder = byteOrder;
     }
 
-    protected List<TiffOutputItem> getOutputItems(TiffOutputSummary outputSummary)
-            throws ImageWriteException
-    {
+    protected List<TiffOutputItem> getOutputItems(
+            TiffOutputSummary outputSummary) throws ImageWriteException {
         List<TiffOutputItem> result = new ArrayList<TiffOutputItem>();
 
-        for (int i = 0; i < directories.size(); i++)
-        {
-            TiffOutputDirectory directory = directories
-                    .get(i);
+        for (int i = 0; i < directories.size(); i++) {
+            TiffOutputDirectory directory = directories.get(i);
 
             result.addAll(directory.getOutputItems(outputSummary));
         }
@@ -59,32 +53,27 @@ public final class TiffOutputSet impleme
     }
 
     public void addDirectory(TiffOutputDirectory directory)
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         if (null != findDirectory(directory.type))
             throw new ImageWriteException(
                     "Output set already contains a directory of that type.");
         directories.add(directory);
     }
 
-    public List<TiffOutputDirectory> getDirectories()
-    {
+    public List<TiffOutputDirectory> getDirectories() {
         return new ArrayList<TiffOutputDirectory>(directories);
     }
 
-    public TiffOutputDirectory getRootDirectory()
-    {
+    public TiffOutputDirectory getRootDirectory() {
         return findDirectory(DIRECTORY_TYPE_ROOT);
     }
 
-    public TiffOutputDirectory getExifDirectory()
-    {
+    public TiffOutputDirectory getExifDirectory() {
         return findDirectory(DIRECTORY_TYPE_EXIF);
     }
 
     public TiffOutputDirectory getOrCreateRootDirectory()
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         TiffOutputDirectory result = findDirectory(DIRECTORY_TYPE_ROOT);
         if (null != result)
             return result;
@@ -92,8 +81,7 @@ public final class TiffOutputSet impleme
     }
 
     public TiffOutputDirectory getOrCreateExifDirectory()
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         // EXIF directory requires root directory.
         getOrCreateRootDirectory();
 
@@ -104,8 +92,7 @@ public final class TiffOutputSet impleme
     }
 
     public TiffOutputDirectory getOrCreateGPSDirectory()
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         // GPS directory requires EXIF directory
         getOrCreateExifDirectory();
 
@@ -115,22 +102,17 @@ public final class TiffOutputSet impleme
         return addGPSDirectory();
     }
 
-    public TiffOutputDirectory getGPSDirectory()
-    {
+    public TiffOutputDirectory getGPSDirectory() {
         return findDirectory(DIRECTORY_TYPE_GPS);
     }
 
-    public TiffOutputDirectory getInteroperabilityDirectory()
-    {
+    public TiffOutputDirectory getInteroperabilityDirectory() {
         return findDirectory(DIRECTORY_TYPE_INTEROPERABILITY);
     }
 
-    public TiffOutputDirectory findDirectory(int directoryType)
-    {
-        for (int i = 0; i < directories.size(); i++)
-        {
-            TiffOutputDirectory directory = directories
-                    .get(i);
+    public TiffOutputDirectory findDirectory(int directoryType) {
+        for (int i = 0; i < directories.size(); i++) {
+            TiffOutputDirectory directory = directories.get(i);
             if (directory.type == directoryType)
                 return directory;
         }
@@ -139,14 +121,15 @@ public final class TiffOutputSet impleme
 
     /**
      * A convenience method to update GPS values in EXIF metadata.
-     *
-     * @param longitude Longitude in degrees E, negative values are W.
-     * @param latitude latitude in degrees N, negative values are S.
+     * 
+     * @param longitude
+     *            Longitude in degrees E, negative values are W.
+     * @param latitude
+     *            latitude in degrees N, negative values are S.
      * @throws ImageWriteException
      */
     public void setGPSInDegrees(double longitude, double latitude)
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         TiffOutputDirectory gpsDirectory = getOrCreateGPSDirectory();
 
         String longitudeRef = longitude < 0 ? "W" : "E";
@@ -155,11 +138,12 @@ public final class TiffOutputSet impleme
         latitude = Math.abs(latitude);
 
         gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE_REF);
-        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF, longitudeRef);
+        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE_REF,
+                longitudeRef);
 
         gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_LATITUDE_REF);
-        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF, latitudeRef);
-
+        gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DEST_LATITUDE_REF,
+                latitudeRef);
 
         {
             double value = longitude;
@@ -172,10 +156,14 @@ public final class TiffOutputSet impleme
             double longitudeSeconds = value;
 
             gpsDirectory.removeField(GpsTagConstants.GPS_TAG_GPS_LONGITUDE);
-            gpsDirectory.add(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE,
-                    RationalNumberUtilities.getRationalNumber(longitudeDegrees),
-                    RationalNumberUtilities.getRationalNumber(longitudeMinutes),
-                    RationalNumberUtilities.getRationalNumber(longitudeSeconds));
+            gpsDirectory
+                    .add(GpsTagConstants.GPS_TAG_GPS_DEST_LONGITUDE,
+                            RationalNumberUtilities
+                                    .getRationalNumber(longitudeDegrees),
+                            RationalNumberUtilities
+                                    .getRationalNumber(longitudeMinutes),
+                            RationalNumberUtilities
+                                    .getRationalNumber(longitudeSeconds));
         }
 
         {
@@ -197,32 +185,24 @@ public final class TiffOutputSet impleme
 
     }
 
-    public void removeField(TagInfo tagInfo)
-    {
+    public void removeField(TagInfo tagInfo) {
         removeField(tagInfo.tag);
     }
 
-    public void removeField(int tag)
-    {
-        for (int i = 0; i < directories.size(); i++)
-        {
-            TiffOutputDirectory directory = directories
-                    .get(i);
+    public void removeField(int tag) {
+        for (int i = 0; i < directories.size(); i++) {
+            TiffOutputDirectory directory = directories.get(i);
             directory.removeField(tag);
         }
     }
 
-    public TiffOutputField findField(TagInfo tagInfo)
-    {
+    public TiffOutputField findField(TagInfo tagInfo) {
         return findField(tagInfo.tag);
     }
 
-    public TiffOutputField findField(int tag)
-    {
-        for (int i = 0; i < directories.size(); i++)
-        {
-            TiffOutputDirectory directory = directories
-                    .get(i);
+    public TiffOutputField findField(int tag) {
+        for (int i = 0; i < directories.size(); i++) {
+            TiffOutputDirectory directory = directories.get(i);
             TiffOutputField field = directory.findField(tag);
             if (null != field)
                 return field;
@@ -230,32 +210,29 @@ public final class TiffOutputSet impleme
         return null;
     }
 
-    public TiffOutputDirectory addRootDirectory() throws ImageWriteException
-    {
+    public TiffOutputDirectory addRootDirectory() throws ImageWriteException {
         TiffOutputDirectory result = new TiffOutputDirectory(
                 DIRECTORY_TYPE_ROOT, byteOrder);
         addDirectory(result);
         return result;
     }
 
-    public TiffOutputDirectory addExifDirectory() throws ImageWriteException
-    {
+    public TiffOutputDirectory addExifDirectory() throws ImageWriteException {
         TiffOutputDirectory result = new TiffOutputDirectory(
                 DIRECTORY_TYPE_EXIF, byteOrder);
         addDirectory(result);
         return result;
     }
 
-    public TiffOutputDirectory addGPSDirectory() throws ImageWriteException
-    {
-        TiffOutputDirectory result = new TiffOutputDirectory(DIRECTORY_TYPE_GPS, byteOrder);
+    public TiffOutputDirectory addGPSDirectory() throws ImageWriteException {
+        TiffOutputDirectory result = new TiffOutputDirectory(
+                DIRECTORY_TYPE_GPS, byteOrder);
         addDirectory(result);
         return result;
     }
 
     public TiffOutputDirectory addInteroperabilityDirectory()
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         getOrCreateExifDirectory();
 
         TiffOutputDirectory result = new TiffOutputDirectory(
@@ -267,13 +244,11 @@ public final class TiffOutputSet impleme
     private static final String newline = System.getProperty("line.separator");
 
     @Override
-    public String toString()
-    {
+    public String toString() {
         return toString(null);
     }
 
-    public String toString(String prefix)
-    {
+    public String toString(String prefix) {
         if (prefix == null)
             prefix = "";
 
@@ -287,18 +262,15 @@ public final class TiffOutputSet impleme
         result.append("byteOrder: " + byteOrder);
         result.append(newline);
 
-        for (int i = 0; i < directories.size(); i++)
-        {
-            TiffOutputDirectory directory = directories
-                    .get(i);
+        for (int i = 0; i < directories.size(); i++) {
+            TiffOutputDirectory directory = directories.get(i);
             result.append(prefix);
             result.append("\t" + "directory " + i + ": "
                     + directory.description() + " (" + directory.type + ")");
             result.append(newline);
 
             List<TiffOutputField> fields = directory.getFields();
-            for (int j = 0; j < fields.size(); j++)
-            {
+            for (int j = 0; j < fields.size(); j++) {
                 TiffOutputField field = fields.get(j);
                 result.append(prefix);
                 result.append("\t\t" + "field " + i + ": " + field.tagInfo);
@@ -313,9 +285,8 @@ public final class TiffOutputSet impleme
         return result.toString();
     }
 
-    public void dump()
-    {
+    public void dump() {
         Debug.debug(this.toString());
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/tiff/write/TiffOutputSummary.java Sat May 26 21:19:03 2012
@@ -23,28 +23,25 @@ import java.util.Map;
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.formats.tiff.constants.TiffConstants;
 
-class TiffOutputSummary implements TiffConstants
-{
+class TiffOutputSummary implements TiffConstants {
     public final int byteOrder;
     public final TiffOutputDirectory rootDirectory;
     public final Map<Integer, TiffOutputDirectory> directoryTypeMap;
 
     public TiffOutputSummary(final int byteOrder,
-            final TiffOutputDirectory rootDirectory, final Map<Integer, TiffOutputDirectory> directoryTypeMap)
-    {
+            final TiffOutputDirectory rootDirectory,
+            final Map<Integer, TiffOutputDirectory> directoryTypeMap) {
         this.byteOrder = byteOrder;
         this.rootDirectory = rootDirectory;
         this.directoryTypeMap = directoryTypeMap;
     }
 
-    private static class OffsetItem
-    {
+    private static class OffsetItem {
         public final TiffOutputItem item;
         public final TiffOutputField itemOffsetField;
 
         public OffsetItem(final TiffOutputItem item,
-                final TiffOutputField itemOffsetField)
-        {
+                final TiffOutputField itemOffsetField) {
             super();
             this.itemOffsetField = itemOffsetField;
             this.item = item;
@@ -54,30 +51,23 @@ class TiffOutputSummary implements TiffC
     private List<OffsetItem> offsetItems = new ArrayList<OffsetItem>();
 
     public void add(final TiffOutputItem item,
-            final TiffOutputField itemOffsetField)
-    {
+            final TiffOutputField itemOffsetField) {
         offsetItems.add(new OffsetItem(item, itemOffsetField));
     }
 
-    public void updateOffsets(int byteOrder) throws ImageWriteException
-    {
-        for (int i = 0; i < offsetItems.size(); i++)
-        {
+    public void updateOffsets(int byteOrder) throws ImageWriteException {
+        for (int i = 0; i < offsetItems.size(); i++) {
             OffsetItem offset = offsetItems.get(i);
 
-            byte value[] = FIELD_TYPE_LONG.writeData(new int[]{
-                offset.item.getOffset(),
-            }, byteOrder);
+            byte value[] = FIELD_TYPE_LONG.writeData(
+                    new int[] { offset.item.getOffset(), }, byteOrder);
             offset.itemOffsetField.setData(value);
         }
 
-        for (int i = 0; i < imageDataItems.size(); i++)
-        {
-            ImageDataOffsets imageDataInfo = imageDataItems
-                    .get(i);
+        for (int i = 0; i < imageDataItems.size(); i++) {
+            ImageDataOffsets imageDataInfo = imageDataItems.get(i);
 
-            for (int j = 0; j < imageDataInfo.outputItems.length; j++)
-            {
+            for (int j = 0; j < imageDataInfo.outputItems.length; j++) {
                 TiffOutputItem item = imageDataInfo.outputItems[j];
                 imageDataInfo.imageDataOffsets[j] = item.getOffset();
             }
@@ -89,9 +79,8 @@ class TiffOutputSummary implements TiffC
 
     private List<ImageDataOffsets> imageDataItems = new ArrayList<ImageDataOffsets>();
 
-    public void addTiffImageData(final ImageDataOffsets imageDataInfo)
-    {
+    public void addTiffImageData(final ImageDataOffsets imageDataInfo) {
         imageDataItems.add(imageDataInfo);
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilter.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilter.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilter.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/transparencyfilters/TransparencyFilter.java Sat May 26 21:19:03 2012
@@ -21,16 +21,14 @@ import java.io.IOException;
 import org.apache.commons.imaging.ImageReadException;
 import org.apache.commons.imaging.common.BinaryFileParser;
 
-public abstract class TransparencyFilter extends BinaryFileParser
-{
+public abstract class TransparencyFilter extends BinaryFileParser {
     protected final byte bytes[];
 
-    public TransparencyFilter(byte bytes[])
-    {
+    public TransparencyFilter(byte bytes[]) {
         this.bytes = bytes;
 
     }
 
     public abstract int filter(int rgb, int index) throws ImageReadException,
             IOException;
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -21,13 +21,11 @@ import java.io.IOException;
 
 import org.apache.commons.imaging.ImageReadException;
 
-public class TransparencyFilterGrayscale extends TransparencyFilter
-{
+public class TransparencyFilterGrayscale extends TransparencyFilter {
     private final int transparent_color;
 
     public TransparencyFilterGrayscale(byte bytes[]) throws ImageReadException,
-            IOException
-    {
+            IOException {
         super(bytes);
 
         ByteArrayInputStream is = new ByteArrayInputStream(bytes);
@@ -37,10 +35,9 @@ public class TransparencyFilterGrayscale
 
     @Override
     public int filter(int rgb, int index) throws ImageReadException,
-            IOException
-    {
+            IOException {
         if (index != transparent_color)
             return rgb;
         return 0x00;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -20,11 +20,9 @@ import java.io.IOException;
 
 import org.apache.commons.imaging.ImageReadException;
 
-public class TransparencyFilterIndexedColor extends TransparencyFilter
-{
+public class TransparencyFilterIndexedColor extends TransparencyFilter {
 
-    public TransparencyFilterIndexedColor(byte bytes[])
-    {
+    public TransparencyFilterIndexedColor(byte bytes[]) {
         super(bytes);
     }
 
@@ -32,8 +30,7 @@ public class TransparencyFilterIndexedCo
 
     @Override
     public int filter(int rgb, int index) throws ImageReadException,
-            IOException
-    {
+            IOException {
         if (index >= bytes.length)
             return rgb;
 
@@ -45,10 +42,9 @@ public class TransparencyFilterIndexedCo
         int alpha = bytes[index];
         int result = ((0xff & alpha) << 24) | (0x00ffffff & rgb);
 
-        if ((count < 100) && (index > 0))
-        {
+        if ((count < 100) && (index > 0)) {
             count++;
         }
         return result;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -21,16 +21,14 @@ import java.io.IOException;
 
 import org.apache.commons.imaging.ImageReadException;
 
-public class TransparencyFilterTrueColor extends TransparencyFilter
-{
+public class TransparencyFilterTrueColor extends TransparencyFilter {
     private final int transparent_red;
     private final int transparent_green;
     private final int transparent_blue;
     private final int transparent_color;
 
     public TransparencyFilterTrueColor(byte bytes[]) throws ImageReadException,
-            IOException
-    {
+            IOException {
         super(bytes);
 
         ByteArrayInputStream is = new ByteArrayInputStream(bytes);
@@ -49,11 +47,10 @@ public class TransparencyFilterTrueColor
 
     @Override
     public int filter(int rgb, int sample) throws ImageReadException,
-            IOException
-    {
+            IOException {
         if ((0x00ffffff & rgb) == transparent_color)
             return 0x00;
 
         return rgb;
     }
-}
\ No newline at end of file
+}

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -39,141 +39,117 @@ import org.apache.commons.imaging.ImageW
 import org.apache.commons.imaging.common.IImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 
-public class WbmpImageParser extends ImageParser
-{
-    public WbmpImageParser()
-    {
+public class WbmpImageParser extends ImageParser {
+    public WbmpImageParser() {
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Wbmp-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
+
     private static final String DEFAULT_EXTENSION = ".wbmp";
-    private static final String ACCEPTED_EXTENSIONS[] =
-    {
-        ".wbmp",
-    };
+    private static final String ACCEPTED_EXTENSIONS[] = { ".wbmp", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
-        return new ImageFormat[]
-        {
-            ImageFormat.IMAGE_FORMAT_WBMP, //
+    protected ImageFormat[] getAcceptedTypes() {
+        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_WBMP, //
         };
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         WbmpHeader wbmpHeader = readWbmpHeader(byteSource);
         return new ImageInfo("WBMP", 1, new ArrayList<String>(),
                 ImageFormat.IMAGE_FORMAT_WBMP,
-                "Wireless Application Protocol Bitmap",
-                wbmpHeader.height, "image/vnd.wap.wbmp", 1,
-                0, 0, 0, 0,
-                wbmpHeader.width, false, false, false,
-                ImageInfo.COLOR_TYPE_BW,
+                "Wireless Application Protocol Bitmap", wbmpHeader.height,
+                "image/vnd.wap.wbmp", 1, 0, 0, 0, 0, wbmpHeader.width, false,
+                false, false, ImageInfo.COLOR_TYPE_BW,
                 ImageInfo.COMPRESSION_ALGORITHM_NONE);
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public Dimension getImageSize(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         WbmpHeader wbmpHeader = readWbmpHeader(byteSource);
         return new Dimension(wbmpHeader.width, wbmpHeader.height);
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         return null;
     }
 
-    static class WbmpHeader
-    {
+    static class WbmpHeader {
         int typeField;
         byte fixHeaderField;
         int width;
         int height;
 
-        public WbmpHeader(int typeField, byte fixHeaderField, int width, int height)
-        {
+        public WbmpHeader(int typeField, byte fixHeaderField, int width,
+                int height) {
             this.typeField = typeField;
             this.fixHeaderField = fixHeaderField;
             this.width = width;
             this.height = height;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("WbmpHeader");
             pw.println("TypeField: " + typeField);
-            pw.println("FixHeaderField: 0x" + Integer.toHexString(0xff & fixHeaderField));
+            pw.println("FixHeaderField: 0x"
+                    + Integer.toHexString(0xff & fixHeaderField));
             pw.println("Width: " + width);
             pw.println("Height: " + height);
         }
     }
 
-    private int readMultiByteInteger(InputStream is)
-            throws ImageReadException, IOException
-    {
+    private int readMultiByteInteger(InputStream is) throws ImageReadException,
+            IOException {
         int value = 0;
         int nextByte;
         int totalBits = 0;
-        do
-        {
+        do {
             nextByte = readByte("Header", is, "Error reading WBMP header");
             value <<= 7;
             value |= nextByte & 0x7f;
             totalBits += 7;
             if (totalBits > 31)
-                throw new ImageReadException("Overflow reading WBMP multi-byte field");
+                throw new ImageReadException(
+                        "Overflow reading WBMP multi-byte field");
         } while ((nextByte & 0x80) != 0);
         return value;
     }
 
     private void writeMultiByteInteger(OutputStream os, int value)
-            throws IOException
-    {
+            throws IOException {
         boolean wroteYet = false;
-        for (int position = 4*7; position > 0; position -= 7)
-        {
+        for (int position = 4 * 7; position > 0; position -= 7) {
             int next7Bits = 0x7f & (value >>> position);
-            if (next7Bits != 0 || wroteYet)
-            {
+            if (next7Bits != 0 || wroteYet) {
                 os.write(0x80 | next7Bits);
                 wroteYet = true;
             }
@@ -182,38 +158,33 @@ public class WbmpImageParser extends Ima
     }
 
     private WbmpHeader readWbmpHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             return readWbmpHeader(is);
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
     private WbmpHeader readWbmpHeader(InputStream is)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         int typeField = readMultiByteInteger(is);
         if (typeField != 0)
-            throw new ImageReadException("Invalid/unsupported WBMP type " + typeField);
+            throw new ImageReadException("Invalid/unsupported WBMP type "
+                    + typeField);
 
-        byte fixHeaderField = readByte("FixHeaderField", is, "Invalid WBMP File");
+        byte fixHeaderField = readByte("FixHeaderField", is,
+                "Invalid WBMP File");
         if ((fixHeaderField & 0x9f) != 0)
-            throw new ImageReadException("Invalid/unsupported WBMP FixHeaderField 0x" +
-                    Integer.toHexString(0xff & fixHeaderField));
+            throw new ImageReadException(
+                    "Invalid/unsupported WBMP FixHeaderField 0x"
+                            + Integer.toHexString(0xff & fixHeaderField));
 
         int width = readMultiByteInteger(is);
 
@@ -224,22 +195,20 @@ public class WbmpImageParser extends Ima
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         readWbmpHeader(byteSource).dump(pw);
         return true;
     }
 
     private BufferedImage readImage(WbmpHeader wbmpHeader, InputStream is)
-            throws IOException
-    {
+            throws IOException {
         int rowLength = (wbmpHeader.width + 7) / 8;
-        byte[] image = readByteArray("Pixels", rowLength * wbmpHeader.height, is,
-                "Error reading image pixels");
+        byte[] image = readByteArray("Pixels", rowLength * wbmpHeader.height,
+                is, "Error reading image pixels");
         DataBufferByte dataBuffer = new DataBufferByte(image, image.length);
         WritableRaster raster = WritableRaster.createPackedRaster(dataBuffer,
                 wbmpHeader.width, wbmpHeader.height, 1, null);
-        int[] palette = {0x000000, 0xffffff};
+        int[] palette = { 0x000000, 0xffffff };
         IndexColorModel colorModel = new IndexColorModel(1, 2, palette, 0,
                 false, -1, DataBuffer.TYPE_BYTE);
         return new BufferedImage(colorModel, raster,
@@ -248,32 +217,24 @@ public class WbmpImageParser extends Ima
 
     @Override
     public final BufferedImage getBufferedImage(ByteSource byteSource,
-            Map params) throws ImageReadException, IOException
-    {
+            Map params) throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             WbmpHeader wbmpHeader = readWbmpHeader(is);
             return readImage(wbmpHeader, is);
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
@@ -281,8 +242,7 @@ public class WbmpImageParser extends Ima
         if (params.containsKey(PARAM_KEY_FORMAT))
             params.remove(PARAM_KEY_FORMAT);
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
@@ -292,12 +252,10 @@ public class WbmpImageParser extends Ima
         writeMultiByteInteger(os, src.getWidth());
         writeMultiByteInteger(os, src.getHeight());
 
-        for (int y = 0; y < src.getHeight(); y++)
-        {
+        for (int y = 0; y < src.getHeight(); y++) {
             int pixel = 0;
             int nextBit = 0x80;
-            for (int x = 0; x < src.getWidth(); x++)
-            {
+            for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
                 int red = 0xff & (argb >> 16);
                 int green = 0xff & (argb >> 8);
@@ -306,8 +264,7 @@ public class WbmpImageParser extends Ima
                 if (sample > 127)
                     pixel |= nextBit;
                 nextBit >>>= 1;
-                if (nextBit == 0)
-                {
+                if (nextBit == 0) {
                     os.write(pixel);
                     pixel = 0;
                     nextBit = 0x80;
@@ -321,17 +278,16 @@ public class WbmpImageParser extends Ima
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>
-     *
+     * 
      * @param byteSource
      *            File containing image data.
      * @param params
      *            Map of optional parameters, defined in SanselanConstants.
-     * @return Xmp Xml as String, if present.  Otherwise, returns null.
+     * @return Xmp Xml as String, if present. Otherwise, returns null.
      */
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 }

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=1342971&r1=1342970&r2=1342971&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 Sat May 26 21:19:03 2012
@@ -45,136 +45,108 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.common.IImageMetadata;
 import org.apache.commons.imaging.common.bytesource.ByteSource;
 
-public class XbmImageParser extends ImageParser
-{
-    public XbmImageParser()
-    {
+public class XbmImageParser extends ImageParser {
+    public XbmImageParser() {
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Xbm-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
+
     private static final String DEFAULT_EXTENSION = ".xbm";
-    private static final String ACCEPTED_EXTENSIONS[] =
-    {
-        ".xbm",
-    };
+    private static final String ACCEPTED_EXTENSIONS[] = { ".xbm", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
-        return new ImageFormat[]
-        {
-            ImageFormat.IMAGE_FORMAT_XBM, //
+    protected ImageFormat[] getAcceptedTypes() {
+        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_XBM, //
         };
     }
 
     @Override
-    public boolean embedICCProfile(File src, File dst, byte profile[])
-    {
+    public boolean embedICCProfile(File src, File dst, byte profile[]) {
         return false;
     }
 
     @Override
     public IImageMetadata getMetadata(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 
     @Override
     public ImageInfo getImageInfo(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         XbmHeader xbmHeader = readXbmHeader(byteSource);
-        return new ImageInfo("XBM", 1,
-                new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XBM,
-                "X BitMap",
-                xbmHeader.height, "image/x-xbitmap", 1,
-                0, 0, 0, 0,
-                xbmHeader.width, false, false, false,
-                ImageInfo.COLOR_TYPE_BW,
+        return new ImageInfo("XBM", 1, new ArrayList<String>(),
+                ImageFormat.IMAGE_FORMAT_XBM, "X BitMap", xbmHeader.height,
+                "image/x-xbitmap", 1, 0, 0, 0, 0, xbmHeader.width, false,
+                false, false, ImageInfo.COLOR_TYPE_BW,
                 ImageInfo.COMPRESSION_ALGORITHM_NONE);
     }
 
     @Override
-    public Dimension getImageSize(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public Dimension getImageSize(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         XbmHeader xbmHeader = readXbmHeader(byteSource);
         return new Dimension(xbmHeader.width, xbmHeader.height);
     }
 
     @Override
-    public byte[] getICCProfileBytes(ByteSource byteSource,
-            Map params)
-            throws ImageReadException, IOException
-    {
+    public byte[] getICCProfileBytes(ByteSource byteSource, Map params)
+            throws ImageReadException, IOException {
         return null;
     }
 
-    private static class XbmHeader
-    {
+    private static class XbmHeader {
         int width;
         int height;
         int xHot = -1;
         int yHot = -1;
 
-        public XbmHeader(int width, int height, int xHot, int yHot)
-        {
+        public XbmHeader(int width, int height, int xHot, int yHot) {
             this.width = width;
             this.height = height;
             this.xHot = xHot;
             this.yHot = yHot;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("XbmHeader");
             pw.println("Width: " + width);
             pw.println("Height: " + height);
-            if (xHot != -1 && yHot != -1)
-            {
+            if (xHot != -1 && yHot != -1) {
                 pw.println("X hot: " + xHot);
                 pw.println("Y hot: " + yHot);
             }
         }
     }
 
-    private static class XbmParseResult
-    {
+    private static class XbmParseResult {
         XbmHeader xbmHeader;
         BasicCParser cParser;
     }
 
     private XbmHeader readXbmHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         XbmParseResult result = parseXbmHeader(byteSource);
         return result.xbmHeader;
     }
 
     private XbmParseResult parseXbmHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             Map<String, String> defines = new HashMap<String, String>();
             ByteArrayOutputStream preprocessedFile = BasicCParser.preprocess(
@@ -183,8 +155,8 @@ public class XbmImageParser extends Imag
             int height = -1;
             int xHot = -1;
             int yHot = -1;
-            for (Iterator<Map.Entry<String,String>> it = defines.entrySet().iterator(); it.hasNext();)
-            {
+            for (Iterator<Map.Entry<String, String>> it = defines.entrySet()
+                    .iterator(); it.hasNext();) {
                 Map.Entry<String, String> entry = it.next();
                 String name = entry.getKey();
                 if (name.endsWith("_width"))
@@ -202,80 +174,81 @@ public class XbmImageParser extends Imag
                 throw new ImageReadException("height not found");
 
             XbmParseResult xbmParseResult = new XbmParseResult();
-            xbmParseResult.cParser = new BasicCParser(
-                    new ByteArrayInputStream(preprocessedFile.toByteArray()));
+            xbmParseResult.cParser = new BasicCParser(new ByteArrayInputStream(
+                    preprocessedFile.toByteArray()));
             xbmParseResult.xbmHeader = new XbmHeader(width, height, xHot, yHot);
             return xbmParseResult;
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
     private BufferedImage readXbmImage(XbmHeader xbmHeader, BasicCParser cParser)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         String token;
         token = cParser.nextToken();
         if (token == null || !token.equals("static"))
-            throw new ImageReadException("Parsing XBM file failed, no 'static' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no 'static' token");
         token = cParser.nextToken();
         if (token == null)
-            throw new ImageReadException("Parsing XBM file failed, no 'unsigned' " +
-                    "or 'char' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no 'unsigned' "
+                            + "or 'char' token");
         if (token.equals("unsigned"))
             token = cParser.nextToken();
         if (token == null || !token.equals("char"))
-            throw new ImageReadException("Parsing XBM file failed, no 'char' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no 'char' token");
         String name = cParser.nextToken();
         if (name == null)
-            throw new ImageReadException("Parsing XBM file failed, no variable name");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no variable name");
         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++)
-        {
+            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 != '_')
-                throw new ImageReadException("Parsing XBM file failed, variable name " +
-                        "contains non-letter non-digit non-underscore");
+                throw new ImageReadException(
+                        "Parsing XBM file failed, variable name "
+                                + "contains non-letter non-digit non-underscore");
         }
         token = cParser.nextToken();
         if (token == null || !token.equals("["))
-            throw new ImageReadException("Parsing XBM file failed, no '[' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no '[' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("]"))
-            throw new ImageReadException("Parsing XBM file failed, no ']' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no ']' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("="))
-            throw new ImageReadException("Parsing XBM file failed, no '=' token");
+            throw new ImageReadException(
+                    "Parsing XBM file failed, no '=' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("{"))
-            throw new ImageReadException("Parsing XBM file failed, no '{' token");
+            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++)
-        {
+        for (int i = 0; i < imageData.length; i++) {
             token = cParser.nextToken();
             if (token == null || !token.startsWith("0x"))
-                throw new ImageReadException("Parsing XBM file failed, " +
-                        "hex value missing");
+                throw new ImageReadException("Parsing XBM file failed, "
+                        + "hex value missing");
             if (token.length() > 4)
-                throw new ImageReadException("Parsing XBM file failed, " +
-                        "hex value too long");
+                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++)
-            {
+            for (int j = 0; j < 8; j++) {
                 if ((value & (1 << j)) != 0)
                     flipped |= (0x80 >>> j);
             }
@@ -283,17 +256,19 @@ public class XbmImageParser extends Imag
 
             token = cParser.nextToken();
             if (token == null)
-                throw new ImageReadException("Parsing XBM file failed, " +
-                        "premature end of file");
-            if (!token.equals(",") && (i < (imageData.length - 1) || !token.equals("}")))
-                throw new ImageReadException("Parsing XBM file failed, " +
-                        "punctuation error");
+                throw new ImageReadException("Parsing XBM file failed, "
+                        + "premature end of file");
+            if (!token.equals(",")
+                    && (i < (imageData.length - 1) || !token.equals("}")))
+                throw new ImageReadException("Parsing XBM file failed, "
+                        + "punctuation error");
         }
 
-        int[] palette = {0xffffff, 0x000000};
-        ColorModel colorModel = new IndexColorModel(1, 2,
-                palette, 0, false, -1, DataBuffer.TYPE_BYTE);
-        DataBufferByte dataBuffer = new DataBufferByte(imageData, imageData.length);
+        int[] palette = { 0xffffff, 0x000000 };
+        ColorModel colorModel = new IndexColorModel(1, 2, palette, 0, false,
+                -1, DataBuffer.TYPE_BYTE);
+        DataBufferByte dataBuffer = new DataBufferByte(imageData,
+                imageData.length);
         WritableRaster raster = WritableRaster.createPackedRaster(dataBuffer,
                 xbmHeader.width, xbmHeader.height, 1, null);
         BufferedImage image = new BufferedImage(colorModel, raster,
@@ -303,36 +278,34 @@ public class XbmImageParser extends Imag
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         readXbmHeader(byteSource).dump(pw);
         return true;
     }
 
     @Override
     public final BufferedImage getBufferedImage(ByteSource byteSource,
-            Map params) throws ImageReadException, IOException
-    {
+            Map params) throws ImageReadException, IOException {
         XbmParseResult result = parseXbmHeader(byteSource);
         return readXbmImage(result.xbmHeader, result.cParser);
     }
 
-    private String randomName()
-    {
+    private String randomName() {
         UUID uuid = UUID.randomUUID();
         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)));
+            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)));
+            stringBuilder.append(Integer
+                    .toHexString((int) ((bits >> i) & 0xff)));
         return stringBuilder.toString();
     }
 
-    private String toPrettyHex(int value)
-    {
+    private String toPrettyHex(int value) {
         String s = Integer.toHexString(0xff & value);
         if (s.length() == 2)
             return "0x" + s;
@@ -341,8 +314,7 @@ public class XbmImageParser extends Imag
 
     @Override
     public void writeImage(BufferedImage src, OutputStream os, Map params)
-            throws ImageWriteException, IOException
-    {
+            throws ImageWriteException, IOException {
         // make copy of params; we'll clear keys as we consume them.
         params = (params == null) ? new HashMap() : new HashMap(params);
 
@@ -350,26 +322,26 @@ public class XbmImageParser extends Imag
         if (params.containsKey(PARAM_KEY_FORMAT))
             params.remove(PARAM_KEY_FORMAT);
 
-        if (params.size() > 0)
-        {
+        if (params.size() > 0) {
             Object firstKey = params.keySet().iterator().next();
             throw new ImageWriteException("Unknown parameter: " + firstKey);
         }
 
         String name = randomName();
 
-        os.write(("#define " + name + "_width " + src.getWidth() + "\n").getBytes("US-ASCII"));
-        os.write(("#define " + name + "_height " + src.getHeight() + "\n").getBytes("US-ASCII"));
-        os.write(("static unsigned char " + name + "_bits[] = {").getBytes("US-ASCII"));
+        os.write(("#define " + name + "_width " + src.getWidth() + "\n")
+                .getBytes("US-ASCII"));
+        os.write(("#define " + name + "_height " + src.getHeight() + "\n")
+                .getBytes("US-ASCII"));
+        os.write(("static unsigned char " + name + "_bits[] = {")
+                .getBytes("US-ASCII"));
 
         int bitcache = 0;
         int bits_in_cache = 0;
         String separator = "\n  ";
         int written = 0;
-        for (int y = 0; y < src.getHeight(); y++)
-        {
-            for (int x = 0; x < src.getWidth(); x++)
-            {
+        for (int y = 0; y < src.getHeight(); y++) {
+            for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
                 int red = 0xff & (argb >> 16);
                 int green = 0xff & (argb >> 8);
@@ -381,12 +353,10 @@ public class XbmImageParser extends Imag
                     sample = 1;
                 bitcache |= (sample << bits_in_cache);
                 ++bits_in_cache;
-                if (bits_in_cache == 8)
-                {
+                if (bits_in_cache == 8) {
                     os.write(separator.getBytes("US-ASCII"));
                     separator = ",";
-                    if (written == 12)
-                    {
+                    if (written == 12) {
                         os.write("\n  ".getBytes("US-ASCII"));
                         written = 0;
                     }
@@ -396,12 +366,10 @@ public class XbmImageParser extends Imag
                     ++written;
                 }
             }
-            if (bits_in_cache != 0)
-            {
+            if (bits_in_cache != 0) {
                 os.write(separator.getBytes("US-ASCII"));
                 separator = ",";
-                if (written == 12)
-                {
+                if (written == 12) {
                     os.write("\n  ".getBytes("US-ASCII"));
                     written = 0;
                 }
@@ -418,17 +386,16 @@ public class XbmImageParser extends Imag
     /**
      * Extracts embedded XML metadata as XML string.
      * <p>
-     *
+     * 
      * @param byteSource
      *            File containing image data.
      * @param params
      *            Map of optional parameters, defined in SanselanConstants.
-     * @return Xmp Xml as String, if present.  Otherwise, returns null.
+     * @return Xmp Xml as String, if present. Otherwise, returns null.
      */
     @Override
     public String getXmpXml(ByteSource byteSource, Map params)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         return null;
     }
 }



Mime
View raw message