]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Removed some unnecessary duplicate code.
authorJeremias Maerki <jeremias@apache.org>
Sun, 16 Feb 2003 12:39:49 +0000 (12:39 +0000)
committerJeremias Maerki <jeremias@apache.org>
Sun, 16 Feb 2003 12:39:49 +0000 (12:39 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@195955 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/pdf/PDFNumber.java

index deed898ac66870a5fcddf9ef5550d3657bc65858..199589def44508eeb77d5fde7f94ecf303268cbd 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $Id$
- * Copyright (C) 2001 The Apache Software Foundation. All rights reserved.
+ * Copyright (C) 2001-2003 The Apache Software Foundation. All rights reserved.
  * For details on use and redistribution please refer to the
  * LICENSE file included with these sources.
  */
@@ -9,39 +9,11 @@ package org.apache.fop.pdf;
 
 public class PDFNumber {
 
-    private PDFNumber() {}
-
     public static 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) {
-            p.append(doubleDown.intValue() + 1);
-        } else if (trouble < 0.050) {
-            p.append(doubleDown.intValue());
-        } else {
-            String doubleString = new String(doubleDown + "");
-            int decimal = doubleString.indexOf(".");
-            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));
-                }
-            } else {
-                p.append(doubleString);
-            }
-        }
-        return (p.toString());
+        return doubleOut(doubleDown.doubleValue());
     }
 
     public static String doubleOut(double doubleDown) {
-
         StringBuffer p = new StringBuffer();
         if (doubleDown < 0) {
             doubleDown = -doubleDown;
@@ -54,7 +26,7 @@ public class PDFNumber {
         } else if (trouble < 0.050) {
             p.append((int)doubleDown);
         } else {
-            String doubleString = new String(doubleDown + "");
+            String doubleString = Double.toString(doubleDown);
             int decimal = doubleString.indexOf(".");
             if (decimal != -1) {
                 p.append(doubleString.substring(0, decimal));
@@ -85,7 +57,7 @@ public class PDFNumber {
         } else if (trouble < (5.0 / (Math.pow(10.0, dec)))) {
             p.append((int)doubleDown);
         } else {
-            String doubleString = new String(doubleDown + "");
+            String doubleString = Double.toString(doubleDown);
             int decimal = doubleString.indexOf(".");
             if (decimal != -1) {
                 p.append(doubleString.substring(0, decimal));