You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flex.apache.org by cf...@apache.org on 2012/10/25 21:01:49 UTC

svn commit: r1402274 [20/31] - in /incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext: ./ awt/ awt/color/ awt/font/ awt/g2d/ awt/geom/ awt/image/ awt/image/codec/ awt/image/codec/jpeg/ awt/image/codec/p...

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableStream.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableStream.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableStream.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableStream.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,933 @@
+/*
+
+   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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.codec.util;
+
+import java.io.DataInput;
+import java.io.DataInputStream;
+import java.io.EOFException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UTFDataFormatException;
+
+/**
+ * An abstract subclass of <code>java.io.InputStream</code> that allows seeking
+ * within the input, similar to the <code>RandomAccessFile</code> class.
+ * Additionally, the <code>DataInput</code> interface is supported and extended
+ * to include support for little-endian representations of fundamental data
+ * types.
+ *
+ * <p> In addition to the familiar methods from <code>InputStream</code>, the
+ * methods <code>getFilePointer()</code>, <code>seek()</code>, are defined as in
+ * the <code>RandomAccessFile</code> class.  The <code>canSeekBackwards()</code>
+ * method will return <code>true</code> if it is permissible to seek to a
+ * position earlier in the stream than the current value of
+ * <code>getFilePointer()</code>.  Some subclasses of
+ * <code>SeekableStream</code> guarantee the ability to seek backwards while
+ * others may not offer this feature in the interest of providing greater
+ * efficiency for those users who do not require it.
+ *
+ * <p> The <code>DataInput</code> interface is supported as well.  This included
+ * the <code>skipBytes()</code> and <code>readFully()</code> methods and a
+ * variety of <code>read</code> methods for various data types.
+ *
+ * <p> A number of concrete subclasses of <code>SeekableStream</code> are
+ * supplied in the <code>com.sun.media.jai.codec</code> package.
+ *
+ * <p> Three classes are provided for the purpose of adapting a standard
+ * <code>InputStream</code> to the <code>SeekableStream</code> interface.
+ * <code>ForwardSeekableStream</code> does not allows seeking backwards, but is
+ * inexpensive to use.  <code>FileCacheSeekableStream</code> maintains a copy of
+ * all of the data read from the input in a temporary file; this file will be
+ * discarded automatically when the <code>FileSeekableStream</code> is
+ * finalized, or when the JVM exits normally.
+ * <code>FileCacheSeekableStream</code> is intended to be reasonably efficient
+ * apart from the unavoidable use of disk space.  In circumstances where the
+ * creation of a temporary file is not possible,
+ * <code>MemoryCacheSeekableStream</code> may be used.
+ * <code>MemoryCacheSeekableStream</code> creates a potentially large in-memory
+ * buffer to store the stream data and so should be avoided when possible.
+ *
+ * <p> The <code>FileSeekableStream</code> class wraps a <code>File</code> or
+ * <code>RandomAccessFile</code>. It forwards requests to the real underlying
+ * file.  It performs a limited amount of caching in order to avoid excessive
+ * I/O costs.
+ *
+ * <p> The <code>SegmentedSeekableStream</code> class performs a different sort
+ * of function.  It creates a <code>SeekableStream</code> from another
+ * <code>SeekableStream</code> by selecting a series of portions or "segments".
+ * Each segment starts at a specified location within the source
+ * <code>SeekableStream</code> and extends for a specified number of bytes.  The
+ * <code>StreamSegmentMapper</code> interface and <code>StreamSegment</code>
+ * class may be used to compute the segment positions dynamically.
+ *
+ * <p> A convenience methods, <code>wrapInputStream</code> is provided to
+ * construct a suitable <code>SeekableStream</code> instance whose data is
+ * supplied by a given <code>InputStream</code>.  The caller, by means of the
+ * <code>canSeekBackwards</code> parameter, determines whether support for
+ * seeking backwards is required.
+ *
+ * @version $Id: SeekableStream.java 522271 2007-03-25 14:42:45Z dvholten $
+ */
+public abstract class SeekableStream extends InputStream implements DataInput {
+
+    /**
+     * Returns a <code>SeekableStream</code> that will read from a
+     * given <code>InputStream</code>, optionally including support
+     * for seeking backwards.  This is a convenience method that
+     * avoids the need to instantiate specific subclasses of
+     * <code>SeekableStream</code> depending on the current security
+     * model.
+     *
+     * @param is An <code>InputStream</code>.
+     * @param canSeekBackwards <code>true</code> if the ability to seek
+     *        backwards in the output is required.
+     * @return An instance of <code>SeekableStream</code>.
+     */
+    public static SeekableStream wrapInputStream(InputStream is,
+                                                 boolean canSeekBackwards) {
+        SeekableStream stream = null;
+
+        if (canSeekBackwards) {
+            try {
+                stream = new FileCacheSeekableStream(is);
+            } catch (Exception e) {
+                stream = new MemoryCacheSeekableStream(is);
+            }
+        } else {
+            stream = new ForwardSeekableStream(is);
+        }
+        return stream;
+    }
+
+    // Methods from InputStream
+
+    /**
+     * Reads the next byte of data from the input stream. The value byte is
+     * returned as an <code>int</code> in the range <code>0</code> to
+     * <code>255</code>. If no byte is available because the end of the stream
+     * has been reached, the value <code>-1</code> is returned. This method
+     * blocks until input data is available, the end of the stream is detected,
+     * or an exception is thrown.
+     *
+     * <p> A subclass must provide an implementation of this method.
+     *
+     * @return     the next byte of data, or <code>-1</code> if the end of the
+     *             stream is reached.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    public abstract int read() throws IOException;
+
+    /**
+     * Reads up to <code>len</code> bytes of data from the input stream into
+     * an array of bytes.  An attempt is made to read as many as
+     * <code>len</code> bytes, but a smaller number may be read, possibly
+     * zero. The number of bytes actually read is returned as an integer.
+     *
+     * <p> This method blocks until input data is available, end of stream is
+     * detected, or an exception is thrown.
+     *
+     * <p> If <code>b</code> is <code>null</code>, a
+     * <code>NullPointerException</code> is thrown.
+     *
+     * <p> If <code>off</code> is negative, or <code>len</code> is negative, or
+     * <code>off+len</code> is greater than the length of the array
+     * <code>b</code>, then an <code>IndexOutOfBoundsException</code> is
+     * thrown.
+     *
+     * <p> If <code>len</code> is zero, then no bytes are read and
+     * <code>0</code> is returned; otherwise, there is an attempt to read at
+     * least one byte. If no byte is available because the stream is at end of
+     * stream, the value <code>-1</code> is returned; otherwise, at least one
+     * byte is read and stored into <code>b</code>.
+     *
+     * <p> The first byte read is stored into element <code>b[off]</code>, the
+     * next one into <code>b[off+1]</code>, and so on. The number of bytes read
+     * is, at most, equal to <code>len</code>. Let <i>k</i> be the number of
+     * bytes actually read; these bytes will be stored in elements
+     * <code>b[off]</code> through <code>b[off+</code><i>k</i><code>-1]</code>,
+     * leaving elements <code>b[off+</code><i>k</i><code>]</code> through
+     * <code>b[off+len-1]</code> unaffected.
+     *
+     * <p> In every case, elements <code>b[0]</code> through
+     * <code>b[off]</code> and elements <code>b[off+len]</code> through
+     * <code>b[b.length-1]</code> are unaffected.
+     *
+     * <p> If the first byte cannot be read for any reason other than end of
+     * stream, then an <code>IOException</code> is thrown. In particular, an
+     * <code>IOException</code> is thrown if the input stream has been closed.
+     *
+     * <p> A subclass must provide an implementation of this method.
+     *
+     * @param      b     the buffer into which the data is read.
+     * @param      off   the start offset in array <code>b</code>
+     *                   at which the data is written.
+     * @param      len   the maximum number of bytes to read.
+     * @return     the total number of bytes read into the buffer, or
+     *             <code>-1</code> if there is no more data because the end of
+     *             the stream has been reached.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    public abstract int read(byte[] b, int off, int len) throws IOException;
+
+    // Implemented in InputStream:
+    //
+    // public int read(byte[] b) throws IOException {
+    // public long skip(long n) throws IOException
+    // public int available) throws IOException
+    // public void close() throws IOException;
+
+    /** Marked position, shared by {@link ForwardSeekableStream} */
+    protected long markPos = -1L;
+
+    /**
+     * Marks the current file position for later return using
+     * the <code>reset()</code> method.
+     */
+    public synchronized void mark(int readLimit) {
+        try {
+            markPos = getFilePointer();
+        } catch (IOException e) {
+            markPos = -1L;
+        }
+    }
+
+    /**
+     * Returns the file position to its position at the time of
+     * the immediately previous call to the <code>mark()</code>
+     * method.
+     */
+    public synchronized void reset() throws IOException {
+        if (markPos != -1) {
+            seek(markPos);
+        }
+    }
+
+    /**
+     * Returns <code>true</code> if marking is supported.
+     * Marking is automatically supported for <code>SeekableStream</code>
+     * subclasses that support seeking backeards.  Subclasses that do
+     * not support seeking backwards but do support marking must override
+     * this method.
+     */
+    public boolean markSupported() {
+        return canSeekBackwards();
+    }
+
+    /**
+     * Returns <code>true</code> if this object supports calls to
+     * <code>seek(pos)</code> with an offset <code>pos</code> smaller
+     * than the current offset, as returned by <code>getFilePointer</code>.
+     */
+    public boolean canSeekBackwards() {
+        return false;
+    }
+
+    /**
+     * Returns the current offset in this stream.
+     *
+     * @return     the offset from the beginning of the stream, in bytes,
+     *             at which the next read occurs.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    public abstract long getFilePointer() throws IOException;
+
+    /**
+     * Sets the offset, measured from the beginning of this
+     * stream, at which the next read occurs.
+     *
+     * <p> If <code>canSeekBackwards()</code> returns <code>false</code>,
+     * then setting <code>pos</code> to an offset smaller than
+     * the current value of <code>getFilePointer()</code> will have
+     * no effect.
+     *
+     * @param      pos   the offset position, measured in bytes from the
+     *                   beginning of the stream, at which to set the stream
+     *                   pointer.
+     * @exception  IOException  if <code>pos</code> is less than
+     *                          <code>0</code> or if an I/O error occurs.
+     */
+    public abstract void seek(long pos) throws IOException;
+
+    // Methods from RandomAccessFile
+
+    /**
+     * Reads <code>b.length</code> bytes from this stream into the byte
+     * array, starting at the current stream pointer. This method reads
+     * repeatedly from the stream until the requested number of bytes are
+     * read. This method blocks until the requested number of bytes are
+     * read, the end of the stream is detected, or an exception is thrown.
+     *
+     * @param      b   the buffer into which the data is read.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               all the bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final void readFully(byte[] b) throws IOException {
+        readFully(b, 0, b.length);
+    }
+
+    /**
+     * Reads exactly <code>len</code> bytes from this stream into the byte
+     * array, starting at the current stream pointer. This method reads
+     * repeatedly from the stream until the requested number of bytes are
+     * read. This method blocks until the requested number of bytes are
+     * read, the end of the stream is detected, or an exception is thrown.
+     *
+     * @param      b     the buffer into which the data is read.
+     * @param      off   the start offset of the data.
+     * @param      len   the number of bytes to read.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               all the bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    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);
+    }
+
+    // Methods from DataInput, plus little-endian versions
+
+    /**
+     * Attempts to skip over <code>n</code> bytes of input discarding the
+     * skipped bytes.
+     * <p>
+     *
+     * This method may skip over some smaller number of bytes, possibly zero.
+     * This may result from any of a number of conditions; reaching end of
+     * stream before <code>n</code> bytes have been skipped is only one
+     * possibility. This method never throws an <code>EOFException</code>.
+     * The actual number of bytes skipped is returned.  If <code>n</code>
+     * is negative, no bytes are skipped.
+     *
+     * @param      n   the number of bytes to be skipped.
+     * @return     the actual number of bytes skipped.
+     * @exception  IOException  if an I/O error occurs.
+     */
+    public int skipBytes(int n) throws IOException {
+        if (n <= 0) {
+            return 0;
+        }
+        return (int)skip(n);
+    }
+
+    /**
+     * Reads a <code>boolean</code> from this stream. This method reads a
+     * single byte from the stream, starting at the current stream pointer.
+     * A value of <code>0</code> represents
+     * <code>false</code>. Any other value represents <code>true</code>.
+     * This method blocks until the byte is read, the end of the stream
+     * is detected, or an exception is thrown.
+     *
+     * @return     the <code>boolean</code> value read.
+     * @exception  EOFException  if this stream has reached the end.
+     * @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);
+    }
+
+    /**
+     * Reads a signed eight-bit value from this stream. This method reads a
+     * byte from the stream, starting from the current stream pointer.
+     * If the byte read is <code>b</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is:
+     * <blockquote><pre>
+     *     (byte)(b)
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the byte is read, the end of the stream
+     * is detected, or an exception is thrown.
+     *
+     * @return     the next byte of this stream as a signed eight-bit
+     *             <code>byte</code>.
+     * @exception  EOFException  if this stream has reached the end.
+     * @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);
+    }
+
+    /**
+     * Reads an unsigned eight-bit number from this stream. This method reads
+     * a byte from this stream, starting at the current stream pointer,
+     * and returns that byte.
+     * <p>
+     * This method blocks until the byte is read, the end of the stream
+     * is detected, or an exception is thrown.
+     *
+     * @return     the next byte of this stream, interpreted as an unsigned
+     *             eight-bit number.
+     * @exception  EOFException  if this stream has reached the end.
+     * @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;
+    }
+
+    /**
+     * Reads a signed 16-bit number from this stream.
+     * The method reads two
+     * bytes from this stream, starting at the current stream pointer.
+     * If the two bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where each of the two values is
+     * between <code>0</code> and <code>255</code>, inclusive, then the
+     * result is equal to:
+     * <blockquote><pre>
+     *     (short)((b1 &lt;&lt; 8) | b2)
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream, interpreted as a signed
+     *             16-bit number.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               two bytes.
+     * @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));
+    }
+
+    /**
+     * Reads a signed 16-bit number from this stream in little-endian order.
+     * The method reads two
+     * bytes from this stream, starting at the current stream pointer.
+     * If the two bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where each of the two values is
+     * between <code>0</code> and <code>255</code>, inclusive, then the
+     * result is equal to:
+     * <blockquote><pre>
+     *     (short)((b2 &lt;&lt; 8) | b1)
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream, interpreted as a signed
+     *             16-bit number.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               two bytes.
+     * @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));
+    }
+
+    /**
+     * Reads an unsigned 16-bit number from this stream. This method reads
+     * two bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b1 &lt;&lt; 8) | b2
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream, interpreted as an
+     *             unsigned 16-bit integer.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *             two bytes.
+     * @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);
+    }
+
+    /**
+     * Reads an unsigned 16-bit number from this stream in little-endian order.
+     * This method reads
+     * two bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b2 &lt;&lt; 8) | b1
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream, interpreted as an
+     *             unsigned 16-bit integer.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               two bytes.
+     * @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);
+    }
+
+    /**
+     * Reads a Unicode character from this stream. This method reads two
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1,&nbsp;b2&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (char)((b1 &lt;&lt; 8) | b2)
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream as a Unicode character.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               two bytes.
+     * @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));
+    }
+
+    /**
+     * Reads a Unicode character from this stream in little-endian order.
+     * This method reads two
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code> and <code>b2</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1,&nbsp;b2&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (char)((b2 &lt;&lt; 8) | b1)
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the two bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next two bytes of this stream as a Unicode character.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               two bytes.
+     * @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));
+    }
+
+    /**
+     * Reads a signed 32-bit integer from this stream. This method reads 4
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are <code>b1</code>,
+     * <code>b2</code>, <code>b3</code>, and <code>b4</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2, b3, b4&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b1 &lt;&lt; 24) | (b2 &lt;&lt; 16) + (b3 &lt;&lt; 8) + b4
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as an
+     *             <code>int</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               four bytes.
+     * @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));
+    }
+
+    /**
+     * Reads a signed 32-bit integer from this stream in little-endian order.
+     * This method reads 4
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are <code>b1</code>,
+     * <code>b2</code>, <code>b3</code>, and <code>b4</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2, b3, b4&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b4 &lt;&lt; 24) | (b3 &lt;&lt; 16) + (b2 &lt;&lt; 8) + b1
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as an
+     *             <code>int</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               four bytes.
+     * @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));
+    }
+
+    /**
+     * Reads an unsigned 32-bit integer from this stream. This method reads 4
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are <code>b1</code>,
+     * <code>b2</code>, <code>b3</code>, and <code>b4</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2, b3, b4&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b1 &lt;&lt; 24) | (b2 &lt;&lt; 16) + (b3 &lt;&lt; 8) + b4
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as a
+     *             <code>long</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               four bytes.
+     * @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));
+    }
+
+    private byte[] ruileBuf = new byte[4];
+
+    /**
+     * Reads an unsigned 32-bit integer from this stream in little-endian
+     * order.  This method reads 4
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are <code>b1</code>,
+     * <code>b2</code>, <code>b3</code>, and <code>b4</code>, where
+     * <code>0&nbsp;&lt;=&nbsp;b1, b2, b3, b4&nbsp;&lt;=&nbsp;255</code>,
+     * then the result is equal to:
+     * <blockquote><pre>
+     *     (b4 &lt;&lt; 24) | (b3 &lt;&lt; 16) + (b2 &lt;&lt; 8) + b1
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as a
+     *             <code>long</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               four bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    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);
+
+        return ((ch4 << 24) + (ch3 << 16) + (ch2 << 8) + (ch1 << 0));
+    }
+
+    /**
+     * Reads a signed 64-bit integer from this stream. This method reads eight
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code>, <code>b2</code>, <code>b3</code>,
+     * <code>b4</code>, <code>b5</code>, <code>b6</code>,
+     * <code>b7</code>, and <code>b8,</code> where:
+     * <blockquote><pre>
+     *     0 &lt;= b1, b2, b3, b4, b5, b6, b7, b8 &lt;=255,
+     * </pre></blockquote>
+     * <p>
+     * then the result is equal to:
+     * <p><blockquote><pre>
+     *     ((long)b1 &lt;&lt; 56) + ((long)b2 &lt;&lt; 48)
+     *     + ((long)b3 &lt;&lt; 40) + ((long)b4 &lt;&lt; 32)
+     *     + ((long)b5 &lt;&lt; 24) + ((long)b6 &lt;&lt; 16)
+     *     + ((long)b7 &lt;&lt; 8) + b8
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the eight bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next eight bytes of this stream, interpreted as a
+     *             <code>long</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               eight bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final long readLong() throws IOException {
+        return ((long)(readInt()) << 32) + (readInt() & 0xFFFFFFFFL);
+    }
+
+    /**
+     * Reads a signed 64-bit integer from this stream in little-endian
+     * order. This method reads eight
+     * bytes from the stream, starting at the current stream pointer.
+     * If the bytes read, in order, are
+     * <code>b1</code>, <code>b2</code>, <code>b3</code>,
+     * <code>b4</code>, <code>b5</code>, <code>b6</code>,
+     * <code>b7</code>, and <code>b8,</code> where:
+     * <blockquote><pre>
+     *     0 &lt;= b1, b2, b3, b4, b5, b6, b7, b8 &lt;=255,
+     * </pre></blockquote>
+     * <p>
+     * then the result is equal to:
+     * <p><blockquote><pre>
+     *     ((long)b1 &lt;&lt; 56) + ((long)b2 &lt;&lt; 48)
+     *     + ((long)b3 &lt;&lt; 40) + ((long)b4 &lt;&lt; 32)
+     *     + ((long)b5 &lt;&lt; 24) + ((long)b6 &lt;&lt; 16)
+     *     + ((long)b7 &lt;&lt; 8) + b8
+     * </pre></blockquote>
+     * <p>
+     * This method blocks until the eight bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next eight bytes of this stream, interpreted as a
+     *             <code>long</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *               eight bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final long readLongLE() throws IOException {
+        int i1 = readIntLE();
+        int i2 = readIntLE();
+        return ((long)i2 << 32) + (i1 & 0xFFFFFFFFL);
+    }
+
+    /**
+     * Reads a <code>float</code> from this stream. This method reads an
+     * <code>int</code> value, starting at the current stream pointer,
+     * as if by the <code>readInt</code> method
+     * and then converts that <code>int</code> to a <code>float</code>
+     * using the <code>intBitsToFloat</code> method in class
+     * <code>Float</code>.
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as a
+     *             <code>float</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *             four bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final float readFloat() throws IOException {
+        return Float.intBitsToFloat(readInt());
+    }
+
+    /**
+     * Reads a <code>float</code> from this stream in little-endian order.
+     * This method reads an
+     * <code>int</code> value, starting at the current stream pointer,
+     * as if by the <code>readInt</code> method
+     * and then converts that <code>int</code> to a <code>float</code>
+     * using the <code>intBitsToFloat</code> method in class
+     * <code>Float</code>.
+     * <p>
+     * This method blocks until the four bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next four bytes of this stream, interpreted as a
+     *             <code>float</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *             four bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final float readFloatLE() throws IOException {
+        return Float.intBitsToFloat(readIntLE());
+    }
+
+    /**
+     * Reads a <code>double</code> from this stream. This method reads a
+     * <code>long</code> value, starting at the current stream pointer,
+     * as if by the <code>readLong</code> method
+     * and then converts that <code>long</code> to a <code>double</code>
+     * using the <code>longBitsToDouble</code> method in
+     * class <code>Double</code>.
+     * <p>
+     * This method blocks until the eight bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next eight bytes of this stream, interpreted as a
+     *             <code>double</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *             eight bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final double readDouble() throws IOException {
+        return Double.longBitsToDouble(readLong());
+    }
+
+    /**
+     * Reads a <code>double</code> from this stream in little-endian order.
+     * This method reads a
+     * <code>long</code> value, starting at the current stream pointer,
+     * as if by the <code>readLong</code> method
+     * and then converts that <code>long</code> to a <code>double</code>
+     * using the <code>longBitsToDouble</code> method in
+     * class <code>Double</code>.
+     * <p>
+     * This method blocks until the eight bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     the next eight bytes of this stream, interpreted as a
+     *             <code>double</code>.
+     * @exception  EOFException  if this stream reaches the end before reading
+     *             eight bytes.
+     * @exception  IOException   if an I/O error occurs.
+     */
+    public final double readDoubleLE() throws IOException {
+        return Double.longBitsToDouble(readLongLE());
+    }
+
+    /**
+     * Reads the next line of text from this stream.  This method successively
+     * reads bytes from the stream, starting at the current stream pointer,
+     * until it reaches a line terminator or the end
+     * of the stream.  Each byte is converted into a character by taking the
+     * byte's value for the lower eight bits of the character and setting the
+     * high eight bits of the character to zero.  This method does not,
+     * therefore, support the full Unicode character set.
+     *
+     * <p> A line of text is terminated by a carriage-return character
+     * (<code>'&#92;r'</code>), a newline character (<code>'&#92;n'</code>), a
+     * carriage-return character immediately followed by a newline character,
+     * or the end of the stream.  Line-terminating characters are discarded and
+     * are not included as part of the string returned.
+     *
+     * <p> This method blocks until a newline character is read, a carriage
+     * return and the byte following it are read (to see if it is a newline),
+     * the end of the stream is reached, or an exception is thrown.
+     *
+     * @return     the next line of text from this stream, or null if end
+     *             of stream is encountered before even one byte is read.
+     * @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();
+    }
+
+    /**
+     * Reads in a string from this stream. The string has been encoded
+     * using a modified UTF-8 format.
+     * <p>
+     * The first two bytes are read, starting from the current stream
+     * pointer, as if by
+     * <code>readUnsignedShort</code>. This value gives the number of
+     * following bytes that are in the encoded string, not
+     * the length of the resulting string. The following bytes are then
+     * interpreted as bytes encoding characters in the UTF-8 format
+     * and are converted into characters.
+     * <p>
+     * This method blocks until all the bytes are read, the end of the
+     * stream is detected, or an exception is thrown.
+     *
+     * @return     a Unicode string.
+     * @exception  EOFException            if this stream reaches the end before
+     *               reading all the bytes.
+     * @exception  IOException             if an I/O error occurs.
+     * @exception  UTFDataFormatException  if the bytes do not represent
+     *               valid UTF-8 encoding of a Unicode string.
+     */
+    public final String readUTF() throws IOException {
+        return DataInputStream.readUTF(this);
+    }
+
+    /**
+     * Releases any system resources associated with this stream
+     * by calling the <code>close()</code> method.
+     */
+    protected void finalize() throws Throwable {
+        super.finalize();
+        close();
+    }
+}

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableStream.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SimpleRenderedImage.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SimpleRenderedImage.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SimpleRenderedImage.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SimpleRenderedImage.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,541 @@
+/*
+
+   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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.codec.util;
+
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.SampleModel;
+import java.awt.image.WritableRaster;
+
+import java.util.Vector;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * A simple class implemented the <code>RenderedImage</code>
+ * interface.  Only the <code>getTile()</code> method needs to be
+ * implemented by subclasses.  The instance variables must also be
+ * filled in properly.
+ *
+ * <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: SimpleRenderedImage.java 498747 2007-01-22 18:56:19Z dvholten $
+ */
+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 List sources = new ArrayList();
+
+    /** A Hashtable containing the image properties. */
+    protected Map properties = new HashMap();
+
+    public SimpleRenderedImage() {}
+
+    /** Returns the X coordinate of the leftmost column of the image. */
+    public int getMinX() {
+        return minX;
+    }
+
+    /**
+     * Returns the X coordinate of the column immediatetely to the
+     * right of the rightmost column of the image.  getMaxX() is
+     * implemented in terms of getMinX() and getWidth() and so does
+     * not need to be implemented by subclasses.
+     */
+    public final int getMaxX() {
+        return getMinX() + getWidth();
+    }
+
+    /** Returns the X coordinate of the uppermost row of the image. */
+    public int getMinY() {
+        return minY;
+    }
+
+    /**
+     * Returns the Y coordinate of the row immediately below the
+     * bottom row of the image.  getMaxY() is implemented in terms of
+     * getMinY() and getHeight() and so does not need to be
+     * implemented by subclasses.
+     */
+    public final int getMaxY() {
+        return getMinY() + getHeight();
+    }
+
+    /** Returns the width of the image. */
+    public int getWidth() {
+        return width;
+    }
+
+    /** Returns the height of the image. */
+    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;
+    }
+
+    /** Returns the height of a tile. */
+    public int getTileHeight() {
+        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() {
+        return tileGridYOffset;
+    }
+
+    /**
+     * Returns the horizontal index of the leftmost column of tiles.
+     * getMinTileX() is implemented in terms of getMinX()
+     * and so does not need to be implemented by subclasses.
+     */
+    public int getMinTileX() {
+        return XToTileX(getMinX());
+    }
+
+    /**
+     * Returns the horizontal index of the rightmost column of tiles.
+     * getMaxTileX() is implemented in terms of getMaxX()
+     * and so does not need to be implemented by subclasses.
+     */
+    public int getMaxTileX() {
+        return XToTileX(getMaxX() - 1);
+    }
+
+    /**
+     * Returns the number of tiles along the tile grid in the
+     * horizontal direction.  getNumXTiles() is implemented in terms
+     * of getMinTileX() and getMaxTileX() and so does not need to be
+     * implemented by subclasses.
+     */
+    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.
+     */
+    public int getMinTileY() {
+        return YToTileY(getMinY());
+    }
+
+    /**
+     * Returns the vertical index of the bottom row of tiles.  getMaxTileY()
+     * is implemented in terms of getMaxY() and so does not need to
+     * be implemented by subclasses.
+     */
+    public int getMaxTileY() {
+        return YToTileY(getMaxY() - 1);
+    }
+
+    /**
+     * Returns the number of tiles along the tile grid in the vertical
+     * direction.  getNumYTiles() is implemented in terms
+     * of getMinTileY() and getMaxTileY() and so does not need to be
+     * implemented by subclasses.
+     */
+    public int getNumYTiles() {
+        return getMaxTileY() - getMinTileY() + 1;
+    }
+
+    /** Returns the SampleModel of the image. */
+    public SampleModel getSampleModel() {
+        return sampleModel;
+    }
+
+    /** Returns the ColorModel of the image. */
+    public ColorModel getColorModel() {
+        return colorModel;
+    }
+
+    /**
+     * Gets a property from the property set of this image.  If the
+     * 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>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, 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;
+//        }
+        properties.keySet().toArray( names );
+        return names;
+    }
+
+    /**
+     * Returns an array of <code>String</code>s recognized as names by
+     * this property source that begin with the supplied prefix.  If
+     * no property names match, <code>null</code> will be returned.
+     * The comparison is done in a case-independent manner.
+     *
+     * <p> The default implementation calls
+     * <code>getPropertyNames()</code> and searches the list of names
+     * for matches.
+     *
+     * @return an array of <code>String</code>s giving the valid
+     * property names (can be null).
+     */
+    public String[] getPropertyNames(String prefix) {
+        String[] propertyNames = getPropertyNames();
+        if (propertyNames == null) {
+            return null;
+        }
+
+        prefix = prefix.toLowerCase();
+
+        List names = new ArrayList();
+        for (int i = 0; i < propertyNames.length; i++) {
+            if (propertyNames[i].startsWith(prefix)) {
+                names.add(propertyNames[i]);
+            }
+        }
+
+        if (names.size() == 0) {
+            return null;
+        }
+
+        // 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(); ) { // todo xx.toArray()
+//            prefixNames[count++] = (String)it.next();
+//        }
+        names.toArray( prefixNames );
+
+        return prefixNames;
+    }
+
+    // Utility methods.
+
+    /**
+     * Converts a pixel's X coordinate into a horizontal tile index
+     * relative to a given tile grid layout specified by its X offset
+     * and tile width.
+     */
+    public static int XToTileX(int x, int tileGridXOffset, int tileWidth) {
+        x -= tileGridXOffset;
+        if (x < 0) {
+            x += 1 - tileWidth; // Force round to -infinity
+        }
+        return x/tileWidth;
+    }
+
+    /**
+     * Converts a pixel's Y coordinate into a vertical tile index
+     * relative to a given tile grid layout specified by its Y offset
+     * and tile height.
+     */
+    public static int YToTileY(int y, int tileGridYOffset, int tileHeight) {
+        y -= tileGridYOffset;
+        if (y < 0) {
+            y += 1 - tileHeight; // Force round to -infinity
+        }
+        return y/tileHeight;
+    }
+
+    /**
+     * Converts a pixel's X coordinate into a horizontal tile index.
+     * This is a convenience method.  No attempt is made to detect
+     * out-of-range coordinates.
+     *
+     * @param x the X coordinate of a pixel.
+     * @return the X index of the tile containing the pixel.
+     */
+    public int XToTileX(int x) {
+        return XToTileX(x, getTileGridXOffset(), getTileWidth());
+    }
+
+    /**
+     * 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.
+     *
+     * @param y the Y coordinate of a pixel.
+     * @return the Y index of the tile containing the pixel.
+     */
+    public int YToTileY(int y) {
+        return YToTileY(y, getTileGridYOffset(), getTileHeight());
+    }
+
+    /**
+     * Converts a horizontal tile index into the X coordinate of its
+     * upper left pixel relative to a given tile grid layout specified
+     * by its X offset and tile width.
+     */
+    public static int tileXToX(int tx, int tileGridXOffset, int tileWidth) {
+        return tx*tileWidth + tileGridXOffset;
+    }
+
+    /**
+     * Converts a vertical tile index into the Y coordinate of
+     * its upper left pixel relative to a given tile grid layout
+     * specified by its Y offset and tile height.
+     */
+    public static int tileYToY(int ty, int tileGridYOffset, int tileHeight) {
+        return ty*tileHeight + tileGridYOffset;
+    }
+
+    /**
+     * Converts a horizontal tile index into the X coordinate of its
+     * upper left pixel.  This is a convenience method.  No attempt is made
+     * to detect out-of-range indices.
+     *
+     * @param tx the horizontal index of a tile.
+     * @return the X coordinate of the tile's upper left pixel.
+     */
+    public int tileXToX(int tx) {
+        return tx*tileWidth + tileGridXOffset;
+    }
+
+    /**
+     * Converts a vertical tile index into the Y coordinate of its
+     * upper left pixel.  This is a convenience method.  No attempt is made
+     * to detect out-of-range indices.
+     *
+     * @param ty the vertical index of a tile.
+     * @return the Y coordinate of the tile's upper left pixel.
+     */
+    public int tileYToY(int ty) {
+        return ty*tileHeight + tileGridYOffset;
+    }
+
+    public Vector getSources() {
+        return null;
+    }
+
+    /**
+     * Returns the entire image in a single Raster.  For images with
+     * multiple tiles this will require making a copy.
+     *
+     * <p> The returned Raster is semantically a copy.  This means
+     * that updates to the source image will not be reflected in the
+     * returned Raster.  For non-writable (immutable) source images,
+     * the returned value may be a reference to the image's internal
+     * data.  The returned Raster should be considered non-writable;
+     * any attempt to alter its pixel data (such as by casting it to
+     * WritableRaster or obtaining and modifying its DataBuffer) may
+     * result in undefined behavior.  The copyData method should be
+     * used if the returned Raster is to be modified.
+     *
+     * @return a Raster containing a copy of this image's data.
+     */
+    public Raster getData() {
+        Rectangle rect = new Rectangle(getMinX(), getMinY(),
+                                       getWidth(), getHeight());
+        return getData(rect);
+    }
+
+    /**
+     * Returns an arbitrary rectangular region of the RenderedImage
+     * in a Raster.  The rectangle of interest will be clipped against
+     * the image bounds.
+     *
+     * <p> The returned Raster is semantically a copy.  This means
+     * that updates to the source image will not be reflected in the
+     * returned Raster.  For non-writable (immutable) source images,
+     * the returned value may be a reference to the image's internal
+     * data.  The returned Raster should be considered non-writable;
+     * any attempt to alter its pixel data (such as by casting it to
+     * WritableRaster or obtaining and modifying its DataBuffer) may
+     * result in undefined behavior.  The copyData method should be
+     * used if the returned Raster is to be modified.
+     *
+     * @param bounds the region of the RenderedImage to be returned.
+     */
+    public Raster getData(Rectangle bounds) {
+        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);
+        Raster tile;
+
+        if ((startX == endX) && (startY == endY)) {
+            tile = getTile(startX, startY);
+            return tile.createChild(bounds.x, bounds.y,
+                                    bounds.width, bounds.height,
+                                    bounds.x, bounds.y, null);
+        } else {
+            // Create a WritableRaster of the desired size
+            SampleModel sm =
+                sampleModel.createCompatibleSampleModel(bounds.width,
+                                                       bounds.height);
+
+            // Translate it
+            WritableRaster dest =
+                Raster.createWritableRaster(sm, bounds.getLocation());
+
+            for (int j = startY; j <= endY; j++) {
+                for (int i = startX; i <= endX; i++) {
+                    tile = getTile(i, j);
+                    Rectangle intersectRect =
+                        bounds.intersection(tile.getBounds());
+                    Raster liveRaster = tile.createChild(intersectRect.x,
+                                                         intersectRect.y,
+                                                         intersectRect.width,
+                                                         intersectRect.height,
+                                                         intersectRect.x,
+                                                         intersectRect.y,
+                                                         null);
+                    dest.setDataElements(0, 0, liveRaster);
+                }
+            }
+            return dest;
+        }
+    }
+
+    /**
+     * Copies an arbitrary rectangular region of the RenderedImage
+     * into a caller-supplied WritableRaster.  The region to be
+     * computed is determined by clipping the bounds of the supplied
+     * WritableRaster against the bounds of the image.  The supplied
+     * WritableRaster must have a SampleModel that is compatible with
+     * that of the image.
+     *
+     * <p> If the raster argument is null, the entire image will
+     * be copied into a newly-created WritableRaster with a SampleModel
+     * that is compatible with that of the image.
+     *
+     * @param dest a WritableRaster to hold the returned portion of
+     *        the image.
+     * @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);
+            /* A SampleModel to hold the entire image. */
+            SampleModel sm = sampleModel.createCompatibleSampleModel(
+                                         width, height);
+            dest = Raster.createWritableRaster(sm, p);
+        } 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);
+                Rectangle intersectRect =
+                    bounds.intersection(tile.getBounds());
+                Raster liveRaster = tile.createChild(intersectRect.x,
+                                                     intersectRect.y,
+                                                     intersectRect.width,
+                                                     intersectRect.height,
+                                                     intersectRect.x,
+                                                     intersectRect.y,
+                                                     null);
+
+                /*
+                 * WritableRaster.setDataElements takes into account of
+                 * inRaster's minX and minY and add these to x and y. Since
+                 * liveRaster has the origin at the correct location, the
+                 * following call should not again give these coordinates in
+                 * places of x and y.
+                 */
+                dest.setDataElements(0, 0, liveRaster);
+            }
+        }
+        return dest;
+    }
+}

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SimpleRenderedImage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SingleTileRenderedImage.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SingleTileRenderedImage.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SingleTileRenderedImage.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SingleTileRenderedImage.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,63 @@
+/*
+
+   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.
+
+*/
+
+package org.apache.flex.forks.batik.ext.awt.image.codec.util;
+
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+
+/**
+ * A simple class that provides RenderedImage functionality
+ * given a Raster and a ColorModel.
+ *
+ * @version $Id: SingleTileRenderedImage.java 479564 2006-11-27 09:56:57Z dvholten $
+ */
+public class SingleTileRenderedImage extends SimpleRenderedImage {
+
+    Raster ras;
+
+    /**
+     * Constructs a SingleTileRenderedImage based on a Raster
+     * and a ColorModel.
+     *
+     * @param ras A Raster that will define tile (0, 0) of the image.
+     * @param colorModel A ColorModel that will serve as the image's
+     *                   ColorModel.
+     */
+    public SingleTileRenderedImage(Raster ras, ColorModel colorModel) {
+        this.ras = ras;
+
+        this.tileGridXOffset = this.minX = ras.getMinX();
+        this.tileGridYOffset = this.minY = ras.getMinY();
+        this.tileWidth = this.width = ras.getWidth();
+        this.tileHeight = this.height = ras.getHeight();
+        this.sampleModel = ras.getSampleModel();
+        this.colorModel = colorModel;
+    }
+
+    /**
+     * Returns the image's Raster as tile (0, 0).
+     */
+    public Raster getTile(int tileX, int tileY) {
+        if (tileX != 0 || tileY != 0) {
+            throw new IllegalArgumentException(PropertyUtil.getString("SingleTileRenderedImage0"));
+        }
+        return ras;
+    }
+}

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SingleTileRenderedImage.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/package.html
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/package.html?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/package.html (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/package.html Thu Oct 25 19:01:43 2012
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+  <head>
+    <title>org.apache.batik.ext.awt.image</title>
+  </head>
+
+  <body>
+Contains extensions to the <tt>java.awt.image</tt> package. This
+package provides convenient methods and some utility classes. These
+generally bypass broken methods in Java2D or provide tweaked
+implementations.
+  </body>
+</html>

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/package.html
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractColorInterpolationRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractColorInterpolationRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractColorInterpolationRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractColorInterpolationRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,131 @@
+/*
+
+   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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.color.ColorSpace;
+import java.awt.image.RenderedImage;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.flex.forks.batik.ext.awt.image.GraphicsUtil;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+
+/**
+ * This is an abstract base class that adds the ability to specify the
+ * Color Space that the operation should take place in (linear sRGB or
+ * gamma corrected sRBG).
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: AbstractColorInterpolationRable.java 475477 2006-11-15 22:44:28Z cam $
+ */
+public abstract class AbstractColorInterpolationRable extends AbstractRable {
+
+    /**
+     * Indicates if the operation should be done in linear or gamma
+     * corrected sRGB.
+     */
+    protected boolean csLinear = true;
+
+    /**
+     * void constructor. The subclass must call one of the
+     * flavors of init before the object becomes usable.
+     * This is useful when the proper parameters to the init
+     * method need to be computed in the subclasses constructor.  */
+    protected AbstractColorInterpolationRable() {
+        super();
+    }
+
+    /**
+     * Construct an Abstract Rable from src.
+     * @param src will be the first (and only) member of the srcs
+     * Vector. The bounds of src are also used to set the bounds of
+     * this renderable.
+     */
+    protected AbstractColorInterpolationRable(Filter src) {
+        super(src);
+    }
+
+    /**
+     * Construct an Abstract Rable from src and props.
+     * @param src will also be set as the first (and only) member of
+     * the srcs Vector.
+     * @param props use to initialize the properties on this renderable image.
+     */
+    protected AbstractColorInterpolationRable(Filter src, Map props) {
+        super(src, props);
+    }
+
+    /**
+     * Construct an Abstract Rable from a list of sources.
+     * @param srcs This is used to initialize the srcs Vector.
+     * The bounds of this renderable will be the union of the bounds
+     * of all the sources in srcs.  All the members of srcs must be
+     * CachableRable otherwise an error will be thrown.
+     */
+    protected AbstractColorInterpolationRable(List srcs) {
+        super(srcs);
+    }
+
+    /**
+     * Construct an Abstract Rable from a list of sources, and bounds.
+     * @param srcs This is used to initialize the srcs Vector.  All
+     * the members of srcs must be CachableRable otherwise an error
+     * will be thrown.
+     * @param props use to initialize the properties on this renderable image.
+     */
+    protected AbstractColorInterpolationRable(List srcs, Map props) {
+        super(srcs, props);
+    }
+
+    /**
+     * Returns true if this operation is to be performed in
+     * the linear sRGB colorspace, returns false if the
+     * operation is performed in gamma corrected sRGB.
+     */
+    public boolean isColorSpaceLinear() { return csLinear; }
+
+    /**
+     * Sets the colorspace the operation will be performed in.
+     * @param csLinear if true this operation will be performed in the
+     * linear sRGB colorspace, if false the operation will be performed in
+     * gamma corrected sRGB.
+     */
+    public void setColorSpaceLinear(boolean csLinear) {
+        touch();
+        this.csLinear = csLinear;
+    }
+
+    public ColorSpace getOperationColorSpace() {
+        if (csLinear)
+            return ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB);
+        else
+            return ColorSpace.getInstance(ColorSpace.CS_sRGB);
+    }
+
+    protected CachableRed convertSourceCS(CachableRed cr) {
+        if (csLinear)
+            return GraphicsUtil.convertToLsRGB(cr);
+        else
+            return GraphicsUtil.convertTosRGB(cr);
+    }
+
+    protected CachableRed convertSourceCS(RenderedImage ri) {
+        return convertSourceCS(GraphicsUtil.wrap(ri));
+    }
+}

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractColorInterpolationRable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,314 @@
+/*
+
+   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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.Rectangle;
+import java.awt.RenderingHints;
+import java.awt.Shape;
+import java.awt.geom.AffineTransform;
+import java.awt.geom.Rectangle2D;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderContext;
+import java.awt.image.renderable.RenderableImage;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.Vector;
+
+import org.apache.flex.forks.batik.ext.awt.image.PadMode;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.CachableRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.PadRed;
+import org.apache.flex.forks.batik.ext.awt.image.rendered.RenderedImageCachableRed;
+
+/**
+ * This is an abstract base class that takes care of most of the
+ * normal issues surrounding the implementation of the RenderableImage
+ * interface.  It tries to make no assumptions about the subclass
+ * implementation.
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: AbstractRable.java 489226 2006-12-21 00:05:36Z cam $
+ */
+public abstract class AbstractRable implements Filter {
+
+    protected Vector srcs;
+    protected Map    props = new HashMap();
+    protected long   stamp = 0;
+
+    /**
+     * void constructor. The subclass must call one of the
+     * flavors of init before the object becomes usable.
+     * This is useful when the proper parameters to the init
+     * method need to be computed in the subclasses constructor.
+     */
+    protected AbstractRable() {
+        srcs = new Vector();
+    }
+
+    /**
+     * Construct an Abstract Rable from src.
+     * @param src will be the first (and only) member of the srcs
+     * Vector. The bounds of src are also used to set the bounds of
+     * this renderable.
+     */
+    protected AbstractRable(Filter src) {
+        init(src, null);
+    }
+
+    /**
+     * Construct an Abstract Rable from src and props.
+     * @param src will also be set as the first (and only) member of
+     * the srcs Vector.
+     * @param props use to initialize the properties on this renderable image.
+     */
+    protected AbstractRable(Filter src, Map props) {
+        init(src, props);
+    }
+
+    /**
+     * Construct an Abstract Rable from a list of sources.
+     * @param srcs This is used to initialize the srcs Vector.
+     * The bounds of this renderable will be the union of the bounds
+     * of all the sources in srcs.  All the members of srcs must be
+     * CacheableRable otherwise an error will be thrown.
+     */
+    protected AbstractRable(List srcs) {
+        this(srcs, null);
+    }
+
+    /**
+     * Construct an Abstract Rable from a list of sources, and bounds.
+     * @param srcs This is used to initialize the srcs Vector.  All
+     * the members of srcs must be CacheableRable otherwise an error
+     * will be thrown.
+     * @param props use to initialize the properties on this renderable image.
+     */
+    protected AbstractRable(List srcs, Map props) {
+        init(srcs, props);
+    }
+
+    /**
+     * Increments the time stamp.  This should be called when ever
+     * the image changes in such a way that cached output should be
+     * discarded.
+     */
+    public final void touch() { stamp++; }
+
+      /**
+       * Returns the current modification timestamp on this Renderable
+       * node.  This value will change whenever cached output data becomes
+       * invalid.
+       * @return Current modification timestamp value.
+       */
+    public long getTimeStamp() { return stamp; }
+
+    /**
+     * Initialize an Abstract Rable from src, bounds and props.  This
+     * can be called long after the object is constructed to reset the
+     * state of the Renderable.
+     * @param src will become the first (and only) member of the srcs Vector.
+     */
+    protected void init(Filter src) {
+        touch();
+
+        this.srcs   = new Vector(1);
+        if (src != null) {
+            this.srcs.add(src);
+        }
+    }
+
+    /**
+     * Initialize an Abstract Rable from src, bounds and props.  This
+     * can be called long after the object is constructed to reset the
+     * state of the Renderable.
+     * @param src will also be set as the first (and only) member of
+     * the srcs Vector.
+     * @param props use to set the properties on this renderable image.
+     * Always clears the current properties (even if null).
+     */
+    protected void init(Filter src, Map props) {
+        init (src);
+        if(props != null){
+            this.props.putAll(props);
+        }
+    }
+
+    /**
+     * Initialize an Abstract Rable from a list of sources, and
+     * possibly a bounds.  This can be called long after the object is
+     * constructed to reset the state of the Renderable.
+     * @param srcs Used the create a new srcs Vector (old sources are dropped).
+     */
+    protected void init(List srcs) {
+        touch();
+        this.srcs   = new Vector(srcs);
+    }
+
+    /**
+     * Initialize an Abstract Rable from a list of sources, and
+     * possibly a bounds.  This can be called long after the object is
+     * constructed to reset the state of the Renderable.
+     * @param srcs Used the create a new srcs Vector (old sources are dropped).
+     * @param props use to set the properties on this renderable image.
+     * Always clears the current properties (even if null).
+     */
+    protected void init(List srcs, Map props) {
+        init (srcs);
+        if(props != null)
+            this.props.putAll(props);
+    }
+
+    public Rectangle2D getBounds2D() {
+        Rectangle2D bounds = null;
+        if (this.srcs.size() != 0) {
+            Iterator i = srcs.iterator();
+            Filter src = (Filter)i.next();
+            bounds = (Rectangle2D)src.getBounds2D().clone();
+            Rectangle2D r;
+            while (i.hasNext()) {
+                src = (Filter)i.next();
+                r = src.getBounds2D();
+                Rectangle2D.union(bounds, r, bounds);
+            }
+        }
+        return bounds;
+    }
+
+    public Vector getSources() {
+        return srcs;
+    }
+
+    public RenderedImage createDefaultRendering() {
+        return createScaledRendering(100, 100, null);
+    }
+
+    public RenderedImage createScaledRendering(int w, int h,
+                                           RenderingHints hints) {
+        float sX = w/getWidth();
+        float sY = h/getHeight();
+        float scale = Math.min(sX, sY);
+
+        AffineTransform at = AffineTransform.getScaleInstance(scale, scale);
+        RenderContext rc = new RenderContext(at, hints);
+
+        float dX = (getWidth()*scale)-w;
+        float dY = (getHeight()*scale)-h;
+
+        RenderedImage ri = createRendering(rc);
+        CachableRed cr = RenderedImageCachableRed.wrap(ri);
+        return new PadRed(cr, new Rectangle((int)(dX/2), (int)(dY/2), w, h),
+                          PadMode.ZERO_PAD, null);
+    }
+
+    public float getMinX() {
+        return (float)getBounds2D().getX();
+    }
+    public float getMinY() {
+        return (float)getBounds2D().getY();
+    }
+    public float getWidth() {
+        return (float)getBounds2D().getWidth();
+    }
+    public float getHeight() {
+        return (float)getBounds2D().getHeight();
+    }
+
+    public Object getProperty(String name) {
+        Object ret = props.get(name);
+        if (ret != null) return ret;
+        Iterator i = srcs.iterator();
+        while (i.hasNext()) {
+            RenderableImage ri = (RenderableImage)i.next();
+            ret = ri.getProperty(name);
+            if (ret != null) return ret;
+        }
+        return null;
+    }
+
+    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();
+        }
+
+        iter = srcs.iterator();
+        while (iter.hasNext()) {
+            RenderableImage ri = (RenderableImage)iter.next();
+            String [] srcProps = ri.getPropertyNames();
+            if (srcProps.length != 0) {
+                String [] tmp = new String[ret.length+srcProps.length];
+                System.arraycopy(ret,0,tmp,0,ret.length);
+                System.arraycopy(tmp,ret.length,srcProps,0,srcProps.length);
+                ret = tmp;
+            }
+        }
+
+        return ret;
+    }
+
+    public boolean isDynamic() { return false; }
+
+    public Shape getDependencyRegion(int srcIndex,
+                                     Rectangle2D outputRgn) {
+        if ((srcIndex < 0) || (srcIndex > srcs.size()))
+            throw new IndexOutOfBoundsException
+                ("Nonexistant source requested.");
+
+        // We only depend on our source for stuff that is inside
+        // our bounds...
+        Rectangle2D srect = (Rectangle2D)outputRgn.clone();
+        Rectangle2D bounds = getBounds2D();
+
+        // Return empty rect if they don't intersect.
+        if ( ! bounds.intersects(srect) )
+            return new Rectangle2D.Float();
+
+        Rectangle2D.intersect(srect, bounds, srect);
+        return srect;
+    }
+
+    public Shape getDirtyRegion(int srcIndex,
+                                Rectangle2D inputRgn) {
+        if ((srcIndex < 0) || (srcIndex > srcs.size()))
+            throw new IndexOutOfBoundsException
+                ("Nonexistant source requested.");
+
+          // Changes in the input region don't propogate outside our
+          // bounds.
+        Rectangle2D drect = (Rectangle2D)inputRgn.clone();
+        Rectangle2D bounds = getBounds2D();
+
+        // Return empty rect if they don't intersect.
+        if ( ! bounds.intersects(drect) )
+            return new Rectangle2D.Float();
+
+        Rectangle2D.intersect(drect, bounds, drect);
+        return drect;
+    }
+
+
+    /* left for subclass:
+       public RenderedImage createRendering(RenderContext rc);
+    */
+}

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AbstractRable.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable.java
URL: http://svn.apache.org/viewvc/incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,54 @@
+/*
+
+   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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.renderable;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * Adjusts the input images coordinate system by a general Affine transform
+ *
+ * @author <a href="mailto:Thomas.DeWeeese@Kodak.com">Thomas DeWeese</a>
+ * @version $Id: AffineRable.java 478276 2006-11-22 18:33:37Z dvholten $
+ */
+public interface AffineRable extends Filter {
+      /**
+       * Returns the source to be offset.
+       */
+      Filter getSource();
+
+      /**
+       * Sets the source to be offset.
+       * @param src image to offset.
+       */
+      void setSource(Filter src);
+
+      /**
+       * Set the affine.
+       * @param affine the new Affine transform for the filter.
+       */
+      void setAffine(AffineTransform affine);
+
+      /**
+       * Get the current affine.
+       * @return The current affine transform for the filter.
+       */
+      AffineTransform getAffine();
+}
+
+

Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/renderable/AffineRable.java
------------------------------------------------------------------------------
    svn:eol-style = native