commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r1342971 [15/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/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/formats/xpm/XpmImageParser.java Sat May 26 21:19:03 2012
@@ -51,24 +51,20 @@ import org.apache.commons.imaging.palett
 import org.apache.commons.imaging.palette.SimplePalette;
 import org.apache.commons.imaging.util.Debug;
 
-public class XpmImageParser extends ImageParser
-{
+public class XpmImageParser extends ImageParser {
     private static Map<String, Integer> colorNames = null;
 
-    public XpmImageParser()
-    {
+    public XpmImageParser() {
     }
 
-    private synchronized static boolean loadColorNames()
-    {
+    private synchronized static boolean loadColorNames() {
         if (colorNames != null)
             return true;
 
         BufferedReader reader = null;
-        try
-        {
-            InputStream rgbTxtStream = XpmImageParser.class.getResourceAsStream(
-                    "rgb.txt");
+        try {
+            InputStream rgbTxtStream = XpmImageParser.class
+                    .getResourceAsStream("rgb.txt");
             if (rgbTxtStream == null) {
                 return false;
             }
@@ -76,137 +72,107 @@ public class XpmImageParser extends Imag
                     "US-ASCII"));
             Map<String, Integer> colors = new HashMap<String, Integer>();
             String line;
-            while ((line = reader.readLine()) != null)
-            {
+            while ((line = reader.readLine()) != null) {
                 if (line.startsWith("!"))
                     continue;
-                try
-                {
+                try {
                     int red = Integer.parseInt(line.substring(0, 3).trim());
                     int green = Integer.parseInt(line.substring(4, 7).trim());
                     int blue = Integer.parseInt(line.substring(8, 11).trim());
                     String colorName = line.substring(11).trim();
-                    colors.put(colorName, 0xff000000 |
-                            (red << 16) | (green << 8) | blue);
-                }
-                catch (NumberFormatException nfe)
-                {
+                    colors.put(colorName, 0xff000000 | (red << 16)
+                            | (green << 8) | blue);
+                } catch (NumberFormatException nfe) {
                 }
             }
             colorNames = colors;
             return true;
-        }
-        catch (IOException ioException)
-        {
+        } catch (IOException ioException) {
             Debug.debug(ioException);
             return false;
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (reader != null)
                     reader.close();
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
     @Override
-    public String getName()
-    {
+    public String getName() {
         return "Xpm-Custom";
     }
 
     @Override
-    public String getDefaultExtension()
-    {
+    public String getDefaultExtension() {
         return DEFAULT_EXTENSION;
     }
+
     private static final String DEFAULT_EXTENSION = ".xpm";
-    private static final String ACCEPTED_EXTENSIONS[] =
-    {
-        ".xpm",
-    };
+    private static final String ACCEPTED_EXTENSIONS[] = { ".xpm", };
 
     @Override
-    protected String[] getAcceptedExtensions()
-    {
+    protected String[] getAcceptedExtensions() {
         return ACCEPTED_EXTENSIONS;
     }
 
     @Override
-    protected ImageFormat[] getAcceptedTypes()
-    {
-        return new ImageFormat[]
-        {
-            ImageFormat.IMAGE_FORMAT_XPM, //
+    protected ImageFormat[] getAcceptedTypes() {
+        return new ImageFormat[] { ImageFormat.IMAGE_FORMAT_XPM, //
         };
     }
 
     @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 {
         XpmHeader xpmHeader = readXpmHeader(byteSource);
         boolean isTransparent = false;
         int colorType = ImageInfo.COLOR_TYPE_BW;
-        for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
-        {
+        for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
+                .entrySet().iterator(); it.hasNext();) {
             Map.Entry<Object, PaletteEntry> entry = it.next();
             PaletteEntry paletteEntry = entry.getValue();
             if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000)
                 isTransparent = true;
             if (paletteEntry.haveColor)
                 colorType = ImageInfo.COLOR_TYPE_RGB;
-            else if (colorType != ImageInfo.COLOR_TYPE_RGB &&
-                    (paletteEntry.haveGray || paletteEntry.haveGray4Level))
+            else if (colorType != ImageInfo.COLOR_TYPE_RGB
+                    && (paletteEntry.haveGray || paletteEntry.haveGray4Level))
                 colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
         }
         return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
                 new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XPM,
-                "X PixMap",
-                xpmHeader.height, "image/x-xpixmap", 1,
-                0, 0, 0, 0,
-                xpmHeader.width, false, isTransparent, true,
-                colorType,
+                "X PixMap", xpmHeader.height, "image/x-xpixmap", 1, 0, 0, 0, 0,
+                xpmHeader.width, false, isTransparent, true, colorType,
                 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 {
         XpmHeader xpmHeader = readXpmHeader(byteSource);
         return new Dimension(xpmHeader.width, xpmHeader.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 XpmHeader
-    {
+    private static class XpmHeader {
         int width;
         int height;
         int numColors;
@@ -214,13 +180,11 @@ public class XpmImageParser extends Imag
         int xHotSpot = -1;
         int yHotSpot = -1;
         boolean xpmExt;
-        
+
         Map<Object, PaletteEntry> palette = new HashMap<Object, PaletteEntry>();
 
         public XpmHeader(int width, int height, int numColors,
-                int numCharsPerPixel, int xHotSpot, int yHotSpot,
-                boolean xpmExt)
-        {
+                int numCharsPerPixel, int xHotSpot, int yHotSpot, boolean xpmExt) {
             this.width = width;
             this.height = height;
             this.numColors = numColors;
@@ -230,15 +194,13 @@ public class XpmImageParser extends Imag
             this.xpmExt = xpmExt;
         }
 
-        public void dump(PrintWriter pw)
-        {
+        public void dump(PrintWriter pw) {
             pw.println("XpmHeader");
             pw.println("Width: " + width);
             pw.println("Height: " + height);
             pw.println("NumColors: " + numColors);
             pw.println("NumCharsPerPixel: " + numCharsPerPixel);
-            if (xHotSpot != -1 && yHotSpot != -1)
-            {
+            if (xHotSpot != -1 && yHotSpot != -1) {
                 pw.println("X hotspot: " + xHotSpot);
                 pw.println("Y hotspot: " + yHotSpot);
             }
@@ -246,8 +208,7 @@ public class XpmImageParser extends Imag
         }
     }
 
-    private static class PaletteEntry
-    {
+    private static class PaletteEntry {
         int index;
         boolean haveColor = false;
         int colorArgb;
@@ -259,8 +220,7 @@ public class XpmImageParser extends Imag
         int monoArgb;
         String symbolicName = null;
 
-        int getBestARGB()
-        {
+        int getBestARGB() {
             if (haveColor)
                 return colorArgb;
             else if (haveGray)
@@ -274,63 +234,53 @@ public class XpmImageParser extends Imag
         }
     }
 
-    private static class XpmParseResult
-    {
+    private static class XpmParseResult {
         XpmHeader xpmHeader;
         BasicCParser cParser;
     }
 
     private XpmHeader readXpmHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         XpmParseResult result = parseXpmHeader(byteSource);
         return result.xpmHeader;
     }
 
     private XpmParseResult parseXpmHeader(ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         InputStream is = null;
-        try
-        {
+        try {
             is = byteSource.getInputStream();
             StringBuilder firstComment = new StringBuilder();
             ByteArrayOutputStream preprocessedFile = BasicCParser.preprocess(
                     is, firstComment, null);
             if (!firstComment.toString().trim().equals("XPM"))
-                throw new ImageReadException("Parsing XPM file failed, " +
-                        "signature isn't '/* XPM */'");
+                throw new ImageReadException("Parsing XPM file failed, "
+                        + "signature isn't '/* XPM */'");
 
             XpmParseResult xpmParseResult = new XpmParseResult();
-            xpmParseResult.cParser = new BasicCParser(
-                    new ByteArrayInputStream(preprocessedFile.toByteArray()));
+            xpmParseResult.cParser = new BasicCParser(new ByteArrayInputStream(
+                    preprocessedFile.toByteArray()));
             xpmParseResult.xpmHeader = parseXpmHeader(xpmParseResult.cParser);
             return xpmParseResult;
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            }
-            catch (IOException ignored)
-            {
+            } catch (IOException ignored) {
             }
         }
     }
 
-    private boolean parseNextString(BasicCParser cParser, StringBuilder stringBuilder)
-            throws IOException, ImageReadException
-    {
+    private boolean parseNextString(BasicCParser cParser,
+            StringBuilder stringBuilder) throws IOException, ImageReadException {
         stringBuilder.setLength(0);
         String token = cParser.nextToken();
         if (token.charAt(0) != '"')
-            throw new ImageReadException("Parsing XPM file failed, " +
-                    "no string found where expected");
+            throw new ImageReadException("Parsing XPM file failed, "
+                    + "no string found where expected");
         BasicCParser.unescapeString(stringBuilder, token);
-        for (token = cParser.nextToken(); token.charAt(0) == '"'; token = cParser.nextToken())
-        {
+        for (token = cParser.nextToken(); token.charAt(0) == '"'; token = cParser
+                .nextToken()) {
             BasicCParser.unescapeString(stringBuilder, token);
         }
         if (token.equals(","))
@@ -338,19 +288,17 @@ public class XpmImageParser extends Imag
         else if (token.equals("}"))
             return false;
         else
-            throw new ImageReadException("Parsing XPM file failed, " +
-                    "no ',' or '}' found where expected");
+            throw new ImageReadException("Parsing XPM file failed, "
+                    + "no ',' or '}' found where expected");
     }
 
     private XpmHeader parseXpmValuesSection(String row)
-            throws ImageReadException
-    {
+            throws ImageReadException {
         String[] tokens = BasicCParser.tokenizeRow(row);
         if (tokens.length < 4 && tokens.length > 7)
-            throw new ImageReadException("Parsing XPM file failed, " +
-                    "<Values> section has incorrect tokens");
-        try
-        {
+            throw new ImageReadException("Parsing XPM file failed, "
+                    + "<Values> section has incorrect tokens");
+        try {
             int width = Integer.parseInt(tokens[0]);
             int height = Integer.parseInt(tokens[1]);
             int numColors = Integer.parseInt(tokens[2]);
@@ -358,70 +306,53 @@ public class XpmImageParser extends Imag
             int xHotSpot = -1;
             int yHotSpot = -1;
             boolean xpmExt = false;
-            if (tokens.length >= 6)
-            {
+            if (tokens.length >= 6) {
                 xHotSpot = Integer.parseInt(tokens[4]);
                 yHotSpot = Integer.parseInt(tokens[5]);
             }
-            if (tokens.length == 5 || tokens.length == 7)
-            {
-                if (tokens[tokens.length-1].equals("XPMEXT"))
+            if (tokens.length == 5 || tokens.length == 7) {
+                if (tokens[tokens.length - 1].equals("XPMEXT"))
                     xpmExt = true;
                 else
-                    throw new ImageReadException("Parsing XPM file failed, " +
-                            "can't parse <Values> section XPMEXT");
+                    throw new ImageReadException("Parsing XPM file failed, "
+                            + "can't parse <Values> section XPMEXT");
             }
             return new XpmHeader(width, height, numColors, numCharsPerPixel,
                     xHotSpot, yHotSpot, xpmExt);
-        }
-        catch (NumberFormatException nfe)
-        {
-            throw new ImageReadException("Parsing XPM file failed, " +
-                    "error parsing <Values> section", nfe);
+        } catch (NumberFormatException nfe) {
+            throw new ImageReadException("Parsing XPM file failed, "
+                    + "error parsing <Values> section", nfe);
         }
     }
 
-    private int parseColor(String color)
-            throws ImageReadException
-    {
-        if (color.charAt(0) == '#')
-        {
+    private int parseColor(String color) throws ImageReadException {
+        if (color.charAt(0) == '#') {
             color = color.substring(1);
-            if (color.length() == 3)
-            {
+            if (color.length() == 3) {
                 int red = Integer.parseInt(color.substring(0, 1), 16);
                 int green = Integer.parseInt(color.substring(1, 2), 16);
                 int blue = Integer.parseInt(color.substring(2, 3), 16);
                 return 0xff000000 | (red << 20) | (green << 12) | (blue << 4);
-            }
-            else if (color.length() == 6)
+            } else if (color.length() == 6)
                 return 0xff000000 | Integer.parseInt(color, 16);
-            else if (color.length() == 9)
-            {
+            else if (color.length() == 9) {
                 int red = Integer.parseInt(color.substring(0, 1), 16);
                 int green = Integer.parseInt(color.substring(3, 4), 16);
                 int blue = Integer.parseInt(color.substring(6, 7), 16);
                 return 0xff000000 | (red << 16) | (green << 8) | blue;
-            }
-            else if (color.length() == 12)
-            {
+            } else if (color.length() == 12) {
                 int red = Integer.parseInt(color.substring(0, 1), 16);
                 int green = Integer.parseInt(color.substring(4, 5), 16);
                 int blue = Integer.parseInt(color.substring(8, 9), 16);
                 return 0xff000000 | (red << 16) | (green << 8) | blue;
-            }
-            else
+            } else
                 return 0x00000000;
-        }
-        else if (color.charAt(0) == '%')
-        {
-            throw new ImageReadException("HSV colors are not implemented " +
-                    "even in the XPM specification!");
-        }
-        else if (color.equals("None"))
+        } else if (color.charAt(0) == '%') {
+            throw new ImageReadException("HSV colors are not implemented "
+                    + "even in the XPM specification!");
+        } else if (color.equals("None"))
             return 0x00000000;
-        else
-        {
+        else {
             if (!loadColorNames())
                 return 0x00000000;
             if (colorNames.containsKey(color))
@@ -432,72 +363,55 @@ public class XpmImageParser extends Imag
     }
 
     private void parsePaletteEntries(XpmHeader xpmHeader, BasicCParser cParser)
-            throws IOException, ImageReadException
-    {
+            throws IOException, ImageReadException {
         StringBuilder row = new StringBuilder();
-        for (int i = 0; i < xpmHeader.numColors; i++)
-        {
+        for (int i = 0; i < xpmHeader.numColors; i++) {
             row.setLength(0);
             boolean hasMore = parseNextString(cParser, row);
             if (!hasMore)
-                throw new ImageReadException("Parsing XPM file failed, " +
-                        "file ended while reading palette");
+                throw new ImageReadException("Parsing XPM file failed, "
+                        + "file ended while reading palette");
             String name = row.substring(0, xpmHeader.numCharsPerPixel);
-            String[] tokens = BasicCParser.tokenizeRow(
-                    row.substring(xpmHeader.numCharsPerPixel));
+            String[] tokens = BasicCParser.tokenizeRow(row
+                    .substring(xpmHeader.numCharsPerPixel));
             PaletteEntry paletteEntry = new PaletteEntry();
             paletteEntry.index = i;
             int previousKeyIndex = Integer.MIN_VALUE;
             StringBuilder colorBuffer = new StringBuilder();
-            for (int j = 0; j < tokens.length; j++)
-            {
+            for (int j = 0; j < tokens.length; j++) {
                 String token = tokens[j];
                 boolean isKey = false;
-                if (previousKeyIndex < (j - 1))
-                {
-                    if (token.equals("m") || token.equals("g4") ||
-                            token.equals("g") || token.equals("c") ||
-                            token.equals("s"))
+                if (previousKeyIndex < (j - 1)) {
+                    if (token.equals("m") || token.equals("g4")
+                            || token.equals("g") || token.equals("c")
+                            || token.equals("s"))
                         isKey = true;
                 }
-                if (isKey)
-                {
-                    if (previousKeyIndex >= 0)
-                    {
+                if (isKey) {
+                    if (previousKeyIndex >= 0) {
                         String key = tokens[previousKeyIndex];
                         String color = colorBuffer.toString();
                         colorBuffer.setLength(0);
-                        if (key.equals("m"))
-                        {
+                        if (key.equals("m")) {
                             paletteEntry.monoArgb = parseColor(color);
                             paletteEntry.haveMono = true;
-                        }
-                        else if (key.equals("g4"))
-                        {
+                        } else if (key.equals("g4")) {
                             paletteEntry.gray4LevelArgb = parseColor(color);
                             paletteEntry.haveGray4Level = true;
-                        }
-                        else if (key.equals("g"))
-                        {
+                        } else if (key.equals("g")) {
                             paletteEntry.grayArgb = parseColor(color);
                             paletteEntry.haveGray = true;
-                        }
-                        else if (key.equals("s"))
-                        {
+                        } else if (key.equals("s")) {
                             paletteEntry.symbolicName = color;
                             paletteEntry.colorArgb = parseColor(color);
                             paletteEntry.haveColor = true;
-                        }
-                        else if (key.equals("c"))
-                        {
+                        } else if (key.equals("c")) {
                             paletteEntry.colorArgb = parseColor(color);
                             paletteEntry.haveColor = true;
                         }
                     }
                     previousKeyIndex = j;
-                }
-                else
-                {
+                } else {
                     if (previousKeyIndex < 0)
                         break;
                     if (colorBuffer.length() > 0)
@@ -505,34 +419,24 @@ public class XpmImageParser extends Imag
                     colorBuffer.append(token);
                 }
             }
-            if (previousKeyIndex >= 0 && colorBuffer.length() > 0)
-            {
+            if (previousKeyIndex >= 0 && colorBuffer.length() > 0) {
                 String key = tokens[previousKeyIndex];
                 String color = colorBuffer.toString();
                 colorBuffer.setLength(0);
-                if (key.equals("m"))
-                {
+                if (key.equals("m")) {
                     paletteEntry.monoArgb = parseColor(color);
                     paletteEntry.haveMono = true;
-                }
-                else if (key.equals("g4"))
-                {
+                } else if (key.equals("g4")) {
                     paletteEntry.gray4LevelArgb = parseColor(color);
                     paletteEntry.haveGray4Level = true;
-                }
-                else if (key.equals("g"))
-                {
+                } else if (key.equals("g")) {
                     paletteEntry.grayArgb = parseColor(color);
                     paletteEntry.haveGray = true;
-                }
-                else if (key.equals("s"))
-                {
+                } else if (key.equals("s")) {
                     paletteEntry.symbolicName = color;
                     paletteEntry.colorArgb = parseColor(color);
                     paletteEntry.haveColor = true;
-                }
-                else if (key.equals("c"))
-                {
+                } else if (key.equals("c")) {
                     paletteEntry.colorArgb = parseColor(color);
                     paletteEntry.haveColor = true;
                 }
@@ -542,98 +446,102 @@ public class XpmImageParser extends Imag
     }
 
     private XpmHeader parseXpmHeader(BasicCParser cParser)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         String name;
         String token;
         token = cParser.nextToken();
         if (token == null || !token.equals("static"))
-            throw new ImageReadException("Parsing XPM file failed, no 'static' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no 'static' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("char"))
-            throw new ImageReadException("Parsing XPM file failed, no 'char' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no 'char' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("*"))
-            throw new ImageReadException("Parsing XPM file failed, no '*' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no '*' token");
         name = cParser.nextToken();
         if (name == null)
-            throw new ImageReadException("Parsing XPM file failed, no variable name");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no variable name");
         if (name.charAt(0) != '_' && !Character.isLetter(name.charAt(0)))
-            throw new ImageReadException("Parsing XPM file failed, variable name " +
-                    "doesn't start with letter or underscore");
-        for (int i = 0; i < name.length(); i++)
-        {
+            throw new ImageReadException(
+                    "Parsing XPM file failed, variable name "
+                            + "doesn't start with letter or underscore");
+        for (int i = 0; i < name.length(); i++) {
             char c = name.charAt(i);
             if (!Character.isLetterOrDigit(c) && c != '_')
-                throw new ImageReadException("Parsing XPM file failed, variable name " +
-                        "contains non-letter non-digit non-underscore");
+                throw new ImageReadException(
+                        "Parsing XPM file failed, variable name "
+                                + "contains non-letter non-digit non-underscore");
         }
         token = cParser.nextToken();
         if (token == null || !token.equals("["))
-            throw new ImageReadException("Parsing XPM file failed, no '[' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no '[' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("]"))
-            throw new ImageReadException("Parsing XPM file failed, no ']' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no ']' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("="))
-            throw new ImageReadException("Parsing XPM file failed, no '=' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no '=' token");
         token = cParser.nextToken();
         if (token == null || !token.equals("{"))
-            throw new ImageReadException("Parsing XPM file failed, no '{' token");
+            throw new ImageReadException(
+                    "Parsing XPM file failed, no '{' token");
 
         StringBuilder row = new StringBuilder();
         boolean hasMore = parseNextString(cParser, row);
         if (!hasMore)
-            throw new ImageReadException("Parsing XPM file failed, " +
-                    "file too short");
+            throw new ImageReadException("Parsing XPM file failed, "
+                    + "file too short");
         XpmHeader xpmHeader = parseXpmValuesSection(row.toString());
         parsePaletteEntries(xpmHeader, cParser);
         return xpmHeader;
     }
 
     private BufferedImage readXpmImage(XpmHeader xpmHeader, BasicCParser cParser)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         ColorModel colorModel;
         WritableRaster raster;
         int bpp;
-        if (xpmHeader.palette.size() <= (1 << 8))
-        {
+        if (xpmHeader.palette.size() <= (1 << 8)) {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
-            {
+            for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
+                    .entrySet().iterator(); it.hasNext();) {
                 Map.Entry<Object, PaletteEntry> entry = it.next();
                 PaletteEntry paletteEntry = entry.getValue();
                 palette[paletteEntry.index] = paletteEntry.getBestARGB();
             }
             colorModel = new IndexColorModel(8, xpmHeader.palette.size(),
                     palette, 0, true, -1, DataBuffer.TYPE_BYTE);
-            raster = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_BYTE,
-                    xpmHeader.width, xpmHeader.height, 1, null);
+            raster = WritableRaster.createInterleavedRaster(
+                    DataBuffer.TYPE_BYTE, xpmHeader.width, xpmHeader.height, 1,
+                    null);
             bpp = 8;
-        }
-        else if (xpmHeader.palette.size() <= (1 << 16))
-        {
+        } else if (xpmHeader.palette.size() <= (1 << 16)) {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
-            {
+            for (Iterator<Map.Entry<Object, PaletteEntry>> it = xpmHeader.palette
+                    .entrySet().iterator(); it.hasNext();) {
                 Map.Entry<Object, PaletteEntry> entry = it.next();
                 PaletteEntry paletteEntry = entry.getValue();
                 palette[paletteEntry.index] = paletteEntry.getBestARGB();
             }
             colorModel = new IndexColorModel(16, xpmHeader.palette.size(),
                     palette, 0, true, -1, DataBuffer.TYPE_USHORT);
-            raster = WritableRaster.createInterleavedRaster(DataBuffer.TYPE_USHORT,
-                    xpmHeader.width, xpmHeader.height, 1, null);
+            raster = WritableRaster.createInterleavedRaster(
+                    DataBuffer.TYPE_USHORT, xpmHeader.width, xpmHeader.height,
+                    1, null);
             bpp = 16;
-        }
-        else
-        {
+        } else {
             colorModel = new DirectColorModel(32, 0x00ff0000, 0x0000ff00,
                     0x000000ff, 0xff000000);
             raster = WritableRaster.createPackedRaster(DataBuffer.TYPE_INT,
-                    xpmHeader.width, xpmHeader.height,
-                    new int[]{0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000}, null);
+                    xpmHeader.width, xpmHeader.height, new int[] { 0x00ff0000,
+                            0x0000ff00, 0x000000ff, 0xff000000 }, null);
             bpp = 32;
         }
 
@@ -642,106 +550,97 @@ public class XpmImageParser extends Imag
         DataBuffer dataBuffer = raster.getDataBuffer();
         StringBuilder row = new StringBuilder();
         boolean hasMore = true;
-        for (int y = 0; y < xpmHeader.height; y++)
-        {
+        for (int y = 0; y < xpmHeader.height; y++) {
             row.setLength(0);
             hasMore = parseNextString(cParser, row);
             if (y < (xpmHeader.height - 1) && !hasMore)
-                throw new ImageReadException("Parsing XPM file failed, " +
-                        "insufficient image rows in file");
-            int rowOffset = y*xpmHeader.width;
-            for (int x = 0; x < xpmHeader.width; x++)
-            {
-                String index = row.substring(x*xpmHeader.numCharsPerPixel,
-                        (x + 1)*xpmHeader.numCharsPerPixel);
+                throw new ImageReadException("Parsing XPM file failed, "
+                        + "insufficient image rows in file");
+            int rowOffset = y * xpmHeader.width;
+            for (int x = 0; x < xpmHeader.width; x++) {
+                String index = row.substring(x * xpmHeader.numCharsPerPixel,
+                        (x + 1) * xpmHeader.numCharsPerPixel);
                 PaletteEntry paletteEntry = xpmHeader.palette.get(index);
                 if (paletteEntry == null) {
-                    throw new ImageReadException("No palette entry was defined " +
-                            "for " + index);
+                    throw new ImageReadException(
+                            "No palette entry was defined " + "for " + index);
                 }
                 if (bpp <= 16)
                     dataBuffer.setElem(rowOffset + x, paletteEntry.index);
                 else
-                    dataBuffer.setElem(rowOffset + x, paletteEntry.getBestARGB());
+                    dataBuffer.setElem(rowOffset + x,
+                            paletteEntry.getBestARGB());
             }
         }
 
-        while (hasMore)
-        {
+        while (hasMore) {
             row.setLength(0);
             hasMore = parseNextString(cParser, row);
         }
-        
+
         String token = cParser.nextToken();
         if (!token.equals(";"))
             throw new ImageReadException("Last token wasn't ';'");
-        
+
         return image;
     }
 
     @Override
     public boolean dumpImageFile(PrintWriter pw, ByteSource byteSource)
-            throws ImageReadException, IOException
-    {
+            throws ImageReadException, IOException {
         readXpmHeader(byteSource).dump(pw);
         return true;
     }
 
     @Override
     public final BufferedImage getBufferedImage(ByteSource byteSource,
-            Map params) throws ImageReadException, IOException
-    {
+            Map params) throws ImageReadException, IOException {
         XpmParseResult result = parseXpmHeader(byteSource);
         return readXpmImage(result.xpmHeader, 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 pixelsForIndex(int index, int charsPerPixel)
-    {
+    private String pixelsForIndex(int index, int charsPerPixel) {
         StringBuilder stringBuilder = new StringBuilder();
         int highestPower = 1;
         for (int i = 1; i < charsPerPixel; i++)
             highestPower *= writePalette.length;
-        for (int i = 0; i < charsPerPixel; i++)
-        {
+        for (int i = 0; i < charsPerPixel; i++) {
             int multiple = index / highestPower;
-            index  -= (multiple * highestPower);
+            index -= (multiple * highestPower);
             highestPower /= writePalette.length;
             stringBuilder.append(writePalette[multiple]);
         }
         return stringBuilder.toString();
     }
 
-    private String toColor(int color)
-    {
+    private String toColor(int color) {
         String hex = Integer.toHexString(color);
-        if (hex.length() < 6)
-        {
+        if (hex.length() < 6) {
             char zeroes[] = new char[6 - hex.length()];
             Arrays.fill(zeroes, '0');
             return "#" + new String(zeroes) + hex;
-        }
-        else
+        } else
             return "#" + hex;
     }
 
     @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);
 
@@ -749,8 +648,7 @@ public class XpmImageParser 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);
         }
@@ -762,12 +660,10 @@ public class XpmImageParser extends Imag
         SimplePalette palette = null;
         int maxColors = writePalette.length;
         int charsPerPixel = 1;
-        for (; palette == null; )
-        {
+        for (; palette == null;) {
             palette = paletteFactory.makePaletteSimple(src,
                     hasTransparency ? maxColors - 1 : maxColors);
-            if (palette == null)
-            {
+            if (palette == null) {
                 maxColors *= writePalette.length;
                 charsPerPixel++;
             }
@@ -780,39 +676,35 @@ public class XpmImageParser extends Imag
         os.write(line.getBytes("US-ASCII"));
         line = "static char *" + randomName() + "[] = {\n";
         os.write(line.getBytes("US-ASCII"));
-        line = "\"" + src.getWidth() +
-                " " + src.getHeight() +
-                " " + colors +
-                " " + charsPerPixel + "\",\n";
+        line = "\"" + src.getWidth() + " " + src.getHeight() + " " + colors
+                + " " + charsPerPixel + "\",\n";
         os.write(line.getBytes("US-ASCII"));
 
-        for (int i = 0; i < colors; i++)
-        {
+        for (int i = 0; i < colors; i++) {
             String color;
             if (i < palette.length())
                 color = toColor(palette.getEntry(i));
             else
                 color = "None";
-            line = "\"" + pixelsForIndex(i, charsPerPixel) +
-                    " c " + color + "\",\n";
+            line = "\"" + pixelsForIndex(i, charsPerPixel) + " c " + color
+                    + "\",\n";
             os.write(line.getBytes("US-ASCII"));
         }
 
         String separator = "";
-        for (int y = 0; y < src.getHeight(); y++)
-        {
+        for (int y = 0; y < src.getHeight(); y++) {
             os.write(separator.getBytes("US-ASCII"));
             separator = ",\n";
             line = "\"";
             os.write(line.getBytes("US-ASCII"));
-            for (int x = 0; x < src.getWidth(); x++)
-            {
+            for (int x = 0; x < src.getWidth(); x++) {
                 int argb = src.getRGB(x, y);
                 if ((argb & 0xff000000) == 0)
                     line = pixelsForIndex(palette.length(), charsPerPixel);
                 else
-                    line = pixelsForIndex(palette.getPaletteIndex(
-                            0xffffff & argb), charsPerPixel);
+                    line = pixelsForIndex(
+                            palette.getPaletteIndex(0xffffff & argb),
+                            charsPerPixel);
                 os.write(line.getBytes("US-ASCII"));
             }
             line = "\"";
@@ -823,115 +715,28 @@ public class XpmImageParser extends Imag
         os.write(line.getBytes("US-ASCII"));
     }
 
-    private static final char writePalette[] = {
-        ' ',
-        '.',
-        'X',
-        'o',
-        'O',
-        '+',
-        '@',
-        '#',
-        '$',
-        '%',
-        '&',
-        '*',
-        '=',
-        '-',
-        ';',
-        ':',
-        '>',
-        ',',
-        '<',
-        '1',
-        '2',
-        '3',
-        '4',
-        '5',
-        '6',
-        '7',
-        '8',
-        '9',
-        '0',
-        'q',
-        'w',
-        'e',
-        'r',
-        't',
-        'y',
-        'u',
-        'i',
-        'p',
-        'a',
-        's',
-        'd',
-        'f',
-        'g',
-        'h',
-        'j',
-        'k',
-        'l',
-        'z',
-        'x',
-        'c',
-        'v',
-        'b',
-        'n',
-        'm',
-        'M',
-        'N',
-        'B',
-        'V',
-        'C',
-        'Z',
-        'A',
-        'S',
-        'D',
-        'F',
-        'G',
-        'H',
-        'J',
-        'K',
-        'L',
-        'P',
-        'I',
-        'U',
-        'Y',
-        'T',
-        'R',
-        'E',
-        'W',
-        'Q',
-        '!',
-        '~',
-        '^',
-        '/',
-        '(',
-        ')',
-        '_',
-        '`',
-        '\'',
-        ']',
-        '[',
-        '{',
-        '}',
-        '|',
-    };
+    private static final char writePalette[] = { ' ', '.', 'X', 'o', 'O', '+',
+            '@', '#', '$', '%', '&', '*', '=', '-', ';', ':', '>', ',', '<',
+            '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'q', 'w', 'e',
+            'r', 't', 'y', 'u', 'i', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j',
+            'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'M', 'N', 'B', 'V',
+            'C', 'Z', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'P', 'I',
+            'U', 'Y', 'T', 'R', 'E', 'W', 'Q', '!', '~', '^', '/', '(', ')',
+            '_', '`', '\'', ']', '[', '{', '}', '|', };
 
     /**
      * 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/icc/IccConstants.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccConstants.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccConstants.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccConstants.java Sat May 26 21:19:03 2012
@@ -16,9 +16,7 @@
  */
 package org.apache.commons.imaging.icc;
 
-
-public interface IccConstants
-{
+public interface IccConstants {
     public final static int IEC = (((0xff & 'I') << 24) | ((0xff & 'E') << 16)
             | ((0xff & 'C') << 8) | ((0xff & ' ') << 0));
     public final static int sRGB = (((0xff & 's') << 24) | ((0xff & 'R') << 16)

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileInfo.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileInfo.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileInfo.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileInfo.java Sat May 26 21:19:03 2012
@@ -22,8 +22,7 @@ import java.io.StringWriter;
 
 import org.apache.commons.imaging.ImageReadException;
 
-public class IccProfileInfo implements IccConstants
-{
+public class IccProfileInfo implements IccConstants {
 
     public final byte data[];
     public final int ProfileSize;
@@ -48,8 +47,7 @@ public class IccProfileInfo implements I
             int ProfileFileSignature, int PrimaryPlatformSignature,
             int VariousFlags, int DeviceManufacturer, int DeviceModel,
             int RenderingIntent, int ProfileCreatorSignature, byte ProfileID[],
-            IccTag tags[])
-    {
+            IccTag tags[]) {
         this.data = data;
 
         this.ProfileSize = ProfileSize;
@@ -70,44 +68,36 @@ public class IccProfileInfo implements I
         this.tags = tags;
     }
 
-    public boolean issRGB()
-    {
+    public boolean issRGB() {
         boolean result = ((DeviceManufacturer == IEC) && (DeviceModel == sRGB));
         return result;
     }
 
-    private void printCharQuad(PrintWriter pw, String msg, int i)
-    {
+    private void printCharQuad(PrintWriter pw, String msg, int i) {
         pw.println(msg + ": '" + (char) (0xff & (i >> 24))
                 + (char) (0xff & (i >> 16)) + (char) (0xff & (i >> 8))
                 + (char) (0xff & (i >> 0)) + "'");
     }
 
-    public void dump(String prefix)
-    {
+    public void dump(String prefix) {
         System.out.print(toString());
     }
 
     @Override
-    public String toString()
-    {
-        try
-        {
+    public String toString() {
+        try {
             return toString("");
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             return "IccProfileInfo: Error";
         }
     }
 
     public String toString(String prefix) throws ImageReadException,
-            IOException
-    {
+            IOException {
         StringWriter sw = new StringWriter();
         PrintWriter pw = new PrintWriter(sw);
 
-        //        StringBuffer result = new StringBuffer();
+        // StringBuffer result = new StringBuffer();
         pw.println(prefix + ": " + "data length: " + data.length);
 
         printCharQuad(pw, prefix + ": " + "ProfileDeviceClassSignature",
@@ -140,8 +130,7 @@ public class IccProfileInfo implements I
         printCharQuad(pw, prefix + ": " + "ProfileCreatorSignature",
                 ProfileCreatorSignature);
 
-        for (int i = 0; i < tags.length; i++)
-        {
+        for (int i = 0; i < tags.length; i++) {
             IccTag tag = tags[i];
             tag.dump(pw, "\t" + i + ": ");
         }
@@ -152,4 +141,4 @@ public class IccProfileInfo implements I
         return sw.getBuffer().toString();
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccProfileParser.java Sat May 26 21:19:03 2012
@@ -28,44 +28,37 @@ import org.apache.commons.imaging.common
 import org.apache.commons.imaging.util.CachingInputStream;
 import org.apache.commons.imaging.util.Debug;
 
-public class IccProfileParser extends BinaryFileParser implements IccConstants
-{
-    public IccProfileParser()
-    {
+public class IccProfileParser extends BinaryFileParser implements IccConstants {
+    public IccProfileParser() {
         this.setByteOrder(BYTE_ORDER_NETWORK);
     }
 
-    public IccProfileInfo getICCProfileInfo(ICC_Profile icc_profile)
-    {
+    public IccProfileInfo getICCProfileInfo(ICC_Profile icc_profile) {
         if (icc_profile == null)
             return null;
 
         return getICCProfileInfo(new ByteSourceArray(icc_profile.getData()));
     }
 
-    public IccProfileInfo getICCProfileInfo(byte bytes[])
-    {
+    public IccProfileInfo getICCProfileInfo(byte bytes[]) {
         if (bytes == null)
             return null;
 
         return getICCProfileInfo(new ByteSourceArray(bytes));
     }
 
-    public IccProfileInfo getICCProfileInfo(File file)
-    {
+    public IccProfileInfo getICCProfileInfo(File file) {
         if (file == null)
             return null;
 
         return getICCProfileInfo(new ByteSourceFile(file));
     }
 
-    public IccProfileInfo getICCProfileInfo(ByteSource byteSource)
-    {
+    public IccProfileInfo getICCProfileInfo(ByteSource byteSource) {
 
         InputStream is = null;
 
-        try
-        {
+        try {
 
             IccProfileInfo result;
             {
@@ -80,32 +73,24 @@ public class IccProfileParser extends Bi
             is.close();
             is = null;
 
-            for (int i = 0; i < result.tags.length; i++)
-            {
+            for (int i = 0; i < result.tags.length; i++) {
                 IccTag tag = result.tags[i];
                 byte bytes[] = byteSource.getBlock(tag.offset, tag.length);
-                //                Debug.debug("bytes: " + bytes.length);
+                // Debug.debug("bytes: " + bytes.length);
                 tag.setData(bytes);
-                //                tag.dump("\t" + i + ": ");
+                // tag.dump("\t" + i + ": ");
             }
-            //            result.fillInTagData(byteSource);
+            // result.fillInTagData(byteSource);
 
             return result;
-        }
-        catch (Exception e)
-        {
-            //            Debug.debug("Error: " + file.getAbsolutePath());
+        } catch (Exception e) {
+            // Debug.debug("Error: " + file.getAbsolutePath());
             Debug.debug(e);
-        }
-        finally
-        {
-            try
-            {
+        } finally {
+            try {
                 if (is != null)
                     is.close();
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 Debug.debug(e);
             }
 
@@ -117,33 +102,32 @@ public class IccProfileParser extends Bi
         return null;
     }
 
-    private IccProfileInfo readICCProfileInfo(InputStream is)
-    {
+    private IccProfileInfo readICCProfileInfo(InputStream is) {
         CachingInputStream cis = new CachingInputStream(is);
         is = cis;
 
         if (debug)
             Debug.debug();
 
-        //                setDebug(true);
+        // setDebug(true);
 
-        //        if (debug)
-        //            Debug.debug("length: " + length);
+        // if (debug)
+        // Debug.debug("length: " + length);
 
-        try
-        {
+        try {
             int ProfileSize = read4Bytes("ProfileSize", is,
                     "Not a Valid ICC Profile");
 
-            //            if (length != ProfileSize)
-            //            {
-            //                //                Debug.debug("Unexpected Length data expected: " + Integer.toHexString((int) length)
-            //                //                        + ", encoded: " + Integer.toHexString(ProfileSize));
-            //                //                Debug.debug("Unexpected Length data: " + length
-            //                //                        + ", length: " + ProfileSize);
-            //                //                throw new Error("asd");
-            //                return null;
-            //            }
+            // if (length != ProfileSize)
+            // {
+            // // Debug.debug("Unexpected Length data expected: " +
+            // Integer.toHexString((int) length)
+            // // + ", encoded: " + Integer.toHexString(ProfileSize));
+            // // Debug.debug("Unexpected Length data: " + length
+            // // + ", length: " + ProfileSize);
+            // // throw new Error("asd");
+            // return null;
+            // }
 
             int CMMTypeSignature = read4Bytes("Signature", is,
                     "Not a Valid ICC Profile");
@@ -215,58 +199,57 @@ public class IccProfileParser extends Bi
 
             byte ProfileID[] = null;
             skipBytes(is, 16, "Not a Valid ICC Profile");
-            //            readByteArray("ProfileID", 16, is,
-            //                    "Not a Valid ICC Profile");
-            //            if (debug)
-            //                System.out
-            //                        .println("ProfileID: '" + new String(ProfileID) + "'");
+            // readByteArray("ProfileID", 16, is,
+            // "Not a Valid ICC Profile");
+            // if (debug)
+            // System.out
+            // .println("ProfileID: '" + new String(ProfileID) + "'");
 
             skipBytes(is, 28, "Not a Valid ICC Profile");
 
-            //            this.setDebug(true);
+            // this.setDebug(true);
 
             int TagCount = read4Bytes("TagCount", is, "Not a Valid ICC Profile");
 
-            //            List tags = new ArrayList();
+            // List tags = new ArrayList();
             IccTag tags[] = new IccTag[TagCount];
 
-            for (int i = 0; i < TagCount; i++)
-            {
+            for (int i = 0; i < TagCount; i++) {
                 int TagSignature = read4Bytes("TagSignature[" + i + "]", is,
                         "Not a Valid ICC Profile");
-                //                Debug.debug("TagSignature t "
-                //                        + Integer.toHexString(TagSignature));
+                // Debug.debug("TagSignature t "
+                // + Integer.toHexString(TagSignature));
 
-                //                this.printCharQuad("TagSignature", TagSignature);
+                // this.printCharQuad("TagSignature", TagSignature);
                 int OffsetToData = read4Bytes("OffsetToData[" + i + "]", is,
                         "Not a Valid ICC Profile");
                 int ElementSize = read4Bytes("ElementSize[" + i + "]", is,
                         "Not a Valid ICC Profile");
 
                 IccTagType fIccTagType = getIccTagType(TagSignature);
-                //                if (fIccTagType == null)
-                //                    throw new Error("oops.");
+                // if (fIccTagType == null)
+                // throw new Error("oops.");
 
-                //                System.out
-                //                        .println("\t["
-                //                                + i
-                //                                + "]: "
-                //                                + ((fIccTagType == null)
-                //                                        ? "unknown"
-                //                                        : fIccTagType.name));
-                //                Debug.debug();
+                // System.out
+                // .println("\t["
+                // + i
+                // + "]: "
+                // + ((fIccTagType == null)
+                // ? "unknown"
+                // : fIccTagType.name));
+                // Debug.debug();
 
                 IccTag tag = new IccTag(TagSignature, OffsetToData,
                         ElementSize, fIccTagType);
-                //                tag.dump("\t" + i + ": ");
+                // tag.dump("\t" + i + ": ");
                 tags[i] = tag;
-                //                tags .add(tag);
+                // tags .add(tag);
             }
 
             {
                 // read stream to end, filling cache.
-                while (is.read() >= 0)
-                { /* do nothing */ }
+                while (is.read() >= 0) { /* do nothing */
+                }
             }
 
             byte data[] = cis.getCache();
@@ -286,17 +269,14 @@ public class IccProfileParser extends Bi
                 Debug.debug("issRGB: " + result.issRGB());
 
             return result;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             Debug.debug(e);
         }
 
         return null;
     }
 
-    private IccTagType getIccTagType(int quad)
-    {
+    private IccTagType getIccTagType(int quad) {
         for (IccTagType iccTagType : IccTagTypes.values()) {
             if (iccTagType.getSignature() == quad) {
                 return iccTagType;
@@ -306,43 +286,38 @@ public class IccProfileParser extends Bi
         return null;
     }
 
-    public Boolean issRGB(ICC_Profile icc_profile)
-    {
+    public Boolean issRGB(ICC_Profile icc_profile) {
         if (icc_profile == null)
             return null;
 
         return issRGB(new ByteSourceArray(icc_profile.getData()));
     }
 
-    public Boolean issRGB(byte bytes[])
-    {
+    public Boolean issRGB(byte bytes[]) {
         if (bytes == null)
             return null;
 
         return issRGB(new ByteSourceArray(bytes));
     }
 
-    public Boolean issRGB(File file)
-    {
+    public Boolean issRGB(File file) {
         if (file == null)
             return null;
 
         return issRGB(new ByteSourceFile(file));
     }
 
-    public Boolean issRGB(ByteSource byteSource)
-    {
-        try
-        {
+    public Boolean issRGB(ByteSource byteSource) {
+        try {
             if (debug)
                 Debug.debug();
 
-            //            setDebug(true);
+            // setDebug(true);
 
-            //            long length = byteSource.getLength();
+            // long length = byteSource.getLength();
             //
-            //            if (debug)
-            //                Debug.debug("length: " + length);
+            // if (debug)
+            // Debug.debug("length: " + length);
 
             InputStream is = null;
             try {
@@ -350,26 +325,26 @@ public class IccProfileParser extends Bi
 
                 int ProfileSize = read4Bytes("ProfileSize", is,
                         "Not a Valid ICC Profile");
-    
-                //            if (length != ProfileSize)
-                //                return null;
-    
+
+                // if (length != ProfileSize)
+                // return null;
+
                 this.skipBytes(is, 4 * 5);
-    
+
                 skipBytes(is, 12, "Not a Valid ICC Profile");
-    
+
                 this.skipBytes(is, 4 * 3);
-    
+
                 int DeviceManufacturer = read4Bytes("ProfileFileSignature", is,
                         "Not a Valid ICC Profile");
                 if (debug)
                     printCharQuad("DeviceManufacturer", DeviceManufacturer);
-    
+
                 int DeviceModel = read4Bytes("DeviceModel", is,
                         "Not a Valid ICC Profile");
                 if (debug)
                     printCharQuad("DeviceModel", DeviceModel);
-                
+
                 boolean result = ((DeviceManufacturer == IEC) && (DeviceModel == sRGB));
 
                 return result;
@@ -381,13 +356,11 @@ public class IccProfileParser extends Bi
                     }
                 }
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             Debug.debug(e);
         }
 
         return null;
     }
 
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTag.java Sat May 26 21:19:03 2012
@@ -26,16 +26,14 @@ import org.apache.commons.imaging.ImageR
 import org.apache.commons.imaging.common.BinaryConstants;
 import org.apache.commons.imaging.common.BinaryInputStream;
 
-public class IccTag implements BinaryConstants, IccConstants
-{
+public class IccTag implements BinaryConstants, IccConstants {
     public final int signature;
     public final int offset, length;
     public final IccTagType fIccTagType;
 
-    //        public final byte data[];
+    // public final byte data[];
 
-    public IccTag(int signature, int offset, int length, IccTagType fIccTagType)
-    {
+    public IccTag(int signature, int offset, int length, IccTagType fIccTagType) {
         this.signature = signature;
         this.offset = offset;
         this.length = length;
@@ -46,8 +44,7 @@ public class IccTag implements BinaryCon
     private IccTagDataType itdt = null;
     private int data_type_signature;
 
-    public void setData(byte bytes[]) throws IOException
-    {
+    public void setData(byte bytes[]) throws IOException {
         data = bytes;
 
         BinaryInputStream bis = new BinaryInputStream(new ByteArrayInputStream(
@@ -56,15 +53,14 @@ public class IccTag implements BinaryCon
                 "ICC: corrupt tag data");
 
         itdt = getIccTagDataType(data_type_signature);
-        //        if (itdt != null)
-        //        {
-        //            System.out.println("\t\t\t" + "itdt: " + itdt.name);
-        //        }
+        // if (itdt != null)
+        // {
+        // System.out.println("\t\t\t" + "itdt: " + itdt.name);
+        // }
 
     }
 
-    private IccTagDataType getIccTagDataType(int quad)
-    {
+    private IccTagDataType getIccTagDataType(int quad) {
         for (IccTagDataType iccTagDataType : IccTagDataTypes.values()) {
             if (iccTagDataType.getSignature() == quad) {
                 return iccTagDataType;
@@ -74,8 +70,7 @@ public class IccTag implements BinaryCon
         return null;
     }
 
-    public void dump(String prefix) throws ImageReadException, IOException
-    {
+    public void dump(String prefix) throws ImageReadException, IOException {
         PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
 
         dump(pw, prefix);
@@ -84,40 +79,35 @@ public class IccTag implements BinaryCon
     }
 
     public void dump(PrintWriter pw, String prefix) throws ImageReadException,
-            IOException
-    {
+            IOException {
         pw.println(prefix
                 + "tag signature: "
                 + Integer.toHexString(signature)
                 + " ("
-                + new String(new byte[]{
-                        (byte) (0xff & (signature >> 24)),
+                + new String(new byte[] { (byte) (0xff & (signature >> 24)),
                         (byte) (0xff & (signature >> 16)),
                         (byte) (0xff & (signature >> 8)),
-                        (byte) (0xff & (signature >> 0)),
-                }) + ")");
+                        (byte) (0xff & (signature >> 0)), }) + ")");
 
         if (data == null)
             pw.println(prefix + "data: " + Arrays.toString(data));
-        else
-        {
+        else {
             pw.println(prefix + "data: " + data.length);
 
             pw.println(prefix
                     + "data type signature: "
                     + Integer.toHexString(data_type_signature)
                     + " ("
-                    + new String(new byte[]{
+                    + new String(new byte[] {
                             (byte) (0xff & (data_type_signature >> 24)),
                             (byte) (0xff & (data_type_signature >> 16)),
                             (byte) (0xff & (data_type_signature >> 8)),
-                            (byte) (0xff & (data_type_signature >> 0)),
-                    }) + ")");
+                            (byte) (0xff & (data_type_signature >> 0)), })
+                    + ")");
 
             if (itdt == null)
                 pw.println(prefix + "IccTagType : " + "unknown");
-            else
-            {
+            else {
                 pw.println(prefix + "IccTagType : " + itdt.getName());
                 itdt.dump(prefix, data);
             }
@@ -128,4 +118,4 @@ public class IccTag implements BinaryCon
         pw.flush();
 
     }
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataType.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataType.java Sat May 26 21:19:03 2012
@@ -20,12 +20,11 @@ import java.io.IOException;
 
 import org.apache.commons.imaging.ImageReadException;
 
-interface IccTagDataType
-{
+interface IccTagDataType {
     String getName();
-    
+
     int getSignature();
-    
-    void dump(String prefix, byte bytes[])
-            throws ImageReadException, IOException;
-}
\ No newline at end of file
+
+    void dump(String prefix, byte bytes[]) throws ImageReadException,
+            IOException;
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagDataTypes.java Sat May 26 21:19:03 2012
@@ -117,8 +117,7 @@ public enum IccTagDataTypes implements I
     public final String name;
     public final int signature;
 
-    IccTagDataTypes(String name, int signature)
-    {
+    IccTagDataTypes(String name, int signature) {
         this.name = name;
         this.signature = signature;
     }

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagType.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagType.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagType.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagType.java Sat May 26 21:19:03 2012
@@ -16,9 +16,10 @@
  */
 package org.apache.commons.imaging.icc;
 
-interface IccTagType
-{
+interface IccTagType {
     String getName();
+
     String getTypeDescription();
+
     int getSignature();
-}
\ No newline at end of file
+}

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/icc/IccTagTypes.java Sat May 26 21:19:03 2012
@@ -318,8 +318,7 @@ public enum IccTagTypes implements IccTa
     public final String type_description;
     public final int signature;
 
-    IccTagTypes(String name, String type_description, int signature)
-    {
+    IccTagTypes(String name, String type_description, int signature) {
         this.name = name;
         this.type_description = type_description;
         this.signature = signature;

Modified: commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java
URL: http://svn.apache.org/viewvc/commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java?rev=1342971&r1=1342970&r2=1342971&view=diff
==============================================================================
--- commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java (original)
+++ commons/proper/imaging/trunk/src/main/java/org/apache/commons/imaging/palette/ColorSpaceSubset.java Sat May 26 21:19:03 2012
@@ -16,26 +16,23 @@
  */
 package org.apache.commons.imaging.palette;
 
-class ColorSpaceSubset implements Comparable<ColorSpaceSubset>
-{
+class ColorSpaceSubset implements Comparable<ColorSpaceSubset> {
     public final int mins[], maxs[];
     public final int precision;
     public final int precision_mask;
     public final int total;
     public int rgb; // median
 
-    public ColorSpaceSubset(int total, int precision)
-    {
+    public ColorSpaceSubset(int total, int precision) {
         this.total = total;
         this.precision = precision;
         precision_mask = (1 << precision) - 1;
 
         mins = new int[PaletteFactory.components];
         maxs = new int[PaletteFactory.components];
-        for (int i = 0; i < PaletteFactory.components; i++)
-        {
+        for (int i = 0; i < PaletteFactory.components; i++) {
             mins[i] = 0;
-            //            maxs[i] = 255;
+            // maxs[i] = 255;
             maxs[i] = precision_mask;
         }
 
@@ -43,8 +40,7 @@ class ColorSpaceSubset implements Compar
     }
 
     public ColorSpaceSubset(int total, int precision, int mins[], int maxs[],
-            int table[])
-    {
+            int table[]) {
         this.total = total;
         this.precision = precision;
         this.mins = mins;
@@ -56,8 +52,7 @@ class ColorSpaceSubset implements Compar
 
     public static long compares = 0;
 
-    public final boolean contains(int red, int green, int blue)
-    {
+    public final boolean contains(int red, int green, int blue) {
         compares++;
 
         red >>= (8 - precision);
@@ -81,8 +76,7 @@ class ColorSpaceSubset implements Compar
         return true;
     }
 
-    public void dump(String prefix)
-    {
+    public void dump(String prefix) {
         int rdiff = maxs[0] - mins[0] + 1;
         int gdiff = maxs[1] - mins[1] + 1;
         int bdiff = maxs[2] - mins[2] + 1;
@@ -90,9 +84,9 @@ class ColorSpaceSubset implements Compar
 
         System.out.println(prefix + ": [" + Integer.toHexString(rgb)
                 + "] total : " + total
-        //                        + " ("
-                //                        + (100.0 * (double) total / (double) total_area)
-                //                        + " %)"
+        // + " ("
+        // + (100.0 * (double) total / (double) total_area)
+        // + " %)"
                 );
         System.out.println("\t" + "rgb: " + Integer.toHexString(rgb) + ", "
                 + "red: " + Integer.toHexString(mins[0] << (8 - precision))
@@ -110,8 +104,7 @@ class ColorSpaceSubset implements Compar
                         + color_area);
     }
 
-    public void dumpJustRGB(String prefix)
-    {
+    public void dumpJustRGB(String prefix) {
         System.out.println("\t" + "rgb: " + Integer.toHexString(rgb) + ", "
                 + "red: " + Integer.toHexString(mins[0] << (8 - precision))
                 + ", " + Integer.toHexString(maxs[0] << (8 - precision)) + ", "
@@ -121,8 +114,7 @@ class ColorSpaceSubset implements Compar
                 + ", " + Integer.toHexString(maxs[2] << (8 - precision)));
     }
 
-    public int getArea()
-    {
+    public int getArea() {
         int rdiff = maxs[0] - mins[0] + 1;
         int gdiff = maxs[1] - mins[1] + 1;
         int bdiff = maxs[2] - mins[2] + 1;
@@ -132,8 +124,7 @@ class ColorSpaceSubset implements Compar
 
     }
 
-    public void setAverageRGB(int table[])
-    {
+    public void setAverageRGB(int table[]) {
 
         {
             long redsum = 0, greensum = 0, bluesum = 0;
@@ -141,11 +132,12 @@ class ColorSpaceSubset implements Compar
             for (int red = mins[0]; red <= maxs[0]; red++)
                 for (int green = mins[1]; green <= maxs[1]; green++)
                     for (int blue = mins[2]; blue <= maxs[2]; blue++)
-                    //                    for (int red = 0; red <= precision_mask; red++)
-                    //                        for (int green = 0; green <= precision_mask; green++)
-                    //                            for (int blue = 0; blue <= precision_mask; blue++)
+                    // for (int red = 0; red <= precision_mask; red++)
+                    // for (int green = 0; green <= precision_mask; green++)
+                    // for (int blue = 0; blue <= precision_mask; blue++)
                     {
-                        int index = (blue << (2 * precision)) // note: order reversed
+                        int index = (blue << (2 * precision)) // note: order
+                                                              // reversed
                                 | (green << (1 * precision))
                                 | (red << (0 * precision));
                         int count = table[index];
@@ -162,16 +154,14 @@ class ColorSpaceSubset implements Compar
         }
     }
 
-    public int compareTo(ColorSpaceSubset other)
-    {
+    public int compareTo(ColorSpaceSubset other) {
         return rgb - other.rgb;
     }
 
     public int index;
 
-    public final void setIndex(int i)
-    {
+    public final void setIndex(int i) {
         index = i;
     }
-    
-}
\ No newline at end of file
+
+}



Mime
View raw message