diff options
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java | 137 |
1 files changed, 64 insertions, 73 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java index 6d0a52b91be..6f6ea560db7 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GdkPixbufDecoder.java @@ -184,22 +184,22 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder int len = 0; synchronized(pixbufLock) { - initState(); + initState(); } needsClose = true; // Note: We don't want the pixbufLock while reading from the InputStream. while ((len = is.read (bytes)) != -1) { - synchronized(pixbufLock) - { - pumpBytes (bytes, len); - } + synchronized(pixbufLock) + { + pumpBytes (bytes, len); + } } synchronized(pixbufLock) { - pumpDone(); + pumpDone(); } needsClose = false; @@ -217,7 +217,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder { synchronized(pixbufLock) { - finish(needsClose); + finish(needsClose); } } @@ -226,8 +226,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder { public String name; public boolean writable = false; - public ArrayList mimeTypes = new ArrayList(); - public ArrayList extensions = new ArrayList(); + public ArrayList<String> mimeTypes = new ArrayList<String>(); + public ArrayList<String> extensions = new ArrayList<String>(); public ImageFormatSpec(String name, boolean writable) { @@ -246,7 +246,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder } } - static ArrayList imageFormatSpecs; + static ArrayList<ImageFormatSpec> imageFormatSpecs; public static ImageFormatSpec registerFormat(String name, boolean writable) { @@ -254,7 +254,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder synchronized(GdkPixbufDecoder.class) { if (imageFormatSpecs == null) - imageFormatSpecs = new ArrayList(); + imageFormatSpecs = new ArrayList<ImageFormatSpec>(); imageFormatSpecs.add(ifs); } return ifs; @@ -262,13 +262,13 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder static String[] getFormatNames(boolean writable) { - ArrayList names = new ArrayList(); + ArrayList<String> names = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; names.add(ifs.name); @@ -279,62 +279,50 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder * This generally means "all the extensions people might use". */ - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) - names.add((String) j.next()); + names.add(j.next()); } } - Object[] objs = names.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return names.toArray(new String[names.size()]); } static String[] getFormatExtensions(boolean writable) { - ArrayList extensions = new ArrayList(); + ArrayList<String> extensions = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) - extensions.add((String) j.next()); + extensions.add(j.next()); } } - Object[] objs = extensions.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return extensions.toArray(new String[extensions.size()]); } static String[] getFormatMimeTypes(boolean writable) { - ArrayList mimeTypes = new ArrayList(); + ArrayList<String> mimeTypes = new ArrayList<String>(); synchronized (imageFormatSpecs) { - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (writable && !ifs.writable) continue; - Iterator j = ifs.mimeTypes.iterator(); + Iterator<String> j = ifs.mimeTypes.iterator(); while (j.hasNext()) - mimeTypes.add((String) j.next()); + mimeTypes.add(j.next()); } } - Object[] objs = mimeTypes.toArray(); - String[] strings = new String[objs.length]; - for (int i = 0; i < objs.length; ++i) - strings[i] = (String) objs[i]; - return strings; + return mimeTypes.toArray(new String[mimeTypes.size()]); } @@ -348,10 +336,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder String str = (String) ext; - Iterator i = imageFormatSpecs.iterator(); + Iterator<ImageFormatSpec> i = imageFormatSpecs.iterator(); while (i.hasNext()) { - ImageFormatSpec ifs = (ImageFormatSpec) i.next(); + ImageFormatSpec ifs = i.next(); if (needWritable && !ifs.writable) continue; @@ -359,10 +347,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (ifs.name.equals(str)) return str; - Iterator j = ifs.extensions.iterator(); + Iterator<String> j = ifs.extensions.iterator(); while (j.hasNext()) { - String extension = (String)j.next(); + String extension = j.next(); if (extension.equals(str)) return ifs.name; } @@ -370,7 +358,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder j = ifs.mimeTypes.iterator(); while (j.hasNext()) { - String mimeType = (String)j.next(); + String mimeType = j.next(); if (mimeType.equals(str)) return ifs.name; } @@ -510,10 +498,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (pixels == null) { - BufferedImage img; - if(model != null && model.hasAlpha()) - img = CairoSurface.getBufferedImage(width, height); - img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); + BufferedImage img; + if(model != null && model.hasAlpha()) + img = CairoSurface.getBufferedImage(width, height); + img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); int[] pix = new int[4]; for (int y = 0; y < height; ++y) for (int x = 0; x < width; ++x) @@ -527,10 +515,10 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder workerThread.start(); processImageStarted(1); synchronized(pixbufLock) - { - streamImage(pixels, this.ext, width, height, model.hasAlpha(), - this); - } + { + streamImage(pixels, this.ext, width, height, model.hasAlpha(), + this); + } synchronized(data) { data.add(DATADONE); @@ -539,18 +527,18 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder while (workerThread.isAlive()) { - try - { - workerThread.join(); - } - catch (InterruptedException ioe) - { - // Ignored. - } + try + { + workerThread.join(); + } + catch (InterruptedException ioe) + { + // Ignored. + } } if (exception != null) - throw exception; + throw exception; processImageComplete(); } @@ -566,7 +554,7 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder * Needs to be synchronized for access. * The special object DATADONE is added when all data has been delivered. */ - private ArrayList data = new ArrayList(); + private ArrayList<Object> data = new ArrayList<Object>(); /** * Holds any IOException thrown by the run method that needs @@ -643,7 +631,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder this.ext = findFormatName(ext, false); } - public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext, GdkPixbufDecoder d) + public GdkPixbufReader(GdkPixbufReaderSpi ownerSpi, Object ext, + GdkPixbufDecoder d) { this(ownerSpi, ext); dec = d; @@ -680,10 +669,12 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder if (bufferedImage == null) { - if(model != null && model.hasAlpha()) - bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_ARGB); - else - bufferedImage = new BufferedImage (width, height, BufferedImage.TYPE_INT_RGB); + if(model != null && model.hasAlpha()) + bufferedImage = new BufferedImage (width, height, + BufferedImage.TYPE_INT_ARGB); + else + bufferedImage = new BufferedImage (width, height, + BufferedImage.TYPE_INT_RGB); } int pixels2[]; @@ -735,11 +726,11 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder return null; } - public Iterator getImageTypes(int imageIndex) + public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException { BufferedImage img = getBufferedImage(); - Vector vec = new Vector(); + Vector<ImageTypeSpecifier> vec = new Vector<ImageTypeSpecifier>(); vec.add(new ImageTypeSpecifier(img)); return vec.iterator(); } @@ -767,8 +758,8 @@ public class GdkPixbufDecoder extends gnu.java.awt.image.ImageDecoder else if (get instanceof DataInput) dec = new GdkPixbufDecoder((DataInput) get); else - throw new IllegalArgumentException("input object not supported: " - + get); + throw new IllegalArgumentException("input object not supported: " + + get); } public BufferedImage read(int imageIndex, ImageReadParam param) |