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 [19/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/FileCacheSeekableStream.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/FileCacheSeekableStream.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/FileCacheSeekableStream.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/FileCacheSeekableStream.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,263 @@
+/*
+
+ 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.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.RandomAccessFile;
+
+/**
+ * A subclass of <code>SeekableStream</code> that may be used to wrap
+ * a regular <code>InputStream</code>. Seeking backwards is supported
+ * by means of a file cache. In circumstances that do not allow the
+ * creation of a temporary file (for example, due to security
+ * consideration or the absence of local disk), the
+ * <code>MemoryCacheSeekableStream</code> class may be used instead.
+ *
+ * <p> The <code>mark()</code> and <code>reset()</code> methods are
+ * supported.
+ *
+ * <p><b> This class is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: FileCacheSeekableStream.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public final class FileCacheSeekableStream extends SeekableStream {
+
+ /** The source stream. */
+ private InputStream stream;
+
+ /** The cache File. */
+ private File cacheFile;
+
+ /** The cache as a RandomAcessFile. */
+ private RandomAccessFile cache;
+
+ /** The length of the read buffer. */
+ private int bufLen = 1024;
+
+ /** The read buffer. */
+ private byte[] buf = new byte[bufLen];
+
+ /** Number of bytes in the cache. */
+ private long length = 0;
+
+ /** Next byte to be read. */
+ private long pointer = 0;
+
+ /** True if we've encountered the end of the source stream. */
+ private boolean foundEOF = false;
+
+ /**
+ * Constructs a <code>MemoryCacheSeekableStream</code> that takes
+ * its source data from a regular <code>InputStream</code>.
+ * Seeking backwards is supported by means of an file cache.
+ *
+ * <p> An <code>IOException</code> will be thrown if the
+ * attempt to create the cache file fails for any reason.
+ */
+ public FileCacheSeekableStream(InputStream stream)
+ throws IOException {
+ this.stream = stream;
+ this.cacheFile = File.createTempFile("jai-FCSS-", ".tmp");
+ cacheFile.deleteOnExit();
+ this.cache = new RandomAccessFile(cacheFile, "rw");
+ }
+
+ /**
+ * Ensures that at least <code>pos</code> bytes are cached,
+ * or the end of the source is reached. The return value
+ * is equal to the smaller of <code>pos</code> and the
+ * length of the source file.
+ */
+ private long readUntil(long pos) throws IOException {
+ // We've already got enough data cached
+ if (pos < length) {
+ return pos;
+ }
+ // pos >= length but length isn't getting any bigger, so return it
+ if (foundEOF) {
+ return length;
+ }
+
+ long len = pos - length;
+ cache.seek(length);
+ while (len > 0) {
+ // Copy a buffer's worth of data from the source to the cache
+ // bufLen will always fit into an int so this is safe
+ int nbytes = stream.read(buf, 0, (int)Math.min(len, bufLen));
+ if (nbytes == -1) {
+ foundEOF = true;
+ return length;
+ }
+
+ cache.setLength(cache.length() + nbytes);
+ cache.write(buf, 0, nbytes);
+ len -= nbytes;
+ length += nbytes;
+ }
+
+ return pos;
+ }
+
+ /**
+ * Returns <code>true</code> since all
+ * <code>FileCacheSeekableStream</code> instances support seeking
+ * backwards.
+ */
+ public boolean canSeekBackwards() {
+ return true;
+ }
+
+ /**
+ * Returns the current offset in this file.
+ *
+ * @return the offset from the beginning of the file, in bytes,
+ * at which the next read occurs.
+ */
+ public long getFilePointer() {
+ return pointer;
+ }
+
+ /**
+ * 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
+ * pointer.
+ * @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 {
+ if (pos < 0) {
+ throw new IOException(PropertyUtil.getString("FileCacheSeekableStream0"));
+ }
+ pointer = pos;
+ }
+
+ /**
+ * 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.
+ *
+ * @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 int read() throws IOException {
+ long next = pointer + 1;
+ long pos = readUntil(next);
+ if (pos >= next) {
+ cache.seek(pointer++);
+ return cache.read();
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * 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 file 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
+ * file, 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
+ * file, then an <code>IOException</code> is thrown. In particular, an
+ * <code>IOException</code> is thrown if the input stream has been closed.
+ *
+ * @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 int read(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ }
+ if ((off < 0) || (len < 0) || (off + len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (len == 0) {
+ return 0;
+ }
+
+ long pos = readUntil(pointer + len);
+
+ // len will always fit into an int so this is safe
+ len = (int)Math.min(len, pos - pointer);
+ if (len > 0) {
+ cache.seek(pointer);
+ cache.readFully(b, off, len);
+ pointer += len;
+ return len;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * Closes this stream and releases any system resources
+ * associated with the stream.
+ *
+ * @throws IOException if an I/O error occurs.
+ */
+ public void close() throws IOException {
+ super.close();
+ cache.close();
+ cacheFile.delete();
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/FileCacheSeekableStream.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/ForwardSeekableStream.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/ForwardSeekableStream.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ForwardSeekableStream.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ForwardSeekableStream.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,128 @@
+/*
+
+ 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.IOException;
+import java.io.InputStream;
+
+/**
+ * A subclass of <code>SeekableStream</code> that may be used
+ * to wrap a regular <code>InputStream</code> efficiently.
+ * Seeking backwards is not supported.
+ *
+ * @version $Id: ForwardSeekableStream.java 522271 2007-03-25 14:42:45Z dvholten $
+ */
+public class ForwardSeekableStream extends SeekableStream {
+
+ /** The source <code>InputStream</code>. */
+ private InputStream src;
+
+ /** The current position. */
+ long pointer = 0L;
+
+ /**
+ * Constructs a <code>InputStreamForwardSeekableStream</code> from a
+ * regular <code>InputStream</code>.
+ */
+ public ForwardSeekableStream(InputStream src) {
+ this.src = src;
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public final int read() throws IOException {
+ int result = src.read();
+ if (result != -1) {
+ ++pointer;
+ }
+ return result;
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public final int read(byte[] b, int off, int len) throws IOException {
+ int result = src.read(b, off, len);
+ if (result != -1) {
+ pointer += result;
+ }
+ return result;
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public final long skip(long n) throws IOException {
+ long skipped = src.skip(n);
+ pointer += skipped;
+ return skipped;
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public final int available() throws IOException {
+ return src.available();
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public final void close() throws IOException {
+ src.close();
+ }
+
+ /**
+ * Forwards the request to the real <code>InputStream</code>.
+ * We use {@link SeekableStream#markPos}
+ */
+ public final synchronized void mark(int readLimit) {
+ markPos = pointer;
+ src.mark(readLimit);
+ }
+
+ /**
+ * Forwards the request to the real <code>InputStream</code>.
+ * We use {@link SeekableStream#markPos}
+ */
+ public final synchronized void reset() throws IOException {
+ if (markPos != -1) {
+ pointer = markPos;
+ }
+ src.reset();
+ }
+
+ /** Forwards the request to the real <code>InputStream</code>. */
+ public boolean markSupported() {
+ return src.markSupported();
+ }
+
+ /** Returns <code>false</code> since seking backwards is not supported. */
+ public final boolean canSeekBackwards() {
+ return false;
+ }
+
+ /** Returns the current position in the stream (bytes read). */
+ public final long getFilePointer() {
+ return pointer;
+ }
+
+ /**
+ * Seeks forward to the given position in the stream.
+ * If <code>pos</code> is smaller than the current position
+ * as returned by <code>getFilePointer()</code>, nothing
+ * happens.
+ */
+ public final void seek(long pos) throws IOException {
+ while (pos - pointer > 0) {
+ pointer += src.skip(pos - pointer);
+ }
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ForwardSeekableStream.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/ImageDecodeParam.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/ImageDecodeParam.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecodeParam.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecodeParam.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,33 @@
+/*
+
+ 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.Serializable;
+
+/**
+ * An empty (marker) interface to be implemented by all image decoder
+ * parameter classes.
+ *
+ * <p><b> This interface is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: ImageDecodeParam.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public interface ImageDecodeParam extends Cloneable, Serializable {
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecodeParam.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/ImageDecoder.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/ImageDecoder.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoder.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoder.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,93 @@
+/*
+
+ 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.Raster;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+
+/**
+ * An interface describing objects that transform an InputStream into a
+ * BufferedImage or Raster.
+ *
+ * @version $Id: ImageDecoder.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public interface ImageDecoder {
+
+ /**
+ * Returns the current parameters as an instance of the
+ * ImageDecodeParam interface. Concrete implementations of this
+ * interface will return corresponding concrete implementations of
+ * the ImageDecodeParam interface. For example, a JPEGImageDecoder
+ * will return an instance of JPEGDecodeParam.
+ */
+ ImageDecodeParam getParam();
+
+ /**
+ * Sets the current parameters to an instance of the
+ * ImageDecodeParam interface. Concrete implementations
+ * of ImageDecoder may throw a RuntimeException if the
+ * param argument is not an instance of the appropriate
+ * subclass or subinterface. For example, a JPEGImageDecoder
+ * will expect param to be an instance of JPEGDecodeParam.
+ */
+ void setParam(ImageDecodeParam param);
+
+ /** Returns the SeekableStream associated with this ImageDecoder. */
+ SeekableStream getInputStream();
+
+ /** Returns the number of pages present in the current stream. */
+ int getNumPages() throws IOException;
+
+ /**
+ * Returns a Raster that contains the decoded contents of the
+ * SeekableStream associated with this ImageDecoder. Only
+ * the first page of a multi-page image is decoded.
+ */
+ Raster decodeAsRaster() throws IOException;
+
+ /**
+ * Returns a Raster that contains the decoded contents of the
+ * SeekableStream associated with this ImageDecoder.
+ * The given page of a multi-page image is decoded. If
+ * the page does not exist, an IOException will be thrown.
+ * Page numbering begins at zero.
+ *
+ * @param page The page to be decoded.
+ */
+ Raster decodeAsRaster(int page) throws IOException;
+
+ /**
+ * Returns a RenderedImage that contains the decoded contents of the
+ * SeekableStream associated with this ImageDecoder. Only
+ * the first page of a multi-page image is decoded.
+ */
+ RenderedImage decodeAsRenderedImage() throws IOException;
+
+ /**
+ * Returns a RenderedImage that contains the decoded contents of the
+ * SeekableStream associated with this ImageDecoder.
+ * The given page of a multi-page image is decoded. If
+ * the page does not exist, an IOException will be thrown.
+ * Page numbering begins at zero.
+ *
+ * @param page The page to be decoded.
+ */
+ RenderedImage decodeAsRenderedImage(int page) throws IOException;
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoder.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/ImageDecoderImpl.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/ImageDecoderImpl.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoderImpl.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoderImpl.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,162 @@
+/*
+
+ 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.Raster;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * A partial implementation of the <code>ImageDecoder</code> interface
+ * useful for subclassing.
+ *
+ * @version $Id: ImageDecoderImpl.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public abstract class ImageDecoderImpl implements ImageDecoder {
+
+ /**
+ * The <code>SeekableStream</code> associcted with this
+ * <code>ImageEncoder</code>.
+ */
+ protected SeekableStream input;
+
+ /**
+ * The <code>ImageDecodeParam</code> object associated with this
+ * <code>ImageEncoder</code>.
+ */
+ protected ImageDecodeParam param;
+
+ /**
+ * Constructs an <code>ImageDecoderImpl</code> with a given
+ * <code>SeekableStream</code> and <code>ImageDecodeParam</code>
+ * instance.
+ */
+ public ImageDecoderImpl(SeekableStream input,
+ ImageDecodeParam param) {
+ this.input = input;
+ this.param = param;
+ }
+
+ /**
+ * Constructs an <code>ImageDecoderImpl</code> with a given
+ * <code>InputStream</code> and <code>ImageDecodeParam</code>
+ * instance. The <code>input</code> parameter will be used to
+ * construct a <code>ForwardSeekableStream</code>; if the ability
+ * to seek backwards is required, the caller should construct
+ * an instance of <code>SeekableStream</code> and
+ * make use of the other contructor.
+ */
+ public ImageDecoderImpl(InputStream input,
+ ImageDecodeParam param) {
+ this.input = new ForwardSeekableStream(input);
+ this.param = param;
+ }
+
+ /**
+ * Returns the current parameters as an instance of the
+ * <code>ImageDecodeParam</code> interface. Concrete
+ * implementations of this interface will return corresponding
+ * concrete implementations of the <code>ImageDecodeParam</code>
+ * interface. For example, a <code>JPEGImageDecoder</code> will
+ * return an instance of <code>JPEGDecodeParam</code>.
+ */
+ public ImageDecodeParam getParam() {
+ return param;
+ }
+
+ /**
+ * Sets the current parameters to an instance of the
+ * <code>ImageDecodeParam</code> interface. Concrete
+ * implementations of <code>ImageDecoder</code> may throw a
+ * <code>RuntimeException</code> if the <code>param</code>
+ * argument is not an instance of the appropriate subclass or
+ * subinterface. For example, a <code>JPEGImageDecoder</code>
+ * will expect <code>param</code> to be an instance of
+ * <code>JPEGDecodeParam</code>.
+ */
+ public void setParam(ImageDecodeParam param) {
+ this.param = param;
+ }
+
+ /**
+ * Returns the <code>SeekableStream</code> associated with
+ * this <code>ImageDecoder</code>.
+ */
+ public SeekableStream getInputStream() {
+ return input;
+ }
+
+ /**
+ * Returns the number of pages present in the current stream.
+ * By default, the return value is 1. Subclasses that deal with
+ * multi-page formats should override this method.
+ */
+ public int getNumPages() throws IOException {
+ return 1;
+ }
+
+ /**
+ * Returns a <code>Raster</code> that contains the decoded
+ * contents of the <code>SeekableStream</code> associated
+ * with this <code>ImageDecoder</code>. Only
+ * the first page of a multi-page image is decoded.
+ */
+ public Raster decodeAsRaster() throws IOException {
+ return decodeAsRaster(0);
+ }
+
+ /**
+ * Returns a <code>Raster</code> that contains the decoded
+ * contents of the <code>SeekableStream</code> associated
+ * with this <code>ImageDecoder</code>.
+ * The given page of a multi-page image is decoded. If
+ * the page does not exist, an IOException will be thrown.
+ * Page numbering begins at zero.
+ *
+ * @param page The page to be decoded.
+ */
+ public Raster decodeAsRaster(int page) throws IOException {
+ RenderedImage im = decodeAsRenderedImage(page);
+ return im.getData();
+ }
+
+ /**
+ * Returns a <code>RenderedImage</code> that contains the decoded
+ * contents of the <code>SeekableStream</code> associated
+ * with this <code>ImageDecoder</code>. Only
+ * the first page of a multi-page image is decoded.
+ */
+ public RenderedImage decodeAsRenderedImage() throws IOException {
+ return decodeAsRenderedImage(0);
+ }
+
+ /**
+ * Returns a <code>RenderedImage</code> that contains the decoded
+ * contents of the <code>SeekableStream</code> associated
+ * with this <code>ImageDecoder</code>.
+ * The given page of a multi-page image is decoded. If
+ * the page does not exist, an IOException will be thrown.
+ * Page numbering begins at zero.
+ *
+ * @param page The page to be decoded.
+ */
+ public abstract RenderedImage decodeAsRenderedImage(int page)
+ throws IOException;
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageDecoderImpl.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/ImageEncodeParam.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/ImageEncodeParam.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncodeParam.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncodeParam.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,34 @@
+/*
+
+ 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.Serializable;
+
+/**
+ * An empty (marker) interface to be implemented by all image encoder
+ * parameter classes.
+ *
+ * <p><b> This interface is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: ImageEncodeParam.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public interface ImageEncodeParam extends
+ ImageDecodeParam, Cloneable, Serializable {
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncodeParam.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/ImageEncoder.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/ImageEncoder.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoder.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoder.java Thu Oct 25 19:01:43 2012
@@ -0,0 +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.
+
+ */
+package org.apache.flex.forks.batik.ext.awt.image.codec.util;
+
+import java.awt.image.ColorModel;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * An interface describing objects that transform a BufferedImage or
+ * Raster into an OutputStream.
+ *
+ * <p><b> This interface is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: ImageEncoder.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public interface ImageEncoder {
+
+ /**
+ * Returns the current parameters as an instance of the
+ * ImageEncodeParam interface. Concrete implementations of this
+ * interface will return corresponding concrete implementations of
+ * the ImageEncodeParam interface. For example, a JPEGImageEncoder
+ * will return an instance of JPEGEncodeParam.
+ */
+ ImageEncodeParam getParam();
+
+ /**
+ * 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.
+ */
+ void setParam(ImageEncodeParam param);
+
+ /** Returns the OutputStream associated with this ImageEncoder. */
+ OutputStream getOutputStream();
+
+ /**
+ * Encodes a Raster with a given ColorModel and writes the output
+ * to the OutputStream associated with this ImageEncoder.
+ */
+ void encode(Raster ras, ColorModel cm) throws IOException;
+
+ /**
+ * Encodes a RenderedImage and writes the output to the
+ * OutputStream associated with this ImageEncoder.
+ */
+ void encode(RenderedImage im) throws IOException;
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoder.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/ImageEncoderImpl.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/ImageEncoderImpl.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoderImpl.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoderImpl.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,97 @@
+/*
+
+ 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;
+import java.awt.image.RenderedImage;
+import java.io.IOException;
+import java.io.OutputStream;
+
+/**
+ * A partial implementation of the ImageEncoder interface useful for
+ * subclassing.
+ *
+ * <p><b> This class is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: ImageEncoderImpl.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public abstract class ImageEncoderImpl implements ImageEncoder {
+
+ /** The OutputStream associcted with this ImageEncoder. */
+ protected OutputStream output;
+
+ /** The ImageEncodeParam object associcted with this ImageEncoder. */
+ protected ImageEncodeParam param;
+
+ /**
+ * Constructs an ImageEncoderImpl with a given OutputStream
+ * and ImageEncoderParam instance.
+ */
+ public ImageEncoderImpl(OutputStream output,
+ ImageEncodeParam param) {
+ this.output = output;
+ this.param = param;
+ }
+
+ /**
+ * Returns the current parameters as an instance of the
+ * ImageEncodeParam interface. Concrete implementations of this
+ * interface will return corresponding concrete implementations of
+ * the ImageEncodeParam interface. For example, a JPEGImageEncoder
+ * will return an instance of JPEGEncodeParam.
+ */
+ public ImageEncodeParam getParam() {
+ return param;
+ }
+
+ /**
+ * 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) {
+ this.param = param;
+ }
+
+ /** Returns the OutputStream associated with this ImageEncoder. */
+ public OutputStream getOutputStream() {
+ return output;
+ }
+
+ /**
+ * 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 {
+ RenderedImage im = new SingleTileRenderedImage(ras, cm);
+ encode(im);
+ }
+
+ /**
+ * Encodes a RenderedImage and writes the output to the
+ * OutputStream associated with this ImageEncoder.
+ */
+ public abstract void encode(RenderedImage im) throws IOException;
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/ImageEncoderImpl.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/MemoryCacheSeekableStream.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/MemoryCacheSeekableStream.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/MemoryCacheSeekableStream.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/MemoryCacheSeekableStream.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,256 @@
+/*
+
+ 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.IOException;
+import java.io.InputStream;
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ * A subclass of <code>SeekableStream</code> that may be used to wrap
+ * a regular <code>InputStream</code>. Seeking backwards is supported
+ * by means of an in-memory cache. For greater efficiency,
+ * <code>FileCacheSeekableStream</code> should be used in
+ * circumstances that allow the creation of a temporary file.
+ *
+ * <p> The <code>mark()</code> and <code>reset()</code> methods are
+ * supported.
+ *
+ * <p><b> This class is not a committed part of the JAI API. It may
+ * be removed or changed in future releases of JAI.</b>
+ *
+ * @version $Id: MemoryCacheSeekableStream.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public final class MemoryCacheSeekableStream extends SeekableStream {
+
+ /** The source input stream. */
+ private InputStream src;
+
+ /** Position of first unread byte. */
+ private long pointer = 0;
+
+ /** Log_2 of the sector size. */
+ private static final int SECTOR_SHIFT = 9;
+
+ /** The sector size. */
+ private static final int SECTOR_SIZE = 1 << SECTOR_SHIFT;
+
+ /** A mask to determine the offset within a sector. */
+ private static final int SECTOR_MASK = SECTOR_SIZE - 1;
+
+ /** A Vector of source sectors. */
+ private List data = new ArrayList();
+
+ /** Number of sectors stored. */
+ int sectors = 0;
+
+ /** Number of bytes read. */
+ int length = 0;
+
+ /** True if we've previously reached the end of the source stream */
+ boolean foundEOS = false;
+
+ /**
+ * Constructs a <code>MemoryCacheSeekableStream</code> that takes
+ * its source data from a regular <code>InputStream</code>.
+ * Seeking backwards is supported by means of an in-memory cache.
+ */
+ public MemoryCacheSeekableStream(InputStream src) {
+ this.src = src;
+ }
+
+ /**
+ * Ensures that at least <code>pos</code> bytes are cached,
+ * or the end of the source is reached. The return value
+ * is equal to the smaller of <code>pos</code> and the
+ * length of the source stream.
+ */
+ private long readUntil(long pos) throws IOException {
+ // We've already got enough data cached
+ if (pos < length) {
+ return pos;
+ }
+ // pos >= length but length isn't getting any bigger, so return it
+ if (foundEOS) {
+ return length;
+ }
+
+ int sector = (int)(pos >> SECTOR_SHIFT);
+
+ // First unread sector
+ int startSector = length >> SECTOR_SHIFT;
+
+ // Read sectors until the desired sector
+ for (int i = startSector; i <= sector; i++) {
+ byte[] buf = new byte[SECTOR_SIZE];
+ data.add(buf);
+
+ // Read up to SECTOR_SIZE bytes
+ int len = SECTOR_SIZE;
+ int off = 0;
+ while (len > 0) {
+ int nbytes = src.read(buf, off, len);
+ // Found the end-of-stream
+ if (nbytes == -1) {
+ foundEOS = true;
+ return length;
+ }
+ off += nbytes;
+ len -= nbytes;
+
+ // Record new data length
+ length += nbytes;
+ }
+ }
+
+ return length;
+ }
+
+ /**
+ * Returns <code>true</code> since all
+ * <code>MemoryCacheSeekableStream</code> instances support seeking
+ * backwards.
+ */
+ public boolean canSeekBackwards() {
+ return true;
+ }
+
+ /**
+ * Returns the current offset in this file.
+ *
+ * @return the offset from the beginning of the file, in bytes,
+ * at which the next read occurs.
+ */
+ public long getFilePointer() {
+ return pointer;
+ }
+
+ /**
+ * 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
+ * pointer.
+ * @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 {
+ if (pos < 0) {
+ throw new IOException(PropertyUtil.getString("MemoryCacheSeekableStream0"));
+ }
+ pointer = pos;
+ }
+
+ /**
+ * 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.
+ *
+ * @return the next byte of data, or <code>-1</code> if the end of the
+ * stream is reached.
+ */
+ public int read() throws IOException {
+ long next = pointer + 1;
+ long pos = readUntil(next);
+ if (pos >= next) {
+ byte[] buf =
+ (byte[])data.get((int)(pointer >> SECTOR_SHIFT));
+ return buf[(int)(pointer++ & SECTOR_MASK)] & 0xff;
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * 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 file 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
+ * file, 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
+ * file, then an <code>IOException</code> is thrown. In particular, an
+ * <code>IOException</code> is thrown if the input stream has been closed.
+ *
+ * @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.
+ */
+ public int read(byte[] b, int off, int len) throws IOException {
+ if (b == null) {
+ throw new NullPointerException();
+ }
+ if ((off < 0) || (len < 0) || (off + len > b.length)) {
+ throw new IndexOutOfBoundsException();
+ }
+ if (len == 0) {
+ return 0;
+ }
+
+ long pos = readUntil(pointer + len);
+ // End-of-stream
+ if (pos <= pointer) {
+ return -1;
+ }
+
+ 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);
+ pointer += nbytes;
+ return nbytes;
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/MemoryCacheSeekableStream.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/PropertyUtil.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/PropertyUtil.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/PropertyUtil.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/PropertyUtil.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,45 @@
+/*
+
+ 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.util.MissingResourceException;
+
+import org.apache.flex.forks.batik.i18n.LocalizableSupport;
+
+/**
+ *
+ * @version $Id: PropertyUtil.java 498740 2007-01-22 18:35:57Z dvholten $
+ */
+public class PropertyUtil {
+ protected static final String RESOURCES =
+ "org.apache.flex.forks.batik.bridge.resources.properties";
+
+
+ protected static LocalizableSupport localizableSupport =
+ new LocalizableSupport
+ (RESOURCES, PropertyUtil.class.getClassLoader());
+
+ public static String getString(String key) {
+ try{
+ return localizableSupport.formatMessage(key, null);
+ }catch(MissingResourceException e){
+ return key;
+ }
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/PropertyUtil.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/SeekableOutputStream.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/SeekableOutputStream.java?rev=1402274&view=auto
==============================================================================
--- incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableOutputStream.java (added)
+++ incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableOutputStream.java Thu Oct 25 19:01:43 2012
@@ -0,0 +1,84 @@
+/*
+
+ 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.IOException;
+import java.io.OutputStream;
+import java.io.RandomAccessFile;
+
+/**
+ * An <code>OutputStream</code> which can seek to an arbitrary offset.
+ *
+ * @version $Id: SeekableOutputStream.java 478249 2006-11-22 17:29:37Z dvholten $
+ */
+public class SeekableOutputStream extends OutputStream {
+
+ private RandomAccessFile file;
+
+ /**
+ * Constructs a <code>SeekableOutputStream</code> from a
+ * <code>RandomAccessFile</code>. Unless otherwise indicated,
+ * all method invocations are fowarded to the underlying
+ * <code>RandomAccessFile</code>.
+ *
+ * @param file The <code>RandomAccessFile</code> to which calls
+ * will be forwarded.
+ * @exception IllegalArgumentException if <code>file</code> is
+ * <code>null</code>.
+ */
+ public SeekableOutputStream(RandomAccessFile file) {
+ if(file == null) {
+ throw new IllegalArgumentException("SeekableOutputStream0");
+ }
+ this.file = file;
+ }
+
+ public void write(int b) throws IOException {
+ file.write(b);
+ }
+
+ public void write(byte[] b) throws IOException {
+ file.write(b);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ file.write(b, off, len);
+ }
+
+ /**
+ * Invokes <code>getFD().sync()</code> on the underlying
+ * <code>RandomAccessFile</code>.
+ */
+ public void flush() throws IOException {
+ file.getFD().sync();
+ }
+
+ public void close() throws IOException {
+ file.close();
+ }
+
+ public long getFilePointer() throws IOException {
+ return file.getFilePointer();
+ }
+
+ public void seek(long pos) throws IOException {
+ file.seek(pos);
+ }
+}
Propchange: incubator/flex/sdk/branches/develop/modules/thirdparty/batik/sources/org/apache/flex/forks/batik/ext/awt/image/codec/util/SeekableOutputStream.java
------------------------------------------------------------------------------
svn:eol-style = native