KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > it > stefanochizzolini > clown > objects > PdfReal


1 /*
2   Copyright © 2006 Stefano Chizzolini. http://clown.stefanochizzolini.it
3
4   Contributors:
5     * Stefano Chizzolini (original code developer, info@stefanochizzolini.it):
6       contributed code is Copyright © 2006 by Stefano Chizzolini.
7
8   This file should be part of the source code distribution of "PDF Clown library"
9   (the Program): see the accompanying README files for more info.
10
11   This Program is free software; you can redistribute it and/or modify it under
12   the terms of the GNU General Public License as published by the Free Software
13   Foundation; either version 2 of the License, or (at your option) any later version.
14
15   This Program is distributed in the hope that it will be useful, but WITHOUT ANY
16   WARRANTY, either expressed or implied; without even the implied warranty of
17   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more details.
18
19   You should have received a copy of the GNU General Public License along with this
20   Program (see README files); if not, go to the GNU website (http://www.gnu.org/).
21
22   Redistribution and use, with or without modification, are permitted provided that such
23   redistributions retain the above copyright notice, license and disclaimer, along with
24   this list of conditions.
25 */

26
27 package it.stefanochizzolini.clown.objects;
28
29 import it.stefanochizzolini.clown.files.File;
30 import java.text.DecimalFormat JavaDoc;
31 import java.text.DecimalFormatSymbols JavaDoc;
32
33 /**
34   PDF real number object.
35 */

36 public class PdfReal
37   extends PdfAtomicObject<Double JavaDoc>
38   implements IPdfNumber
39 {
40   // <class>
41
// <static>
42
// <fields>
43
protected static final DecimalFormat JavaDoc formatter;
44   // </fields>
45

46   // <constructors>
47
static
48   {
49     DecimalFormatSymbols JavaDoc symbols = new DecimalFormatSymbols JavaDoc();
50     symbols.setDecimalSeparator('.');
51     formatter = new DecimalFormat JavaDoc("0.#####",symbols);
52   }
53   // </constructors>
54

55   // <interface>
56
// <public>
57
public static String JavaDoc toPdf(
58     double value
59     )
60   {return formatter.format(value);}
61   // </public>
62
// </interface>
63
// </static>
64

65   // <dynamic>
66
// <constructors>
67
public PdfReal(
68     double value
69     )
70   {setValue(value);}
71   // </constructors>
72

73   // <iterface>
74
// <public>
75
@Override JavaDoc
76   public Object JavaDoc clone(
77     File context
78     )
79   {
80     // Shallow copy.
81
PdfReal clone = (PdfReal)super.clone();
82
83     // Deep copy.
84
/* NOTE: No mutable object to be cloned. */
85
86     return clone;
87   }
88
89   @Override JavaDoc
90   public String JavaDoc toPdf(
91     )
92   {return PdfReal.toPdf(getValue());}
93
94   // <IPdfNumber>
95
public double getNumberValue(
96     )
97   {return getValue();}
98
99   public void setNumberValue(
100     double value
101     )
102   {setValue(value);}
103
104   public void translateNumberValue(
105     double value
106     )
107   {setValue(getValue() + value);}
108   // </IPdfNumber>
109
// </public>
110
// </interface>
111
// </class>
112
}
Popular Tags