xmlgraphics-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gad...@apache.org
Subject svn commit: r1331939 - in /xmlgraphics/commons/trunk: src/java/org/apache/xmlgraphics/ps/PSGenerator.java status.xml
Date Sun, 29 Apr 2012 16:27:57 GMT
Author: gadams
Date: Sun Apr 29 16:27:56 2012
New Revision: 1331939

URL: http://svn.apache.org/viewvc?rev=1331939&view=rev
Log:
Bugzilla #43940: Use new double format utility. Submitted by Julien Aymé.

Modified:
    xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
    xmlgraphics/commons/trunk/status.xml

Modified: xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java?rev=1331939&r1=1331938&r2=1331939&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java (original)
+++ xmlgraphics/commons/trunk/src/java/org/apache/xmlgraphics/ps/PSGenerator.java Sun Apr
29 16:27:56 2012
@@ -26,10 +26,7 @@ import java.awt.geom.Rectangle2D;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
 import java.util.Date;
-import java.util.Locale;
 import java.util.Stack;
 
 import javax.xml.transform.Source;
@@ -40,6 +37,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.xmlgraphics.java2d.color.ColorUtil;
 import org.apache.xmlgraphics.java2d.color.ColorWithAlternatives;
 import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
+import org.apache.xmlgraphics.util.DoubleFormatUtil;
 
 /**
  * This class is used to output PostScript code to an OutputStream. This class assumes that
@@ -74,9 +72,8 @@ public class PSGenerator implements PSCo
 
     private Stack<PSState> graphicsStateStack = new Stack<PSState>();
     private PSState currentState;
-    //private DecimalFormat df3 = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
-    private DecimalFormat df3 = new DecimalFormat("0.###", new DecimalFormatSymbols(Locale.US));
-    private DecimalFormat df5 = new DecimalFormat("0.#####", new DecimalFormatSymbols(Locale.US));
+
+    private StringBuffer doubleBuffer = new StringBuffer(16);
 
     private StringBuffer tempBuffer = new StringBuffer(256);
 
@@ -185,7 +182,9 @@ public class PSGenerator implements PSCo
      * @return the formatted value
      */
     public String formatDouble(double value) {
-        return df3.format(value);
+        doubleBuffer.setLength(0);
+        DoubleFormatUtil.formatDouble(value, 3, 3, doubleBuffer);
+        return doubleBuffer.toString();
     }
 
     /**
@@ -195,7 +194,9 @@ public class PSGenerator implements PSCo
      * @return the formatted value
      */
     public String formatDouble5(double value) {
-        return df5.format(value);
+        doubleBuffer.setLength(0);
+        DoubleFormatUtil.formatDouble(value, 5, 5, doubleBuffer);
+        return doubleBuffer.toString();
     }
 
     /**
@@ -418,7 +419,7 @@ public class PSGenerator implements PSCo
                 } else if (params[i] == DSCConstants.ATEND) {
                     tempBuffer.append(DSCConstants.ATEND);
                 } else if (params[i] instanceof Double) {
-                    tempBuffer.append(df3.format(params[i]));
+                    tempBuffer.append(formatDouble(((Double)params[i]).doubleValue()));
                 } else if (params[i] instanceof Number) {
                     tempBuffer.append(params[i].toString());
                 } else if (params[i] instanceof Date) {

Modified: xmlgraphics/commons/trunk/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/commons/trunk/status.xml?rev=1331939&r1=1331938&r2=1331939&view=diff
==============================================================================
--- xmlgraphics/commons/trunk/status.xml (original)
+++ xmlgraphics/commons/trunk/status.xml Sun Apr 29 16:27:56 2012
@@ -41,6 +41,9 @@
   </contexts>
   <changes>
     <release version="Trunk" date="n/a">
+      <action context="Code" dev="GA" type="update" fixes-bug="43940" due-to="Julien Aymé">
+        Use new double format utility.
+      </action>
       <action context="Code" dev="GA" type="add" fixes-bug="43940" due-to="Julien Aymé">
         Add double format utility to improve thread safety and performance.
       </action>



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: commits-help@xmlgraphics.apache.org


Mime
View raw message