xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jerem...@apache.org
Subject svn commit: r447320 - in /xmlgraphics/commons/trunk: ./ src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ src/java/org/apache/xmlgraphics/image/writer/
Date Mon, 18 Sep 2006 08:40:00 GMT
Author: jeremias
Date: Mon Sep 18 01:39:59 2006
New Revision: 447320

URL: http://svn.apache.org/viewvc?view=rev&rev=447320
Log:
Added a runtime check for ImageWriter to verify that it will be functional when used. Example:
There's no TIFF codec in the Sun JDK. You have to include the JAI Image I/O tools in the classpath
to get TIFF support. With this change the ImageWriterRegistry automatically falls back to
the internal TIFF codec if there's no Image I/O TIFF codec.

Modified:
    xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/AbstractImageWriter.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java?view=diff&rev=447320&r1=447319&r2=447320
==============================================================================
--- xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
(original)
+++ xmlgraphics/commons/trunk/src/java-1.4/org/apache/xmlgraphics/image/writer/imageio/ImageIOImageWriter.java
Mon Sep 18 01:39:59 2006
@@ -109,13 +109,15 @@
     
     private javax.imageio.ImageWriter getIIOImageWriter() {
         Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
-        javax.imageio.ImageWriter iiowriter = (javax.imageio.ImageWriter)iter.next();
-        if (iiowriter != null) {
-            return iiowriter;
-        } else {
+        javax.imageio.ImageWriter iiowriter = null;
+        if (iter.hasNext()) {
+            iiowriter = (javax.imageio.ImageWriter)iter.next();
+        }
+        if (iiowriter == null) {
             throw new UnsupportedOperationException("No ImageIO codec for writing " 
                     + getMIMEType() + " is available!");
         }
+        return iiowriter;
     }
     
     /**
@@ -194,6 +196,13 @@
     /** @see ImageWriter#getMIMEType() */
     public String getMIMEType() {
         return this.targetMIME;
+    }
+
+    /** @see org.apache.xmlgraphics.image.writer.ImageWriter#isFunctional() */
+    public boolean isFunctional() {
+        Iterator iter = ImageIO.getImageWritersByMIMEType(getMIMEType());
+        //Only return true if an IIO ImageWriter is available in the current environment
+        return (iter.hasNext());
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/AbstractImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/AbstractImageWriter.java?view=diff&rev=447320&r1=447319&r2=447320
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/AbstractImageWriter.java
(original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/AbstractImageWriter.java
Mon Sep 18 01:39:59 2006
@@ -39,6 +39,11 @@
                 + " multiple images to a single image file.");
     }
 
+    /** @see org.apache.xmlgraphics.image.writer.ImageWriter#isFunctional() */
+    public boolean isFunctional() {
+        return true;
+    }
+
     /** @see org.apache.xmlgraphics.image.writer.ImageWriter#supportsMultiImageWriter() */
     public boolean supportsMultiImageWriter() {
         return false;

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java?view=diff&rev=447320&r1=447319&r2=447320
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
(original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
Mon Sep 18 01:39:59 2006
@@ -53,6 +53,9 @@
     /** @return the target MIME type supported by this ImageWriter */
     public String getMIMEType();
 
+    /** @return true if the ImageWriter is expected to work properly in the current environment
*/
+    public boolean isFunctional();
+    
     /** @return true if the implemented format supports multiple pages in a single file */
     public boolean supportsMultiImageWriter();
     

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java?view=diff&rev=447320&r1=447319&r2=447320
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
(original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
Mon Sep 18 01:39:59 2006
@@ -141,11 +141,14 @@
      */
     public ImageWriter getWriterFor(String mime) {
         List entries = (List)imageWriterMap.get(mime);
-        if (entries == null) {
-            return null;
-        } else {
-            return (ImageWriter)entries.get(0);
+        Iterator iter = entries.iterator();
+        while (iter.hasNext()) {
+            ImageWriter writer = (ImageWriter)iter.next();
+            if (writer.isFunctional()) {
+                return writer;
+            }
         }
+        return null;
     }
 
 }

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?view=diff&rev=447320&r1=447319&r2=447320
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Mon Sep 18 01:39:59 2006
@@ -28,6 +28,15 @@
 
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="JM" type="fix">
+        Various fixes and improvements in the ImageWriter abstraction.
+      </action>
+      <action context="Code" dev="JM" type="add">
+        ImageWriter abstraction now supports writing multi-page formats like TIFF.
+      </action>
+      <action context="Code" dev="JM" type="add">
+        ImageWriter implementation for TIFF output using Image I/O API.
+      </action>
       <action context="Code" dev="JM" type="add" due-to="Max Berger">
         Default implementation for AbstractGraphics2D.drawText(ACI, float, float) so
         PSGraphics2D supports painting text using the AttributedCharacterIterator.



---------------------------------------------------------------------
Apache XML Graphics Project URL: http://xmlgraphics.apache.org/
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message