View | Details | Raw Unified | Return to bug 43940
Collapse All | Expand All

(-)PSGenerator.java (-9 / +10 lines)
Lines 26-40 Link Here
26
import java.io.IOException;
26
import java.io.IOException;
27
import java.io.OutputStream;
27
import java.io.OutputStream;
28
import java.text.DateFormat;
28
import java.text.DateFormat;
29
import java.text.DecimalFormat;
30
import java.text.DecimalFormatSymbols;
31
import java.util.Date;
29
import java.util.Date;
32
import java.util.Locale;
33
import java.util.Stack;
30
import java.util.Stack;
34
31
35
import javax.xml.transform.Source;
32
import javax.xml.transform.Source;
36
33
37
import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
34
import org.apache.xmlgraphics.ps.dsc.ResourceTracker;
35
import org.apache.xmlgraphics.util.DoubleFormatUtil;
38
36
39
/**
37
/**
40
 * This class is used to output PostScript code to an OutputStream. This class assumes that
38
 * This class is used to output PostScript code to an OutputStream. This class assumes that
Lines 67-76 Link Here
67
65
68
    private Stack graphicsStateStack = new Stack();
66
    private Stack graphicsStateStack = new Stack();
69
    private PSState currentState;
67
    private PSState currentState;
70
    //private DecimalFormat df3 = new DecimalFormat("0.000", new DecimalFormatSymbols(Locale.US));
71
    private DecimalFormat df3 = new DecimalFormat("0.###", new DecimalFormatSymbols(Locale.US));
72
    private DecimalFormat df5 = new DecimalFormat("0.#####", new DecimalFormatSymbols(Locale.US));
73
68
69
    private StringBuffer doubleBuffer = new StringBuffer(16);
70
74
    private StringBuffer tempBuffer = new StringBuffer(256);
71
    private StringBuffer tempBuffer = new StringBuffer(256);
75
72
76
    /**
73
    /**
Lines 178-184 Link Here
178
     * @return the formatted value
175
     * @return the formatted value
179
     */
176
     */
180
    public String formatDouble(double value) {
177
    public String formatDouble(double value) {
181
        return df3.format(value);
178
        doubleBuffer.setLength(0);
179
        DoubleFormatUtil.formatDouble(value, 3, 3, doubleBuffer);
180
        return doubleBuffer.toString();
182
    }
181
    }
183
182
184
    /**
183
    /**
Lines 188-194 Link Here
188
     * @return the formatted value
187
     * @return the formatted value
189
     */
188
     */
190
    public String formatDouble5(double value) {
189
    public String formatDouble5(double value) {
191
        return df5.format(value);
190
        doubleBuffer.setLength(0);
191
        DoubleFormatUtil.formatDouble(value, 5, 5, doubleBuffer);
192
        return doubleBuffer.toString();
192
    }
193
    }
193
194
194
    /**
195
    /**
Lines 411-417 Link Here
411
                } else if (params[i] == DSCConstants.ATEND) {
412
                } else if (params[i] == DSCConstants.ATEND) {
412
                    tempBuffer.append(DSCConstants.ATEND);
413
                    tempBuffer.append(DSCConstants.ATEND);
413
                } else if (params[i] instanceof Double) {
414
                } else if (params[i] instanceof Double) {
414
                    tempBuffer.append(df3.format(params[i]));
415
                    tempBuffer.append(formatDouble(((Double)params[i]).doubleValue()));
415
                } else if (params[i] instanceof Number) {
416
                } else if (params[i] instanceof Number) {
416
                    tempBuffer.append(params[i].toString());
417
                    tempBuffer.append(params[i].toString());
417
                } else if (params[i] instanceof Date) {
418
                } else if (params[i] instanceof Date) {

Return to bug 43940