harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndbe...@apache.org
Subject svn commit: r465514 - in /incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl: font/ image/
Date Thu, 19 Oct 2006 06:54:48 GMT
Author: ndbeyer
Date: Wed Oct 18 23:54:47 2006
New Revision: 465514

URL: http://svn.apache.org/viewvc?view=rev&rev=465514
Log:
Cleanup code
* Add if/else braces
* Add missing annotations
* Add type variables
* Use foreach loops
* etc

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextDecorator.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextMetricsCalculator.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextRunBreaker.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageGraphics2D.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageSource.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ByteArrayDecodingImageSource.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/DecodingImageSource.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/FileDecodingImageSource.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageDecoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageLoader.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OrdinaryWritableRaster.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/URLDecodingImageSource.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontManager.java Wed Oct 18 23:54:47 2006
@@ -194,7 +194,7 @@
      * Table with all available font properties corresponding
      * to the current system configuration.
      */
-    public Hashtable fProperties = new Hashtable();
+    public Hashtable<String, Vector<FontProperty>> fProperties = new Hashtable<String, Vector<FontProperty>>();
 
     public FontManager(){
         allFamilies = getAllFamilies();
@@ -207,14 +207,14 @@
     }
 
     /**
-     * Maximum number of unreferensed font peers to keep.
+     * Maximum number of unreferenced font peers to keep.
      */
     public static final int EMPTY_FONTS_CAPACITY = 10;
 
     /**
      * Locale - Language ID hash table.
      */
-    Hashtable tableLCID = new Hashtable();
+    Hashtable<String, Short> tableLCID = new Hashtable<String, Short>();
 
     /**
      * Hash table that contains FontPeers instances.
@@ -226,7 +226,7 @@
      * ReferenceQueue for HashMapReference objects to check
      * if they were collected by garbage collector. 
      */
-    public ReferenceQueue queue = new ReferenceQueue();
+    public ReferenceQueue<FontPeer> queue = new ReferenceQueue<FontPeer>();
 
     /**
      * Singleton instance
@@ -237,7 +237,7 @@
     /**
      * Gets singleton instance of FontManager
      * 
-     * @return instanse of FontManager implementation
+     * @return instance of FontManager implementation
      */
     public static FontManager getInstance() {
         return inst;
@@ -245,11 +245,11 @@
 
     /**
      * Returns platform-dependent Font peer created from the specified 
-     * Font object from the table with cached FontPeers instanses.
+     * Font object from the table with cached FontPeers instances.
      * 
      * Note, this method checks whether FontPeer with specified parameters 
-     * exists in the table with cached FontPeers' instanses. If there is no needed 
-     * instanse - it is created and cached.
+     * exists in the table with cached FontPeers' instances. If there is no needed 
+     * instance - it is created and cached.
      * 
      * @param fontName name of the font 
      * @param _fontStyle style of the font 
@@ -281,7 +281,7 @@
         
         HashMapReference hmr   = fontsTable.get(key);
         if (hmr != null) {
-            peer = (FontPeer)hmr.get();
+            peer = hmr.get();
         }
 
         if (peer == null) {
@@ -405,7 +405,7 @@
         
         HashMapReference hmr   = fontsTable.get(key);
         if (hmr != null) {
-            peer = (FontPeer)hmr.get();
+            peer = hmr.get();
         }
 
         if (peer == null) {
@@ -500,7 +500,7 @@
             initLCIDTable();
         }
 
-        return (Short)tableLCID.get(l.toString());
+        return tableLCID.get(l.toString());
     }
 
     /**
@@ -573,7 +573,7 @@
         int i = 0;
 
         // OS names from system properties don't match
-        // OS identifiers used in font.peroperty files
+        // OS identifiers used in font.property files
         for (; i < OS_VALUES.length; i++){
             if (os.endsWith(OS_VALUES[i])){
                 os = OS_VALUES[i];
@@ -678,7 +678,7 @@
      * @param fpName key of the font properties in the properties set
      */
     public FontProperty[] getFontProperties(String fpName){
-        Vector props = (Vector)fProperties.get(fpName);
+        Vector<FontProperty> props = fProperties.get(fpName);
         
         if (props == null){
             return null;
@@ -692,7 +692,7 @@
 
         FontProperty[] fps = new FontProperty[size];
         for (int i=0; i < fps.length; i++){
-            fps[i] = (FontProperty)props.elementAt(i);
+            fps[i] = props.elementAt(i);
         }
         return fps;
     }
@@ -765,12 +765,12 @@
      * Class contains SoftReference instance that can be stored in the 
      * Hashtable by means of key field corresponding to it.
      */
-    private class HashMapReference extends SoftReference {
+    private class HashMapReference extends SoftReference<FontPeer> {
         
         /**
          * The key for Hashtable.
          */
-        private final Object key;
+        private final String key;
 
         /**
          * Creates a new soft reference with the key specified and 
@@ -780,8 +780,8 @@
          * @param value object that corresponds to the key
          * @param queue reference queue where reference is to be added 
          */
-        public HashMapReference(final Object key, final Object value,
-                              final ReferenceQueue queue) {
+        public HashMapReference(final String key, final FontPeer value,
+                              final ReferenceQueue<FontPeer> queue) {
             super(value, queue);
             this.key = key;
         }
@@ -803,8 +803,7 @@
     private void updateFontsTable() {
         HashMapReference r;
         while ((r = (HashMapReference)queue.poll()) != null) {
-            Object obj = fontsTable.remove(r.getKey());
-            
+            fontsTable.remove(r.getKey());
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/FontMetricsImpl.java Wed Oct 18 23:54:47 2006
@@ -60,7 +60,7 @@
     private float scaleX = 1;
 
     // Y scale parameter of the font transform
-    private float scaleY = 1;
+    // private float scaleY = 1;
 
     /**
      * Creates new FontMericsImpl object described by the specified Font.
@@ -73,8 +73,7 @@
         AffineTransform at = fnt.getTransform();
         if (!at.isIdentity()){
             scaleX = (float)at.getScaleX();
-            scaleY = (float)at.getScaleY();
-
+            // scaleY = (float)at.getScaleY();
         }
 
         LineMetricsImpl lm = (LineMetricsImpl)peer.getLineMetrics("", null, at);
@@ -181,6 +180,8 @@
      * Returns the maximum descent of the Font describing this 
      * FontMetricsImpl object.
      */
+    @SuppressWarnings("deprecation")
+    @Deprecated
     @Override
     public int getMaxDecent() {
         return this.maxDescent;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextDecorator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextDecorator.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextDecorator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextDecorator.java Wed Oct 18 23:54:47 2006
@@ -31,6 +31,7 @@
 import java.awt.geom.Area;
 import java.awt.geom.Line2D;
 import java.awt.geom.Rectangle2D;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.Map;
 
 /**
@@ -156,7 +157,7 @@
      * @param attributes - text attributes
      * @return Decoration object
      */
-    static Decoration getDecoration(Map attributes) {
+    static Decoration getDecoration(Map<? extends Attribute, ?> attributes) {
         if (attributes == null) {
             return null; // It is for plain text
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextMetricsCalculator.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextMetricsCalculator.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextMetricsCalculator.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextMetricsCalculator.java Wed Oct 18 23:54:47 2006
@@ -83,7 +83,7 @@
      */
     public void checkBaselines() {
         // Take baseline offsets of the first font and normalize them
-        HashMap fonts = breaker.fonts;
+        HashMap<Integer, Font> fonts = breaker.fonts;
 
         Object val = fonts.get(new Integer(0));
 
@@ -111,7 +111,7 @@
             baselineOffsets[0] = 0;
             baselineOffsets[1] = (ga.getDescent() - ga.getAscent()) / 2.f;
             baselineOffsets[2] = -ga.getAscent();
-        } else { // Use defaults - roman baseline and zero offsets
+        } else { // Use defaults - Roman baseline and zero offsets
             baselineIndex = GraphicAttribute.ROMAN_BASELINE;
             baselineOffsets = new float[3];
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextRunBreaker.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextRunBreaker.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextRunBreaker.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/font/TextRunBreaker.java Wed Oct 18 23:54:47 2006
@@ -30,11 +30,12 @@
 import java.awt.*;
 import java.text.AttributedCharacterIterator;
 import java.text.Annotation;
+import java.text.AttributedCharacterIterator.Attribute;
 import java.util.*;
 
 import org.apache.harmony.awt.gl.font.TextDecorator.Decoration;
 import org.apache.harmony.misc.HashCode;
-// XXX - TODO - bidi not implemented yet
+// TODO - bidi not implemented yet
 
 /**
  * This class is responsible for breaking the text into the run segments
@@ -51,21 +52,21 @@
 
     byte[] levels;
 
-    HashMap fonts = null;
-    HashMap<Integer, Decoration> decorations = null;
+    HashMap<Integer, Font> fonts;
+    HashMap<Integer, Decoration> decorations;
 
     // Related to default font substitution
-    int forcedFontRunStarts[] = null;
+    int forcedFontRunStarts[];
 
     ArrayList<TextRunSegment> runSegments = new ArrayList<TextRunSegment>();
 
     // For fast retrieving of the segment containing
     // character with known logical index
-    int logical2segment[] = null;
-    int segment2visual[] = null; // Visual order of segments XXX - todo - implement
-    int visual2segment[] = null;
-    int logical2visual[] = null;
-    int visual2logical[] = null;
+    int logical2segment[];
+    int segment2visual[]; // Visual order of segments TODO - implement
+    int visual2segment[];
+    int logical2visual[];
+    int visual2logical[];
 
     SegmentsInfo storedSegments;
     private boolean haveAllSegments = false;
@@ -155,9 +156,9 @@
      * @param attrs - text attributes
      * @return patched text attributes
      */
-    Map unpackAttributes(Map attrs) {
+    Map<? extends Attribute, ?> unpackAttributes(Map<? extends Attribute, ?> attrs) {
         if (attrs.containsKey(TextAttribute.INPUT_METHOD_HIGHLIGHT)) {
-            Map styles = null;
+            Map<TextAttribute, ?> styles = null;
 
             Object val = attrs.get(TextAttribute.INPUT_METHOD_HIGHLIGHT);
 
@@ -176,7 +177,7 @@
             }
 
             if (styles != null) {
-                HashMap newAttrs = new HashMap();
+                HashMap<Attribute, Object> newAttrs = new HashMap<Attribute, Object>();
                 newAttrs.putAll(attrs);
                 newAttrs.putAll(styles);
                 return newAttrs;
@@ -190,14 +191,14 @@
      * Breaks the text into separate style runs.
      */
     void createStyleRuns() {
-        // XXX - todo - implement fast and simple case
-        fonts = new HashMap();
+        // TODO - implement fast and simple case
+        fonts = new HashMap<Integer, Font>();
         decorations = new HashMap<Integer, Decoration>();
         ////
 
         ArrayList<Integer> forcedFontRunStartsList = null;
 
-        Map attributes = null;
+        Map<? extends Attribute, ?> attributes = null;
 
         // Check justification attribute
         Object val = aci.getAttribute(TextAttribute.JUSTIFICATION);
@@ -219,11 +220,11 @@
             // Find appropriate font or place GraphicAttribute there
 
             // 1. Try to pick up CHAR_REPLACEMENT (compatibility)
-            Object value = attributes.get(TextAttribute.CHAR_REPLACEMENT);
+            Font value = (Font)attributes.get(TextAttribute.CHAR_REPLACEMENT);
 
             if (value == null) {
                 // 2. Try to Get FONT
-                value = attributes.get(TextAttribute.FONT);
+                value = (Font)attributes.get(TextAttribute.FONT);
 
                 if (value == null) {
                     // 3. Try to create font from FAMILY
@@ -301,7 +302,7 @@
     public void createSegments(int runStart, int runEnd) {
         int endStyleRun, endLevelRun;
 
-        // XXX - todo - update levels
+        // TODO - update levels
 
         int pos = runStart, levelPos;
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageGraphics2D.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageGraphics2D.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageGraphics2D.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageGraphics2D.java Wed Oct 18 23:54:47 2006
@@ -53,15 +53,18 @@
         }
     }
 
+    @Override
     public void copyArea(int x, int y, int width, int height, int dx, int dy) {
     }
 
+    @Override
     public Graphics create() {
         BufferedImageGraphics2D res = new BufferedImageGraphics2D(bi);
         copyInternalFields(res);
         return res;
     }
 
+    @Override
     public GraphicsConfiguration getDeviceConfiguration() {
         return null;
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageSource.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/BufferedImageSource.java Wed Oct 18 23:54:47 2006
@@ -36,27 +36,25 @@
 
 public class BufferedImageSource implements ImageProducer {
 
-    private BufferedImage image;
-    private Hashtable properties;
+    private Hashtable<?, ?> properties;
     private ColorModel cm;
     private WritableRaster raster;
-    private int numElem;
     private int width;
     private int height;
 
     private ImageConsumer ic;
 
-    public BufferedImageSource(BufferedImage image, Hashtable properties){
-        this.image = image;
-
-        if(properties == null) this.properties = new Hashtable();
-        else this.properties = properties;
+    public BufferedImageSource(BufferedImage image, Hashtable<?, ?> properties){
+        if(properties == null) {
+            this.properties = new Hashtable<Object, Object>();
+        } else {
+            this.properties = properties;
+        }
 
         width = image.getWidth();
         height = image.getHeight();
         cm = image.getColorModel();
         raster = image.getRaster();
-        numElem = raster.getNumDataElements();
     }
 
     public BufferedImageSource(BufferedImage image){
@@ -75,7 +73,9 @@
     }
 
     public void removeConsumer(ImageConsumer ic) {
-        if (this.ic == ic) this.ic = null;
+        if (this.ic == ic) {
+            this.ic = null;
+        }
     }
 
     public void addConsumer(ImageConsumer ic) {
@@ -127,7 +127,9 @@
             }
             ic.imageComplete(ImageConsumer.STATICIMAGEDONE);
         }catch (NullPointerException e){
-            if (ic != null) ic.imageComplete(ImageConsumer.IMAGEERROR);
+            if (ic != null) {
+                ic.imageComplete(ImageConsumer.IMAGEERROR);
+            }
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ByteArrayDecodingImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ByteArrayDecodingImageSource.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ByteArrayDecodingImageSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ByteArrayDecodingImageSource.java Wed Oct 18 23:54:47 2006
@@ -45,10 +45,12 @@
         this(imagedata, 0, imagedata.length);
     }
 
+    @Override
     protected boolean checkConnection() {
         return true;
     }
 
+    @Override
     protected InputStream getInputStream() {
         return new BufferedInputStream(new ByteArrayInputStream(imagedata,
                 imageoffset, imagelength));

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/DecodingImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/DecodingImageSource.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/DecodingImageSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/DecodingImageSource.java Wed Oct 18 23:54:47 2006
@@ -29,18 +29,19 @@
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Iterator;
+import java.util.List;
 
 /**
- * This is an abstract class that incapsulates a main part of ImageProducer functionality
+ * This is an abstract class that encapsulates a main part of ImageProducer functionality
  * for the images being decoded by the native decoders, like PNG, JPEG and GIF.
  * It helps to integrate image decoders into producer/consumer model. It provides
  * functionality for working with several decoder instances and several image consumers
  * simultaneously.
  */
 public abstract class DecodingImageSource implements ImageProducer {
-    ArrayList consumers = new ArrayList(5);
-    ArrayList decoders = new ArrayList(5);
-    boolean loading = false;
+    List<ImageConsumer> consumers = new ArrayList<ImageConsumer>(5);
+    List<ImageDecoder> decoders = new ArrayList<ImageDecoder>(5);
+    boolean loading;
 
     ImageDecoder decoder;
 
@@ -60,11 +61,12 @@
             ImageDecoder d = null;
 
             // Check for all existing decoders
-            for (Iterator i = decoders.iterator(); i.hasNext();) {
-                d = (ImageDecoder) i.next();
+            for (Iterator<ImageDecoder> i = decoders.iterator(); i.hasNext();) {
+                d = i.next();
                 cons = findConsumer(d.consumers, ic);
-                if (cons != null)
+                if (cons != null) {
                     break;
+                }
             }
         }
 
@@ -86,20 +88,22 @@
      * This method stops sending data to the list of consumers.
      * @param consumersList - list of consumers
      */
-    private void abortAllConsumers(ArrayList consumersList) {
-        for (Iterator i = consumersList.iterator(); i.hasNext();)
-            abortConsumer((ImageConsumer) i.next());
+    private void abortAllConsumers(List<ImageConsumer> consumersList) {
+        for (ImageConsumer imageConsumer : consumersList) {
+            abortConsumer(imageConsumer);
+        }
     }
 
     public synchronized void removeConsumer(ImageConsumer ic) {
         ImageDecoder d = null;
 
         // Remove in all existing decoders
-        for (Iterator i = decoders.iterator(); i.hasNext();) {
-            d = (ImageDecoder) i.next();
+        for (Iterator<ImageDecoder> i = decoders.iterator(); i.hasNext();) {
+            d = i.next();
             removeConsumer(d.consumers, ic);
-            if (d.consumers.size() <= 0)
+            if (d.consumers.size() <= 0) {
                 d.terminate();
+            }
         }
 
         // Remove in the current queue of consumers
@@ -111,11 +115,11 @@
      * @param consumersList - list of consumers
      * @param ic - consumer to be removed
      */
-    private static void removeConsumer(ArrayList consumersList, ImageConsumer ic) {
+    private static void removeConsumer(List<ImageConsumer> consumersList, ImageConsumer ic) {
         ImageConsumer cons = null;
 
-        for (Iterator i = consumersList.iterator(); i.hasNext();) {
-            cons = (ImageConsumer) i.next();
+        for (Iterator<ImageConsumer> i = consumersList.iterator(); i.hasNext();) {
+            cons = i.next();
             if (cons.equals(ic)) {
                 i.remove();
             }
@@ -127,8 +131,9 @@
     }
 
     public synchronized void startProduction(ImageConsumer ic) {
-        if (ic != null)
+        if (ic != null) {
             addConsumer(ic);
+        }
 
         if (!loading && consumers.size() > 0) {
             ImageLoader.addImageSource(this);
@@ -140,10 +145,11 @@
         ImageDecoder d = null;
 
         // Check for all existing decoders
-        for (Iterator i = decoders.iterator(); i.hasNext();) {
-            d = (ImageDecoder) i.next();
-            if (findConsumer(d.consumers, ic) != null)
+        for (Iterator<ImageDecoder> i = decoders.iterator(); i.hasNext();) {
+            d = i.next();
+            if (findConsumer(d.consumers, ic) != null) {
                 return true;
+            }
         }
 
         // Check current queue of consumers
@@ -156,13 +162,14 @@
      * @param ic - consumer
      * @return consumer if found, null otherwise
      */
-    private static ImageConsumer findConsumer(ArrayList consumersList, ImageConsumer ic) {
+    private static ImageConsumer findConsumer(List<ImageConsumer> consumersList, ImageConsumer ic) {
         ImageConsumer res = null;
 
-        for (Iterator i = consumersList.iterator(); i.hasNext();) {
-            res = (ImageConsumer) i.next();
-            if (res.equals(ic))
+        for (Iterator<ImageConsumer> i = consumersList.iterator(); i.hasNext();) {
+            res = i.next();
+            if (res.equals(ic)) {
                 return res;
+            }
         }
 
         return null;
@@ -201,21 +208,21 @@
                 decoders.add(decoder);
                 this.decoder = decoder;
                 loading = false;
-                consumers = new ArrayList(5); // Reset queue
+                consumers = new ArrayList<ImageConsumer>(5); // Reset queue
             }
 
             return decoder;
-        } else { // We were not able to find appropriate decoder
-            ArrayList cs;
-            synchronized (this) {
-                cs = consumers;
-                consumers = new ArrayList(5);
-                loading = false;
-            }
-            abortAllConsumers(cs);
-
-            return null;
         }
+        // We were not able to find appropriate decoder
+        List<ImageConsumer> cs;
+        synchronized (this) {
+            cs = consumers;
+            consumers = new ArrayList<ImageConsumer>(5);
+            loading = false;
+        }
+        abortAllConsumers(cs);
+
+        return null;
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/FileDecodingImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/FileDecodingImageSource.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/FileDecodingImageSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/FileDecodingImageSource.java Wed Oct 18 23:54:47 2006
@@ -40,7 +40,8 @@
     filename = file;
   }
 
-  protected boolean checkConnection() {
+  @Override
+protected boolean checkConnection() {
       SecurityManager security = System.getSecurityManager();
       if (security != null) {
           try {
@@ -53,7 +54,8 @@
       return true;
   }
 
-  protected InputStream getInputStream() {
+  @Override
+protected InputStream getInputStream() {
     try {
       return new BufferedInputStream(new FileInputStream(filename));
     } catch (FileNotFoundException e) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/GifDecoder.java Wed Oct 18 23:54:47 2006
@@ -31,6 +31,7 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Hashtable;
+import java.util.List;
 
 public class GifDecoder extends ImageDecoder {
     // initializes proper field IDs
@@ -54,27 +55,27 @@
 
     // I/O buffer
     private static final int BUFFER_SIZE = 1024;
-    private byte buffer[] = new byte[BUFFER_SIZE];
+    private final byte buffer[] = new byte[BUFFER_SIZE];
 
     GifDataStream gifDataStream = new GifDataStream();
     GifGraphicBlock currBlock;
 
     // Pointer to native structure which store decoding state
     // between subsequent decoding/IO-suspension cycles
-    private long hNativeDecoder = 0; // NULL initially
+    private long hNativeDecoder; // NULL initially
 
     // Number of bytes eaten by the native decoder
-    private int bytesConsumed = 0;
+    private int bytesConsumed;
 
-    private boolean consumersPrepared = false;
-    private Hashtable properties = new Hashtable();
+    private boolean consumersPrepared;
+    private final Hashtable<String, String> properties = new Hashtable<String, String>();
 
     // Could be set up by java code or native method when
     // transparent pixel index changes or local color table encountered
-    private boolean forceRGB = false;
+    private boolean forceRGB;
 
-    private byte screenBuffer[] = null;
-    private int screenRGBBuffer[] = null;
+    private byte screenBuffer[];
+    private int screenRGBBuffer[];
 
     public GifDecoder(DecodingImageSource src, InputStream is) {
         super(src, is);
@@ -120,26 +121,29 @@
                 gls.logicalScreenHeight);
         setProperties(properties);
 
-        currBlock = (GifGraphicBlock) gifDataStream.graphicBlocks.get(0);
-        if (forceRGB)
+        currBlock = gifDataStream.graphicBlocks.get(0);
+        if (forceRGB) {
             setColorModel(ColorModel.getRGBdefault());
-        else
+        } else {
             setColorModel(gls.globalColorTable.getColorModel(currBlock.transparentColor));
+        }
 
         // Fill screen buffer with the background or transparent color
         if (forceRGB) {
             int fillColor = 0xFF000000;
-            if (gls.backgroundColor != IMPOSSIBLE_VALUE)
+            if (gls.backgroundColor != IMPOSSIBLE_VALUE) {
                 fillColor = gls.backgroundColor;
+            }
 
             Arrays.fill(getScreenRGBBuffer(), fillColor);
         } else {
             int fillColor = 0;
 
-            if (gls.backgroundColor != IMPOSSIBLE_VALUE)
+            if (gls.backgroundColor != IMPOSSIBLE_VALUE) {
                 fillColor = gls.backgroundColor;
-            else
+            } else {
                 fillColor = gls.globalColorTable.cm.getTransparentPixel();
+            }
 
             screenBuffer = new byte[gls.logicalScreenHeight*gls.logicalScreenWidth];
             Arrays.fill(screenBuffer, (byte) fillColor);
@@ -148,6 +152,7 @@
         setHints(interlacedHints); // XXX - always random pixel order
     }
 
+    @Override
     public void decodeImage() throws IOException {
         try {
             int bytesRead = 0;
@@ -201,8 +206,9 @@
                     consumersPrepared = true;
                 }
 
-                if (bytesConsumed < 0)
+                if (bytesConsumed < 0) {
                     break; // Error exit
+                }
 
                 if (currBlock != null) {
                     if (numLines != 0) {
@@ -222,7 +228,9 @@
                     }
                 }
 
-                if (hNativeDecoder == 0) break;
+                if (hNativeDecoder == 0) {
+                    break;
+                }
 
                 if (eosReached && numLines == 0) { // Maybe image is truncated...
                     releaseNativeDecoder(hNativeDecoder);
@@ -236,27 +244,29 @@
         // Here all animation goes
         // Repeat image loopCount-1 times or infinitely if loopCount = 0
         if (gifDataStream.loopCount != 1) {
-            if (currBlock.completed == false) // Last frame is always empty
+            if (currBlock.completed == false) {
                 gifDataStream.graphicBlocks.remove(currBlock);
+            }
 
             int numFrames = gifDataStream.graphicBlocks.size();
             // At first last block will be disposed
             GifGraphicBlock gb =
-                    (GifGraphicBlock) gifDataStream.graphicBlocks.get(numFrames-1);
+                    gifDataStream.graphicBlocks.get(numFrames-1);
 
             ImageLoader.beginAnimation();
 
             while (gifDataStream.loopCount != 1) {
-                if (gifDataStream.loopCount != 0)
+                if (gifDataStream.loopCount != 0) {
                     gifDataStream.loopCount--;
+                }
 
                 // Show all frames
                 for (int i=0; i<numFrames; i++) {
                     gb.dispose();
-                    gb = (GifGraphicBlock) gifDataStream.graphicBlocks.get(i);
+                    gb = gifDataStream.graphicBlocks.get(i);
 
                     // Show one frame
-                    if (forceRGB)
+                    if (forceRGB) {
                         setPixels(
                                 gb.imageLeft,
                                 gb.imageTop,
@@ -267,7 +277,7 @@
                                 0,
                                 gb.imageWidth
                         );
-                    else
+                    } else {
                         setPixels(
                                 gb.imageLeft,
                                 gb.imageTop,
@@ -278,6 +288,7 @@
                                 0,
                                 gb.imageWidth
                         );
+                    }
                 }
             }
             ImageLoader.endAnimation();
@@ -289,10 +300,11 @@
     void setComment(String newComment) {
         Object currComment = properties.get("comment");
 
-        if (currComment == null)
+        if (currComment == null) {
             properties.put("comment", newComment);
-        else
+        } else {
             properties.put("comment", (String) currComment + "\n" + newComment);
+        }
 
         setProperties(properties);
     }
@@ -306,7 +318,7 @@
         int loopCount = 1;
 
         GifLogicalScreen logicalScreen = new GifLogicalScreen();
-        ArrayList graphicBlocks = new ArrayList(10); // Of GifGraphicBlocks
+        List<GifGraphicBlock> graphicBlocks = new ArrayList<GifGraphicBlock>(10); // Of GifGraphicBlocks
 
         // Comments from the image
         String comments[];
@@ -374,7 +386,7 @@
         }
 
         private void replaceTransparentPixels(int numLines) {
-            ArrayList graphicBlocks = gifDataStream.graphicBlocks;
+            List<GifGraphicBlock> graphicBlocks = gifDataStream.graphicBlocks;
             int prevBlockIndex = graphicBlocks.indexOf(this) - 1;
 
             if (prevBlockIndex >= 0) {
@@ -419,7 +431,7 @@
                 replaceTransparentPixels(numLines);
             }
 
-            if (forceRGB)
+            if (forceRGB) {
                 decoder.setPixels(
                         imageLeft,
                         imageTop + currY,
@@ -430,7 +442,7 @@
                         currY*imageWidth,
                         imageWidth
                 );
-            else
+            } else {
                 decoder.setPixels(
                         imageLeft,
                         imageTop + currY,
@@ -441,6 +453,7 @@
                         currY*imageWidth,
                         imageWidth
                 );
+            }
 
             currY += numLines;
         }
@@ -449,19 +462,21 @@
             imageComplete(ImageConsumer.SINGLEFRAMEDONE);
 
             // Show current frame until delayInterval will not elapse
-            if (delayTime > 0)
+            if (delayTime > 0) {
                 try {
                     Thread.sleep(delayTime);
                 } catch (InterruptedException e) {
                     e.printStackTrace();
                 }
-            else
+            } else {
                 Thread.yield(); // Allow consumers to consume data
+            }
 
             // Don't dispose if image is outside of the visible area
             if (imageLeft > gifDataStream.logicalScreen.logicalScreenWidth ||
-                    imageTop > gifDataStream.logicalScreen.logicalScreenHeight)
+                    imageTop > gifDataStream.logicalScreen.logicalScreenHeight) {
                 disposalMethod = DISPOSAL_NONE;
+            }
 
             switch(disposalMethod) {
                 case DISPOSAL_BACKGROUND: {
@@ -551,27 +566,27 @@
             if (forceRGB) {
                 dataInt = (int[]) data;
 
-                if (imageWidth == width)
+                if (imageWidth == width) {
                     System.arraycopy(dataInt,
                             0,
                             getScreenRGBBuffer(),
                             imageLeft + imageTop*width,
                             dataInt.length
                     );
-                else { // Each scanline
+                } else { // Each scanline
                     copyScanlines(dataInt, getScreenRGBBuffer(), width);
                 }
             } else {
                 dataByte = (byte[]) data;
 
-                if (imageWidth == width)
+                if (imageWidth == width) {
                     System.arraycopy(dataByte,
                             0,
                             screenBuffer,
                             imageLeft + imageTop*width,
                             dataByte.length
                     );
-                else { // Each scanline
+                } else { // Each scanline
                     copyScanlines(dataByte, screenBuffer, width);
                 }
             }
@@ -617,7 +632,7 @@
                 toSend = dst;
             }
 
-            if (forceRGB)
+            if (forceRGB) {
                 setPixels(
                         imageLeft,
                         imageTop,
@@ -628,7 +643,7 @@
                         offset,
                         imageWidth
                 );
-            else
+            } else {
                 setPixels(
                         imageLeft,
                         imageTop,
@@ -639,6 +654,7 @@
                         offset,
                         imageWidth
                 );
+            }
         }
     }
 
@@ -651,20 +667,21 @@
         byte colors[] = new byte[256*3];
 
         IndexColorModel getColorModel(int transparentColor) {
-            if (cm != null)
+            if (cm != null) {
                 if (transparentColor != cm.getTransparentPixel()) {
                     return cm = null; // Force default ARGB color model
-                } else {
-                    return cm;
                 }
-            else
+                return cm;
+            } else
                 if (completed && size > 0) {
-                    if (transparentColor == IMPOSSIBLE_VALUE)
+                    if (transparentColor == IMPOSSIBLE_VALUE) {
                         return cm =
                                 new IndexColorModel(8, size, colors, 0, false);
+                    }
 
-                    if (transparentColor > size)
+                    if (transparentColor > size) {
                         size = transparentColor + 1;
+                    }
                     return cm =
                             new IndexColorModel(8, size, colors, 0, false, transparentColor);
                 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageDecoder.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageDecoder.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageDecoder.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageDecoder.java Wed Oct 18 23:54:47 2006
@@ -23,15 +23,17 @@
  */
 package org.apache.harmony.awt.gl.image;
 
+import java.awt.image.ColorModel;
+import java.awt.image.ImageConsumer;
 import java.io.BufferedInputStream;
-import java.io.InputStream;
 import java.io.IOException;
-import java.util.ArrayList;
+import java.io.InputStream;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ConcurrentModificationException;
 import java.util.Hashtable;
 import java.util.Iterator;
-import java.awt.image.ColorModel;
-import java.awt.image.ImageConsumer;
+import java.util.List;
 
 /**
  * This class contains common functionality for all image decoders.
@@ -39,14 +41,14 @@
 abstract class ImageDecoder {
     private static final int MAX_BYTES_IN_SIGNATURE = 8;
 
-    ArrayList consumers;
+    List<ImageConsumer> consumers;
     InputStream inputStream;
     DecodingImageSource src;
 
-    boolean terminated = false;
+    boolean terminated;
 
     /**
-     * Choouses appropriate image decoder by looking into input stream and checking
+     * Chooses appropriate image decoder by looking into input stream and checking
      * the image signature.
      * @param src - image producer, required for passing data to it from the
      * created decoder via callbacks
@@ -56,10 +58,11 @@
     static ImageDecoder createDecoder(DecodingImageSource src, InputStream is) {
         InputStream markable;
 
-        if (!is.markSupported())
+        if (!is.markSupported()) {
             markable = new BufferedInputStream(is);
-        else
+        } else {
             markable = is;
+        }
 
         // Read the signature from the stream and then reset it back
         try {
@@ -119,9 +122,9 @@
         src.lockDecoder(this);
         closeStream();
 
-        java.security.AccessController.doPrivileged(
-                new java.security.PrivilegedAction() {
-                    public Object run() {
+        AccessController.doPrivileged(
+                new PrivilegedAction<Void>() {
+                    public Void run() {
                         Thread.currentThread().interrupt();
                         return null;
                     }
@@ -132,49 +135,41 @@
     }
 
     protected void setDimensions(int w, int h) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setDimensions(w, h);
         }
     }
 
-    protected void setProperties(Hashtable props) {
-        if (terminated)
+    protected void setProperties(Hashtable<?, ?> props) {
+        if (terminated) {
             return;
+        }
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setProperties(props);
         }
     }
 
     protected void setColorModel(ColorModel cm) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setColorModel(cm);
         }
     }
 
     protected void setHints(int hints) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setHints(hints);
         }
     }
@@ -186,15 +181,13 @@
             byte pix[],
             int off, int scansize
             ) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
         src.lockDecoder(this);
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setPixels(x, y, w, h, model, pix, off, scansize);
         }
     }
@@ -206,30 +199,29 @@
             int pix[],
             int off, int scansize
             ) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
         src.lockDecoder(this);
 
-        ImageConsumer ic = null;
-
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
-            ic = (ImageConsumer) i.next();
+        for (ImageConsumer ic : consumers) {
             ic.setPixels(x, y, w, h, model, pix, off, scansize);
         }
     }
 
     protected void imageComplete(int status) {
-        if (terminated)
+        if (terminated) {
             return;
+        }
 
         src.lockDecoder(this);
 
         ImageConsumer ic = null;
 
-        for (Iterator i = consumers.iterator(); i.hasNext();) {
+        for (Iterator<ImageConsumer> i = consumers.iterator(); i.hasNext();) {
             try {
-                ic = (ImageConsumer) i.next();
+                ic = i.next();
             } catch (ConcurrentModificationException e) {
                 i = consumers.iterator();
                 continue;

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageLoader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageLoader.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageLoader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/ImageLoader.java Wed Oct 18 23:54:47 2006
@@ -23,8 +23,11 @@
  */
 package org.apache.harmony.awt.gl.image;
 
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.util.ArrayList;
 import java.util.LinkedList;
+import java.util.List;
 
 /**
  * This class provides functionality for simultaneous loading of
@@ -36,12 +39,12 @@
     static class ImageLoadersStorage {
         private static final int MAX_THREADS = 5;
         private static final int TIMEOUT = 4000;
-        static ImageLoadersStorage instance = null;
+        static ImageLoadersStorage instance;
 
-        LinkedList queue = new LinkedList();
-        ArrayList loaders = new ArrayList(MAX_THREADS);
+        List<DecodingImageSource> queue = new LinkedList<DecodingImageSource>();
+        List<Thread> loaders = new ArrayList<Thread>(MAX_THREADS);
 
-        private int freeLoaders = 0;
+        private int freeLoaders;
 
         private ImageLoadersStorage() {}
 
@@ -68,16 +71,17 @@
         final ImageLoadersStorage storage = ImageLoadersStorage.getStorage();
 
         synchronized(storage.loaders) {
-            if (storage.loaders.size() < ImageLoadersStorage.MAX_THREADS)
-                java.security.AccessController.doPrivileged(
-                        new java.security.PrivilegedAction() {
-                            public Object run() {
+            if (storage.loaders.size() < ImageLoadersStorage.MAX_THREADS) {
+                AccessController.doPrivileged(
+                        new PrivilegedAction<Void>() {
+                            public Void run() {
                                 ImageLoader loader = new ImageLoader();
                                 storage.loaders.add(loader);
                                 loader.start();
                                 return null;
                             }
                         });
+            }
         }
     }
 
@@ -89,10 +93,12 @@
     public static void addImageSource(DecodingImageSource imgSrc) {
         ImageLoadersStorage storage = ImageLoadersStorage.getStorage();
         synchronized(storage.queue) {
-            if (!storage.queue.contains(imgSrc))
+            if (!storage.queue.contains(imgSrc)) {
                 storage.queue.add(imgSrc);
-            if (storage.freeLoaders == 0)
+            }
+            if (storage.freeLoaders == 0) {
                 createLoader();
+            }
 
             storage.queue.notify();
         }
@@ -122,7 +128,7 @@
             }
 
             if (storage.queue.size() > 0) {
-                isrc = (DecodingImageSource) storage.queue.get(0);
+                isrc = storage.queue.get(0);
                 storage.queue.remove(0);
             }
 
@@ -135,6 +141,7 @@
      * runs decoders for them while there are available image sources in the queue.
      * If there are no and timeout expires it terminates.
      */
+    @Override
     public void run() {
         ImageLoadersStorage storage = ImageLoadersStorage.getStorage();
 
@@ -172,8 +179,9 @@
         synchronized(storage) {
             storage.loaders.remove(currThread);
 
-            if (storage.freeLoaders < storage.queue.size())
+            if (storage.freeLoaders < storage.queue.size()) {
                 createLoader();
+            }
         }
 
         currThread.setPriority(Thread.MIN_PRIORITY);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/JpegDecoder.java Wed Oct 18 23:54:47 2006
@@ -47,7 +47,7 @@
 
     // Buffer for the stream
     private static final int BUFFER_SIZE = 1024;
-    private byte buffer[] = new byte[BUFFER_SIZE];
+    private final byte buffer[] = new byte[BUFFER_SIZE];
 
     // 3 possible color models only
     private static ColorModel cmRGB;
@@ -58,22 +58,22 @@
 
     // Pointer to native structure which store decoding state
     // between subsequent decoding/IO-suspension cycles
-    private long hNativeDecoder = 0; // NULL initially
+    private final long hNativeDecoder = 0; // NULL initially
 
     private boolean headerDone = false;
 
     // Next 4 members are filled by the native method (decompress).
     // We can simply check if imageWidth is still negative to find
     // out if they are already filled.
-    private int imageWidth = -1;
-    private int imageHeight = -1;
-    private boolean progressive = false;
-    private int jpegColorSpace = 0;
+    private final int imageWidth = -1;
+    private final int imageHeight = -1;
+    private final boolean progressive = false;
+    private final int jpegColorSpace = 0;
 
     // Stores number of bytes consumed by the native decoder
-    private int bytesConsumed = 0;
+    private final int bytesConsumed = 0;
     // Stores current scanline returned by the decoder
-    private int currScanline = 0;
+    private final int currScanline = 0;
 
     private ColorModel cm = null;
 
@@ -113,6 +113,7 @@
 
     private static native void releaseNativeDecoder(long hDecoder);
 
+    @Override
     public void decodeImage() throws IOException {
         try {
             int bytesRead = 0, dataLength = 0;
@@ -152,8 +153,9 @@
                     headerDone = true;
                 }
 
-                if (bytesConsumed < 0)
+                if (bytesConsumed < 0) {
                     break; // Error exit
+                }
 
                 if (arr instanceof byte[]) {
                     byteOut = (byte[]) arr;
@@ -167,7 +169,9 @@
                     dataLength = 0;
                 }
 
-                if (hNativeDecoder == 0) break;
+                if (hNativeDecoder == 0) {
+                    break;
+                }
 
                 if (dataLength == 0 && eosReached) {
                     releaseNativeDecoder(hNativeDecoder);
@@ -194,28 +198,30 @@
 
         setHints(progressive ? hintflagsProgressive : hintflagsSingle);
 
-        setProperties(new Hashtable()); // Empty
+        setProperties(new Hashtable<Object, Object>()); // Empty
     }
 
     // Send the data to the consumer
     public void returnData(int data[], int currScanLine) {
         // Send 1 or more scanlines to the consumer.
         int numScanlines = data.length / imageWidth;
-        if (numScanlines > 0)
+        if (numScanlines > 0) {
             setPixels(
                     0, currScanLine - numScanlines,
                     imageWidth, numScanlines,
                     cm, data, 0, imageWidth
             );
+        }
     }
 
     public void returnData(byte data[], int currScanLine) {
         int numScanlines = data.length / imageWidth;
-        if (numScanlines > 0)
+        if (numScanlines > 0) {
             setPixels(
                     0, currScanLine - numScanlines,
                     imageWidth, numScanlines,
                     cm, data, 0, imageWidth
             );
+        }
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OffscreenImage.java Wed Oct 18 23:54:47 2006
@@ -37,7 +37,6 @@
 import java.awt.image.ImageProducer;
 import java.awt.image.IndexColorModel;
 import java.awt.image.WritableRaster;
-import java.util.Enumeration;
 import java.util.Hashtable;
 import java.util.Vector;
 
@@ -55,8 +54,8 @@
     ColorModel cm;
     WritableRaster raster;
     boolean isIntRGB;
-    Hashtable properties;
-    Vector observers;
+    Hashtable<?, ?> properties;
+    Vector<ImageObserver> observers;
     int width;
     int height;
     int imageState;
@@ -69,53 +68,65 @@
         src = ip;
         width = -1;
         height = -1;
-        observers = new Vector();
+        observers = new Vector<ImageObserver>();
         producing = false;
     }
 
+    @Override
     public Object getProperty(String name, ImageObserver observer) {
-        if(name == null)
+        if(name == null) {
             throw new NullPointerException("Property name is not defined");
+        }
         if(properties == null){
             addObserver(observer);
             startProduction();
-            if(properties == null) return null;
+            if(properties == null) {
+                return null;
+            }
         }
         Object prop = properties.get(name);
-        if(prop == null)
+        if(prop == null) {
             prop = UndefinedProperty;
+        }
         return prop;
     }
 
+    @Override
     public ImageProducer getSource() {
         return src;
     }
 
+    @Override
     public int getWidth(ImageObserver observer) {
         if((imageState & ImageObserver.WIDTH) == 0){
             addObserver(observer);
             startProduction();
-            if((imageState & ImageObserver.WIDTH) == 0)
+            if((imageState & ImageObserver.WIDTH) == 0) {
                 return -1;
+            }
         }
         return width;
     }
 
+    @Override
     public int getHeight(ImageObserver observer) {
         if((imageState & ImageObserver.HEIGHT) == 0){
             addObserver(observer);
             startProduction();
-            if((imageState & ImageObserver.HEIGHT) == 0)
+            if((imageState & ImageObserver.HEIGHT) == 0) {
                 return -1;
+            }
         }
         return height;
     }
 
+    @Override
     public Graphics getGraphics() {
         throw new UnsupportedOperationException("This method is not " +
                 "implemented for image obtained from ImageProducer");
     }
 
+    @Override
     public void flush() {
         stopProduction();
         imageUpdate(this, ImageObserver.ABORT, -1, -1, -1, -1);
@@ -129,7 +140,7 @@
         height = -1;
     }
 
-    public void setProperties(Hashtable properties) {
+    public void setProperties(Hashtable<?, ?> properties) {
         this.properties = properties;
         imageUpdate(this, ImageObserver.PROPERTIES, 0, 0, width, height);
     }
@@ -152,14 +163,17 @@
             int[] pixels, int off, int scansize) {
         if(raster == null){
             if(cm == null){
-                if(model == null)
+                if(model == null) {
                     throw new NullPointerException("Color Model is null");
+                }
                 cm = model;
             }
             createRaster();
         }
 
-        if(model == null) model = cm;
+        if(model == null) {
+            model = cm;
+        }
         if(cm != model){
             forceToIntARGB();
         }
@@ -209,13 +223,16 @@
 
         if(raster == null){
             if(cm == null){
-                if(model == null)
+                if(model == null) {
                     throw new NullPointerException("Color Model is null");
+                }
                 cm = model;
             }
             createRaster();
         }
-        if(model == null) model = cm;
+        if(model == null) {
+            model = cm;
+        }
         if(model != cm){
             forceToIntARGB();
         }
@@ -319,8 +336,9 @@
         if(image == null){
             ColorModel model = getColorModel();
             WritableRaster wr = getRaster();
-            if(model != null && wr != null)
-            image = new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
+            if(model != null && wr != null) {
+                image = new BufferedImage(model, wr, model.isAlphaPremultiplied(), null);
+            }
         }
         return image;
     }
@@ -338,19 +356,25 @@
             }
             return false;
         }
-        if((imageState & ImageObserver.ALLBITS) != 0) return true;
+        if((imageState & ImageObserver.ALLBITS) != 0) {
+            return true;
+        }
         addObserver(observer);
         startProduction();
         return ((imageState & ImageObserver.ALLBITS) != 0);
     }
 
     public /*synchronized*/ ColorModel getColorModel(){
-        if(cm == null) startProduction();
+        if(cm == null) {
+            startProduction();
+        }
         return cm;
     }
 
     public /*synchronized*/ WritableRaster getRaster(){
-        if(raster == null) startProduction();
+        if(raster == null) {
+            startProduction();
+        }
         return raster;
     }
 
@@ -360,7 +384,9 @@
 
     private /*synchronized*/ void addObserver(ImageObserver observer){
         if(observer != null){
-          if(observers.contains(observer)) return;
+          if(observers.contains(observer)) {
+            return;
+        }
           if((imageState & ImageObserver.ERROR) != 0){
               observer.imageUpdate(this, ImageObserver.ERROR |
                       ImageObserver.ABORT, -1, -1, -1, -1);
@@ -411,8 +437,7 @@
             int width, int height){
 
         imageState |= infoflags;
-        for(Enumeration e = observers.elements(); e.hasMoreElements();){
-            ImageObserver observer = (ImageObserver)e.nextElement();
+        for (ImageObserver observer : observers) {
             observer.imageUpdate(this, infoflags, x, y, width, height);
         }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OrdinaryWritableRaster.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OrdinaryWritableRaster.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OrdinaryWritableRaster.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/OrdinaryWritableRaster.java Wed Oct 18 23:54:47 2006
@@ -48,85 +48,105 @@
         super(sampleModel, origin);
     }
 
+    @Override
     public void setDataElements(int x, int y, Object inData) {
         super.setDataElements(x, y, inData);
     }
 
+    @Override
     public void setDataElements(int x, int y, int w, int h, Object inData) {
         super.setDataElements(x, y, w, h, inData);
     }
 
+    @Override
     public WritableRaster createWritableChild(int parentX, int parentY, int w,
             int h, int childMinX, int childMinY, int[] bandList) {
         return super.createWritableChild(parentX, parentY, w, h, childMinX,
                 childMinY, bandList);
     }
 
+    @Override
     public WritableRaster createWritableTranslatedChild(int childMinX,
             int childMinY) {
         return super.createWritableTranslatedChild(childMinX, childMinY);
     }
 
+    @Override
     public WritableRaster getWritableParent() {
         return super.getWritableParent();
     }
 
+    @Override
     public void setRect(Raster srcRaster) {
         super.setRect(srcRaster);
     }
 
+    @Override
     public void setRect(int dx, int dy, Raster srcRaster) {
         super.setRect(dx, dy, srcRaster);
     }
 
+    @Override
     public void setDataElements(int x, int y, Raster inRaster) {
         super.setDataElements(x, y, inRaster);
     }
 
+    @Override
     public void setPixel(int x, int y, int[] iArray) {
         super.setPixel(x, y, iArray);
     }
 
+    @Override
     public void setPixel(int x, int y, float[] fArray) {
         super.setPixel(x, y, fArray);
     }
 
+    @Override
     public void setPixel(int x, int y, double[] dArray) {
         super.setPixel(x, y, dArray);
     }
 
+    @Override
     public void setPixels(int x, int y, int w, int h, int[] iArray) {
         super.setPixels(x, y, w, h, iArray);
     }
 
+    @Override
     public void setPixels(int x, int y, int w, int h, float[] fArray) {
         super.setPixels(x, y, w, h, fArray);
     }
 
+    @Override
     public void setPixels(int x, int y, int w, int h, double[] dArray) {
         super.setPixels(x, y, w, h, dArray);
     }
 
+    @Override
     public void setSamples(int x, int y, int w, int h, int b, int[] iArray) {
         super.setSamples(x, y, w, h, b, iArray);
     }
 
+    @Override
     public void setSamples(int x, int y, int w, int h, int b, float[] fArray) {
         super.setSamples(x, y, w, h, b, fArray);
     }
 
+    @Override
     public void setSamples(int x, int y, int w, int h, int b, double[] dArray) {
         super.setSamples(x, y, w, h, b, dArray);
     }
 
+    @Override
     public void setSample(int x, int y, int b, int s) {
         super.setSample(x, y, b, s);
     }
 
+    @Override
     public void setSample(int x, int y, int b, float s) {
         super.setSample(x, y, b, s);
     }
 
+    @Override
     public void setSample(int x, int y, int b, double s) {
         super.setSample(x, y, b, s);
     }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/PngDecoder.java Wed Oct 18 23:54:47 2006
@@ -56,11 +56,11 @@
     private static final int PNG_COLOR_TYPE_RGBA = 6;
 
     private static final int INPUT_BUFFER_SIZE = 4096;
-    private byte buffer[] = new byte[INPUT_BUFFER_SIZE];
+    private final byte buffer[] = new byte[INPUT_BUFFER_SIZE];
 
     // Buffers for decoded image data
-    byte byteOut[] = null;
-    int intOut[] = null;
+    byte byteOut[];
+    int intOut[];
 
     // Native pointer to png decoder data
     private long hNativeDecoder;
@@ -86,6 +86,7 @@
         super(src, is);
     }
 
+    @Override
     public void decodeImage() throws IOException {
         try {
             int bytesRead = 0;
@@ -114,7 +115,9 @@
                 returnData();
 
                 // OK, we decoded all the picture in the right way...
-                if (hNativeDecoder == 0) break;
+                if (hNativeDecoder == 0) {
+                    break;
+                }
             }
 
             imageComplete(ImageConsumer.STATICIMAGEDONE);
@@ -128,13 +131,15 @@
         }
     }
 
+    @SuppressWarnings("unused")
     private void returnHeader() { // Called from native code
         setDimensions(imageWidth, imageHeight);
 
         switch (colorType) {
             case PNG_COLOR_TYPE_GRAY: {
-                if (bitDepth != 8 && bitDepth != 4 && bitDepth != 2 && bitDepth != 1)
+                if (bitDepth != 8 && bitDepth != 4 && bitDepth != 2 && bitDepth != 1) {
                     throw new IllegalArgumentException("Unknown PNG color type");
+                }
 
                 // Create gray color model
                 int numEntries = 1 << bitDepth;
@@ -150,8 +155,9 @@
             }
 
             case PNG_COLOR_TYPE_RGB: {
-                if (bitDepth != 8)
+                if (bitDepth != 8) {
                     throw new IllegalArgumentException("Unknown PNG color type");
+                }
 
                 cm = new DirectColorModel(24, 0xFF0000, 0xFF00, 0xFF);
 
@@ -160,8 +166,9 @@
             }
 
             case PNG_COLOR_TYPE_PLTE: {
-                if (bitDepth != 8 && bitDepth != 4 && bitDepth != 2 && bitDepth != 1)
+                if (bitDepth != 8 && bitDepth != 4 && bitDepth != 2 && bitDepth != 1) {
                     throw new IllegalArgumentException("Unknown PNG color type");
+                }
 
                 cm = new IndexColorModel(/*bitDepth*/8, cmap.length / 3, cmap, 0, false);
 
@@ -170,8 +177,9 @@
             }
 
             case PNG_COLOR_TYPE_GRAY_ALPHA: {
-                if (bitDepth != 8)
+                if (bitDepth != 8) {
                     throw new IllegalArgumentException("Unknown PNG color type");
+                }
 
                 cm = new ComponentColorModel(ColorSpace.getInstance(ColorSpace.CS_GRAY),
                         true, false,
@@ -184,8 +192,9 @@
             }
 
             case PNG_COLOR_TYPE_RGBA: {
-                if (bitDepth != 8)
+                if (bitDepth != 8) {
                     throw new IllegalArgumentException("Unknown PNG color type");
+                }
 
                 cm = ColorModel.getRGBdefault();
 
@@ -206,7 +215,7 @@
         setColorModel(cm);
 
         setHints(hintflags);
-        setProperties(new Hashtable()); // Empty
+        setProperties(new Hashtable<Object, Object>()); // Empty
     }
 
     // Send the data to the consumer
@@ -225,8 +234,9 @@
             }
 
             transfer(updateFromScanline, pass1);
-            if (pass2 != 0)
+            if (pass2 != 0) {
                 transfer(0, pass2);
+            }
         }
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/URLDecodingImageSource.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/URLDecodingImageSource.java?view=diff&rev=465514&r1=465513&r2=465514
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/URLDecodingImageSource.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/org/apache/harmony/awt/gl/image/URLDecodingImageSource.java Wed Oct 18 23:54:47 2006
@@ -48,6 +48,7 @@
         this.url = url;
     }
 
+    @Override
     protected boolean checkConnection() {
         SecurityManager security = System.getSecurityManager();
         if (security != null) {
@@ -61,6 +62,7 @@
         return true;
     }
 
+    @Override
     protected InputStream getInputStream() {
         try{
             URLConnection uc = url.openConnection();



Mime
View raw message