aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/util
diff options
context:
space:
mode:
authorAdrian Cumiskey <acumiskey@apache.org>2008-08-26 09:10:19 +0000
committerAdrian Cumiskey <acumiskey@apache.org>2008-08-26 09:10:19 +0000
commitc0227d2e2ef00b0193062df4f6d6e56ba211c51c (patch)
treebcc7d3ff1b6c19bc4e9a19c8849006e261aff553 /src/java/org/apache/fop/util
parent0f20fb70bc3c4e6f7f3c58f3a9afc1e884769cea (diff)
downloadxmlgraphics-fop-c0227d2e2ef00b0193062df4f6d6e56ba211c51c.tar.gz
xmlgraphics-fop-c0227d2e2ef00b0193062df4f6d6e56ba211c51c.zip
Merged revisions 687576,687657,687786,688078,688087,688139,688508,688633,688652-688653,688660,688664,688666,688674,688698,688994,689000 via svnmerge from
https://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r687576 | maxberger | 2008-08-21 07:25:40 +0100 (Thu, 21 Aug 2008) | 1 line Included patched retroweaver which does not modify Boolean.valueOf ........ r687657 | jeremias | 2008-08-21 09:51:50 +0100 (Thu, 21 Aug 2008) | 1 line Added an FAQ entry about the element mismatch error message. ........ r687786 | jeremias | 2008-08-21 16:49:13 +0100 (Thu, 21 Aug 2008) | 1 line Added some performance statistics to MemoryEater. ........ r688078 | jeremias | 2008-08-22 14:02:37 +0100 (Fri, 22 Aug 2008) | 1 line Final statistics output after the test with average speed indication. ........ r688087 | jeremias | 2008-08-22 15:16:58 +0100 (Fri, 22 Aug 2008) | 2 lines Merge from branch https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_95: Fixed text stroking in SVG when the stroke-width is zero. ........ r688139 | maxberger | 2008-08-22 19:08:36 +0100 (Fri, 22 Aug 2008) | 1 line minor spelling mistakes ........ r688508 | maxberger | 2008-08-24 14:12:02 +0100 (Sun, 24 Aug 2008) | 2 lines Moved DataURIResolver from FOP to commons; use new URIResolver registry ........ r688633 | jeremias | 2008-08-25 07:42:44 +0100 (Mon, 25 Aug 2008) | 2 lines Fixed memory leak in property cache (not cleaning stale PropertyCache$CacheEntry instances). Special thanks to Andreas Delmelle for his help! ........ r688652 | maxberger | 2008-08-25 09:19:13 +0100 (Mon, 25 Aug 2008) | 1 line Re-added moved class as deprecated ........ r688653 | jeremias | 2008-08-25 09:23:31 +0100 (Mon, 25 Aug 2008) | 1 line Added a page on metadata (partly ported from the FOP Wiki). ........ r688660 | jeremias | 2008-08-25 09:41:29 +0100 (Mon, 25 Aug 2008) | 2 lines Fixed example. Thanks for noticing, Pascal Sancho! ........ r688664 | jeremias | 2008-08-25 09:59:27 +0100 (Mon, 25 Aug 2008) | 1 line Minor documentation improvements, most notably a comment about keep-together="always". ........ r688666 | maxberger | 2008-08-25 10:00:27 +0100 (Mon, 25 Aug 2008) | 1 line CommonURIResolver is no longer a singleton ........ r688674 | jeremias | 2008-08-25 10:15:22 +0100 (Mon, 25 Aug 2008) | 1 line Hmm, I missed the redirects for the 0.95 release. ........ r688698 | jeremias | 2008-08-25 12:24:15 +0100 (Mon, 25 Aug 2008) | 2 lines Merge from 0.95 branch: Fixed jar-sources target. ........ r688994 | acumiskey | 2008-08-26 09:34:45 +0100 (Tue, 26 Aug 2008) | 1 line Deprecate UnitConv now that it resides only in xmlgraphics commons. ........ r689000 | acumiskey | 2008-08-26 09:59:31 +0100 (Tue, 26 Aug 2008) | 1 line Forgot to add deprecated public statics. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@689005 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/util')
-rw-r--r--src/java/org/apache/fop/util/DataURIResolver.java51
-rw-r--r--src/java/org/apache/fop/util/DataURLUtil.java46
-rw-r--r--src/java/org/apache/fop/util/UnitConv.java170
-rw-r--r--src/java/org/apache/fop/util/WriterOutputStream.java54
4 files changed, 223 insertions, 98 deletions
diff --git a/src/java/org/apache/fop/util/DataURIResolver.java b/src/java/org/apache/fop/util/DataURIResolver.java
index 89db6dc9d..99a8318c8 100644
--- a/src/java/org/apache/fop/util/DataURIResolver.java
+++ b/src/java/org/apache/fop/util/DataURIResolver.java
@@ -19,60 +19,25 @@
package org.apache.fop.util;
-import java.io.ByteArrayInputStream;
-
import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
import javax.xml.transform.URIResolver;
-import javax.xml.transform.stream.StreamSource;
-
-// base64 support for "data" urls
-import org.apache.xmlgraphics.util.io.Base64DecodeStream;
/**
- * Resolves data URLs (described in RFC 2397) returning its data as a StreamSource.
- *
- * @see javax.xml.transform.URIResolver
- * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURIResolver
*/
public class DataURIResolver implements URIResolver {
- /**
- * {@inheritDoc}
- */
- public Source resolve(String href, String base) throws TransformerException {
- if (href.startsWith("data:")) {
- return parseDataURI(href);
- } else {
- return null;
- }
- }
+ private final URIResolver newResolver = new org.apache.xmlgraphics.util.uri.DataURIResolver();
/**
- * Parses inline data URIs as generated by MS Word's XML export and FO
- * stylesheet.
- *
- * @see <a href="http://www.ietf.org/rfc/rfc2397">RFC 2397</a>
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURIResolver#resolve(String,
+ * String)
*/
- private Source parseDataURI(String href) {
- int commaPos = href.indexOf(',');
- // header is of the form data:[<mediatype>][;base64]
- String header = href.substring(0, commaPos);
- String data = href.substring(commaPos + 1);
- if (header.endsWith(";base64")) {
- byte[] bytes = data.getBytes();
- ByteArrayInputStream encodedStream = new ByteArrayInputStream(bytes);
- Base64DecodeStream decodedStream = new Base64DecodeStream(
- encodedStream);
- return new StreamSource(decodedStream);
- } else {
- // Note that this is not quite the full story here. But since we are
- // only interested
- // in base64-encoded binary data, the next line will probably never
- // be called.
- //TODO Handle un-escaping of special URL chars like %20
- return new StreamSource(new java.io.StringReader(data));
- }
+ public Source resolve(String href, String base) throws TransformerException {
+ return newResolver.resolve(href, base);
}
}
diff --git a/src/java/org/apache/fop/util/DataURLUtil.java b/src/java/org/apache/fop/util/DataURLUtil.java
index d8f7f17bf..8568df274 100644
--- a/src/java/org/apache/fop/util/DataURLUtil.java
+++ b/src/java/org/apache/fop/util/DataURLUtil.java
@@ -21,47 +21,33 @@ package org.apache.fop.util;
import java.io.IOException;
import java.io.InputStream;
-import java.io.StringWriter;
import java.io.Writer;
-import org.apache.commons.io.IOUtils;
-import org.apache.xmlgraphics.util.io.Base64EncodeStream;
-
/**
- * Utility classes for generating RFC 2397 data URLs.
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil
*/
public class DataURLUtil {
/**
- * Creates a new data URL and returns it as a String.
- * @param in the InputStream to read the data from
- * @param mediatype the MIME type of the content, or null
- * @return the newly created data URL
- * @throws IOException if an I/O error occurs
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil#createDataURL(InputStream,
+ * String)
*/
- public static String createDataURL(InputStream in, String mediatype) throws IOException {
- StringWriter writer = new StringWriter();
- writeDataURL(in, mediatype, writer);
- return writer.toString();
+ public static String createDataURL(InputStream in, String mediatype)
+ throws IOException {
+ return org.apache.xmlgraphics.util.uri.DataURLUtil.createDataURL(in,
+ mediatype);
}
/**
- * Generates a data URL and writes it to a Writer.
- * @param in the InputStream to read the data from
- * @param mediatype the MIME type of the content, or null
- * @param writer the Writer to write to
- * @throws IOException if an I/O error occurs
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.uri.DataURLUtil#writeDataURL(InputStream,
+ * String, Writer)
*/
- public static void writeDataURL(InputStream in, String mediatype, Writer writer)
- throws IOException {
- writer.write("data:");
- if (mediatype != null) {
- writer.write(mediatype);
- }
- writer.write(";base64,");
- Base64EncodeStream out = new Base64EncodeStream(
- new WriterOutputStream(writer, "US-ASCII"));
- IOUtils.copy(in, out);
- out.flush();
+ public static void writeDataURL(InputStream in, String mediatype,
+ Writer writer) throws IOException {
+ org.apache.xmlgraphics.util.uri.DataURLUtil.writeDataURL(in, mediatype,
+ writer);
}
}
diff --git a/src/java/org/apache/fop/util/UnitConv.java b/src/java/org/apache/fop/util/UnitConv.java
new file mode 100644
index 000000000..cf599712f
--- /dev/null
+++ b/src/java/org/apache/fop/util/UnitConv.java
@@ -0,0 +1,170 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id: $ */
+
+package org.apache.fop.util;
+
+import java.awt.geom.AffineTransform;
+
+/**
+ * Utility class for unit conversions.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv instead.
+ */
+public final class UnitConv {
+
+ /**
+ * conversion factory from millimeters to inches.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2MM instead.
+ */
+ public static final float IN2MM = org.apache.xmlgraphics.util.UnitConv.IN2MM;
+
+ /**
+ * conversion factory from centimeters to inches.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2CM instead.
+ */
+ public static final float IN2CM = org.apache.xmlgraphics.util.UnitConv.IN2CM;
+
+ /**
+ * conversion factory from inches to points.
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.IN2PT instead.
+ */
+ public static final int IN2PT = org.apache.xmlgraphics.util.UnitConv.IN2PT;
+
+ /**
+ * Converts millimeters (mm) to points (pt)
+ * @param mm the value in mm
+ * @return the value in pt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2pt(mm) instead.
+ */
+ public static double mm2pt(double mm) {
+ return org.apache.xmlgraphics.util.UnitConv.mm2pt(mm);
+ }
+
+ /**
+ * Converts millimeters (mm) to millipoints (mpt)
+ * @param mm the value in mm
+ * @return the value in mpt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2mpt(mm) instead.
+ */
+ public static double mm2mpt(double mm) {
+ return org.apache.xmlgraphics.util.UnitConv.mm2mpt(mm);
+ }
+
+ /**
+ * Converts points (pt) to millimeters (mm)
+ * @param pt the value in pt
+ * @return the value in mm
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.pt2mm(pt) instead.
+ */
+ public static double pt2mm(double pt) {
+ return org.apache.xmlgraphics.util.UnitConv.pt2mm(pt);
+ }
+
+ /**
+ * Converts millimeters (mm) to inches (in)
+ * @param mm the value in mm
+ * @return the value in inches
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.pt2mm(pt) instead.
+ */
+ public static double mm2in(double mm) {
+ return org.apache.xmlgraphics.util.UnitConv.mm2in(mm);
+ }
+
+ /**
+ * Converts inches (in) to millimeters (mm)
+ * @param in the value in inches
+ * @return the value in mm
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2mm(in) instead.
+ */
+ public static double in2mm(double in) {
+ return org.apache.xmlgraphics.util.UnitConv.in2mm(in);
+ }
+
+ /**
+ * Converts inches (in) to millipoints (mpt)
+ * @param in the value in inches
+ * @return the value in mpt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2mpt(in) instead.
+ */
+ public static double in2mpt(double in) {
+ return org.apache.xmlgraphics.util.UnitConv.in2mpt(in);
+ }
+
+ /**
+ * Converts inches (in) to points (pt)
+ * @param in the value in inches
+ * @return the value in pt
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.in2pt(in) instead.
+ */
+ public static double in2pt(double in) {
+ return org.apache.xmlgraphics.util.UnitConv.in2pt(in);
+ }
+
+ /**
+ * Converts millipoints (mpt) to inches (in)
+ * @param mpt the value in mpt
+ * @return the value in inches
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mpt2in(mpt) instead.
+ */
+ public static double mpt2in(double mpt) {
+ return org.apache.xmlgraphics.util.UnitConv.mpt2in(mpt);
+ }
+
+ /**
+ * Converts millimeters (mm) to pixels (px)
+ * @param mm the value in mm
+ * @param resolution the resolution in dpi (dots per inch)
+ * @return the value in pixels
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mm2px(mm, resolution) instead.
+ */
+ public static double mm2px(double mm, int resolution) {
+ return org.apache.xmlgraphics.util.UnitConv.mm2px(mm, resolution);
+ }
+
+ /**
+ * Converts millipoints (mpt) to pixels (px)
+ * @param mpt the value in mpt
+ * @param resolution the resolution in dpi (dots per inch)
+ * @return the value in pixels
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mpt2px(mpt, resolution) instead.
+ */
+ public static double mpt2px(double mpt, int resolution) {
+ return org.apache.xmlgraphics.util.UnitConv.mpt2px(mpt, resolution);
+ }
+
+ /**
+ * Converts a millipoint-based transformation matrix to points.
+ * @param at a millipoint-based transformation matrix
+ * @return a point-based transformation matrix
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.mptToPt(at) instead.
+ */
+ public static AffineTransform mptToPt(AffineTransform at) {
+ return org.apache.xmlgraphics.util.UnitConv.mptToPt(at);
+ }
+
+ /**
+ * Converts a point-based transformation matrix to millipoints.
+ * @param at a point-based transformation matrix
+ * @return a millipoint-based transformation matrix
+ * @deprecated use org.apache.xmlgraphics.util.UnitConv.ptToMpt(at) instead.
+ */
+ public static AffineTransform ptToMpt(AffineTransform at) {
+ return org.apache.xmlgraphics.util.UnitConv.ptToMpt(at);
+ }
+
+}
diff --git a/src/java/org/apache/fop/util/WriterOutputStream.java b/src/java/org/apache/fop/util/WriterOutputStream.java
index fb6875498..e08109ab0 100644
--- a/src/java/org/apache/fop/util/WriterOutputStream.java
+++ b/src/java/org/apache/fop/util/WriterOutputStream.java
@@ -24,68 +24,72 @@ import java.io.OutputStream;
import java.io.Writer;
/**
- * An OutputStream wrapper for a Writer.
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream
*/
public class WriterOutputStream extends OutputStream {
- private Writer writer;
- private String encoding;
+ private final org.apache.xmlgraphics.util.WriterOutputStream writerOutputStream;
/**
- * Creates a new WriterOutputStream.
- * @param writer the Writer to write to
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer)
+ * String)
*/
public WriterOutputStream(Writer writer) {
- this(writer, null);
+ writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
+ writer);
}
/**
- * Creates a new WriterOutputStream.
- * @param writer the Writer to write to
- * @param encoding the encoding to use, or null if the default encoding should be used
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#WriterOutputStream(Writer,
+ * String) String)
*/
public WriterOutputStream(Writer writer, String encoding) {
- this.writer = writer;
- this.encoding = encoding;
+ writerOutputStream = new org.apache.xmlgraphics.util.WriterOutputStream(
+ writer, encoding);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#close()
*/
public void close() throws IOException {
- writer.close();
+ writerOutputStream.close();
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#flush()
*/
public void flush() throws IOException {
- writer.flush();
+ writerOutputStream.flush();
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[], int,
+ * int)
*/
public void write(byte[] buf, int offset, int length) throws IOException {
- if (encoding != null) {
- writer.write(new String(buf, offset, length, encoding));
- } else {
- writer.write(new String(buf, offset, length));
- }
+ writerOutputStream.write(buf, offset, length);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(byte[])
*/
public void write(byte[] buf) throws IOException {
- write(buf, 0, buf.length);
+ writerOutputStream.write(buf);
}
/**
- * {@inheritDoc}
+ * @deprecated
+ * @see org.apache.xmlgraphics.util.WriterOutputStream#write(int)
*/
public void write(int b) throws IOException {
- write(new byte[] {(byte)b});
+ writerOutputStream.write(b);
}
}