From 674fde376ccacb669b93fbf662f7662f2bd2d5e0 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 11 Jul 2000 01:14:26 +0000 Subject: handles negative numbers, same otherwise git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193470 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/pdf/PDFNumber.java | 48 +++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 16 deletions(-) (limited to 'src/org/apache/fop/pdf/PDFNumber.java') diff --git a/src/org/apache/fop/pdf/PDFNumber.java b/src/org/apache/fop/pdf/PDFNumber.java index 6dc9cbdba..c1774a5cb 100644 --- a/src/org/apache/fop/pdf/PDFNumber.java +++ b/src/org/apache/fop/pdf/PDFNumber.java @@ -64,6 +64,10 @@ public class PDFNumber { public String doubleOut(Double doubleDown) { StringBuffer p = new StringBuffer(); + if(doubleDown.doubleValue() < 0) { + doubleDown = new Double(-doubleDown.doubleValue()); + p.append("-"); + } double trouble = doubleDown.doubleValue() % 1; if(trouble > 0.950) { @@ -77,15 +81,19 @@ public class PDFNumber { { String doubleString = new String(doubleDown+""); int decimal = doubleString.indexOf("."); - p.append(doubleString.substring(0, decimal)); + if(decimal != -1) { + p.append(doubleString.substring(0, decimal)); - if ((doubleString.length() - decimal) > 6) - { - p.append(doubleString.substring(decimal,decimal+6)); - } - else - { - p.append(doubleString.substring(decimal)); + if ((doubleString.length() - decimal) > 6) + { + p.append(doubleString.substring(decimal,decimal+6)); + } + else + { + p.append(doubleString.substring(decimal)); + } + } else { + p.append(doubleString); } } return(p.toString()); @@ -95,6 +103,10 @@ public class PDFNumber { { StringBuffer p = new StringBuffer(); + if(doubleDown < 0) { + doubleDown = -doubleDown; + p.append("-"); + } double trouble = doubleDown % 1; if(trouble > 0.950) @@ -109,15 +121,19 @@ public class PDFNumber { { String doubleString = new String(doubleDown+""); int decimal = doubleString.indexOf("."); - p.append(doubleString.substring(0, decimal)); + if(decimal != -1) { + p.append(doubleString.substring(0, decimal)); - if ((doubleString.length() - decimal) > 6) - { - p.append(doubleString.substring(decimal,decimal+6)); - } - else - { - p.append(doubleString.substring(decimal)); + if ((doubleString.length() - decimal) > 6) + { + p.append(doubleString.substring(decimal,decimal+6)); + } + else + { + p.append(doubleString.substring(decimal)); + } + } else { + p.append(doubleString); } } return(p.toString()); -- cgit v1.2.3