commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1342971 [16/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/palette/MedianCutQuantizer.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/MedianCutQuantizer.java Sat May 26 21:19:03 2012
@@ -27,23 +27,19 @@ import java.util.Map;
 import org.apache.commons.imaging.ImageWriteException;
 import org.apache.commons.imaging.util.Debug;
 
-public class MedianCutQuantizer
-{
+public class MedianCutQuantizer {
     private final boolean ignoreAlpha;
 
-    public MedianCutQuantizer(boolean ignore_alpha)
-    {
+    public MedianCutQuantizer(boolean ignore_alpha) {
         this.ignoreAlpha = ignore_alpha;
     }
 
-    private static class ColorCount
-    {
+    private static class ColorCount {
         public final int argb;
         public int count = 0;
         public final int alpha, red, green, blue;
 
-        public ColorCount(int argb)
-        {
+        public ColorCount(int argb) {
             this.argb = argb;
 
             alpha = 0xff & (argb >> 24);
@@ -51,18 +47,16 @@ public class MedianCutQuantizer
             green = 0xff & (argb >> 8);
             blue = 0xff & (argb >> 0);
 
-            //            super.hashCode();
+            // super.hashCode();
         }
 
         @Override
-        public int hashCode()
-        {
+        public int hashCode() {
             return argb;
         }
 
         @Override
-        public boolean equals(Object o)
-        {
+        public boolean equals(Object o) {
             if (o instanceof ColorCount) {
                 ColorCount other = (ColorCount) o;
                 return other.argb == this.argb;
@@ -72,11 +66,10 @@ public class MedianCutQuantizer
 
     }
 
-    private class ColorGroup
-    {
-        //        public final ColorGroup parent;
+    private class ColorGroup {
+        // public final ColorGroup parent;
         public ColorGroupCut cut = null;
-        //        public final List children = new ArrayList();
+        // public final List children = new ArrayList();
         public int palette_index = -1;
 
         public final List<ColorCount> color_counts;
@@ -97,15 +90,14 @@ public class MedianCutQuantizer
         public final int max_diff;
         public final int diff_total;
 
-        public ColorGroup(final List<ColorCount> color_counts) throws ImageWriteException
-        {
+        public ColorGroup(final List<ColorCount> color_counts)
+                throws ImageWriteException {
             this.color_counts = color_counts;
 
             if (color_counts.size() < 1)
                 throw new ImageWriteException("empty color_group");
 
-            for (int i = 0; i < color_counts.size(); i++)
-            {
+            for (int i = 0; i < color_counts.size(); i++) {
                 ColorCount color = color_counts.get(i);
 
                 min_alpha = Math.min(min_alpha, color.alpha);
@@ -122,15 +114,15 @@ public class MedianCutQuantizer
             red_diff = max_red - min_red;
             green_diff = max_green - min_green;
             blue_diff = max_blue - min_blue;
-            max_diff = Math.max(ignoreAlpha ? red_diff : Math.max(alpha_diff,
-                    red_diff), Math.max(green_diff, blue_diff));
+            max_diff = Math.max(
+                    ignoreAlpha ? red_diff : Math.max(alpha_diff, red_diff),
+                    Math.max(green_diff, blue_diff));
             diff_total = (ignoreAlpha ? 0 : alpha_diff) + red_diff + green_diff
                     + blue_diff;
 
         }
 
-        public boolean contains(int argb)
-        {
+        public boolean contains(int argb) {
             int alpha = 0xff & (argb >> 24);
             int red = 0xff & (argb >> 16);
             int green = 0xff & (argb >> 8);
@@ -147,13 +139,11 @@ public class MedianCutQuantizer
             return true;
         }
 
-        public int getMedianValue()
-        {
+        public int getMedianValue() {
             long count_total = 0;
             long alpha_total = 0, red_total = 0, green_total = 0, blue_total = 0;
 
-            for (int i = 0; i < color_counts.size(); i++)
-            {
+            for (int i = 0; i < color_counts.size(); i++) {
                 ColorCount color = color_counts.get(i);
 
                 count_total += color.count;
@@ -173,8 +163,7 @@ public class MedianCutQuantizer
         }
 
         @Override
-        public String toString()
-        {
+        public String toString() {
             return "{ColorGroup. min_red: " + Integer.toHexString(min_red)
                     + ", max_red: " + Integer.toHexString(max_red)
                     + ", min_green: " + Integer.toHexString(min_green)
@@ -189,29 +178,25 @@ public class MedianCutQuantizer
 
     }
 
-    public Map<Integer, ColorCount> groupColors1(BufferedImage image, int max, int mask)
-    {
+    public Map<Integer, ColorCount> groupColors1(BufferedImage image, int max,
+            int mask) {
         Map<Integer, ColorCount> color_map = new HashMap<Integer, ColorCount>();
 
         int width = image.getWidth();
         int height = image.getHeight();
 
         int row[] = new int[width];
-        for (int y = 0; y < height; y++)
-        {
+        for (int y = 0; y < height; y++) {
             image.getRGB(0, y, width, 1, row, 0, width);
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int argb = row[x];
 
                 if (ignoreAlpha)
                     argb &= 0xffffff;
                 argb &= mask;
 
-                ColorCount color = color_map
-                        .get(argb);
-                if (color == null)
-                {
+                ColorCount color = color_map.get(argb);
+                if (color == null) {
                     color = new ColorCount(argb);
                     color_map.put(argb, color);
                     if (color_map.keySet().size() > max)
@@ -224,16 +209,16 @@ public class MedianCutQuantizer
         return color_map;
     }
 
-    public Map<Integer, ColorCount> groupColors(BufferedImage image, int max_colors)
-    {
+    public Map<Integer, ColorCount> groupColors(BufferedImage image,
+            int max_colors) {
         int max = Integer.MAX_VALUE;
 
-        for (int i = 0; i < 8; i++)
-        {
+        for (int i = 0; i < 8; i++) {
             int mask = 0xff & (0xff << i);
             mask = mask | (mask << 8) | (mask << 16) | (mask << 24);
 
-            Debug.debug("mask(" + i + ")", mask + " (" + Integer.toHexString(mask) + ")");
+            Debug.debug("mask(" + i + ")",
+                    mask + " (" + Integer.toHexString(mask) + ")");
 
             Map<Integer, ColorCount> result = groupColors1(image, max, mask);
             if (result != null)
@@ -243,21 +228,19 @@ public class MedianCutQuantizer
     }
 
     public Palette process(BufferedImage image, int max_colors, boolean verbose)
-            throws ImageWriteException
-    {
+            throws ImageWriteException {
         Map<Integer, ColorCount> color_map = groupColors(image, max_colors);
 
         int discrete_colors = color_map.keySet().size();
-        if (discrete_colors <= max_colors)
-        {
+        if (discrete_colors <= max_colors) {
             if (verbose)
                 Debug.debug("lossless palette: " + discrete_colors);
 
             int palette[] = new int[discrete_colors];
-            List<ColorCount> color_counts = new ArrayList<ColorCount>(color_map.values());
+            List<ColorCount> color_counts = new ArrayList<ColorCount>(
+                    color_map.values());
 
-            for (int i = 0; i < color_counts.size(); i++)
-            {
+            for (int i = 0; i < color_counts.size(); i++) {
                 ColorCount color_count = color_counts.get(i);
                 palette[i] = color_count.argb;
                 if (ignoreAlpha)
@@ -271,22 +254,20 @@ public class MedianCutQuantizer
             Debug.debug("discrete colors: " + discrete_colors);
 
         List<ColorGroup> color_groups = new ArrayList<ColorGroup>();
-        ColorGroup root = new ColorGroup(new ArrayList<ColorCount>(color_map.values()));
+        ColorGroup root = new ColorGroup(new ArrayList<ColorCount>(
+                color_map.values()));
         {
             color_groups.add(root);
 
-            final Comparator<ColorGroup> comparator = new Comparator<ColorGroup>()
-            {
-                public int compare(ColorGroup cg1, ColorGroup cg2)
-                {
+            final Comparator<ColorGroup> comparator = new Comparator<ColorGroup>() {
+                public int compare(ColorGroup cg1, ColorGroup cg2) {
                     if (cg1.max_diff == cg2.max_diff)
                         return cg2.diff_total - cg1.diff_total;
                     return cg2.max_diff - cg1.max_diff;
                 }
             };
 
-            while (color_groups.size() < max_colors)
-            {
+            while (color_groups.size() < max_colors) {
                 Collections.sort(color_groups, comparator);
 
                 ColorGroup color_group = color_groups.get(0);
@@ -296,21 +277,14 @@ public class MedianCutQuantizer
                 if (!ignoreAlpha
                         && color_group.alpha_diff > color_group.red_diff
                         && color_group.alpha_diff > color_group.green_diff
-                        && color_group.alpha_diff > color_group.blue_diff)
-                {
+                        && color_group.alpha_diff > color_group.blue_diff) {
                     doCut(color_group, ALPHA, color_groups);
-                }
-                else if (color_group.red_diff > color_group.green_diff
-                        && color_group.red_diff > color_group.blue_diff)
-                {
+                } else if (color_group.red_diff > color_group.green_diff
+                        && color_group.red_diff > color_group.blue_diff) {
                     doCut(color_group, RED, color_groups);
-                }
-                else if (color_group.green_diff > color_group.blue_diff)
-                {
+                } else if (color_group.green_diff > color_group.blue_diff) {
                     doCut(color_group, GREEN, color_groups);
-                }
-                else
-                {
+                } else {
                     doCut(color_group, BLUE, color_groups);
                 }
             }
@@ -323,8 +297,7 @@ public class MedianCutQuantizer
 
             int palette[] = new int[palette_size];
 
-            for (int i = 0; i < color_groups.size(); i++)
-            {
+            for (int i = 0; i < color_groups.size(); i++) {
                 ColorGroup color_group = color_groups.get(i);
 
                 palette[i] = color_group.getMedianValue();
@@ -335,10 +308,10 @@ public class MedianCutQuantizer
                     throw new ImageWriteException("empty color_group: "
                             + color_group);
 
-                //                if(color_group.)
-                //                Debug.debug("color_group", color_group);
-                //                Debug.debug("palette[" + i + "]", palette[i] + " ("
-                //                        + Integer.toHexString(palette[i]) + ")");
+                // if(color_group.)
+                // Debug.debug("color_group", color_group);
+                // Debug.debug("palette[" + i + "]", palette[i] + " ("
+                // + Integer.toHexString(palette[i]) + ")");
             }
 
             if (palette_size > discrete_colors)
@@ -353,31 +326,27 @@ public class MedianCutQuantizer
     private static final int GREEN = 2;
     private static final int BLUE = 3;
 
-    private void doCut(ColorGroup color_group, final int mode, final List<ColorGroup> color_groups) throws ImageWriteException
-    {
+    private void doCut(ColorGroup color_group, final int mode,
+            final List<ColorGroup> color_groups) throws ImageWriteException {
         int count_total = 0;
-        for (int i = 0; i < color_group.color_counts.size(); i++)
-        {
+        for (int i = 0; i < color_group.color_counts.size(); i++) {
             ColorCount color_count = color_group.color_counts.get(i);
             count_total += color_count.count;
         }
 
-        Comparator<ColorCount> comparator = new Comparator<ColorCount>()
-        {
-            public int compare(ColorCount c1, ColorCount c2)
-            {
-                switch (mode)
-                {
-                    case ALPHA :
-                        return c1.alpha - c2.alpha;
-                    case RED :
-                        return c1.red - c2.red;
-                    case GREEN :
-                        return c1.green - c2.green;
-                    case BLUE :
-                        return c1.blue - c2.blue;
-                    default :
-                        return 0;
+        Comparator<ColorCount> comparator = new Comparator<ColorCount>() {
+            public int compare(ColorCount c1, ColorCount c2) {
+                switch (mode) {
+                case ALPHA:
+                    return c1.alpha - c2.alpha;
+                case RED:
+                    return c1.red - c2.red;
+                case GREEN:
+                    return c1.green - c2.green;
+                case BLUE:
+                    return c1.blue - c2.blue;
+                default:
+                    return 0;
                 }
             }
         };
@@ -386,14 +355,12 @@ public class MedianCutQuantizer
         int count_half = (int) Math.round((double) count_total / 2);
         int old_count = 0, new_count = 0;
         int median_index;
-        for (median_index = 0; median_index < color_group.color_counts.size(); median_index++)
-        {
+        for (median_index = 0; median_index < color_group.color_counts.size(); median_index++) {
             ColorCount color_count = color_group.color_counts.get(median_index);
 
             new_count += color_count.count;
 
-            if (new_count < count_half)
-            {
+            if (new_count < count_half) {
                 old_count = new_count;
                 continue;
             }
@@ -402,8 +369,7 @@ public class MedianCutQuantizer
 
         if (median_index == color_group.color_counts.size() - 1)
             median_index--;
-        else if (median_index > 0)
-        {
+        else if (median_index > 0) {
             int new_diff = Math.abs(new_count - count_half);
             int old_diff = Math.abs(count_half - old_count);
             if (old_diff < new_diff)
@@ -412,8 +378,11 @@ public class MedianCutQuantizer
 
         color_groups.remove(color_group);
         {
-            List<ColorCount> color_counts1 = new ArrayList<ColorCount>(color_group.color_counts.subList(0, median_index + 1));
-            List<ColorCount> color_counts2 = new ArrayList<ColorCount>(color_group.color_counts.subList(median_index + 1, color_group.color_counts.size()));
+            List<ColorCount> color_counts1 = new ArrayList<ColorCount>(
+                    color_group.color_counts.subList(0, median_index + 1));
+            List<ColorCount> color_counts2 = new ArrayList<ColorCount>(
+                    color_group.color_counts.subList(median_index + 1,
+                            color_group.color_counts.size()));
 
             ColorGroup less, more;
             {
@@ -425,62 +394,59 @@ public class MedianCutQuantizer
                 color_groups.add(more);
             }
 
-            ColorCount median_value = color_group.color_counts.get(median_index);
+            ColorCount median_value = color_group.color_counts
+                    .get(median_index);
             int limit;
-            switch (mode)
-            {
-                case ALPHA :
-                    limit = median_value.alpha;
-                    break;
-                case RED :
-                    limit = median_value.red;
-                    break;
-                case GREEN :
-                    limit = median_value.green;
-                    break;
-                case BLUE :
-                    limit = median_value.blue;
-                    break;
-                default :
-                    throw new Error("Bad mode.");
+            switch (mode) {
+            case ALPHA:
+                limit = median_value.alpha;
+                break;
+            case RED:
+                limit = median_value.red;
+                break;
+            case GREEN:
+                limit = median_value.green;
+                break;
+            case BLUE:
+                limit = median_value.blue;
+                break;
+            default:
+                throw new Error("Bad mode.");
             }
             color_group.cut = new ColorGroupCut(less, more, mode, limit);
 
         }
     }
-    private static class ColorGroupCut
-    {
+
+    private static class ColorGroupCut {
         public final ColorGroup less, more;
         public final int mode, limit;
 
         public ColorGroupCut(ColorGroup less, ColorGroup more, int mode,
-                int limit)
-        {
+                int limit) {
             this.less = less;
             this.more = more;
             this.mode = mode;
             this.limit = limit;
         }
 
-        public ColorGroup getColorGroup(int argb)
-        {
+        public ColorGroup getColorGroup(int argb) {
             int value;
-            switch (mode)
-            {
-                case ALPHA :
-                    value = 0xff & (argb >> 24);
-                    break;
-                case RED :
-                    value = 0xff & (argb >> 16);
-                    break;
-                case GREEN :
-                    value = 0xff & (argb >> 8);
-                    break;
-                case BLUE :
-                    value = 0xff & (argb >> 0);
-                    break;
-                default :
-                    throw new Error("bad mode.");
+            switch (mode) {
+            case ALPHA:
+                value = 0xff & (argb >> 24);
+                break;
+            case RED:
+                value = 0xff & (argb >> 16);
+                break;
+            case GREEN:
+                value = 0xff & (argb >> 8);
+                break;
+            case BLUE:
+                value = 0xff & (argb >> 0);
+                break;
+            default:
+                throw new Error("bad mode.");
             }
             if (value <= limit)
                 return less;
@@ -489,23 +455,19 @@ public class MedianCutQuantizer
 
     }
 
-    public static class MedianCutPalette extends SimplePalette
-    {
+    public static class MedianCutPalette extends SimplePalette {
         private final ColorGroup root;
 
-        public MedianCutPalette(ColorGroup root, int palette[])
-        {
+        public MedianCutPalette(ColorGroup root, int palette[]) {
             super(palette);
             this.root = root;
         }
 
         @Override
-        public int getPaletteIndex(int rgb)
-        {
+        public int getPaletteIndex(int rgb) {
             ColorGroup cg = root;
 
-            while (cg.cut != null)
-            {
+            while (cg.cut != null) {
                 cg = cg.cut.getColorGroup(rgb);
             }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Palette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Palette.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Palette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/Palette.java Sat May 26 21:19:03 2012
@@ -18,8 +18,7 @@ package org.apache.commons.imaging.palet
 
 import org.apache.commons.imaging.ImageWriteException;
 
-public abstract class Palette
-{
+public abstract class Palette {
 
     public abstract int getPaletteIndex(int rgb) throws ImageWriteException;
 
@@ -27,8 +26,7 @@ public abstract class Palette
 
     public abstract int length();
 
-    public void dump()
-    {
+    public void dump() {
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/PaletteFactory.java Sat May 26 21:19:03 2012
@@ -26,13 +26,11 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-public class PaletteFactory
-{
+public class PaletteFactory {
     private static final boolean debug = false;
 
-    public void makePaletteFancy(BufferedImage src)
-    {
-        //         map what rgb values have been used
+    public void makePaletteFancy(BufferedImage src) {
+        // map what rgb values have been used
 
         byte rgbmap[] = new byte[256 * 256 * 32];
         for (int i = 0; i < rgbmap.length; i++)
@@ -42,8 +40,7 @@ public class PaletteFactory
         int height = src.getHeight();
 
         for (int y = 0; y < height; y++)
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int argb = src.getRGB(x, y);
                 int rggbb = 0x1fffff & argb;
                 int highred = 0x7 & (argb >> 21);
@@ -52,14 +49,11 @@ public class PaletteFactory
             }
 
         int count = 0;
-        for (int i = 0; i < rgbmap.length; i++)
-        {
+        for (int i = 0; i < rgbmap.length; i++) {
             int eight = 0xff & rgbmap[i];
-            if ((i < 3) || ((i - rgbmap.length) > -3))
-            {
+            if ((i < 3) || ((i - rgbmap.length) > -3)) {
             }
-            for (int j = 0; j < 8; j++)
-            {
+            for (int j = 0; j < 8; j++) {
                 int mask = 1 << (7 - j);
                 int bit = eight & mask;
                 if (bit > 0)
@@ -73,17 +67,14 @@ public class PaletteFactory
 
         int colormap[] = new int[count];
         int mapsize = 0;
-        for (int i = 0; i < rgbmap.length; i++)
-        {
+        for (int i = 0; i < rgbmap.length; i++) {
             int eight = 0xff & rgbmap[i];
 
-            for (int j = 0; j < 8; j++)
-            {
+            for (int j = 0; j < 8; j++) {
                 int mask = 1 << (7 - j);
                 int bit = eight & mask;
 
-                if (bit > 0)
-                {
+                if (bit > 0) {
                     int rgb = i | ((7 - j) << 21);
 
                     if (mapsize < colormap.length)
@@ -96,20 +87,18 @@ public class PaletteFactory
         if (debug)
             System.out.println("mapsize: " + mapsize);
 
-        //        for (int i = 0; i < colormap.length; i++)
-        //        {
-        //            int rgb = colormap[i];
-        //        }
+        // for (int i = 0; i < colormap.length; i++)
+        // {
+        // int rgb = colormap[i];
+        // }
 
     }
 
-    private int pixelToQuantizationTableIndex(int argb, int precision)
-    {
+    private int pixelToQuantizationTableIndex(int argb, int precision) {
         int result = 0;
         int precision_mask = (1 << precision) - 1;
 
-        for (int i = 0; i < components; i++)
-        {
+        for (int i = 0; i < components; i++) {
             int sample = argb & 0xff;
             argb >>= 8;
 
@@ -121,19 +110,15 @@ public class PaletteFactory
     }
 
     private int getFrequencyTotal(int table[], int mins[], int maxs[],
-            int precision)
-    {
+            int precision) {
         int sum = 0;
 
-        for (int blue = mins[2]; blue <= maxs[2]; blue++)
-        {
+        for (int blue = mins[2]; blue <= maxs[2]; blue++) {
             int b = (blue << (2 * precision));
-            for (int green = mins[1]; green <= maxs[1]; green++)
-            {
+            for (int green = mins[1]; green <= maxs[1]; green++) {
                 int g = (green << (1 * precision));
 
-                for (int red = mins[0]; red <= maxs[0]; red++)
-                {
+                for (int red = mins[0]; red <= maxs[0]; red++) {
                     int index = b | g | red;
 
                     sum += table[index];
@@ -146,31 +131,27 @@ public class PaletteFactory
 
     private DivisionCandidate finishDivision(int table[],
             ColorSpaceSubset subset, int component, int precision, int sum,
-            int slice)
-    {
+            int slice) {
         if (debug)
             subset.dump("trying (" + component + "): ");
 
         int total = subset.total;
 
         if ((slice < subset.mins[component])
-                || (slice >= subset.maxs[component]))
-        {
+                || (slice >= subset.maxs[component])) {
             return null;
         }
 
-        if ((sum < 1) || (sum >= total))
-        {
+        if ((sum < 1) || (sum >= total)) {
             return null;
         }
 
         int remainder = total - sum;
-        if ((remainder < 1) || (remainder >= total))
-        {
+        if ((remainder < 1) || (remainder >= total)) {
             return null;
         }
 
-        //        List result = new ArrayList();
+        // List result = new ArrayList();
 
         int slice_mins[] = new int[subset.mins.length];
         System.arraycopy(subset.mins, 0, slice_mins, 0, subset.mins.length);
@@ -180,13 +161,12 @@ public class PaletteFactory
         slice_maxs[component] = slice;
         slice_mins[component] = slice + 1;
 
-        if (debug)
-        {
+        if (debug) {
             System.out.println("total: " + total);
             System.out.println("first total: " + sum);
             System.out.println("second total: " + (total - sum));
-            //            System.out.println("start: " + start);
-            //            System.out.println("end: " + end);
+            // System.out.println("start: " + start);
+            // System.out.println("end: " + end);
             System.out.println("slice: " + slice);
 
         }
@@ -200,9 +180,8 @@ public class PaletteFactory
 
     }
 
-    private List<DivisionCandidate> divideSubset2(int table[], ColorSpaceSubset subset,
-                                                  int component, int precision)
-    {
+    private List<DivisionCandidate> divideSubset2(int table[],
+            ColorSpaceSubset subset, int component, int precision) {
         if (debug)
             subset.dump("trying (" + component + "): ");
 
@@ -218,8 +197,7 @@ public class PaletteFactory
         int last = 0;
 
         {
-            for (slice1 = subset.mins[component]; slice1 != subset.maxs[component] + 1; slice1++)
-            {
+            for (slice1 = subset.mins[component]; slice1 != subset.maxs[component] + 1; slice1++) {
 
                 slice_mins[component] = slice1;
                 slice_maxs[component] = slice1;
@@ -254,8 +232,7 @@ public class PaletteFactory
     }
 
     private DivisionCandidate divideSubset2(int table[],
-            ColorSpaceSubset subset, int precision)
-    {
+            ColorSpaceSubset subset, int precision) {
         List<DivisionCandidate> dcs = new ArrayList<DivisionCandidate>();
 
         dcs.addAll(divideSubset2(table, subset, 0, precision));
@@ -263,11 +240,10 @@ public class PaletteFactory
         dcs.addAll(divideSubset2(table, subset, 2, precision));
 
         DivisionCandidate best_v = null;
-        //        int best_split
+        // int best_split
         double best_score = Double.MAX_VALUE;
 
-        for (int i = 0; i < dcs.size(); i++)
-        {
+        for (int i = 0; i < dcs.size(); i++) {
             DivisionCandidate dc = dcs.get(i);
 
             ColorSpaceSubset first = dc.dst_a;
@@ -280,13 +256,10 @@ public class PaletteFactory
 
             double score = split;
 
-            if (best_v == null)
-            {
+            if (best_v == null) {
                 best_v = dc;
                 best_score = score;
-            }
-            else if (score < best_score)
-            {
+            } else if (score < best_score) {
                 best_v = dc;
                 best_score = score;
             }
@@ -298,28 +271,24 @@ public class PaletteFactory
 
     public static final int components = 3; // in bits
 
-    private static class DivisionCandidate
-    {
-        //        private final ColorSpaceSubset src;
+    private static class DivisionCandidate {
+        // private final ColorSpaceSubset src;
         private final ColorSpaceSubset dst_a, dst_b;
 
         public DivisionCandidate(ColorSpaceSubset src, ColorSpaceSubset dst_a,
-                ColorSpaceSubset dst_b)
-        {
-            //            this.src = src;
+                ColorSpaceSubset dst_b) {
+            // this.src = src;
             this.dst_a = dst_a;
             this.dst_b = dst_b;
         }
     }
 
-    private List<ColorSpaceSubset> divide(List<ColorSpaceSubset> v, int desired_count, int table[],
-                                          int precision)
-    {
+    private List<ColorSpaceSubset> divide(List<ColorSpaceSubset> v,
+            int desired_count, int table[], int precision) {
         List<ColorSpaceSubset> ignore = new ArrayList<ColorSpaceSubset>();
 
         int count = 0;
-        while (true)
-        {
+        while (true) {
             count++;
 
             if (debug)
@@ -329,27 +298,22 @@ public class PaletteFactory
             int max_area = -1;
             ColorSpaceSubset max_subset = null;
 
-            for (int i = 0; i < v.size(); i++)
-            {
+            for (int i = 0; i < v.size(); i++) {
                 ColorSpaceSubset subset = v.get(i);
                 if (ignore.contains(subset))
                     continue;
                 int area = subset.total;
 
-                if (max_subset == null)
-                {
+                if (max_subset == null) {
                     max_subset = subset;
                     max_area = area;
-                }
-                else if (area > max_area)
-                {
+                } else if (area > max_area) {
                     max_subset = subset;
                     max_area = area;
                 }
             }
 
-            if (max_subset == null)
-            {
+            if (max_subset == null) {
                 return v;
             }
             if (debug)
@@ -359,13 +323,11 @@ public class PaletteFactory
 
                 DivisionCandidate dc = divideSubset2(table, max_subset,
                         precision);
-                if (dc != null)
-                {
+                if (dc != null) {
                     v.remove(max_subset);
                     v.add(dc.dst_a);
                     v.add(dc.dst_b);
-                }
-                else
+                } else
                     ignore.add(max_subset);
             }
 
@@ -373,11 +335,10 @@ public class PaletteFactory
                 return v;
         }
 
-        //        return result;
+        // return result;
     }
 
-    public Palette makePaletteQuantized(BufferedImage src, int max)
-    {
+    public Palette makePaletteQuantized(BufferedImage src, int max) {
         int precision = 6; // in bits
 
         int table_scale = precision * components;
@@ -398,8 +359,7 @@ public class PaletteFactory
         { // step 1: count frequency of colors
 
             for (int y = 0; y < height; y++)
-                for (int x = 0; x < width; x++)
-                {
+                for (int x = 0; x < width; x++) {
                     int argb = src.getRGB(x, y);
 
                     int index = pixelToQuantizationTableIndex(argb, precision);
@@ -409,8 +369,7 @@ public class PaletteFactory
         }
 
         int all_total = getFrequencyTotal(table, all.mins, all.maxs, precision);
-        if (debug)
-        {
+        if (debug) {
             System.out.println("all total: " + all_total);
 
             System.out.println("width * height: " + (width * height));
@@ -418,14 +377,12 @@ public class PaletteFactory
 
         subsets = divide(subsets, 256, table, precision);
 
-        if (debug)
-        {
+        if (debug) {
             System.out.println("subsets: " + subsets.size());
             System.out.println("width*height: " + width * height);
         }
 
-        for (int i = 0; i < subsets.size(); i++)
-        {
+        for (int i = 0; i < subsets.size(); i++) {
             ColorSpaceSubset subset = subsets.get(i);
 
             subset.setAverageRGB(table);
@@ -450,14 +407,12 @@ public class PaletteFactory
         int height = src.getHeight();
 
         for (int y = 0; y < height; y++)
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int argb = src.getRGB(x, y);
                 int rgb = 0xffffff & argb;
 
                 String key = "" + rgb;
-                if (null == map.get(key))
-                {
+                if (null == map.get(key)) {
                     if (rgb_count == max)
                         return null;
 
@@ -471,12 +426,11 @@ public class PaletteFactory
         System.arraycopy(rgbs, 0, result, 0, rgb_count);
         Arrays.sort(result);
 
-        //        return result;
+        // return result;
         return new SimplePalette(result);
     }
 
-    public boolean isGrayscale(BufferedImage src)
-    {
+    public boolean isGrayscale(BufferedImage src) {
         int width = src.getWidth();
         int height = src.getHeight();
 
@@ -485,8 +439,7 @@ public class PaletteFactory
             return true;
 
         for (int y = 0; y < height; y++)
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int argb = src.getRGB(x, y);
 
                 int red = 0xff & (argb >> 16);
@@ -500,13 +453,11 @@ public class PaletteFactory
         return true;
     }
 
-    public boolean hasTransparency(BufferedImage src)
-    {
+    public boolean hasTransparency(BufferedImage src) {
         return hasTransparency(src, 255);
     }
 
-    public boolean hasTransparency(BufferedImage src, int threshold)
-    {
+    public boolean hasTransparency(BufferedImage src, int threshold) {
         int width = src.getWidth();
         int height = src.getHeight();
 
@@ -514,8 +465,7 @@ public class PaletteFactory
             return false;
 
         for (int y = 0; y < height; y++)
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int argb = src.getRGB(x, y);
                 int alpha = 0xff & (argb >> 24);
                 if (alpha < threshold)
@@ -525,21 +475,16 @@ public class PaletteFactory
         return false;
     }
 
-    public int countTrasparentColors(int rgbs[])
-    {
+    public int countTrasparentColors(int rgbs[]) {
         int first = -1;
 
-        for (int i = 0; i < rgbs.length; i++)
-        {
+        for (int i = 0; i < rgbs.length; i++) {
             int rgb = rgbs[i];
             int alpha = 0xff & (rgb >> 24);
-            if (alpha < 0xff)
-            {
-                if (first < 0)
-                {
+            if (alpha < 0xff) {
+                if (first < 0) {
                     first = rgb;
-                }
-                else if (rgb != first)
+                } else if (rgb != first)
                     return 2; // more than one transparent color;
             }
         }
@@ -549,8 +494,7 @@ public class PaletteFactory
         return 1;
     }
 
-    public int countTransparentColors(BufferedImage src)
-    {
+    public int countTransparentColors(BufferedImage src) {
         ColorModel cm = src.getColorModel();
         if (!cm.hasAlpha())
             return 0;
@@ -561,17 +505,13 @@ public class PaletteFactory
         int first = -1;
 
         for (int y = 0; y < height; y++)
-            for (int x = 0; x < width; x++)
-            {
+            for (int x = 0; x < width; x++) {
                 int rgb = src.getRGB(x, y);
                 int alpha = 0xff & (rgb >> 24);
-                if (alpha < 0xff)
-                {
-                    if (first < 0)
-                    {
+                if (alpha < 0xff) {
+                    if (first < 0) {
                         first = rgb;
-                    }
-                    else if (rgb != first)
+                    } else if (rgb != first)
                         return 2; // more than one transparent color;
                 }
             }
@@ -581,4 +521,4 @@ public class PaletteFactory
         return 1;
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/QuantizedPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/QuantizedPalette.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/QuantizedPalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/QuantizedPalette.java Sat May 26 21:19:03 2012
@@ -20,29 +20,25 @@ import java.util.List;
 
 import org.apache.commons.imaging.ImageWriteException;
 
-public class QuantizedPalette extends Palette
-{
+public class QuantizedPalette extends Palette {
     private final int precision;
     private final List<ColorSpaceSubset> subsets;
     private final ColorSpaceSubset straight[];
 
-    public QuantizedPalette(List<ColorSpaceSubset> subsets, int precision)
-    {
+    public QuantizedPalette(List<ColorSpaceSubset> subsets, int precision) {
         this.subsets = subsets;
         this.precision = precision;
 
         {
             straight = new ColorSpaceSubset[1 << (precision * 3)];
 
-            for (int i = 0; i < subsets.size(); i++)
-            {
+            for (int i = 0; i < subsets.size(); i++) {
                 ColorSpaceSubset subset = subsets.get(i);
                 subset.setIndex(i);
 
                 for (int u = subset.mins[0]; u <= subset.maxs[0]; u++)
                     for (int j = subset.mins[1]; j <= subset.maxs[1]; j++)
-                        for (int k = subset.mins[2]; k <= subset.maxs[2]; k++)
-                        {
+                        for (int k = subset.mins[2]; k <= subset.maxs[2]; k++) {
                             int index = (u << (precision * 2))
                                     | (j << (precision * 1))
                                     | (k << (precision * 0));
@@ -54,8 +50,7 @@ public class QuantizedPalette extends Pa
     }
 
     @Override
-    public int getPaletteIndex(int rgb) throws ImageWriteException
-    {
+    public int getPaletteIndex(int rgb) throws ImageWriteException {
         int precisionMask = (1 << precision) - 1;
 
         int index = ((rgb >> (24 - 3 * precision)) & (precisionMask << (precision << 1)))
@@ -66,25 +61,22 @@ public class QuantizedPalette extends Pa
     }
 
     @Override
-    public void dump()
-    {
-        //        System.out.println("ColorSpaceSubset.compares: "
-        //                + ColorSpaceSubset.compares);
-        //        System.out.println("converted: " + converted);
-        //        System.out.println("avg. distance: " + (distance / converted));
+    public void dump() {
+        // System.out.println("ColorSpaceSubset.compares: "
+        // + ColorSpaceSubset.compares);
+        // System.out.println("converted: " + converted);
+        // System.out.println("avg. distance: " + (distance / converted));
     }
 
     @Override
-    public int getEntry(int index)
-    {
+    public int getEntry(int index) {
         ColorSpaceSubset subset = subsets.get(index);
         return subset.rgb;
     }
 
     @Override
-    public int length()
-    {
+    public int length() {
         return subsets.size();
 
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/SimplePalette.java Sat May 26 21:19:03 2012
@@ -18,38 +18,32 @@ package org.apache.commons.imaging.palet
 
 import org.apache.commons.imaging.util.Debug;
 
-public class SimplePalette extends Palette
-{
+public class SimplePalette extends Palette {
     private final int palette[];
 
-    public SimplePalette(int palette[])
-    {
+    public SimplePalette(int palette[]) {
         this.palette = palette;
     }
 
     @Override
-    public int getPaletteIndex(int rgb)
-    {
+    public int getPaletteIndex(int rgb) {
         return getPaletteIndex(palette, rgb);
     }
 
     @Override
-    public int getEntry(int index)
-    {
+    public int getEntry(int index) {
         return palette[index];
-        //            return getPaletteIndex(palette, rgb);
+        // return getPaletteIndex(palette, rgb);
     }
 
-    private int getPaletteIndex(int palette[], int argb)
-    {
+    private int getPaletteIndex(int palette[], int argb) {
 
-        //        Debug.debug("getPaletteIndex argb", argb + " ("
-        //                + Integer.toHexString(argb) + ")");
+        // Debug.debug("getPaletteIndex argb", argb + " ("
+        // + Integer.toHexString(argb) + ")");
 
-        for (int i = 0; i < palette.length; i++)
-        {
-            //            Debug.debug("\t" + "palette[" + i + "]", palette[i] + " ("
-            //                    + Integer.toHexString(palette[i]) + ")");
+        for (int i = 0; i < palette.length; i++) {
+            // Debug.debug("\t" + "palette[" + i + "]", palette[i] + " ("
+            // + Integer.toHexString(palette[i]) + ")");
 
             if (palette[i] == argb)
                 return i;
@@ -59,18 +53,15 @@ public class SimplePalette extends Palet
     }
 
     @Override
-    public void dump()
-    {
-        for (int i = 0; i < palette.length; i++)
-        {
+    public void dump() {
+        for (int i = 0; i < palette.length; i++) {
             Debug.debug("\t" + "palette[" + i + "]", palette[i] + " (0x"
                     + Integer.toHexString(palette[i]) + ")");
         }
     }
 
     @Override
-    public int length()
-    {
+    public int length() {
         return palette.length;
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingInputStream.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingInputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingInputStream.java Sat May 26 21:19:03 2012
@@ -21,38 +21,32 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-public class CachingInputStream extends InputStream
-{
+public class CachingInputStream extends InputStream {
     private final InputStream is;
     private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-    public CachingInputStream(InputStream is)
-    {
+    public CachingInputStream(InputStream is) {
         this.is = is;
     }
 
-    public byte[] getCache()
-    {
+    public byte[] getCache() {
         return baos.toByteArray();
     }
 
     @Override
-    public int read() throws IOException
-    {
+    public int read() throws IOException {
         int result = is.read();
         baos.write(result);
         return result;
     }
 
     @Override
-    public int available() throws IOException
-    {
+    public int available() throws IOException {
         return is.available();
     }
 
     @Override
-    public void close() throws IOException
-    {
+    public void close() throws IOException {
         is.close();
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingOutputStream.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingOutputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/CachingOutputStream.java Sat May 26 21:19:03 2012
@@ -21,37 +21,31 @@ import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class CachingOutputStream extends OutputStream
-{
+public class CachingOutputStream extends OutputStream {
     private final OutputStream os;
     private final ByteArrayOutputStream baos = new ByteArrayOutputStream();
 
-    public CachingOutputStream(OutputStream os)
-    {
+    public CachingOutputStream(OutputStream os) {
         this.os = os;
     }
 
     @Override
-    public void write(int b) throws IOException
-    {
+    public void write(int b) throws IOException {
         os.write(b);
         baos.write(b);
     }
 
-    public byte[] getCache()
-    {
+    public byte[] getCache() {
         return baos.toByteArray();
     }
 
     @Override
-    public void close() throws IOException
-    {
+    public void close() throws IOException {
         os.close();
     }
 
     @Override
-    public void flush() throws IOException
-    {
+    public void flush() throws IOException {
         os.flush();
     }
 

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/Debug.java Sat May 26 21:19:03 2012
@@ -30,70 +30,58 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
-public final class Debug
-{
+public final class Debug {
 
     private static final boolean DEBUG = false;
-    
-    public static void debug(String message)
-    {
+
+    public static void debug(String message) {
         if (DEBUG) {
             System.out.println(message);
         }
     }
 
-    public static void debug(Object o)
-    {
+    public static void debug(Object o) {
         if (DEBUG) {
             System.out.println(o == null ? "null" : o.toString());
         }
     }
 
-    public static String getDebug(String message)
-    {
+    public static String getDebug(String message) {
         return message;
     }
 
-    public static void debug()
-    {
+    public static void debug() {
         newline();
     }
 
-    public static void newline()
-    {
+    public static void newline() {
         if (DEBUG) {
             System.out.print(newline);
         }
     }
 
-    public static String getDebug(String message, int value)
-    {
+    public static String getDebug(String message, int value) {
         return getDebug(message + ": " + (value));
     }
 
-    public static String getDebug(String message, double value)
-    {
+    public static String getDebug(String message, double value) {
         return getDebug(message + ": " + (value));
     }
 
-    public static String getDebug(String message, String value)
-    {
+    public static String getDebug(String message, String value) {
         return getDebug(message + " " + value);
     }
 
-    public static String getDebug(String message, long value)
-    {
+    public static String getDebug(String message, long value) {
         return getDebug(message + " " + Long.toString(value));
     }
 
-    public static String getDebug(String message, int v[])
-    {
+    public static String getDebug(String message, int v[]) {
         StringBuffer result = new StringBuffer();
 
         if (v == null)
             result.append(message + " (" + null + ")" + newline);
-        else
-        {
+        else {
             result.append(message + " (" + v.length + ")" + newline);
             for (int i = 0; i < v.length; i++)
                 result.append("\t" + v[i] + newline);
@@ -102,24 +90,20 @@ public final class Debug
         return result.toString();
     }
 
-    public static String getDebug(String message, byte v[])
-    {
+    public static String getDebug(String message, byte v[]) {
         final int max = 250;
         return getDebug(message, v, max);
     }
 
-    public static String getDebug(String message, byte v[], int max)
-    {
+    public static String getDebug(String message, byte v[], int max) {
 
         StringBuffer result = new StringBuffer();
 
         if (v == null)
             result.append(message + " (" + null + ")" + newline);
-        else
-        {
+        else {
             result.append(message + " (" + v.length + ")" + newline);
-            for (int i = 0; i < max && i < v.length; i++)
-            {
+            for (int i = 0; i < max && i < v.length; i++) {
                 int b = 0xff & v[i];
 
                 char c;
@@ -139,14 +123,12 @@ public final class Debug
         return result.toString();
     }
 
-    public static String getDebug(String message, char v[])
-    {
+    public static String getDebug(String message, char v[]) {
         StringBuffer result = new StringBuffer();
 
         if (v == null)
             result.append(getDebug(message + " (" + null + ")") + newline);
-        else
-        {
+        else {
             result.append(getDebug(message + " (" + v.length + ")") + newline);
             for (int i = 0; i < v.length; i++)
                 result.append(getDebug("\t" + v[i] + " (" + (0xff & v[i]))
@@ -158,8 +140,7 @@ public final class Debug
 
     private static long counter = 0;
 
-    public static String getDebug(String message, java.util.List<?> v)
-    {
+    public static String getDebug(String message, java.util.List<?> v) {
         StringBuffer result = new StringBuffer();
 
         String suffix = " [" + counter++ + "]";
@@ -174,13 +155,11 @@ public final class Debug
         return result.toString();
     }
 
-    public static void debug(String message, Map map)
-    {
+    public static void debug(String message, Map map) {
         debug(getDebug(message, map));
     }
 
-    public static String getDebug(String message, Map map)
-    {
+    public static String getDebug(String message, Map map) {
         StringBuffer result = new StringBuffer();
 
         if (map == null)
@@ -188,8 +167,7 @@ public final class Debug
 
         List keys = new ArrayList(map.keySet());
         result.append(getDebug(message + " map: " + keys.size()) + newline);
-        for (int i = 0; i < keys.size(); i++)
-        {
+        for (int i = 0; i < keys.size(); i++) {
             Object key = keys.get(i);
             Object value = map.get(key);
             result.append(getDebug("\t" + i + ": '" + key + "' -> '" + value
@@ -202,36 +180,30 @@ public final class Debug
         return result.toString();
     }
 
-    public static boolean compare(String prefix, Map a, Map b)
-    {
+    public static boolean compare(String prefix, Map a, Map b) {
         return compare(prefix, a, b, null, null);
     }
 
-    //    public static String newline = System.getProperty("line.separator");
+    // public static String newline = System.getProperty("line.separator");
     public static final String newline = "\r\n";
 
-    private static void log(StringBuffer buffer, String s)
-    {
+    private static void log(StringBuffer buffer, String s) {
         Debug.debug(s);
         if (buffer != null)
             buffer.append(s + newline);
     }
 
-    public static boolean compare(String prefix, Map a, Map b,
-            List ignore, StringBuffer buffer)
-    {
-        if ((a == null) && (b == null))
-        {
+    public static boolean compare(String prefix, Map a, Map b, List ignore,
+            StringBuffer buffer) {
+        if ((a == null) && (b == null)) {
             log(buffer, prefix + " both maps null");
             return true;
         }
-        if (a == null)
-        {
+        if (a == null) {
             log(buffer, prefix + " map a: null, map b: map");
             return false;
         }
-        if (b == null)
-        {
+        if (b == null) {
             log(buffer, prefix + " map a: map, map b: null");
             return false;
         }
@@ -239,37 +211,30 @@ public final class Debug
         List keys_a = new ArrayList(a.keySet());
         List keys_b = new ArrayList(b.keySet());
 
-        if (ignore != null)
-        {
+        if (ignore != null) {
             keys_a.removeAll(ignore);
             keys_b.removeAll(ignore);
         }
 
         boolean result = true;
 
-        for (int i = 0; i < keys_a.size(); i++)
-        {
+        for (int i = 0; i < keys_a.size(); i++) {
             Object key = keys_a.get(i);
-            if (!keys_b.contains(key))
-            {
+            if (!keys_b.contains(key)) {
                 log(buffer, prefix + "b is missing key '" + key + "' from a");
                 result = false;
-            }
-            else
-            {
+            } else {
                 keys_b.remove(key);
                 Object value_a = a.get(key);
                 Object value_b = b.get(key);
-                if (!value_a.equals(value_b))
-                {
+                if (!value_a.equals(value_b)) {
                     log(buffer, prefix + "key(" + key + ") value a: " + value_a
                             + ") !=  b: " + value_b + ")");
                     result = false;
                 }
             }
         }
-        for (int i = 0; i < keys_b.size(); i++)
-        {
+        for (int i = 0; i < keys_b.size(); i++) {
             Object key = keys_b.get(i);
 
             log(buffer, prefix + "a is missing key '" + key + "' from b");
@@ -282,8 +247,7 @@ public final class Debug
         return result;
     }
 
-    private static final String byteQuadToString(int bytequad)
-    {
+    private static final String byteQuadToString(int bytequad) {
         byte b1 = (byte) ((bytequad >> 24) & 0xff);
         byte b2 = (byte) ((bytequad >> 16) & 0xff);
         byte b3 = (byte) ((bytequad >> 8) & 0xff);
@@ -293,11 +257,9 @@ public final class Debug
         char c2 = (char) b2;
         char c3 = (char) b3;
         char c4 = (char) b4;
-        //        return new String(new char[] { c1, c2, c3, c4 });
+        // return new String(new char[] { c1, c2, c3, c4 });
         StringBuffer fStringBuffer = new StringBuffer();
-        fStringBuffer.append(new String(new char[]{
-                c1, c2, c3, c4
-        }));
+        fStringBuffer.append(new String(new char[] { c1, c2, c3, c4 }));
         fStringBuffer.append(" bytequad: " + bytequad);
         fStringBuffer.append(" b1: " + b1);
         fStringBuffer.append(" b2: " + b2);
@@ -307,16 +269,14 @@ public final class Debug
         return fStringBuffer.toString();
     }
 
-    public static String getDebug(String message, ICC_Profile value)
-    {
+    public static String getDebug(String message, ICC_Profile value) {
 
         StringBuffer result = new StringBuffer();
 
         result.append(getDebug("ICC_Profile " + message + ": "
                 + ((value == null) ? "null" : value.toString()))
                 + newline);
-        if (value != null)
-        {
+        if (value != null) {
             result.append(getDebug("\t getProfileClass: "
                     + byteQuadToString(value.getProfileClass()))
                     + newline);
@@ -332,32 +292,27 @@ public final class Debug
 
     }
 
-    public static String getDebug(String message, boolean value)
-    {
+    public static String getDebug(String message, boolean value) {
         return getDebug(message + " " + ((value) ? ("true") : ("false")));
     }
 
-    public static String getDebug(String message, File file)
-    {
+    public static String getDebug(String message, File file) {
         return getDebug(message + ": "
                 + ((file == null) ? "null" : file.getPath()));
     }
 
-    public static String getDebug(String message, Date value)
-    {
+    public static String getDebug(String message, Date value) {
         DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
         return getDebug(message, (value == null) ? "null" : df.format(value));
     }
 
-    public static String getDebug(String message, Calendar value)
-    {
+    public static String getDebug(String message, Calendar value) {
         DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
-        return getDebug(message, (value == null) ? "null" : df.format(value
-                .getTime()));
+        return getDebug(message,
+                (value == null) ? "null" : df.format(value.getTime()));
     }
 
-    public static void debug(String message, Object value)
-    {
+    public static void debug(String message, Object value) {
         if (value == null)
             debug(message, "null");
         else if (value instanceof char[])
@@ -372,8 +327,8 @@ public final class Debug
             debug(message, (java.util.List) value);
         else if (value instanceof Map)
             debug(message, (Map) value);
-        //        else if (value instanceof Object)
-        //            debug(message, (Object) value);
+        // else if (value instanceof Object)
+        // debug(message, (Object) value);
         else if (value instanceof ICC_Profile)
             debug(message, (ICC_Profile) value);
         else if (value instanceof File)
@@ -386,8 +341,7 @@ public final class Debug
             debug(message, value.toString());
     }
 
-    public static void debug(String message, Object value[])
-    {
+    public static void debug(String message, Object value[]) {
         if (value == null) {
             debug(message, "null");
         } else {
@@ -403,8 +357,7 @@ public final class Debug
         debug();
     }
 
-    public static String getDebug(String message, Object value)
-    {
+    public static String getDebug(String message, Object value) {
         if (value == null)
             return getDebug(message, "null");
         else if (value instanceof Calendar)
@@ -419,7 +372,8 @@ public final class Debug
             return getDebug(message, (Map) value);
         else if (value instanceof Map)
             return getDebug(message, (Map) value); //
-        //        else if (value instanceof Object) // getDebug(message, (Object) value);
+        // else if (value instanceof Object) // getDebug(message, (Object)
+        // value);
         else if (value instanceof String)
             return getDebug(message, (String) value);
         else if (value instanceof byte[])
@@ -434,8 +388,7 @@ public final class Debug
             return getDebug(message, value.toString());
     }
 
-    public static String getType(Object value)
-    {
+    public static String getType(Object value) {
         if (value == null)
             return "null";
         else if (value instanceof Object[])
@@ -460,8 +413,7 @@ public final class Debug
             return value.getClass().getName();
     }
 
-    public static boolean isArray(Object value)
-    {
+    public static boolean isArray(Object value) {
         if (value == null)
             return false;
         else if (value instanceof Object[])
@@ -486,8 +438,7 @@ public final class Debug
             return false;
     }
 
-    public static String getDebug(String message, Object value[])
-    {
+    public static String getDebug(String message, Object value[]) {
         StringBuffer result = new StringBuffer();
 
         if (value == null) {
@@ -507,65 +458,54 @@ public final class Debug
         return result.toString();
     }
 
-    public static String getDebug(Class fClass, Throwable e)
-    {
+    public static String getDebug(Class fClass, Throwable e) {
         return getDebug(fClass == null ? "[Unknown]" : fClass.getName(), e);
     }
 
-    public static void debug(Class fClass, Throwable e)
-    {
+    public static void debug(Class fClass, Throwable e) {
         debug(fClass.getName(), e);
     }
 
-    public static void debug(String message, boolean value)
-    {
+    public static void debug(String message, boolean value) {
         debug(message + " " + ((value) ? ("true") : ("false")));
     }
 
-    public static void debug(String message, byte v[])
-    {
+    public static void debug(String message, byte v[]) {
         debug(getDebug(message, v));
     }
 
-    public static void debug(String message, char v[])
-    {
+    public static void debug(String message, char v[]) {
         debug(getDebug(message, v));
     }
 
-    public static void debug(String message, Calendar value)
-    {
+    public static void debug(String message, Calendar value) {
         DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
         debug(message, (value == null) ? "null" : df.format(value.getTime()));
     }
 
-    public static void debug(String message, Date value)
-    {
+    public static void debug(String message, Date value) {
         DateFormat df = new SimpleDateFormat("MM/dd/yyyy HH:mm:ss");
         debug(message, (value == null) ? "null" : df.format(value));
     }
 
-    public static void debug(String message, double value)
-    {
+    public static void debug(String message, double value) {
         debug(message + ": " + (value));
     }
 
-    public static void debug(String message, File file)
-    {
+    public static void debug(String message, File file) {
         debug(message + ": " + ((file == null) ? "null" : file.getPath()));
     }
 
-    //    public static void debug(String message, Object value)
-    //    {
-    //        debug("Unknown Object " + message + ": "
-    //                + ((value == null) ? "null" : value.toString()));
-    //    }
+    // public static void debug(String message, Object value)
+    // {
+    // debug("Unknown Object " + message + ": "
+    // + ((value == null) ? "null" : value.toString()));
+    // }
 
-    public static void debug(String message, ICC_Profile value)
-    {
+    public static void debug(String message, ICC_Profile value) {
         debug("ICC_Profile " + message + ": "
                 + ((value == null) ? "null" : value.toString()));
-        if (value != null)
-        {
+        if (value != null) {
             debug("\t getProfileClass: "
                     + byteQuadToString(value.getProfileClass()));
             debug("\t getPCSType: " + byteQuadToString(value.getPCSType()));
@@ -574,23 +514,19 @@ public final class Debug
         }
     }
 
-    public static void debug(String message, int value)
-    {
+    public static void debug(String message, int value) {
         debug(message + ": " + (value));
     }
 
-    public static void debug(String message, int v[])
-    {
+    public static void debug(String message, int v[]) {
         debug(getDebug(message, v));
     }
 
-    public static void debug(String message, byte v[], int max)
-    {
+    public static void debug(String message, byte v[], int max) {
         debug(getDebug(message, v, max));
     }
 
-    public static void debug(String message, java.util.List v)
-    {
+    public static void debug(String message, java.util.List v) {
         String suffix = " [" + counter++ + "]";
 
         debug(message + " (" + v.size() + ")" + suffix);
@@ -599,64 +535,52 @@ public final class Debug
         debug();
     }
 
-    public static void debug(String message, long value)
-    {
+    public static void debug(String message, long value) {
         debug(message + " " + Long.toString(value));
     }
 
-    public static void debug(String prefix, Point p)
-    {
+    public static void debug(String prefix, Point p) {
         System.out.println(prefix + ": "
                 + ((p == null) ? "null" : (p.x + ", " + p.y)));
     }
 
-    public static void debug(String prefix, Rectangle r)
-    {
+    public static void debug(String prefix, Rectangle r) {
         debug(getDebug(prefix, r));
     }
 
-    public static void debug(String message, String value)
-    {
+    public static void debug(String message, String value) {
         debug(message + " " + value);
     }
 
-    public static void debug(String message, Throwable e)
-    {
+    public static void debug(String message, Throwable e) {
         debug(getDebug(message, e));
     }
 
-    public static void debug(Throwable e)
-    {
+    public static void debug(Throwable e) {
         debug(getDebug(e));
     }
 
-    public static void debug(Throwable e, int value)
-    {
+    public static void debug(Throwable e, int value) {
         debug(getDebug(e, value));
     }
 
-    public static void dumpStack()
-    {
+    public static void dumpStack() {
         debug(getStackTrace(new Exception("Stack trace"), -1, 1));
     }
 
-    public static void dumpStack(int limit)
-    {
+    public static void dumpStack(int limit) {
         debug(getStackTrace(new Exception("Stack trace"), limit, 1));
     }
 
-    public static String getDebug(String message, Throwable e)
-    {
+    public static String getDebug(String message, Throwable e) {
         return message + newline + getDebug(e);
     }
 
-    public static String getDebug(Throwable e)
-    {
+    public static String getDebug(Throwable e) {
         return getDebug(e, -1);
     }
 
-    public static String getDebug(Throwable e, int max)
-    {
+    public static String getDebug(Throwable e, int max) {
         StringBuffer result = new StringBuffer();
 
         final SimpleDateFormat timestamp = new SimpleDateFormat(
@@ -675,32 +599,26 @@ public final class Debug
 
         result.append("Caught here:" + newline);
         result.append(getStackTrace(new Exception(), max, 1));
-        //        Debug.dumpStack();
+        // Debug.dumpStack();
         result.append(newline);
         return result.toString();
     }
 
-    public static String getStackTrace(Throwable e)
-    {
+    public static String getStackTrace(Throwable e) {
         return getStackTrace(e, -1);
     }
 
-    public static String getStackTrace(Throwable e, int limit)
-    {
+    public static String getStackTrace(Throwable e, int limit) {
         return getStackTrace(e, limit, 0);
     }
 
-    public static String getStackTrace(Throwable e, int limit, int skip)
-    {
+    public static String getStackTrace(Throwable e, int limit, int skip) {
         StringBuffer result = new StringBuffer();
 
-        if (e != null)
-        {
+        if (e != null) {
             StackTraceElement stes[] = e.getStackTrace();
-            if (stes != null)
-            {
-                for (int i = skip; i < stes.length && (limit < 0 || i < limit); i++)
-                {
+            if (stes != null) {
+                for (int i = skip; i < stes.length && (limit < 0 || i < limit); i++) {
                     StackTraceElement ste = stes[i];
 
                     result.append("\tat " + ste.getClassName() + "."
@@ -711,15 +629,14 @@ public final class Debug
                     result.append("\t..." + newline);
             }
 
-            //            e.printStackTrace(System.out);
+            // e.printStackTrace(System.out);
             result.append(newline);
         }
 
         return result.toString();
     }
 
-    public static void debugByteQuad(String message, int i)
-    {
+    public static void debugByteQuad(String message, int i) {
         int alpha = (i >> 24) & 0xff;
         int red = (i >> 16) & 0xff;
         int green = (i >> 8) & 0xff;
@@ -729,8 +646,7 @@ public final class Debug
                 + red + ", " + "green: " + green + ", " + "blue: " + blue);
     }
 
-    public static void debugIPQuad(String message, int i)
-    {
+    public static void debugIPQuad(String message, int i) {
         int b1 = (i >> 24) & 0xff;
         int b2 = (i >> 16) & 0xff;
         int b3 = (i >> 8) & 0xff;
@@ -740,15 +656,12 @@ public final class Debug
                 + ", " + "b3: " + b3 + ", " + "b4: " + b4);
     }
 
-    public static void debugIPQuad(String message, byte bytes[])
-    {
+    public static void debugIPQuad(String message, byte bytes[]) {
         System.out.print(message + ": ");
         if (bytes == null)
             System.out.print("null");
-        else
-        {
-            for (int i = 0; i < bytes.length; i++)
-            {
+        else {
+            for (int i = 0; i < bytes.length; i++) {
                 if (i > 0)
                     System.out.print(".");
                 System.out.print(0xff & bytes[i]);
@@ -757,13 +670,11 @@ public final class Debug
         System.out.println();
     }
 
-    public static String getDebug(String prefix, Dimension r)
-    {
+    public static String getDebug(String prefix, Dimension r) {
         String s_ar1 = "null";
         String s_ar2 = "null";
 
-        if (r != null)
-        {
+        if (r != null) {
             double aspect_ratio = ((double) r.width) / ((double) r.height);
             double aspect_ratio2 = 1.0 / aspect_ratio;
 
@@ -781,18 +692,15 @@ public final class Debug
                 + " aspect_ratio: " + s_ar1 + " (" + s_ar2 + ")");
     }
 
-    public static void debug(String prefix, Dimension r)
-    {
+    public static void debug(String prefix, Dimension r) {
         debug(getDebug(prefix, r));
     }
 
-    public static String getDebug(String prefix, Rectangle r)
-    {
+    public static String getDebug(String prefix, Rectangle r) {
         String s_ar1 = "null";
         String s_ar2 = "null";
 
-        if (r != null)
-        {
+        if (r != null) {
             double aspect_ratio = ((double) r.width) / ((double) r.height);
             double aspect_ratio2 = 1.0 / aspect_ratio;
 
@@ -812,111 +720,87 @@ public final class Debug
                 + s_ar2 + ")");
     }
 
-    public static String getDebug(String prefix, Point p)
-    {
+    public static String getDebug(String prefix, Point p) {
         return (prefix + ": " + ((p == null) ? "null" : (p.x + ", " + p.y)));
     }
 
-    public static void dump(String prefix, Object value)
-    {
+    public static void dump(String prefix, Object value) {
         if (value == null)
             debug(prefix, "null");
-        else if (value instanceof Object[])
-        {
+        else if (value instanceof Object[]) {
             Object[] array = (Object[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 dump(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof int[])
-        {
+        } else if (value instanceof int[]) {
             int[] array = (int[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof char[])
-        {
+        } else if (value instanceof char[]) {
             char[] array = (char[]) value;
             debug(prefix, "[" + new String(array) + "]");
-        }
-        else if (value instanceof long[])
-        {
+        } else if (value instanceof long[]) {
             long[] array = (long[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof boolean[])
-        {
+        } else if (value instanceof boolean[]) {
             boolean[] array = (boolean[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof byte[])
-        {
+        } else if (value instanceof byte[]) {
             byte[] array = (byte[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof float[])
-        {
+        } else if (value instanceof float[]) {
             float[] array = (float[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof double[])
-        {
+        } else if (value instanceof double[]) {
             double[] array = (double[]) value;
             debug(prefix, array);
             for (int i = 0; i < array.length; i++)
                 debug(prefix + "\t" + i + ": ", array[i]);
-        }
-        else if (value instanceof java.util.List)
-        {
+        } else if (value instanceof java.util.List) {
             java.util.List list = (java.util.List) value;
             debug(prefix, "list");
             for (int i = 0; i < list.size(); i++)
                 dump(prefix + "\t" + "list: " + i + ": ", list.get(i));
-        }
-        else if (value instanceof Map)
-        {
+        } else if (value instanceof Map) {
             java.util.Map map = (java.util.Map) value;
             debug(prefix, "map");
             List keys = new ArrayList(map.keySet());
             Collections.sort(keys);
-            for (int i = 0; i < keys.size(); i++)
-            {
+            for (int i = 0; i < keys.size(); i++) {
                 Object key = keys.get(i);
                 dump(prefix + "\t" + "map: " + key + " -> ", map.get(key));
             }
         }
-        //        else if (value instanceof String)
-        //            debug(prefix, value);
-        else
-        {
+        // else if (value instanceof String)
+        // debug(prefix, value);
+        else {
             debug(prefix, value.toString());
             debug(prefix + "\t", value.getClass().getName());
         }
     }
 
-    public static final void purgeMemory()
-    {
-//        try
-//        {
-//            //            Thread.sleep(50);
-//            System.runFinalization();
-//            Thread.sleep(50);
-//            System.gc();
-//            Thread.sleep(50);
-//        }
-//        catch (Throwable e)
-//        {
-//            Debug.debug(e);
-//        }
+    public static final void purgeMemory() {
+        // try
+        // {
+        // // Thread.sleep(50);
+        // System.runFinalization();
+        // Thread.sleep(50);
+        // System.gc();
+        // Thread.sleep(50);
+        // }
+        // catch (Throwable e)
+        // {
+        // Debug.debug(e);
+        // }
     }
 
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugInputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugInputStream.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugInputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugInputStream.java Sat May 26 21:19:03 2012
@@ -20,47 +20,40 @@ package org.apache.commons.imaging.util;
 import java.io.IOException;
 import java.io.InputStream;
 
-public class DebugInputStream extends InputStream
-{
+public class DebugInputStream extends InputStream {
     private final InputStream is;
 
-    public DebugInputStream(InputStream is)
-    {
+    public DebugInputStream(InputStream is) {
         this.is = is;
     }
 
     private long bytes_read = 0;
 
     @Override
-    public int read() throws IOException
-    {
+    public int read() throws IOException {
         int result = is.read();
         bytes_read++;
         return result;
     }
 
     @Override
-    public long skip(long n) throws IOException
-    {
+    public long skip(long n) throws IOException {
         long result = is.skip(n);
         bytes_read += n;
         return result;
     }
 
     @Override
-    public int available() throws IOException
-    {
+    public int available() throws IOException {
         return is.available();
     }
 
     @Override
-    public void close() throws IOException
-    {
+    public void close() throws IOException {
         is.close();
     }
 
-    public long getBytesRead()
-    {
+    public long getBytesRead() {
         return bytes_read;
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugOutputStream.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugOutputStream.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugOutputStream.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/DebugOutputStream.java Sat May 26 21:19:03 2012
@@ -20,52 +20,44 @@ package org.apache.commons.imaging.util;
 import java.io.IOException;
 import java.io.OutputStream;
 
-public class DebugOutputStream extends OutputStream
-{
+public class DebugOutputStream extends OutputStream {
     private final OutputStream os;
     private long count = 0;
 
-    public DebugOutputStream(final OutputStream os)
-    {
+    public DebugOutputStream(final OutputStream os) {
         super();
         this.os = os;
     }
 
     @Override
-    public void write(int b) throws IOException
-    {
+    public void write(int b) throws IOException {
         os.write(b);
         count++;
     }
 
     @Override
-    public void write(byte b[]) throws IOException
-    {
+    public void write(byte b[]) throws IOException {
         os.write(b);
         count += b.length;
     }
 
     @Override
-    public void write(byte b[], int off, int len) throws IOException
-    {
+    public void write(byte b[], int off, int len) throws IOException {
         os.write(b, off, len);
         count += len;
     }
 
     @Override
-    public void flush() throws IOException
-    {
+    public void flush() throws IOException {
         os.flush();
     }
 
     @Override
-    public void close() throws IOException
-    {
+    public void close() throws IOException {
         os.close();
     }
 
-    public long count()
-    {
+    public long count() {
         return count;
     }
 }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/util/IoUtils.java Sat May 26 21:19:03 2012
@@ -30,52 +30,44 @@ import java.nio.channels.FileChannel;
 
 import org.apache.commons.imaging.ImagingConstants;
 
-public class IoUtils implements ImagingConstants
-{
+public class IoUtils implements ImagingConstants {
     /**
      * This class should never be instantiated.
      */
-    private IoUtils()
-    {
+    private IoUtils() {
     }
 
     /**
      * Reads an InputStream to the end.
      * <p>
-     *
+     * 
      * @param is
      *            The InputStream to read.
      * @return A byte array containing the contents of the InputStream
      * @see InputStream
      */
-    public static byte[] getInputStreamBytes(InputStream is) throws IOException
-    {
+    public static byte[] getInputStreamBytes(InputStream is) throws IOException {
         ByteArrayOutputStream os = null;
 
-        try
-        {
+        try {
             os = new ByteArrayOutputStream(4096);
 
             is = new BufferedInputStream(is);
 
             int count;
             byte[] buffer = new byte[4096];
-            while ((count = is.read(buffer, 0, 4096)) > 0)
-            {
+            while ((count = is.read(buffer, 0, 4096)) > 0) {
                 os.write(buffer, 0, count);
             }
 
             os.flush();
 
             return os.toByteArray();
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (os != null)
                     os.close();
-            } catch (IOException e)
-            {
+            } catch (IOException e) {
                 Debug.debug(e);
             }
         }
@@ -84,51 +76,41 @@ public class IoUtils implements ImagingC
     /**
      * Reads a File into memory.
      * <p>
-     *
+     * 
      * @param file
      *            The File to read.
      * @return A byte array containing the contents of the File
      * @see InputStream
      */
-    public static byte[] getFileBytes(File file) throws IOException
-    {
+    public static byte[] getFileBytes(File file) throws IOException {
         InputStream is = null;
 
-        try
-        {
+        try {
             is = new FileInputStream(file);
 
             return getInputStreamBytes(is);
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            } catch (IOException e)
-            {
+            } catch (IOException e) {
                 Debug.debug(e);
             }
         }
     }
 
-    public static void writeToFile(byte[] src, File file) throws IOException
-    {
+    public static void writeToFile(byte[] src, File file) throws IOException {
         ByteArrayInputStream stream = null;
 
-        try
-        {
+        try {
             stream = new ByteArrayInputStream(src);
 
             putInputStreamToFile(stream, file);
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (stream != null)
                     stream.close();
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
 
             }
@@ -136,47 +118,40 @@ public class IoUtils implements ImagingC
     }
 
     public static void putInputStreamToFile(InputStream src, File file)
-            throws IOException
-    {
+            throws IOException {
         FileOutputStream stream = null;
 
-        try
-        {
+        try {
             if (file.getParentFile() != null && !file.getParentFile().exists()) {
                 if (!file.getParentFile().mkdirs()) {
-                    throw new IOException("Could not create directory for file " + file);
+                    throw new IOException(
+                            "Could not create directory for file " + file);
                 }
             }
             stream = new FileOutputStream(file);
 
             copyStreamToStream(src, stream);
-        } finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (stream != null)
                     stream.close();
-            } catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
         }
     }
 
     public static void copyStreamToStream(InputStream src, OutputStream dst)
-            throws IOException
-    {
+            throws IOException {
         copyStreamToStream(src, dst, true);
     }
 
     public static void copyStreamToStream(InputStream src, OutputStream dst,
-            boolean close_streams) throws IOException
-    {
+            boolean close_streams) throws IOException {
         BufferedInputStream bis = null;
         BufferedOutputStream bos = null;
 
-        try
-        {
+        try {
             bis = new BufferedInputStream(src);
             bos = new BufferedOutputStream(dst);
 
@@ -186,24 +161,18 @@ public class IoUtils implements ImagingC
                 dst.write(buffer, 0, count);
 
             bos.flush();
-        } finally
-        {
-            if (close_streams)
-            {
-                try
-                {
+        } finally {
+            if (close_streams) {
+                try {
                     if (bis != null)
                         bis.close();
-                } catch (IOException e)
-                {
+                } catch (IOException e) {
                     Debug.debug(e);
                 }
-                try
-                {
+                try {
                     if (bos != null)
                         bos.close();
-                } catch (IOException e)
-                {
+                } catch (IOException e) {
                     Debug.debug(e);
                 }
             }
@@ -212,11 +181,9 @@ public class IoUtils implements ImagingC
     }
 
     public static final boolean copyFileNio(File src, File dst)
-            throws IOException
-    {
+            throws IOException {
         FileChannel srcChannel = null, dstChannel = null;
-        try
-        {
+        try {
             // Create channel on the source
             srcChannel = new FileInputStream(src).getChannel();
 
@@ -231,42 +198,35 @@ public class IoUtils implements ImagingC
                 int safe_max = (64 * 1024 * 1024) / 4;
                 long size = srcChannel.size();
                 long position = 0;
-                while (position < size)
-                {
+                while (position < size) {
                     position += srcChannel.transferTo(position, safe_max,
                             dstChannel);
                 }
             }
 
             // Close the channels
-             srcChannel.close();
-             srcChannel = null;
-             dstChannel.close();
-             dstChannel = null;
+            srcChannel.close();
+            srcChannel = null;
+            dstChannel.close();
+            dstChannel = null;
 
             return true;
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (srcChannel != null)
                     srcChannel.close();
-            } catch (IOException e)
-            {
+            } catch (IOException e) {
                 Debug.debug(e);
 
             }
-            try
-            {
+            try {
                 if (dstChannel != null)
                     dstChannel.close();
-            } catch (IOException e)
-            {
+            } catch (IOException e) {
                 Debug.debug(e);
 
             }
         }
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message