aboutsummaryrefslogtreecommitdiff
path: root/libjava/javax
diff options
context:
space:
mode:
authorMark Wielaard <mark@gcc.gnu.org>2004-11-06 18:09:00 +0000
committerMark Wielaard <mark@gcc.gnu.org>2004-11-06 18:09:00 +0000
commit6c56bdc2faced04b598b5d2a88e11bed6d67bd0c (patch)
tree9540c8ff7414ddaee88ad1c8b7d570e68bfa8b89 /libjava/javax
parentbb05e3410cddd9bb2fad83ced5004c38626db220 (diff)
downloadgcc-6c56bdc2faced04b598b5d2a88e11bed6d67bd0c.zip
gcc-6c56bdc2faced04b598b5d2a88e11bed6d67bd0c.tar.gz
gcc-6c56bdc2faced04b598b5d2a88e11bed6d67bd0c.tar.bz2
[multiple changes]
2004-11-06 Mark Wielaard <mark@klomp.org> * Makefile.am: Add new javax.imageio files. * Makefile.in: Regenerated. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/event/IIOReadProgressListener.java, javax/imageio/event/IIOReadUpdateListener.java, javax/imageio/event/IIOReadWarningListener.java, javax/imageio/event/IIOWriteProgressListener.java, javax/imageio/event/IIOWriteWarningListener.java, javax/imageio/metadata/IIOMetadataFormat.java, javax/imageio/stream/FileCacheImageInputStream.java, javax/imageio/stream/FileCacheImageOutputStream.java, javax/imageio/stream/ImageInputStreamImpl.java: Import cleanup. * javax/imageio/metadata/package.html: New file. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/spi/ImageReaderSpi.java (isOwnReader): New method. * javax/imageio/spi/ImageWriterSpi.java (isOwnWriter): Likewise. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageWriter.java (convertImageMetadata): New abstract method. (convertStreamMetadata): Likewise. (write): Likewise. * javax/imageio/stream/FileCacheImageInputStream.java (close): Fixed setting of stream to null. (checkStreamClosed): Throws IOException. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/stream/FileCacheImageInputStream.java, javax/imageio/stream/FileCacheImageOutputStream.java, javax/imageio/stream/FileImageInputStream.java, javax/imageio/stream/FileImageOutputStream.java, javax/imageio/stream/MemoryCacheImageInputStream.java, javax/imageio/stream/MemoryCacheImageOutputStream.java: New files. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/metadata/IIOInvalidTreeException.java, javax/imageio/metadata/IIOMetadataFormatImpl.java, javax/imageio/metadata/IIOMetadataNode.java: New stub files. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/stream/ImageInputStreamImpl.java, javax/imageio/stream/ImageOutputStreamImpl.java: New files. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageIO.java: Added much new methods. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageReader.java, javax/imageio/ImageWriter.java, javax/imageio/spi/ImageWriterSpi.java: Add SOME new methods. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/IIOParam.java, javax/imageio/ImageReadParam.java, javax/imageio/ImageReader.java, javax/imageio/ImageWriter.java: Mostly implemented. * javax/imageio/spi/ImageReaderSpi.java, javax/imageio/spi/ImageWriterSpi.java: New files. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageWriteParam.java, javax/imageio/metadata/IIOMetadataFormat.java: Implemented. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageTypeSpecifier.java: Mostly implemented. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/metadata/IIOMetadata.java: Mostly implemented. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/IIOImage.java, javax/imageio/ImageReadParam.java, javax/imageio/metadata/IIOMetadataController.java, javax/imageio/metadata/IIOMetadataFormat.java: New files. * javax/imageio/stream/ImageOutputStream.java: Implemented. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/IIOParam.java, javax/imageio/IIOParamController.java, javax/imageio/ImageTypeSpecifier.java, javax/imageio/ImageWriteParam.java, javax/imageio/metadata/IIOMetadata.java: New files. * javax/imageio/ImageTranscoder.java: Implemented. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/spi/ImageInputStreamSpi.java, javax/imageio/spi/ImageOutputStreamSpi.java: Reworked import startments. * javax/imageio/spi/ServiceRegistry.java: Reworked import startments. Fixed XHTML in javadocs. (ServiceRegistry): Added @param tag to javadoc. * javax/imageio/stream/ImageInputStream.java (mark): Doesn't throws IOException; 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/ImageIO.java: New file. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/spi/IIORegistry.java (static): Don't register ImageReaderSpi.class and ImageWriterSpi.class yet. 2004-11-06 Michael Koch <konqueror@gmx.de> * javax/imageio/spi/IIORegistry.java: New file. From-SVN: r90181
Diffstat (limited to 'libjava/javax')
-rw-r--r--libjava/javax/imageio/IIOImage.java138
-rw-r--r--libjava/javax/imageio/IIOParam.java157
-rw-r--r--libjava/javax/imageio/IIOParamController.java58
-rw-r--r--libjava/javax/imageio/ImageIO.java494
-rw-r--r--libjava/javax/imageio/ImageReadParam.java110
-rw-r--r--libjava/javax/imageio/ImageReader.java481
-rw-r--r--libjava/javax/imageio/ImageTranscoder.java16
-rw-r--r--libjava/javax/imageio/ImageTypeSpecifier.java94
-rw-r--r--libjava/javax/imageio/ImageWriteParam.java398
-rw-r--r--libjava/javax/imageio/ImageWriter.java350
-rw-r--r--libjava/javax/imageio/event/IIOReadProgressListener.java3
-rw-r--r--libjava/javax/imageio/event/IIOReadUpdateListener.java3
-rw-r--r--libjava/javax/imageio/event/IIOReadWarningListener.java3
-rw-r--r--libjava/javax/imageio/event/IIOWriteProgressListener.java3
-rw-r--r--libjava/javax/imageio/event/IIOWriteWarningListener.java3
-rw-r--r--libjava/javax/imageio/event/package.html46
-rw-r--r--libjava/javax/imageio/metadata/IIOInvalidTreeException.java63
-rw-r--r--libjava/javax/imageio/metadata/IIOMetadata.java213
-rw-r--r--libjava/javax/imageio/metadata/IIOMetadataController.java47
-rw-r--r--libjava/javax/imageio/metadata/IIOMetadataFormat.java124
-rw-r--r--libjava/javax/imageio/metadata/IIOMetadataFormatImpl.java43
-rw-r--r--libjava/javax/imageio/metadata/IIOMetadataNode.java43
-rw-r--r--libjava/javax/imageio/metadata/package.html46
-rw-r--r--libjava/javax/imageio/spi/IIORegistry.java103
-rw-r--r--libjava/javax/imageio/spi/ImageInputStreamSpi.java2
-rw-r--r--libjava/javax/imageio/spi/ImageOutputStreamSpi.java2
-rw-r--r--libjava/javax/imageio/spi/ImageReaderSpi.java121
-rw-r--r--libjava/javax/imageio/spi/ImageWriterSpi.java135
-rw-r--r--libjava/javax/imageio/spi/ServiceRegistry.java20
-rw-r--r--libjava/javax/imageio/stream/FileCacheImageInputStream.java93
-rw-r--r--libjava/javax/imageio/stream/FileCacheImageOutputStream.java93
-rw-r--r--libjava/javax/imageio/stream/FileImageInputStream.java87
-rw-r--r--libjava/javax/imageio/stream/FileImageOutputStream.java90
-rw-r--r--libjava/javax/imageio/stream/ImageInputStream.java3
-rw-r--r--libjava/javax/imageio/stream/ImageInputStreamImpl.java157
-rw-r--r--libjava/javax/imageio/stream/ImageOutputStream.java217
-rw-r--r--libjava/javax/imageio/stream/ImageOutputStreamImpl.java65
-rw-r--r--libjava/javax/imageio/stream/MemoryCacheImageInputStream.java60
-rw-r--r--libjava/javax/imageio/stream/MemoryCacheImageOutputStream.java60
39 files changed, 4216 insertions, 28 deletions
diff --git a/libjava/javax/imageio/IIOImage.java b/libjava/javax/imageio/IIOImage.java
new file mode 100644
index 0000000..587a3d4
--- /dev/null
+++ b/libjava/javax/imageio/IIOImage.java
@@ -0,0 +1,138 @@
+/* IIOImage.java --
+ Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.util.List;
+
+import javax.imageio.metadata.IIOMetadata;
+
+public class IIOImage
+{
+ protected RenderedImage image;
+ protected IIOMetadata metadata;
+ protected Raster raster;
+ protected List thumbnails;
+
+ public IIOImage (Raster raster, List thumbnails, IIOMetadata metadata)
+ {
+ if (raster == null)
+ throw new IllegalArgumentException ("raster may not be null");
+
+ this.raster = raster;
+ this.thumbnails = thumbnails;
+ this.metadata = metadata;
+ }
+
+ public IIOImage (RenderedImage image, List thumbnails, IIOMetadata metadata)
+ {
+ if (image == null)
+ throw new IllegalArgumentException ("image may not be null");
+
+ this.image = image;
+ this.thumbnails = thumbnails;
+ this.metadata = metadata;
+ }
+
+ public IIOMetadata getMetadata()
+ {
+ return metadata;
+ }
+
+ public int getNumThumbnails()
+ {
+ return thumbnails.size();
+ }
+
+ public Raster getRaster()
+ {
+ return raster;
+ }
+
+ public RenderedImage getRenderedImage()
+ {
+ return image;
+ }
+
+ public BufferedImage getThumbnail (int index)
+ {
+ return (BufferedImage) thumbnails.get (index);
+ }
+
+ public List getThumbnails()
+ {
+ return thumbnails;
+ }
+
+ public boolean hasRaster()
+ {
+ return raster != null;
+ }
+
+ public void setMetadata (IIOMetadata metadata)
+ {
+ this.metadata = metadata;
+ }
+
+ public void setRaster (Raster raster)
+ {
+ if (raster == null)
+ throw new IllegalArgumentException ("raster may not be null");
+
+ this.image = null;
+ this.raster = raster;
+ }
+
+ public void setRenderedImage (RenderedImage image)
+ {
+ if (image == null)
+ throw new IllegalArgumentException ("image may not be null");
+
+ this.image = image;
+ this.raster = null;
+ }
+
+ public void setThumbnails (List thumbnails)
+ {
+ this.thumbnails = thumbnails;
+ }
+
+} // class IIOParam
diff --git a/libjava/javax/imageio/IIOParam.java b/libjava/javax/imageio/IIOParam.java
new file mode 100644
index 0000000..bbab1cf
--- /dev/null
+++ b/libjava/javax/imageio/IIOParam.java
@@ -0,0 +1,157 @@
+/* IIOParam.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class IIOParam
+{
+ protected IIOParamController controller;
+ protected IIOParamController defaultController;
+ protected Point destinationOffset = new Point(0, 0);
+ protected ImageTypeSpecifier destinationType;
+ protected int[] sourceBands;
+ protected Rectangle sourceRegion;
+ protected int sourceXSubsampling;
+ protected int sourceYSubsampling;
+ protected int subsamplingXOffset;
+ protected int subsamplingYOffset;
+
+ /**
+ * Initializes an <code>IIOParam</code> object.
+ */
+ protected IIOParam()
+ {
+ // Do nothing here.
+ }
+
+ public boolean activateController()
+ {
+ if (controller == null)
+ return false;
+
+ return controller.activate(this);
+ }
+
+ public IIOParamController getController()
+ {
+ return controller;
+ }
+
+ public IIOParamController getDefaultController()
+ {
+ return defaultController;
+ }
+
+ public Point getDestinationOffset()
+ {
+ return destinationOffset;
+ }
+
+ public ImageTypeSpecifier getDestinationType()
+ {
+ return destinationType;
+ }
+
+ public int[] getSourceBands()
+ {
+ return sourceBands;
+ }
+
+ public Rectangle getSourceRegion()
+ {
+ return sourceRegion;
+ }
+
+ public int getSourceXSubsampling()
+ {
+ return sourceXSubsampling;
+ }
+
+ public int getSourceYSubsampling()
+ {
+ return sourceYSubsampling;
+ }
+
+ public int getSubsamplingXOffset()
+ {
+ return subsamplingXOffset;
+ }
+
+ public int getSubsamplingYOffset()
+ {
+ return subsamplingYOffset;
+ }
+
+ public boolean hasController()
+ {
+ return getController() != null;
+ }
+
+ public void setController(IIOParamController controller)
+ {
+ this.controller = controller;
+ }
+
+ public void setDestinationOffset(Point destinationOffset)
+ {
+ if (destinationOffset == null)
+ throw new IllegalArgumentException("destinationOffset is null");
+
+ this.destinationOffset = destinationOffset;
+ }
+
+ public void setSourceRegion(Rectangle sourceRegion)
+ {
+ if (sourceRegion != null
+ && (sourceRegion.x < 0
+ || sourceRegion.y < 0
+ || sourceRegion.width <= 0
+ || sourceRegion.height <= 0))
+ throw new IllegalArgumentException("illegal source region");
+
+ // FIXME: Throw IllegalStateException.
+
+ this.sourceRegion = sourceRegion;
+ }
+}
diff --git a/libjava/javax/imageio/IIOParamController.java b/libjava/javax/imageio/IIOParamController.java
new file mode 100644
index 0000000..0568c19
--- /dev/null
+++ b/libjava/javax/imageio/IIOParamController.java
@@ -0,0 +1,58 @@
+/* IIOParamController.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public interface IIOParamController
+{
+ /**
+ * Activates the controller.
+ *
+ * @param param the <code>IIOParam</code> to be modified
+ *
+ * @return true if the <code>IIOParam</code> has been modified,
+ * false otherwise
+ *
+ * @exception IllegalArgumentException if param is null or is not an instance
+ * of the correct class
+ */
+ boolean activate(IIOParam param);
+}
diff --git a/libjava/javax/imageio/ImageIO.java b/libjava/javax/imageio/ImageIO.java
new file mode 100644
index 0000000..5cc7c92
--- /dev/null
+++ b/libjava/javax/imageio/ImageIO.java
@@ -0,0 +1,494 @@
+/* ImageIO.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+
+import javax.imageio.spi.IIORegistry;
+import javax.imageio.spi.ImageReaderSpi;
+import javax.imageio.spi.ImageWriterSpi;
+import javax.imageio.spi.ServiceRegistry;
+
+public final class ImageIO
+{
+ private static final class ReaderFormatFilter implements ServiceRegistry.Filter
+ {
+ private String formatName;
+
+ public ReaderFormatFilter(String formatName)
+ {
+ this.formatName = formatName;
+ }
+
+ public boolean filter (Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) provider;
+ String[] formatNames = spi.getFormatNames();
+
+ for (int i = formatNames.length - 1; i >= 0; --i)
+ if (formatName.equals(formatNames[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class ReaderMIMETypeFilter implements ServiceRegistry.Filter
+ {
+ private String MIMEType;
+
+ public ReaderMIMETypeFilter(String MIMEType)
+ {
+ this.MIMEType = MIMEType;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) provider;
+ String[] mimetypes = spi.getMIMETypes();
+
+ for (int i = mimetypes.length - 1; i >= 0; --i)
+ if (MIMEType.equals(mimetypes[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class ReaderSuffixFilter implements ServiceRegistry.Filter
+ {
+ private String fileSuffix;
+
+ public ReaderSuffixFilter(String fileSuffix)
+ {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) provider;
+ String[] suffixes = spi.getFileSuffixes();
+
+ for (int i = suffixes.length - 1; i >= 0; --i)
+ if (fileSuffix.equals(suffixes[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class WriterFormatFilter implements ServiceRegistry.Filter
+ {
+ private String formatName;
+
+ public WriterFormatFilter(String formatName)
+ {
+ this.formatName = formatName;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) provider;
+ String[] formatNames = spi.getFormatNames();
+
+ for (int i = formatNames.length - 1; i >= 0; --i)
+ if (formatName.equals(formatNames[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class WriterMIMETypeFilter implements ServiceRegistry.Filter
+ {
+ private String MIMEType;
+
+ public WriterMIMETypeFilter(String MIMEType)
+ {
+ this.MIMEType = MIMEType;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) provider;
+ String[] mimetypes = spi.getMIMETypes();
+
+ for (int i = mimetypes.length - 1; i >= 0; --i)
+ if (MIMEType.equals(mimetypes[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class WriterSuffixFilter implements ServiceRegistry.Filter
+ {
+ private String fileSuffix;
+
+ public WriterSuffixFilter(String fileSuffix)
+ {
+ this.fileSuffix = fileSuffix;
+ }
+
+ public boolean filter(Object provider)
+ {
+ if (provider instanceof ImageReaderSpi)
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) provider;
+ String[] suffixes = spi.getFileSuffixes();
+
+ for (int i = suffixes.length - 1; i >= 0; --i)
+ if (fileSuffix.equals(suffixes[i]))
+ return true;
+ }
+
+ return false;
+ }
+ }
+
+ private static final class ImageReaderIterator implements Iterator
+ {
+ Iterator it;
+
+ public ImageReaderIterator(Iterator it)
+ {
+ this.it = it;
+ }
+
+ public boolean hasNext()
+ {
+ return it.hasNext();
+ }
+
+ public Object next()
+ {
+ try
+ {
+ return ((ImageReaderSpi) it.next()).createReaderInstance();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static final class ImageWriterIterator implements Iterator
+ {
+ Iterator it;
+
+ public ImageWriterIterator(Iterator it)
+ {
+ this.it = it;
+ }
+
+ public boolean hasNext()
+ {
+ return it.hasNext();
+ }
+
+ public Object next()
+ {
+ try
+ {
+ return ((ImageWriterSpi) it.next()).createWriterInstance();
+ }
+ catch (IOException e)
+ {
+ return null;
+ }
+ }
+
+ public void remove()
+ {
+ throw new UnsupportedOperationException();
+ }
+ }
+
+ private static File cacheDirectory;
+ private static boolean useCache = true;
+
+ private static Iterator getReadersByFilter(Class type,
+ ServiceRegistry.Filter filter)
+ {
+ try
+ {
+ Iterator it = getRegistry().getServiceProviders(type, filter, true);
+ return new ImageReaderIterator(it);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return Collections.EMPTY_SET.iterator();
+ }
+ }
+
+ private static Iterator getWritersByFilter(Class type,
+ ServiceRegistry.Filter filter)
+ {
+ try
+ {
+ Iterator it = getRegistry().getServiceProviders(type, filter, true);
+ return new ImageWriterIterator(it);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return Collections.EMPTY_SET.iterator();
+ }
+ }
+
+ public static File getCacheDirectory()
+ {
+ return cacheDirectory;
+ }
+
+ public static Iterator getImageReadersByFormatName(String formatName)
+ {
+ if (formatName == null)
+ throw new IllegalArgumentException("formatName may not be null");
+
+ return getReadersByFilter(ImageReaderSpi.class,
+ new ReaderFormatFilter(formatName));
+ }
+
+ public static Iterator getImageReadersByMIMEType(String MIMEType)
+ {
+ if (MIMEType == null)
+ throw new IllegalArgumentException("MIMEType may not be null");
+
+ return getReadersByFilter(ImageReaderSpi.class,
+ new ReaderMIMETypeFilter(MIMEType));
+ }
+
+ public static Iterator getImageReadersBySuffix(String fileSuffix)
+ {
+ if (fileSuffix == null)
+ throw new IllegalArgumentException("formatName may not be null");
+
+ return getReadersByFilter(ImageReaderSpi.class,
+ new ReaderSuffixFilter(fileSuffix));
+ }
+
+ public static Iterator getImageWritersByFormatName(String formatName)
+ {
+ if (formatName == null)
+ throw new IllegalArgumentException("formatName may not be null");
+
+ return getWritersByFilter(ImageWriterSpi.class,
+ new WriterFormatFilter(formatName));
+ }
+
+ public static Iterator getImageWritersByMIMEType(String MIMEType)
+ {
+ if (MIMEType == null)
+ throw new IllegalArgumentException("MIMEType may not be null");
+
+ return getWritersByFilter(ImageWriterSpi.class,
+ new WriterMIMETypeFilter(MIMEType));
+ }
+
+ public static Iterator getImageWritersBySuffix(String fileSuffix)
+ {
+ if (fileSuffix == null)
+ throw new IllegalArgumentException("fileSuffix may not be null");
+
+ return getWritersByFilter(ImageWriterSpi.class,
+ new WriterSuffixFilter(fileSuffix));
+ }
+
+ public static String[] getReaderFormatNames()
+ {
+ try
+ {
+ Iterator it =
+ getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+ ArrayList result = new ArrayList();
+
+ while (it.hasNext())
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) it.next();
+ String[] names = spi.getFormatNames();
+
+ for (int i = names.length - 1; i >= 0; --i)
+ result.add(names[i]);
+ }
+
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return new String[0];
+ }
+ }
+
+ public static String[] getReaderMIMETypes()
+ {
+ try
+ {
+ Iterator it =
+ getRegistry().getServiceProviders(ImageReaderSpi.class, true);
+ ArrayList result = new ArrayList();
+
+ while (it.hasNext())
+ {
+ ImageReaderSpi spi = (ImageReaderSpi) it.next();
+ String[] names = spi.getMIMETypes();
+
+ for (int i = names.length - 1; i >= 0; --i)
+ result.add(names[i]);
+ }
+
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return new String[0];
+ }
+ }
+
+ private static IIORegistry getRegistry()
+ {
+ return IIORegistry.getDefaultInstance();
+ }
+
+ public static boolean getUseCache()
+ {
+ return useCache;
+ }
+
+ public static String[] getWriterFormatNames()
+ {
+ try
+ {
+ Iterator it =
+ getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+ ArrayList result = new ArrayList();
+
+ while (it.hasNext())
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) it.next();
+ String[] names = spi.getFormatNames();
+
+ for (int i = names.length - 1; i >= 0; --i)
+ result.add(names[i]);
+ }
+
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return new String[0];
+ }
+ }
+
+ public static String[] getWriterMIMETypes()
+ {
+ try
+ {
+ Iterator it =
+ getRegistry().getServiceProviders(ImageWriterSpi.class, true);
+ ArrayList result = new ArrayList();
+
+ while (it.hasNext())
+ {
+ ImageWriterSpi spi = (ImageWriterSpi) it.next();
+ String[] names = spi.getMIMETypes();
+
+ for (int i = names.length - 1; i >= 0; --i)
+ result.add(names[i]);
+ }
+
+ return (String[]) result.toArray(new String[result.size()]);
+ }
+ catch (IllegalArgumentException e)
+ {
+ return new String[0];
+ }
+ }
+
+ /**
+ * Rescans the application classpath for ImageIO service providers
+ * and registers them.
+ */
+ public static void scanForPlugins()
+ {
+ IIORegistry.getDefaultInstance().registerApplicationClasspathSpis();
+ }
+
+ public static void setCacheDirectory(File cacheDirectory)
+ {
+ if (cacheDirectory != null)
+ {
+ if (!cacheDirectory.isDirectory())
+ throw new IllegalArgumentException("cacheDirectory must be a directory");
+
+ cacheDirectory.canWrite();
+ }
+
+ ImageIO.cacheDirectory = cacheDirectory;
+ }
+
+ public static void setUseCache(boolean useCache)
+ {
+ ImageIO.useCache = useCache;
+ }
+}
diff --git a/libjava/javax/imageio/ImageReadParam.java b/libjava/javax/imageio/ImageReadParam.java
new file mode 100644
index 0000000..e5414bd
--- /dev/null
+++ b/libjava/javax/imageio/ImageReadParam.java
@@ -0,0 +1,110 @@
+/* ImageReadParam.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.awt.Dimension;
+import java.awt.image.BufferedImage;
+
+/**
+ * @author Michel Koch (konqueror@gmx.de)
+ */
+public class ImageReadParam extends IIOParam
+{
+ protected boolean canSetSourceRenderSize;
+ protected BufferedImage destination;
+ protected int[] destinationBands;
+ protected int minProgressivePass;
+ protected int numProgressivePasses = Integer.MAX_VALUE;
+ protected Dimension sourceRenderSize;
+
+ public ImageReadParam()
+ {
+ }
+
+ public boolean canSetSourceRenderSize()
+ {
+ return canSetSourceRenderSize;
+ }
+
+ public BufferedImage getDestination()
+ {
+ return destination;
+ }
+
+ public int[] getDestinationBands()
+ {
+ return destinationBands;
+ }
+
+ public int getSourceMaxProgressivePass()
+ {
+ if (getSourceNumProgressivePasses() == Integer.MAX_VALUE)
+ return Integer.MAX_VALUE;
+
+ return getSourceMinProgressivePass() + getSourceNumProgressivePasses() - 1;
+ }
+
+ public int getSourceMinProgressivePass()
+ {
+ return minProgressivePass;
+ }
+
+ public int getSourceNumProgressivePasses()
+ {
+ return numProgressivePasses;
+ }
+
+ public Dimension getSourceRenderSize()
+ {
+ return sourceRenderSize;
+ }
+
+ public void setSourceRenderSize(Dimension size)
+ throws UnsupportedOperationException
+ {
+ if (! canSetSourceRenderSize())
+ throw new UnsupportedOperationException
+ ("setting source render size not supported");
+
+ if (size.width <= 0 || size.height <= 0)
+ throw new IllegalArgumentException("negative dimension not allowed");
+
+ sourceRenderSize = size;
+ }
+}
diff --git a/libjava/javax/imageio/ImageReader.java b/libjava/javax/imageio/ImageReader.java
index 75ae9ad..91cb53c 100644
--- a/libjava/javax/imageio/ImageReader.java
+++ b/libjava/javax/imageio/ImageReader.java
@@ -1,5 +1,5 @@
/* ImageReader.java -- Decodes raster images.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,482 @@ exception statement from your version. */
package javax.imageio;
+import java.awt.image.BufferedImage;
+import java.awt.image.Raster;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import javax.imageio.event.IIOReadProgressListener;
+import javax.imageio.event.IIOReadUpdateListener;
+import javax.imageio.event.IIOReadWarningListener;
+import javax.imageio.metadata.IIOMetadata;
+import javax.imageio.spi.ImageReaderSpi;
+
public abstract class ImageReader
{
- // FIXME: Incomplete. This class is merely present in order to allow
- // compilation of the javax.imageio.spi package, for which GNU
- // Classpath does provide an implementation.
+ private boolean aborted;
+
+ protected Locale[] availableLocales;
+ protected boolean ignoreMetadata;
+ protected Object input;
+ protected Locale locale;
+ protected int minIndex;
+ protected ImageReaderSpi originatingProvider;
+ protected List progressListeners;
+ protected boolean seekForwardOnly;
+ protected List updateListeners = new ArrayList();
+ protected List warningListeners = new ArrayList();
+ protected List warningLocales = new ArrayList();
+
+ protected ImageReader(ImageReaderSpi originatingProvider)
+ {
+ this.originatingProvider = originatingProvider;
+ }
+
+ public void abort()
+ {
+ aborted = true;
+ }
+
+ protected boolean abortRequested()
+ {
+ return aborted;
+ }
+
+ public void addIIOReadProgressListener(IIOReadProgressListener listener)
+ {
+ if (listener == null)
+ return;
+
+ progressListeners.add(listener);
+ }
+
+ public void addIIOReadUpdateListener(IIOReadUpdateListener listener)
+ {
+ if (listener == null)
+ return;
+
+ updateListeners.add(listener);
+ }
+
+ public void addIIOReadWarningListener(IIOReadWarningListener listener)
+ {
+ if (listener == null)
+ return;
+
+ warningListeners.add(listener);
+ }
+
+ public boolean canReadRaster()
+ {
+ return false;
+ }
+
+ protected void clearAbortRequest()
+ {
+ aborted = false;
+ }
+
+ public void dispose()
+ {
+ // The default implementation does nothing.
+ }
+
+ public float getAspectRatio(int imageIndex)
+ throws IOException
+ {
+ return (float) (getWidth(imageIndex) / getHeight(imageIndex));
+ }
+
+ public Locale[] getAvailableLocales()
+ {
+ if (availableLocales == null)
+ return null;
+
+ return (Locale[]) availableLocales.clone();
+ }
+
+ public ImageReadParam getDefaultReadParam()
+ {
+ return new ImageReadParam();
+ }
+
+ public String getFormatName()
+ throws IOException
+ {
+ return originatingProvider.getFormatNames()[0];
+ }
+
+ public abstract int getHeight(int imageIndex)
+ throws IOException;
+
+ public abstract IIOMetadata getImageMetadata(int imageIndex)
+ throws IOException;
+
+ public abstract Iterator getImageTypes(int imageIndex)
+ throws IOException;
+
+ public Object getInput()
+ {
+ return input;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public abstract int getNumImages(boolean allowSearch)
+ throws IOException;
+
+ public int getNumThumbnails(int imageIndex)
+ throws IOException
+ {
+ return 0;
+ }
+
+ public ImageReaderSpi getOriginatingProvider()
+ {
+ return originatingProvider;
+ }
+
+ public abstract IIOMetadata getStreamMetadata()
+ throws IOException;
+
+ public int getThumbnailHeight(int imageIndex, int thumbnailIndex)
+ throws IOException
+ {
+ return readThumbnail(imageIndex, thumbnailIndex).getHeight();
+ }
+
+ public int getThumbnailWidth(int imageIndex, int thumbnailIndex)
+ throws IOException
+ {
+ return readThumbnail(imageIndex, thumbnailIndex).getWidth();
+ }
+
+ public int getTileGridXOffset(int imageIndex)
+ throws IOException
+ {
+ return 0;
+ }
+
+ public int getTileGridYOffset(int imageIndex)
+ throws IOException
+ {
+ return 0;
+ }
+
+ public int getTileHeight(int imageIndex)
+ throws IOException
+ {
+ return getHeight(imageIndex);
+ }
+
+ public int getTileWidth(int imageIndex)
+ throws IOException
+ {
+ return getWidth(imageIndex);
+ }
+
+ public abstract int getWidth(int imageIndex)
+ throws IOException;
+
+ public boolean hasThumbnails(int imageIndex)
+ throws IOException
+ {
+ return getNumThumbnails(imageIndex) > 0;
+ }
+
+ public boolean isIgnoringMetadata()
+ {
+ return ignoreMetadata;
+ }
+
+ public boolean isImageTiled(int imageIndex)
+ throws IOException
+ {
+ return false;
+ }
+
+ public boolean isRandomAccessEasy(int imageIndex)
+ throws IOException
+ {
+ return false;
+ }
+
+ public boolean isSeekForwardOnly()
+ {
+ return seekForwardOnly;
+ }
+
+ protected void processImageComplete()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.imageComplete (this);
+ }
+ }
+
+ protected void processImageProgress(float percentageDone)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.imageProgress(this, percentageDone);
+ }
+ }
+
+ protected void processImageStarted(int imageIndex)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.imageStarted(this, imageIndex);
+ }
+ }
+
+ protected void processImageUpdate(BufferedImage image, int minX, int minY,
+ int width, int height, int periodX,
+ int periodY, int[] bands)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.imageUpdate(this, image, minX, minY, width, height, periodX,
+ periodY, bands);
+ }
+ }
+
+ protected void processPassComplete(BufferedImage image)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.passComplete(this, image);
+ }
+ }
+
+ protected void processPassStarted(BufferedImage image, int pass, int minPass,
+ int maxPass, int minX, int minY,
+ int periodX, int periodY, int[] bands)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.passStarted(this, image, pass, minPass, maxPass, minX, minY,
+ periodX, periodY, bands);
+ }
+ }
+
+ protected void processReadAborted()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.readAborted(this);
+ }
+ }
+
+ protected void processSequenceComplete()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.sequenceComplete(this);
+ }
+ }
+
+ protected void processSequenceStarted(int minIndex)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.sequenceStarted(this, minIndex);
+ }
+ }
+
+ protected void processThumbnailComplete()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.thumbnailComplete(this);
+ }
+ }
+
+ protected void processThumbnailPassComplete(BufferedImage thumbnail)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailPassComplete(this, thumbnail);
+ }
+ }
+
+ protected void processThumbnailPassStarted(BufferedImage thumbnail, int pass,
+ int minPass, int maxPass, int minX,
+ int minY, int periodX, int periodY,
+ int[] bands)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailPassStarted(this, thumbnail, pass, minPass, maxPass,
+ minX, minY, periodX, periodY, bands);
+ }
+ }
+
+ protected void processThumbnailProgress(float percentageDone)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.thumbnailProgress(this, percentageDone);
+ }
+ }
+
+ protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadProgressListener listener = (IIOReadProgressListener) it.next();
+ listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ }
+ }
+
+ protected void processThumbnailUpdate(BufferedImage image, int minX, int minY,
+ int width, int height, int periodX,
+ int periodY, int[] bands)
+ {
+ Iterator it = updateListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadUpdateListener listener = (IIOReadUpdateListener) it.next();
+ listener.thumbnailUpdate(this, image, minX, minY, width, height,
+ periodX, periodY, bands);
+ }
+ }
+
+ protected void processWarningOccurred(String warning)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOReadWarningListener listener = (IIOReadWarningListener) it.next();
+ listener.warningOccurred(this, warning);
+ }
+ }
+
+ public abstract BufferedImage read(int imageIndex, ImageReadParam param)
+ throws IOException;
+
+ public boolean readerSupportsThumbnails()
+ {
+ return false;
+ }
+
+ public Raster readRaster(int imageIndex, ImageReadParam param)
+ throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public BufferedImage readThumbnail(int imageIndex, int thumbnailIndex)
+ throws IOException
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ public void removeAllIIOReadProgressListeners()
+ {
+ progressListeners.clear();
+ }
+
+ public void removeAllIIOReadUpdateListeners()
+ {
+ updateListeners.clear();
+ }
+
+ public void removeAllIIOReadWarningListeners()
+ {
+ warningListeners.clear();
+ }
+
+ public void removeIIOReadProgressListener(IIOReadProgressListener listener)
+ {
+ if (listener == null)
+ return;
+
+ progressListeners.remove(listener);
+ }
+
+ public void removeIIOReadUpdateListener(IIOReadUpdateListener listener)
+ {
+ if (listener == null)
+ return;
+
+ updateListeners.remove(listener);
+ }
+
+ public void removeIIOReadWarningListener(IIOReadWarningListener listener)
+ {
+ if (listener == null)
+ return;
+
+ warningListeners.remove(listener);
+ }
+
+ public void setLocale(Locale locale)
+ {
+ if (locale != null)
+ {
+ // Check if its a valid locale.
+ boolean found = false;
+
+ if (availableLocales != null)
+ for (int i = availableLocales.length - 1; i >= 0; --i)
+ if (availableLocales[i].equals(locale))
+ found = true;
+
+ if (! found)
+ throw new IllegalArgumentException("looale not available");
+ }
+
+ this.locale = locale;
+ }
}
diff --git a/libjava/javax/imageio/ImageTranscoder.java b/libjava/javax/imageio/ImageTranscoder.java
index 20c6959..7b2012b 100644
--- a/libjava/javax/imageio/ImageTranscoder.java
+++ b/libjava/javax/imageio/ImageTranscoder.java
@@ -1,5 +1,5 @@
/* ImageTranscoder.java -- Image metadata transcoder.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,9 +38,17 @@ exception statement from your version. */
package javax.imageio;
+import javax.imageio.metadata.IIOMetadata;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
public interface ImageTranscoder
{
- // FIXME: Incomplete. This interface is merely present in order to
- // allow compilation of the javax.imageio.spi package, for which GNU
- // Classpath does provide an implementation.
+ IIOMetadata convertImageMetadata(IIOMetadata inData,
+ ImageTypeSpecifier imageType,
+ ImageWriteParam param);
+
+ IIOMetadata convertStreamMetadata(IIOMetadata inData,
+ ImageWriteParam param);
}
diff --git a/libjava/javax/imageio/ImageTypeSpecifier.java b/libjava/javax/imageio/ImageTypeSpecifier.java
new file mode 100644
index 0000000..f5d9ee2
--- /dev/null
+++ b/libjava/javax/imageio/ImageTypeSpecifier.java
@@ -0,0 +1,94 @@
+/* ImageTypeSpecifier.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.awt.image.ColorModel;
+import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
+
+public class ImageTypeSpecifier
+{
+ protected ColorModel colorModel;
+ protected SampleModel sampleModel;
+
+ public ImageTypeSpecifier(ColorModel colorModel, SampleModel sampleModel)
+ {
+ if (colorModel == null)
+ throw new IllegalArgumentException("colorModel may not be null");
+
+ if (sampleModel == null)
+ throw new IllegalArgumentException("sampleModel may not be null");
+
+ if (!colorModel.isCompatibleSampleModel(sampleModel))
+ throw new IllegalArgumentException
+ ("sample Model not compatible with colorModel");
+
+ this.colorModel = colorModel;
+ this.sampleModel = sampleModel;
+ }
+
+ public ImageTypeSpecifier(RenderedImage image)
+ {
+ if (image == null)
+ throw new IllegalArgumentException("image may not be null");
+
+ this.colorModel = image.getColorModel();
+ this.sampleModel = image.getSampleModel();
+ }
+
+ public ColorModel getColorModel()
+ {
+ return colorModel;
+ }
+
+ public int getNumBands()
+ {
+ return sampleModel.getNumBands();
+ }
+
+ public int getNumComponents()
+ {
+ return colorModel.getNumComponents();
+ }
+
+ public SampleModel getSampleModel()
+ {
+ return sampleModel;
+ }
+}
diff --git a/libjava/javax/imageio/ImageWriteParam.java b/libjava/javax/imageio/ImageWriteParam.java
new file mode 100644
index 0000000..0eb9073
--- /dev/null
+++ b/libjava/javax/imageio/ImageWriteParam.java
@@ -0,0 +1,398 @@
+/* ImageWriteParam.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio;
+
+import java.awt.Dimension;
+import java.util.Locale;
+
+public class ImageWriteParam extends IIOParam
+{
+ public static final int MODE_DISABLED = 0;
+ public static final int MODE_DEFAULT = 1;
+ public static final int MODE_EXPLICIT = 2;
+ public static final int MODE_COPY_FROM_METADATA = 3;
+
+ protected boolean canOffsetTiles;
+ protected boolean canWriteCompressed;
+ protected boolean canWriteProgressive;
+ protected boolean canWriteTiles;
+ protected int compressionMode = MODE_COPY_FROM_METADATA;
+ protected float compressionQuality;
+ protected String compressionType;
+ protected String[] compressionTypes;
+ protected Locale locale;
+ protected Dimension[] preferredTileSizes;
+ protected int progressiveMode = MODE_COPY_FROM_METADATA;
+ protected int tileGridXOffset;
+ protected int tileGridYOffset;
+ protected int tileHeight;
+ protected int tileWidth;
+ protected int tilingMode;
+ protected boolean tilingSet;
+
+ /**
+ * Creates an empty <code>ImageWriteParam</code> object.
+ * The subclass is responsible to initialize all fields.
+ */
+ protected ImageWriteParam()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * Creates an <code>ImageWriteParam</code> object with the given locale.
+ *
+ * @param locale the locale to use for user visible strings
+ */
+ public ImageWriteParam(Locale locale)
+ {
+ this.locale = locale;
+ }
+
+ public float getBitRate(float quality)
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();
+
+ return -1.0f;
+ }
+
+ private void checkSupportsCompression()
+ {
+ if (! canWriteCompressed())
+ throw new UnsupportedOperationException("compression not supported");
+ }
+
+ private void checkNotExplicitCompression()
+ {
+ if (getCompressionMode() != MODE_EXPLICIT)
+ throw new IllegalStateException("compression mode is not MODE_EXPLICIT");
+ }
+
+ private void checkCompressionTypesSet()
+ {
+ if (getCompressionType() == null
+ && getCompressionTypes() != null)
+ throw new IllegalStateException("no compression type set");
+ }
+
+ private void checkSupportsProgressiveEncoding()
+ {
+ if (! canWriteProgressive())
+ throw new UnsupportedOperationException
+ ("progressive output not supported");
+ }
+
+ private void checkSupportsTiling()
+ {
+ if (! canWriteTiles())
+ throw new UnsupportedOperationException("tiling not supported");
+ }
+
+ private void checkNotExplicitTiling()
+ {
+ if (getTilingMode() != MODE_EXPLICIT)
+ throw new IllegalStateException("tiling mode not MODE_EXPLICIT");
+ }
+
+ private void checkTilingInitialized()
+ {
+ if (! tilingSet)
+ throw new IllegalStateException("tiling parameters not set");
+ }
+
+ private void checkMode(int mode)
+ {
+ if (mode < MODE_DISABLED || mode > MODE_COPY_FROM_METADATA)
+ throw new IllegalArgumentException("mode not supported");
+ }
+
+ public boolean canOffsetTiles()
+ {
+ return canOffsetTiles;
+ }
+
+ public boolean canWriteCompressed()
+ {
+ return canWriteCompressed;
+ }
+
+ public boolean canWriteProgressive()
+ {
+ return canWriteProgressive;
+ }
+
+ public boolean canWriteTiles()
+ {
+ return canWriteTiles;
+ }
+
+ public int getCompressionMode()
+ {
+ checkSupportsCompression();
+
+ return compressionMode;
+ }
+
+ public float getCompressionQuality()
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();
+
+ return compressionQuality;
+ }
+
+ public String[] getCompressionQualityDescriptions()
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();;
+
+ return null;
+ }
+
+ public float[] getCompressionQualityValues()
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();;
+
+ return null;
+ }
+
+ public String getCompressionType()
+ {
+ checkNotExplicitCompression();
+
+ return compressionType;
+ }
+
+ public String[] getCompressionTypes()
+ {
+ checkSupportsCompression();
+
+ return compressionTypes != null ? (String[]) compressionTypes.clone() : null;
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public String getLocalizedCompressionTypeName()
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();
+
+ return getCompressionType();
+ }
+
+ public Dimension[] getPreferredTileSizes()
+ {
+ checkSupportsTiling();
+
+ return preferredTileSizes;
+ }
+
+ public int getProgressiveMode()
+ {
+ checkSupportsProgressiveEncoding();
+
+ return progressiveMode;
+ }
+
+ public int getTileGridXOffset()
+ {
+ checkNotExplicitTiling();
+ checkTilingInitialized();
+
+ return tileGridXOffset;
+ }
+
+ public int getTileGridYOffset()
+ {
+ checkNotExplicitTiling();
+ checkTilingInitialized();
+
+ return tileGridYOffset;
+ }
+
+ public int getTileHeight()
+ {
+ checkNotExplicitTiling();
+ checkTilingInitialized();
+
+ return tileHeight;
+ }
+
+ public int getTileWidth()
+ {
+ checkNotExplicitTiling();
+ checkTilingInitialized();
+
+ return tileWidth;
+ }
+
+ public int getTilingMode()
+ {
+ checkSupportsTiling();
+
+ return tilingMode;
+ }
+
+ public boolean isCompressionLossless()
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();
+
+ return true;
+ }
+
+ public void setCompressionMode(int mode)
+ {
+ checkSupportsCompression();
+ checkMode(mode);
+
+ compressionMode = mode;
+
+ if (mode == MODE_EXPLICIT)
+ unsetCompression();
+ }
+
+ public void setCompressionQuality(float quality)
+ {
+ checkNotExplicitCompression();
+ checkCompressionTypesSet();
+
+ if (quality < 0.0f || quality > 1.0f)
+ throw new IllegalArgumentException("quality out of range");
+
+ compressionQuality = quality;
+ }
+
+ public void setCompressionType(String compressionType)
+ {
+ checkNotExplicitCompression();
+
+ String[] types = getCompressionTypes();
+
+ if (types == null)
+ throw new UnsupportedOperationException("no settable compression types");
+
+ if (compressionType == null)
+ this.compressionType = null;
+
+ for (int i = types.length - 1; i >= 0; --i)
+ if (types[i].equals(compressionType))
+ {
+ this.compressionType = compressionType;
+ return;
+ }
+
+ throw new IllegalArgumentException("unknown compression type");
+ }
+
+ public void setProgressiveMode(int mode)
+ {
+ checkSupportsProgressiveEncoding();
+ checkMode(mode);
+
+ progressiveMode = mode;
+ }
+
+ public void setTiling(int tileWidth, int tileHeight,
+ int tileGridXOffset, int tileGridYOffset)
+ {
+ checkNotExplicitTiling();
+
+ if (! canOffsetTiles
+ && tileGridXOffset != 0
+ && tileGridYOffset != 0)
+ throw new UnsupportedOperationException("tile offsets not supported");
+
+ if (tileWidth < 0 || tileHeight < 0)
+ throw new IllegalArgumentException("negative tile dimension");
+
+ if (preferredTileSizes != null)
+ {
+ boolean found = false;
+
+ for (int i = 0; i < preferredTileSizes.length; i += 2)
+ {
+ if (tileWidth >= preferredTileSizes[i].width
+ && tileWidth <= preferredTileSizes[i + 1].width
+ && tileHeight >= preferredTileSizes[i].height
+ && tileHeight <= preferredTileSizes[i + 1].height)
+ found = true;
+ }
+
+ if (! found)
+ throw new IllegalArgumentException("illegal tile size");
+ }
+
+ this.tilingSet = true;
+ this.tileWidth = tileWidth;
+ this.tileHeight = tileHeight;
+ this.tileGridXOffset = tileGridXOffset;
+ this.tileGridYOffset = tileGridYOffset;
+ }
+
+ public void setTilingMode(int mode)
+ {
+ checkSupportsTiling();
+ checkMode(mode);
+ tilingMode = mode;
+ }
+
+ public void unsetCompression()
+ {
+ checkNotExplicitCompression();
+
+ compressionType = null;
+ compressionQuality = 1.0F;
+ }
+
+ public void unsetTiling()
+ {
+ checkNotExplicitTiling();
+
+ tileWidth = 0;
+ tileHeight = 0;
+ tileGridXOffset = 0;
+ tileGridYOffset = 0;
+ }
+}
diff --git a/libjava/javax/imageio/ImageWriter.java b/libjava/javax/imageio/ImageWriter.java
index 7ef60c3..64466b1 100644
--- a/libjava/javax/imageio/ImageWriter.java
+++ b/libjava/javax/imageio/ImageWriter.java
@@ -1,5 +1,5 @@
/* ImageWriter.java -- Encodes raster images.
- Copyright (C) 2004 Free Software Foundation, Inc.
+ Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -38,10 +38,352 @@ exception statement from your version. */
package javax.imageio;
+import java.awt.Dimension;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Locale;
+
+import javax.imageio.event.IIOWriteProgressListener;
+import javax.imageio.event.IIOWriteWarningListener;
+import javax.imageio.metadata.IIOMetadata;
+
+import javax.imageio.spi.ImageWriterSpi;
+
public abstract class ImageWriter
implements ImageTranscoder
{
- // FIXME: Incomplete. This class is merely present in order to allow
- // compilation of the javax.imageio.spi package, for which GNU
- // Classpath does provide an implementation.
+ private boolean aborted;
+
+ protected Locale[] availableLocales;
+ protected Locale locale;
+ protected ImageWriterSpi originatingProvider;
+ protected Object output;
+ protected List progressListeners;
+ protected List warningListeners;
+ protected List warningLocales;
+
+ protected ImageWriter(ImageWriterSpi originatingProvider)
+ {
+ this.originatingProvider = originatingProvider;
+ }
+
+ private void checkOutputSet()
+ {
+ if (output == null)
+ throw new IllegalStateException("no output set");
+ }
+
+ public void abort()
+ {
+ aborted = true;
+ }
+
+ protected boolean abortRequested()
+ {
+ return aborted;
+ }
+
+ public void addIIOWriteProgressListener(IIOWriteProgressListener listener)
+ {
+ if (listener == null)
+ return;
+
+ progressListeners.add(listener);
+ }
+
+ public void addIIOWriteWarningListener (IIOWriteWarningListener listener)
+ {
+ if (listener == null)
+ return;
+
+ warningListeners.add(listener);
+ }
+
+ public boolean canInsertEmpty(int imageIndex)
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canInsertImage(int imageIndex)
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canRemoveImage(int imageIndex)
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canReplaceImageMetadata(int imageIndex)
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canReplacePixels(int imageIndex)
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canReplaceStreamMetadata()
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canWriteEmpty()
+ throws IOException
+ {
+ checkOutputSet();
+ return false;
+ }
+
+ public boolean canWriteRasters()
+ {
+ return false;
+ }
+
+ public boolean canWriteSequence()
+ {
+ return false;
+ }
+
+ protected void clearAbortRequest()
+ {
+ aborted = false;
+ }
+
+ public abstract IIOMetadata convertImageMetadata (IIOMetadata inData,
+ ImageTypeSpecifier imageType,
+ ImageWriteParam param);
+
+ public abstract IIOMetadata convertStreamMetadata (IIOMetadata inData,
+ ImageWriteParam param);
+
+ public void dispose()
+ {
+ // The default implementation is empty. Subclasses have to overwrite it.
+ }
+
+ public Locale[] getAvailableLocales()
+ {
+ return availableLocales;
+ }
+
+ public abstract IIOMetadata getDefaultImageMetadata (ImageTypeSpecifier imageType, ImageWriteParam param);
+
+ public abstract IIOMetadata getDefaultStreamMetadata (ImageWriteParam param);
+
+ public ImageWriteParam getDefaultWriteParam()
+ {
+ return new ImageWriteParam(getLocale());
+ }
+
+ public Locale getLocale()
+ {
+ return locale;
+ }
+
+ public int getNumThumbnailsSupported (ImageTypeSpecifier imageType, ImageWriteParam param,
+ IIOMetadata streamMetadata, IIOMetadata imageMetadata)
+ {
+ return 0;
+ }
+
+ public ImageWriterSpi getOriginatingProvider()
+ {
+ return originatingProvider;
+ }
+
+ public Object getOutput()
+ {
+ return output;
+ }
+
+ public Dimension[] getPreferredThumbnailSizes (ImageTypeSpecifier imageType,
+ ImageWriteParam param,
+ IIOMetadata streamMetadata,
+ IIOMetadata imageMetadata)
+ {
+ return null;
+ }
+
+ protected void processImageComplete()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.imageComplete(this);
+ }
+ }
+
+ protected void processImageProgress(float percentageDone)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.imageProgress(this, percentageDone);
+ }
+ }
+
+ protected void processImageStarted(int imageIndex)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.imageStarted(this, imageIndex);
+ }
+ }
+
+ protected void processThumbnailComplete()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.thumbnailComplete(this);
+ }
+ }
+
+ protected void processThumbnailProgress(float percentageDone)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.thumbnailProgress(this, percentageDone);
+ }
+ }
+
+ protected void processThumbnailStarted(int imageIndex, int thumbnailIndex)
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.thumbnailStarted(this, imageIndex, thumbnailIndex);
+ }
+ }
+
+ protected void processWarningOccurred(int imageIndex, String warning)
+ {
+ Iterator it = warningListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteWarningListener listener = (IIOWriteWarningListener) it.next();
+ listener.warningOccurred(this, imageIndex, warning);
+ }
+ }
+
+ protected void processWriteAborted()
+ {
+ Iterator it = progressListeners.iterator();
+
+ while (it.hasNext())
+ {
+ IIOWriteProgressListener listener = (IIOWriteProgressListener) it.next();
+ listener.writeAborted(this);
+ }
+ }
+
+ public void removeAllIIOWriteProgressListeners()
+ {
+ progressListeners.clear();
+ }
+
+ public void removeAllIIOWriteWarningListeners()
+ {
+ progressListeners.clear();
+ }
+
+ public void removeIIOWriteProgressListener (IIOWriteProgressListener listener)
+ {
+ if (listener == null)
+ return;
+
+ progressListeners.remove(listener);
+ }
+
+ public void removeIIOWriteWarningListener (IIOWriteWarningListener listener)
+ {
+ if (listener == null)
+ return;
+
+ warningListeners.remove(listener);
+ }
+
+ public void reset()
+ {
+ setOutput(null);
+ setLocale(null);
+ removeAllIIOWriteWarningListeners();
+ removeAllIIOWriteProgressListeners();
+ clearAbortRequest();
+ }
+
+ public void setLocale(Locale locale)
+ {
+ if (locale != null)
+ {
+ // Check if its a valid locale.
+ boolean found = false;
+
+ if (availableLocales != null)
+ for (int i = availableLocales.length - 1; i >= 0; --i)
+ if (availableLocales[i].equals(locale))
+ found = true;
+
+ if (! found)
+ throw new IllegalArgumentException("looale not available");
+ }
+
+ this.locale = locale;
+ }
+
+ public void setOutput(Object output)
+ {
+ if (output != null)
+ {
+ // Check if its a valid output object.
+ boolean found = false;
+ Class[] types = null;
+
+ if (originatingProvider != null)
+ types = originatingProvider.getOutputTypes();
+
+ if (types != null)
+ for (int i = types.length - 1; i >= 0; --i)
+ if (types[i].equals(output.getClass()))
+ found = true;
+
+ if (! found)
+ throw new IllegalArgumentException("output type not available");
+ }
+
+ this.output = output;
+ }
+
+ public abstract void write (IIOMetadata streamMetadata, IIOImage image, ImageWriteParam param)
+ throws IOException;
}
diff --git a/libjava/javax/imageio/event/IIOReadProgressListener.java b/libjava/javax/imageio/event/IIOReadProgressListener.java
index 1574432..7ba5bba 100644
--- a/libjava/javax/imageio/event/IIOReadProgressListener.java
+++ b/libjava/javax/imageio/event/IIOReadProgressListener.java
@@ -35,11 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.imageio.event;
import java.util.EventListener;
-import javax.imageio.ImageReader;
+import javax.imageio.ImageReader;
public interface IIOReadProgressListener extends EventListener
{
diff --git a/libjava/javax/imageio/event/IIOReadUpdateListener.java b/libjava/javax/imageio/event/IIOReadUpdateListener.java
index d51c852..18ac4f0 100644
--- a/libjava/javax/imageio/event/IIOReadUpdateListener.java
+++ b/libjava/javax/imageio/event/IIOReadUpdateListener.java
@@ -35,12 +35,13 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.imageio.event;
import java.awt.image.BufferedImage;
import java.util.EventListener;
-import javax.imageio.ImageReader;
+import javax.imageio.ImageReader;
public interface IIOReadUpdateListener extends EventListener
{
diff --git a/libjava/javax/imageio/event/IIOReadWarningListener.java b/libjava/javax/imageio/event/IIOReadWarningListener.java
index ab12df0..34fcbb7 100644
--- a/libjava/javax/imageio/event/IIOReadWarningListener.java
+++ b/libjava/javax/imageio/event/IIOReadWarningListener.java
@@ -35,11 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.imageio.event;
import java.util.EventListener;
-import javax.imageio.ImageReader;
+import javax.imageio.ImageReader;
public interface IIOReadWarningListener extends EventListener
{
diff --git a/libjava/javax/imageio/event/IIOWriteProgressListener.java b/libjava/javax/imageio/event/IIOWriteProgressListener.java
index 6158c54..e713642 100644
--- a/libjava/javax/imageio/event/IIOWriteProgressListener.java
+++ b/libjava/javax/imageio/event/IIOWriteProgressListener.java
@@ -35,11 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.imageio.event;
import java.util.EventListener;
-import javax.imageio.ImageWriter;
+import javax.imageio.ImageWriter;
public interface IIOWriteProgressListener extends EventListener
{
diff --git a/libjava/javax/imageio/event/IIOWriteWarningListener.java b/libjava/javax/imageio/event/IIOWriteWarningListener.java
index a0630c9..9f8d521 100644
--- a/libjava/javax/imageio/event/IIOWriteWarningListener.java
+++ b/libjava/javax/imageio/event/IIOWriteWarningListener.java
@@ -35,11 +35,12 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package javax.imageio.event;
import java.util.EventListener;
-import javax.imageio.ImageWriter;
+import javax.imageio.ImageWriter;
/**
* @author Michael Koch (konqueror@gmx.de)
diff --git a/libjava/javax/imageio/event/package.html b/libjava/javax/imageio/event/package.html
new file mode 100644
index 0000000..c36a11a
--- /dev/null
+++ b/libjava/javax/imageio/event/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.event package.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.event</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/javax/imageio/metadata/IIOInvalidTreeException.java b/libjava/javax/imageio/metadata/IIOInvalidTreeException.java
new file mode 100644
index 0000000..c3ce424
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOInvalidTreeException.java
@@ -0,0 +1,63 @@
+/* IIOInvalidTreeException.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+import javax.imageio.IIOException;
+
+public class IIOInvalidTreeException extends IIOException
+{
+ protected /*Node*/ Object offendingNode;
+
+ public IIOInvalidTreeException(String message, /*Node*/ Object offendingNode)
+ {
+ super(message);
+ this.offendingNode = offendingNode;
+ }
+
+ public IIOInvalidTreeException(String message, Throwable cause, /*Node*/ Object offendingNode)
+ {
+ super(message, cause);
+ this.offendingNode = offendingNode;
+ }
+
+ public /*Node*/ Object getOffendingNode()
+ {
+ return offendingNode;
+ }
+}
diff --git a/libjava/javax/imageio/metadata/IIOMetadata.java b/libjava/javax/imageio/metadata/IIOMetadata.java
new file mode 100644
index 0000000..bb96770
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOMetadata.java
@@ -0,0 +1,213 @@
+/* IIOMetadata.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class IIOMetadata
+{
+ protected IIOMetadataController controller;
+ protected IIOMetadataController defaultController;
+ protected String[] extraMetadataFormatClassNames;
+ protected String[] extraMetadataFormatNames;
+ protected String nativeMetadataFormatClassName;
+ protected String nativeMetadataFormatName;
+ protected boolean standardFormatSupported;
+
+ /**
+ * Creates a <code>IIOMetaData</code> object.
+ */
+ protected IIOMetadata()
+ {
+ // Do nothing here.
+ }
+
+ /**
+ * Creates a <code>IIOMetaData</code> object with the given arguments.
+ *
+ * @param standardMetadataFormatSupported
+ * @param nativeMetadataFormatName
+ * @param nativeMetadataFormatClassName
+ * @param extraMetadataFormatNames
+ * @param extraMetadataFormatClassNames
+ *
+ * @throws IllegalArgumentException if extraMetadataFormatNames has length of
+ * zero or extraMetadataFormatNames and extraMetadataFormatClassNames are
+ * neither both null, not have the same length
+ */
+ protected IIOMetadata(boolean standardMetadataFormatSupported,
+ String nativeMetadataFormatName,
+ String nativeMetadataFormatClassName,
+ String[] extraMetadataFormatNames,
+ String[] extraMetadataFormatClassNames)
+ {
+ if (extraMetadataFormatNames != null
+ && extraMetadataFormatNames.length == 0)
+ throw new IllegalArgumentException
+ ("extraMetadataFormatNames may not be empty");
+
+ if (((extraMetadataFormatNames == null)
+ && (extraMetadataFormatClassNames != null))
+ || ((extraMetadataFormatNames != null)
+ && (extraMetadataFormatClassNames == null))
+ || ((extraMetadataFormatNames != null)
+ && (extraMetadataFormatClassNames != null)
+ && (extraMetadataFormatNames.length !=
+ extraMetadataFormatClassNames.length)))
+ throw new IllegalArgumentException
+ ("extraMetadataFormatNames and extraMetadataFormatClassNames " +
+ "have different lengths");
+
+ this.standardFormatSupported = standardMetadataFormatSupported;
+ this.nativeMetadataFormatName = nativeMetadataFormatName;
+ this.nativeMetadataFormatClassName = nativeMetadataFormatClassName;
+ this.extraMetadataFormatNames = extraMetadataFormatNames;
+ this.extraMetadataFormatClassNames = extraMetadataFormatClassNames;
+ }
+
+ public boolean activateController()
+ {
+ if (! hasController())
+ return false;
+
+ return getDefaultController().activate(this);
+ }
+
+ public IIOMetadataController getController()
+ {
+ return controller;
+ }
+
+ public IIOMetadataController getDefaultController()
+ {
+ return defaultController;
+ }
+
+ public String[] getExtraMetadataFormatNames()
+ {
+ return (String[]) extraMetadataFormatNames.clone();
+ }
+
+ public IIOMetadataFormat getMetadataFormat(String formatName)
+ {
+ if (formatName == null)
+ throw new IllegalArgumentException("formatName may not be null");
+
+ String formatClassName = null;
+
+ if (isStandardMetadataFormatSupported()
+ && formatName.equals(nativeMetadataFormatName))
+ formatClassName = nativeMetadataFormatClassName;
+ else
+ {
+ String[] extraFormatNames = getExtraMetadataFormatNames();
+
+ for (int i = extraFormatNames.length - 1; i >= 0; --i)
+ if (extraFormatNames[i].equals(formatName))
+ {
+ formatClassName = extraFormatNames[i];
+ break;
+ }
+ }
+
+ if (formatClassName == null)
+ throw new IllegalArgumentException("unknown format");
+
+ IIOMetadataFormat format;
+
+ try
+ {
+ format = (IIOMetadataFormat) Class.forName(formatClassName)
+ .newInstance();
+ }
+ catch (Exception e)
+ {
+ IllegalStateException ise = new IllegalStateException();
+ ise.initCause(e);
+ throw ise;
+ }
+
+ return format;
+ }
+
+ public String[] getMetadataFormatNames()
+ {
+ String[] formatNames = getExtraMetadataFormatNames();
+
+ if (isStandardMetadataFormatSupported())
+ {
+ // Combine native metadata format name and extra metadata format names
+ // into one String array.
+ String[] tmp = new String[formatNames.length + 1];
+ tmp[0] = getNativeMetadataFormatName();
+
+ for (int i = 1; i < tmp.length; ++i)
+ tmp[i] = formatNames[i - 1];
+
+ formatNames = tmp;
+ }
+
+ return formatNames;
+ }
+
+ public String getNativeMetadataFormatName()
+ {
+ return nativeMetadataFormatName;
+ }
+
+ public boolean hasController()
+ {
+ return getController() != null;
+ }
+
+ public abstract boolean isReadOnly();
+
+ public boolean isStandardMetadataFormatSupported()
+ {
+ return standardFormatSupported;
+ }
+
+ public abstract void reset();
+
+ public void setController(IIOMetadataController controller)
+ {
+ this.controller = controller;
+ }
+}
diff --git a/libjava/javax/imageio/metadata/IIOMetadataController.java b/libjava/javax/imageio/metadata/IIOMetadataController.java
new file mode 100644
index 0000000..db899d8
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOMetadataController.java
@@ -0,0 +1,47 @@
+/* IIOMetadataController.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public interface IIOMetadataController
+{
+ boolean activate(IIOMetadata metadata);
+}
diff --git a/libjava/javax/imageio/metadata/IIOMetadataFormat.java b/libjava/javax/imageio/metadata/IIOMetadataFormat.java
new file mode 100644
index 0000000..2aef266
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOMetadataFormat.java
@@ -0,0 +1,124 @@
+/* IIOMetadataFormat.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+import java.util.Locale;
+
+import javax.imageio.ImageTypeSpecifier;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public interface IIOMetadataFormat
+{
+ int CHILD_POLICY_ALL = 1;
+ int CHILD_POLICY_CHOICE = 3;
+ int CHILD_POLICY_EMPTY = 0;
+ int CHILD_POLICY_MAX = 5;
+ int CHILD_POLICY_REPEAT = 5;
+ int CHILD_POLICY_SEQUENCE = 4;
+ int CHILD_POLICY_SOME = 2;
+ int DATATYPE_BOOLEAN = 1;
+ int DATATYPE_DOUBLE = 4;
+ int DATATYPE_FLOAT = 3;
+ int DATATYPE_INTEGER = 2;
+ int DATATYPE_STRING = 0;
+ int VALUE_ARBITRARY = 1;
+ int VALUE_ENUMERATION = 16;
+ int VALUE_LIST = 32;
+ int VALUE_NONE = 0;
+ int VALUE_RANGE = 2;
+ int VALUE_RANGE_MAX_INCLUSIVE = 10;
+ int VALUE_RANGE_MAX_INCLUSIVE_MASK = 8;
+ int VALUE_RANGE_MIN_INCLUSIVE = 6;
+ int VALUE_RANGE_MIN_INCLUSIVE_MASK = 4;
+ int VALUE_RANGE_MIN_MAX_INCLUSIVE = 14;
+
+ boolean canNodeAppear (String elementName, ImageTypeSpecifier imageType);
+
+ int getAttributeDataType (String elementName, String attrName);
+
+ String getAttributeDefaultValue (String elementName, String attrName);
+
+ String getAttributeDescription (String elementName, String attrName, Locale locale);
+
+ String[] getAttributeEnumerations (String elementName, String attrName);
+
+ int getAttributeListMaxLength (String elementName, String attrName);
+
+ int getAttributeListMinLength (String elementName, String attrName);
+
+ String getAttributeMaxValue (String elementName, String attrName);
+
+ String getAttributeMinValue (String elementName, String attrName);
+
+ String[] getAttributeNames (String elementName);
+
+ int getAttributeValueType (String elementName, String attrName);
+
+ String[] getChildNames (String elementName);
+
+ int getChildPolicy (String elementName);
+
+ String getElementDescription (String elementName, Locale locale);
+
+ int getElementMaxChildren (String elementName);
+
+ int getElementMinChildren (String elementName);
+
+ int getObjectArrayMaxLength (String elementName);
+
+ int getObjectArrayMinLength (String elementName);
+
+ Class getObjectClass (String elementName);
+
+ Object getObjectDefaultValue (String elementName);
+
+ Object[] getObjectEnumerations (String elementName);
+
+ Comparable getObjectMaxValue (String elementName);
+
+ Comparable getObjectMinValue (String elementName);
+
+ int getObjectValueType (String elementName);
+
+ String getRootName();
+
+ boolean isAttributeRequired (String elementName, String attrName);
+}
diff --git a/libjava/javax/imageio/metadata/IIOMetadataFormatImpl.java b/libjava/javax/imageio/metadata/IIOMetadataFormatImpl.java
new file mode 100644
index 0000000..eab2055
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOMetadataFormatImpl.java
@@ -0,0 +1,43 @@
+/* IIOMetadataFormatImpl.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+public abstract class IIOMetadataFormatImpl implements IIOMetadataFormat
+{
+}
diff --git a/libjava/javax/imageio/metadata/IIOMetadataNode.java b/libjava/javax/imageio/metadata/IIOMetadataNode.java
new file mode 100644
index 0000000..3d1c7d2
--- /dev/null
+++ b/libjava/javax/imageio/metadata/IIOMetadataNode.java
@@ -0,0 +1,43 @@
+/* IIOMetadataNode.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.metadata;
+
+public class IIOMetadataNode
+{
+}
diff --git a/libjava/javax/imageio/metadata/package.html b/libjava/javax/imageio/metadata/package.html
new file mode 100644
index 0000000..3188e32
--- /dev/null
+++ b/libjava/javax/imageio/metadata/package.html
@@ -0,0 +1,46 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
+<!-- package.html - describes classes in javax.imageio.metadata package.
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. -->
+
+<html>
+<head><title>GNU Classpath - javax.imageio.metadata</title></head>
+
+<body>
+<p></p>
+
+</body>
+</html>
diff --git a/libjava/javax/imageio/spi/IIORegistry.java b/libjava/javax/imageio/spi/IIORegistry.java
new file mode 100644
index 0000000..7728cf4
--- /dev/null
+++ b/libjava/javax/imageio/spi/IIORegistry.java
@@ -0,0 +1,103 @@
+/* IIORegistry.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.spi;
+
+import gnu.classpath.ServiceFactory;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+
+public final class IIORegistry extends ServiceRegistry
+{
+ private static final HashSet defaultCategories = new HashSet();
+
+ private static HashMap instances = new HashMap();
+
+ static
+ {
+ //defaultCategories.add(ImageReaderSpi.class);
+ //defaultCategories.add(ImageWriterSpi.class);
+ defaultCategories.add(ImageTranscoderSpi.class);
+ defaultCategories.add(ImageInputStreamSpi.class);
+ defaultCategories.add(ImageOutputStreamSpi.class);
+ }
+
+ public static synchronized IIORegistry getDefaultInstance()
+ {
+ ThreadGroup group = Thread.currentThread().getThreadGroup();
+ IIORegistry registry = (IIORegistry) instances.get(group);
+
+ if (registry == null)
+ {
+ registry = new IIORegistry();
+ instances.put(group, registry);
+ }
+
+ return registry;
+ }
+
+ private IIORegistry()
+ {
+ super(defaultCategories.iterator());
+
+ // XXX: Register built-in Spis here.
+
+ registerApplicationClasspathSpis();
+ }
+
+ /**
+ * Registers all available service providers found on the application
+ * classpath.
+ */
+ public void registerApplicationClasspathSpis()
+ {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ Iterator categories = getCategories();
+
+ while (categories.hasNext())
+ {
+ Class category = (Class) categories.next();
+ Iterator providers = ServiceFactory.lookupProviders(category, loader);
+
+ while (providers.hasNext())
+ registerServiceProvider((IIOServiceProvider) providers.next());
+ }
+ }
+}
diff --git a/libjava/javax/imageio/spi/ImageInputStreamSpi.java b/libjava/javax/imageio/spi/ImageInputStreamSpi.java
index b8d5854..6e33d1d 100644
--- a/libjava/javax/imageio/spi/ImageInputStreamSpi.java
+++ b/libjava/javax/imageio/spi/ImageInputStreamSpi.java
@@ -40,8 +40,8 @@ package javax.imageio.spi;
import java.io.File;
import java.io.IOException;
-import javax.imageio.stream.ImageInputStream;
+import javax.imageio.stream.ImageInputStream;
/**
* An abstract superclass for service providers that create
diff --git a/libjava/javax/imageio/spi/ImageOutputStreamSpi.java b/libjava/javax/imageio/spi/ImageOutputStreamSpi.java
index aa287c3..935aa7c 100644
--- a/libjava/javax/imageio/spi/ImageOutputStreamSpi.java
+++ b/libjava/javax/imageio/spi/ImageOutputStreamSpi.java
@@ -40,8 +40,8 @@ package javax.imageio.spi;
import java.io.File;
import java.io.IOException;
-import javax.imageio.stream.ImageOutputStream;
+import javax.imageio.stream.ImageOutputStream;
/**
* An abstract superclass for service providers that create
diff --git a/libjava/javax/imageio/spi/ImageReaderSpi.java b/libjava/javax/imageio/spi/ImageReaderSpi.java
new file mode 100644
index 0000000..e041c37
--- /dev/null
+++ b/libjava/javax/imageio/spi/ImageReaderSpi.java
@@ -0,0 +1,121 @@
+/* ImageReaderSpi.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.spi;
+
+import java.io.IOException;
+
+import javax.imageio.ImageReader;
+import javax.imageio.stream.ImageInputStream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class ImageReaderSpi extends ImageReaderWriterSpi
+{
+ public static final Class[] STANDARD_INPUT_TYPE =
+ { ImageInputStream.class };
+
+ protected Class[] inputTypes;
+ protected String[] writerSpiNames;
+
+ protected ImageReaderSpi()
+ {
+ // Do nothing here.
+ }
+
+ public ImageReaderSpi(String vendorName, String version, String[] names,
+ String[] suffixes, String[] MIMETypes,
+ String readerClassName, Class[] inputTypes,
+ String[] writerSpiNames,
+ boolean supportsStandardStreamMetadataFormat,
+ String nativeStreamMetadataFormatName,
+ String nativeStreamMetadataFormatClassName,
+ String[] extraStreamMetadataFormatNames,
+ String[] extraStreamMetadataFormatClassNames,
+ boolean supportsStandardImageMetadataFormat,
+ String nativeImageMetadataFormatName,
+ String nativeImageMetadataFormatClassName,
+ String[] extraImageMetadataFormatNames,
+ String[] extraImageMetadataFormatClassNames)
+ {
+ super(vendorName, version, names, suffixes, MIMETypes, readerClassName,
+ supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
+
+ if (inputTypes == null
+ || inputTypes.length == 0)
+ throw new IllegalArgumentException("inputTypes may not be null or empty");
+
+ this.inputTypes = inputTypes;
+ this.writerSpiNames = writerSpiNames;
+ }
+
+ public abstract boolean canDecodeInput(Object source)
+ throws IOException;
+
+ public ImageReader createReaderInstance()
+ throws IOException
+ {
+ return createReaderInstance(null);
+ }
+
+ public abstract ImageReader createReaderInstance(Object extension)
+ throws IOException;
+
+ public String[] getImageWriterSpiNames()
+ {
+ return writerSpiNames;
+ }
+
+ public Class[] getInputTypes()
+ {
+ return inputTypes;
+ }
+
+ public boolean isOwnReader(ImageReader reader)
+ {
+ if (reader == null)
+ throw new IllegalArgumentException("reader may not be null");
+
+ return pluginClassName.equals(reader.getClass().getName());
+ }
+}
diff --git a/libjava/javax/imageio/spi/ImageWriterSpi.java b/libjava/javax/imageio/spi/ImageWriterSpi.java
new file mode 100644
index 0000000..306408d
--- /dev/null
+++ b/libjava/javax/imageio/spi/ImageWriterSpi.java
@@ -0,0 +1,135 @@
+/* ImageWriterSpi.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.spi;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+import javax.imageio.ImageTypeSpecifier;
+import javax.imageio.ImageWriter;
+import javax.imageio.stream.ImageOutputStream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class ImageWriterSpi extends ImageReaderWriterSpi
+{
+ public static final Class[] STANDARD_OUTPUT_TYPE =
+ { ImageOutputStream.class };
+
+ protected Class[] outputTypes;
+ protected String[] readerSpiNames;
+
+ protected ImageWriterSpi()
+ {
+ // Do nothing here.
+ }
+
+ public ImageWriterSpi(String vendorName, String version, String[] names,
+ String[] suffixes, String[] MIMETypes,
+ String writerClassName, Class[] outputTypes,
+ String[] readerSpiNames,
+ boolean supportsStandardStreamMetadataFormat,
+ String nativeStreamMetadataFormatName,
+ String nativeStreamMetadataFormatClassName,
+ String[] extraStreamMetadataFormatNames,
+ String[] extraStreamMetadataFormatClassNames,
+ boolean supportsStandardImageMetadataFormat,
+ String nativeImageMetadataFormatName,
+ String nativeImageMetadataFormatClassName,
+ String[] extraImageMetadataFormatNames,
+ String[] extraImageMetadataFormatClassNames)
+ {
+ super(vendorName, version, names, suffixes, MIMETypes, writerClassName,
+ supportsStandardStreamMetadataFormat, nativeStreamMetadataFormatName,
+ nativeStreamMetadataFormatClassName, extraStreamMetadataFormatNames,
+ extraStreamMetadataFormatClassNames, supportsStandardImageMetadataFormat,
+ nativeImageMetadataFormatName, nativeImageMetadataFormatClassName,
+ extraImageMetadataFormatNames, extraImageMetadataFormatClassNames);
+
+ if (writerClassName == null)
+ throw new IllegalArgumentException("writerClassName is null");
+
+ if (outputTypes == null
+ || outputTypes.length == 0)
+ throw new IllegalArgumentException("outputTypes may not be null or empty");
+
+ this.outputTypes = outputTypes;
+ this.readerSpiNames = readerSpiNames;
+ }
+
+ public abstract boolean canEncodeImage(ImageTypeSpecifier type);
+
+ public boolean canEncodeImage(RenderedImage image)
+ {
+ return canEncodeImage (new ImageTypeSpecifier(image));
+ }
+
+ public ImageWriter createWriterInstance()
+ throws IOException
+ {
+ return createWriterInstance(null);
+ }
+
+ public abstract ImageWriter createWriterInstance(Object extension)
+ throws IOException;
+
+ public String[] getImageReaderSpiNames()
+ {
+ return readerSpiNames;
+ }
+
+ public Class[] getOutputTypes()
+ {
+ return outputTypes;
+ }
+
+ public boolean isFormatLossless()
+ {
+ return true;
+ }
+
+ public boolean isOwnWriter(ImageWriter writer)
+ {
+ if (writer == null)
+ throw new IllegalArgumentException("writer may not be null");
+
+ return pluginClassName.equals(writer.getClass().getName());
+ }
+}
diff --git a/libjava/javax/imageio/spi/ServiceRegistry.java b/libjava/javax/imageio/spi/ServiceRegistry.java
index c41e1b5..566d50f 100644
--- a/libjava/javax/imageio/spi/ServiceRegistry.java
+++ b/libjava/javax/imageio/spi/ServiceRegistry.java
@@ -38,9 +38,19 @@ exception statement from your version. */
package javax.imageio.spi;
-import java.util.*;
import gnu.classpath.ServiceFactory;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashSet;
+import java.util.IdentityHashMap;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Set;
/**
* A registry for service providers.
@@ -100,6 +110,8 @@ public class ServiceRegistry
/**
* Constructs a <code>ServiceRegistry</code> for the specified
* service categories.
+ *
+ * @param categories the categories to support
*
* @throws IllegalArgumentException if <code>categories</code> is
* <code>null</code>, or if its {@link Iterator#next()} method
@@ -141,7 +153,7 @@ public class ServiceRegistry
* might make sense to install only the frequently needed service
* providers on the local machine. More exotic providers can be put
* onto a server; the server will only be contacted when no suitable
- * service could be found locally.
+ * service could be found locally.</p>
*
* <p><b>Security considerations:</b> Any loaded service providers
* are loaded through the specified ClassLoader, or the system
@@ -150,7 +162,7 @@ public class ServiceRegistry
* the current {@link java.security.AccessControlContext} gets
* recorded. This captured security context will determine the
* permissions when services get loaded via the <code>next()</code>
- * method of the returned <code>Iterator</code>.
+ * method of the returned <code>Iterator</code>.</p>
*
* @param spi the service provider interface which must be
* implemented by any loaded service providers.
@@ -474,7 +486,7 @@ public class ServiceRegistry
* invoked in order to inform the provider about the removal from
* this registry. If <code>provider</code> implements several
* service categories, <code>onDeregistration</code> gets called
- * multiple times.
+ * multiple times.</p>
*
* @param provider the service provider to be de-registered.
*
diff --git a/libjava/javax/imageio/stream/FileCacheImageInputStream.java b/libjava/javax/imageio/stream/FileCacheImageInputStream.java
new file mode 100644
index 0000000..49827d4
--- /dev/null
+++ b/libjava/javax/imageio/stream/FileCacheImageInputStream.java
@@ -0,0 +1,93 @@
+/* FileCacheImageInputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class FileCacheImageInputStream
+{
+ private InputStream stream;
+ private File cacheDir;
+
+ public FileCacheImageInputStream(InputStream stream, File cacheDir)
+ throws IOException
+ {
+ super();
+ this.stream = stream;
+ // FIXME: We do not support caching yet.
+ this.cacheDir = cacheDir;
+ }
+
+ public void close()
+ throws IOException
+ {
+ if (stream != null)
+ {
+ stream.close();
+ stream = null;
+ }
+ }
+
+ private void checkStreamClosed()
+ throws IOException
+ {
+ if (stream == null)
+ throw new IOException("stream closed");
+ }
+
+ public boolean isCached()
+ {
+ return true;
+ }
+
+ public boolean isCachedFile()
+ {
+ return true;
+ }
+
+ public boolean isCachedMemory()
+ {
+ return false;
+ }
+}
diff --git a/libjava/javax/imageio/stream/FileCacheImageOutputStream.java b/libjava/javax/imageio/stream/FileCacheImageOutputStream.java
new file mode 100644
index 0000000..f8bb310
--- /dev/null
+++ b/libjava/javax/imageio/stream/FileCacheImageOutputStream.java
@@ -0,0 +1,93 @@
+/* FileCacheImageOutputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class FileCacheImageOutputStream
+{
+ private OutputStream stream;
+ private File cacheDir;
+
+ public FileCacheImageOutputStream(OutputStream stream, File cacheDir)
+ throws IOException
+ {
+ super();
+ this.stream = stream;
+ // FIXME: We do not support caching yet.
+ this.cacheDir = cacheDir;
+ }
+
+ public void close()
+ throws IOException
+ {
+ if (stream != null)
+ {
+ stream.close();
+ stream = null;
+ }
+ }
+
+ private void checkStreamClosed()
+ throws IOException
+ {
+ if (stream == null)
+ throw new IOException("stream closed");
+ }
+
+ public boolean isCached()
+ {
+ return true;
+ }
+
+ public boolean isCachedFile()
+ {
+ return true;
+ }
+
+ public boolean isCachedMemory()
+ {
+ return false;
+ }
+}
diff --git a/libjava/javax/imageio/stream/FileImageInputStream.java b/libjava/javax/imageio/stream/FileImageInputStream.java
new file mode 100644
index 0000000..67fd075
--- /dev/null
+++ b/libjava/javax/imageio/stream/FileImageInputStream.java
@@ -0,0 +1,87 @@
+/* FileImageInputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class FileImageInputStream
+{
+ private RandomAccessFile file;
+
+ public FileImageInputStream(File file)
+ throws FileNotFoundException, IOException
+ {
+ if (file == null)
+ throw new IllegalArgumentException ("file may not be null");
+
+ this.file = new RandomAccessFile(file, "r");
+ }
+
+ public FileImageInputStream(RandomAccessFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException ("file may not be null");
+
+ this.file = file;
+ }
+
+ public void close()
+ throws IOException
+ {
+ file.close();
+ }
+
+ public long length()
+ {
+ try
+ {
+ return file.length();
+ }
+ catch (IOException e)
+ {
+ return -1L;
+ }
+ }
+}
diff --git a/libjava/javax/imageio/stream/FileImageOutputStream.java b/libjava/javax/imageio/stream/FileImageOutputStream.java
new file mode 100644
index 0000000..073faed
--- /dev/null
+++ b/libjava/javax/imageio/stream/FileImageOutputStream.java
@@ -0,0 +1,90 @@
+/* FileImageOutputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class FileImageOutputStream
+{
+ private RandomAccessFile file;
+
+ public FileImageOutputStream(File file)
+ throws FileNotFoundException, IOException
+ {
+ if (file == null)
+ throw new IllegalArgumentException("file may not be null");
+
+ // Do security check.
+ file.canRead();
+
+ this.file = new RandomAccessFile(file, "r");
+ }
+
+ public FileImageOutputStream(RandomAccessFile file)
+ {
+ if (file == null)
+ throw new IllegalArgumentException("file may not be null");
+
+ this.file = file;
+ }
+
+ public void close()
+ throws IOException
+ {
+ file.close();
+ }
+
+ public long length()
+ {
+ try
+ {
+ return file.length();
+ }
+ catch (IOException e)
+ {
+ return -1L;
+ }
+ }
+}
diff --git a/libjava/javax/imageio/stream/ImageInputStream.java b/libjava/javax/imageio/stream/ImageInputStream.java
index d37231d..39296a7 100644
--- a/libjava/javax/imageio/stream/ImageInputStream.java
+++ b/libjava/javax/imageio/stream/ImageInputStream.java
@@ -626,8 +626,7 @@ public interface ImageInputStream
void seek(long pos)
throws IOException;
- void mark()
- throws IOException;
+ void mark();
void reset()
throws IOException;
diff --git a/libjava/javax/imageio/stream/ImageInputStreamImpl.java b/libjava/javax/imageio/stream/ImageInputStreamImpl.java
new file mode 100644
index 0000000..27cb6c5
--- /dev/null
+++ b/libjava/javax/imageio/stream/ImageInputStreamImpl.java
@@ -0,0 +1,157 @@
+/* ImageInputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.IOException;
+import java.nio.ByteOrder;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class ImageInputStreamImpl implements ImageInputStream
+{
+ private boolean closed;
+
+ protected int bitOffset;
+ protected ByteOrder byteOrder;
+ protected long flushedPos;
+ protected long streamPos;
+
+ public ImageInputStreamImpl()
+ {
+ // Do nothing here.
+ }
+
+ protected void checkClosed()
+ throws IOException
+ {
+ if (closed)
+ throw new IOException("stream closed");
+ }
+
+ public void close()
+ throws IOException
+ {
+ checkClosed();
+ closed = true;
+ }
+
+ protected void finalize()
+ throws Throwable
+ {
+ close();
+ }
+
+ public void flush()
+ throws IOException
+ {
+ flushBefore(getStreamPosition());
+ }
+
+ public void flushBefore(long position)
+ throws IOException
+ {
+ if (position < flushedPos)
+ throw new IndexOutOfBoundsException();
+
+ if (position > streamPos)
+ throw new IndexOutOfBoundsException();
+
+ flushedPos = position;
+ }
+
+ public int getBitOffset()
+ throws IOException
+ {
+ return bitOffset;
+ }
+
+ public ByteOrder getByteOrder()
+ {
+ return byteOrder;
+ }
+
+ public long getFlushedPosition()
+ {
+ return flushedPos;
+ }
+
+ public long getStreamPosition()
+ throws IOException
+ {
+ return streamPos;
+ }
+
+ public boolean isCached()
+ {
+ return false;
+ }
+
+ public boolean isCachedFile()
+ {
+ return false;
+ }
+
+ public boolean isCachedMemory()
+ {
+ return false;
+ }
+
+ public long length()
+ {
+ return -1L;
+ }
+
+ public abstract int read()
+ throws IOException;
+
+ public int read(byte[] data)
+ throws IOException
+ {
+ return read(data, 0, data.length);
+ }
+
+ public abstract int read(byte[] data, int offset, int len)
+ throws IOException;
+
+ public void setByteOrder (ByteOrder byteOrder)
+ {
+ this.byteOrder = byteOrder;
+ }
+}
diff --git a/libjava/javax/imageio/stream/ImageOutputStream.java b/libjava/javax/imageio/stream/ImageOutputStream.java
index 58a6594..f53feab 100644
--- a/libjava/javax/imageio/stream/ImageOutputStream.java
+++ b/libjava/javax/imageio/stream/ImageOutputStream.java
@@ -39,6 +39,7 @@ exception statement from your version. */
package javax.imageio.stream;
import java.io.DataOutput;
+import java.io.IOException;
/**
@@ -52,7 +53,217 @@ import java.io.DataOutput;
public interface ImageOutputStream
extends ImageInputStream, DataOutput
{
- // FIXME: Incomplete. This interface is merely present in order to
- // allow compilation of the javax.imageio.spi package, for which GNU
- // Classpath does provide an implementation.
+ /**
+ * @param postion
+ *
+ * @throws IOException if an errror occurs
+ */
+ void flushBefore(long position) throws IOException;
+
+ /**
+ * Writes an array into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void write(byte[] data) throws IOException;
+
+ /**
+ * Writes a region of data from an array into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the length in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void write(byte[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes an <code>int</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void write(int data) throws IOException;
+
+ /**
+ * Writes a bit value to the stream.
+ *
+ * @throws IOException if an error occurs
+ */
+ void writeBit(int bit) throws IOException;
+
+ /**
+ * Writes a number of bit values to the stream.
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeBits(long bits, int numBits) throws IOException;
+
+ /**
+ * Writes a <code>boolean</code> value into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeBoolean(boolean data) throws IOException;
+
+ /**
+ * Writes a <code>byte</code> value into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeByte(int data) throws IOException;
+
+ /**
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeBytes(String data) throws IOException;
+
+ /**
+ * Writes a character into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeChar(int data) throws IOException;
+
+ /**
+ * Writes characters to the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeChars(char[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes characters from a given <code>String</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeChars(String data) throws IOException;
+
+ /**
+ * Writes a <code>double</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeDouble(double data) throws IOException;
+
+ /**
+ * Writes an array of <code>double</code> into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeDoubles(double[] data, int offset, int len)
+ throws IOException;
+
+ /**
+ * Writes a <code>float</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeFloat(float data) throws IOException;
+
+ /**
+ * Writes an array of <code>float</code> into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeFloats(float[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes a <code>int</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeInt(int data) throws IOException;
+
+ /**
+ * Writes an array of <code>int</code> into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeInts(int[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes a <code>long</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeLong(long data) throws IOException;
+
+ /**
+ * Writes an array of <code>long</code> into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeLongs(long[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes a <code>short</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeShort(int data) throws IOException;
+
+ /**
+ * Writes an array of <code>short</code> into the stream.
+ *
+ * @param data the data to be written
+ * @param offset the offset in the array
+ * @param len the lenth in the array
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeShorts(short[] data, int offset, int len) throws IOException;
+
+ /**
+ * Writes a <code>String</code> into the stream.
+ *
+ * @param data the data to be written
+ *
+ * @throws IOException if an errror occurs
+ */
+ void writeUTF(String data) throws IOException;
}
diff --git a/libjava/javax/imageio/stream/ImageOutputStreamImpl.java b/libjava/javax/imageio/stream/ImageOutputStreamImpl.java
new file mode 100644
index 0000000..d600943
--- /dev/null
+++ b/libjava/javax/imageio/stream/ImageOutputStreamImpl.java
@@ -0,0 +1,65 @@
+/* ImageOutputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+import java.io.IOException;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public abstract class ImageOutputStreamImpl extends ImageInputStreamImpl
+ implements ImageOutputStream
+{
+ public ImageOutputStreamImpl()
+ {
+ // Do nothing here.
+ }
+
+ public void write(byte[] data)
+ throws IOException
+ {
+ write(data, 0, data.length);
+ }
+
+ public abstract void write(byte[] data, int offset, int len)
+ throws IOException;
+
+ public abstract void write(int value)
+ throws IOException;
+}
diff --git a/libjava/javax/imageio/stream/MemoryCacheImageInputStream.java b/libjava/javax/imageio/stream/MemoryCacheImageInputStream.java
new file mode 100644
index 0000000..c7ca6d6
--- /dev/null
+++ b/libjava/javax/imageio/stream/MemoryCacheImageInputStream.java
@@ -0,0 +1,60 @@
+/* MemoryCacheImageInputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class MemoryCacheImageInputStream
+{
+ public boolean isCached()
+ {
+ return true;
+ }
+
+ public boolean isCachedFile()
+ {
+ return false;
+ }
+
+ public boolean isCachedMemory()
+ {
+ return true;
+ }
+}
diff --git a/libjava/javax/imageio/stream/MemoryCacheImageOutputStream.java b/libjava/javax/imageio/stream/MemoryCacheImageOutputStream.java
new file mode 100644
index 0000000..b91fd66
--- /dev/null
+++ b/libjava/javax/imageio/stream/MemoryCacheImageOutputStream.java
@@ -0,0 +1,60 @@
+/* MemoryCacheImageOutputStream.java --
+ Copyright (C) 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package javax.imageio.stream;
+
+/**
+ * @author Michael Koch (konqueror@gmx.de)
+ */
+public class MemoryCacheImageOutputStream
+{
+ public boolean isCached()
+ {
+ return true;
+ }
+
+ public boolean isCachedFile()
+ {
+ return false;
+ }
+
+ public boolean isCachedMemory()
+ {
+ return true;
+ }
+}