aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/pdf/PDFNumber.java
diff options
context:
space:
mode:
authorKeiron Liddle <keiron@apache.org>2000-07-11 01:14:26 +0000
committerKeiron Liddle <keiron@apache.org>2000-07-11 01:14:26 +0000
commit674fde376ccacb669b93fbf662f7662f2bd2d5e0 (patch)
treea0ec495c5aa41b66ac94d9cdf29e2bd425ee05df /src/org/apache/fop/pdf/PDFNumber.java
parentb563a42d583b3e52541525f5e4e63bf2f4df35cb (diff)
downloadxmlgraphics-fop-674fde376ccacb669b93fbf662f7662f2bd2d5e0.tar.gz
xmlgraphics-fop-674fde376ccacb669b93fbf662f7662f2bd2d5e0.zip
handles negative numbers, same otherwise
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193470 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/org/apache/fop/pdf/PDFNumber.java')
-rw-r--r--src/org/apache/fop/pdf/PDFNumber.java48
1 files changed, 32 insertions, 16 deletions
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());