commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject svn commit: r1221504 [2/2] - in /commons/proper/sanselan/trunk: ./ src/main/java/org/apache/commons/sanselan/ src/main/java/org/apache/commons/sanselan/common/ src/main/java/org/apache/commons/sanselan/common/itu_t4/ src/main/java/org/apache/commons/sa...
Date Tue, 20 Dec 2011 22:09:50 GMT
Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/TiffReader.java
Tue Dec 20 22:09:48 2011
@@ -97,14 +97,14 @@ public class TiffReader extends BinaryFi
         int offset = tiffHeader.offsetToFirstIFD;
         int dirType = TiffDirectory.DIRECTORY_TYPE_ROOT;
 
-        List visited = new ArrayList();
+        List<Number> visited = new ArrayList<Number>();
         readDirectory(byteSource, offset, dirType, formatCompliance, listener,
                 visited);
     }
 
     private boolean readDirectory(ByteSource byteSource, int offset,
             int dirType, FormatCompliance formatCompliance, Listener listener,
-            List visited) throws ImageReadException, IOException
+            List<Number> visited) throws ImageReadException, IOException
     {
         boolean ignoreNextDirectory = false;
         return readDirectory(byteSource, offset, dirType, formatCompliance,
@@ -113,7 +113,7 @@ public class TiffReader extends BinaryFi
 
     private boolean readDirectory(ByteSource byteSource, int offset,
             int dirType, FormatCompliance formatCompliance, Listener listener,
-            boolean ignoreNextDirectory, List visited)
+            boolean ignoreNextDirectory, List<Number> visited)
             throws ImageReadException, IOException
     {
         Number key = new Integer(offset);
@@ -138,7 +138,7 @@ public class TiffReader extends BinaryFi
             if (offset > 0)
                 is.skip(offset);
 
-            List fields = new ArrayList();
+            List<TiffField> fields = new ArrayList<TiffField>();
 
             if (offset >= byteSource.getLength())
             {
@@ -242,10 +242,10 @@ public class TiffReader extends BinaryFi
 
             if (listener.readOffsetDirectories())
             {
-                List fieldsToRemove = new ArrayList();
+                List<TiffField> fieldsToRemove = new ArrayList<TiffField>();
                 for (int j = 0; j < fields.size(); j++)
                 {
-                    TiffField entry = (TiffField) fields.get(j);
+                    TiffField entry = fields.get(j);
 
                     if (entry.tag == TiffConstants.EXIF_TAG_EXIF_OFFSET.tag
                             || entry.tag == TiffConstants.EXIF_TAG_GPSINFO.tag
@@ -321,8 +321,8 @@ public class TiffReader extends BinaryFi
     private static class Collector implements Listener
     {
         private TiffHeader tiffHeader = null;
-        private List directories = new ArrayList();
-        private List fields = new ArrayList();
+        private List<TiffDirectory> directories = new ArrayList<TiffDirectory>();
+        private List<TiffField> fields = new ArrayList<TiffField>();
         private final boolean readThumbnails;
 
         public Collector()

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterBase.java
Tue Dec 20 22:09:48 2011
@@ -62,7 +62,7 @@ public abstract class TiffImageWriterBas
     protected TiffOutputSummary validateDirectories(TiffOutputSet outputSet)
             throws ImageWriteException
     {
-        List directories = outputSet.getDirectories();
+        List<TiffOutputDirectory> directories = outputSet.getDirectories();
 
         if (1 > directories.size())
             throw new ImageWriteException("No directories.");
@@ -74,11 +74,11 @@ public abstract class TiffImageWriterBas
         TiffOutputField gpsDirectoryOffsetField = null;
         TiffOutputField interoperabilityDirectoryOffsetField = null;
 
-        List directoryIndices = new ArrayList();
-        Map directoryTypeMap = new HashMap();
+        List<Integer> directoryIndices = new ArrayList<Integer>();
+        Map<Integer, TiffOutputDirectory> directoryTypeMap = new HashMap<Integer,
TiffOutputDirectory>();
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
             int dirType = directory.type;
             Integer key = new Integer(dirType);
@@ -124,7 +124,7 @@ public abstract class TiffImageWriterBas
                 // dirMap.put(arg0, arg1)
             }
 
-            HashSet fieldTags = new HashSet();
+            HashSet<Integer> fieldTags = new HashSet<Integer>();
             List fields = directory.getFields();
             for (int j = 0; j < fields.size(); j++)
             {
@@ -170,19 +170,19 @@ public abstract class TiffImageWriterBas
         TiffOutputDirectory previousDirectory = null;
         for (int i = 0; i < directoryIndices.size(); i++)
         {
-            Integer index = (Integer) directoryIndices.get(i);
+            Integer index = directoryIndices.get(i);
             if (index.intValue() != i)
                 throw new ImageWriteException("Missing directory: " + i + ".");
 
             // set up chain of directory references for "normal" directories.
-            TiffOutputDirectory directory = (TiffOutputDirectory) directoryTypeMap
+            TiffOutputDirectory directory = directoryTypeMap
                     .get(index);
             if (null != previousDirectory)
                 previousDirectory.setNextDirectory(directory);
             previousDirectory = directory;
         }
 
-        TiffOutputDirectory rootDirectory = (TiffOutputDirectory) directoryTypeMap
+        TiffOutputDirectory rootDirectory = directoryTypeMap
                 .get(new Integer(DIRECTORY_TYPE_ROOT));
 
         // prepare results

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffImageWriterLossless.java
Tue Dec 20 22:09:48 2011
@@ -67,7 +67,7 @@ public class TiffImageWriterLossless ext
     //        }
     //    }
 
-    private void dumpElements(List elements) throws IOException
+    private void dumpElements(List<TiffElement> elements) throws IOException
     {
         //        try
         //        {
@@ -81,13 +81,13 @@ public class TiffImageWriterLossless ext
         //        }
     }
 
-    private void dumpElements(ByteSource byteSource, List elements)
+    private void dumpElements(ByteSource byteSource, List<TiffElement> elements)
             throws IOException
     {
         int last = TIFF_HEADER_SIZE;
         for (int i = 0; i < elements.size(); i++)
         {
-            TiffElement element = (TiffElement) elements.get(i);
+            TiffElement element = elements.get(i);
             if (element.offset > last)
             {
                 final int SLICE_SIZE = 32;
@@ -132,16 +132,16 @@ public class TiffImageWriterLossless ext
             List elements = new ArrayList();
             //            result.add(contents.header); // ?
 
-            List directories = contents.directories;
+            List<TiffDirectory> directories = contents.directories;
             for (int d = 0; d < directories.size(); d++)
             {
-                TiffDirectory directory = (TiffDirectory) directories.get(d);
+                TiffDirectory directory = directories.get(d);
                 elements.add(directory);
 
-                List fields = directory.getDirectoryEntrys();
+                List<TiffField> fields = directory.getDirectoryEntrys();
                 for (int f = 0; f < fields.size(); f++)
                 {
-                    TiffField field = (TiffField) fields.get(f);
+                    TiffField field = fields.get(f);
                     TiffElement oversizeValue = field.getOversizeValueElement();
                     if (oversizeValue != null)
                         elements.add(oversizeValue);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputDirectory.java
Tue Dec 20 22:09:48 2011
@@ -68,7 +68,7 @@ public final class TiffOutputDirectory e
 
     public void removeField(int tag)
     {
-        List matches = new ArrayList();
+        List<TiffOutputField> matches = new ArrayList<TiffOutputField>();
         for (int i = 0; i < fields.size(); i++)
         {
             TiffOutputField field = (TiffOutputField) fields.get(i);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSet.java
Tue Dec 20 22:09:48 2011
@@ -27,7 +27,7 @@ import org.apache.commons.sanselan.util.
 public final class TiffOutputSet implements TiffConstants
 {
     public final int byteOrder;
-    private final List directories = new ArrayList();
+    private final List<TiffOutputDirectory> directories = new ArrayList<TiffOutputDirectory>();
 
     public TiffOutputSet()
     {
@@ -47,7 +47,7 @@ public final class TiffOutputSet impleme
 
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
 
             result.addAll(directory.getOutputItems(outputSummary));
@@ -65,9 +65,9 @@ public final class TiffOutputSet impleme
         directories.add(directory);
     }
 
-    public List getDirectories()
+    public List<TiffOutputDirectory> getDirectories()
     {
-        return new ArrayList(directories);
+        return new ArrayList<TiffOutputDirectory>(directories);
     }
 
     public TiffOutputDirectory getRootDirectory()
@@ -127,7 +127,7 @@ public final class TiffOutputSet impleme
     {
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
             if (directory.type == directoryType)
                 return directory;
@@ -219,7 +219,7 @@ public final class TiffOutputSet impleme
     {
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
             directory.removeField(tag);
         }
@@ -234,7 +234,7 @@ public final class TiffOutputSet impleme
     {
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
             TiffOutputField field = directory.findField(tag);
             if (null != field)
@@ -301,7 +301,7 @@ public final class TiffOutputSet impleme
 
         for (int i = 0; i < directories.size(); i++)
         {
-            TiffOutputDirectory directory = (TiffOutputDirectory) directories
+            TiffOutputDirectory directory = directories
                     .get(i);
             result.append(prefix);
             result.append("\t" + "directory " + i + ": "

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSummary.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSummary.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSummary.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/tiff/write/TiffOutputSummary.java
Tue Dec 20 22:09:48 2011
@@ -27,10 +27,10 @@ class TiffOutputSummary implements TiffC
 {
     public final int byteOrder;
     public final TiffOutputDirectory rootDirectory;
-    public final Map directoryTypeMap;
+    public final Map<Integer, TiffOutputDirectory> directoryTypeMap;
 
     public TiffOutputSummary(final int byteOrder,
-            final TiffOutputDirectory rootDirectory, final Map directoryTypeMap)
+            final TiffOutputDirectory rootDirectory, final Map<Integer, TiffOutputDirectory>
directoryTypeMap)
     {
         this.byteOrder = byteOrder;
         this.rootDirectory = rootDirectory;
@@ -51,7 +51,7 @@ class TiffOutputSummary implements TiffC
         }
     }
 
-    private List offsetItems = new ArrayList();
+    private List<OffsetItem> offsetItems = new ArrayList<OffsetItem>();
 
     public void add(final TiffOutputItem item,
             final TiffOutputField itemOffsetField)
@@ -63,7 +63,7 @@ class TiffOutputSummary implements TiffC
     {
         for (int i = 0; i < offsetItems.size(); i++)
         {
-            OffsetItem offset = (OffsetItem) offsetItems.get(i);
+            OffsetItem offset = offsetItems.get(i);
 
             byte value[] = FIELD_TYPE_LONG.writeData(new int[]{
                 offset.item.getOffset(),
@@ -73,7 +73,7 @@ class TiffOutputSummary implements TiffC
 
         for (int i = 0; i < imageDataItems.size(); i++)
         {
-            ImageDataOffsets imageDataInfo = (ImageDataOffsets) imageDataItems
+            ImageDataOffsets imageDataInfo = imageDataItems
                     .get(i);
 
             for (int j = 0; j < imageDataInfo.outputItems.length; j++)
@@ -87,7 +87,7 @@ class TiffOutputSummary implements TiffC
         }
     }
 
-    private List imageDataItems = new ArrayList();
+    private List<ImageDataOffsets> imageDataItems = new ArrayList<ImageDataOffsets>();
 
     public void addTiffImageData(final ImageDataOffsets imageDataInfo)
     {

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/wbmp/WbmpImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/wbmp/WbmpImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/wbmp/WbmpImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/wbmp/WbmpImageParser.java
Tue Dec 20 22:09:48 2011
@@ -88,7 +88,7 @@ public class WbmpImageParser extends Ima
             throws ImageReadException, IOException
     {
         WbmpHeader wbmpHeader = readWbmpHeader(byteSource);
-        return new ImageInfo("WBMP", 1, new ArrayList(),
+        return new ImageInfo("WBMP", 1, new ArrayList<String>(),
                 ImageFormat.IMAGE_FORMAT_WBMP,
                 "Wireless Application Protocol Bitmap",
                 wbmpHeader.height, "image/vnd.wap.wbmp", 1,

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xbm/XbmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xbm/XbmImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xbm/XbmImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xbm/XbmImageParser.java
Tue Dec 20 22:09:48 2011
@@ -95,7 +95,7 @@ public class XbmImageParser extends Imag
     {
         XbmHeader xbmHeader = readXbmHeader(byteSource);
         return new ImageInfo("XBM", 1,
-                new ArrayList(), ImageFormat.IMAGE_FORMAT_XBM,
+                new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XBM,
                 "X BitMap",
                 xbmHeader.height, "image/x-xbitmap", 1,
                 0, 0, 0, 0,
@@ -167,25 +167,25 @@ public class XbmImageParser extends Imag
         try
         {
             is = byteSource.getInputStream();
-            Map defines = new HashMap();
+            Map<String, String> defines = new HashMap<String, String>();
             ByteArrayOutputStream preprocessedFile = BasicCParser.preprocess(
                     is, null, defines);
             int width = -1;
             int height = -1;
             int xHot = -1;
             int yHot = -1;
-            for (Iterator it = defines.entrySet().iterator(); it.hasNext();)
+            for (Iterator<Map.Entry<String,String>> it = defines.entrySet().iterator();
it.hasNext();)
             {
-                Map.Entry entry = (Map.Entry)it.next();
-                String name = (String)entry.getKey();
+                Map.Entry<String, String> entry = it.next();
+                String name = entry.getKey();
                 if (name.endsWith("_width"))
-                    width = Integer.parseInt((String)entry.getValue());
+                    width = Integer.parseInt(entry.getValue());
                 else if (name.endsWith("_height"))
-                    height = Integer.parseInt((String)entry.getValue());
+                    height = Integer.parseInt(entry.getValue());
                 else if (name.endsWith("_x_hot"))
-                    xHot = Integer.parseInt((String)entry.getValue());
+                    xHot = Integer.parseInt(entry.getValue());
                 else if (name.endsWith("_y_hot"))
-                    yHot = Integer.parseInt((String)entry.getValue());
+                    yHot = Integer.parseInt(entry.getValue());
             }
             if (width == -1)
                 throw new ImageReadException("width not found");

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xpm/XpmImageParser.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xpm/XpmImageParser.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xpm/XpmImageParser.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/formats/xpm/XpmImageParser.java
Tue Dec 20 22:09:48 2011
@@ -53,7 +53,7 @@ import org.apache.commons.sanselan.util.
 
 public class XpmImageParser extends ImageParser
 {
-    private static Map colorNames = null;
+    private static Map<String, Integer> colorNames = null;
 
     public XpmImageParser()
     {
@@ -74,7 +74,7 @@ public class XpmImageParser extends Imag
             }
             reader = new BufferedReader(new InputStreamReader(rgbTxtStream,
                     "US-ASCII"));
-            Map colors = new HashMap();
+            Map<String, Integer> colors = new HashMap<String, Integer>();
             String line;
             while ((line = reader.readLine()) != null)
             {
@@ -159,10 +159,10 @@ public class XpmImageParser extends Imag
         XpmHeader xpmHeader = readXpmHeader(byteSource);
         boolean isTransparent = false;
         int colorType = ImageInfo.COLOR_TYPE_BW;
-        for (Iterator it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
+        for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator();
it.hasNext();)
         {
-            Map.Entry entry = (Map.Entry)it.next();
-            PaletteEntry paletteEntry = (PaletteEntry)entry.getValue();
+            Map.Entry<Object, PaletteEntry> entry = it.next();
+            PaletteEntry paletteEntry = entry.getValue();
             if ((paletteEntry.getBestARGB() & 0xff000000) != 0xff000000)
                 isTransparent = true;
             if (paletteEntry.haveColor)
@@ -172,7 +172,7 @@ public class XpmImageParser extends Imag
                 colorType = ImageInfo.COLOR_TYPE_GRAYSCALE;
         }
         return new ImageInfo("XPM version 3", xpmHeader.numCharsPerPixel * 8,
-                new ArrayList(), ImageFormat.IMAGE_FORMAT_XPM,
+                new ArrayList<String>(), ImageFormat.IMAGE_FORMAT_XPM,
                 "X PixMap",
                 xpmHeader.height, "image/x-xpixmap", 1,
                 0, 0, 0, 0,
@@ -206,7 +206,7 @@ public class XpmImageParser extends Imag
         int yHotSpot = -1;
         boolean xpmExt;
         
-        Map palette = new HashMap();
+        Map<Object, PaletteEntry> palette = new HashMap<Object, PaletteEntry>();
 
         public XpmHeader(int width, int height, int numColors,
                 int numCharsPerPixel, int xHotSpot, int yHotSpot,
@@ -416,7 +416,7 @@ public class XpmImageParser extends Imag
             if (!loadColorNames())
                 return 0x00000000;
             if (colorNames.containsKey(color))
-                return ((Integer)colorNames.get(color)).intValue();
+                return (colorNames.get(color)).intValue();
             else
                 return 0x00000000;
         }
@@ -587,10 +587,10 @@ public class XpmImageParser extends Imag
         if (xpmHeader.palette.size() <= (1 << 8))
         {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
+            for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator();
it.hasNext();)
             {
-                Map.Entry entry = (Map.Entry)it.next();
-                PaletteEntry paletteEntry = (PaletteEntry)entry.getValue();
+                Map.Entry<Object, PaletteEntry> entry = it.next();
+                PaletteEntry paletteEntry = entry.getValue();
                 palette[paletteEntry.index] = paletteEntry.getBestARGB();
             }
             colorModel = new IndexColorModel(8, xpmHeader.palette.size(),
@@ -602,10 +602,10 @@ public class XpmImageParser extends Imag
         else if (xpmHeader.palette.size() <= (1 << 16))
         {
             int[] palette = new int[xpmHeader.palette.size()];
-            for (Iterator it = xpmHeader.palette.entrySet().iterator(); it.hasNext();)
+            for (Iterator<Map.Entry<Object,PaletteEntry>> it = xpmHeader.palette.entrySet().iterator();
it.hasNext();)
             {
-                Map.Entry entry = (Map.Entry)it.next();
-                PaletteEntry paletteEntry = (PaletteEntry)entry.getValue();
+                Map.Entry<Object, PaletteEntry> entry = it.next();
+                PaletteEntry paletteEntry = entry.getValue();
                 palette[paletteEntry.index] = paletteEntry.getBestARGB();
             }
             colorModel = new IndexColorModel(16, xpmHeader.palette.size(),
@@ -641,7 +641,7 @@ public class XpmImageParser extends Imag
             {
                 String index = row.substring(x*xpmHeader.numCharsPerPixel,
                         (x + 1)*xpmHeader.numCharsPerPixel);
-                PaletteEntry paletteEntry = (PaletteEntry) xpmHeader.palette.get(index);
+                PaletteEntry paletteEntry = xpmHeader.palette.get(index);
                 if (paletteEntry == null) {
                     throw new ImageReadException("No palette entry was defined " +
                             "for " + index);

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/MedianCutQuantizer.java
Tue Dec 20 22:09:48 2011
@@ -74,7 +74,7 @@ public class MedianCutQuantizer
         //        public final List children = new ArrayList();
         public int palette_index = -1;
 
-        public final List color_counts;
+        public final List<ColorCount> color_counts;
         public int min_red = Integer.MAX_VALUE;
         public int max_red = Integer.MIN_VALUE;
         public int min_green = Integer.MAX_VALUE;
@@ -92,7 +92,7 @@ public class MedianCutQuantizer
         public final int max_diff;
         public final int diff_total;
 
-        public ColorGroup(final List color_counts) throws ImageWriteException
+        public ColorGroup(final List<ColorCount> color_counts) throws ImageWriteException
         {
             this.color_counts = color_counts;
 
@@ -101,7 +101,7 @@ public class MedianCutQuantizer
 
             for (int i = 0; i < color_counts.size(); i++)
             {
-                ColorCount color = (ColorCount) color_counts.get(i);
+                ColorCount color = color_counts.get(i);
 
                 min_alpha = Math.min(min_alpha, color.alpha);
                 max_alpha = Math.max(max_alpha, color.alpha);
@@ -149,7 +149,7 @@ public class MedianCutQuantizer
 
             for (int i = 0; i < color_counts.size(); i++)
             {
-                ColorCount color = (ColorCount) color_counts.get(i);
+                ColorCount color = color_counts.get(i);
 
                 count_total += color.count;
                 alpha_total += color.count * color.alpha;
@@ -183,9 +183,9 @@ public class MedianCutQuantizer
 
     }
 
-    public Map groupColors1(BufferedImage image, int max, int mask)
+    public Map<Integer, ColorCount> groupColors1(BufferedImage image, int max, int
mask)
     {
-        Map color_map = new HashMap();
+        Map<Integer, ColorCount> color_map = new HashMap<Integer, ColorCount>();
 
         int width = image.getWidth();
         int height = image.getHeight();
@@ -202,7 +202,7 @@ public class MedianCutQuantizer
                     argb &= 0xffffff;
                 argb &= mask;
 
-                ColorCount color = (ColorCount) color_map
+                ColorCount color = color_map
                         .get(new Integer(argb));
                 if (color == null)
                 {
@@ -218,7 +218,7 @@ public class MedianCutQuantizer
         return color_map;
     }
 
-    public Map groupColors(BufferedImage image, int max_colors)
+    public Map<Integer, ColorCount> groupColors(BufferedImage image, int max_colors)
     {
         int max = Integer.MAX_VALUE;
 
@@ -227,10 +227,9 @@ public class MedianCutQuantizer
             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 result = groupColors1(image, max, mask);
+            Map<Integer, ColorCount> result = groupColors1(image, max, mask);
             if (result != null)
                 return result;
         }
@@ -240,7 +239,7 @@ public class MedianCutQuantizer
     public Palette process(BufferedImage image, int max_colors, boolean verbose)
             throws ImageWriteException
     {
-        Map color_map = groupColors(image, max_colors);
+        Map<Integer, ColorCount> color_map = groupColors(image, max_colors);
 
         int discrete_colors = color_map.keySet().size();
         if (discrete_colors <= max_colors)
@@ -249,11 +248,11 @@ public class MedianCutQuantizer
                 Debug.debug("lossless palette: " + discrete_colors);
 
             int palette[] = new int[discrete_colors];
-            List color_counts = new ArrayList(color_map.values());
+            List<ColorCount> color_counts = new ArrayList<ColorCount>(color_map.values());
 
             for (int i = 0; i < color_counts.size(); i++)
             {
-                ColorCount color_count = (ColorCount) color_counts.get(i);
+                ColorCount color_count = color_counts.get(i);
                 palette[i] = color_count.argb;
                 if (ignoreAlpha)
                     palette[i] |= 0xff000000;
@@ -265,18 +264,15 @@ public class MedianCutQuantizer
         if (verbose)
             Debug.debug("discrete colors: " + discrete_colors);
 
-        List color_groups = new ArrayList();
-        ColorGroup root = new ColorGroup(new ArrayList(color_map.values()));
+        List<ColorGroup> color_groups = new ArrayList<ColorGroup>();
+        ColorGroup root = new ColorGroup(new ArrayList<ColorCount>(color_map.values()));
         {
             color_groups.add(root);
 
-            final Comparator comparator = new Comparator()
+            final Comparator<ColorGroup> comparator = new Comparator<ColorGroup>()
             {
-                public int compare(Object o1, Object o2)
+                public int compare(ColorGroup cg1, ColorGroup cg2)
                 {
-                    ColorGroup cg1 = (ColorGroup) o1;
-                    ColorGroup cg2 = (ColorGroup) o2;
-
                     if (cg1.max_diff == cg2.max_diff)
                         return cg2.diff_total - cg1.diff_total;
                     return cg2.max_diff - cg1.max_diff;
@@ -287,7 +283,7 @@ public class MedianCutQuantizer
             {
                 Collections.sort(color_groups, comparator);
 
-                ColorGroup color_group = (ColorGroup) color_groups.get(0);
+                ColorGroup color_group = color_groups.get(0);
 
                 if (color_group.max_diff == 0)
                     break;
@@ -323,7 +319,7 @@ public class MedianCutQuantizer
 
             for (int i = 0; i < color_groups.size(); i++)
             {
-                ColorGroup color_group = (ColorGroup) color_groups.get(i);
+                ColorGroup color_group = color_groups.get(i);
 
                 palette[i] = color_group.getMedianValue();
 
@@ -351,24 +347,19 @@ 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 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++)
         {
-            ColorCount color_count = (ColorCount) color_group.color_counts
-                    .get(i);
+            ColorCount color_count = color_group.color_counts.get(i);
             count_total += color_count.count;
         }
 
-        Comparator comparator = new Comparator()
+        Comparator<ColorCount> comparator = new Comparator<ColorCount>()
         {
-            public int compare(Object o1, Object o2)
+            public int compare(ColorCount c1, ColorCount c2)
             {
-                ColorCount c1 = (ColorCount) o1;
-                ColorCount c2 = (ColorCount) o2;
-
                 switch (mode)
                 {
                     case ALPHA :
@@ -391,8 +382,7 @@ public class MedianCutQuantizer
         int median_index;
         for (median_index = 0; median_index < color_group.color_counts.size(); median_index++)
         {
-            ColorCount color_count = (ColorCount) color_group.color_counts
-                    .get(median_index);
+            ColorCount color_count = color_group.color_counts.get(median_index);
 
             new_count += color_count.count;
 
@@ -416,23 +406,20 @@ public class MedianCutQuantizer
 
         color_groups.remove(color_group);
         {
-            List color_counts1 = new ArrayList(color_group.color_counts
-                    .subList(0, median_index + 1));
-            List color_counts2 = new ArrayList(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;
             {
-                less = new ColorGroup(new ArrayList(color_counts1));
+                less = new ColorGroup(new ArrayList<ColorCount>(color_counts1));
                 color_groups.add(less);
             }
             {
-                more = new ColorGroup(new ArrayList(color_counts2));
+                more = new ColorGroup(new ArrayList<ColorCount>(color_counts2));
                 color_groups.add(more);
             }
 
-            ColorCount median_value = (ColorCount) color_group.color_counts
-                    .get(median_index);
+            ColorCount median_value = color_group.color_counts.get(median_index);
             int limit;
             switch (mode)
             {
@@ -512,9 +499,7 @@ public class MedianCutQuantizer
 
             while (cg.cut != null)
             {
-                ColorGroup next = cg.cut.getColorGroup(rgb);
-
-                cg = next;
+                cg = cg.cut.getColorGroup(rgb);
             }
 
             return cg.palette_index;

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/PaletteFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/PaletteFactory.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/PaletteFactory.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/PaletteFactory.java
Tue Dec 20 22:09:48 2011
@@ -200,8 +200,8 @@ public class PaletteFactory
 
     }
 
-    private List 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 + "): ");
@@ -243,7 +243,7 @@ public class PaletteFactory
         DivisionCandidate dc2 = finishDivision(table, subset, component,
                 precision, sum2, slice2);
 
-        List result = new ArrayList();
+        List<DivisionCandidate> result = new ArrayList<DivisionCandidate>();
 
         if (dc1 != null)
             result.add(dc1);
@@ -256,7 +256,7 @@ public class PaletteFactory
     private DivisionCandidate divideSubset2(int table[],
             ColorSpaceSubset subset, int precision)
     {
-        List dcs = new ArrayList();
+        List<DivisionCandidate> dcs = new ArrayList<DivisionCandidate>();
 
         dcs.addAll(divideSubset2(table, subset, 0, precision));
         dcs.addAll(divideSubset2(table, subset, 1, precision));
@@ -268,7 +268,7 @@ public class PaletteFactory
 
         for (int i = 0; i < dcs.size(); i++)
         {
-            DivisionCandidate dc = (DivisionCandidate) dcs.get(i);
+            DivisionCandidate dc = dcs.get(i);
 
             ColorSpaceSubset first = dc.dst_a;
             ColorSpaceSubset second = dc.dst_b;
@@ -312,10 +312,10 @@ public class PaletteFactory
         }
     }
 
-    private List divide(List v, int desired_count, int table[],
-            int precision)
+    private List<ColorSpaceSubset> divide(List<ColorSpaceSubset> v, int desired_count,
int table[],
+                                          int precision)
     {
-        List ignore = new ArrayList();
+        List<ColorSpaceSubset> ignore = new ArrayList<ColorSpaceSubset>();
 
         int count = 0;
         while (true)
@@ -331,7 +331,7 @@ public class PaletteFactory
 
             for (int i = 0; i < v.size(); i++)
             {
-                ColorSpaceSubset subset = (ColorSpaceSubset) v.get(i);
+                ColorSpaceSubset subset = v.get(i);
                 if (ignore.contains(subset))
                     continue;
                 int area = subset.total;
@@ -387,7 +387,7 @@ public class PaletteFactory
         int width = src.getWidth();
         int height = src.getHeight();
 
-        List subsets = new ArrayList();
+        List<ColorSpaceSubset> subsets = new ArrayList<ColorSpaceSubset>();
         ColorSpaceSubset all = new ColorSpaceSubset(width * height, precision);
         subsets.add(all);
 
@@ -426,7 +426,7 @@ public class PaletteFactory
 
         for (int i = 0; i < subsets.size(); i++)
         {
-            ColorSpaceSubset subset = (ColorSpaceSubset) subsets.get(i);
+            ColorSpaceSubset subset = subsets.get(i);
 
             subset.setAverageRGB(table);
 
@@ -442,7 +442,7 @@ public class PaletteFactory
     public SimplePalette makePaletteSimple(BufferedImage src, int max)
     // This is not efficient for large values of max, say, max > 256;
     {
-        Map map = new HashMap();
+        Map<String, String> map = new HashMap<String, String>();
         int rgbs[] = new int[max];
         int rgb_count = 0;
 

Modified: commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/QuantizedPalette.java
URL: http://svn.apache.org/viewvc/commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/QuantizedPalette.java?rev=1221504&r1=1221503&r2=1221504&view=diff
==============================================================================
--- commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/QuantizedPalette.java
(original)
+++ commons/proper/sanselan/trunk/src/main/java/org/apache/commons/sanselan/palette/QuantizedPalette.java
Tue Dec 20 22:09:48 2011
@@ -23,10 +23,10 @@ import org.apache.commons.sanselan.Image
 public class QuantizedPalette extends Palette
 {
     private final int precision;
-    private final List subsets;
+    private final List<ColorSpaceSubset> subsets;
     private final ColorSpaceSubset straight[];
 
-    public QuantizedPalette(List subsets, int precision)
+    public QuantizedPalette(List<ColorSpaceSubset> subsets, int precision)
     {
         this.subsets = subsets;
         this.precision = precision;
@@ -36,7 +36,7 @@ public class QuantizedPalette extends Pa
 
             for (int i = 0; i < subsets.size(); i++)
             {
-                ColorSpaceSubset subset = (ColorSpaceSubset) subsets.get(i);
+                ColorSpaceSubset subset = subsets.get(i);
                 subset.setIndex(i);
 
                 for (int u = subset.mins[0]; u <= subset.maxs[0]; u++)
@@ -74,7 +74,7 @@ public class QuantizedPalette extends Pa
 
     public int getEntry(int index)
     {
-        ColorSpaceSubset subset = (ColorSpaceSubset) subsets.get(index);
+        ColorSpaceSubset subset = subsets.get(index);
         return subset.rgb;
     }
 



Mime
View raw message