Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 50 51 package com.lowagie.text.pdf; 52 53 64 65 public class PdfNumber extends PdfObject { 66 67 68 private double value; 69 70 72 77 78 public PdfNumber(String content) { 79 super(NUMBER); 80 try { 81 value = Double.parseDouble(content.trim()); 82 setContent(content); 83 } 84 catch (NumberFormatException nfe){ 85 throw new RuntimeException (content + " is not a valid number - " + nfe.toString()); 86 } 87 } 88 89 94 95 public PdfNumber(int value) { 96 super(NUMBER); 97 this.value = value; 98 setContent(String.valueOf(value)); 99 } 100 101 106 107 public PdfNumber(double value) { 108 super(NUMBER); 109 this.value = value; 110 setContent(ByteBuffer.formatDouble(value)); 111 } 112 113 118 119 public PdfNumber(float value) { 120 this((double)value); 121 } 122 123 125 130 131 public int intValue() { 132 return (int) value; 133 } 134 135 140 141 public double doubleValue() { 142 return value; 143 } 144 145 public float floatValue() { 146 return (float)value; 147 } 148 149 151 154 155 public void increment() { 156 value += 1.0; 157 setContent(ByteBuffer.formatDouble(value)); 158 } 159 }
| Popular Tags
|