xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c..@apache.org
Subject svn commit: r496556 [4/5] - in /xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics: image/ image/codec/png/ image/codec/tiff/ image/codec/util/ image/rendered/ image/writer/ image/writer/internal/ java2d/ util/ util/i18n/ util/io/
Date Tue, 16 Jan 2007 00:59:50 GMT
Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/tiff/TIFFLZWDecoder.java Mon Jan 15 16:59:48 2007
@@ -26,8 +26,9 @@
  */
 public class TIFFLZWDecoder {
 
-    byte stringTable[][];
-    byte data[] = null, uncompData[];
+    byte[][] stringTable;
+    byte[] data = null;
+    byte[] uncompData;
     int tableIndex, bitsToGet = 9;
     int bytePointer, bitPointer;
     int dstIndex;
@@ -36,17 +37,17 @@
     int nextData = 0;
     int nextBits = 0;
 
-    int andTable[] = {
-	511, 
-	1023,
-	2047,
-	4095
+    int[] andTable = {
+        511,
+        1023,
+        2047,
+        4095
     };
-    
+
     public TIFFLZWDecoder(int w, int predictor, int samplesPerPixel) {
-	this.w = w;
-	this.predictor = predictor;
-	this.samplesPerPixel = samplesPerPixel;
+        this.w = w;
+        this.predictor = predictor;
+        this.samplesPerPixel = samplesPerPixel;
     }
 
     /**
@@ -56,85 +57,85 @@
      * @param uncompData      Array to return the uncompressed data in.
      * @param h               The number of rows the compressed data contains.
      */
-    public byte[] decode(byte data[], byte uncompData[], int h) {
+    public byte[] decode(byte[] data, byte[] uncompData, int h) {
 
         if(data[0] == (byte)0x00 && data[1] == (byte)0x01) {
             throw new UnsupportedOperationException("TIFFLZWDecoder0");
         }
 
-	initializeStringTable();
+        initializeStringTable();
+
+        this.data = data;
+        this.h = h;
+        this.uncompData = uncompData;
+
+        // Initialize pointers
+        bytePointer = 0;
+        bitPointer = 0;
+        dstIndex = 0;
 
-	this.data = data;	
-	this.h = h;
-	this.uncompData = uncompData;
-	
-	// Initialize pointers
-	bytePointer = 0;
-	bitPointer = 0;
-	dstIndex = 0;
 
+        nextData = 0;
+        nextBits = 0;
 
-	nextData = 0;
-	nextBits = 0;
+        int code, oldCode = 0;
+        byte[] string;
 
-	int code, oldCode = 0;
-	byte string[];
- 
-	while ( ((code = getNextCode()) != 257) && 
-		dstIndex != uncompData.length) {
+        while ( ((code = getNextCode()) != 257) &&
+                dstIndex != uncompData.length) {
 
-	    if (code == 256) {
+            if (code == 256) {
 
-		initializeStringTable();
-		code = getNextCode();
+                initializeStringTable();
+                code = getNextCode();
 
-		if (code == 257) {
-		    break;
-		}
+                if (code == 257) {
+                    break;
+                }
 
-		writeString(stringTable[code]);
-		oldCode = code;
+                writeString(stringTable[code]);
+                oldCode = code;
 
-	    } else {
+            } else {
 
-		if (code < tableIndex) {
+                if (code < tableIndex) {
 
-		    string = stringTable[code];
+                    string = stringTable[code];
 
-		    writeString(string);
-		    addStringToTable(stringTable[oldCode], string[0]); 
-		    oldCode = code;
+                    writeString(string);
+                    addStringToTable(stringTable[oldCode], string[0]);
+                    oldCode = code;
 
-		} else {
+                } else {
 
-		    string = stringTable[oldCode];
-		    string = composeString(string, string[0]);
-		    writeString(string);
-		    addStringToTable(string);
-		    oldCode = code;
-		}
+                    string = stringTable[oldCode];
+                    string = composeString(string, string[0]);
+                    writeString(string);
+                    addStringToTable(string);
+                    oldCode = code;
+                }
 
-	    }
+            }
+
+        }
 
-	}
+        // Horizontal Differencing Predictor
+        if (predictor == 2) {
 
-	// Horizontal Differencing Predictor
-	if (predictor == 2) {
+            int count;
+            for (int j = 0; j < h; j++) {
 
-	    int count;
-	    for (int j = 0; j < h; j++) {
-		
-		count = samplesPerPixel * (j * w + 1);
-		
-		for (int i = samplesPerPixel; i < w * samplesPerPixel; i++) {
-		    
-		    uncompData[count] += uncompData[count - samplesPerPixel];
-		    count++;
-		}
-	    }
-	}
+                count = samplesPerPixel * (j * w + 1);
 
-	return uncompData;
+                for (int i = samplesPerPixel; i < w * samplesPerPixel; i++) {
+
+                    uncompData[count] += uncompData[count - samplesPerPixel];
+                    count++;
+                }
+            }
+        }
+
+        return uncompData;
     }
 
 
@@ -143,75 +144,75 @@
      */
     public void initializeStringTable() {
 
-	stringTable = new byte[4096][];
-	
-	for (int i=0; i<256; i++) {
-	    stringTable[i] = new byte[1];
-	    stringTable[i][0] = (byte)i;
-	}
-	
-	tableIndex = 258;
-	bitsToGet = 9;
+        stringTable = new byte[4096][];
+
+        for (int i=0; i<256; i++) {
+            stringTable[i] = new byte[1];
+            stringTable[i][0] = (byte)i;
+        }
+
+        tableIndex = 258;
+        bitsToGet = 9;
     }
 
     /**
      * Write out the string just uncompressed.
      */
-    public void writeString(byte string[]) {
-	
-	for (int i=0; i<string.length; i++) {
-	    uncompData[dstIndex++] = string[i];
-	}
+    public void writeString(byte[] string) {
+
+        for (int i=0; i<string.length; i++) {
+            uncompData[dstIndex++] = string[i];
+        }
     }
-    
+
     /**
      * Add a new string to the string table.
      */
-    public void addStringToTable(byte oldString[], byte newString) {
-	int length = oldString.length;
-	byte string[] = new byte[length + 1];
-	System.arraycopy(oldString, 0, string, 0, length);
-	string[length] = newString;
-	
-	// Add this new String to the table
-	stringTable[tableIndex++] = string;
-	
-	if (tableIndex == 511) {
-	    bitsToGet = 10;
-	} else if (tableIndex == 1023) {
-	    bitsToGet = 11;
-	} else if (tableIndex == 2047) {
-	    bitsToGet = 12;
-	} 
+    public void addStringToTable(byte[] oldString, byte newString) {
+        int length = oldString.length;
+        byte[] string = new byte[length + 1];
+        System.arraycopy(oldString, 0, string, 0, length);
+        string[length] = newString;
+
+        // Add this new String to the table
+        stringTable[tableIndex++] = string;
+
+        if (tableIndex == 511) {
+            bitsToGet = 10;
+        } else if (tableIndex == 1023) {
+            bitsToGet = 11;
+        } else if (tableIndex == 2047) {
+            bitsToGet = 12;
+        }
     }
 
     /**
      * Add a new string to the string table.
      */
-    public void addStringToTable(byte string[]) {
-	
-	// Add this new String to the table
-	stringTable[tableIndex++] = string;
-	
-	if (tableIndex == 511) {
-	    bitsToGet = 10;
-	} else if (tableIndex == 1023) {
-	    bitsToGet = 11;
-	} else if (tableIndex == 2047) {
-	    bitsToGet = 12;
-	} 
+    public void addStringToTable(byte[] string) {
+
+        // Add this new String to the table
+        stringTable[tableIndex++] = string;
+
+        if (tableIndex == 511) {
+            bitsToGet = 10;
+        } else if (tableIndex == 1023) {
+            bitsToGet = 11;
+        } else if (tableIndex == 2047) {
+            bitsToGet = 12;
+        }
     }
 
     /**
      * Append <code>newString</code> to the end of <code>oldString</code>.
      */
-    public byte[] composeString(byte oldString[], byte newString) {
-	int length = oldString.length;
-	byte string[] = new byte[length + 1];
-	System.arraycopy(oldString, 0, string, 0, length);
-	string[length] = newString;
+    public byte[] composeString(byte[] oldString, byte newString) {
+        int length = oldString.length;
+        byte[] string = new byte[length + 1];
+        System.arraycopy(oldString, 0, string, 0, length);
+        string[length] = newString;
 
-	return string;
+        return string;
     }
 
     // Returns the next 9, 10, 11 or 12 bits

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ForwardSeekableStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ForwardSeekableStream.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ForwardSeekableStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ForwardSeekableStream.java Mon Jan 15 16:59:48 2007
@@ -39,7 +39,7 @@
     /** The marked position. */
     long markPos = -1L;
 
-    /** 
+    /**
      * Constructs a <code>InputStreamForwardSeekableStream</code> from a
      * regular <code>InputStream</code>.
      */
@@ -83,13 +83,13 @@
     }
 
     /** Forwards the request to the real <code>InputStream</code>. */
-    public synchronized final void mark(int readLimit) {
+    public final synchronized void mark(int readLimit) {
         markPos = pointer;
         src.mark(readLimit);
     }
 
     /** Forwards the request to the real <code>InputStream</code>. */
-    public synchronized final void reset() throws IOException {
+    public final synchronized void reset() throws IOException {
         if (markPos != -1) {
             pointer = markPos;
         }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ImageEncoder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ImageEncoder.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ImageEncoder.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/ImageEncoder.java Mon Jan 15 16:59:48 2007
@@ -41,30 +41,30 @@
      * the ImageEncodeParam interface.  For example, a JPEGImageEncoder
      * will return an instance of JPEGEncodeParam.
      */
-    public ImageEncodeParam getParam();
+    ImageEncodeParam getParam();
 
     /**
-     * Sets the current parameters to an instance of the 
+     * Sets the current parameters to an instance of the
      * ImageEncodeParam interface.  Concrete implementations
      * of ImageEncoder may throw a RuntimeException if the
      * params argument is not an instance of the appropriate
      * subclass or subinterface.  For example, a JPEGImageEncoder
      * will expect param to be an instance of JPEGEncodeParam.
      */
-    public void setParam(ImageEncodeParam param);
+    void setParam(ImageEncodeParam param);
 
     /** Returns the OutputStream associated with this ImageEncoder. */
-    public OutputStream getOutputStream();
-    
+    OutputStream getOutputStream();
+
     /**
      * Encodes a Raster with a given ColorModel and writes the output
      * to the OutputStream associated with this ImageEncoder.
      */
-    public void encode(Raster ras, ColorModel cm) throws IOException;
+    void encode(Raster ras, ColorModel cm) throws IOException;
 
     /**
      * Encodes a RenderedImage and writes the output to the
      * OutputStream associated with this ImageEncoder.
      */
-    public void encode(RenderedImage im) throws IOException;
+    void encode(RenderedImage im) throws IOException;
 }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/MemoryCacheSeekableStream.java Mon Jan 15 16:59:48 2007
@@ -21,7 +21,8 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * A subclass of <code>SeekableStream</code> that may be used to wrap
@@ -54,7 +55,7 @@
     private static final int SECTOR_MASK = SECTOR_SIZE - 1;
 
     /** A Vector of source sectors. */
-    private Vector data = new Vector();
+    private List data = new ArrayList();
 
     /** Number of sectors stored. */
     int sectors = 0;
@@ -98,8 +99,8 @@
         // Read sectors until the desired sector
         for (int i = startSector; i <= sector; i++) {
             byte[] buf = new byte[SECTOR_SIZE];
-            data.addElement(buf);
-            
+            data.add(buf);
+
             // Read up to SECTOR_SIZE bytes
             int len = SECTOR_SIZE;
             int off = 0;
@@ -112,7 +113,7 @@
                 }
                 off += nbytes;
                 len -= nbytes;
-                
+
                 // Record new data length
                 length += nbytes;
             }
@@ -131,7 +132,7 @@
     }
 
     /**
-     * Returns the current offset in this file. 
+     * Returns the current offset in this file.
      *
      * @return     the offset from the beginning of the file, in bytes,
      *             at which the next read occurs.
@@ -141,13 +142,13 @@
     }
 
     /**
-     * Sets the file-pointer offset, measured from the beginning of this 
+     * Sets the file-pointer offset, measured from the beginning of this
      * file, at which the next read occurs.
      *
-     * @param      pos   the offset position, measured in bytes from the 
-     *                   beginning of the file, at which to set the file 
+     * @param      pos   the offset position, measured in bytes from the
+     *                   beginning of the file, at which to set the file
      *                   pointer.
-     * @exception  IOException  if <code>pos</code> is less than 
+     * @exception  IOException  if <code>pos</code> is less than
      *                          <code>0</code> or if an I/O error occurs.
      */
     public void seek(long pos) throws IOException {
@@ -173,7 +174,7 @@
         long pos = readUntil(next);
         if (pos >= next) {
             byte[] buf =
-                (byte[])data.elementAt((int)(pointer >> SECTOR_SHIFT));
+                (byte[])data.get((int)(pointer >> SECTOR_SHIFT));
             return buf[(int)(pointer++ & SECTOR_MASK)] & 0xff;
         } else {
             return -1;
@@ -244,7 +245,7 @@
             return -1;
         }
 
-        byte[] buf = (byte[])data.elementAt((int)(pointer >> SECTOR_SHIFT));
+        byte[] buf = (byte[])data.get((int)(pointer >> SECTOR_SHIFT));
         int nbytes = Math.min(len, SECTOR_SIZE - (int)(pointer & SECTOR_MASK));
         System.arraycopy(buf, (int)(pointer & SECTOR_MASK),
                          b, off, nbytes);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/PropertyUtil.java Mon Jan 15 16:59:48 2007
@@ -24,7 +24,7 @@
 import org.apache.xmlgraphics.util.i18n.LocalizableSupport;
 
 public class PropertyUtil {
-    protected final static String RESOURCES =
+    protected static final String RESOURCES =
         "org.apache.xmlgraphics.image.codec.resources.Messages";
 
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableOutputStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableOutputStream.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableOutputStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableOutputStream.java Mon Jan 15 16:59:48 2007
@@ -25,6 +25,8 @@
 
 /**
  * An <code>OutputStream</code> which can seek to an arbitrary offset.
+ *
+ * @version $Id$
  */
 public class SeekableOutputStream extends OutputStream {
 
@@ -52,11 +54,11 @@
         file.write(b);
     }
 
-    public void write(byte b[]) throws IOException {
+    public void write(byte[] b) throws IOException {
         file.write(b);
     }
 
-    public void write(byte b[], int off, int len) throws IOException {
+    public void write(byte[] b, int off, int len) throws IOException {
         file.write(b, off, len);
     }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableStream.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableStream.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SeekableStream.java Mon Jan 15 16:59:48 2007
@@ -298,12 +298,12 @@
     public final void readFully(byte[] b, int off, int len)
         throws IOException {
         int n = 0;
-	do {
-	    int count = this.read(b, off + n, len - n);
-	    if (count < 0)
-		throw new EOFException();
-	    n += count;
-	} while (n < len);
+        do {
+            int count = this.read(b, off + n, len - n);
+            if (count < 0)
+                throw new EOFException();
+            n += count;
+        } while (n < len);
     }
 
     // Methods from DataInput, plus little-endian versions
@@ -328,7 +328,7 @@
         if (n <= 0) {
             return 0;
         }
-	return (int)skip(n);
+        return (int)skip(n);
     }
 
     /**
@@ -344,10 +344,10 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final boolean readBoolean() throws IOException {
-	int ch = this.read();
-	if (ch < 0)
-	    throw new EOFException();
-	return (ch != 0);
+        int ch = this.read();
+        if (ch < 0)
+            throw new EOFException();
+        return (ch != 0);
     }
 
     /**
@@ -369,10 +369,10 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final byte readByte() throws IOException {
-	int ch = this.read();
-	if (ch < 0)
-	    throw new EOFException();
-	return (byte)(ch);
+        int ch = this.read();
+        if (ch < 0)
+            throw new EOFException();
+        return (byte)(ch);
     }
 
     /**
@@ -389,10 +389,10 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final int readUnsignedByte() throws IOException {
-	int ch = this.read();
-	if (ch < 0)
-	    throw new EOFException();
-	return ch;
+        int ch = this.read();
+        if (ch < 0)
+            throw new EOFException();
+        return ch;
     }
 
     /**
@@ -417,11 +417,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final short readShort() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (short)((ch1 << 8) + (ch2 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (short)((ch1 << 8) + (ch2 << 0));
     }
 
     /**
@@ -446,11 +446,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final short readShortLE() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (short)((ch2 << 8) + (ch1 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (short)((ch2 << 8) + (ch1 << 0));
     }
 
     /**
@@ -474,11 +474,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final int readUnsignedShort() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (ch1 << 8) + (ch2 << 0);
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (ch1 << 8) + (ch2 << 0);
     }
 
     /**
@@ -503,11 +503,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final int readUnsignedShortLE() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (ch2 << 8) + (ch1 << 0);
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (ch2 << 8) + (ch1 << 0);
     }
 
     /**
@@ -530,11 +530,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final char readChar() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (char)((ch1 << 8) + (ch2 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (char)((ch1 << 8) + (ch2 << 0));
     }
 
     /**
@@ -558,11 +558,11 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final char readCharLE() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	if ((ch1 | ch2) < 0)
-	    throw new EOFException();
-	return (char)((ch2 << 8) + (ch1 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        if ((ch1 | ch2) < 0)
+            throw new EOFException();
+        return (char)((ch2 << 8) + (ch1 << 0));
     }
 
     /**
@@ -586,13 +586,13 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final int readInt() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	int ch3 = this.read();
-	int ch4 = this.read();
-	if ((ch1 | ch2 | ch3 | ch4) < 0)
-	    throw new EOFException();
-	return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        int ch3 = this.read();
+        int ch4 = this.read();
+        if ((ch1 | ch2 | ch3 | ch4) < 0)
+            throw new EOFException();
+        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
     }
 
     /**
@@ -617,13 +617,13 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final int readIntLE() throws IOException {
-	int ch1 = this.read();
-	int ch2 = this.read();
-	int ch3 = this.read();
-	int ch4 = this.read();
-	if ((ch1 | ch2 | ch3 | ch4) < 0)
-	    throw new EOFException();
-	return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
+        int ch1 = this.read();
+        int ch2 = this.read();
+        int ch3 = this.read();
+        int ch4 = this.read();
+        if ((ch1 | ch2 | ch3 | ch4) < 0)
+            throw new EOFException();
+        return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
     }
 
     /**
@@ -647,13 +647,13 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final long readUnsignedInt() throws IOException {
-	long ch1 = this.read();
-	long ch2 = this.read();
-	long ch3 = this.read();
-	long ch4 = this.read();
-	if ((ch1 | ch2 | ch3 | ch4) < 0)
-	    throw new EOFException();
-	return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
+        long ch1 = this.read();
+        long ch2 = this.read();
+        long ch3 = this.read();
+        long ch4 = this.read();
+        if ((ch1 | ch2 | ch3 | ch4) < 0)
+            throw new EOFException();
+        return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0));
     }
 
     private byte[] ruileBuf = new byte[4];
@@ -681,12 +681,12 @@
      */
     public final long readUnsignedIntLE() throws IOException {
         this.readFully(ruileBuf);
-	long ch1 = (ruileBuf[0] & 0xff);
-	long ch2 = (ruileBuf[1] & 0xff);
-	long ch3 = (ruileBuf[2] & 0xff);
-	long ch4 = (ruileBuf[3] & 0xff);
+        long ch1 = (ruileBuf[0] & 0xff);
+        long ch2 = (ruileBuf[1] & 0xff);
+        long ch3 = (ruileBuf[2] & 0xff);
+        long ch4 = (ruileBuf[3] & 0xff);
 
-	return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
+        return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
     }
 
     /**
@@ -718,7 +718,7 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final long readLong() throws IOException {
-	return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
+        return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
     }
 
     /**
@@ -753,7 +753,7 @@
     public final long readLongLE() throws IOException {
         int i1 = readIntLE();
         int i2 = readIntLE();
-	return ((long)i2 << 32) + (i1 & 0xFFFFFFFFL);
+        return ((long)i2 << 32) + (i1 & 0xFFFFFFFFL);
     }
 
     /**
@@ -774,7 +774,7 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final float readFloat() throws IOException {
-	return Float.intBitsToFloat(readInt());
+        return Float.intBitsToFloat(readInt());
     }
 
     /**
@@ -796,7 +796,7 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final float readFloatLE() throws IOException {
-	return Float.intBitsToFloat(readIntLE());
+        return Float.intBitsToFloat(readIntLE());
     }
 
     /**
@@ -817,7 +817,7 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final double readDouble() throws IOException {
-	return Double.longBitsToDouble(readLong());
+        return Double.longBitsToDouble(readLong());
     }
 
     /**
@@ -839,7 +839,7 @@
      * @exception  IOException   if an I/O error occurs.
      */
     public final double readDoubleLE() throws IOException {
-	return Double.longBitsToDouble(readLongLE());
+        return Double.longBitsToDouble(readLongLE());
     }
 
     /**
@@ -866,33 +866,33 @@
      * @exception  IOException  if an I/O error occurs.
      */
     public final String readLine() throws IOException {
-	StringBuffer input = new StringBuffer();
-	int c = -1;
-	boolean eol = false;
-
-	while (!eol) {
-	    switch (c = read()) {
-	    case -1:
-	    case '\n':
-		eol = true;
-		break;
-	    case '\r':
-		eol = true;
-		long cur = getFilePointer();
-		if ((read()) != '\n') {
-		    seek(cur);
-		}
-		break;
-	    default:
-		input.append((char)c);
-		break;
-	    }
-	}
-
-	if ((c == -1) && (input.length() == 0)) {
-	    return null;
-	}
-	return input.toString();
+        StringBuffer input = new StringBuffer();
+        int c = -1;
+        boolean eol = false;
+
+        while (!eol) {
+            switch (c = read()) {
+            case -1:
+            case '\n':
+                eol = true;
+                break;
+            case '\r':
+                eol = true;
+                long cur = getFilePointer();
+                if ((read()) != '\n') {
+                    seek(cur);
+                }
+                break;
+            default:
+                input.append((char)c);
+                break;
+            }
+        }
+
+        if ((c == -1) && (input.length() == 0)) {
+            return null;
+        }
+        return input.toString();
     }
 
     /**
@@ -918,7 +918,7 @@
      *               valid UTF-8 encoding of a Unicode string.
      */
     public final String readUTF() throws IOException {
-	return DataInputStream.readUTF(this);
+        return DataInputStream.readUTF(this);
     }
 
     /**

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SimpleRenderedImage.java Mon Jan 15 16:59:48 2007
@@ -26,10 +26,11 @@
 import java.awt.image.RenderedImage;
 import java.awt.image.SampleModel;
 import java.awt.image.WritableRaster;
-import java.util.Enumeration;
+
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
 
 /**
  * A simple class implemented the <code>RenderedImage</code>
@@ -40,41 +41,43 @@
  * <p> Normally in JAI <code>PlanarImage</code> is used for this
  * purpose, but in the interest of modularity the
  * use of <code>PlanarImage</code> has been avoided.
+ *
+ * @version $Id$
  */
 public abstract class SimpleRenderedImage implements RenderedImage {
 
     /** The X coordinate of the image's upper-left pixel. */
     protected int minX;
-    
+
     /** The Y coordinate of the image's upper-left pixel. */
     protected int minY;
-    
+
     /** The image's width in pixels. */
     protected int width;
-    
+
     /** The image's height in pixels. */
     protected int height;
-    
+
     /** The width of a tile. */
     protected int tileWidth;
-    
+
     /** The height of a tile. */
     protected int tileHeight;
 
     /** The X coordinate of the upper-left pixel of tile (0, 0). */
     protected int tileGridXOffset = 0;
-    
+
     /** The Y coordinate of the upper-left pixel of tile (0, 0). */
     protected int tileGridYOffset = 0;
-    
+
     /** The image's SampleModel. */
     protected SampleModel sampleModel = null;
-    
+
     /** The image's ColorModel. */
     protected ColorModel colorModel = null;
-    
+
     /** The image's sources, stored in a Vector. */
-    protected Vector sources = new Vector();
+    protected List sources = new ArrayList();
 
     /** A Hashtable containing the image properties. */
     protected Hashtable properties = new Hashtable();
@@ -120,13 +123,13 @@
     public int getHeight() {
         return height;
     }
-    
+
     /** Returns a Rectangle indicating the image bounds. */
     public Rectangle getBounds() {
         return new Rectangle(getMinX(), getMinY(),
                              getWidth(), getHeight());
     }
-    
+
     /** Returns the width of a tile. */
     public int getTileWidth() {
         return tileWidth;
@@ -137,14 +140,14 @@
         return tileHeight;
     }
 
-    /** 
+    /**
      * Returns the X coordinate of the upper-left pixel of tile (0, 0).
      */
     public int getTileGridXOffset() {
         return tileGridXOffset;
     }
 
-    /** 
+    /**
      * Returns the Y coordinate of the upper-left pixel of tile (0, 0).
      */
     public int getTileGridYOffset() {
@@ -178,11 +181,11 @@
     public int getNumXTiles() {
         return getMaxTileX() - getMinTileX() + 1;
     }
-    
+
     /**
      * Returns the vertical index of the uppermost row of tiles.  getMinTileY()
      * is implemented in terms of getMinY() and so does not need to be
-     * implemented by subclasses. 
+     * implemented by subclasses.
      */
     public int getMinTileY() {
         return YToTileY(getMinY());
@@ -219,37 +222,35 @@
 
     /**
      * Gets a property from the property set of this image.  If the
-     * property name is not recognized,
-     * <code>java.awt.Image.UndefinedProperty</code> will be returned.
+     * property name is not recognized, <code>null</code> will be returned.
      *
      * @param name the name of the property to get, as a
-     * <code>String</code>.  @return a reference to the property
-     * <code>Object</code>, or the value
-     * <code>java.awt.Image.UndefinedProperty.</code>
+     * <code>String</code>.
+     * @return a reference to the property
+     * <code>Object</code>, or the value <code>null</code>
      */
     public Object getProperty(String name) {
         name = name.toLowerCase();
         return properties.get(name);
     }
-    
+
     /**
      * Returns a list of the properties recognized by this image.  If
-     * no properties are available, <code>null</code> will be
-     * returned.
+     * no properties are available, an empty String[] will be returned.
      *
      * @return an array of <code>String</code>s representing valid
      *         property names.
      */
     public String[] getPropertyNames() {
         String[] names = new String[properties.size()];
-        int index = 0;
-
-        Enumeration e = properties.keys();
-        while (e.hasMoreElements()) {
-            String name = (String)e.nextElement();
-            names[index++] = name;
-        }
-        
+//        int index = 0;
+//
+//        Enumeration e = properties.keys();
+//        while (e.hasMoreElements()) {
+//            String name = (String)e.nextElement();
+//            names[index++] = name;
+//        }
+        properties.keySet().toArray( names );
         return names;
     }
 
@@ -264,20 +265,20 @@
      * for matches.
      *
      * @return an array of <code>String</code>s giving the valid
-     * property names.
+     * property names (can be null).
      */
     public String[] getPropertyNames(String prefix) {
-        String propertyNames[] = getPropertyNames();
+        String[] propertyNames = getPropertyNames();
         if (propertyNames == null) {
             return null;
         }
 
         prefix = prefix.toLowerCase();
 
-        Vector names = new Vector();
+        List names = new ArrayList();
         for (int i = 0; i < propertyNames.length; i++) {
             if (propertyNames[i].startsWith(prefix)) {
-                names.addElement(propertyNames[i]);
+                names.add(propertyNames[i]);
             }
         }
 
@@ -286,11 +287,13 @@
         }
 
         // Copy the strings from the Vector over to a String array.
-        String prefixNames[] = new String[names.size()];
-        int count = 0;
-        for (Iterator it = names.iterator(); it.hasNext(); ) {
-            prefixNames[count++] = (String)it.next();
-        }
+        String[] prefixNames = new String[names.size()];
+
+//        int count = 0;
+//        for (Iterator it = names.iterator(); it.hasNext(); ) { // todo xx.toArray()
+//            prefixNames[count++] = (String)it.next();
+//        }
+        names.toArray( prefixNames );
 
         return prefixNames;
     }
@@ -336,7 +339,7 @@
     }
 
     /**
-     * Converts a pixel's Y coordinate into a vertical tile index. 
+     * Converts a pixel's Y coordinate into a vertical tile index.
      * This is a convenience method.  No attempt is made to detect
      * out-of-range coordinates.
      *
@@ -487,13 +490,13 @@
      *
      * @param dest a WritableRaster to hold the returned portion of
      *        the image.
-     * @return a reference to the supplied WritableRaster, or to a 
+     * @return a reference to the supplied WritableRaster, or to a
      *         new WritableRaster if the supplied one was null.
      */
     public WritableRaster copyData(WritableRaster dest) {
         Rectangle bounds;
         Raster tile;
-                    
+
         if (dest == null) {
             bounds = getBounds();
             Point p = new Point(minX, minY);
@@ -504,12 +507,12 @@
         } else {
             bounds = dest.getBounds();
         }
-        
+
         int startX = XToTileX(bounds.x);
         int startY = YToTileY(bounds.y);
         int endX = XToTileX(bounds.x + bounds.width - 1);
         int endY = YToTileY(bounds.y + bounds.height - 1);
-            
+
         for (int j = startY; j <= endY; j++) {
             for (int i = startX; i <= endX; i++) {
                 tile = getTile(i, j);

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SingleTileRenderedImage.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SingleTileRenderedImage.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SingleTileRenderedImage.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/codec/util/SingleTileRenderedImage.java Mon Jan 15 16:59:48 2007
@@ -25,6 +25,8 @@
 /**
  * A simple class that provides RenderedImage functionality
  * given a Raster and a ColorModel.
+ *
+ * @version $Id$
  */
 public class SingleTileRenderedImage extends SimpleRenderedImage {
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/AbstractRed.java Mon Jan 15 16:59:48 2007
@@ -115,7 +115,7 @@
     /**
      * Construct an Abstract RenderedImage from a source image, bounds
      * rect and props (may be null).
-     * @param src if not null, will be the first (and only) member 
+     * @param src if not null, will be the first (and only) member
      * of the srcs Vector. Also if it is not null it provides the
      * tile grid offsets, otherwise they are zero.
      * @param bounds The bounds of this image.
@@ -440,21 +440,24 @@
 
     public String [] getPropertyNames() {
         Set keys = props.keySet();
-        Iterator iter = keys.iterator();
-        String [] ret  = new String[keys.size()];
-        int i=0;
-        while (iter.hasNext()) {
-            ret[i++] = (String)iter.next();
-        }
+        String[] ret  = new String[keys.size()];
+        keys.toArray( ret );
+
+//        Iterator iter = keys.iterator();
+//        int i=0;
+//        while (iter.hasNext()) {
+//            ret[i++] = (String)iter.next();
+//        }
 
-        iter = srcs.iterator();
+        Iterator iter = srcs.iterator();
         while (iter.hasNext()) {
             RenderedImage ri = (RenderedImage)iter.next();
             String [] srcProps = ri.getPropertyNames();
             if (srcProps.length != 0) {
                 String [] tmp = new String[ret.length+srcProps.length];
-                System.arraycopy(tmp,0,tmp,0,ret.length);
-                System.arraycopy(tmp,ret.length,srcProps,0,srcProps.length);
+                System.arraycopy(ret,0,tmp,0,ret.length);
+                /// ??? System.arraycopy((tmp,ret.length,srcProps,0,srcProps.length);
+                System.arraycopy( srcProps, 0, tmp, ret.length, srcProps.length);
                 ret = tmp;
             }
         }
@@ -468,7 +471,7 @@
                 ("Nonexistant source requested.");
 
         // Return empty rect if they don't intersect.
-        if (outputRgn.intersects(bounds) == false)
+        if ( ! outputRgn.intersects(bounds) )
             return new Rectangle();
 
         // We only depend on our source for stuff that is inside
@@ -482,7 +485,7 @@
                 ("Nonexistant source requested.");
 
         // Return empty rect if they don't intersect.
-        if (inputRgn.intersects(bounds) == false)
+        if ( ! inputRgn.intersects(bounds) )
             return new Rectangle();
 
         // Changes in the input region don't propogate outside our
@@ -564,7 +567,7 @@
         if (tx1 >= minTileX+numXTiles) tx1 = minTileX+numXTiles-1;
         if (ty1 >= minTileY+numYTiles) ty1 = minTileY+numYTiles-1;
 
-        final boolean is_INT_PACK = 
+        final boolean is_INT_PACK =
             GraphicsUtil.is_INT_PACK_Data(getSampleModel(), false);
 
         for (int y=ty0; y<=ty1; y++)
@@ -594,7 +597,7 @@
         if ((tileX < minTileX) || (tileX >= minTileX+numXTiles) ||
             (tileY < minTileY) || (tileY >= minTileY+numYTiles))
             throw new IndexOutOfBoundsException
-                ("Requested Tile (" + tileX + "," + tileY +
+                ("Requested Tile (" + tileX + ',' + tileY +
                  ") lies outside the bounds of image");
 
         Point pt = new Point(tileGridXOff+tileX*tileWidth,
@@ -602,19 +605,19 @@
 
         WritableRaster wr;
         wr = Raster.createWritableRaster(sm, pt);
-        // if (!(sm instanceof SinglePixelPackedSampleModel)) 
+        // if (!(sm instanceof SinglePixelPackedSampleModel))
         //     wr = Raster.createWritableRaster(sm, pt);
         // else {
         //     SinglePixelPackedSampleModel sppsm;
         //     sppsm = (SinglePixelPackedSampleModel)sm;
         //     int stride = sppsm.getScanlineStride();
         //     int sz = stride*sppsm.getHeight();
-        // 
+        //
         //     int [] data = reclaim.request(sz);
         //     DataBuffer db = new DataBufferInt(data, sz);
-        // 
+        //
         //     reclaim.register(db);
-        // 
+        //
         //     wr = Raster.createWritableRaster(sm, db, pt);
         // }
 
@@ -640,7 +643,7 @@
         return wr;
     }
 
-    public static void copyBand(Raster         src, int srcBand, 
+    public static void copyBand(Raster         src, int srcBand,
                                 WritableRaster dst, int dstBand) {
         Rectangle srcR = new Rectangle(src.getMinX(),  src.getMinY(),
                                        src.getWidth(), src.getHeight());

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/Any2sRGBRed.java Mon Jan 15 16:59:48 2007
@@ -19,7 +19,6 @@
 
 package org.apache.xmlgraphics.image.rendered;
 
-
 import java.awt.color.ColorSpace;
 import java.awt.image.BandCombineOp;
 import java.awt.image.BufferedImage;
@@ -51,7 +50,7 @@
      * @param src The image to convert to a luminance image
      */
     public Any2sRGBRed(CachableRed src) {
-        super(src,src.getBounds(), 
+        super(src,src.getBounds(),
               fixColorModel(src),
               fixSampleModel(src),
               src.getTileGridXOffset(),
@@ -81,7 +80,7 @@
         if(masks[2] != 0x000000ff) return false;
         if ((masks.length == 4) &&
             (masks[3] != 0xff000000)) return false;
- 
+
         return true;
    }
 
@@ -96,7 +95,7 @@
      * linearToLinear table is used when the values are considered to
      * be on the sRGB scale to begin with.
      */
-    private static final int linearToSRGBLut[] = new int[256];
+    private static final int[] linearToSRGBLut = new int[256];
     static {
         final double scale = 1.0/255;
         final double exp   = 1.0/GAMMA;
@@ -107,25 +106,25 @@
                 value *= 12.92;
             else
                 value = 1.055 * Math.pow(value, exp) - 0.055;
-            
+
             linearToSRGBLut[i] = (int)Math.round(value*255.);
             // System.out.print(linearToSRGBLut[i] + ",");
         }
         // System.out.println("");
     }
-     
+
     public static WritableRaster applyLut_INT(WritableRaster wr,
                                               final int []lut) {
         SinglePixelPackedSampleModel sm =
             (SinglePixelPackedSampleModel)wr.getSampleModel();
         DataBufferInt db = (DataBufferInt)wr.getDataBuffer();
 
-        final int     srcBase 
-            = (db.getOffset() + 
-               sm.getOffset(wr.getMinX()-wr.getSampleModelTranslateX(), 
+        final int     srcBase
+            = (db.getOffset() +
+               sm.getOffset(wr.getMinX()-wr.getSampleModelTranslateX(),
                             wr.getMinY()-wr.getSampleModelTranslateY()));
         // Access the pixel data array
-        final int pixels[]   = db.getBankData()[0];
+        final int[] pixels   = db.getBankData()[0];
         final int width      = wr.getWidth();
         final int height     = wr.getHeight();
         final int scanStride = sm.getScanlineStride();
@@ -139,7 +138,7 @@
 
             while (sp<end) {
                 pix = pixels[sp];
-                pixels[sp] = 
+                pixels[sp] =
                     ((     pix      &0xFF000000)|
                      (lut[(pix>>>16)&0xFF]<<16) |
                      (lut[(pix>>> 8)&0xFF]<< 8) |
@@ -160,7 +159,7 @@
 
 
         // Fast case, Linear SRGB source, INT Pack writable raster...
-        if (srcIsLsRGB && 
+        if (srcIsLsRGB &&
             is_INT_PACK_COMP(wr.getSampleModel())) {
             src.copyData(wr);
             if (srcCM.hasAlpha())
@@ -176,17 +175,17 @@
             float [][] matrix = null;
             switch (srcSM.getNumBands()) {
             case 1:
-                matrix = new float[1][3];
+                matrix = new float[3][1];
                 matrix[0][0] = 1; // Red
-                matrix[0][1] = 1; // Grn
-                matrix[0][2] = 1; // Blu
+                matrix[1][0] = 1; // Grn
+                matrix[2][0] = 1; // Blu
                 break;
             case 2:
-                matrix = new float[2][4];
+                matrix = new float[4][2];
                 matrix[0][0] = 1; // Red
-                matrix[0][1] = 1; // Grn
-                matrix[0][2] = 1; // Blu
-                matrix[1][3] = 1; // Alpha
+                matrix[1][0] = 1; // Grn
+                matrix[3][0] = 1; // Blu
+                matrix[3][1] = 1; // Alpha
                 break;
             case 3:
                 matrix = new float[3][3];
@@ -195,7 +194,7 @@
                 matrix[2][2] = 1; // Blu
                 break;
             default:
-                matrix = new float[srcSM.getNumBands()][4];
+                matrix = new float[4][srcSM.getNumBands()];
                 matrix[0][0] = 1; // Red
                 matrix[1][1] = 1; // Grn
                 matrix[2][2] = 1; // Blu
@@ -205,53 +204,88 @@
             Raster srcRas = src.getData(wr.getBounds());
             BandCombineOp op = new BandCombineOp(matrix, null);
             op.filter(srcRas, wr);
-        } else {
-            ColorModel dstCM = getColorModel();
-            if (srcCM.getColorSpace() == dstCM.getColorSpace()) {
-                // No transform needed, just reformat data...
-                // System.out.println("Bypassing");
-
-                if (is_INT_PACK_COMP(srcSM))
-                    src.copyData(wr);
-                else
-                    GraphicsUtil.copyData(src.getData(wr.getBounds()), wr);
+            return wr;
+        }
 
-                return wr;
-            }
+        if (srcCM.getColorSpace() ==
+            ColorSpace.getInstance(ColorSpace.CS_GRAY)) {
 
+            // This is a little bit of a hack.  There is only
+            // a linear grayscale ICC profile in the JDK so
+            // many things use this when the data _really_
+            // has sRGB gamma applied.
+            try {
+            float [][] matrix = null;
+            switch (srcSM.getNumBands()) {
+            case 1:
+                matrix = new float[3][1];
+                matrix[0][0] = 1; // Red
+                matrix[1][0] = 1; // Grn
+                matrix[2][0] = 1; // Blu
+                break;
+            case 2:
+            default:
+                matrix = new float[4][2];
+                matrix[0][0] = 1; // Red
+                matrix[1][0] = 1; // Grn
+                matrix[3][0] = 1; // Blu
+                matrix[4][1] = 1; // Alpha
+                break;
+            }
             Raster srcRas = src.getData(wr.getBounds());
-            WritableRaster srcWr  = (WritableRaster)srcRas;
+            BandCombineOp op = new BandCombineOp(matrix, null);
+            op.filter(srcRas, wr);
+            } catch (Throwable t) {
+                t.printStackTrace();
+            }
+            return wr;
+        }
 
-            // Divide out alpha if we have it.  We need to do this since
-            // the color convert may not be a linear operation which may 
-            // lead to out of range values.
-            ColorModel srcBICM = srcCM;
-            if (srcCM.hasAlpha())
-                srcBICM = GraphicsUtil.coerceData(srcWr, srcCM, false);
+        ColorModel dstCM = getColorModel();
+        if (srcCM.getColorSpace() == dstCM.getColorSpace()) {
+            // No transform needed, just reformat data...
+            // System.out.println("Bypassing");
+
+            if (is_INT_PACK_COMP(srcSM))
+                src.copyData(wr);
+            else
+                GraphicsUtil.copyData(src.getData(wr.getBounds()), wr);
 
-            BufferedImage srcBI, dstBI;
-            srcBI = new BufferedImage(srcBICM, 
-                                      srcWr.createWritableTranslatedChild(0,0),
-                                      false, 
-                                      null);
-
-            // System.out.println("src: " + srcBI.getWidth() + "x" + 
-            //                    srcBI.getHeight());
-
-            ColorConvertOp op = new ColorConvertOp(dstCM.getColorSpace(), 
-                                                   null);
-            dstBI = op.filter(srcBI, null);
-
-            // System.out.println("After filter:");
-            
-            WritableRaster wr00 = wr.createWritableTranslatedChild(0,0);
-            for (int i=0; i<dstCM.getColorSpace().getNumComponents(); i++)
-                copyBand(dstBI.getRaster(), i, wr00,    i);
-
-            if (dstCM.hasAlpha())
-                copyBand(srcWr, srcSM.getNumBands()-1,
-                         wr,    getSampleModel().getNumBands()-1);
+            return wr;
         }
+
+        Raster srcRas = src.getData(wr.getBounds());
+        WritableRaster srcWr  = (WritableRaster)srcRas;
+
+        // Divide out alpha if we have it.  We need to do this since
+        // the color convert may not be a linear operation which may
+        // lead to out of range values.
+        ColorModel srcBICM = srcCM;
+        if (srcCM.hasAlpha())
+            srcBICM = GraphicsUtil.coerceData(srcWr, srcCM, false);
+
+        BufferedImage srcBI, dstBI;
+        srcBI = new BufferedImage(srcBICM,
+                                  srcWr.createWritableTranslatedChild(0,0),
+                                  false,
+                                  null);
+
+        // System.out.println("src: " + srcBI.getWidth() + "x" +
+        //                    srcBI.getHeight());
+
+        ColorConvertOp op = new ColorConvertOp(dstCM.getColorSpace(),
+                                               null);
+        dstBI = op.filter(srcBI, null);
+
+        // System.out.println("After filter:");
+
+        WritableRaster wr00 = wr.createWritableTranslatedChild(0,0);
+        for (int i=0; i<dstCM.getColorSpace().getNumComponents(); i++)
+            copyBand(dstBI.getRaster(), i, wr00,    i);
+
+        if (dstCM.hasAlpha())
+            copyBand(srcWr, srcSM.getNumBands()-1,
+                     wr,    getSampleModel().getNumBands()-1);
         return wr;
     }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/BufferedImageCachableRed.java Mon Jan 15 16:59:48 2007
@@ -19,7 +19,6 @@
 
 package org.apache.xmlgraphics.image.rendered;
 
-
 import java.awt.Rectangle;
 import java.awt.image.BufferedImage;
 import java.awt.image.Raster;
@@ -43,19 +42,19 @@
      * Construct an instance of CachableRed around a BufferedImage.
      */
     public BufferedImageCachableRed(BufferedImage bi) {
-        super((CachableRed)null, 
+        super((CachableRed)null,
               new Rectangle(bi.getMinX(),  bi.getMinY(),
                             bi.getWidth(), bi.getHeight()),
-              bi.getColorModel(), bi.getSampleModel(), 
+              bi.getColorModel(), bi.getSampleModel(),
               bi.getMinX(), bi.getMinY(), null);
 
         this.bi = bi;
     }
 
-    public BufferedImageCachableRed(BufferedImage bi, 
+    public BufferedImageCachableRed(BufferedImage bi,
                                             int xloc, int yloc) {
         super((CachableRed)null, new Rectangle(xloc,  yloc,
-                                               bi.getWidth(), 
+                                               bi.getWidth(),
                                                bi.getHeight()),
               bi.getColorModel(), bi.getSampleModel(), xloc, yloc, null);
 
@@ -96,13 +95,13 @@
     public Raster getData(Rectangle rect) {
         Rectangle r = (Rectangle)rect.clone();
 
-        if (r.intersects(getBounds()) == false)
+        if ( ! r.intersects(getBounds()) )
             return null;
         r = r.intersection(getBounds());
         r.translate(-getMinX(), - getMinY());
 
         Raster ret = bi.getData(r);
-        return ret.createTranslatedChild(ret.getMinX()+getMinX(), 
+        return ret.createTranslatedChild(ret.getMinX()+getMinX(),
                                          ret.getMinY()+getMinY());
     }
 
@@ -123,14 +122,14 @@
          */
         /*
           BufferedImage dest;
-         dest = new BufferedImage(bi.getColorModel(), 
-                                  wr.createWritableTranslatedChild(0,0), 
-                                  bi.getColorModel().isAlphaPremultiplied(), 
+         dest = new BufferedImage(bi.getColorModel(),
+                                  wr.createWritableTranslatedChild(0,0),
+                                  bi.getColorModel().isAlphaPremultiplied(),
                                   null);
          java.awt.Graphics2D g2d = dest.createGraphics();
-         g2d.drawImage(bi, null, getMinX()-wr.getMinX(), 
+         g2d.drawImage(bi, null, getMinX()-wr.getMinX(),
                        getMinY()-wr.getMinY());
-         g2d.dispose(); 
+         g2d.dispose();
          */
         return wr;
     }

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/CachableRed.java Mon Jan 15 16:59:48 2007
@@ -36,7 +36,7 @@
      * Returns the bounds of the current image.
      * This should be 'in sync' with getMinX, getMinY, getWidth, getHeight
      */
-    public Rectangle getBounds();
+    Rectangle getBounds();
 
     /**
      * Returns the region of input data is is required to generate
@@ -48,7 +48,7 @@
      * @return The region of input required.  This is in the output pixel
      * coordinate system for the source indicated by srcIndex.
      */
-    public Shape getDependencyRegion(int srcIndex, Rectangle outputRgn);
+    Shape getDependencyRegion(int srcIndex, Rectangle outputRgn);
 
     /**
      * This calculates the region of output that is affected by a change
@@ -61,6 +61,6 @@
      *  a change to inputRgn of the source selected by srcIndex.
      *  this is in the output pixel coordinate system of this node.
      */
-    public Shape getDirtyRegion(int srcIndex, Rectangle inputRgn);
+    Shape getDirtyRegion(int srcIndex, Rectangle inputRgn);
 }
 

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/FormatRed.java Mon Jan 15 16:59:48 2007
@@ -42,7 +42,8 @@
  * alpha=1.  In all other cases bands are simply copied.
  *
  * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id$ */
+ * @version $Id$
+ */
 public class FormatRed extends AbstractRed {
 
     public static CachableRed construct(CachableRed src, ColorModel cm) {
@@ -50,39 +51,39 @@
         if ((cm.hasAlpha() != srcCM.hasAlpha()) ||
             (cm.isAlphaPremultiplied() != srcCM.isAlphaPremultiplied()))
             return new FormatRed(src, cm);
-            
+
         if (cm.getNumComponents() != srcCM.getNumComponents())
             throw new IllegalArgumentException
                 ("Incompatible ColorModel given");
-                
+
 
         if ((srcCM instanceof ComponentColorModel) &&
-            (cm    instanceof ComponentColorModel)) 
+            (cm    instanceof ComponentColorModel))
             return src;
 
         if ((srcCM instanceof DirectColorModel) &&
-            (cm    instanceof DirectColorModel)) 
+            (cm    instanceof DirectColorModel))
             return src;
 
         return new FormatRed(src, cm);
     }
-    
+
     /**
      * Construct an instance of CachableRed around a BufferedImage.
      */
     public FormatRed(CachableRed cr, SampleModel sm) {
         super(cr, cr.getBounds(),
-              makeColorModel(cr, sm), sm, 
-              cr.getTileGridXOffset(), 
-              cr.getTileGridYOffset(), 
+              makeColorModel(cr, sm), sm,
+              cr.getTileGridXOffset(),
+              cr.getTileGridYOffset(),
               null);
     }
 
     public FormatRed(CachableRed cr, ColorModel cm) {
         super(cr, cr.getBounds(),
-              cm, makeSampleModel(cr, cm), 
-              cr.getTileGridXOffset(), 
-              cr.getTileGridYOffset(), 
+              cm, makeSampleModel(cr, cm),
+              cr.getTileGridXOffset(),
+              cr.getTileGridYOffset(),
               null);
     }
 
@@ -106,18 +107,18 @@
         CachableRed cr    = getSource();
         ColorModel  srcCM = cr.getColorModel();
         SampleModel srcSM = cr.getSampleModel();
-        srcSM = srcSM.createCompatibleSampleModel(wr.getWidth(), 
+        srcSM = srcSM.createCompatibleSampleModel(wr.getWidth(),
                                                   wr.getHeight());
         WritableRaster srcWR;
         srcWR = Raster.createWritableRaster(srcSM, new Point(wr.getMinX(),
                                                              wr.getMinY()));
         getSource().copyData(srcWR);
-        
+
         BufferedImage srcBI = new BufferedImage
-            (srcCM, srcWR.createWritableTranslatedChild(0,0), 
+            (srcCM, srcWR.createWritableTranslatedChild(0,0),
              srcCM.isAlphaPremultiplied(), null);
         BufferedImage dstBI = new BufferedImage
-            (cm, wr.createWritableTranslatedChild(0,0), 
+            (cm, wr.createWritableTranslatedChild(0,0),
              cm.isAlphaPremultiplied(), null);
 
         GraphicsUtil.copyData(srcBI, dstBI);
@@ -154,7 +155,7 @@
             // if Src has Alpha then our out bands must
             // either be one less than the source (no out alpha)
             // or equal (still has alpha)
-            if (bands == srcCM.getNumComponents()-1) 
+            if (bands == srcCM.getNumComponents()-1)
                 hasAlpha = false;
             else if (bands != srcCM.getNumComponents())
                 throw new IllegalArgumentException
@@ -183,7 +184,7 @@
         } else if (sm instanceof SinglePixelPackedSampleModel) {
             SinglePixelPackedSampleModel sppsm;
             sppsm = (SinglePixelPackedSampleModel)sm;
-            int masks [] = sppsm.getBitMasks();
+            int[] masks  = sppsm.getBitMasks();
             if (bands == 4)
                 return new DirectColorModel
                     (cs, bits, masks[0], masks[1], masks[2], masks[3],

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/rendered/RenderedImageCachableRed.java Mon Jan 15 16:59:48 2007
@@ -35,7 +35,8 @@
  * It essentially ignores the dependency and dirty region methods.
  *
  * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
- * @version $Id$ */
+ * @version $Id$
+ */
 public class RenderedImageCachableRed implements CachableRed {
 
     private RenderedImage src;
@@ -52,8 +53,8 @@
         return srcs; // should always be empty...
     }
 
-    public Rectangle getBounds() {
-        return new Rectangle(getMinX(),
+    public Rectangle getBounds() { 
+        return new Rectangle(getMinX(),    // could we cache the rectangle??
                              getMinY(),
                              getWidth(),
                              getHeight());

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=496556&r1=496555&r2=496556
==============================================================================
--- 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 Jan 15 16:59:48 2007
@@ -1,71 +1,71 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer;
-
-import java.awt.image.RenderedImage;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Interface which allows image library independent image writing. 
- *
- * @version $Id$
- */
-public interface ImageWriter {
-    
-    /**
-     * Encodes an image and writes it to an OutputStream.
-     * @param image the image to be encoded
-     * @param out the OutputStream to write to
-     * @throws IOException In case of an /IO problem
-     */
-    public void writeImage(RenderedImage image, OutputStream out) 
-            throws IOException;
-
-    /**
-     * Encodes an image and writes it to an OutputStream.
-     * @param image the image to be encoded
-     * @param out the OutputStream to write to
-     * @param params a parameters object to customize the encoding.
-     * @throws IOException In case of an /IO problem
-     */
-    public void writeImage(RenderedImage image, OutputStream out, 
-            ImageWriterParams params) 
-            throws IOException;
-
-    /** @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();
-    
-    /**
-     * Creates a MultiImageWriter instance that lets you put multiple pages into a single file
-     * if the format supports it.
-     * @param out the OutputStream to write the image to
-     * @return the requested MultiImageWriter instance
-     * @throws IOException In case of an /IO problem
-     */
-    public MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException;
-    
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer;
+
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * Interface which allows image library independent image writing.
+ *
+ * @version $Id$
+ */
+public interface ImageWriter {
+
+    /**
+     * Encodes an image and writes it to an OutputStream.
+     * @param image the image to be encoded
+     * @param out the OutputStream to write to
+     * @throws IOException In case of an /IO problem
+     */
+    public void writeImage(RenderedImage image, OutputStream out)
+            throws IOException;
+
+    /**
+     * Encodes an image and writes it to an OutputStream.
+     * @param image the image to be encoded
+     * @param out the OutputStream to write to
+     * @param params a parameters object to customize the encoding.
+     * @throws IOException In case of an /IO problem
+     */
+    public void writeImage(RenderedImage image, OutputStream out,
+            ImageWriterParams params)
+            throws IOException;
+
+    /** @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();
+
+    /**
+     * Creates a MultiImageWriter instance that lets you put multiple pages into a single file
+     * if the format supports it.
+     * @param out the OutputStream to write the image to
+     * @return the requested MultiImageWriter instance
+     * @throws IOException In case of an /IO problem
+     */
+    public MultiImageWriter createMultiImageWriter(OutputStream out) throws IOException;
+
+}

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriter.java
            ('svn:executable' removed)

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java?view=diff&rev=496556&r1=496555&r2=496556
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java Mon Jan 15 16:59:48 2007
@@ -1,95 +1,95 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer;
-
-/**
- * Parameters for the encoder which is accessed through the
- * ImageWriter interface.
- *
- * @version $Id$
- */
-public class ImageWriterParams {
-    
-    private Integer resolution;
-    private Float jpegQuality;
-    private Boolean jpegForceBaseline;
-    private String compressionMethod;
-    
-    /**
-     * Default constructor.
-     */
-    public ImageWriterParams() {
-        //nop
-    }
-
-    /**
-     * @return the image resolution in dpi, or null if undefined
-     */
-    public Integer getResolution() {
-        return this.resolution;
-    }
-    
-    /**
-     * @return the quality value for encoding a JPEG image 
-     *          (0.0-1.0), or null if undefined
-     */
-    public Float getJPEGQuality() {
-        return this.jpegQuality;
-    }
-    
-    /**
-     * @return true if the baseline quantization table is forced, 
-     *          or null if undefined.
-     */
-    public Boolean getJPEGForceBaseline() {
-        return this.jpegForceBaseline;
-    }
-    
-    /** @return the compression method for encoding the image */
-    public String getCompressionMethod() {
-        return this.compressionMethod;
-    }
-    
-    /**
-     * Sets the target resolution of the bitmap image to be written.
-     * @param dpi the resolution in dpi
-     */
-    public void setResolution(int dpi) {
-        this.resolution = new Integer(dpi);
-    }
-    
-    /**
-     * Sets the quality setting for encoding JPEG images.
-     * @param quality the quality setting (0.0-1.0)
-     * @param forceBaseline force baseline quantization table
-     */
-    public void setJPEGQuality(float quality, boolean forceBaseline) {
-        this.jpegQuality = new Float(quality);
-        this.jpegForceBaseline = forceBaseline ? Boolean.TRUE : Boolean.FALSE;
-    }
-    
-    /**
-     * Set the compression method that shall be used to encode the image.
-     * @param method the compression method
-     */
-    public void setCompressionMethod(String method) {
-        this.compressionMethod = method;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer;
+
+/**
+ * Parameters for the encoder which is accessed through the
+ * ImageWriter interface.
+ *
+ * @version $Id$
+ */
+public class ImageWriterParams {
+
+    private Integer resolution;
+    private Float jpegQuality;
+    private Boolean jpegForceBaseline;
+    private String compressionMethod;
+
+    /**
+     * Default constructor.
+     */
+    public ImageWriterParams() {
+        //nop
+    }
+
+    /**
+     * @return the image resolution in dpi, or null if undefined
+     */
+    public Integer getResolution() {
+        return this.resolution;
+    }
+
+    /**
+     * @return the quality value for encoding a JPEG image
+     *          (0.0-1.0), or null if undefined
+     */
+    public Float getJPEGQuality() {
+        return this.jpegQuality;
+    }
+
+    /**
+     * @return true if the baseline quantization table is forced,
+     *          or null if undefined.
+     */
+    public Boolean getJPEGForceBaseline() {
+        return this.jpegForceBaseline;
+    }
+
+    /** @return the compression method for encoding the image */
+    public String getCompressionMethod() {
+        return this.compressionMethod;
+    }
+
+    /**
+     * Sets the target resolution of the bitmap image to be written.
+     * @param dpi the resolution in dpi
+     */
+    public void setResolution(int dpi) {
+        this.resolution = new Integer(dpi);
+    }
+
+    /**
+     * Sets the quality setting for encoding JPEG images.
+     * @param quality the quality setting (0.0-1.0)
+     * @param forceBaseline force baseline quantization table
+     */
+    public void setJPEGQuality(float quality, boolean forceBaseline) {
+        this.jpegQuality = new Float(quality);
+        this.jpegForceBaseline = forceBaseline ? Boolean.TRUE : Boolean.FALSE;
+    }
+
+    /**
+     * Set the compression method that shall be used to encode the image.
+     * @param method the compression method
+     */
+    public void setCompressionMethod(String method) {
+        this.compressionMethod = method;
+    }
+}

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterParams.java
            ('svn:executable' removed)

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=496556&r1=496555&r2=496556
==============================================================================
--- 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 Jan 15 16:59:48 2007
@@ -1,157 +1,157 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- * 
- *      http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.xmlgraphics.image.writer;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Properties;
-
-import org.apache.xmlgraphics.util.Service;
-
-/**
- * Registry for ImageWriter implementations. They are primarily registered through the "Service
- * Provider" mechanism.
- * @see org.apache.xmlgraphics.util.Service
- */
-public class ImageWriterRegistry {
-
-    private static ImageWriterRegistry instance;
-    
-    private Map imageWriterMap = new HashMap();
-    private Map preferredOrder;
-    
-    /**
-     * Default constructor. The default preferred order for the image writers is loaded from the 
-     * resources.
-     */
-    public ImageWriterRegistry() {
-        Properties props = new Properties();
-        InputStream in = getClass().getResourceAsStream("default-preferred-order.properties");
-        if (in != null) {
-            try {
-                try {
-                    props.load(in);
-                } finally {
-                    in.close();
-                }
-            } catch (IOException ioe) {
-                throw new RuntimeException(
-                        "Could not load default preferred order due to I/O error: " 
-                            + ioe.getMessage());
-            }
-        }
-        this.preferredOrder = props;
-        setup();
-    }
-    
-    /**
-     * Special constructor. The preferred order for the image writers can be specified as a 
-     * Map (for example a Properties file). The entries of the Map consists of fully qualified
-     * class or package names as keys and integer numbers as values. Zero (0) is the default
-     * priority.   
-     */
-    public ImageWriterRegistry(Properties preferredOrder) {
-        this.preferredOrder = preferredOrder;
-        setup();
-    }
-    
-    /** @return a singleton instance of the ImageWriterRegistry. */
-    public static ImageWriterRegistry getInstance() {
-        if (instance == null) {
-            instance = new ImageWriterRegistry();
-        }
-        return instance;
-    }
-    
-    private void setup() {
-        Iterator iter = Service.providers(ImageWriter.class);
-        while (iter.hasNext()) {
-            ImageWriter writer = (ImageWriter)iter.next();
-            register(writer);
-        }
-    }
-
-    private int getPriority(ImageWriter writer) {
-        String key = writer.getClass().getName();
-        Object value = preferredOrder.get(key);
-        while (value == null) {
-            int pos = key.lastIndexOf(".");
-            if (pos < 0) {
-                break;
-            }
-            key = key.substring(0, pos);
-            value = preferredOrder.get(key);
-        }
-        return (value != null) ? Integer.parseInt(value.toString()) : 0;
-    }
-    
-    /**
-     * Registers a new ImageWriter implementation in the registry. If an ImageWriter for the same
-     * target MIME type has already been registered, it is overwritten with the new one.
-     * @param writer the ImageWriter instance to register.
-     */
-    public void register(ImageWriter writer) {
-        List entries = (List)imageWriterMap.get(writer.getMIMEType());
-        if (entries == null) {
-            entries = new java.util.ArrayList();
-            imageWriterMap.put(writer.getMIMEType(), entries);
-        }
-        
-        int priority = getPriority(writer);
-        ListIterator li;
-        li = entries.listIterator();
-        while (li.hasNext()) {
-            ImageWriter w = (ImageWriter)li.next();
-            if (getPriority(w) < priority) {
-                li.previous();
-                li.add(writer);
-                return;
-            }
-        }
-        li.add(writer);
-    }
-    
-    /**
-     * Returns an ImageWriter that can be used to encode an image to the requested MIME type.
-     * @param mime the MIME type of the desired output format
-     * @return an ImageWriter instance handling the desired output format or null if none can be
-     *         found.
-     */
-    public ImageWriter getWriterFor(String mime) {
-        List entries = (List)imageWriterMap.get(mime);
-        if (entries == null) {
-            return null;
-        }
-        Iterator iter = entries.iterator();
-        while (iter.hasNext()) {
-            ImageWriter writer = (ImageWriter)iter.next();
-            if (writer.isFunctional()) {
-                return writer;
-            }
-        }
-        return null;
-    }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.xmlgraphics.image.writer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Properties;
+
+import org.apache.xmlgraphics.util.Service;
+
+/**
+ * Registry for ImageWriter implementations. They are primarily registered through the "Service
+ * Provider" mechanism.
+ * @see org.apache.xmlgraphics.util.Service
+ */
+public class ImageWriterRegistry {
+
+    private static ImageWriterRegistry instance;
+
+    private Map imageWriterMap = new HashMap();
+    private Map preferredOrder;
+
+    /**
+     * Default constructor. The default preferred order for the image writers is loaded from the
+     * resources.
+     */
+    public ImageWriterRegistry() {
+        Properties props = new Properties();
+        InputStream in = getClass().getResourceAsStream("default-preferred-order.properties");
+        if (in != null) {
+            try {
+                try {
+                    props.load(in);
+                } finally {
+                    in.close();
+                }
+            } catch (IOException ioe) {
+                throw new RuntimeException(
+                        "Could not load default preferred order due to I/O error: "
+                            + ioe.getMessage());
+            }
+        }
+        this.preferredOrder = props;
+        setup();
+    }
+
+    /**
+     * Special constructor. The preferred order for the image writers can be specified as a
+     * Map (for example a Properties file). The entries of the Map consists of fully qualified
+     * class or package names as keys and integer numbers as values. Zero (0) is the default
+     * priority.
+     */
+    public ImageWriterRegistry(Properties preferredOrder) {
+        this.preferredOrder = preferredOrder;
+        setup();
+    }
+
+    /** @return a singleton instance of the ImageWriterRegistry. */
+    public static ImageWriterRegistry getInstance() {
+        if (instance == null) {
+            instance = new ImageWriterRegistry();
+        }
+        return instance;
+    }
+
+    private void setup() {
+        Iterator iter = Service.providers(ImageWriter.class);
+        while (iter.hasNext()) {
+            ImageWriter writer = (ImageWriter)iter.next();
+            register(writer);
+        }
+    }
+
+    private int getPriority(ImageWriter writer) {
+        String key = writer.getClass().getName();
+        Object value = preferredOrder.get(key);
+        while (value == null) {
+            int pos = key.lastIndexOf(".");
+            if (pos < 0) {
+                break;
+            }
+            key = key.substring(0, pos);
+            value = preferredOrder.get(key);
+        }
+        return (value != null) ? Integer.parseInt(value.toString()) : 0;
+    }
+
+    /**
+     * Registers a new ImageWriter implementation in the registry. If an ImageWriter for the same
+     * target MIME type has already been registered, it is overwritten with the new one.
+     * @param writer the ImageWriter instance to register.
+     */
+    public void register(ImageWriter writer) {
+        List entries = (List)imageWriterMap.get(writer.getMIMEType());
+        if (entries == null) {
+            entries = new java.util.ArrayList();
+            imageWriterMap.put(writer.getMIMEType(), entries);
+        }
+
+        int priority = getPriority(writer);
+        ListIterator li;
+        li = entries.listIterator();
+        while (li.hasNext()) {
+            ImageWriter w = (ImageWriter)li.next();
+            if (getPriority(w) < priority) {
+                li.previous();
+                li.add(writer);
+                return;
+            }
+        }
+        li.add(writer);
+    }
+
+    /**
+     * Returns an ImageWriter that can be used to encode an image to the requested MIME type.
+     * @param mime the MIME type of the desired output format
+     * @return an ImageWriter instance handling the desired output format or null if none can be
+     *         found.
+     */
+    public ImageWriter getWriterFor(String mime) {
+        List entries = (List)imageWriterMap.get(mime);
+        if (entries == null) {
+            return null;
+        }
+        Iterator iter = entries.iterator();
+        while (iter.hasNext()) {
+            ImageWriter writer = (ImageWriter)iter.next();
+            if (writer.isFunctional()) {
+                return writer;
+            }
+        }
+        return null;
+    }
+
+}

Propchange: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/image/writer/ImageWriterRegistry.java
            ('svn:executable' removed)



---------------------------------------------------------------------
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