aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf/PDFNumber.java
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2013-01-16 23:43:53 +0000
committerGlenn Adams <gadams@apache.org>2013-01-16 23:43:53 +0000
commit3a520dbe96e9ca54e9552b3f95b56edca6260884 (patch)
treecc092f57fc0cac53097721ee48798246753ba3da /src/java/org/apache/fop/pdf/PDFNumber.java
parenta4bea91e0dafb96d904f82a1abbb6605fedd9e56 (diff)
downloadxmlgraphics-fop-3a520dbe96e9ca54e9552b3f95b56edca6260884.tar.gz
xmlgraphics-fop-3a520dbe96e9ca54e9552b3f95b56edca6260884.zip
FOP-2188: optimize string allocation in pdf output processing
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1434502 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFNumber.java')
-rw-r--r--src/java/org/apache/fop/pdf/PDFNumber.java18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFNumber.java b/src/java/org/apache/fop/pdf/PDFNumber.java
index e638a51b1..1c31f8e9d 100644
--- a/src/java/org/apache/fop/pdf/PDFNumber.java
+++ b/src/java/org/apache/fop/pdf/PDFNumber.java
@@ -83,6 +83,24 @@ public class PDFNumber extends PDFObject {
return buf.toString();
}
+ /**
+ * Append a double value to a string buffer suitable for PDF.
+ * In this method it is possible to set the maximum
+ * number of decimal places to output.
+ *
+ * @param doubleDown the Double value
+ * @param dec the number of decimal places to output
+ * @param buf the string buffer to which double is formatted (appended)
+ * @return the string buffer
+ */
+ public static StringBuffer doubleOut(double doubleDown, int dec, StringBuffer buf) {
+ if (dec < 0 || dec > 16) {
+ throw new IllegalArgumentException("Parameter dec must be between 1 and 16");
+ }
+ DoubleFormatUtil.formatDouble(doubleDown, dec, dec, buf);
+ return buf;
+ }
+
/** {@inheritDoc} */
protected String toPDFString() {
if (getNumber() == null) {