]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
handles negative numbers, same otherwise
authorKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 01:14:26 +0000 (01:14 +0000)
committerKeiron Liddle <keiron@apache.org>
Tue, 11 Jul 2000 01:14:26 +0000 (01:14 +0000)
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

index 6dc9cbdba0f80ad548df0a0cab297070fd2daf9c..c1774a5cb8c5022683e0117a7b735ddfd81aa90a 100644 (file)
@@ -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());